Skip to content

Commit

Permalink
fix: Fix v5 upgrade VE handler (#1468) (#1469)
Browse files Browse the repository at this point in the history
* Add nil protections on upgrade handler

* Fix import name

* Address comment

(cherry picked from commit 5e002ee)

Co-authored-by: Eric Warehime <eric.warehime@gmail.com>
  • Loading branch information
mergify[bot] and Eric-Warehime committed May 6, 2024
1 parent 63363ad commit e08b5f0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions protocol/app/upgrades/v5.0.0/upgrade.go
Expand Up @@ -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"

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e08b5f0

Please sign in to comment.