Skip to content

Commit

Permalink
fix: remove consensus param migration from finalizeBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
poorphd committed Jul 22, 2024
1 parent 74d808f commit f3619c5
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 @@ -8,9 +8,7 @@ import (
"net/http"
"os"
"path/filepath"
"sync"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
"github.com/cosmos/gogoproto/proto"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
Expand Down Expand Up @@ -269,7 +267,6 @@ type Canto struct {
configurator module.Configurator

tpsCounter *tpsCounter
once sync.Once
}

func init() {
Expand Down Expand Up @@ -1265,23 +1262,6 @@ func (app *Canto) GetTxConfig() client.TxConfig {
}

func (app *Canto) 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 f3619c5

Please sign in to comment.