From e08b5f06b18fe456e85b16a39a0500c6b6a77fe7 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 14:24:40 -0400 Subject: [PATCH] fix: Fix v5 upgrade VE handler (#1468) (#1469) * Add nil protections on upgrade handler * Fix import name * Address comment (cherry picked from commit 5e002ee87769ee23838a983bac5eb58a7b8c5337) Co-authored-by: Eric Warehime --- protocol/app/upgrades/v5.0.0/upgrade.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/protocol/app/upgrades/v5.0.0/upgrade.go b/protocol/app/upgrades/v5.0.0/upgrade.go index a37e3ab810..b7442debce 100644 --- a/protocol/app/upgrades/v5.0.0/upgrade.go +++ b/protocol/app/upgrades/v5.0.0/upgrade.go @@ -5,6 +5,7 @@ import ( "fmt" "math/big" + tenderminttypes "github.com/cometbft/cometbft/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" @@ -263,15 +264,12 @@ func voteExtensionsUpgrade( keeper consensusparamkeeper.Keeper, ) { currentParams, err := keeper.Params(ctx, &consensustypes.QueryParamsRequest{}) - if err != nil { + if err != nil || currentParams == nil || currentParams.Params == nil { panic(fmt.Sprintf("failed to retrieve existing consensus params in VE upgrade handler: %s", err)) } - if currentParams.Params.Abci.VoteExtensionsEnableHeight != 0 { - panic(fmt.Sprintf( - "unable to update VE Enable Height since its current value of %d is already non-zero", - currentParams.Params.Abci.VoteExtensionsEnableHeight)) + currentParams.Params.Abci = &tenderminttypes.ABCIParams{ + VoteExtensionsEnableHeight: ctx.BlockHeight() + VEEnableHeightDelta, } - currentParams.Params.Abci.VoteExtensionsEnableHeight = ctx.BlockHeight() + VEEnableHeightDelta _, err = keeper.UpdateParams(ctx, &consensustypes.MsgUpdateParams{ Authority: keeper.GetAuthority(), Block: currentParams.Params.Block,