diff --git a/contrib/updates/prepare_cosmovisor.sh b/contrib/updates/prepare_cosmovisor.sh index 378e5840f..75d2f708f 100644 --- a/contrib/updates/prepare_cosmovisor.sh +++ b/contrib/updates/prepare_cosmovisor.sh @@ -5,7 +5,7 @@ # These fields should be fetched automatically in the future # Need to do more upgrade to see upgrade patterns -OLD_VERSION=v2.0.1 +OLD_VERSION=v2.2.1 # this command will retrieve the folder with the largest number in format v SOFTWARE_UPGRADE_NAME=$(ls -d -- ./app/upgrades/v* | sort -Vr | head -n 1 | xargs basename) BUILDDIR=$1 diff --git a/contrib/updates/upgrade-test.sh b/contrib/updates/upgrade-test.sh index 49429827e..c2e886b48 100644 --- a/contrib/updates/upgrade-test.sh +++ b/contrib/updates/upgrade-test.sh @@ -17,7 +17,18 @@ CHAIN_ID=${STATUS_INFO[0]} UPGRADE_HEIGHT=$((STATUS_INFO[1] + 20)) echo $UPGRADE_HEIGHT -$BINARY_OLD tx gov submit-proposal software-upgrade "$SOFTWARE_UPGRADE_NAME" --upgrade-height $UPGRADE_HEIGHT --upgrade-info "temp" --title "upgrade" --description "upgrade" --from node1 --keyring-backend test --chain-id $CHAIN_ID --home $NODE1_HOME -y +docker exec terradnode1 tar -cf ./terrad.tar -C . terrad +SUM=$(docker exec terradnode1 sha256sum ./terrad.tar | cut -d ' ' -f1) +DOCKER_BASE_PATH=$(docker exec terradnode1 pwd) +echo $SUM +UPGRADE_INFO=$(jq -n ' +{ + "binaries": { + "linux/amd64": "file://'$DOCKER_BASE_PATH'/terrad.tar?checksum=sha256:'"$SUM"'", + } +}') + +$BINARY_OLD tx gov submit-legacy-proposal software-upgrade "$SOFTWARE_UPGRADE_NAME" --upgrade-height $UPGRADE_HEIGHT --upgrade-info "$UPGRADE_INFO" --title "upgrade" --description "upgrade" --from node1 --keyring-backend test --chain-id $CHAIN_ID --home $NODE1_HOME -y sleep 5 diff --git a/go.mod b/go.mod index 3a996747d..720d6421c 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ go 1.20 module github.com/classic-terra/core/v2 require ( + cosmossdk.io/math v1.0.0-rc.0 github.com/CosmWasm/wasmd v0.30.0 github.com/CosmWasm/wasmvm v1.1.2 github.com/cosmos/cosmos-sdk v0.46.14 @@ -33,7 +34,6 @@ require ( cloud.google.com/go/iam v1.1.1 // indirect cloud.google.com/go/storage v1.30.1 // indirect cosmossdk.io/errors v1.0.0-beta.7 // indirect - cosmossdk.io/math v1.0.0-rc.0 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect diff --git a/scripts/run-node.sh b/scripts/run-node.sh index fb331feed..38cff39e6 100755 --- a/scripts/run-node.sh +++ b/scripts/run-node.sh @@ -3,9 +3,10 @@ BINARY=$1 CONTINUE=${CONTINUE:-"false"} HOME_DIR=mytestnet +ENV=${ENV:-""} if [ "$CONTINUE" == "true" ]; then - $BINARY start --home $HOME_DIR + $BINARY start --home $HOME_DIR --log_level debug exit 0 fi diff --git a/scripts/upgrade-test.sh b/scripts/upgrade-test.sh index edaa996c8..9a08ae36c 100755 --- a/scripts/upgrade-test.sh +++ b/scripts/upgrade-test.sh @@ -22,19 +22,16 @@ fi mkdir -p _build/gocache export GOMODCACHE=$ROOT/_build/gocache -# install old binary -if ! command -v _build/old/terrad &> /dev/null +# install old binary if not exist +if [ ! -f "_build/$OLD_VERSION.zip" ] &> /dev/null then mkdir -p _build/old wget -c "https://github.com/classic-terra/core/archive/refs/tags/${OLD_VERSION}.zip" -O _build/${OLD_VERSION}.zip unzip _build/${OLD_VERSION}.zip -d _build - cd ./_build/core-${OLD_VERSION:1} - GOBIN="$ROOT/_build/old" go install -mod=readonly ./... - cd ../.. fi # reinstall old binary -if [ $# -eq 1 ] && [ $1 == "--reinstall-old" ]; then +if [ $# -eq 1 ] && [ $1 == "--reinstall-old" ] || ! command -v _build/old/terrad &> /dev/null; then cd ./_build/core-${OLD_VERSION:1} GOBIN="$ROOT/_build/old" go install -mod=readonly ./... cd ../.. @@ -43,7 +40,9 @@ fi # install new binary if ! command -v _build/new/terrad &> /dev/null then + cd ./_build/core-${NEW_VERSION:1} GOBIN="$ROOT/_build/new" go install -mod=readonly ./... + cd ../.. fi # run old node @@ -95,7 +94,16 @@ run_upgrade () { tar -cf ./_build/new/terrad.tar -C ./_build/new terrad SUM=$(shasum -a 256 ./_build/new/terrad.tar | cut -d ' ' -f1) - ./_build/old/terrad tx gov submit-legacy-proposal software-upgrade "$SOFTWARE_UPGRADE_NAME" --upgrade-height $UPGRADE_HEIGHT --upgrade-info "{\"binaries\":{\"linux/amd64\":\"file://"$(pwd)"/_build/new/terrad.tar?checksum=sha256:"$SUM"\"}}" --title "upgrade" --description "upgrade" --from test1 --keyring-backend test --chain-id $CHAIN_ID --home $HOME -y + UPGRADE_INFO=$(jq -n ' + { + "binaries": { + "linux/amd64": "file://'$(pwd)'/_build/new/terrad.tar?checksum=sha256:'"$SUM"'", + } + }') + + ./_build/old/terrad keys list --home $HOME --keyring-backend test + + ./_build/old/terrad tx gov submit-legacy-proposal software-upgrade "$SOFTWARE_UPGRADE_NAME" --upgrade-height $UPGRADE_HEIGHT --upgrade-info "$UPGRADE_INFO" --title "upgrade" --description "upgrade" --from test1 --keyring-backend test --chain-id $CHAIN_ID --home $HOME -y sleep 5 diff --git a/x/dyncomm/keeper/dyncomm.go b/x/dyncomm/keeper/dyncomm.go index 6fae35faa..e74dc430b 100644 --- a/x/dyncomm/keeper/dyncomm.go +++ b/x/dyncomm/keeper/dyncomm.go @@ -152,10 +152,11 @@ func (k Keeper) UpdateValidatorMinRates(ctx sdk.Context, validator stakingtypes. k.StakingKeeper.SetValidator(ctx, newValidator) k.SetDynCommissionRate(ctx, validator.OperatorAddress, minRate) + k.SetTargetCommissionRate(ctx, validator.OperatorAddress, newRate) // Debug targetRate = k.GetTargetCommissionRate(ctx, validator.OperatorAddress) - ctx.Logger().Info("dyncomm:", "val", validator.OperatorAddress, "min_rate", minRate, "target_rate", targetRate) + ctx.Logger().Debug("dyncomm:", "val", validator.OperatorAddress, "min_rate", minRate, "new target_rate", targetRate) } func (k Keeper) UpdateAllBondedValidatorRates(ctx sdk.Context) (err error) { diff --git a/x/dyncomm/post/post.go b/x/dyncomm/post/post.go index 8f619d682..519c450ba 100644 --- a/x/dyncomm/post/post.go +++ b/x/dyncomm/post/post.go @@ -63,7 +63,7 @@ func (dd DyncommDecorator) ProcessEditValidator(ctx sdk.Context, msg sdk.Msg) { func (dd DyncommDecorator) ProcessCreateValidator(ctx sdk.Context, msg sdk.Msg) { // post handler runs after successfully // calling runMsgs -> we can set state changes here! - msgEditValidator := msg.(*stakingtypes.MsgCreateValidator) - newIntendedRate := msgEditValidator.Commission.Rate - dd.dyncommKeeper.SetTargetCommissionRate(ctx, msgEditValidator.ValidatorAddress, newIntendedRate) + msgCreateValidator := msg.(*stakingtypes.MsgCreateValidator) + newIntendedRate := msgCreateValidator.Commission.Rate + dd.dyncommKeeper.SetTargetCommissionRate(ctx, msgCreateValidator.ValidatorAddress, newIntendedRate) }