From a8efba4649eaf8c8dfeb585f34ebb73792113b88 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Tue, 23 Jul 2024 11:19:08 -0700 Subject: [PATCH] chore: remove simapp imports --- app/ante/utils_test.go | 3 +- app/app.go | 46 ++++++++++++++++++------ app/app_test.go | 5 --- app/benchmark_test.go | 9 ----- app/export.go | 3 +- app/utils.go | 19 ++++------ cmd/ethermintd/root.go | 14 +++----- encoding/config.go | 6 ++-- ethereum/eip712/eip712_test.go | 4 +-- ethereum/eip712/encoding.go | 3 +- go.mod | 1 - go.sum | 2 -- gomod2nix.toml | 3 -- indexer/kv_indexer_test.go | 4 +-- testutil/network/network.go | 48 +++++++++++--------------- types/encoding.go | 16 +++++++++ x/evm/handler_test.go | 3 +- x/evm/keeper/integration_test.go | 4 --- x/evm/keeper/keeper_test.go | 3 +- x/feemarket/keeper/integration_test.go | 4 --- 20 files changed, 97 insertions(+), 103 deletions(-) create mode 100644 types/encoding.go diff --git a/app/ante/utils_test.go b/app/ante/utils_test.go index c5ddd77d..62f903b3 100644 --- a/app/ante/utils_test.go +++ b/app/ante/utils_test.go @@ -21,7 +21,6 @@ import ( "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" - "cosmossdk.io/simapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -84,7 +83,7 @@ func (suite *AnteTestSuite) SetupTest() { suite.Require().NoError(err) suite.priv = priv - suite.app = app.Setup(checkTx, func(app *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState { + suite.app = app.Setup(checkTx, func(app *app.EthermintApp, genesis app.GenesisState) app.GenesisState { if suite.enableFeemarket { // setup feemarketGenesis params feemarketGenesis := feemarkettypes.DefaultGenesisState() diff --git a/app/app.go b/app/app.go index 70839956..ff831477 100644 --- a/app/app.go +++ b/app/app.go @@ -36,9 +36,9 @@ import ( "github.com/cometbft/cometbft/libs/log" tmos "github.com/cometbft/cometbft/libs/os" - "cosmossdk.io/simapp" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/cosmos/cosmos-sdk/codec" @@ -123,8 +123,10 @@ import ( ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + "github.com/cosmos/cosmos-sdk/server" // unnamed import of statik for swagger UI support _ "github.com/evmos/ethermint/client/docs/statik" + "github.com/evmos/ethermint/encoding" "github.com/evmos/ethermint/app/ante" "github.com/evmos/ethermint/ethereum/eip712" @@ -140,7 +142,6 @@ import ( consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" - simappparams "cosmossdk.io/simapp/params" // Force-load the tracer engines to trigger registration due to Go-Ethereum v1.10.15 changes _ "github.com/ethereum/go-ethereum/eth/tracers/js" _ "github.com/ethereum/go-ethereum/eth/tracers/native" @@ -225,6 +226,7 @@ type EthermintApp struct { // encoding cdc *codec.LegacyAmino appCodec codec.Codec + txConfig client.TxConfig interfaceRegistry types.InterfaceRegistry invCheckPeriod uint @@ -282,15 +284,13 @@ func NewEthermintApp( db dbm.DB, traceStore io.Writer, loadLatest bool, - skipUpgradeHeights map[int64]bool, - homePath string, - invCheckPeriod uint, - encodingConfig simappparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *EthermintApp { + encodingConfig := encoding.MakeConfig(ModuleBasics) appCodec := encodingConfig.Codec cdc := encodingConfig.Amino + txConfig := encodingConfig.TxConfig interfaceRegistry := encodingConfig.InterfaceRegistry eip712.SetEncodingConfig(encodingConfig) @@ -308,12 +308,13 @@ func NewEthermintApp( appName, logger, db, - encodingConfig.TxConfig.TxDecoder(), + txConfig.TxDecoder(), baseAppOptions..., ) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) + bApp.SetTxEncoder(txConfig.TxEncoder()) keys := sdk.NewKVStoreKeys( // SDK keys @@ -338,9 +339,11 @@ func NewEthermintApp( os.Exit(1) } + invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)) app := &EthermintApp{ BaseApp: bApp, cdc: cdc, + txConfig: txConfig, appCodec: appCodec, interfaceRegistry: interfaceRegistry, invCheckPeriod: invCheckPeriod, @@ -428,6 +431,16 @@ func NewEthermintApp( keys[feegrant.StoreKey], app.AccountKeeper) + // get skipUpgradeHeights from the app options + skipUpgradeHeights := map[int64]bool{} + for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) { + skipUpgradeHeights[int64(h)] = true + } + homePath := cast.ToString(appOpts.Get(flags.FlagHome)) + if homePath == "" { + homePath = DefaultNodeHome + } + // set the governance module account as the authority for conducting upgrades app.UpgradeKeeper = *upgradekeeper.NewKeeper( skipUpgradeHeights, @@ -543,7 +556,7 @@ func NewEthermintApp( // SDK app modules genutil.NewAppModule( app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx, - encodingConfig.TxConfig, + txConfig, ), auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), @@ -711,7 +724,7 @@ func NewEthermintApp( app.SetInitChainer(app.InitChainer) app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) - app.setAnteHandler(encodingConfig.TxConfig, cast.ToUint64(appOpts.Get(srvflags.EVMMaxTxGasWanted))) + app.setAnteHandler(txConfig, cast.ToUint64(appOpts.Get(srvflags.EVMMaxTxGasWanted))) // In v0.46, the SDK introduces _postHandlers_. PostHandlers are like // antehandlers, but are run _after_ the `runMsgs` execution. They are also // defined as a chain, and have the same signature as antehandlers. @@ -791,7 +804,7 @@ func (app *EthermintApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) a // InitChainer updates at chain initialization func (app *EthermintApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { - var genesisState simapp.GenesisState + var genesisState GenesisState if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) } @@ -846,6 +859,19 @@ func (app *EthermintApp) InterfaceRegistry() types.InterfaceRegistry { return app.interfaceRegistry } +func (app *EthermintApp) TxConfig() client.TxConfig { + return app.txConfig +} + +func (app *EthermintApp) EncodingConfig() ethermint.EncodingConfig { + return ethermint.EncodingConfig{ + InterfaceRegistry: app.InterfaceRegistry(), + Codec: app.AppCodec(), + TxConfig: app.TxConfig(), + Amino: app.LegacyAmino(), + } +} + // GetKey returns the KVStoreKey for the provided store key. // // NOTE: This is solely to be used for testing purposes. diff --git a/app/app_test.go b/app/app_test.go index e4094920..bbaacd00 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - "github.com/evmos/ethermint/encoding" ) func TestEthermintAppExport(t *testing.T) { @@ -25,10 +24,6 @@ func TestEthermintAppExport(t *testing.T) { db, nil, true, - map[int64]bool{}, - DefaultNodeHome, - 0, - encoding.MakeConfig(ModuleBasics), simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), baseapp.SetChainID(ChainID), ) diff --git a/app/benchmark_test.go b/app/benchmark_test.go index 7921edc1..137b336f 100644 --- a/app/benchmark_test.go +++ b/app/benchmark_test.go @@ -10,7 +10,6 @@ import ( "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/baseapp" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - "github.com/evmos/ethermint/encoding" ) func BenchmarkEthermintApp_ExportAppStateAndValidators(b *testing.B) { @@ -20,10 +19,6 @@ func BenchmarkEthermintApp_ExportAppStateAndValidators(b *testing.B) { db, nil, true, - map[int64]bool{}, - DefaultNodeHome, - 0, - encoding.MakeConfig(ModuleBasics), simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), baseapp.SetChainID(ChainID), ) @@ -53,10 +48,6 @@ func BenchmarkEthermintApp_ExportAppStateAndValidators(b *testing.B) { db, nil, true, - map[int64]bool{}, - DefaultNodeHome, - 0, - encoding.MakeConfig(ModuleBasics), simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), baseapp.SetChainID(ChainID), ) diff --git a/app/export.go b/app/export.go index 6e78bfaa..bdd62481 100644 --- a/app/export.go +++ b/app/export.go @@ -21,7 +21,6 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - "cosmossdk.io/simapp" servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -33,7 +32,7 @@ import ( ) // NewDefaultGenesisState generates the default state for the application. -func NewDefaultGenesisState() simapp.GenesisState { +func NewDefaultGenesisState() GenesisState { encCfg := encoding.MakeConfig(ModuleBasics) return ModuleBasics.DefaultGenesis(encCfg.Codec) } diff --git a/app/utils.go b/app/utils.go index 9ecc59d8..f12050a4 100644 --- a/app/utils.go +++ b/app/utils.go @@ -19,7 +19,6 @@ import ( "encoding/json" "time" - "cosmossdk.io/simapp" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -30,8 +29,6 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/evmos/ethermint/encoding" - dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" @@ -41,6 +38,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +type GenesisState map[string]json.RawMessage + // DefaultConsensusParams defines the default Tendermint consensus params used in // EthermintApp testing. var DefaultConsensusParams = &tmproto.ConsensusParams{ @@ -61,22 +60,18 @@ var DefaultConsensusParams = &tmproto.ConsensusParams{ } // Setup initializes a new EthermintApp. A Nop logger is set in EthermintApp. -func Setup(isCheckTx bool, patchGenesis func(*EthermintApp, simapp.GenesisState) simapp.GenesisState) *EthermintApp { +func Setup(isCheckTx bool, patchGenesis func(*EthermintApp, GenesisState) GenesisState) *EthermintApp { return SetupWithDB(isCheckTx, patchGenesis, dbm.NewMemDB()) } const ChainID = "ethermint_9000-1" // SetupWithDB initializes a new EthermintApp. A Nop logger is set in EthermintApp. -func SetupWithDB(isCheckTx bool, patchGenesis func(*EthermintApp, simapp.GenesisState) simapp.GenesisState, db dbm.DB) *EthermintApp { +func SetupWithDB(isCheckTx bool, patchGenesis func(*EthermintApp, GenesisState) GenesisState, db dbm.DB) *EthermintApp { app := NewEthermintApp(log.NewNopLogger(), db, nil, true, - map[int64]bool{}, - DefaultNodeHome, - 5, - encoding.MakeConfig(ModuleBasics), simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), baseapp.SetChainID(ChainID), ) @@ -108,7 +103,7 @@ func SetupWithDB(isCheckTx bool, patchGenesis func(*EthermintApp, simapp.Genesis } // NewTestGenesisState generate genesis state with single validator -func NewTestGenesisState(codec codec.Codec) simapp.GenesisState { +func NewTestGenesisState(codec codec.Codec) GenesisState { privVal := mock.NewPV() pubKey, err := privVal.GetPubKey() if err != nil { @@ -130,10 +125,10 @@ func NewTestGenesisState(codec codec.Codec) simapp.GenesisState { return genesisStateWithValSet(codec, genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) } -func genesisStateWithValSet(codec codec.Codec, genesisState simapp.GenesisState, +func genesisStateWithValSet(codec codec.Codec, genesisState GenesisState, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance, -) simapp.GenesisState { +) GenesisState { // set genesis accounts authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) genesisState[authtypes.ModuleName] = codec.MustMarshalJSON(authGenesis) diff --git a/cmd/ethermintd/root.go b/cmd/ethermintd/root.go index 12ef6471..ec857db6 100644 --- a/cmd/ethermintd/root.go +++ b/cmd/ethermintd/root.go @@ -30,7 +30,6 @@ import ( tmcli "github.com/cometbft/cometbft/libs/cli" tmlog "github.com/cometbft/cometbft/libs/log" - "cosmossdk.io/simapp/params" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" @@ -66,7 +65,7 @@ const EnvPrefix = "ETHERMINT" // NewRootCmd creates a new root command for simd. It is called once in the // main function. -func NewRootCmd() (*cobra.Command, params.EncodingConfig) { +func NewRootCmd() (*cobra.Command, ethermint.EncodingConfig) { encodingConfig := encoding.MakeConfig(app.ModuleBasics) initClientCtx := client.Context{}. WithCodec(encodingConfig.Codec). @@ -210,7 +209,7 @@ func txCommand() *cobra.Command { } type appCreator struct { - encCfg params.EncodingConfig + encCfg ethermint.EncodingConfig } // newApp is an appCreator @@ -267,10 +266,7 @@ func (a appCreator) newApp(logger tmlog.Logger, db dbm.DB, traceStore io.Writer, chainID = conf.ChainID } ethermintApp := app.NewEthermintApp( - logger, db, traceStore, true, skipUpgradeHeights, - cast.ToString(appOpts.Get(flags.FlagHome)), - cast.ToUint(appOpts.Get(sdkserver.FlagInvCheckPeriod)), - a.encCfg, + logger, db, traceStore, true, appOpts, baseapp.SetPruning(pruningOpts), baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(sdkserver.FlagMinGasPrices))), @@ -308,13 +304,13 @@ func (a appCreator) appExport( } if height != -1 { - ethermintApp = app.NewEthermintApp(logger, db, traceStore, false, map[int64]bool{}, "", uint(1), a.encCfg, appOpts, baseapp.SetChainID(app.ChainID)) + ethermintApp = app.NewEthermintApp(logger, db, traceStore, false, appOpts, baseapp.SetChainID(app.ChainID)) if err := ethermintApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } else { - ethermintApp = app.NewEthermintApp(logger, db, traceStore, true, map[int64]bool{}, "", uint(1), a.encCfg, appOpts, baseapp.SetChainID(app.ChainID)) + ethermintApp = app.NewEthermintApp(logger, db, traceStore, false, appOpts, baseapp.SetChainID(app.ChainID)) } return ethermintApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) diff --git a/encoding/config.go b/encoding/config.go index 779ceab7..7f504b4d 100644 --- a/encoding/config.go +++ b/encoding/config.go @@ -16,22 +16,22 @@ package encoding import ( - "cosmossdk.io/simapp/params" amino "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/auth/tx" enccodec "github.com/evmos/ethermint/encoding/codec" + ethermint "github.com/evmos/ethermint/types" ) // MakeConfig creates an EncodingConfig for testing -func MakeConfig(mb module.BasicManager) params.EncodingConfig { +func MakeConfig(mb module.BasicManager) ethermint.EncodingConfig { cdc := amino.NewLegacyAmino() interfaceRegistry := types.NewInterfaceRegistry() codec := amino.NewProtoCodec(interfaceRegistry) - encodingConfig := params.EncodingConfig{ + encodingConfig := ethermint.EncodingConfig{ InterfaceRegistry: interfaceRegistry, Codec: codec, TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes), diff --git a/ethereum/eip712/eip712_test.go b/ethereum/eip712/eip712_test.go index 33d94736..451bea43 100644 --- a/ethereum/eip712/eip712_test.go +++ b/ethereum/eip712/eip712_test.go @@ -7,7 +7,6 @@ import ( "cosmossdk.io/math" - chainparams "cosmossdk.io/simapp/params" "github.com/cosmos/cosmos-sdk/client" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/signer/core/apitypes" @@ -33,6 +32,7 @@ import ( govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + ethermint "github.com/evmos/ethermint/types" "github.com/stretchr/testify/suite" ) @@ -46,7 +46,7 @@ const ( type EIP712TestSuite struct { suite.Suite - config chainparams.EncodingConfig + config ethermint.EncodingConfig clientCtx client.Context useLegacyEIP712TypedData bool denom string diff --git a/ethereum/eip712/encoding.go b/ethereum/eip712/encoding.go index 3d9a4643..9b270e84 100644 --- a/ethereum/eip712/encoding.go +++ b/ethereum/eip712/encoding.go @@ -19,7 +19,6 @@ import ( "errors" "fmt" - "cosmossdk.io/simapp/params" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" sdk "github.com/cosmos/cosmos-sdk/types" @@ -40,7 +39,7 @@ var ( // The process of unmarshaling SignDoc bytes into a SignDoc object requires having a codec // populated with all relevant message types. As a result, we must call this method on app // initialization with the app's encoding config. -func SetEncodingConfig(cfg params.EncodingConfig) { +func SetEncodingConfig(cfg types.EncodingConfig) { aminoCodec = cfg.Amino protoCodec = codec.NewProtoCodec(cfg.InterfaceRegistry) } diff --git a/go.mod b/go.mod index ebca4c15..1b776c8b 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( cosmossdk.io/api v0.3.1 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 - cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d cosmossdk.io/tools/rosetta v0.2.1 github.com/armon/go-metrics v0.4.1 github.com/btcsuite/btcd v0.23.4 diff --git a/go.sum b/go.sum index 18585da3..3d3f031a 100644 --- a/go.sum +++ b/go.sum @@ -199,8 +199,6 @@ cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= -cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d h1:E/8y0oG3u9hBR8l4F9MtC0LdZIamPCUwUoLlrHrX86I= -cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d/go.mod h1:xbjky3L3DJEylaho6gXplkrMvJ5sFgv+qNX+Nn47bzY= cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= cosmossdk.io/tools/rosetta v0.2.1/go.mod h1:Pqdc1FdvkNV3LcNIkYWt2RQY6IP1ge6YWZk8MhhO9Hw= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= diff --git a/gomod2nix.toml b/gomod2nix.toml index 9a8ae0da..c34b443a 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -34,9 +34,6 @@ schema = 3 [mod."cosmossdk.io/math"] version = "v1.3.0" hash = "sha256-EEFK43Cr0g0ndhQhkIKher0FqV3mvkmE9z0sP7uVSHg=" - [mod."cosmossdk.io/simapp"] - version = "v0.0.0-20230608160436-666c345ad23d" - hash = "sha256-6BMBA98BpK3jG6++ZE4LdPQwwpS+lZ0GLMRF1fO4UfM=" [mod."cosmossdk.io/tools/rosetta"] version = "v0.2.1" hash = "sha256-TrkXwA1ZdwSyu3te0DLMBynCb7CGEtefo2wzFvxeyU8=" diff --git a/indexer/kv_indexer_test.go b/indexer/kv_indexer_test.go index 0efd0c32..1d884aed 100644 --- a/indexer/kv_indexer_test.go +++ b/indexer/kv_indexer_test.go @@ -4,7 +4,6 @@ import ( "math/big" "testing" - "cosmossdk.io/simapp/params" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" tmlog "github.com/cometbft/cometbft/libs/log" @@ -17,6 +16,7 @@ import ( evmenc "github.com/evmos/ethermint/encoding" "github.com/evmos/ethermint/indexer" "github.com/evmos/ethermint/tests" + ethermint "github.com/evmos/ethermint/types" "github.com/evmos/ethermint/x/evm/types" "github.com/stretchr/testify/require" ) @@ -184,6 +184,6 @@ func TestKVIndexer(t *testing.T) { } // MakeEncodingConfig creates the EncodingConfig -func MakeEncodingConfig() params.EncodingConfig { +func MakeEncodingConfig() ethermint.EncodingConfig { return evmenc.MakeConfig(app.ModuleBasics) } diff --git a/testutil/network/network.go b/testutil/network/network.go index adb57b5f..44435826 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -43,8 +43,6 @@ import ( "github.com/spf13/cobra" "google.golang.org/grpc" - "cosmossdk.io/simapp" - "cosmossdk.io/simapp/params" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" @@ -82,17 +80,13 @@ var lock = new(sync.Mutex) type AppConstructor = func(val Validator) servertypes.Application // NewAppConstructor returns a new simapp AppConstructor -func NewAppConstructor(encodingCfg params.EncodingConfig, chainID string) AppConstructor { +func NewAppConstructor(chainID string) AppConstructor { return func(val Validator) servertypes.Application { return app.NewEthermintApp( val.Ctx.Logger, dbm.NewMemDB(), nil, true, - make(map[int64]bool), - val.Ctx.Config.RootDir, - 0, - encodingCfg, simtestutil.NewAppOptionsWithFlagHome(val.Ctx.Config.RootDir), baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), @@ -110,25 +104,25 @@ type Config struct { InterfaceRegistry codectypes.InterfaceRegistry TxConfig client.TxConfig AccountRetriever client.AccountRetriever - AppConstructor AppConstructor // the ABCI application constructor - GenesisState simapp.GenesisState // custom gensis state to provide - TimeoutCommit time.Duration // the consensus commitment timeout - AccountTokens sdkmath.Int // the amount of unique validator tokens (e.g. 1000node0) - StakingTokens sdkmath.Int // the amount of tokens each validator has available to stake - BondedTokens sdkmath.Int // the amount of tokens each validator stakes - NumValidators int // the total number of validators to create and bond - ChainID string // the network chain-id - BondDenom string // the staking bond denomination - MinGasPrices string // the minimum gas prices each validator will accept - PruningStrategy string // the pruning strategy each validator will have - SigningAlgo string // signing algorithm for keys - RPCAddress string // RPC listen address (including port) - JSONRPCAddress string // JSON-RPC listen address (including port) - APIAddress string // REST API listen address (including port) - GRPCAddress string // GRPC server listen address (including port) - EnableTMLogging bool // enable Tendermint logging to STDOUT - CleanupDir bool // remove base temporary directory during cleanup - PrintMnemonic bool // print the mnemonic of first validator as log output for testing + AppConstructor AppConstructor // the ABCI application constructor + GenesisState app.GenesisState // custom gensis state to provide + TimeoutCommit time.Duration // the consensus commitment timeout + AccountTokens sdkmath.Int // the amount of unique validator tokens (e.g. 1000node0) + StakingTokens sdkmath.Int // the amount of tokens each validator has available to stake + BondedTokens sdkmath.Int // the amount of tokens each validator stakes + NumValidators int // the total number of validators to create and bond + ChainID string // the network chain-id + BondDenom string // the staking bond denomination + MinGasPrices string // the minimum gas prices each validator will accept + PruningStrategy string // the pruning strategy each validator will have + SigningAlgo string // signing algorithm for keys + RPCAddress string // RPC listen address (including port) + JSONRPCAddress string // JSON-RPC listen address (including port) + APIAddress string // REST API listen address (including port) + GRPCAddress string // GRPC server listen address (including port) + EnableTMLogging bool // enable Tendermint logging to STDOUT + CleanupDir bool // remove base temporary directory during cleanup + PrintMnemonic bool // print the mnemonic of first validator as log output for testing } // DefaultConfig returns a sane default configuration suitable for nearly all @@ -142,7 +136,7 @@ func DefaultConfig() Config { LegacyAmino: encCfg.Amino, InterfaceRegistry: encCfg.InterfaceRegistry, AccountRetriever: authtypes.AccountRetriever{}, - AppConstructor: NewAppConstructor(encCfg, chainID), + AppConstructor: NewAppConstructor(chainID), GenesisState: app.ModuleBasics.DefaultGenesis(encCfg.Codec), TimeoutCommit: 2 * time.Second, ChainID: chainID, diff --git a/types/encoding.go b/types/encoding.go new file mode 100644 index 00000000..e4a4f1e3 --- /dev/null +++ b/types/encoding.go @@ -0,0 +1,16 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" +) + +// EncodingConfig specifies the concrete encoding types to use for a given app. +// This is provided for compatibility between protobuf and amino implementations. +type EncodingConfig struct { + InterfaceRegistry types.InterfaceRegistry + Codec codec.Codec + TxConfig client.TxConfig + Amino *codec.LegacyAmino +} diff --git a/x/evm/handler_test.go b/x/evm/handler_test.go index bd2a507b..ac30d678 100644 --- a/x/evm/handler_test.go +++ b/x/evm/handler_test.go @@ -14,7 +14,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" tmjson "github.com/cometbft/cometbft/libs/json" - "cosmossdk.io/simapp" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -80,7 +79,7 @@ func (suite *EvmTestSuite) DoSetupTest(t require.TestingT) { require.NoError(t, err) consAddress := sdk.ConsAddress(priv.PubKey().Address()) - suite.app = app.Setup(checkTx, func(app *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState { + suite.app = app.Setup(checkTx, func(app *app.EthermintApp, genesis app.GenesisState) app.GenesisState { if suite.dynamicTxFee { feemarketGenesis := feemarkettypes.DefaultGenesisState() feemarketGenesis.Params.EnableHeight = 1 diff --git a/x/evm/keeper/integration_test.go b/x/evm/keeper/integration_test.go index 73aa363f..d0b42681 100644 --- a/x/evm/keeper/integration_test.go +++ b/x/evm/keeper/integration_test.go @@ -173,10 +173,6 @@ func setupChain(localMinGasPricesStr string) { db, nil, true, - map[int64]bool{}, - app.DefaultNodeHome, - 5, - encoding.MakeConfig(app.ModuleBasics), simtestutil.NewAppOptionsWithFlagHome(app.DefaultNodeHome), baseapp.SetMinGasPrices(localMinGasPricesStr), baseapp.SetChainID(app.ChainID), diff --git a/x/evm/keeper/keeper_test.go b/x/evm/keeper/keeper_test.go index 6478c7d8..11e773ed 100644 --- a/x/evm/keeper/keeper_test.go +++ b/x/evm/keeper/keeper_test.go @@ -16,7 +16,6 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "cosmossdk.io/simapp" tmjson "github.com/cometbft/cometbft/libs/json" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -123,7 +122,7 @@ func (suite *KeeperTestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { require.NoError(t, err) suite.consAddress = sdk.ConsAddress(priv.PubKey().Address()) - suite.app = app.Setup(checkTx, func(app *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState { + suite.app = app.Setup(checkTx, func(app *app.EthermintApp, genesis app.GenesisState) app.GenesisState { feemarketGenesis := feemarkettypes.DefaultGenesisState() if suite.enableFeemarket { feemarketGenesis.Params.EnableHeight = 1 diff --git a/x/feemarket/keeper/integration_test.go b/x/feemarket/keeper/integration_test.go index 66545def..6357dcb7 100644 --- a/x/feemarket/keeper/integration_test.go +++ b/x/feemarket/keeper/integration_test.go @@ -488,10 +488,6 @@ func setupChain(localMinGasPricesStr string) { db, nil, true, - map[int64]bool{}, - app.DefaultNodeHome, - 5, - encoding.MakeConfig(app.ModuleBasics), simtestutil.NewAppOptionsWithFlagHome(app.DefaultNodeHome), baseapp.SetMinGasPrices(localMinGasPricesStr), baseapp.SetChainID(app.ChainID),