Skip to content

Commit

Permalink
bump-up ethermint to resolve panic of accessing consensus parmas at u…
Browse files Browse the repository at this point in the history
…pgrade block
  • Loading branch information
taramakage committed Sep 14, 2023
1 parent 419abb5 commit 167415b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 37 deletions.
32 changes: 4 additions & 28 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down
5 changes: 3 additions & 2 deletions app/modules.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
7 changes: 3 additions & 4 deletions app/upgrades/v210/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 167415b

Please sign in to comment.