Skip to content

Commit

Permalink
fix(app): do not try to migrate consensus params
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Jan 18, 2024
1 parent 758494c commit 61c6ddf
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"path/filepath"
"sort"
"strings"
"sync"

"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
Expand Down Expand Up @@ -243,7 +242,6 @@ type App struct {

// module configurator
configurator module.Configurator
once sync.Once
}

// New returns a reference to an initialized blockchain app.
Expand Down Expand Up @@ -926,24 +924,6 @@ func (app *App) setPostHandler() {
func (app *App) Name() string { return app.BaseApp.Name() }

func (app *App) FinalizeBlock(req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) {
// when skipping sdk 47 for sdk 50, the upgrade handler is called too late in BaseApp
// this is a hack to ensure that the migration is executed when needed and not panics
app.once.Do(func() {
ctx := app.NewUncachedContext(false, tmproto.Header{})
if _, err := app.ConsensusParamsKeeper.Params(ctx, &consensusparamtypes.QueryParamsRequest{}); err != nil {
// prevents panic: consensus key is nil: collections: not found: key 'no_key' of type
// github.com/cosmos/gogoproto/tendermint.types.ConsensusParams
// sdk 47:
// Migrate Tendermint consensus parameters from x/params module to a dedicated x/consensus module.
// see https://github.com/cosmos/cosmos-sdk/blob/v0.47.0/simapp/upgrades.go#L66
baseAppLegacySS := app.GetSubspace(baseapp.Paramspace)
err := baseapp.MigrateParams(sdk.UnwrapSDKContext(ctx), baseAppLegacySS, app.ConsensusParamsKeeper.ParamsStore)
if err != nil {
panic(err)
}
}
})

return app.BaseApp.FinalizeBlock(req)
}

Expand Down

0 comments on commit 61c6ddf

Please sign in to comment.