From 16c0213a625c7bed54c3b28104596cb767d9c09f Mon Sep 17 00:00:00 2001 From: kienn6034 Date: Wed, 24 Apr 2024 18:12:42 +0700 Subject: [PATCH] fix: scripts to deploy pica node --- Makefile | 5 +- scripts/upgrade/localnode.sh | 69 ++++++++++++++ scripts/upgrade/old-node-scripts.sh | 2 +- ...taurid-node.sh => setup-old-picad-node.sh} | 8 +- scripts/upgrade/v6_to_7/post_08_wasm.sh | 19 ---- scripts/upgrade/v6_to_7/pre_08_wasm.sh | 18 ---- .../v_6_4_8/post-script-ibc-transfer.sh | 40 -------- scripts/upgrade/v_6_4_8/post-script.sh | 91 ------------------- .../v_6_4_8/pre-script-ibc-transfer.sh | 35 ------- .../{v_6_4_8 => v_6_6_0}/pre-script.sh | 0 .../{v_6_4_8 => v_6_6_0}/setup-08-wasm.sh | 2 +- 11 files changed, 78 insertions(+), 211 deletions(-) create mode 100755 scripts/upgrade/localnode.sh rename scripts/upgrade/{setup-old-centaurid-node.sh => setup-old-picad-node.sh} (55%) delete mode 100644 scripts/upgrade/v6_to_7/post_08_wasm.sh delete mode 100644 scripts/upgrade/v6_to_7/pre_08_wasm.sh delete mode 100755 scripts/upgrade/v_6_4_8/post-script-ibc-transfer.sh delete mode 100644 scripts/upgrade/v_6_4_8/post-script.sh delete mode 100755 scripts/upgrade/v_6_4_8/pre-script-ibc-transfer.sh rename scripts/upgrade/{v_6_4_8 => v_6_6_0}/pre-script.sh (100%) rename scripts/upgrade/{v_6_4_8 => v_6_6_0}/setup-08-wasm.sh (96%) diff --git a/Makefile b/Makefile index e5852b568..3e4a5879f 100644 --- a/Makefile +++ b/Makefile @@ -167,7 +167,6 @@ test-upgrade: clean-testing-data clean-testing-data: @echo "Killing binary and removing previous data" - -@pkill centaurid 2>/dev/null -@pkill picad 2>/dev/null -@pkill rly 2>/dev/null -@rm -rf ./mytestnet @@ -192,9 +191,9 @@ init-deps: @echo "Installing dependencies" bash ./scripts/upgrade/init-deps.sh -localnet-centauri: +localnet-pica: @echo "Starting localnet" - bash ./scripts/upgrade/setup-old-centaurid-node.sh + bash ./scripts/upgrade/setup-old-picad-node.sh localnet-picasso: @echo "Starting localnet" diff --git a/scripts/upgrade/localnode.sh b/scripts/upgrade/localnode.sh new file mode 100755 index 000000000..50f19174c --- /dev/null +++ b/scripts/upgrade/localnode.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +KEY="mykey" +KEY1="mykey1" +CHAINID="centauri-dev" +MONIKER="localtestnet" +KEYALGO="secp256k1" +KEYRING="test" +LOGLEVEL="info" +BINARY=$1 +# to trace evm +#TRACE="--trace" +TRACE="" + +HOME_DIR=mytestnet +DENOM=ppica + + +if [ "$CONTINUE" == "true" ]; then + echo "\n ->> continuing from previous state" + $BINARY start --home $HOME_DIR --log_level debug + exit 0 +fi + +$BINARY config keyring-backend $KEYRING +$BINARY config chain-id $CHAINID + +# remove existing daemon +rm -rf $HOME_DIR + +# if $KEY exists it should be deleted +echo "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry" | $BINARY keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO --recover --home $HOME_DIR +echo "bottom loan skill merry east cradle onion journey palm apology verb edit desert impose absurd oil bubble sweet glove shallow size build burst effort" | $BINARY keys add $KEY1 --keyring-backend $KEYRING --algo $KEYALGO --recover --home $HOME_DIR +$BINARY init $CHAINID --chain-id $CHAINID --default-denom "ppica" --home $HOME_DIR + +update_test_genesis () { + # update_test_genesis '.consensus_params["block"]["max_gas"]="100000000"' + cat $HOME_DIR/config/genesis.json | jq "$1" > $HOME_DIR/config/tmp_genesis.json && cp $HOME_DIR/config/tmp_genesis.json $HOME_DIR/config/genesis.json +} + +# Allocate genesis accounts (cosmos formatted addresses) +$BINARY add-genesis-account $KEY 100000000000000000000000000ppica --keyring-backend $KEYRING --home $HOME_DIR +$BINARY add-genesis-account $KEY1 100000000000000000000000000ppica --keyring-backend $KEYRING --home $HOME_DIR + +# Sign genesis transaction +$BINARY gentx $KEY 10030009994127689ppica --keyring-backend $KEYRING --chain-id $CHAINID --home $HOME_DIR + +update_test_genesis '.app_state["gov"]["params"]["voting_period"]="5s"' +update_test_genesis '.app_state["mint"]["params"]["mint_denom"]="'$DENOM'"' +update_test_genesis '.app_state["gov"]["params"]["min_deposit"]=[{"denom":"'$DENOM'","amount": "1"}]' +update_test_genesis '.app_state["crisis"]["constant_fee"]={"denom":"'$DENOM'","amount":"1000"}' + +# Collect genesis tx +$BINARY collect-gentxs --home $HOME_DIR + +# Run this to ensure everything worked and that the genesis file is setup correctly +$BINARY validate-genesis --home $HOME_DIR + +if [[ $1 == "pending" ]]; then + echo "pending mode is on, please wait for the first block committed." +fi + +# update request max size so that we can upload the light client +# '' -e is a must have params on mac, if use linux please delete before run +sed -i'' -e 's/max_body_bytes = /max_body_bytes = 1/g' $HOME_DIR/config/config.toml +sed -i'' -e 's/max_tx_bytes = 1048576/max_tx_bytes = 10000000/g' $HOME_DIR/config/config.toml + + +$BINARY start --rpc.unsafe --rpc.laddr tcp://0.0.0.0:26657 --pruning=nothing --minimum-gas-prices=0.001ppica --home=$HOME_DIR --log_level trace --trace --with-tendermint=true --transport=socket --grpc.enable=true --grpc-web.enable=false --api.enable=true --p2p.pex=false --p2p.upnp=false \ No newline at end of file diff --git a/scripts/upgrade/old-node-scripts.sh b/scripts/upgrade/old-node-scripts.sh index d360944f7..732ddd7b9 100755 --- a/scripts/upgrade/old-node-scripts.sh +++ b/scripts/upgrade/old-node-scripts.sh @@ -1,5 +1,5 @@ ADDITIONAL_SCRIPTS=( - "./scripts/upgrade/v_6_4_8/setup-08-wasm.sh" + "./scripts/upgrade/v_6_6_0/setup-08-wasm.sh" ) for SCRIPT in "${ADDITIONAL_SCRIPTS[@]}"; do diff --git a/scripts/upgrade/setup-old-centaurid-node.sh b/scripts/upgrade/setup-old-picad-node.sh similarity index 55% rename from scripts/upgrade/setup-old-centaurid-node.sh rename to scripts/upgrade/setup-old-picad-node.sh index 2316605a9..f0f7ac4e2 100755 --- a/scripts/upgrade/setup-old-centaurid-node.sh +++ b/scripts/upgrade/setup-old-picad-node.sh @@ -4,7 +4,7 @@ FORK=${FORK:-"false"} -BINARY=_build/old/centaurid +BINARY=_build/old/picad HOME=mytestnet ROOT=$(pwd) DENOM=ppica @@ -15,10 +15,12 @@ ADDITIONAL_PRE_SCRIPTS="./scripts/upgrade/old-node-scripts.sh" SLEEP_TIME=1 -screen -L -dmS node1 bash scripts/localnode.sh $BINARY $DENOM --Logfile $HOME/log-screen.txt +screen -L -dmS node1 bash scripts/upgrade/localnode.sh $BINARY $DENOM --Logfile $HOME/log-screen.txt + +#screen -L -dmS bash scripts/upgrade/localnode.sh $BINARY $DENOM --Logfile $HOME/log-screen.txt #scripts/localnode.sh $BINARY -sleep 4 # wait for note to start +sleep 20 # wait for note to start # execute additional pre scripts source $ADDITIONAL_PRE_SCRIPTS diff --git a/scripts/upgrade/v6_to_7/post_08_wasm.sh b/scripts/upgrade/v6_to_7/post_08_wasm.sh deleted file mode 100644 index ea03f7597..000000000 --- a/scripts/upgrade/v6_to_7/post_08_wasm.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -KEY="mykey" -KEYALGO="secp256k1" -KEYRING="test" -HOME_DIR="mytestnet" - - -sleep 2 - -checksum=$(./_build/new/centaurid query ibc-wasm checksums --home $HOME_DIR -o json | jq -r '.checksums[0]') -checksum="58c7623a3ab78f4cb2e4c5d02876ac36c3b38bb472118173a7ec7faa688a66d2" - -if ./_build/new/centaurid query ibc-wasm code $checksum --home $HOME_DIR -o json &> /dev/null; then - echo "Code with checksum $checksum exists." -else - echo "Code with checksum $checksum does not exist." -fi - - diff --git a/scripts/upgrade/v6_to_7/pre_08_wasm.sh b/scripts/upgrade/v6_to_7/pre_08_wasm.sh deleted file mode 100644 index 61b1a1784..000000000 --- a/scripts/upgrade/v6_to_7/pre_08_wasm.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -KEY="mykey" -KEYALGO="secp256k1" -KEYRING="test" -HOME_DIR="mytestnet" - - - -# validate dependencies are installed -command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"; exit 1; } - - -stat $(pwd)/contracts/ics10_grandpa_cw.wasm -./_build/old/centaurid tx 08-wasm push-wasm $(pwd)/contracts/ics10_grandpa_cw.wasm --from=mykey --gas 10002152622 --fees 10020166ppica --keyring-backend test --chain-id=localpica -y --home $HOME_DIR - -sleep 3 - -./_build/old/centaurid query 08-wasm all-wasm-code --home $HOME_DIR \ No newline at end of file diff --git a/scripts/upgrade/v_6_4_8/post-script-ibc-transfer.sh b/scripts/upgrade/v_6_4_8/post-script-ibc-transfer.sh deleted file mode 100755 index 987c8ecd7..000000000 --- a/scripts/upgrade/v_6_4_8/post-script-ibc-transfer.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -echo "" -echo "#################################################" -echo "# post-script: IBC Transfer #" -echo "#################################################" -echo "" - -NEW_BINARY=picad -BINARY=centaurid -CHAIN_DIR=$(pwd)/data - -AMOUNT_TO_DELEGATE=10000000000 -UPICA_DENOM=stake -WALLET_1=$($NEW_BINARY keys show wallet1 -a --keyring-backend test --home $CHAIN_DIR/test-1) -WALLET_2=$($BINARY keys show wallet2 -a --keyring-backend test --home $CHAIN_DIR/test-2) - -ACCOUNT_BALANCE_OF_WALLET1=$($NEW_BINARY q bank balances $WALLET_1 --chain-id test-1 --node tcp://localhost:16657 -o json | jq -r '.balances[0].amount') -echo "CHECK BALANCE POST UPGRADE: $ACCOUNT_BALANCE_OF_WALLET1" - -echo "Sending tokens from validator wallet on test-1 to validator wallet on test-2" -IBC_TRANSFER=$($NEW_BINARY tx ibc-transfer transfer transfer channel-0 $WALLET_2 $AMOUNT_TO_DELEGATE$UPICA_DENOM --chain-id test-1 --from $WALLET_1 --home $CHAIN_DIR/test-1 --fees 60000$UPICA_DENOM --node tcp://localhost:16657 --keyring-backend test -y -o json | jq -r '.raw_log' ) - -if [[ "$IBC_TRANSFER" == "failed to execute message"* ]]; then - echo "Error: IBC transfer failed, with error: $IBC_TRANSFER" - exit 1 -fi - -sleep 5 - -ACCOUNT_BALANCE=$($NEW_BINARY q bank balances $WALLET_1 --chain-id test-1 --node tcp://localhost:16657 -o json | jq -r '.balances[0].amount') -echo "CHECK BALANCE POST UPGRADE AFTER SEND SECOND TIME: $ACCOUNT_BALANCE" - -exit 1 - -echo "" -echo "#########################################################" -echo "# Success: post-script: IBC Transfer #" -echo "#########################################################" -echo "" \ No newline at end of file diff --git a/scripts/upgrade/v_6_4_8/post-script.sh b/scripts/upgrade/v_6_4_8/post-script.sh deleted file mode 100644 index 1846344fa..000000000 --- a/scripts/upgrade/v_6_4_8/post-script.sh +++ /dev/null @@ -1,91 +0,0 @@ -echo -e "\n ********** Running Post-Scripts **********" - -BINARY=$1 -DENOM=${2:-upica} -CHAIN_DIR=$(pwd)/mytestnet - -KEY="test0" -KEY1="test1" -KEY2="test2" - - - -DEFAULT_GAS_FLAG="--gas 3000000 --gas-prices 0.025$DENOM --gas-adjustment 1.5" -DEFAULT_ENV_FLAG="--keyring-backend test --chain-id localpica --home $CHAIN_DIR" - - -WALLET_1=$($BINARY keys show $KEY1 -a --keyring-backend test --home $CHAIN_DIR) -BALANCE_1=$($BINARY query bank balances $WALLET_1 --home $CHAIN_DIR -o json | jq -r '.balances[0].amount') -echo "wallet 1: $WALLET_1 - balance: $BALANCE_1" - - -WALLET_2=$($BINARY keys show $KEY2 -a --keyring-backend test --home $CHAIN_DIR) -echo "wallet 2: $WALLET_2" - - - -echo "binary value: $BINARY" -COUNTER_CONTRACT_DIR=$(pwd)/scripts/upgrade/contracts/counter.wasm - - -# ## TODO: the old contract address would not work, need to derive a new one -# echo "Old bench32 Contract address: $CONTRACT_ADDRESS" - -## Get contract by $CODE_ID -echo -e "\n Fetching the new contract address (it got changed after the upgrade)" -CODE_ID=1 ## TODO: hardfix for now to get the contract, and overide the contract address -CONTRACT_ADDRESS=$($BINARY query wasm list-contract-by-code $CODE_ID -o json | jq -r '.contracts[0]') -echo "Query contract address: $CONTRACT_ADDRESS" - -## Fetch code info -CREATOR=$($BINARY query wasm code-info $CODE_ID -o json | jq -r '.creator') -if [ "$CREATOR" == "$WALLET_1" ]; then - echo "Assertion passed: Code creator ($CREATOR) is equal to Wallet 1 ($WALLET_1)" -else - echo "Assertion failed: Code creator ($CREATOR) is not equal to Wallet 1 ($WALLET_1)" - exit 1 -fi - - -## Fetch contract info -CONTRACT_CREATOR=$($BINARY query wasm contract $CONTRACT_ADDRESS -o json | jq -r '.contract_info.creator') -if [ "$CONTRACT_CREATOR" == "$WALLET_1" ]; then - echo "Assertion passed: Contract creator ($CONTRACT_CREATOR) is equal to Wallet 1 ($WALLET_1)" -else - echo "Assertion failed: Contract creator ($CONTRACT_CREATOR) is not equal to Wallet 1 ($WALLET_1)" - exit 1 -fi - -echo -e "\n Testing with new wallet / wallet that has not interacted with the contract before" -## Execute contract with new address -echo "wallet2: init the counter" -$BINARY tx wasm execute $CONTRACT_ADDRESS '{"increment":{}}' --from $KEY2 $DEFAULT_ENV_FLAG $DEFAULT_GAS_FLAG -y -o json > /dev/null # tx1 is to init the counter== 0 - -sleep 1 -echo "wallet2: call the increment() function" -$BINARY tx wasm execute $CONTRACT_ADDRESS '{"increment":{}}' --from $KEY2 $DEFAULT_ENV_FLAG $DEFAULT_GAS_FLAG -y -o json > /dev/null - -sleep 1 -echo "wallet2: call the get_count() function" -COUNTER_VALUE_2=$($BINARY query wasm contract-state smart $CONTRACT_ADDRESS '{"get_count":{"addr": "'"$WALLET_2"'"}}' -o json | jq -r '.data.count') -echo "COUNTER_VALUE_2 = $COUNTER_VALUE_2" - - -echo -e "\n Testing with wallet that has interacted with the contract before" -## Execute the contract, with the existing address. increment counter to 2 -echo "wallet1: call the increment() function" -$BINARY tx wasm execute $CONTRACT_ADDRESS '{"increment":{}}' --from $KEY1 $DEFAULT_ENV_FLAG $DEFAULT_GAS_FLAG -y -o json > /dev/null - -## assert counter value to be 1 -sleep 1 -echo "wallet1: call the get_count() function" -$BINARY query wasm contract-state smart $CONTRACT_ADDRESS '{"get_count":{"addr": "'"$WALLET_1"'"}}' -o json -COUNTER_VALUE=$($BINARY query wasm contract-state smart $CONTRACT_ADDRESS '{"get_count":{"addr": "'"$WALLET_1"'"}}' -o json | jq -r '.data.count') -echo "COUNTER_VALUE = $COUNTER_VALUE" -# if [ "$COUNTER_VALUE" -ne 2 ]; then -# echo "Assertion failed: Expected counter value to be 2, got $COUNTER_VALUE" -# exit 1 -# fi -# echo "Assertion passed: Counter value is 2 as expected" - - diff --git a/scripts/upgrade/v_6_4_8/pre-script-ibc-transfer.sh b/scripts/upgrade/v_6_4_8/pre-script-ibc-transfer.sh deleted file mode 100755 index 496092577..000000000 --- a/scripts/upgrade/v_6_4_8/pre-script-ibc-transfer.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -echo "" -echo "#################################################" -echo "# pre-script: IBC Transfer #" -echo "#################################################" -echo "" - -BINARY=centaurid -CHAIN_DIR=$(pwd)/data - -AMOUNT_TO_DELEGATE=10000000000 -UPICA_DENOM=stake -WALLET_1=$($BINARY keys show wallet1 -a --keyring-backend test --home $CHAIN_DIR/test-1) -WALLET_2=$($BINARY keys show wallet2 -a --keyring-backend test --home $CHAIN_DIR/test-2) - -echo "Sending tokens from validator wallet on test-1 to validator wallet on test-2" - -IBC_TRANSFER=$($BINARY tx ibc-transfer transfer transfer channel-0 $WALLET_2 $AMOUNT_TO_DELEGATE$UPICA_DENOM --chain-id test-1 --from $WALLET_1 --home $CHAIN_DIR/test-1 --fees 60000$UPICA_DENOM --node tcp://localhost:16657 --keyring-backend test -y -o json | jq -r '.raw_log' ) -if [[ "$IBC_TRANSFER" == "failed to execute message"* ]]; then - echo "Error: IBC transfer failed, with error: $IBC_TRANSFER" - exit 1 -fi - -sleep 5 - -ACCOUNT_BALANCE=$($BINARY q bank balances $WALLET_1 --chain-id test-1 --node tcp://localhost:16657 -o json | jq -r '.balances[0].amount') -echo "CHECK BALANCE PRE UPGRADE: $ACCOUNT_BALANCE" -exit 1 - -echo "" -echo "#########################################################" -echo "# Success: pre-script: IBC Transfer #" -echo "#########################################################" -echo "" \ No newline at end of file diff --git a/scripts/upgrade/v_6_4_8/pre-script.sh b/scripts/upgrade/v_6_6_0/pre-script.sh similarity index 100% rename from scripts/upgrade/v_6_4_8/pre-script.sh rename to scripts/upgrade/v_6_6_0/pre-script.sh diff --git a/scripts/upgrade/v_6_4_8/setup-08-wasm.sh b/scripts/upgrade/v_6_6_0/setup-08-wasm.sh similarity index 96% rename from scripts/upgrade/v_6_4_8/setup-08-wasm.sh rename to scripts/upgrade/v_6_6_0/setup-08-wasm.sh index c764cd774..286d87df0 100755 --- a/scripts/upgrade/v_6_4_8/setup-08-wasm.sh +++ b/scripts/upgrade/v_6_6_0/setup-08-wasm.sh @@ -3,7 +3,7 @@ KEY=mykey KEYALGO="secp256k1" KEYRING="test" HOME_DIR="mytestnet" -BINARY=_build/old/centaurid +BINARY=_build/old/picad DENOM=ppica CHAINID=centauri-dev