diff --git a/CHANGELOG.md b/CHANGELOG.md index 625212007..b565059d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/x/upgrade/abci.go b/x/upgrade/abci.go index f390a873d..5212cd9e2 100644 --- a/x/upgrade/abci.go +++ b/x/upgrade/abci.go @@ -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)) } } }