Skip to content

Commit

Permalink
Improve InitGenesis func in x/evm
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed May 1, 2024
1 parent ee18475 commit 556bfe6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion x/evm/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions x/evm/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
)
}
Expand Down
11 changes: 5 additions & 6 deletions x/evm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{}
}

Expand Down

0 comments on commit 556bfe6

Please sign in to comment.