Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CNS-578: small fixes for init chain scripts #720

Merged
merged 7 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions scripts/init_chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,46 @@
# make install-all
killall -9 lavad

# Function to check if a command is available
command_exists() {
command -v "$1" >/dev/null 2>&1
}

# Flag to track if jq installation is successful
jq_installed=false

# Check if jq is not installed
if ! command_exists jq; then
Yaroms marked this conversation as resolved.
Show resolved Hide resolved
# Try to install jq using apt (for Debian/Ubuntu)
if command_exists apt; then
echo "Installing jq using apt..."
sudo apt update
sudo apt install -y jq
if command_exists jq; then
echo "jq has been successfully installed."
jq_installed=true
fi
fi

# Try to install jq using brew (for macOS)
if ! $jq_installed && command_exists brew; then
echo "Installing jq using brew..."
brew install jq
if command_exists jq; then
echo "jq has been successfully installed."
jq_installed=true
fi
fi
else
jq_installed=true
fi

# if jq is still not installed, exit
if ! $jq_installed; then
echo "Unable to install jq using apt or brew. Please install jq manually."
exit 1
fi

rm -rf ~/.lava
lavad init validator --chain-id lava
lavad config broadcast-mode sync
Expand Down
6 changes: 3 additions & 3 deletions scripts/init_chain_commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GASPRICE="0.000000001ulava"
# ,./cookbook/specs/spec_add_mantle.json

lavad tx gov submit-legacy-proposal spec-add ./cookbook/specs/spec_add_ibc.json,./cookbook/specs/spec_add_cosmoswasm.json,./cookbook/specs/spec_add_cosmossdk.json,./cookbook/specs/spec_add_cosmossdk_full.json,./cookbook/specs/spec_add_ethereum.json,./cookbook/specs/spec_add_cosmoshub.json,./cookbook/specs/spec_add_lava.json,./cookbook/specs/spec_add_osmosis.json,./cookbook/specs/spec_add_fantom.json,./cookbook/specs/spec_add_celo.json,./cookbook/specs/spec_add_optimism.json,./cookbook/specs/spec_add_arbitrum.json,./cookbook/specs/spec_add_starknet.json,./cookbook/specs/spec_add_aptos.json,./cookbook/specs/spec_add_juno.json,./cookbook/specs/spec_add_polygon.json,./cookbook/specs/spec_add_evmos.json,./cookbook/specs/spec_add_base.json,./cookbook/specs/spec_add_canto.json,./cookbook/specs/spec_add_sui.json,./cookbook/specs/spec_add_solana.json,./cookbook/specs/spec_add_bsc.json,./cookbook/specs/spec_add_axelar.json,./cookbook/specs/spec_add_avalanche.json,./cookbook/specs/spec_add_fvm.json -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE &
wait_next_block
wait_two_blocks
echo "submitted first proposal"
lavad tx gov vote 1 yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE &
wait_next_block
Expand All @@ -19,7 +19,7 @@ sleep 4


lavad tx gov submit-legacy-proposal plans-add ./cookbook/plans/default.json,./cookbook/plans/temporary-add.json -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE
wait_next_block
wait_two_blocks
lavad tx gov vote 2 yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE
wait_next_block

Expand All @@ -33,7 +33,7 @@ PROVIDER3_LISTENER="127.0.0.1:2223"
sleep 4

lavad tx gov submit-legacy-proposal plans-del ./cookbook/plans/temporary-del.json -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE
wait_next_block
wait_two_blocks
lavad tx gov vote 3 yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE
wait_next_block
lavad tx subscription buy DefaultPlan $(lavad keys show user1 -a) -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE
Expand Down
16 changes: 16 additions & 0 deletions scripts/useful_commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ function wait_next_block {
break
fi
done
}

function wait_two_blocks {
Yaroms marked this conversation as resolved.
Show resolved Hide resolved
current=$( lavad q block | jq -r .block.header.height)
currentNum=$(($current))
echo "Waiting for two blocks"
while true; do
sleep 0.5
new=$( lavad q block | jq -r .block.header.height)
newNum=$(($new))
if [[ $((newNum - current)) -ge 2 ]]
then
echo "finished waiting for two blocks"
break
fi
done
}