From 5c3372f638611834261a52ec66f728a368a9991b Mon Sep 17 00:00:00 2001 From: kien6034 Date: Fri, 6 Dec 2024 15:57:25 +0700 Subject: [PATCH] perf: return error instead of panicking --- custom/staking/hook.go | 4 +++- scripts/upgrade-test.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/custom/staking/hook.go b/custom/staking/hook.go index 9603992d..fdb1a8a4 100644 --- a/custom/staking/hook.go +++ b/custom/staking/hook.go @@ -1,6 +1,8 @@ package staking import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -54,7 +56,7 @@ func (h TerraStakingHooks) AfterDelegationModified(ctx sdk.Context, _ sdk.AccAdd validatorDelegationPercent := sdk.NewDec(validatorPower).QuoInt64(totalPower.Int64()) if validatorDelegationPercent.GT(sdk.NewDecWithPrec(20, 2)) { - panic("validator power is over the allowed limit") + return fmt.Errorf("validator power is over the allowed limit") } return nil diff --git a/scripts/upgrade-test.sh b/scripts/upgrade-test.sh index 340aa278..4ba1c6f0 100755 --- a/scripts/upgrade-test.sh +++ b/scripts/upgrade-test.sh @@ -10,7 +10,7 @@ HOME=mytestnet ROOT=$(pwd) DENOM=uluna CHAIN_ID=localterra -SOFTWARE_UPGRADE_NAME="v8_4" +SOFTWARE_UPGRADE_NAME="v11" ADDITIONAL_PRE_SCRIPTS=${ADDITIONAL_PRE_SCRIPTS:-""} ADDITIONAL_AFTER_SCRIPTS=${ADDITIONAL_AFTER_SCRIPTS:-""}