From 556bfe64ed36b2b9a8702b0a9f846684eaa9061e Mon Sep 17 00:00:00 2001 From: evgeniy-scherbina Date: Wed, 1 May 2024 11:43:19 -0400 Subject: [PATCH] Improve InitGenesis func in x/evm --- x/evm/genesis.go | 3 ++- x/evm/genesis_test.go | 4 ++-- x/evm/module.go | 11 +++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/x/evm/genesis.go b/x/evm/genesis.go index 86b0075ea2..67ef6c33cc 100644 --- a/x/evm/genesis.go +++ b/x/evm/genesis.go @@ -36,11 +36,12 @@ func InitGenesis( k *keeper.Keeper, accountKeeper types.AccountKeeper, data types.GenesisState, + registeredModules []precompile_modules.Module, ) []abci.ValidatorUpdate { k.WithChainID(ctx) err := types.CheckIfEnabledPrecompilesAreRegistered( - precompile_modules.RegisteredModules(), + registeredModules, data.Params.GetEnabledPrecompiles(), ) if err != nil { diff --git a/x/evm/genesis_test.go b/x/evm/genesis_test.go index e060c5d965..107b8b4290 100644 --- a/x/evm/genesis_test.go +++ b/x/evm/genesis_test.go @@ -149,13 +149,13 @@ func (suite *EvmTestSuite) TestInitGenesis() { if tc.expPanic { suite.Require().Panics( func() { - _ = evm.InitGenesis(suite.ctx, suite.app.EvmKeeper, suite.app.AccountKeeper, *tc.genState) + _ = evm.InitGenesis(suite.ctx, suite.app.EvmKeeper, suite.app.AccountKeeper, *tc.genState, nil) }, ) } else { suite.Require().NotPanics( func() { - _ = evm.InitGenesis(suite.ctx, suite.app.EvmKeeper, suite.app.AccountKeeper, *tc.genState) + _ = evm.InitGenesis(suite.ctx, suite.app.EvmKeeper, suite.app.AccountKeeper, *tc.genState, nil) }, ) } diff --git a/x/evm/module.go b/x/evm/module.go index 80ac05269b..353f887a96 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -20,18 +20,17 @@ import ( "encoding/json" "fmt" - "github.com/gorilla/mux" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + precompile_modules "github.com/ethereum/go-ethereum/precompile/modules" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" "github.com/evmos/ethermint/x/evm/client/cli" "github.com/evmos/ethermint/x/evm/keeper" @@ -166,7 +165,7 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - InitGenesis(ctx, am.keeper, am.ak, genesisState) + InitGenesis(ctx, am.keeper, am.ak, genesisState, precompile_modules.RegisteredModules()) return []abci.ValidatorUpdate{} }