From 167415b18c1fdbee04708a263983fb8d13c61605 Mon Sep 17 00:00:00 2001 From: yuandu Date: Thu, 14 Sep 2023 17:20:47 +0800 Subject: [PATCH] bump-up ethermint to resolve panic of accessing consensus parmas at upgrade block --- app/app.go | 32 ++++---------------------------- app/modules.go | 5 +++-- app/upgrades/v210/upgrades.go | 7 +++---- go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 13 insertions(+), 37 deletions(-) diff --git a/app/app.go b/app/app.go index fceeab5c3..ea12b12c6 100644 --- a/app/app.go +++ b/app/app.go @@ -99,10 +99,6 @@ import ( tibcroutingtypes "github.com/bianjieai/tibc-go/modules/tibc/core/26-routing/types" tibckeeper "github.com/bianjieai/tibc-go/modules/tibc/core/keeper" - nfttransfer "github.com/bianjieai/nft-transfer" - ibcnfttransferkeeper "github.com/bianjieai/nft-transfer/keeper" - ibcnfttransfertypes "github.com/bianjieai/nft-transfer/types" - "github.com/evmos/ethermint/ethereum/eip712" srvflags "github.com/evmos/ethermint/server/flags" ethermint "github.com/evmos/ethermint/types" @@ -112,6 +108,10 @@ import ( feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper" feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" + nfttransfer "github.com/bianjieai/nft-transfer" + ibcnfttransferkeeper "github.com/bianjieai/nft-transfer/keeper" + ibcnfttransfertypes "github.com/bianjieai/nft-transfer/types" + "github.com/irisnet/irishub/v2/address" irishubante "github.com/irisnet/irishub/v2/ante" "github.com/irisnet/irishub/v2/lite" @@ -740,32 +740,9 @@ func (app *IrisApp) BeginBlocker( ctx sdk.Context, req abci.RequestBeginBlock, ) abci.ResponseBeginBlock { - // NOTE: if we can't get conParmas from x/consensus, we go for the default x/params - // WARNING: this line of code must be removed once the x/params is deprecated - ctx = app.getConsensusParams(ctx) return app.mm.BeginBlock(ctx, req) } -// getConsensusParams gets the consensus parameters from the x/consensus module or the x/params module -// Note: some modules require consensus params from the sdk.Context. -// By default, baseapp.BeginBlock accesses the consensus params from x/consensus -// module before calling each module's BeginBlock. However, for the first time of -// consensus params migration, it will only get an empty value until we finalize -// the upgrade block. So we must access the consensus params from the legacy x/params -// module instead for that case. -func (app *IrisApp) getConsensusParams(ctx sdk.Context) sdk.Context { - consParams := ctx.ConsensusParams() - if consParams.Block == nil && consParams.Evidence == nil && consParams.Validator == nil { - baseAppLegacySS, ok := app.ParamsKeeper.GetSubspace(baseapp.Paramspace) - if !ok { - panic("cannot get param subspace") - } - consParams = baseapp.GetConsensusParams(ctx, baseAppLegacySS) - return ctx.WithConsensusParams(consParams) - } - return ctx -} - // EndBlocker application updates every end block func (app *IrisApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { return app.mm.EndBlock(ctx, req) @@ -944,7 +921,6 @@ func initParamsKeeper( paramsKeeper.Subspace(ibcexported.ModuleName) paramsKeeper.Subspace(farmtypes.ModuleName).WithKeyTable(farmtypes.ParamKeyTable()) paramsKeeper.Subspace(tibchost.ModuleName) - paramsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) // ethermint subspaces paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable()) diff --git a/app/modules.go b/app/modules.go index 2d3c890e1..c39ac7966 100644 --- a/app/modules.go +++ b/app/modules.go @@ -1,7 +1,6 @@ package app import ( - ibcnfttransfertypes "github.com/bianjieai/nft-transfer/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/auth" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" @@ -68,7 +67,6 @@ import ( "github.com/irisnet/irismod/modules/token" tokentypes "github.com/irisnet/irismod/modules/token/types" - nfttransfer "github.com/bianjieai/nft-transfer" tibcmttransfer "github.com/bianjieai/tibc-go/modules/tibc/apps/mt_transfer" tibcmttypes "github.com/bianjieai/tibc-go/modules/tibc/apps/mt_transfer/types" tibcnfttransfer "github.com/bianjieai/tibc-go/modules/tibc/apps/nft_transfer" @@ -82,6 +80,9 @@ import ( "github.com/evmos/ethermint/x/feemarket" feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" + nfttransfer "github.com/bianjieai/nft-transfer" + ibcnfttransfertypes "github.com/bianjieai/nft-transfer/types" + irisappparams "github.com/irisnet/irishub/v2/app/params" irisevm "github.com/irisnet/irishub/v2/modules/evm" "github.com/irisnet/irishub/v2/modules/guardian" diff --git a/app/upgrades/v210/upgrades.go b/app/upgrades/v210/upgrades.go index 18b1e6569..a46c6d518 100644 --- a/app/upgrades/v210/upgrades.go +++ b/app/upgrades/v210/upgrades.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ibcnfttransfertypes "github.com/bianjieai/nft-transfer/types" @@ -41,10 +42,8 @@ func upgradeHandlerConstructor( // Migrate Tendermint consensus parameters from x/params module to a // dedicated x/consensus module. - baseAppLegacySS, ok := app.ParamsKeeper.GetSubspace(baseapp.Paramspace) - if !ok { - panic("failed to get legacy param subspace") - } + baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace). + WithKeyTable(paramstypes.ConsensusParamsKeyTable()) baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper) return app.ModuleManager.RunMigrations(ctx, c, fromVM) } diff --git a/go.mod b/go.mod index 373276618..ec34317cc 100644 --- a/go.mod +++ b/go.mod @@ -221,6 +221,6 @@ require ( replace github.com/zondax/hid => github.com/zondax/hid v0.9.0 // use bianjieai fork of ethermint -replace github.com/evmos/ethermint => github.com/bianjieai/ethermint v0.6.1-0.20230824080820-7416e4b8e2c6 +replace github.com/evmos/ethermint => github.com/bianjieai/ethermint v0.6.1-0.20230914085944-3cc455cce3d4 replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 diff --git a/go.sum b/go.sum index 791659ac5..4695c19c7 100644 --- a/go.sum +++ b/go.sum @@ -291,8 +291,8 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bianjieai/ethermint v0.6.1-0.20230824080820-7416e4b8e2c6 h1:eF39/n5pVKfxqanQvNdKAeqKF3Oz3iGDL/cX202HK8g= -github.com/bianjieai/ethermint v0.6.1-0.20230824080820-7416e4b8e2c6/go.mod h1:JEhGmVj5rZX5bTfOqh3nltE2N6+qMI4HVNV2vW6PpOQ= +github.com/bianjieai/ethermint v0.6.1-0.20230914085944-3cc455cce3d4 h1:M3LU8I+hB9vqsK4oRFq0GxD+6Pzs48eWejvYuebtweQ= +github.com/bianjieai/ethermint v0.6.1-0.20230914085944-3cc455cce3d4/go.mod h1:JEhGmVj5rZX5bTfOqh3nltE2N6+qMI4HVNV2vW6PpOQ= github.com/bianjieai/nft-transfer v1.1.2-ibc-v6.1.0.0.20230911023600-fa7bd3f3cb1e h1:6XiMxCG7DpIOBjqw2rGtZgMIOgS/0KsbU6m84BQ0mfo= github.com/bianjieai/nft-transfer v1.1.2-ibc-v6.1.0.0.20230911023600-fa7bd3f3cb1e/go.mod h1:u2PNH4v8CD4AWU4Rf7yt8/qqQtrrwwHiw03qQSKERhg= github.com/bianjieai/tibc-go v0.4.4-0.20230824091732-bbd58021f825 h1:+/6FK0V7uXouVYigb1EvPGuDN1ZDPfBnvzOUbTRe4rg=