Skip to content

Commit

Permalink
fix: upgrade module panic (#11969)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez committed May 17, 2022
1 parent b0abdff commit 450cd7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* [#11969](https://github.com/cosmos/cosmos-sdk/pull/11969) Fix the panic error in `x/upgrade` when `AppVersion` is not set.
* (tests) [\#11940](https://github.com/cosmos/cosmos-sdk/pull/11940) Fix some client tests in the `x/gov` module
* [\#11772](https://github.com/cosmos/cosmos-sdk/pull/11772) Limit types.Dec length to avoid overflow.
* [\#11724](https://github.com/cosmos/cosmos-sdk/pull/11724) Fix data race issues with api.Server
Expand Down
9 changes: 8 additions & 1 deletion x/upgrade/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ func BeginBlocker(k keeper.Keeper, ctx sdk.Context, _ abci.RequestBeginBlock) {
// 3. If the plan is ready and skip upgrade height is set for current height.
if !found || !plan.ShouldExecute(ctx) || (plan.ShouldExecute(ctx) && k.IsSkipHeight(ctx.BlockHeight())) {
if lastAppliedPlan != "" && !k.HasHandler(lastAppliedPlan) {
panic(fmt.Sprintf("Wrong app version %d, upgrade handler is missing for %s upgrade plan", ctx.ConsensusParams().Version.AppVersion, lastAppliedPlan))
var appVersion uint64

cp := ctx.ConsensusParams()
if cp != nil && cp.Version != nil {
appVersion = cp.Version.AppVersion
}

panic(fmt.Sprintf("Wrong app version %d, upgrade handler is missing for %s upgrade plan", appVersion, lastAppliedPlan))
}
}
}
Expand Down

0 comments on commit 450cd7f

Please sign in to comment.