From 804f9e3d726e33bd72609761c138ee0f6dc9d0be Mon Sep 17 00:00:00 2001 From: kienn6034 Date: Sun, 14 Apr 2024 22:32:58 +0700 Subject: [PATCH 1/8] feat: run locanode and push wasm code --- scripts/localnode.sh | 108 ++++++++--------------- scripts/upgrade/init-old-node-env.sh | 31 ++----- scripts/upgrade/init_deps.sh | 6 +- scripts/upgrade/old-node-scripts.sh | 13 +++ scripts/upgrade/v_6_4_8/setup-08-wasm.sh | 20 +++-- 5 files changed, 76 insertions(+), 102 deletions(-) create mode 100755 scripts/upgrade/old-node-scripts.sh diff --git a/scripts/localnode.sh b/scripts/localnode.sh index ca302b1a1..a5a7c6f6b 100755 --- a/scripts/localnode.sh +++ b/scripts/localnode.sh @@ -1,93 +1,63 @@ #!/bin/bash -echo "starting localnode" - +KEY="mykey" +KEY1="mykey1" +CHAINID="centauri" +MONIKER="localtestnet" +KEYALGO="secp256k1" +KEYRING="test" +LOGLEVEL="info" BINARY=$1 -CONTINUE=${CONTINUE:-"false"} -HOME_DIR=mytestnet -ENV=${ENV:-""} - -if [ "$CONTINUE" == "true" ]; then - echo "\n ->> continuing from previous state" - $BINARY start --home $HOME_DIR --log_level debug - exit 0 -fi - -rm -rf mytestnet -pkill centaurid +# to trace evm +#TRACE="--trace" +TRACE="" -# check DENOM is set. If not, set to upica -DENOM=${2:-upica} -echo "denom: $DENOM" -COMMISSION_RATE=0.01 -COMMISSION_MAX_RATE=0.02 +HOME_DIR=mytestnet +DENOM=ppica -SED_BINARY=sed -# check if this is OS X -if [[ "$OSTYPE" == "darwin"* ]]; then - # check if gsed is installed - if ! command -v gsed &> /dev/null - then - echo "gsed could not be found. Please install it with 'brew install gnu-sed'" - exit - else - SED_BINARY=gsed - fi -fi +# remove existing daemon +rm -rf $HOME_DIR -# check BINARY is set. If not, build picad and set BINARY -if [ -z "$BINARY" ]; then - make build - BINARY=build/picad -fi +$BINARY config keyring-backend $KEYRING +$BINARY config chain-id $CHAINID -CHAIN_ID="localpica" -KEYRING="test" -KEY="test0" -KEY1="test1" -KEY2="test2" +# 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 -# Function updates the config based on a jq argument as a string 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 && mv $HOME_DIR/config/tmp_genesis.json $HOME_DIR/config/genesis.json + 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 } -$BINARY init --chain-id $CHAIN_ID moniker --home $HOME_DIR - -$BINARY keys add $KEY --keyring-backend $KEYRING --home $HOME_DIR -$BINARY keys add $KEY1 --keyring-backend $KEYRING --home $HOME_DIR -$BINARY keys add $KEY2 --keyring-backend $KEYRING --home $HOME_DIR - # Allocate genesis accounts (cosmos formatted addresses) -$BINARY add-genesis-account $KEY "1000000000000000000000${DENOM}" --keyring-backend $KEYRING --home $HOME_DIR -$BINARY add-genesis-account $KEY1 "1000000000000000000000${DENOM}" --keyring-backend $KEYRING --home $HOME_DIR -$BINARY add-genesis-account $KEY2 "1000000000000000000000${DENOM}" --keyring-backend $KEYRING --home $HOME_DIR +$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": "1000000"}]' +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"}' -update_test_genesis '.app_state["staking"]["params"]["bond_denom"]="'$DENOM'"' - -# enable rest server and swagger -$SED_BINARY -i '0,/enable = false/s//enable = true/' $HOME_DIR/config/app.toml -$SED_BINARY -i 's/swagger = false/swagger = true/' $HOME_DIR/config/app.toml -$SED_BINARY -i -e 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' $HOME_DIR/config/app.toml -$SED_BINARY -i 's/minimum-gas-prices = "0.25upica"/minimum-gas-prices = "0.0upica"/' $HOME_DIR/config/app.toml - -## Adjust block time -$SED_BINARY -i 's/timeout_commit = "5s"/timeout_commit = "500ms"/' $HOME_DIR/config/config.toml - - - -# Sign genesis transaction -$BINARY gentx $KEY "1000000000000000000000${DENOM}" --commission-rate=$COMMISSION_RATE --commission-max-rate=$COMMISSION_MAX_RATE --keyring-backend $KEYRING --chain-id $CHAIN_ID --home $HOME_DIR # 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 -$BINARY start --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 +sed -i'' -e 's/timeout_commit = "5s"/timeout_commit = "1s"/' $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/init-old-node-env.sh b/scripts/upgrade/init-old-node-env.sh index 8507c52c8..3ff94e4bc 100755 --- a/scripts/upgrade/init-old-node-env.sh +++ b/scripts/upgrade/init-old-node-env.sh @@ -10,30 +10,15 @@ ROOT=$(pwd) DENOM=ppica CHAIN_ID=centaurid -ADDITIONAL_PRE_SCRIPTS="./scripts/upgrade/v_6_4_8/setup-08-wasm.sh" +ADDITIONAL_PRE_SCRIPTS="./scripts/upgrade/old-node-scripts.sh" SLEEP_TIME=1 -# run old node -if [[ "$OSTYPE" == "darwin"* ]]; then - echo "running old node" - screen -L -dmS node1 bash scripts/localnode.sh $BINARY $DENOM --Logfile $HOME/log-screen.txt -else - screen -L -Logfile $HOME/log-screen.txt -dmS node1 bash scripts/localnode.sh $BINARY $DENOM -fi + + +screen -L -dmS node1 bash scripts/localnode.sh $BINARY $DENOM --Logfile $HOME/log-screen.txt +#scripts/localnode.sh $BINARY + +sleep 4 # wait for note to start # execute additional pre scripts -if [ ! -z "$ADDITIONAL_PRE_SCRIPTS" ]; then - # slice ADDITIONAL_SCRIPTS by , - SCRIPTS=($(echo "$ADDITIONAL_PRE_SCRIPTS" | tr ',' ' ')) - for SCRIPT in "${SCRIPTS[@]}"; do - # check if SCRIPT is a file - if [ -f "$SCRIPT" ]; then - echo "executing additional pre scripts from $SCRIPT" - source $SCRIPT $BINARY - echo "CONTRACT_ADDRESS = $CONTRACT_ADDRESS" - sleep 5 - else - echo "$SCRIPT is not a file" - fi - done -fi +source $ADDITIONAL_PRE_SCRIPTS diff --git a/scripts/upgrade/init_deps.sh b/scripts/upgrade/init_deps.sh index 604cebb5f..2ba5b0006 100755 --- a/scripts/upgrade/init_deps.sh +++ b/scripts/upgrade/init_deps.sh @@ -1,7 +1,7 @@ #!/bin/bash -OLD_VERSION=v6.5.2 +OLD_VERSION=kien-devnet-651 SOFTWARE_UPGRADE_NAME="v6_6_0" ROOT=$(pwd) @@ -20,13 +20,13 @@ fi if [ ! -f "_build/$OLD_VERSION.zip" ] &> /dev/null then mkdir -p _build/old - wget -c "https://github.com/ComposableFi/composable-cosmos/archive/refs/tags/${OLD_VERSION}.zip" -O _build/${OLD_VERSION}.zip + wget -c "https://github.com/notional-labs/composable-cosmos/archive/refs/tags/${OLD_VERSION}.zip" -O _build/${OLD_VERSION}.zip unzip _build/${OLD_VERSION}.zip -d _build fi # reinstall old binary if [ $# -eq 1 ] && [ $1 == "--reinstall-old" ] || ! command -v _build/old/centaurid &> /dev/null; then - cd ./_build/composable-cosmos-${OLD_VERSION:1} + cd ./_build/composable-cosmos-${OLD_VERSION} GOBIN="$ROOT/_build/old" go install -mod=readonly ./... cd ../.. fi diff --git a/scripts/upgrade/old-node-scripts.sh b/scripts/upgrade/old-node-scripts.sh new file mode 100755 index 000000000..d360944f7 --- /dev/null +++ b/scripts/upgrade/old-node-scripts.sh @@ -0,0 +1,13 @@ +ADDITIONAL_SCRIPTS=( + "./scripts/upgrade/v_6_4_8/setup-08-wasm.sh" +) + +for SCRIPT in "${ADDITIONAL_SCRIPTS[@]}"; do + if [ -f "$SCRIPT" ]; then + echo "Running additional script: $SCRIPT" + source $SCRIPT + else + echo "Additional script $SCRIPT does not exist." + fi +done + diff --git a/scripts/upgrade/v_6_4_8/setup-08-wasm.sh b/scripts/upgrade/v_6_4_8/setup-08-wasm.sh index 6dc8b67d2..cfadccaf5 100755 --- a/scripts/upgrade/v_6_4_8/setup-08-wasm.sh +++ b/scripts/upgrade/v_6_4_8/setup-08-wasm.sh @@ -1,17 +1,23 @@ -!/bin/bash -KEY="mykey" +#!/bin/bash +KEY=mykey KEYALGO="secp256k1" -CHAINID="centaurid" KEYRING="test" HOME_DIR="mytestnet" BINARY=_build/old/centaurid DENOM=ppica - -$BINARY tx gov submit-proposal scripts/08-wasm/ics10_grandpa_cw.wasm.json --from=mykey --fees 100000${DENOM} --gas auto --keyring-backend test --home $HOME_DIR -y +CHAINID=centauri + +$BINARY tx gov submit-proposal scripts/08-wasm/ics10_grandpa_cw.wasm.json --from=$KEY --fees 100000${DENOM} --gas auto --keyring-backend test --home $HOME_DIR --chain-id $CHAINID -y sleep 2 # TODO: fetch the propsoal id dynamically -$BINARY tx gov deposit "1" "20000000ppica" --from $KEY --fees 100000${DENOM} --keyring-backend test --home $HOME_DIR -y +$BINARY tx gov deposit "1" "20000000ppica" --from $KEY --fees 100000${DENOM} --keyring-backend test --home $HOME_DIR --chain-id $CHAINID -y sleep 2 -$BINARY tx gov vote 1 yes --from $KEY --fees 100000${DENOM} --keyring-backend test --home $HOME_DIR -y +$BINARY tx gov vote 1 yes --from $KEY --fees 100000${DENOM} --keyring-backend test --home $HOME_DIR --chain-id $CHAINID -y + + +## Voting time is 5s, check in localnode.sh +sleep 5 + +$BINARY query 08-wasm all-wasm-code --home $HOME_DIR --chain-id $CHAINID \ No newline at end of file From b9515955e08ab7cba28210983fbd9da6b000c790 Mon Sep 17 00:00:00 2001 From: kienn6034 Date: Sun, 14 Apr 2024 22:41:11 +0700 Subject: [PATCH 2/8] feat: setup relayer --- ...ode-env.sh => setup-old-centaurid-node.sh} | 0 scripts/upgrade/setup-polkadot-node.sh | 14 +++++++++++++ scripts/upgrade/setup-relayer.sh | 20 +++++++++++++++++++ 3 files changed, 34 insertions(+) rename scripts/upgrade/{init-old-node-env.sh => setup-old-centaurid-node.sh} (100%) create mode 100644 scripts/upgrade/setup-polkadot-node.sh create mode 100644 scripts/upgrade/setup-relayer.sh diff --git a/scripts/upgrade/init-old-node-env.sh b/scripts/upgrade/setup-old-centaurid-node.sh similarity index 100% rename from scripts/upgrade/init-old-node-env.sh rename to scripts/upgrade/setup-old-centaurid-node.sh diff --git a/scripts/upgrade/setup-polkadot-node.sh b/scripts/upgrade/setup-polkadot-node.sh new file mode 100644 index 000000000..7336ab120 --- /dev/null +++ b/scripts/upgrade/setup-polkadot-node.sh @@ -0,0 +1,14 @@ +ROOT=$(pwd) + +cd $ROOT/_build/composable/composable-pfm-fix + +# This start the node +nix run .#zombienet-rococo-local-picasso-dev + + +# Sleep 20secs for the node to run, before setting up the relayer + +sleep 20 + + + diff --git a/scripts/upgrade/setup-relayer.sh b/scripts/upgrade/setup-relayer.sh new file mode 100644 index 000000000..4b96136fb --- /dev/null +++ b/scripts/upgrade/setup-relayer.sh @@ -0,0 +1,20 @@ + +ROOT=$(pwd) + +cd $ROOT/_build/composable/composable-pfm-fix + +# init clients +nix run .#picasso-centauri-ibc-init +sleep 1 + +# init connection +nix run .#picasso-centauri-ibc-connection-init +sleep 1 + +# init channel +nix run .#picasso-centauri-ibc-channels-init +sleep 1 + + # run relayer +nix run .#picasso-centauri-ibc-relay +sleep 1 \ No newline at end of file From f75d22e6532a58540377f95320abf59aa1d1164f Mon Sep 17 00:00:00 2001 From: kienn6034 Date: Sun, 14 Apr 2024 23:38:49 +0700 Subject: [PATCH 3/8] feat: using ngit for repo with nix --- scripts/upgrade/init_deps.sh | 17 ++++++++++------- scripts/upgrade/setup-polkadot-node.sh | 8 +++++++- scripts/upgrade/setup-relayer.sh | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) mode change 100644 => 100755 scripts/upgrade/setup-polkadot-node.sh diff --git a/scripts/upgrade/init_deps.sh b/scripts/upgrade/init_deps.sh index 2ba5b0006..cd985f0f1 100755 --- a/scripts/upgrade/init_deps.sh +++ b/scripts/upgrade/init_deps.sh @@ -5,16 +5,19 @@ OLD_VERSION=kien-devnet-651 SOFTWARE_UPGRADE_NAME="v6_6_0" ROOT=$(pwd) -COMPOSABLE_VERSION="pfm-fix" +COMPOSABLE_VERSION="branchfortestingpfmfix" -if [ ! -f "_build/composable/$COMPOSABLE_VERSION.zip" ] &> /dev/null -then - mkdir -p _build/composable - wget -c "https://github.com/notional-labs/composable/archive/refs/tags/${COMPOSABLE_VERSION}.zip" -O _build/composable/${COMPOSABLE_VERSION}.zip - unzip _build/composable/${COMPOSABLE_VERSION}.zip -d _build/composable -fi +mkdir -p _build/ +# Check if the directory exists and is a Git repository +if [ ! -d "_build/composable/.git" ]; then + cd _build/ + git clone https://github.com/ComposableFi/composable.git composable + cd composable + git checkout "$COMPOSABLE_VERSION" +fi + # install old binary if not exist if [ ! -f "_build/$OLD_VERSION.zip" ] &> /dev/null diff --git a/scripts/upgrade/setup-polkadot-node.sh b/scripts/upgrade/setup-polkadot-node.sh old mode 100644 new mode 100755 index 7336ab120..7d040a231 --- a/scripts/upgrade/setup-polkadot-node.sh +++ b/scripts/upgrade/setup-polkadot-node.sh @@ -1,6 +1,6 @@ ROOT=$(pwd) -cd $ROOT/_build/composable/composable-pfm-fix +cd $ROOT/_build/composable # This start the node nix run .#zombienet-rococo-local-picasso-dev @@ -12,3 +12,9 @@ sleep 20 +ROOT=$(pwd) + +cd $ROOT/_build/composable + +# This start the node +nix run .#zombienet-rococo-local-picasso-dev diff --git a/scripts/upgrade/setup-relayer.sh b/scripts/upgrade/setup-relayer.sh index 4b96136fb..ca8f83501 100644 --- a/scripts/upgrade/setup-relayer.sh +++ b/scripts/upgrade/setup-relayer.sh @@ -1,7 +1,7 @@ ROOT=$(pwd) -cd $ROOT/_build/composable/composable-pfm-fix +cd $ROOT/_build/composable/ # init clients nix run .#picasso-centauri-ibc-init From f9d4beee31318d7ea18487f9e0ce62882f9e0963 Mon Sep 17 00:00:00 2001 From: kienn6034 Date: Sun, 14 Apr 2024 23:42:04 +0700 Subject: [PATCH 4/8] chore: update notes install deps --- scripts/upgrade/init_deps.sh | 2 ++ scripts/upgrade/setup-polkadot-node.sh | 14 -------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/scripts/upgrade/init_deps.sh b/scripts/upgrade/init_deps.sh index cd985f0f1..f01738b2e 100755 --- a/scripts/upgrade/init_deps.sh +++ b/scripts/upgrade/init_deps.sh @@ -11,6 +11,8 @@ mkdir -p _build/ # Check if the directory exists and is a Git repository +# TODO: using git, since nix in composable repo requires something with git +# Consider using submodule, or firgure this out if [ ! -d "_build/composable/.git" ]; then cd _build/ git clone https://github.com/ComposableFi/composable.git composable diff --git a/scripts/upgrade/setup-polkadot-node.sh b/scripts/upgrade/setup-polkadot-node.sh index 7d040a231..dadd487ff 100755 --- a/scripts/upgrade/setup-polkadot-node.sh +++ b/scripts/upgrade/setup-polkadot-node.sh @@ -4,17 +4,3 @@ cd $ROOT/_build/composable # This start the node nix run .#zombienet-rococo-local-picasso-dev - - -# Sleep 20secs for the node to run, before setting up the relayer - -sleep 20 - - - -ROOT=$(pwd) - -cd $ROOT/_build/composable - -# This start the node -nix run .#zombienet-rococo-local-picasso-dev From 8d9c3833b2df5fe3221bdec7b82f4564734e19c6 Mon Sep 17 00:00:00 2001 From: kienn6034 Date: Mon, 15 Apr 2024 00:11:43 +0700 Subject: [PATCH 5/8] feat: script to upgrade --- scripts/localnode.sh | 2 +- scripts/upgrade/upgrade.sh | 80 ++++++++++++++++++++++++ scripts/upgrade/v_6_4_8/setup-08-wasm.sh | 2 +- 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 scripts/upgrade/upgrade.sh diff --git a/scripts/localnode.sh b/scripts/localnode.sh index a5a7c6f6b..c1c95d3c3 100755 --- a/scripts/localnode.sh +++ b/scripts/localnode.sh @@ -2,7 +2,7 @@ KEY="mykey" KEY1="mykey1" -CHAINID="centauri" +CHAINID="centauri-dev" MONIKER="localtestnet" KEYALGO="secp256k1" KEYRING="test" diff --git a/scripts/upgrade/upgrade.sh b/scripts/upgrade/upgrade.sh new file mode 100644 index 000000000..f77e2b979 --- /dev/null +++ b/scripts/upgrade/upgrade.sh @@ -0,0 +1,80 @@ +# the upgrade is a fork, "true" otherwise +FORK=${FORK:-"false"} + +UPGRADE_WAIT=${UPGRADE_WAIT:-20} +HOME=mytestnet +ROOT=$(pwd) +DENOM=ppica +CHAIN_ID=centauri-dev +SOFTWARE_UPGRADE_NAME="v6_6_0" +ADDITIONAL_PRE_SCRIPTS="./scripts/upgrade/v_6_4_8/pre-script.sh" +ADDITIONAL_AFTER_SCRIPTS="./scripts/upgrade/v_6_4_8/post-script.sh" +KEY="mykey" +KEY1="mykey1" + +SLEEP_TIME=1 + + +UPGRADE_PROPOSAL_ID=2 +run_upgrade () { + echo -e "\n\n=> =>start upgrading" + + # Get upgrade height, 12 block after (6s) + STATUS_INFO=($(./_build/old/centaurid status --home $HOME | jq -r '.NodeInfo.network,.SyncInfo.latest_block_height')) + UPGRADE_HEIGHT=$((STATUS_INFO[1] + 12)) + echo "UPGRADE_HEIGHT = $UPGRADE_HEIGHT" + + tar -cf ./_build/new/picad.tar -C ./_build/new picad + SUM=$(shasum -a 256 ./_build/new/picad.tar | cut -d ' ' -f1) + UPGRADE_INFO=$(jq -n ' + { + "binaries": { + "linux/amd64": "file://'$(pwd)'/_build/new/picad.tar?checksum=sha256:'"$SUM"'", + } + }') + + + ./_build/old/centaurid tx gov submit-legacy-proposal software-upgrade "$SOFTWARE_UPGRADE_NAME" --upgrade-height $UPGRADE_HEIGHT --upgrade-info "$UPGRADE_INFO" --title "upgrade" --description "upgrade" --from $KEY --fees 100000${DENOM} --keyring-backend test --chain-id $CHAIN_ID --home $HOME -y > /dev/null + + sleep $SLEEP_TIME + + ./_build/old/centaurid tx gov deposit $UPGRADE_PROPOSAL_ID "20000000${DENOM}" --from $KEY --keyring-backend test --fees 100000${DENOM} --chain-id $CHAIN_ID --home $HOME -y + + sleep $SLEEP_TIME + + ./_build/old/centaurid tx gov vote $UPGRADE_PROPOSAL_ID yes --from $KEY --keyring-backend test --fees 100000${DENOM} --chain-id $CHAIN_ID --home $HOME -y + + sleep $SLEEP_TIME + + + # determine block_height to halt + while true; do + BLOCK_HEIGHT=$(./_build/old/centaurid status | jq '.SyncInfo.latest_block_height' -r) + if [ $BLOCK_HEIGHT = "$UPGRADE_HEIGHT" ]; then + # assuming running only 1 centaurid + echo "BLOCK HEIGHT = $UPGRADE_HEIGHT REACHED, KILLING OLD ONE" + pkill centaurid + break + else + ./_build/old/centaurid q gov proposal $UPGRADE_PROPOSAL_ID --output=json | jq ".status" + echo "BLOCK_HEIGHT = $BLOCK_HEIGHT" + sleep 1 + fi + done +} + +# if FORK = true +if [[ "$FORK" == "true" ]]; then + run_fork + unset PICA_HALT_HEIGHT +else + run_upgrade +fi + +sleep 1 + +# run new node +echo -e "\n\n=> =>continue running nodes after upgrade" +#CONTINUE="true" screen -L -dmS picad bash scripts/localnode.sh _build/new/picad $DENOM +bash scripts/localnode.sh _build/new/picad $DENOM + diff --git a/scripts/upgrade/v_6_4_8/setup-08-wasm.sh b/scripts/upgrade/v_6_4_8/setup-08-wasm.sh index cfadccaf5..c764cd774 100755 --- a/scripts/upgrade/v_6_4_8/setup-08-wasm.sh +++ b/scripts/upgrade/v_6_4_8/setup-08-wasm.sh @@ -5,7 +5,7 @@ KEYRING="test" HOME_DIR="mytestnet" BINARY=_build/old/centaurid DENOM=ppica -CHAINID=centauri +CHAINID=centauri-dev $BINARY tx gov submit-proposal scripts/08-wasm/ics10_grandpa_cw.wasm.json --from=$KEY --fees 100000${DENOM} --gas auto --keyring-backend test --home $HOME_DIR --chain-id $CHAINID -y From 06be8db35e745f3346ed5bd80b7848e60603c3dc Mon Sep 17 00:00:00 2001 From: kienn6034 Date: Mon, 15 Apr 2024 01:07:28 +0700 Subject: [PATCH 6/8] fix: upgrade scripts --- scripts/localnode.sh | 11 +++++++++-- scripts/upgrade/upgrade.sh | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) mode change 100644 => 100755 scripts/upgrade/upgrade.sh diff --git a/scripts/localnode.sh b/scripts/localnode.sh index c1c95d3c3..b9ff67675 100755 --- a/scripts/localnode.sh +++ b/scripts/localnode.sh @@ -15,12 +15,19 @@ TRACE="" HOME_DIR=mytestnet DENOM=ppica -# remove existing daemon -rm -rf $HOME_DIR + +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 diff --git a/scripts/upgrade/upgrade.sh b/scripts/upgrade/upgrade.sh old mode 100644 new mode 100755 index f77e2b979..166975b1e --- a/scripts/upgrade/upgrade.sh +++ b/scripts/upgrade/upgrade.sh @@ -76,5 +76,5 @@ sleep 1 # run new node echo -e "\n\n=> =>continue running nodes after upgrade" #CONTINUE="true" screen -L -dmS picad bash scripts/localnode.sh _build/new/picad $DENOM -bash scripts/localnode.sh _build/new/picad $DENOM +CONTINUE="true" bash scripts/localnode.sh _build/new/picad $DENOM From 4f5cae1ff2fd1d784fbba58f0b567a9102a0f075 Mon Sep 17 00:00:00 2001 From: kienn6034 Date: Mon, 15 Apr 2024 01:39:44 +0700 Subject: [PATCH 7/8] fix: init deps script --- scripts/upgrade/init_deps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade/init_deps.sh b/scripts/upgrade/init_deps.sh index f01738b2e..5ed0b2f6a 100755 --- a/scripts/upgrade/init_deps.sh +++ b/scripts/upgrade/init_deps.sh @@ -18,6 +18,7 @@ if [ ! -d "_build/composable/.git" ]; then git clone https://github.com/ComposableFi/composable.git composable cd composable git checkout "$COMPOSABLE_VERSION" + cd ../.././ fi From e05ae57304d1aca851701e20fabb71a4af078e5d Mon Sep 17 00:00:00 2001 From: kienn6034 Date: Mon, 15 Apr 2024 02:55:20 +0700 Subject: [PATCH 8/8] fix/migration: wrong prefix relay addresS --- bech32-migration/transfermiddleware/transfermiddleware.go | 6 ++++-- scripts/upgrade/setup-old-centaurid-node.sh | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bech32-migration/transfermiddleware/transfermiddleware.go b/bech32-migration/transfermiddleware/transfermiddleware.go index 5781f6066..68add6ef4 100644 --- a/bech32-migration/transfermiddleware/transfermiddleware.go +++ b/bech32-migration/transfermiddleware/transfermiddleware.go @@ -15,13 +15,15 @@ func MigrateAddressBech32(ctx sdk.Context, storeKey storetypes.StoreKey, cdc cod allowRelayAddressCount := uint64(0) store := ctx.KVStore(storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.KeyRlyAddress) + + relayAddressPrefix := []byte{1} + iterator := sdk.KVStorePrefixIterator(store, relayAddressPrefix) for ; iterator.Valid(); iterator.Next() { allowRelayAddressCount++ trimedAddr := strings.Replace(string(iterator.Key()), "\x04", "", 1) newPrefixAddr := utils.ConvertAccAddr(trimedAddr) - store.Set(types.GetKeyByRlyAddress(newPrefixAddr), []byte{1}) + store.Set(types.GetKeyByRlyAddress(newPrefixAddr), relayAddressPrefix) } ctx.Logger().Info( diff --git a/scripts/upgrade/setup-old-centaurid-node.sh b/scripts/upgrade/setup-old-centaurid-node.sh index 3ff94e4bc..2316605a9 100755 --- a/scripts/upgrade/setup-old-centaurid-node.sh +++ b/scripts/upgrade/setup-old-centaurid-node.sh @@ -22,3 +22,4 @@ sleep 4 # wait for note to start # execute additional pre scripts source $ADDITIONAL_PRE_SCRIPTS +