diff --git a/Makefile b/Makefile index 771e6f58..fe9cec02 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,40 @@ #!/usr/bin/make -f -PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation') +############################################################################### +### Module & Versioning ### +############################################################################### + VERSION ?= $(shell echo $(shell git describe --tags --always) | sed 's/^v//') TMVERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::') COMMIT := $(shell git log -1 --format='%H') + +############################################################################### +### Directories & Binaries ### +############################################################################### + BINDIR ?= $(GOPATH)/bin -EXAMPLE_BINARY = evmd BUILDDIR ?= $(CURDIR)/build +EXAMPLE_BINARY := evmd + +############################################################################### +### Repo Info ### +############################################################################### + HTTPS_GIT := https://github.com/cosmos/evm.git DOCKER := $(shell which docker) export GO111MODULE = on -# Default target executed when no arguments are given to make. -default_target: all +############################################################################### +### Submodule Settings ### +############################################################################### -.PHONY: build default_target +# evmd is a separate module under ./evmd +EVMD_DIR := evmd +EVMD_MAIN_PKG := ./cmd/evmd ############################################################################### -### evmd Build & Install ### +### Build & Install evmd ### ############################################################################### # process build tags @@ -71,19 +87,29 @@ ifneq (,$(findstring nooptimization,$(COSMOS_BUILD_OPTIONS))) BUILD_FLAGS += -gcflags "all=-N -l" endif +# Build into $(BUILDDIR) +build: go.sum $(BUILDDIR)/ + @echo "🏗️ Building evmd to $(BUILDDIR)/$(EXAMPLE_BINARY) ..." + @cd $(EVMD_DIR) && CGO_ENABLED="1" \ + go build $(BUILD_FLAGS) -o $(BUILDDIR)/$(EXAMPLE_BINARY) $(EVMD_MAIN_PKG) -BUILD_TARGETS := build install - -build: BUILD_ARGS=-o $(BUILDDIR)/ +# Cross-compile for Linux AMD64 build-linux: GOOS=linux GOARCH=amd64 $(MAKE) build -$(BUILD_TARGETS): go.sum $(BUILDDIR)/ - CGO_ENABLED="1" go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./... +# Install into $(BINDIR) +install: go.sum + @echo "🚚 Installing evmd to $(BINDIR) ..." + @cd $(EVMD_DIR) && CGO_ENABLED="1" \ + go install $(BUILD_FLAGS) $(EVMD_MAIN_PKG) $(BUILDDIR)/: mkdir -p $(BUILDDIR)/ +# Default & all target +.PHONY: all build build-linux install +all: build + ############################################################################### ### Tools & Dependencies ### ############################################################################### @@ -101,6 +127,7 @@ vulncheck: ### Tests & Simulation ### ############################################################################### +PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation') PACKAGES_UNIT := $(shell go list ./... | grep -v '/tests/e2e$$' | grep -v '/simulation') PACKAGES_EVMD := $(shell cd evmd && go list ./... | grep -v '/simulation') COVERPKG_EVM := $(shell go list ./... | grep -v '/tests/e2e$$' | grep -v '/simulation' | paste -sd, -) diff --git a/ante/evm/fee_checker_test.go b/ante/evm/fee_checker_test.go index 87038f78..a5cbc373 100644 --- a/ante/evm/fee_checker_test.go +++ b/ante/evm/fee_checker_test.go @@ -10,9 +10,8 @@ import ( "github.com/cosmos/evm/ante/evm" anteinterfaces "github.com/cosmos/evm/ante/interfaces" - evmdconfig "github.com/cosmos/evm/cmd/evmd/config" "github.com/cosmos/evm/encoding" - "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm/testutil/config" testconstants "github.com/cosmos/evm/testutil/constants" "github.com/cosmos/evm/types" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" @@ -58,9 +57,9 @@ func TestSDKTxFeeChecker(t *testing.T) { // with extension option // without extension option // london hardfork enableness - chainID := uint64(evmdconfig.EighteenDecimalsChainID) + chainID := uint64(config.EighteenDecimalsChainID) encodingConfig := encoding.MakeConfig(chainID) - err := evmd.EvmAppOptions(chainID) + err := config.EvmAppOptions(chainID) require.NoError(t, err) evmDenom := evmtypes.GetEVMCoinDenom() diff --git a/cmd/evmd/config/opendb.go b/cmd/evmd/config/opendb.go deleted file mode 100644 index af6de8dc..00000000 --- a/cmd/evmd/config/opendb.go +++ /dev/null @@ -1,30 +0,0 @@ -//go:build !rocksdb -// +build !rocksdb - -package config - -import ( - "path/filepath" - - dbm "github.com/cosmos/cosmos-db" - - "github.com/cosmos/cosmos-sdk/server/types" -) - -// OpenDB opens a database based on the specified backend type. -// It takes the home directory where the database data will be stored, along with the backend type. -// It opens a database named "application" using the specified backend type and the data directory. -// It returns the opened database and an error (if any). If the database opens successfully, the error will be nil. -// -// NOTE: this is included in builds without rocksdb. -// When building the binary with rocksdb, the code in 'rocksdb.go' will be included -// instead of this -func OpenDB(_ types.AppOptions, home string, backendType dbm.BackendType) (dbm.DB, error) { - dataDir := filepath.Join(home, "data") - return dbm.NewDB("application", backendType, dataDir) -} - -// OpenReadOnlyDB opens rocksdb backend in read-only mode. -func OpenReadOnlyDB(home string, backendType dbm.BackendType) (dbm.DB, error) { - return OpenDB(nil, home, backendType) -} diff --git a/tests/integration/ante/benchmark_evm_antehandler.go b/evmd/ante/evm_antehandler_benchmark_test.go similarity index 91% rename from tests/integration/ante/benchmark_evm_antehandler.go rename to evmd/ante/evm_antehandler_benchmark_test.go index 30d1c22b..45c81e5d 100644 --- a/tests/integration/ante/benchmark_evm_antehandler.go +++ b/evmd/ante/evm_antehandler_benchmark_test.go @@ -1,4 +1,4 @@ -package ante +package ante_test import ( "fmt" @@ -7,7 +7,8 @@ import ( "github.com/cosmos/evm/ante" ethante "github.com/cosmos/evm/ante/evm" - chainante "github.com/cosmos/evm/evmd/ante" + evmdante "github.com/cosmos/evm/evmd/ante" + "github.com/cosmos/evm/evmd/tests/integration" basefactory "github.com/cosmos/evm/testutil/integration/base/factory" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" @@ -81,7 +82,7 @@ func RunBenchmarkAnteHandler(b *testing.B, create network.CreateEvmApp, options } handlerOptions := suite.generateHandlerOptions() - ante := chainante.NewAnteHandler(handlerOptions) + ante := evmdante.NewAnteHandler(handlerOptions) b.StartTimer() b.Run(fmt.Sprintf("tx_type_%v", v.name), func(b *testing.B) { @@ -141,9 +142,9 @@ func (s *benchmarkSuite) generateTxType(txType string) (sdktypes.Tx, error) { } } -func (s *benchmarkSuite) generateHandlerOptions() chainante.HandlerOptions { +func (s *benchmarkSuite) generateHandlerOptions() evmdante.HandlerOptions { encCfg := s.network.GetEncodingConfig() - return chainante.HandlerOptions{ + return evmdante.HandlerOptions{ Cdc: s.network.App.AppCodec(), AccountKeeper: s.network.App.GetAccountKeeper(), BankKeeper: s.network.App.GetBankKeeper(), @@ -158,3 +159,8 @@ func (s *benchmarkSuite) generateHandlerOptions() chainante.HandlerOptions { TxFeeChecker: ethante.NewDynamicFeeChecker(s.network.App.GetFeeMarketKeeper()), } } + +func BenchmarkAnteHandler(b *testing.B) { + // Run the benchmark with a mock EVM app + RunBenchmarkAnteHandler(b, integration.CreateEvmd) +} diff --git a/tests/integration/ante/test_validate_handler_options.go b/evmd/ante/validate_handler_options_test.go similarity index 87% rename from tests/integration/ante/test_validate_handler_options.go rename to evmd/ante/validate_handler_options_test.go index 4a94362b..8cd9b8cc 100644 --- a/tests/integration/ante/test_validate_handler_options.go +++ b/evmd/ante/validate_handler_options_test.go @@ -1,4 +1,4 @@ -package ante +package ante_test import ( "testing" @@ -7,7 +7,8 @@ import ( "github.com/cosmos/evm/ante" ethante "github.com/cosmos/evm/ante/evm" - chainante "github.com/cosmos/evm/evmd/ante" + evmdante "github.com/cosmos/evm/evmd/ante" + "github.com/cosmos/evm/evmd/tests/integration" "github.com/cosmos/evm/testutil/integration/evm/network" "github.com/cosmos/evm/types" ) @@ -17,17 +18,17 @@ func RunValidateHandlerOptionsTest(t *testing.T, create network.CreateEvmApp, op nw := network.NewUnitTestNetwork(create, options...) cases := []struct { name string - options chainante.HandlerOptions + options evmdante.HandlerOptions expPass bool }{ { "fail - empty options", - chainante.HandlerOptions{}, + evmdante.HandlerOptions{}, false, }, { "fail - empty account keeper", - chainante.HandlerOptions{ + evmdante.HandlerOptions{ Cdc: nw.App.AppCodec(), AccountKeeper: nil, }, @@ -35,7 +36,7 @@ func RunValidateHandlerOptionsTest(t *testing.T, create network.CreateEvmApp, op }, { "fail - empty bank keeper", - chainante.HandlerOptions{ + evmdante.HandlerOptions{ Cdc: nw.App.AppCodec(), AccountKeeper: nw.App.GetAccountKeeper(), BankKeeper: nil, @@ -44,7 +45,7 @@ func RunValidateHandlerOptionsTest(t *testing.T, create network.CreateEvmApp, op }, { "fail - empty IBC keeper", - chainante.HandlerOptions{ + evmdante.HandlerOptions{ Cdc: nw.App.AppCodec(), AccountKeeper: nw.App.GetAccountKeeper(), BankKeeper: nw.App.GetBankKeeper(), @@ -54,7 +55,7 @@ func RunValidateHandlerOptionsTest(t *testing.T, create network.CreateEvmApp, op }, { "fail - empty fee market keeper", - chainante.HandlerOptions{ + evmdante.HandlerOptions{ Cdc: nw.App.AppCodec(), AccountKeeper: nw.App.GetAccountKeeper(), BankKeeper: nw.App.GetBankKeeper(), @@ -65,7 +66,7 @@ func RunValidateHandlerOptionsTest(t *testing.T, create network.CreateEvmApp, op }, { "fail - empty EVM keeper", - chainante.HandlerOptions{ + evmdante.HandlerOptions{ Cdc: nw.App.AppCodec(), AccountKeeper: nw.App.GetAccountKeeper(), BankKeeper: nw.App.GetBankKeeper(), @@ -77,7 +78,7 @@ func RunValidateHandlerOptionsTest(t *testing.T, create network.CreateEvmApp, op }, { "fail - empty signature gas consumer", - chainante.HandlerOptions{ + evmdante.HandlerOptions{ Cdc: nw.App.AppCodec(), AccountKeeper: nw.App.GetAccountKeeper(), BankKeeper: nw.App.GetBankKeeper(), @@ -90,7 +91,7 @@ func RunValidateHandlerOptionsTest(t *testing.T, create network.CreateEvmApp, op }, { "fail - empty signature mode handler", - chainante.HandlerOptions{ + evmdante.HandlerOptions{ Cdc: nw.App.AppCodec(), AccountKeeper: nw.App.GetAccountKeeper(), BankKeeper: nw.App.GetBankKeeper(), @@ -104,7 +105,7 @@ func RunValidateHandlerOptionsTest(t *testing.T, create network.CreateEvmApp, op }, { "fail - empty tx fee checker", - chainante.HandlerOptions{ + evmdante.HandlerOptions{ Cdc: nw.App.AppCodec(), AccountKeeper: nw.App.GetAccountKeeper(), BankKeeper: nw.App.GetBankKeeper(), @@ -119,7 +120,7 @@ func RunValidateHandlerOptionsTest(t *testing.T, create network.CreateEvmApp, op }, { "success - default app options", - chainante.HandlerOptions{ + evmdante.HandlerOptions{ Cdc: nw.App.AppCodec(), AccountKeeper: nw.App.GetAccountKeeper(), BankKeeper: nw.App.GetBankKeeper(), @@ -146,3 +147,7 @@ func RunValidateHandlerOptionsTest(t *testing.T, create network.CreateEvmApp, op } } } + +func TestValidateHandlerOptions(t *testing.T) { + RunValidateHandlerOptionsTest(t, integration.CreateEvmd) +} diff --git a/evmd/app.go b/evmd/app.go index b1b2fead..20d4fbf7 100644 --- a/evmd/app.go +++ b/evmd/app.go @@ -4,11 +4,8 @@ import ( "encoding/json" "fmt" "io" - "maps" "os" - "sort" - corevm "github.com/ethereum/go-ethereum/core/vm" "github.com/spf13/cast" // Force-load the tracer engines to trigger registration due to Go-Ethereum v1.10.15 changes @@ -21,10 +18,10 @@ import ( evmante "github.com/cosmos/evm/ante" cosmosevmante "github.com/cosmos/evm/ante/evm" evmosencoding "github.com/cosmos/evm/encoding" - chainante "github.com/cosmos/evm/evmd/ante" + "github.com/cosmos/evm/evmd/ante" + evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" srvflags "github.com/cosmos/evm/server/flags" cosmosevmtypes "github.com/cosmos/evm/types" - cosmosevmutils "github.com/cosmos/evm/utils" "github.com/cosmos/evm/x/erc20" erc20keeper "github.com/cosmos/evm/x/erc20/keeper" erc20types "github.com/cosmos/evm/x/erc20/types" @@ -60,7 +57,6 @@ import ( autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" "cosmossdk.io/client/v2/autocli" - clienthelpers "cosmossdk.io/client/v2/helpers" "cosmossdk.io/core/appmodule" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" @@ -139,36 +135,14 @@ func init() { // manually update the power reduction by replacing micro (u) -> atto (a) evmos sdk.DefaultPowerReduction = cosmosevmtypes.AttoPowerReduction - // get the user's home directory - var err error - DefaultNodeHome, err = clienthelpers.GetNodeHomeDirectory(".evmd") - if err != nil { - panic(err) - } + defaultNodeHome = evmdconfig.MustGetDefaultNodeHome() } const appName = "evmd" var ( - // DefaultNodeHome default home directories for the application daemon - DefaultNodeHome string - - // module account permissions - maccPerms = map[string][]string{ - authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, - ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - minttypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - govtypes.ModuleName: {authtypes.Burner}, - - // Cosmos EVM modules - evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - feemarkettypes.ModuleName: nil, - erc20types.ModuleName: {authtypes.Minter, authtypes.Burner}, - precisebanktypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - } + // defaultNodeHome default home directories for the application daemon + defaultNodeHome string ) var ( @@ -236,7 +210,7 @@ func NewExampleApp( loadLatest bool, appOpts servertypes.AppOptions, evmChainID uint64, - evmAppOptions EVMOptionsFn, + evmAppOptions evmdconfig.EVMOptionsFn, baseAppOptions ...func(*baseapp.BaseApp), ) *EVMD { encodingConfig := evmosencoding.MakeConfig(evmChainID) @@ -341,7 +315,7 @@ func NewExampleApp( // add keepers app.AccountKeeper = authkeeper.NewAccountKeeper( appCodec, runtime.NewKVStoreService(keys[authtypes.StoreKey]), - authtypes.ProtoBaseAccount, maccPerms, + authtypes.ProtoBaseAccount, evmdconfig.GetMaccPerms(), authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), sdk.GetConfig().GetBech32AccountAddrPrefix(), authAddr, @@ -351,7 +325,7 @@ func NewExampleApp( appCodec, runtime.NewKVStoreService(keys[banktypes.StoreKey]), app.AccountKeeper, - BlockedAddresses(), + evmdconfig.BlockedAddresses(), authAddr, logger, ) @@ -832,7 +806,7 @@ func NewExampleApp( } func (app *EVMD) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64) { - options := chainante.HandlerOptions{ + options := ante.HandlerOptions{ Cdc: app.appCodec, AccountKeeper: app.AccountKeeper, BankKeeper: app.BankKeeper, @@ -850,7 +824,7 @@ func (app *EVMD) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64) { panic(err) } - app.SetAnteHandler(chainante.NewAnteHandler(options)) + app.SetAnteHandler(ante.NewAnteHandler(options)) } func (app *EVMD) setPostHandler() { @@ -1148,43 +1122,6 @@ func (app *EVMD) AutoCliOpts() autocli.AppOptions { } } -// GetMaccPerms returns a copy of the module account permissions -func GetMaccPerms() map[string][]string { - return maps.Clone(maccPerms) -} - -// BlockedAddresses returns all the app's blocked account addresses. -// -// Note, this includes: -// - module accounts -// - Ethereum's native precompiled smart contracts -// - Cosmos EVM' available static precompiled contracts -func BlockedAddresses() map[string]bool { - blockedAddrs := make(map[string]bool) - - maccPerms := GetMaccPerms() - accs := make([]string, 0, len(maccPerms)) - for acc := range maccPerms { - accs = append(accs, acc) - } - sort.Strings(accs) - - for _, acc := range accs { - blockedAddrs[authtypes.NewModuleAddress(acc).String()] = true - } - - blockedPrecompilesHex := evmtypes.AvailableStaticPrecompiles - for _, addr := range corevm.PrecompiledAddressesBerlin { - blockedPrecompilesHex = append(blockedPrecompilesHex, addr.Hex()) - } - - for _, precompile := range blockedPrecompilesHex { - blockedAddrs[cosmosevmutils.Bech32StringFromHexAddress(precompile)] = true - } - - return blockedAddrs -} - // initParamsKeeper init params keeper and its subspaces func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper { //nolint:staticcheck paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) //nolint:staticcheck diff --git a/cmd/evmd/cmd/root.go b/evmd/cmd/evmd/cmd/root.go similarity index 82% rename from cmd/evmd/cmd/root.go rename to evmd/cmd/evmd/cmd/root.go index e8b99d7d..a44a6581 100644 --- a/cmd/evmd/cmd/root.go +++ b/evmd/cmd/evmd/cmd/root.go @@ -14,11 +14,10 @@ import ( dbm "github.com/cosmos/cosmos-db" cosmosevmcmd "github.com/cosmos/evm/client" - evmdconfig "github.com/cosmos/evm/cmd/evmd/config" cosmosevmkeyring "github.com/cosmos/evm/crypto/keyring" "github.com/cosmos/evm/evmd" + evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" cosmosevmserver "github.com/cosmos/evm/server" - cosmosevmserverconfig "github.com/cosmos/evm/server/config" srvflags "github.com/cosmos/evm/server/flags" "cosmossdk.io/log" @@ -36,7 +35,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/rpc" "github.com/cosmos/cosmos-sdk/client/snapshot" sdkserver "github.com/cosmos/cosmos-sdk/server" - serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" @@ -84,7 +82,7 @@ func NewRootCmd() *cobra.Command { WithInput(os.Stdin). WithAccountRetriever(authtypes.AccountRetriever{}). WithBroadcastMode(flags.FlagBroadcastMode). - WithHomeDir(evmd.DefaultNodeHome). + WithHomeDir(evmdconfig.MustGetDefaultNodeHome()). WithViper(""). // In simapp, we don't use any prefix for env variables. // Cosmos EVM specific setup WithKeyringOptions(cosmosevmkeyring.Option()). @@ -133,7 +131,7 @@ func NewRootCmd() *cobra.Command { return err } - customAppTemplate, customAppConfig := InitAppConfig(evmdconfig.BaseDenom, evmdconfig.EVMChainID) + customAppTemplate, customAppConfig := evmdconfig.InitAppConfig(evmdconfig.BaseDenom, evmdconfig.EVMChainID) customTMConfig := initTendermintConfig() return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTMConfig) @@ -151,7 +149,7 @@ func NewRootCmd() *cobra.Command { } if initClientCtx.ChainID != "" { - if err := evmd.EvmAppOptions(evmdconfig.EVMChainID); err != nil { + if err := evmdconfig.EvmAppOptions(evmdconfig.EVMChainID); err != nil { panic(err) } } @@ -171,78 +169,32 @@ func initTendermintConfig() *tmcfg.Config { return cfg } -// InitAppConfig helps to override default appConfig template and configs. -// return "", nil if no custom configuration is required for the application. -func InitAppConfig(denom string, evmChainID uint64) (string, interface{}) { - type CustomAppConfig struct { - serverconfig.Config - - EVM cosmosevmserverconfig.EVMConfig - JSONRPC cosmosevmserverconfig.JSONRPCConfig - TLS cosmosevmserverconfig.TLSConfig - } - - // Optionally allow the chain developer to overwrite the SDK's default - // server config. - srvCfg := serverconfig.DefaultConfig() - // The SDK's default minimum gas price is set to "" (empty value) inside - // app.toml. If left empty by validators, the node will halt on startup. - // However, the chain developer can set a default app.toml value for their - // validators here. - // - // In summary: - // - if you leave srvCfg.MinGasPrices = "", all validators MUST tweak their - // own app.toml config, - // - if you set srvCfg.MinGasPrices non-empty, validators CAN tweak their - // own app.toml to override, or use this default value. - // - // In this example application, we set the min gas prices to 0. - srvCfg.MinGasPrices = "0" + denom - - evmCfg := cosmosevmserverconfig.DefaultEVMConfig() - evmCfg.EVMChainID = evmChainID - - customAppConfig := CustomAppConfig{ - Config: *srvCfg, - EVM: *evmCfg, - JSONRPC: *cosmosevmserverconfig.DefaultJSONRPCConfig(), - TLS: *cosmosevmserverconfig.DefaultTLSConfig(), - } - - customAppTemplate := serverconfig.DefaultConfigTemplate + - cosmosevmserverconfig.DefaultEVMConfigTemplate - - return customAppTemplate, customAppConfig -} - func initRootCmd(rootCmd *cobra.Command, osApp *evmd.EVMD) { cfg := sdk.GetConfig() cfg.Seal() + defaultNodeHome := evmdconfig.MustGetDefaultNodeHome() rootCmd.AddCommand( - genutilcli.InitCmd( - osApp.BasicModuleManager, - evmd.DefaultNodeHome, - ), - genutilcli.Commands(osApp.TxConfig(), osApp.BasicModuleManager, evmd.DefaultNodeHome), + genutilcli.InitCmd(osApp.BasicModuleManager, defaultNodeHome), + genutilcli.Commands(osApp.TxConfig(), osApp.BasicModuleManager, defaultNodeHome), cmtcli.NewCompletionCmd(rootCmd, true), debug.Cmd(), confixcmd.ConfigCommand(), - pruning.Cmd(newApp, evmd.DefaultNodeHome), + pruning.Cmd(newApp, defaultNodeHome), snapshot.Cmd(newApp), ) // add Cosmos EVM' flavored TM commands to start server, etc. cosmosevmserver.AddCommands( rootCmd, - cosmosevmserver.NewDefaultStartOptions(newApp, evmd.DefaultNodeHome), + cosmosevmserver.NewDefaultStartOptions(newApp, defaultNodeHome), appExport, addModuleInitFlags, ) // add Cosmos EVM key commands rootCmd.AddCommand( - cosmosevmcmd.KeyCommands(evmd.DefaultNodeHome, true), + cosmosevmcmd.KeyCommands(defaultNodeHome, true), ) // add keybase, auxiliary RPC, query, genesis, and tx child commands @@ -375,7 +327,7 @@ func newApp( logger, db, traceStore, true, appOpts, evmdconfig.EVMChainID, - evmd.EvmAppOptions, + evmdconfig.EvmAppOptions, baseappOptions..., ) } @@ -416,13 +368,13 @@ func appExport( } if height != -1 { - exampleApp = evmd.NewExampleApp(logger, db, traceStore, false, appOpts, evmdconfig.EVMChainID, evmd.EvmAppOptions, baseapp.SetChainID(chainID)) + exampleApp = evmd.NewExampleApp(logger, db, traceStore, false, appOpts, evmdconfig.EVMChainID, evmdconfig.EvmAppOptions, baseapp.SetChainID(chainID)) if err := exampleApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } else { - exampleApp = evmd.NewExampleApp(logger, db, traceStore, true, appOpts, evmdconfig.EVMChainID, evmd.EvmAppOptions, baseapp.SetChainID(chainID)) + exampleApp = evmd.NewExampleApp(logger, db, traceStore, true, appOpts, evmdconfig.EVMChainID, evmdconfig.EvmAppOptions, baseapp.SetChainID(chainID)) } return exampleApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) diff --git a/evmd/activators.go b/evmd/cmd/evmd/config/activators.go similarity index 95% rename from evmd/activators.go rename to evmd/cmd/evmd/config/activators.go index 05bccbef..136f1f2b 100644 --- a/evmd/activators.go +++ b/evmd/cmd/evmd/config/activators.go @@ -1,4 +1,4 @@ -package evmd +package config import ( "github.com/ethereum/go-ethereum/core/vm" diff --git a/cmd/evmd/config/chain_id.go b/evmd/cmd/evmd/config/chain_id.go similarity index 100% rename from cmd/evmd/config/chain_id.go rename to evmd/cmd/evmd/config/chain_id.go diff --git a/cmd/evmd/config/config.go b/evmd/cmd/evmd/config/config.go similarity index 100% rename from cmd/evmd/config/config.go rename to evmd/cmd/evmd/config/config.go diff --git a/evmd/config_testing.go b/evmd/cmd/evmd/config/config_testing.go similarity index 77% rename from evmd/config_testing.go rename to evmd/cmd/evmd/config/config_testing.go index c0d5a005..688c7a5e 100644 --- a/evmd/config_testing.go +++ b/evmd/cmd/evmd/config/config_testing.go @@ -1,12 +1,11 @@ //go:build test // +build test -package evmd +package config import ( "fmt" - "github.com/cosmos/evm/cmd/evmd/config" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/math" @@ -14,44 +13,44 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// ChainsCoinInfo is a map of the chain id and its corresponding EvmCoinInfo +// TestChainsCoinInfo is a map of the chain id and its corresponding EvmCoinInfo // that allows initializing the app with different coin info based on the // chain id -var ChainsCoinInfo = map[uint64]evmtypes.EvmCoinInfo{ - config.EighteenDecimalsChainID: { - Denom: config.ExampleChainDenom, - ExtendedDenom: config.ExampleChainDenom, - DisplayDenom: config.ExampleDisplayDenom, +var TestChainsCoinInfo = map[uint64]evmtypes.EvmCoinInfo{ + EighteenDecimalsChainID: { + Denom: ExampleChainDenom, + ExtendedDenom: ExampleChainDenom, + DisplayDenom: ExampleDisplayDenom, Decimals: evmtypes.EighteenDecimals, }, - config.SixDecimalsChainID: { + SixDecimalsChainID: { Denom: "utest", ExtendedDenom: "atest", DisplayDenom: "test", Decimals: evmtypes.SixDecimals, }, - config.TwelveDecimalsChainID: { + TwelveDecimalsChainID: { Denom: "ptest2", ExtendedDenom: "atest2", DisplayDenom: "test2", Decimals: evmtypes.TwelveDecimals, }, - config.TwoDecimalsChainID: { + TwoDecimalsChainID: { Denom: "ctest3", ExtendedDenom: "atest3", DisplayDenom: "test3", Decimals: evmtypes.TwoDecimals, }, - config.TestChainID1: { - Denom: config.ExampleChainDenom, - ExtendedDenom: config.ExampleChainDenom, - DisplayDenom: config.ExampleChainDenom, + TestChainID1: { + Denom: ExampleChainDenom, + ExtendedDenom: ExampleChainDenom, + DisplayDenom: ExampleChainDenom, Decimals: evmtypes.EighteenDecimals, }, - config.TestChainID2: { - Denom: config.ExampleChainDenom, - ExtendedDenom: config.ExampleChainDenom, - DisplayDenom: config.ExampleChainDenom, + TestChainID2: { + Denom: ExampleChainDenom, + ExtendedDenom: ExampleChainDenom, + DisplayDenom: ExampleChainDenom, Decimals: evmtypes.EighteenDecimals, }, } @@ -70,7 +69,7 @@ func NoOpEVMOptions(_ uint64) error { // EvmAppOptions allows to setup the global configuration // for the Cosmos EVM chain. func EvmAppOptions(chainID uint64) error { - coinInfo, found := ChainsCoinInfo[chainID] + coinInfo, found := TestChainsCoinInfo[chainID] if !found { return fmt.Errorf("unknown chain id: %d", chainID) } diff --git a/cmd/evmd/config/constants.go b/evmd/cmd/evmd/config/constants.go similarity index 100% rename from cmd/evmd/config/constants.go rename to evmd/cmd/evmd/config/constants.go diff --git a/evmd/config.go b/evmd/cmd/evmd/config/evm_app_options.go similarity index 93% rename from evmd/config.go rename to evmd/cmd/evmd/config/evm_app_options.go index 1f11fa28..1643ea5e 100644 --- a/evmd/config.go +++ b/evmd/cmd/evmd/config/evm_app_options.go @@ -1,12 +1,11 @@ //go:build !test // +build !test -package evmd +package config import ( "fmt" - "github.com/cosmos/evm/cmd/evmd/config" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/math" @@ -28,7 +27,7 @@ func EvmAppOptions(chainID uint64) error { return nil } - coinInfo, found := config.ChainsCoinInfo[chainID] + coinInfo, found := ChainsCoinInfo[chainID] if !found { return fmt.Errorf("unknown chain id: %d", chainID) } diff --git a/evmd/cmd/evmd/config/evmd_config.go b/evmd/cmd/evmd/config/evmd_config.go new file mode 100644 index 00000000..de13ea62 --- /dev/null +++ b/evmd/cmd/evmd/config/evmd_config.go @@ -0,0 +1,132 @@ +package config + +import ( + "maps" + "sort" + + corevm "github.com/ethereum/go-ethereum/core/vm" + + cosmosevmserverconfig "github.com/cosmos/evm/server/config" + cosmosevmutils "github.com/cosmos/evm/utils" + erc20types "github.com/cosmos/evm/x/erc20/types" + feemarkettypes "github.com/cosmos/evm/x/feemarket/types" + precisebanktypes "github.com/cosmos/evm/x/precisebank/types" + evmtypes "github.com/cosmos/evm/x/vm/types" + ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" + + clienthelpers "cosmossdk.io/client/v2/helpers" + + serverconfig "github.com/cosmos/cosmos-sdk/server/config" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +func MustGetDefaultNodeHome() string { + defaultNodeHome, err := clienthelpers.GetNodeHomeDirectory(".evmd") + if err != nil { + panic(err) + } + return defaultNodeHome +} + +// module account permissions +var maccPerms = map[string][]string{ + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + + // Cosmos EVM modules + evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + feemarkettypes.ModuleName: nil, + erc20types.ModuleName: {authtypes.Minter, authtypes.Burner}, + precisebanktypes.ModuleName: {authtypes.Minter, authtypes.Burner}, +} + +// BlockedAddresses returns all the app's blocked account addresses. +// +// Note, this includes: +// - module accounts +// - Ethereum's native precompiled smart contracts +// - Cosmos EVM' available static precompiled contracts +func BlockedAddresses() map[string]bool { + blockedAddrs := make(map[string]bool) + + maps.Clone(maccPerms) + maccPerms := GetMaccPerms() + accs := make([]string, 0, len(maccPerms)) + for acc := range maccPerms { + accs = append(accs, acc) + } + sort.Strings(accs) + + for _, acc := range accs { + blockedAddrs[authtypes.NewModuleAddress(acc).String()] = true + } + + blockedPrecompilesHex := evmtypes.AvailableStaticPrecompiles + for _, addr := range corevm.PrecompiledAddressesBerlin { + blockedPrecompilesHex = append(blockedPrecompilesHex, addr.Hex()) + } + + for _, precompile := range blockedPrecompilesHex { + blockedAddrs[cosmosevmutils.Bech32StringFromHexAddress(precompile)] = true + } + + return blockedAddrs +} + +// GetMaccPerms returns a copy of the module account permissions +func GetMaccPerms() map[string][]string { + return maps.Clone(maccPerms) +} + +// InitAppConfig helps to override default appConfig template and configs. +// return "", nil if no custom configuration is required for the application. +func InitAppConfig(denom string, evmChainID uint64) (string, interface{}) { + type CustomAppConfig struct { + serverconfig.Config + + EVM cosmosevmserverconfig.EVMConfig + JSONRPC cosmosevmserverconfig.JSONRPCConfig + TLS cosmosevmserverconfig.TLSConfig + } + + // Optionally allow the chain developer to overwrite the SDK's default + // server config. + srvCfg := serverconfig.DefaultConfig() + // The SDK's default minimum gas price is set to "" (empty value) inside + // app.toml. If left empty by validators, the node will halt on startup. + // However, the chain developer can set a default app.toml value for their + // validators here. + // + // In summary: + // - if you leave srvCfg.MinGasPrices = "", all validators MUST tweak their + // own app.toml config, + // - if you set srvCfg.MinGasPrices non-empty, validators CAN tweak their + // own app.toml to override, or use this default value. + // + // In this example application, we set the min gas prices to 0. + srvCfg.MinGasPrices = "0" + denom + + evmCfg := cosmosevmserverconfig.DefaultEVMConfig() + evmCfg.EVMChainID = evmChainID + + customAppConfig := CustomAppConfig{ + Config: *srvCfg, + EVM: *evmCfg, + JSONRPC: *cosmosevmserverconfig.DefaultJSONRPCConfig(), + TLS: *cosmosevmserverconfig.DefaultTLSConfig(), + } + + customAppTemplate := serverconfig.DefaultConfigTemplate + + cosmosevmserverconfig.DefaultEVMConfigTemplate + + return customAppTemplate, customAppConfig +} diff --git a/cmd/evmd/main.go b/evmd/cmd/evmd/main.go similarity index 64% rename from cmd/evmd/main.go rename to evmd/cmd/evmd/main.go index 85dc94e2..0669a589 100644 --- a/cmd/evmd/main.go +++ b/evmd/cmd/evmd/main.go @@ -4,9 +4,8 @@ import ( "fmt" "os" - "github.com/cosmos/evm/cmd/evmd/cmd" - evmdconfig "github.com/cosmos/evm/cmd/evmd/config" - "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm/evmd/cmd/evmd/cmd" + evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" sdk "github.com/cosmos/cosmos-sdk/types" @@ -16,7 +15,7 @@ func main() { setupSDKConfig() rootCmd := cmd.NewRootCmd() - if err := svrcmd.Execute(rootCmd, "evmd", evmd.DefaultNodeHome); err != nil { + if err := svrcmd.Execute(rootCmd, "evmd", evmdconfig.MustGetDefaultNodeHome()); err != nil { fmt.Fprintln(rootCmd.OutOrStderr(), err) os.Exit(1) } diff --git a/tests/integration/eips/test_eips.go b/evmd/eips/eips_test.go similarity index 98% rename from tests/integration/eips/test_eips.go rename to evmd/eips/eips_test.go index 351e406f..4cebbf66 100644 --- a/tests/integration/eips/test_eips.go +++ b/evmd/eips/eips_test.go @@ -1,4 +1,4 @@ -package eips +package eips_test import ( "fmt" @@ -15,6 +15,7 @@ import ( "github.com/cosmos/evm/evmd/eips" "github.com/cosmos/evm/evmd/eips/testdata" + "github.com/cosmos/evm/evmd/tests/integration" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -33,7 +34,7 @@ import ( // 3. Deploy and interact with contracts to compute the gas used AFTER enabling // the EIP. -func TestEIPs(t *testing.T, create network.CreateEvmApp, options ...network.ConfigOption) { +func RunTests(t *testing.T, create network.CreateEvmApp, options ...network.ConfigOption) { _ = Describe("EIP-0000 - ", Ordered, func() { var ( in network.Network @@ -130,6 +131,8 @@ func TestEIPs(t *testing.T, create network.CreateEvmApp, options ...network.Conf }) It("should change CREATE opcode constant gas after enabling EIP", func() { + qRes, err := gh.GetEvmParams() + _ = qRes.Params gasCostPre := params.CreateGas deploymentTxArgs, err := tf.GenerateDeployContractArgs(senderAddr2, evmtypes.EvmTxArgs{}, deploymentData) @@ -443,3 +446,7 @@ func TestEIPs(t *testing.T, create network.CreateEvmApp, options ...network.Conf RegisterFailHandler(Fail) RunSpecs(t, "EIPs Suite") } + +func TestEIPs(t *testing.T) { + RunTests(t, integration.CreateEvmd) +} diff --git a/evmd/genesis.go b/evmd/genesis.go index 97d621bf..51cb1c02 100644 --- a/evmd/genesis.go +++ b/evmd/genesis.go @@ -3,7 +3,7 @@ package evmd import ( "encoding/json" - "github.com/cosmos/evm/cmd/evmd/config" + "github.com/cosmos/evm/evmd/cmd/evmd/config" testconstants "github.com/cosmos/evm/testutil/constants" erc20types "github.com/cosmos/evm/x/erc20/types" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" diff --git a/evmd/go.mod b/evmd/go.mod index f23a5e89..005edd2e 100644 --- a/evmd/go.mod +++ b/evmd/go.mod @@ -10,9 +10,9 @@ require ( cosmossdk.io/log v1.6.0 cosmossdk.io/math v1.5.3 cosmossdk.io/store v1.1.2 + cosmossdk.io/tools/confix v0.1.2 cosmossdk.io/x/evidence v0.2.0 cosmossdk.io/x/feegrant v0.2.0 - cosmossdk.io/x/tx v0.14.0 cosmossdk.io/x/upgrade v0.2.0 github.com/cometbft/cometbft v0.38.17 github.com/cosmos/cosmos-db v1.1.3 @@ -21,8 +21,14 @@ require ( github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-go/v10 v10.0.0-beta.0.0.20250528142215-7d579b91ac6b github.com/ethereum/go-ethereum v1.15.11 + github.com/onsi/ginkgo/v2 v2.22.2 + github.com/onsi/gomega v1.36.2 github.com/spf13/cast v1.9.2 + github.com/spf13/cobra v1.9.1 + github.com/spf13/viper v1.20.1 github.com/stretchr/testify v1.10.0 + golang.org/x/sync v0.15.0 + google.golang.org/grpc v1.73.0 ) require ( @@ -37,6 +43,7 @@ require ( cosmossdk.io/collections v1.2.1 // indirect cosmossdk.io/depinject v1.2.1 // indirect cosmossdk.io/schema v1.1.0 // indirect + cosmossdk.io/x/tx v0.14.0 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.2 // indirect @@ -83,6 +90,8 @@ require ( github.com/cosmos/ledger-cosmos-go v0.14.0 // indirect github.com/crate-crypto/go-eth-kzg v1.3.0 // indirect github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect + github.com/creachadair/atomicfile v0.3.7 // indirect + github.com/creachadair/tomledit v0.0.28 // indirect github.com/danieljoos/wincred v1.2.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/deckarep/golang-set/v2 v2.6.0 // indirect @@ -169,6 +178,7 @@ require ( github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mdp/qrterminal/v3 v3.2.1 // indirect github.com/minio/highwayhash v1.0.3 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect @@ -178,8 +188,6 @@ require ( github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect github.com/oklog/run v1.1.0 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/onsi/ginkgo/v2 v2.22.2 // indirect - github.com/onsi/gomega v1.36.2 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect github.com/pion/dtls/v2 v2.2.7 // indirect @@ -204,9 +212,7 @@ require ( github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.12.0 // indirect - github.com/spf13/cobra v1.9.1 // indirect github.com/spf13/pflag v1.0.6 // indirect - github.com/spf13/viper v1.20.1 // indirect github.com/spiffe/go-spiffe/v2 v2.5.0 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect @@ -244,7 +250,6 @@ require ( golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect golang.org/x/net v0.41.0 // indirect golang.org/x/oauth2 v0.28.0 // indirect - golang.org/x/sync v0.15.0 // indirect golang.org/x/sys v0.33.0 // indirect golang.org/x/term v0.32.0 // indirect golang.org/x/text v0.26.0 // indirect @@ -254,13 +259,13 @@ require ( google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect - google.golang.org/grpc v1.73.0 // indirect google.golang.org/protobuf v1.36.6 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.2 // indirect nhooyr.io/websocket v1.8.11 // indirect pgregory.net/rapid v1.2.0 // indirect + rsc.io/qr v0.2.0 // indirect rsc.io/tmplfunc v0.0.3 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/evmd/go.sum b/evmd/go.sum index c3d743e0..70322794 100644 --- a/evmd/go.sum +++ b/evmd/go.sum @@ -634,6 +634,8 @@ cosmossdk.io/schema v1.1.0 h1:mmpuz3dzouCoyjjcMcA/xHBEmMChN+EHh8EHxHRHhzE= cosmossdk.io/schema v1.1.0/go.mod h1:Gb7pqO+tpR+jLW5qDcNOSv0KtppYs7881kfzakguhhI= cosmossdk.io/store v1.1.2 h1:3HOZG8+CuThREKv6cn3WSohAc6yccxO3hLzwK6rBC7o= cosmossdk.io/store v1.1.2/go.mod h1:60rAGzTHevGm592kFhiUVkNC9w7gooSEn5iUBPzHQ6A= +cosmossdk.io/tools/confix v0.1.2 h1:2hoM1oFCNisd0ltSAAZw2i4ponARPmlhuNu3yy0VwI4= +cosmossdk.io/tools/confix v0.1.2/go.mod h1:7XfcbK9sC/KNgVGxgLM0BrFbVcR/+6Dg7MFfpx7duYo= cosmossdk.io/x/evidence v0.2.0 h1:o72zbmgCM7U0v7z7b0XnMB+NqX0tFamqb1HHkQbhrZ0= cosmossdk.io/x/evidence v0.2.0/go.mod h1:zx/Xqy+hnGVzkqVuVuvmP9KsO6YCl4SfbAetYi+k+sE= cosmossdk.io/x/feegrant v0.2.0 h1:oq3WVpoJdxko/XgWmpib63V1mYy9ZQN/1qxDajwGzJ8= @@ -885,6 +887,12 @@ github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a h1:W8mUrRp6NOV github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a/go.mod h1:sTwzHBvIzm2RfVCGNEBZgRyjwK40bVoun3ZnGOCafNM= github.com/crate-crypto/go-kzg-4844 v1.1.0 h1:EN/u9k2TF6OWSHrCCDBBU6GLNMq88OspHHlMnHfoyU4= github.com/crate-crypto/go-kzg-4844 v1.1.0/go.mod h1:JolLjpSff1tCCJKaJx4psrlEdlXuJEC996PL3tTAFks= +github.com/creachadair/atomicfile v0.3.7 h1:wdg8+Isz07NDMi2yZQAoI1EKB9SxuDhvo5MUii/ZqlM= +github.com/creachadair/atomicfile v0.3.7/go.mod h1:lUrZrE/XjMA7rJY/n8dF7/sSpy6KjtPaxPbrDambthA= +github.com/creachadair/mds v0.22.1 h1:Wink9jeYR7brBbOkOTVZVrd6vyb5W4ZBRhlZd96TSgU= +github.com/creachadair/mds v0.22.1/go.mod h1:ArfS0vPHoLV/SzuIzoqTEZfoYmac7n9Cj8XPANHocvw= +github.com/creachadair/tomledit v0.0.28 h1:aQJVwcNTzx4SZ/tSbkyGE69w4YQ6Gn+xhHHKtqMZwuw= +github.com/creachadair/tomledit v0.0.28/go.mod h1:pqb2HRQi0lMu6MBiUmTk/0XQ+SmPtq2QbUrG+eiLP5w= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/danieljoos/wincred v1.2.1 h1:dl9cBrupW8+r5250DYkYxocLeZ1Y4vB1kxgtjxw8GQs= @@ -1416,6 +1424,8 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mdp/qrterminal/v3 v3.2.1 h1:6+yQjiiOsSuXT5n9/m60E54vdgFsw0zhADHhHLrFet4= +github.com/mdp/qrterminal/v3 v3.2.1/go.mod h1:jOTmXvnBsMy5xqLniO0R++Jmjs2sTm9dFSuQ5kpz/SU= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE= @@ -2635,6 +2645,8 @@ pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk= pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= +rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY= +rsc.io/qr v0.2.0/go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= diff --git a/evmd/test_helpers.go b/evmd/test_helpers.go index 1ee73fb9..bb8e0957 100644 --- a/evmd/test_helpers.go +++ b/evmd/test_helpers.go @@ -11,7 +11,7 @@ import ( cmttypes "github.com/cometbft/cometbft/types" dbm "github.com/cosmos/cosmos-db" - "github.com/cosmos/evm/cmd/evmd/config" + "github.com/cosmos/evm/evmd/cmd/evmd/config" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" ibctesting "github.com/cosmos/ibc-go/v10/testing" @@ -51,10 +51,10 @@ func setup(withGenesis bool, invCheckPeriod uint, chainID string, evmChainID uin db := dbm.NewMemDB() appOptions := make(simtestutil.AppOptionsMap, 0) - appOptions[flags.FlagHome] = DefaultNodeHome + appOptions[flags.FlagHome] = defaultNodeHome appOptions[server.FlagInvCheckPeriod] = invCheckPeriod - app := NewExampleApp(log.NewNopLogger(), db, nil, true, appOptions, evmChainID, EvmAppOptions, baseapp.SetChainID(chainID)) + app := NewExampleApp(log.NewNopLogger(), db, nil, true, appOptions, evmChainID, config.EvmAppOptions, baseapp.SetChainID(chainID)) if withGenesis { return app, app.DefaultGenesis() } @@ -129,9 +129,9 @@ func SetupTestingApp(chainID string, evmChainID uint64) func() (ibctesting.Testi app := NewExampleApp( log.NewNopLogger(), db, nil, true, - simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), + simtestutil.NewAppOptionsWithFlagHome(defaultNodeHome), evmChainID, - EvmAppOptions, + config.EvmAppOptions, baseapp.SetChainID(chainID), ) return app, app.DefaultGenesis() diff --git a/evmd/tests/ibc/helper.go b/evmd/tests/ibc/helper.go index ce802e33..b7df9057 100644 --- a/evmd/tests/ibc/helper.go +++ b/evmd/tests/ibc/helper.go @@ -9,8 +9,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/cosmos/evm" "github.com/cosmos/evm/contracts" - "github.com/cosmos/evm/evmd" evmibctesting "github.com/cosmos/evm/testutil/ibc" testutiltypes "github.com/cosmos/evm/testutil/types" erc20types "github.com/cosmos/evm/x/erc20/types" @@ -37,10 +37,10 @@ func SetupNativeErc20(t *testing.T, chain *evmibctesting.TestChain, senderAcc ev t.Helper() evmCtx := chain.GetContext() - evmApp := chain.App.(*evmd.EVMD) + evmApp := chain.App.(evm.EvmApp) // Deploy new ERC20 contract with default metadata - contractAddr, err := evmApp.Erc20Keeper.DeployERC20Contract(evmCtx, banktypes.Metadata{ + contractAddr, err := evmApp.GetErc20Keeper().DeployERC20Contract(evmCtx, banktypes.Metadata{ DenomUnits: []*banktypes.DenomUnit{ {Denom: "example", Exponent: 18}, }, @@ -53,7 +53,7 @@ func SetupNativeErc20(t *testing.T, chain *evmibctesting.TestChain, senderAcc ev chain.NextBlock() // Register the contract - _, err = evmApp.Erc20Keeper.RegisterERC20(evmCtx, &erc20types.MsgRegisterERC20{ + _, err = evmApp.GetErc20Keeper().RegisterERC20(evmCtx, &erc20types.MsgRegisterERC20{ Signer: authtypes.NewModuleAddress(govtypes.ModuleName).String(), // does not have to be gov Erc20Addresses: []string{contractAddr.Hex()}, }) @@ -67,7 +67,7 @@ func SetupNativeErc20(t *testing.T, chain *evmibctesting.TestChain, senderAcc ev sendAmt := ibctesting.DefaultCoinAmount senderAddr := senderAcc.SenderAccount.GetAddress() - _, err = evmApp.EVMKeeper.CallEVM( + _, err = evmApp.GetEVMKeeper().CallEVM( evmCtx, contractAbi, erc20types.ModuleAddress, @@ -83,7 +83,7 @@ func SetupNativeErc20(t *testing.T, chain *evmibctesting.TestChain, senderAcc ev } // Verify minted balance - bal := evmApp.Erc20Keeper.BalanceOf(evmCtx, contractAbi, contractAddr, common.BytesToAddress(senderAddr)) + bal := evmApp.GetErc20Keeper().BalanceOf(evmCtx, contractAbi, contractAddr, common.BytesToAddress(senderAddr)) if bal.Cmp(big.NewInt(sendAmt.Int64())) != 0 { t.Fatalf("unexpected ERC20 balance; got %s, want %s", bal.String(), sendAmt.String()) } @@ -103,7 +103,7 @@ func DeployContract(t *testing.T, chain *evmibctesting.TestChain, deploymentData // Get account's nonce to create contract hash from := common.BytesToAddress(chain.SenderPrivKey.PubKey().Address().Bytes()) - account := chain.App.(*evmd.EVMD).EVMKeeper.GetAccount(chain.GetContext(), from) + account := chain.App.(evm.EvmApp).GetEVMKeeper().GetAccount(chain.GetContext(), from) if account == nil { return common.Address{}, errors.New("account not found") } @@ -116,7 +116,7 @@ func DeployContract(t *testing.T, chain *evmibctesting.TestChain, deploymentData data := deploymentData.Contract.Bin data = append(data, ctorArgs...) - _, err = chain.App.(*evmd.EVMD).EVMKeeper.CallEVMWithData(chain.GetContext(), from, nil, data, true, nil) + _, err = chain.App.(evm.EvmApp).GetEVMKeeper().CallEVMWithData(chain.GetContext(), from, nil, data, true, nil) if err != nil { return common.Address{}, errorsmod.Wrapf(err, "failed to deploy contract") } diff --git a/evmd/tests/integration/create_app.go b/evmd/tests/integration/create_app.go index d94421e0..9185dfa8 100644 --- a/evmd/tests/integration/create_app.go +++ b/evmd/tests/integration/create_app.go @@ -5,11 +5,12 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/evm" - "github.com/cosmos/evm/cmd/evmd/config" "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm/evmd/cmd/evmd/config" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" ibctesting "github.com/cosmos/ibc-go/v10/testing" + clienthelpers "cosmossdk.io/client/v2/helpers" "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/baseapp" @@ -20,11 +21,15 @@ import ( // CreateEvmd creates an evmos app func CreateEvmd(chainID string, evmChainID uint64, customBaseAppOptions ...func(*baseapp.BaseApp)) evm.EvmApp { + defaultNodeHome, err := clienthelpers.GetNodeHomeDirectory(".evmd") + if err != nil { + panic(err) + } // create evmos app db := dbm.NewMemDB() logger := log.NewNopLogger() loadLatest := true - appOptions := simutils.NewAppOptionsWithFlagHome(evmd.DefaultNodeHome) + appOptions := simutils.NewAppOptionsWithFlagHome(defaultNodeHome) baseAppOptions := append(customBaseAppOptions, baseapp.SetChainID(chainID)) //nolint:gocritic return evmd.NewExampleApp( @@ -34,7 +39,7 @@ func CreateEvmd(chainID string, evmChainID uint64, customBaseAppOptions ...func( loadLatest, appOptions, evmChainID, - evmd.EvmAppOptions, + config.EvmAppOptions, baseAppOptions..., ) } @@ -49,7 +54,7 @@ func SetupEvmd() (ibctesting.TestingApp, map[string]json.RawMessage) { true, simutils.EmptyAppOptions{}, 9001, - evmd.EvmAppOptions, + config.EvmAppOptions, ) // disable base fee for testing genesisState := app.DefaultGenesis() diff --git a/evmd/tests/integration/eips/eips_test.go b/evmd/tests/integration/eips/eips_test.go deleted file mode 100644 index a959d02a..00000000 --- a/evmd/tests/integration/eips/eips_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package eips - -import ( - "testing" - - "github.com/cosmos/evm/evmd/tests/integration" - "github.com/cosmos/evm/tests/integration/eips" -) - -func Test_EIPs(t *testing.T) { - eips.TestEIPs(t, integration.CreateEvmd) -} diff --git a/evmd/tests/integration/evm_ante_bench_test.go b/evmd/tests/integration/evm_ante_bench_test.go deleted file mode 100644 index 5b4f99e2..00000000 --- a/evmd/tests/integration/evm_ante_bench_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package integration - -import ( - "testing" - - "github.com/cosmos/evm/tests/integration/ante" -) - -func BenchmarkEvmAnteTestSuite(b *testing.B) { - ante.RunBenchmarkEthGasConsumeDecorator(b, CreateEvmd) -} - -func BenchmarkEvmAnteHnadler(b *testing.B) { - ante.RunBenchmarkAnteHandler(b, CreateEvmd) -} diff --git a/evmd/tests/integration/evm_ante_test.go b/evmd/tests/integration/evm_ante_test.go deleted file mode 100644 index b9de94dc..00000000 --- a/evmd/tests/integration/evm_ante_test.go +++ /dev/null @@ -1,45 +0,0 @@ -package integration - -import ( - "testing" - - gethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/stretchr/testify/suite" - - "github.com/cosmos/evm/tests/integration/ante" - testconstants "github.com/cosmos/evm/testutil/constants" -) - -func TestEvmAnteTestSuite(t *testing.T) { - s := ante.NewEvmAnteTestSuite(CreateEvmd) - s.WithLondonHardForkEnabled(true) - - suite.Run(t, s) - - s = ante.NewEvmAnteTestSuite(CreateEvmd) - s.WithLondonHardForkEnabled(true) - // Re-run the tests with EIP-712 Legacy encodings to ensure backwards compatibility. - // LegacyEIP712Extension should not be run with current TypedData encodings, since they are not compatible. - s.UseLegacyEIP712TypedData = true - suite.Run(t, s) -} - -func TestEvmUnitAnteTestSuite(t *testing.T) { - txTypes := []int{gethtypes.DynamicFeeTxType, gethtypes.LegacyTxType, gethtypes.AccessListTxType} - chainIDs := []testconstants.ChainID{testconstants.ExampleChainID, testconstants.SixDecimalsChainID} - - evmTestSuite := ante.NewEvmUnitAnteTestSuite(CreateEvmd) - - for _, txType := range txTypes { - for _, chainID := range chainIDs { - evmTestSuite.EthTxType = txType - evmTestSuite.ChainID = chainID.ChainID - evmTestSuite.EvmChainID = chainID.EVMChainID - suite.Run(t, evmTestSuite) - } - } -} - -func TestValidateHandlerOptionsTest(t *testing.T) { - ante.RunValidateHandlerOptionsTest(t, CreateEvmd) -} diff --git a/tests/integration/ledger/evmosd_suite_test.go b/evmd/tests/ledger/evmosd_suite_test.go similarity index 96% rename from tests/integration/ledger/evmosd_suite_test.go rename to evmd/tests/ledger/evmosd_suite_test.go index 3257a267..3e33ebdc 100644 --- a/tests/integration/ledger/evmosd_suite_test.go +++ b/evmd/tests/ledger/evmosd_suite_test.go @@ -26,8 +26,8 @@ import ( clientkeys "github.com/cosmos/evm/client/keys" "github.com/cosmos/evm/crypto/hd" cosmosevmkeyring "github.com/cosmos/evm/crypto/keyring" - exampleapp "github.com/cosmos/evm/evmd" - "github.com/cosmos/evm/tests/integration/ledger/mocks" + "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm/evmd/tests/ledger/mocks" "github.com/cosmos/evm/testutil/constants" utiltx "github.com/cosmos/evm/testutil/tx" @@ -47,7 +47,7 @@ var s *LedgerTestSuite type LedgerTestSuite struct { suite.Suite - app *exampleapp.EVMD + app *evmd.EVMD ctx sdk.Context ledger *mocks.SECP256K1 @@ -88,7 +88,7 @@ func (suite *LedgerTestSuite) SetupEvmosApp() { // init app chainID := constants.ExampleChainID - suite.app = exampleapp.Setup(suite.T(), chainID.ChainID, chainID.EVMChainID) + suite.app = evmd.Setup(suite.T(), chainID.ChainID, chainID.EVMChainID) suite.ctx = suite.app.NewContextLegacy(false, tmproto.Header{ Height: 1, ChainID: chainID.ChainID, diff --git a/tests/integration/ledger/ledger_test.go b/evmd/tests/ledger/ledger_test.go similarity index 99% rename from tests/integration/ledger/ledger_test.go rename to evmd/tests/ledger/ledger_test.go index 81da2d2d..488bb1ea 100644 --- a/tests/integration/ledger/ledger_test.go +++ b/evmd/tests/ledger/ledger_test.go @@ -11,8 +11,8 @@ import ( "github.com/cosmos/evm/crypto/hd" "github.com/cosmos/evm/encoding" + "github.com/cosmos/evm/evmd/tests/ledger/mocks" "github.com/cosmos/evm/server/config" - "github.com/cosmos/evm/tests/integration/ledger/mocks" "github.com/cosmos/evm/testutil" utiltx "github.com/cosmos/evm/testutil/tx" diff --git a/tests/integration/ledger/mocks/AccountRetriever.go b/evmd/tests/ledger/mocks/AccountRetriever.go similarity index 100% rename from tests/integration/ledger/mocks/AccountRetriever.go rename to evmd/tests/ledger/mocks/AccountRetriever.go diff --git a/tests/integration/ledger/mocks/SECP256K1.go b/evmd/tests/ledger/mocks/SECP256K1.go similarity index 100% rename from tests/integration/ledger/mocks/SECP256K1.go rename to evmd/tests/ledger/mocks/SECP256K1.go diff --git a/tests/integration/ledger/mocks/registry.go b/evmd/tests/ledger/mocks/registry.go similarity index 100% rename from tests/integration/ledger/mocks/registry.go rename to evmd/tests/ledger/mocks/registry.go diff --git a/tests/integration/ledger/mocks/tendermint.go b/evmd/tests/ledger/mocks/tendermint.go similarity index 100% rename from tests/integration/ledger/mocks/tendermint.go rename to evmd/tests/ledger/mocks/tendermint.go diff --git a/testutil/network/doc.go b/evmd/tests/network/doc.go similarity index 100% rename from testutil/network/doc.go rename to evmd/tests/network/doc.go diff --git a/testutil/network/network.go b/evmd/tests/network/network.go similarity index 97% rename from testutil/network/network.go rename to evmd/tests/network/network.go index 7c0ed83f..ddd8645f 100644 --- a/testutil/network/network.go +++ b/evmd/tests/network/network.go @@ -27,9 +27,9 @@ import ( cmtclient "github.com/cometbft/cometbft/rpc/client" dbm "github.com/cosmos/cosmos-db" - chaincmd "github.com/cosmos/evm/cmd/evmd/cmd" "github.com/cosmos/evm/crypto/hd" - exampleapp "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm/evmd" + evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" "github.com/cosmos/evm/server/config" testconstants "github.com/cosmos/evm/testutil/constants" cosmosevmtypes "github.com/cosmos/evm/types" @@ -109,7 +109,7 @@ func DefaultConfig() Config { panic(fmt.Sprintf("failed creating temporary directory: %v", err)) } defer os.RemoveAll(dir) - tempApp := exampleapp.NewExampleApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simutils.NewAppOptionsWithFlagHome(dir), evmChainID, exampleapp.EvmAppOptions, baseapp.SetChainID(chainID)) + tempApp := evmd.NewExampleApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simutils.NewAppOptionsWithFlagHome(dir), evmChainID, evmdconfig.EvmAppOptions, baseapp.SetChainID(chainID)) cfg := Config{ Codec: tempApp.AppCodec(), @@ -139,11 +139,11 @@ func DefaultConfig() Config { // NewAppConstructor returns a new Cosmos EVM AppConstructor func NewAppConstructor(chainID string, evmChainID uint64) AppConstructor { return func(val Validator) servertypes.Application { - return exampleapp.NewExampleApp( + return evmd.NewExampleApp( val.Ctx.Logger, dbm.NewMemDB(), nil, true, simutils.NewAppOptionsWithFlagHome(val.Ctx.Config.RootDir), evmChainID, - exampleapp.EvmAppOptions, + evmdconfig.EvmAppOptions, baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), baseapp.SetChainID(chainID), @@ -476,7 +476,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { return nil, err } - customAppTemplate, _ := chaincmd.InitAppConfig(testconstants.ExampleAttoDenom, testconstants.ExampleEIP155ChainID) + customAppTemplate, _ := evmdconfig.InitAppConfig(testconstants.ExampleAttoDenom, testconstants.ExampleEIP155ChainID) srvconfig.SetConfigTemplate(customAppTemplate) srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), appCfg) diff --git a/testutil/network/network_test.go b/evmd/tests/network/network_test.go similarity index 88% rename from testutil/network/network_test.go rename to evmd/tests/network/network_test.go index bca38aa7..469c17c9 100644 --- a/testutil/network/network_test.go +++ b/evmd/tests/network/network_test.go @@ -11,15 +11,14 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/stretchr/testify/suite" + cosmosevmnetwork "github.com/cosmos/evm/evmd/tests/network" "github.com/cosmos/evm/server/config" - "github.com/cosmos/evm/testutil/network" - cosmosevmnetwork "github.com/cosmos/evm/testutil/network" ) type IntegrationTestSuite struct { suite.Suite - network *network.Network + network *cosmosevmnetwork.Network } func (s *IntegrationTestSuite) SetupSuite() { @@ -30,7 +29,7 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg.JSONRPCAddress = config.DefaultJSONRPCAddress cfg.NumValidators = 1 - s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.network, err = cosmosevmnetwork.New(s.T(), s.T().TempDir(), cfg) s.Require().NoError(err) s.Require().NotNil(s.network) diff --git a/testutil/network/util.go b/evmd/tests/network/util.go similarity index 100% rename from testutil/network/util.go rename to evmd/tests/network/util.go diff --git a/go.mod b/go.mod index 16aad2ad..5cae8bb3 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.23.8 require ( cosmossdk.io/api v0.9.2 + cosmossdk.io/client/v2 v2.0.0-beta.7 cosmossdk.io/core v0.11.3 cosmossdk.io/errors v1.0.2 cosmossdk.io/log v1.6.0 @@ -19,7 +20,6 @@ require ( github.com/cosmos/cosmos-db v1.1.3 github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/cosmos-sdk v0.53.2 - github.com/cosmos/evm/evmd v0.0.0 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-go/modules/capability v1.0.1 @@ -66,7 +66,6 @@ require ( cloud.google.com/go/iam v1.2.2 // indirect cloud.google.com/go/monitoring v1.21.2 // indirect cloud.google.com/go/storage v1.49.0 // indirect - cosmossdk.io/client/v2 v2.0.0-beta.7 // indirect cosmossdk.io/collections v1.2.1 // indirect cosmossdk.io/depinject v1.2.1 // indirect cosmossdk.io/schema v1.1.0 // indirect @@ -119,8 +118,6 @@ require ( github.com/desertbit/timer v1.0.1 // indirect github.com/dgraph-io/badger/v4 v4.2.0 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect - github.com/dlclark/regexp2 v1.7.0 // indirect - github.com/dop251/goja v0.0.0-20230605162241-28ee0ee714f3 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect github.com/emicklei/dot v1.6.2 // indirect @@ -139,7 +136,6 @@ require ( github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect - github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect @@ -275,7 +271,6 @@ replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 // Pin this pebble version to avoid breaking compilation of geth github.com/cockroachdb/pebble => github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 - github.com/cosmos/evm/evmd => ./evmd // use Cosmos geth fork github.com/ethereum/go-ethereum => github.com/cosmos/go-ethereum v1.15.11-cosmos-0 // Security Advisory https://github.com/advisories/GHSA-h395-qcrw-5vmq diff --git a/go.sum b/go.sum index 70322794..4a8f9590 100644 --- a/go.sum +++ b/go.sum @@ -786,15 +786,12 @@ github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXH github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM= github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic= github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI= github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04= github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= @@ -924,19 +921,11 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= -github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= -github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= -github.com/dop251/goja v0.0.0-20230605162241-28ee0ee714f3 h1:+3HCtB74++ClLy8GgjUQYeC8R4ILzVcIe8+5edAJJnE= -github.com/dop251/goja v0.0.0-20230605162241-28ee0ee714f3/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4= -github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= -github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= @@ -1046,8 +1035,6 @@ github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvSc github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= -github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= -github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= @@ -1178,7 +1165,6 @@ github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg= github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/ZoQgRgVIWFJljSWa/zetS2WTvg= github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= @@ -1310,7 +1296,6 @@ github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSAS github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= diff --git a/server/start.go b/server/start.go index 61dbca62..643818e4 100644 --- a/server/start.go +++ b/server/start.go @@ -29,7 +29,6 @@ import ( cmttypes "github.com/cometbft/cometbft/types" dbm "github.com/cosmos/cosmos-db" - "github.com/cosmos/evm/cmd/evmd/config" "github.com/cosmos/evm/indexer" ethdebug "github.com/cosmos/evm/rpc/namespaces/ethereum/debug" cosmosevmserverconfig "github.com/cosmos/evm/server/config" @@ -68,7 +67,7 @@ func NewDefaultStartOptions(appCreator types.AppCreator, defaultNodeHome string) return StartOptions{ AppCreator: appCreator, DefaultNodeHome: defaultNodeHome, - DBOpener: config.OpenDB, + DBOpener: openDB, } } @@ -674,3 +673,16 @@ func GenDocProvider(cfg *cmtcfg.Config) func() (*cmttypes.GenesisDoc, error) { return appGenesis.ToGenesisDoc() } } + +// openDB opens a database based on the specified backend type. +// It takes the home directory where the database data will be stored, along with the backend type. +// It opens a database named "application" using the specified backend type and the data directory. +// It returns the opened database and an error (if any). If the database opens successfully, the error will be nil. +// +// NOTE: this is included in builds without rocksdb. +// When building the binary with rocksdb, the code in 'rocksdb.go' will be included +// instead of this +func openDB(_ types.AppOptions, home string, backendType dbm.BackendType) (dbm.DB, error) { + dataDir := filepath.Join(home, "data") + return dbm.NewDB("application", backendType, dataDir) +} diff --git a/tests/integration/eip712/test_eip712.go b/tests/integration/eip712/test_eip712.go index 8a2e0a56..92b49813 100644 --- a/tests/integration/eip712/test_eip712.go +++ b/tests/integration/eip712/test_eip712.go @@ -10,9 +10,9 @@ import ( "github.com/tidwall/gjson" "github.com/tidwall/sjson" - chainconfig "github.com/cosmos/evm/cmd/evmd/config" "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/ethereum/eip712" + "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/constants" "github.com/cosmos/evm/testutil/integration/evm/network" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -73,7 +73,7 @@ func (s *TestSuite) SetupTest() { s.clientCtx = client.Context{}.WithTxConfig(s.config.TxConfig) s.denom = evmtypes.GetEVMCoinDenom() - sdk.GetConfig().SetBech32PrefixForAccount(chainconfig.Bech32Prefix, "") + sdk.GetConfig().SetBech32PrefixForAccount(config.Bech32Prefix, "") } // createTestAddress creates random test addresses for messages diff --git a/tests/integration/precompiles/bech32/test_bech32.go b/tests/integration/precompiles/bech32/test_bech32.go index 684ad3e8..ef6f258b 100644 --- a/tests/integration/precompiles/bech32/test_bech32.go +++ b/tests/integration/precompiles/bech32/test_bech32.go @@ -5,8 +5,8 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/holiman/uint256" - chainconfig "github.com/cosmos/evm/cmd/evmd/config" "github.com/cosmos/evm/precompiles/bech32" + "github.com/cosmos/evm/testutil/config" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -111,7 +111,7 @@ func (s *PrecompileTestSuite) TestRun() { input, err := s.precompile.Pack( bech32.HexToBech32Method, s.keyring.GetAddr(0), - chainconfig.Bech32Prefix, + config.Bech32Prefix, ) s.Require().NoError(err, "failed to pack input") contract.Input = input @@ -137,7 +137,7 @@ func (s *PrecompileTestSuite) TestRun() { input, err := s.precompile.Pack( bech32.HexToBech32Method, common.BytesToAddress(valAddrBz), - chainconfig.Bech32PrefixValAddr, + config.Bech32PrefixValAddr, ) s.Require().NoError(err, "failed to pack input") contract.Input = input @@ -160,7 +160,7 @@ func (s *PrecompileTestSuite) TestRun() { input, err := s.precompile.Pack( bech32.HexToBech32Method, s.keyring.GetAddr(0), - chainconfig.Bech32PrefixConsAddr, + config.Bech32PrefixConsAddr, ) s.Require().NoError(err, "failed to pack input") contract.Input = input diff --git a/tests/integration/precompiles/bech32/test_methods.go b/tests/integration/precompiles/bech32/test_methods.go index eb4b367d..592554cd 100644 --- a/tests/integration/precompiles/bech32/test_methods.go +++ b/tests/integration/precompiles/bech32/test_methods.go @@ -5,9 +5,9 @@ import ( "github.com/ethereum/go-ethereum/common" - chainconfig "github.com/cosmos/evm/cmd/evmd/config" "github.com/cosmos/evm/precompiles/bech32" cmn "github.com/cosmos/evm/precompiles/common" + "github.com/cosmos/evm/testutil/config" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -63,7 +63,7 @@ func (s *PrecompileTestSuite) TestHexToBech32() { func() []interface{} { return []interface{}{ s.keyring.GetAddr(0), - chainconfig.Bech32Prefix, + config.Bech32Prefix, } }, func(data []byte) { @@ -135,18 +135,18 @@ func (s *PrecompileTestSuite) TestBech32ToHex() { "fail - invalid bech32 address", func() []interface{} { return []interface{}{ - chainconfig.Bech32Prefix, + config.Bech32Prefix, } }, func([]byte) {}, true, - fmt.Sprintf("invalid bech32 address: %s", chainconfig.Bech32Prefix), + fmt.Sprintf("invalid bech32 address: %s", config.Bech32Prefix), }, { "fail - decoding bech32 failed", func() []interface{} { return []interface{}{ - chainconfig.Bech32Prefix + "1", + config.Bech32Prefix + "1", } }, func([]byte) {}, diff --git a/tests/integration/precompiles/distribution/test_event.go b/tests/integration/precompiles/distribution/test_event.go index 01f71b83..c8317811 100644 --- a/tests/integration/precompiles/distribution/test_event.go +++ b/tests/integration/precompiles/distribution/test_event.go @@ -8,10 +8,10 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/holiman/uint256" - chainconfig "github.com/cosmos/evm/cmd/evmd/config" cmn "github.com/cosmos/evm/precompiles/common" "github.com/cosmos/evm/precompiles/distribution" "github.com/cosmos/evm/precompiles/testutil" + "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/constants" "github.com/cosmos/evm/x/vm/statedb" @@ -59,7 +59,7 @@ func (s *PrecompileTestSuite) TestSetWithdrawAddressEvent() { err := cmn.UnpackLog(s.precompile.ABI, &setWithdrawerAddrEvent, distribution.EventTypeSetWithdrawAddress, *log) s.Require().NoError(err) s.Require().Equal(s.keyring.GetAddr(0), setWithdrawerAddrEvent.Caller) - s.Require().Equal(sdk.MustBech32ifyAddressBytes(chainconfig.Bech32Prefix, s.keyring.GetAddr(0).Bytes()), setWithdrawerAddrEvent.WithdrawerAddress) + s.Require().Equal(sdk.MustBech32ifyAddressBytes(config.Bech32Prefix, s.keyring.GetAddr(0).Bytes()), setWithdrawerAddrEvent.WithdrawerAddress) }, 20000, false, diff --git a/tests/integration/precompiles/ics20/test_integration.go b/tests/integration/precompiles/ics20/test_integration.go index 182c75b0..bc71b752 100644 --- a/tests/integration/precompiles/ics20/test_integration.go +++ b/tests/integration/precompiles/ics20/test_integration.go @@ -13,7 +13,7 @@ import ( //nolint:revive // dot imports are fine for Ginkgo . "github.com/onsi/gomega" - "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm" "github.com/cosmos/evm/precompiles/ics20" "github.com/cosmos/evm/precompiles/testutil/contracts" evmibctesting "github.com/cosmos/evm/testutil/ibc" @@ -30,9 +30,9 @@ import ( ) func TestPrecompileIntegrationTestSuite(t *testing.T, evmAppCreator ibctesting.AppCreator) { - isContractDeployed := func(ctx sdk.Context, evmApp *evmd.EVMD, contractAddr common.Address) bool { - codeHash := evmApp.EVMKeeper.GetCodeHash(ctx, contractAddr) - code := evmApp.EVMKeeper.GetCode(ctx, codeHash) + isContractDeployed := func(ctx sdk.Context, evmApp evm.EvmApp, contractAddr common.Address) bool { + codeHash := evmApp.GetEVMKeeper().GetCodeHash(ctx, contractAddr) + code := evmApp.GetEVMKeeper().GetCode(ctx, codeHash) return len(code) > 0 } @@ -74,7 +74,7 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, evmAppCreator ibctesting.A Expect(res.Code).To(BeZero(), "Failed to deploy ICS20 caller contract: %s", res.Log) ics20CallerAddr = crypto.CreateAddress(common.Address(sender.Bytes()), sentEthTx.AsTransaction().Nonce()) - evmAppA := s.chainA.App.(*evmd.EVMD) + evmAppA := s.chainA.App.(evm.EvmApp) Expect(isContractDeployed(s.chainA.GetContext(), evmAppA, ics20CallerAddr)).To(BeTrue(), "Contract was not deployed successfully") randomAddr = tx.GenerateAddress() @@ -229,13 +229,13 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, evmAppCreator ibctesting.A It("should successfully call the ICS20 precompile to transfer tokens", func() { path := evmibctesting.NewTransferPath(s.chainA, s.chainB) path.Setup() - evmAppA := s.chainA.App.(*evmd.EVMD) + evmAppA := s.chainA.App.(evm.EvmApp) sourcePortID := path.EndpointA.ChannelConfig.PortID sourceChannelID := path.EndpointA.ChannelID sourceBondDenom := s.chainABondDenom escrowAddr := types.GetEscrowAddress(sourcePortID, sourceChannelID) - escrowBalance := evmAppA.BankKeeper.GetBalance( + escrowBalance := evmAppA.GetBankKeeper().GetBalance( s.chainA.GetContext(), escrowAddr, sourceBondDenom, @@ -244,7 +244,7 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, evmAppCreator ibctesting.A // send some tokens to the contract address sendAmt := math.NewInt(1) - err = evmAppA.BankKeeper.SendCoins( + err = evmAppA.GetBankKeeper().SendCoins( s.chainA.GetContext(), s.chainA.SenderAccount.GetAddress(), (ics20CallerAddr.Bytes()), @@ -279,13 +279,13 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, evmAppCreator ibctesting.A ) Expect(err).To(BeNil(), "Failed to testTransfer") // balance after transfer should be 0 - contractBalance := evmAppA.BankKeeper.GetBalance( + contractBalance := evmAppA.GetBankKeeper().GetBalance( s.chainA.GetContext(), ics20CallerAddr.Bytes(), sourceBondDenom, ) Expect(contractBalance.Amount).To(Equal(math.ZeroInt()), "Contract balance should be 0 after transfer") - escrowBalance = evmAppA.BankKeeper.GetBalance( + escrowBalance = evmAppA.GetBankKeeper().GetBalance( s.chainA.GetContext(), escrowAddr, sourceBondDenom, @@ -296,13 +296,13 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, evmAppCreator ibctesting.A DescribeTable("ICS20 transfer with transfer", func(tc testCase) { path := evmibctesting.NewTransferPath(s.chainA, s.chainB) path.Setup() - evmAppA := s.chainA.App.(*evmd.EVMD) + evmAppA := s.chainA.App.(evm.EvmApp) sourcePortID := path.EndpointA.ChannelConfig.PortID sourceChannelID := path.EndpointA.ChannelID sourceBondDenom := s.chainABondDenom escrowAddr := types.GetEscrowAddress(sourcePortID, sourceChannelID) - escrowBalance := evmAppA.BankKeeper.GetBalance( + escrowBalance := evmAppA.GetBankKeeper().GetBalance( s.chainA.GetContext(), escrowAddr, sourceBondDenom, @@ -311,7 +311,7 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, evmAppCreator ibctesting.A // send some tokens to the conoract address fundAmt := math.NewInt(100) - err = evmAppA.BankKeeper.SendCoins( + err = evmAppA.GetBankKeeper().SendCoins( s.chainA.GetContext(), s.chainA.SenderAccount.GetAddress(), ics20CallerAddr.Bytes(), @@ -319,7 +319,7 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, evmAppCreator ibctesting.A ) Expect(err).To(BeNil(), "Failed to send tokens to contract address") // check contract balance - contractBalance := evmAppA.BankKeeper.GetBalance( + contractBalance := evmAppA.GetBankKeeper().GetBalance( s.chainA.GetContext(), ics20CallerAddr.Bytes(), sourceBondDenom, @@ -363,13 +363,13 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, evmAppCreator ibctesting.A expectedContractBalance = expectedContractBalance.Sub(math.NewInt(15)) } // balance after transfer should be 0 - contractBalance = evmAppA.BankKeeper.GetBalance( + contractBalance = evmAppA.GetBankKeeper().GetBalance( s.chainA.GetContext(), ics20CallerAddr.Bytes(), sourceBondDenom, ) Expect(contractBalance.Amount).To(Equal(expectedContractBalance), "Contract balance should be equal to the expected amount after transfer") - escrowBalance = evmAppA.BankKeeper.GetBalance( + escrowBalance = evmAppA.GetBankKeeper().GetBalance( s.chainA.GetContext(), escrowAddr, sourceBondDenom, @@ -393,13 +393,13 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, evmAppCreator ibctesting.A It("should revert the transfer but continue execution after try catch", func() { path := evmibctesting.NewTransferPath(s.chainA, s.chainB) path.Setup() - evmAppA := s.chainA.App.(*evmd.EVMD) + evmAppA := s.chainA.App.(evm.EvmApp) sourcePortID := path.EndpointA.ChannelConfig.PortID sourceChannelID := path.EndpointA.ChannelID sourceBondDenom := s.chainABondDenom escrowAddr := types.GetEscrowAddress(sourcePortID, sourceChannelID) - escrowBalance := evmAppA.BankKeeper.GetBalance( + escrowBalance := evmAppA.GetBankKeeper().GetBalance( s.chainA.GetContext(), escrowAddr, sourceBondDenom, @@ -408,14 +408,14 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, evmAppCreator ibctesting.A // send some tokens to the contract address fundAmt := math.NewInt(100) - err = evmAppA.BankKeeper.SendCoins( + err = evmAppA.GetBankKeeper().SendCoins( s.chainA.GetContext(), s.chainA.SenderAccount.GetAddress(), ics20CallerAddr.Bytes(), sdk.NewCoins(sdk.NewCoin(sourceBondDenom, fundAmt)), ) Expect(err).To(BeNil(), "Failed to send tokens to contract address") - contractBalance := evmAppA.BankKeeper.GetBalance( + contractBalance := evmAppA.GetBankKeeper().GetBalance( s.chainA.GetContext(), ics20CallerAddr.Bytes(), sourceBondDenom, @@ -452,19 +452,19 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, evmAppCreator ibctesting.A 0, ) Expect(err).To(BeNil(), "Failed to testTransfer") - contractBalanceAfter := evmAppA.BankKeeper.GetBalance( + contractBalanceAfter := evmAppA.GetBankKeeper().GetBalance( s.chainA.GetContext(), ics20CallerAddr.Bytes(), sourceBondDenom, ) Expect(contractBalanceAfter.Amount).To(Equal(contractBalance.Amount.Sub(math.NewInt(15)))) - escrowBalance = evmAppA.BankKeeper.GetBalance( + escrowBalance = evmAppA.GetBankKeeper().GetBalance( s.chainA.GetContext(), escrowAddr, sourceBondDenom, ) Expect(escrowBalance.Amount).To(Equal(math.ZeroInt())) - randomAccBalance := evmAppA.BankKeeper.GetBalance( + randomAccBalance := evmAppA.GetBankKeeper().GetBalance( s.chainA.GetContext(), randomAccAddr, sourceBondDenom, diff --git a/tests/integration/precompiles/ics20/test_query.go b/tests/integration/precompiles/ics20/test_query.go index 810c1885..0e46238c 100644 --- a/tests/integration/precompiles/ics20/test_query.go +++ b/tests/integration/precompiles/ics20/test_query.go @@ -5,7 +5,7 @@ import ( "github.com/ethereum/go-ethereum/common" - "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm" cmn "github.com/cosmos/evm/precompiles/common" "github.com/cosmos/evm/precompiles/ics20" precompiletestutil "github.com/cosmos/evm/precompiles/testutil" @@ -46,8 +46,8 @@ func (s *PrecompileTestSuite) TestDenoms() { name: "success", args: []interface{}{query.PageRequest{Limit: 10, CountTotal: true}}, malleate: func(ctx sdk.Context) { - evmApp := s.chainA.App.(*evmd.EVMD) - evmApp.TransferKeeper.SetDenom(ctx, denom) + evmApp := s.chainA.App.(evm.EvmApp) + evmApp.GetTransferKeeper().SetDenom(ctx, denom) }, expDenom: denom, }, @@ -107,8 +107,8 @@ func (s *PrecompileTestSuite) TestDenom() { name: "success - denom found", arg: denom.Hash().String(), malleate: func(ctx sdk.Context) { - evmApp := s.chainA.App.(*evmd.EVMD) - evmApp.TransferKeeper.SetDenom(ctx, denom) + evmApp := s.chainA.App.(evm.EvmApp) + evmApp.GetTransferKeeper().SetDenom(ctx, denom) }, expDenom: denom, }, @@ -188,8 +188,8 @@ func (s *PrecompileTestSuite) TestDenomHash() { name: "success", arg: denom.Path(), malleate: func(ctx sdk.Context) { - evmApp := s.chainA.App.(*evmd.EVMD) - evmApp.TransferKeeper.SetDenom(ctx, denom) + evmApp := s.chainA.App.(evm.EvmApp) + evmApp.GetTransferKeeper().SetDenom(ctx, denom) }, expHash: denom.Hash().String(), }, diff --git a/tests/integration/precompiles/ics20/test_setup.go b/tests/integration/precompiles/ics20/test_setup.go index dcc559da..28ce0c39 100644 --- a/tests/integration/precompiles/ics20/test_setup.go +++ b/tests/integration/precompiles/ics20/test_setup.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/suite" - "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm" "github.com/cosmos/evm/precompiles/ics20" evmibctesting "github.com/cosmos/evm/testutil/ibc" ibctesting "github.com/cosmos/ibc-go/v10/testing" @@ -42,22 +42,22 @@ func (s *PrecompileTestSuite) SetupTest() { s.chainA = s.coordinator.GetChain(evmibctesting.GetEvmChainID(1)) s.chainB = s.coordinator.GetChain(evmibctesting.GetEvmChainID(2)) - evmAppA := s.chainA.App.(*evmd.EVMD) + evmAppA := s.chainA.App.(evm.EvmApp) s.chainAPrecompile, _ = ics20.NewPrecompile( - evmAppA.BankKeeper, - *evmAppA.StakingKeeper, - evmAppA.TransferKeeper, - evmAppA.IBCKeeper.ChannelKeeper, - evmAppA.EVMKeeper, + evmAppA.GetBankKeeper(), + *evmAppA.GetStakingKeeper(), + evmAppA.GetTransferKeeper(), + evmAppA.GetIBCKeeper().ChannelKeeper, + evmAppA.GetEVMKeeper(), ) - s.chainABondDenom, _ = evmAppA.StakingKeeper.BondDenom(s.chainA.GetContext()) - evmAppB := s.chainB.App.(*evmd.EVMD) + s.chainABondDenom, _ = evmAppA.GetStakingKeeper().BondDenom(s.chainA.GetContext()) + evmAppB := s.chainB.App.(evm.EvmApp) s.chainBPrecompile, _ = ics20.NewPrecompile( - evmAppB.BankKeeper, - *evmAppB.StakingKeeper, - evmAppB.TransferKeeper, - evmAppB.IBCKeeper.ChannelKeeper, - evmAppB.EVMKeeper, + evmAppB.GetBankKeeper(), + *evmAppB.GetStakingKeeper(), + evmAppB.GetTransferKeeper(), + evmAppB.GetIBCKeeper().ChannelKeeper, + evmAppB.GetEVMKeeper(), ) - s.chainBBondDenom, _ = evmAppB.StakingKeeper.BondDenom(s.chainB.GetContext()) + s.chainBBondDenom, _ = evmAppB.GetStakingKeeper().BondDenom(s.chainB.GetContext()) } diff --git a/tests/integration/precompiles/ics20/test_tx.go b/tests/integration/precompiles/ics20/test_tx.go index 92ad4b94..c8d90f35 100644 --- a/tests/integration/precompiles/ics20/test_tx.go +++ b/tests/integration/precompiles/ics20/test_tx.go @@ -5,7 +5,7 @@ import ( "github.com/ethereum/go-ethereum/common" - "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm" evmibctesting "github.com/cosmos/evm/testutil/ibc" "github.com/cosmos/evm/testutil/tx" transfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" @@ -27,8 +27,8 @@ type testCase struct { } func (s *PrecompileTestSuite) TestTransferErrors() { - evmAppA := s.chainA.App.(*evmd.EVMD) - denom, err := evmAppA.StakingKeeper.BondDenom(s.chainA.GetContext()) + evmAppA := s.chainA.App.(evm.EvmApp) + denom, err := evmAppA.GetStakingKeeper().BondDenom(s.chainA.GetContext()) s.Require().NoError(err) timeoutHeight := clienttypes.NewHeight(1, 110) @@ -117,8 +117,8 @@ func (s *PrecompileTestSuite) TestTransfer() { path := evmibctesting.NewTransferPath(s.chainA, s.chainB) path.Setup() - evmAppA := s.chainA.App.(*evmd.EVMD) - denom, err := evmAppA.StakingKeeper.BondDenom(s.chainA.GetContext()) + evmAppA := s.chainA.App.(evm.EvmApp) + denom, err := evmAppA.GetStakingKeeper().BondDenom(s.chainA.GetContext()) s.Require().NoError(err) amount := sdkmath.NewInt(5) @@ -160,8 +160,8 @@ func (s *PrecompileTestSuite) TestTransfer() { trace := transfertypes.NewHop(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) chainBDenom := transfertypes.NewDenom(denom, trace) - evmAppB := s.chainB.App.(*evmd.EVMD) - balance := evmAppB.BankKeeper.GetBalance( + evmAppB := s.chainB.App.(evm.EvmApp) + balance := evmAppB.GetBankKeeper().GetBalance( s.chainB.GetContext(), s.chainB.SenderAccount.GetAddress(), chainBDenom.IBCDenom(), diff --git a/tests/integration/rpc/backend/test_backend_suite.go b/tests/integration/rpc/backend/test_backend_suite.go index ab4fdb2e..5f3065fc 100644 --- a/tests/integration/rpc/backend/test_backend_suite.go +++ b/tests/integration/rpc/backend/test_backend_suite.go @@ -13,13 +13,13 @@ import ( cmtrpctypes "github.com/cometbft/cometbft/rpc/core/types" dbm "github.com/cosmos/cosmos-db" - evmdconfig "github.com/cosmos/evm/cmd/evmd/config" "github.com/cosmos/evm/crypto/hd" "github.com/cosmos/evm/encoding" "github.com/cosmos/evm/indexer" rpcbackend "github.com/cosmos/evm/rpc/backend" "github.com/cosmos/evm/rpc/backend/mocks" rpctypes "github.com/cosmos/evm/rpc/types" + "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/constants" "github.com/cosmos/evm/testutil/integration/evm/network" utiltx "github.com/cosmos/evm/testutil/tx" @@ -55,7 +55,7 @@ var ChainID = constants.ExampleChainID func (s *TestSuite) SetupTest() { ctx := server.NewDefaultContext() ctx.Viper.Set("telemetry.global-labels", []interface{}{}) - ctx.Viper.Set("evm.evm-chain-id", evmdconfig.EVMChainID) + ctx.Viper.Set("evm.evm-chain-id", config.EVMChainID) baseDir := s.T().TempDir() nodeDirName := "node" @@ -200,7 +200,7 @@ func (s *TestSuite) buildFormattedBlock( func (s *TestSuite) generateTestKeyring(clientDir string) (keyring.Keyring, error) { buf := bufio.NewReader(os.Stdin) - encCfg := encoding.MakeConfig(evmdconfig.EVMChainID) + encCfg := encoding.MakeConfig(config.EVMChainID) return keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, clientDir, buf, encCfg.Codec, []keyring.Option{hd.EthSecp256k1Option()}...) } diff --git a/tests/integration/rpc/backend/test_chain_info.go b/tests/integration/rpc/backend/test_chain_info.go index 89d79ba9..4965d6c0 100644 --- a/tests/integration/rpc/backend/test_chain_info.go +++ b/tests/integration/rpc/backend/test_chain_info.go @@ -11,9 +11,9 @@ import ( "github.com/cometbft/cometbft/abci/types" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" - evmdconfig "github.com/cosmos/evm/cmd/evmd/config" "github.com/cosmos/evm/rpc/backend/mocks" rpc "github.com/cosmos/evm/rpc/types" + "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -155,7 +155,7 @@ func (s *TestSuite) TestBaseFee() { } func (s *TestSuite) TestChainID() { - expChainID := (*hexutil.Big)(big.NewInt(evmdconfig.EVMChainID)) + expChainID := (*hexutil.Big)(big.NewInt(config.EVMChainID)) testCases := []struct { name string registerMock func() diff --git a/tests/integration/rpc/backend/test_evm_query_client.go b/tests/integration/rpc/backend/test_evm_query_client.go index ef0cf52b..aca52954 100644 --- a/tests/integration/rpc/backend/test_evm_query_client.go +++ b/tests/integration/rpc/backend/test_evm_query_client.go @@ -15,9 +15,9 @@ import ( "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" - evmdconfig "github.com/cosmos/evm/cmd/evmd/config" "github.com/cosmos/evm/rpc/backend/mocks" rpc "github.com/cosmos/evm/rpc/types" + "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -39,18 +39,18 @@ var _ evmtypes.QueryClient = &mocks.EVMQueryClient{} func RegisterTraceTransactionWithPredecessors(queryClient *mocks.EVMQueryClient, msgEthTx *evmtypes.MsgEthereumTx, predecessors []*evmtypes.MsgEthereumTx) { data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d} queryClient.On("TraceTx", rpc.ContextWithHeight(1), - &evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, Predecessors: predecessors, ChainId: evmdconfig.EVMChainID, BlockMaxGas: -1}). + &evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, Predecessors: predecessors, ChainId: config.EVMChainID, BlockMaxGas: -1}). Return(&evmtypes.QueryTraceTxResponse{Data: data}, nil) } func RegisterTraceTransaction(queryClient *mocks.EVMQueryClient, msgEthTx *evmtypes.MsgEthereumTx) { data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d} - queryClient.On("TraceTx", rpc.ContextWithHeight(1), &evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: evmdconfig.EVMChainID, BlockMaxGas: -1}). + queryClient.On("TraceTx", rpc.ContextWithHeight(1), &evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: config.EVMChainID, BlockMaxGas: -1}). Return(&evmtypes.QueryTraceTxResponse{Data: data}, nil) } func RegisterTraceTransactionError(queryClient *mocks.EVMQueryClient, msgEthTx *evmtypes.MsgEthereumTx) { - queryClient.On("TraceTx", rpc.ContextWithHeight(1), &evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: evmdconfig.EVMChainID}). + queryClient.On("TraceTx", rpc.ContextWithHeight(1), &evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: config.EVMChainID}). Return(nil, errortypes.ErrInvalidRequest) } @@ -58,7 +58,7 @@ func RegisterTraceTransactionError(queryClient *mocks.EVMQueryClient, msgEthTx * func RegisterTraceBlock(queryClient *mocks.EVMQueryClient, txs []*evmtypes.MsgEthereumTx) { data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d} queryClient.On("TraceBlock", rpc.ContextWithHeight(1), - &evmtypes.QueryTraceBlockRequest{Txs: txs, BlockNumber: 1, TraceConfig: &evmtypes.TraceConfig{}, ChainId: evmdconfig.EVMChainID, BlockMaxGas: -1}). + &evmtypes.QueryTraceBlockRequest{Txs: txs, BlockNumber: 1, TraceConfig: &evmtypes.TraceConfig{}, ChainId: config.EVMChainID, BlockMaxGas: -1}). Return(&evmtypes.QueryTraceBlockResponse{Data: data}, nil) } diff --git a/tests/integration/x/erc20/test_grpc_query.go b/tests/integration/x/erc20/test_grpc_query.go index 08838297..1fbf19f4 100644 --- a/tests/integration/x/erc20/test_grpc_query.go +++ b/tests/integration/x/erc20/test_grpc_query.go @@ -3,7 +3,7 @@ package erc20 import ( "fmt" - exampleapp "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm/testutil/config" testconstants "github.com/cosmos/evm/testutil/constants" utiltx "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/evm/x/erc20/types" @@ -174,7 +174,7 @@ func (s *KeeperTestSuite) TestTokenPair() { func (s *KeeperTestSuite) TestQueryParams() { s.SetupTest() ctx := s.network.GetContext() - expParams := exampleapp.NewErc20GenesisState().Params + expParams := config.NewErc20GenesisState().Params res, err := s.queryClient.Params(ctx, &types.QueryParamsRequest{}) s.Require().NoError(err) diff --git a/tests/integration/x/precisebank/test_send_integration.go b/tests/integration/x/precisebank/test_send_integration.go index db069fc3..4190b842 100644 --- a/tests/integration/x/precisebank/test_send_integration.go +++ b/tests/integration/x/precisebank/test_send_integration.go @@ -2,22 +2,31 @@ package precisebank import ( "fmt" + "maps" "math/big" "math/rand" + "sort" "testing" + corevm "github.com/ethereum/go-ethereum/core/vm" "github.com/stretchr/testify/require" - "github.com/cosmos/evm/evmd" testconstants "github.com/cosmos/evm/testutil/constants" + cosmosevmutils "github.com/cosmos/evm/utils" + erc20types "github.com/cosmos/evm/x/erc20/types" + feemarkettypes "github.com/cosmos/evm/x/feemarket/types" "github.com/cosmos/evm/x/precisebank/types" + precisebanktypes "github.com/cosmos/evm/x/precisebank/types" evmtypes "github.com/cosmos/evm/x/vm/types" + ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -78,7 +87,7 @@ func (s *KeeperIntegrationTestSuite) TestSendCoinsFromModuleToAccountMatchingErr // we only are testing the errors/panics specific to the method and // remaining logic is the same as SendCoins. - blockedMacAddrs := evmd.BlockedAddresses() + blockedMacAddrs := blockedAddresses() precisebankAddr := s.network.App.GetAccountKeeper().GetModuleAddress(types.ModuleName) var blockedAddr sdk.AccAddress @@ -99,7 +108,7 @@ func (s *KeeperIntegrationTestSuite) TestSendCoinsFromModuleToAccountMatchingErr // x/precisebank is blocked from use with SendCoinsFromModuleToAccount as we // don't want external modules to modify x/precisebank balances. var senderModuleName string - macPerms := evmd.GetMaccPerms() + macPerms := getMaccPerms() for moduleName := range macPerms { if moduleName != types.ModuleName && moduleName != stakingtypes.BondedPoolName { senderModuleName = moduleName @@ -853,3 +862,52 @@ func FuzzSendCoins(f *testing.F) { ) }) } + +func blockedAddresses() map[string]bool { + blockedAddrs := make(map[string]bool) + + maps.Clone(maccPerms) + maccPerms := getMaccPerms() + accs := make([]string, 0, len(maccPerms)) + for acc := range maccPerms { + accs = append(accs, acc) + } + sort.Strings(accs) + + for _, acc := range accs { + blockedAddrs[authtypes.NewModuleAddress(acc).String()] = true + } + + blockedPrecompilesHex := evmtypes.AvailableStaticPrecompiles + for _, addr := range corevm.PrecompiledAddressesBerlin { + blockedPrecompilesHex = append(blockedPrecompilesHex, addr.Hex()) + } + + for _, precompile := range blockedPrecompilesHex { + blockedAddrs[cosmosevmutils.Bech32StringFromHexAddress(precompile)] = true + } + + return blockedAddrs +} + +// module account permissions +var maccPerms = map[string][]string{ + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + + // Cosmos EVM modules + evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + feemarkettypes.ModuleName: nil, + erc20types.ModuleName: {authtypes.Minter, authtypes.Burner}, + precisebanktypes.ModuleName: {authtypes.Minter, authtypes.Burner}, +} + +// getMaccPerms returns a copy of the module account permissions +func getMaccPerms() map[string][]string { + return maps.Clone(maccPerms) +} diff --git a/tests/integration/x/vm/test_params.go b/tests/integration/x/vm/test_params.go index 1bbaf9a9..9f540250 100644 --- a/tests/integration/x/vm/test_params.go +++ b/tests/integration/x/vm/test_params.go @@ -1,12 +1,12 @@ package vm import ( - exampleapp "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/x/vm/types" ) func (s *KeeperTestSuite) TestParams() { - defaultChainEVMParams := exampleapp.NewEVMGenesisState().Params + defaultChainEVMParams := config.NewEVMGenesisState().Params defaultChainEVMParams.ActiveStaticPrecompiles = types.AvailableStaticPrecompiles testCases := []struct { diff --git a/tests/integration/x/vm/test_state_transition.go b/tests/integration/x/vm/test_state_transition.go index de89a150..1486ab50 100644 --- a/tests/integration/x/vm/test_state_transition.go +++ b/tests/integration/x/vm/test_state_transition.go @@ -14,7 +14,7 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" cmttypes "github.com/cometbft/cometbft/types" - exampleapp "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -542,7 +542,7 @@ func (s *KeeperTestSuite) TestResetGasMeterAndConsumeGas() { func (s *KeeperTestSuite) TestEVMConfig() { s.SetupTest() - defaultChainEVMParams := exampleapp.NewEVMGenesisState().Params + defaultChainEVMParams := config.NewEVMGenesisState().Params proposerAddress := s.Network.GetContext().BlockHeader().ProposerAddress cfg, err := s.Network.App.GetEVMKeeper().EVMConfig( diff --git a/tests/solidity/test-helper.js b/tests/solidity/test-helper.js index 12a0d8df..da4265aa 100644 --- a/tests/solidity/test-helper.js +++ b/tests/solidity/test-helper.js @@ -116,7 +116,7 @@ function restoreHardhatConfig(hardhatConfigPath, backupPath) { // Function to sync configuration from Go to Hardhat function syncConfiguration() { // Adjust these paths based on your project structure - const goConfigPath = path.join(__dirname, '../../cmd/evmd/config/config.go') + const goConfigPath = path.join(__dirname, '../../evmd/cmd/evmd/config/config.go') const hardhatConfigPath = path.join(__dirname, './suites/precompiles/hardhat.config.js') logger.info('Syncing configuration from Go to Hardhat...') diff --git a/testutil/config/activators.go b/testutil/config/activators.go new file mode 100644 index 00000000..a88b99e6 --- /dev/null +++ b/testutil/config/activators.go @@ -0,0 +1,13 @@ +package config + +import ( + "github.com/ethereum/go-ethereum/core/vm" +) + +// cosmosEVMActivators defines a map of opcode modifiers associated +// with a key defining the corresponding EIP. +var cosmosEVMActivators = map[int]func(*vm.JumpTable){ + 0o000: Enable0000, + 0o001: Enable0001, + 0o002: Enable0002, +} diff --git a/testutil/config/config.go b/testutil/config/config.go new file mode 100644 index 00000000..304459a4 --- /dev/null +++ b/testutil/config/config.go @@ -0,0 +1,71 @@ +package config + +import ( + "github.com/cosmos/evm/types" + evmtypes "github.com/cosmos/evm/x/vm/types" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// ChainsCoinInfo is a map of the chain id and its corresponding EvmCoinInfo +// that allows initializing the app with different coin info based on the +// chain id +var ChainsCoinInfo = map[uint64]evmtypes.EvmCoinInfo{ + EighteenDecimalsChainID: { + Denom: ExampleChainDenom, + ExtendedDenom: ExampleChainDenom, + DisplayDenom: ExampleDisplayDenom, + Decimals: evmtypes.EighteenDecimals, + }, + CosmosChainID: { + Denom: "atest", + ExtendedDenom: "atest", + DisplayDenom: "test", + Decimals: evmtypes.EighteenDecimals, + }, + EVMChainID: { + Denom: "atest", + ExtendedDenom: "atest", + DisplayDenom: "test", + Decimals: evmtypes.EighteenDecimals, + }, +} + +const ( + // Bech32Prefix defines the Bech32 prefix used for accounts on the exemplary Cosmos EVM blockchain. + Bech32Prefix = "cosmos" + // Bech32PrefixAccAddr defines the Bech32 prefix of an account's address. + Bech32PrefixAccAddr = Bech32Prefix + // Bech32PrefixAccPub defines the Bech32 prefix of an account's public key. + Bech32PrefixAccPub = Bech32Prefix + sdk.PrefixPublic + // Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address. + Bech32PrefixValAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + // Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key. + Bech32PrefixValPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic + // Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address. + Bech32PrefixConsAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + // Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key. + Bech32PrefixConsPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic + // DisplayDenom defines the denomination displayed to users in client applications. + DisplayDenom = "atom" + // BaseDenom defines to the default denomination used in the Cosmos EVM example chain. + BaseDenom = "aatom" + // BaseDenomUnit defines the precision of the base denomination. + BaseDenomUnit = 18 + // EVMChainID defines the EIP-155 replay-protection chain id for the current ethereum chain config. + EVMChainID = 4221 +) + +// SetBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings. +func SetBech32Prefixes(config *sdk.Config) { + config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub) + config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub) + config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub) +} + +// SetBip44CoinType sets the global coin type to be used in hierarchical deterministic wallets. +func SetBip44CoinType(config *sdk.Config) { + config.SetCoinType(types.Bip44CoinType) + config.SetPurpose(sdk.Purpose) // Shared + config.SetFullFundraiserPath(types.BIP44HDPath) //nolint: staticcheck +} diff --git a/testutil/config/config_testing.go b/testutil/config/config_testing.go new file mode 100644 index 00000000..688c7a5e --- /dev/null +++ b/testutil/config/config_testing.go @@ -0,0 +1,116 @@ +//go:build test +// +build test + +package config + +import ( + "fmt" + + evmtypes "github.com/cosmos/evm/x/vm/types" + + "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// TestChainsCoinInfo is a map of the chain id and its corresponding EvmCoinInfo +// that allows initializing the app with different coin info based on the +// chain id +var TestChainsCoinInfo = map[uint64]evmtypes.EvmCoinInfo{ + EighteenDecimalsChainID: { + Denom: ExampleChainDenom, + ExtendedDenom: ExampleChainDenom, + DisplayDenom: ExampleDisplayDenom, + Decimals: evmtypes.EighteenDecimals, + }, + SixDecimalsChainID: { + Denom: "utest", + ExtendedDenom: "atest", + DisplayDenom: "test", + Decimals: evmtypes.SixDecimals, + }, + TwelveDecimalsChainID: { + Denom: "ptest2", + ExtendedDenom: "atest2", + DisplayDenom: "test2", + Decimals: evmtypes.TwelveDecimals, + }, + TwoDecimalsChainID: { + Denom: "ctest3", + ExtendedDenom: "atest3", + DisplayDenom: "test3", + Decimals: evmtypes.TwoDecimals, + }, + TestChainID1: { + Denom: ExampleChainDenom, + ExtendedDenom: ExampleChainDenom, + DisplayDenom: ExampleChainDenom, + Decimals: evmtypes.EighteenDecimals, + }, + TestChainID2: { + Denom: ExampleChainDenom, + ExtendedDenom: ExampleChainDenom, + DisplayDenom: ExampleChainDenom, + Decimals: evmtypes.EighteenDecimals, + }, +} + +// EVMOptionsFn defines a function type for setting app options specifically for +// the Cosmos EVM app. The function should receive the chainID and return an error if +// any. +type EVMOptionsFn func(uint64) error + +// NoOpEVMOptions is a no-op function that can be used when the app does not +// need any specific configuration. +func NoOpEVMOptions(_ uint64) error { + return nil +} + +// EvmAppOptions allows to setup the global configuration +// for the Cosmos EVM chain. +func EvmAppOptions(chainID uint64) error { + coinInfo, found := TestChainsCoinInfo[chainID] + if !found { + return fmt.Errorf("unknown chain id: %d", chainID) + } + + // set the base denom considering if its mainnet or testnet + if err := setBaseDenom(coinInfo); err != nil { + return err + } + + ethCfg := evmtypes.DefaultChainConfig(chainID) + + configurator := evmtypes.NewEVMConfigurator() + // reset configuration to set the new one + configurator.ResetTestConfig() + err := configurator. + WithExtendedEips(cosmosEVMActivators). + WithChainConfig(ethCfg). + WithEVMCoinInfo(coinInfo). + Configure() + if err != nil { + return err + } + + return nil +} + +// setBaseDenom registers the display denom and base denom and sets the +// base denom for the chain. The function registered different values based on +// the EvmCoinInfo to allow different configurations in mainnet and testnet. +func setBaseDenom(ci evmtypes.EvmCoinInfo) (err error) { + // Defer setting the base denom, and capture any potential error from it. + // So when failing because the denom was already registered, we ignore it and set + // the corresponding denom to be base denom + defer func() { + err = sdk.SetBaseDenom(ci.Denom) + }() + if err := sdk.RegisterDenom(ci.DisplayDenom, math.LegacyOneDec()); err != nil { + return err + } + + // sdk.RegisterDenom will automatically overwrite the base denom when the + // new setBaseDenom() units are lower than the current base denom's units. + return sdk.RegisterDenom(ci.Denom, math.LegacyNewDecWithPrec(1, int64(ci.Decimals))) +} diff --git a/testutil/config/constants.go b/testutil/config/constants.go new file mode 100644 index 00000000..fb9bdbe4 --- /dev/null +++ b/testutil/config/constants.go @@ -0,0 +1,31 @@ +package config + +const ( + // ExampleChainDenom is the denomination of the Cosmos EVM example chain's base coin. + ExampleChainDenom = "aatom" + + // ExampleDisplayDenom is the display denomination of the Cosmos EVM example chain's base coin. + ExampleDisplayDenom = "atom" + + // EighteenDecimalsChainID is the chain ID for the 18 decimals chain. + EighteenDecimalsChainID = 9001 + + // SixDecimalsChainID is the chain ID for the 6 decimals chain. + SixDecimalsChainID = 9002 + + // TwelveDecimalsChainID is the chain ID for the 12 decimals chain. + TwelveDecimalsChainID = 9003 + + // TwoDecimalsChainID is the chain ID for the 2 decimals chain. + TwoDecimalsChainID = 9004 + + CosmosChainID = 262144 + + // TestChainID1 is test chain IDs for IBC E2E test + TestChainID1 = 9005 + // TestChainID2 is test chain IDs for IBC E2E test + TestChainID2 = 9006 + + // WEVMOSContractMainnet is the WEVMOS contract address for mainnet + WEVMOSContractMainnet = "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517" +) diff --git a/testutil/config/eips.go b/testutil/config/eips.go new file mode 100644 index 00000000..a1157805 --- /dev/null +++ b/testutil/config/eips.go @@ -0,0 +1,33 @@ +package config + +import ( + "github.com/ethereum/go-ethereum/core/vm" +) + +var ( + Multiplier = uint64(10) + SstoreConstantGas = uint64(500) +) + +// enable0000 contains the logic to modify the CREATE and CREATE2 opcodes +// constant gas value. +func Enable0000(jt *vm.JumpTable) { + currentValCreate := jt[vm.CREATE].GetConstantGas() + jt[vm.CREATE].SetConstantGas(currentValCreate * Multiplier) + + currentValCreate2 := jt[vm.CREATE2].GetConstantGas() + jt[vm.CREATE2].SetConstantGas(currentValCreate2 * Multiplier) +} + +// enable0001 contains the logic to modify the CALL opcode +// constant gas value. +func Enable0001(jt *vm.JumpTable) { + currentVal := jt[vm.CALL].GetConstantGas() + jt[vm.CALL].SetConstantGas(currentVal * Multiplier) +} + +// enable0002 contains the logic to modify the SSTORE opcode +// constant gas value. +func Enable0002(jt *vm.JumpTable) { + jt[vm.SSTORE].SetConstantGas(SstoreConstantGas) +} diff --git a/testutil/config/evm_app_options.go b/testutil/config/evm_app_options.go new file mode 100644 index 00000000..1643ea5e --- /dev/null +++ b/testutil/config/evm_app_options.go @@ -0,0 +1,66 @@ +//go:build !test +// +build !test + +package config + +import ( + "fmt" + + evmtypes "github.com/cosmos/evm/x/vm/types" + + "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// EVMOptionsFn defines a function type for setting app options specifically for +// the Cosmos EVM app. The function should receive the chainID and return an error if +// any. +type EVMOptionsFn func(uint64) error + +var sealed = false + +// EvmAppOptions allows to setup the global configuration +// for the Cosmos EVM chain. +func EvmAppOptions(chainID uint64) error { + if sealed { + return nil + } + + coinInfo, found := ChainsCoinInfo[chainID] + if !found { + return fmt.Errorf("unknown chain id: %d", chainID) + } + + // set the denom info for the chain + if err := setBaseDenom(coinInfo); err != nil { + return err + } + + ethCfg := evmtypes.DefaultChainConfig(chainID) + + err := evmtypes.NewEVMConfigurator(). + WithExtendedEips(cosmosEVMActivators). + WithChainConfig(ethCfg). + // NOTE: we're using the 18 decimals default for the example chain + WithEVMCoinInfo(coinInfo). + Configure() + if err != nil { + return err + } + + sealed = true + return nil +} + +// setBaseDenom registers the display denom and base denom and sets the +// base denom for the chain. +func setBaseDenom(ci evmtypes.EvmCoinInfo) error { + if err := sdk.RegisterDenom(ci.DisplayDenom, math.LegacyOneDec()); err != nil { + return err + } + + // sdk.RegisterDenom will automatically overwrite the base denom when the + // new setBaseDenom() are lower than the current base denom's units. + return sdk.RegisterDenom(ci.Denom, math.LegacyNewDecWithPrec(1, int64(ci.Decimals))) +} diff --git a/testutil/config/genesis.go b/testutil/config/genesis.go new file mode 100644 index 00000000..88e4d5c6 --- /dev/null +++ b/testutil/config/genesis.go @@ -0,0 +1,64 @@ +package config + +import ( + "encoding/json" + + testconstants "github.com/cosmos/evm/testutil/constants" + erc20types "github.com/cosmos/evm/x/erc20/types" + feemarkettypes "github.com/cosmos/evm/x/feemarket/types" + evmtypes "github.com/cosmos/evm/x/vm/types" + + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +// GenesisState of the blockchain is represented here as a map of raw json +// messages key'd by an identifier string. +// The identifier is used to determine which module genesis information belongs +// to so it may be appropriately routed during init chain. +// Within this application default genesis information is retrieved from +// the ModuleBasicManager which populates json from each BasicModule +// object provided to it during init. +type GenesisState map[string]json.RawMessage + +// NewEVMGenesisState returns the default genesis state for the EVM module. +// +// NOTE: for the example chain implementation we need to set the default EVM denomination +// and enable ALL precompiles. +func NewEVMGenesisState() *evmtypes.GenesisState { + evmGenState := evmtypes.DefaultGenesisState() + evmGenState.Params.ActiveStaticPrecompiles = evmtypes.AvailableStaticPrecompiles + + return evmGenState +} + +// NewErc20GenesisState returns the default genesis state for the ERC20 module. +// +// NOTE: for the example chain implementation we are also adding a default token pair, +// which is the base denomination of the chain (i.e. the WEVMOS contract). +func NewErc20GenesisState() *erc20types.GenesisState { + erc20GenState := erc20types.DefaultGenesisState() + erc20GenState.TokenPairs = testconstants.ExampleTokenPairs + erc20GenState.Params.NativePrecompiles = append(erc20GenState.Params.NativePrecompiles, testconstants.WEVMOSContractMainnet) + + return erc20GenState +} + +// NewMintGenesisState returns the default genesis state for the mint module. +// +// NOTE: for the example chain implementation we are also adding a default minter. +func NewMintGenesisState() *minttypes.GenesisState { + mintGenState := minttypes.DefaultGenesisState() + mintGenState.Params.MintDenom = ExampleChainDenom + + return mintGenState +} + +// NewFeeMarketGenesisState returns the default genesis state for the feemarket module. +// +// NOTE: for the example chain implementation we are disabling the base fee. +func NewFeeMarketGenesisState() *feemarkettypes.GenesisState { + feeMarketGenState := feemarkettypes.DefaultGenesisState() + feeMarketGenState.Params.NoBaseFee = true + + return feeMarketGenState +} diff --git a/testutil/constants/constants_test.go b/testutil/constants/constants_test.go index 348b283f..30c951cd 100644 --- a/testutil/constants/constants_test.go +++ b/testutil/constants/constants_test.go @@ -5,14 +5,14 @@ import ( "github.com/stretchr/testify/require" - config2 "github.com/cosmos/evm/cmd/evmd/config" + "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/constants" ) func TestRequireSameTestDenom(t *testing.T) { require.Equal(t, constants.ExampleAttoDenom, - config2.ExampleChainDenom, + config.ExampleChainDenom, "test denoms should be the same across the repo", ) } @@ -20,7 +20,7 @@ func TestRequireSameTestDenom(t *testing.T) { func TestRequireSameTestBech32Prefix(t *testing.T) { require.Equal(t, constants.ExampleBech32Prefix, - config2.Bech32Prefix, + config.Bech32Prefix, "bech32 prefixes should be the same across the repo", ) } @@ -28,7 +28,7 @@ func TestRequireSameTestBech32Prefix(t *testing.T) { func TestRequireSameWEVMOSMainnet(t *testing.T) { require.Equal(t, constants.WEVMOSContractMainnet, - config2.WEVMOSContractMainnet, + config.WEVMOSContractMainnet, "wevmos contract addresses should be the same across the repo", ) } diff --git a/testutil/ibc/chain.go b/testutil/ibc/chain.go index c3caaf46..e78c82c4 100644 --- a/testutil/ibc/chain.go +++ b/testutil/ibc/chain.go @@ -18,8 +18,8 @@ import ( cmtversion "github.com/cometbft/cometbft/version" "github.com/cosmos/evm" - "github.com/cosmos/evm/cmd/evmd/config" "github.com/cosmos/evm/crypto/ethsecp256k1" + "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/evm/x/vm/types" clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" diff --git a/testutil/ibc/coordinator.go b/testutil/ibc/coordinator.go index b7d4959e..c4823df4 100644 --- a/testutil/ibc/coordinator.go +++ b/testutil/ibc/coordinator.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm/testutil/config" ibctesting "github.com/cosmos/ibc-go/v10/testing" ) @@ -42,7 +42,7 @@ func NewCoordinator(t *testing.T, nEVMChains, mCosmosChains int, evmAppCreator i chainID := GetChainID(i) evmChainID, err := strconv.ParseUint(GetEvmChainID(i), 10, 64) require.NoError(t, err) - require.NoError(t, evmd.EvmAppOptions(evmChainID)) + require.NoError(t, config.EvmAppOptions(evmChainID)) // setup EVM chains chains[strconv.FormatUint(evmChainID, 10)] = NewTestChain(t, true, coord, chainID) } diff --git a/testutil/ibc/helpers.go b/testutil/ibc/helpers.go index 2a4a4bba..85f74994 100644 --- a/testutil/ibc/helpers.go +++ b/testutil/ibc/helpers.go @@ -10,7 +10,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/evm/cmd/evmd/config" + "github.com/cosmos/evm/testutil/config" bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" diff --git a/testutil/ibc/testing_app.go b/testutil/ibc/testing_app.go deleted file mode 100644 index f22679e3..00000000 --- a/testutil/ibc/testing_app.go +++ /dev/null @@ -1,33 +0,0 @@ -package ibctesting - -import ( - "encoding/json" - - dbm "github.com/cosmos/cosmos-db" - "github.com/cosmos/evm/evmd" - feemarkettypes "github.com/cosmos/evm/x/feemarket/types" - ibctesting "github.com/cosmos/ibc-go/v10/testing" - - "cosmossdk.io/log" - - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" -) - -func SetupExampleApp() (ibctesting.TestingApp, map[string]json.RawMessage) { - app := evmd.NewExampleApp( - log.NewNopLogger(), - dbm.NewMemDB(), - nil, - true, - simtestutil.EmptyAppOptions{}, - 9001, - evmd.EvmAppOptions, - ) - // disable base fee for testing - genesisState := app.DefaultGenesis() - fmGen := feemarkettypes.DefaultGenesisState() - fmGen.Params.NoBaseFee = true - genesisState[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(fmGen) - - return app, genesisState -} diff --git a/x/erc20/types/params_test.go b/x/erc20/types/params_test.go index e6dca091..547dacc1 100644 --- a/x/erc20/types/params_test.go +++ b/x/erc20/types/params_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm/testutil/config" testconstants "github.com/cosmos/evm/testutil/constants" "github.com/cosmos/evm/x/erc20/types" ) @@ -162,7 +162,7 @@ func (suite *ParamsTestSuite) TestIsNativePrecompile() { }{ { "default", - func() types.Params { return evmd.NewErc20GenesisState().Params }, + func() types.Params { return config.NewErc20GenesisState().Params }, common.HexToAddress(testconstants.WEVMOSContractMainnet), true, }, diff --git a/x/precisebank/keeper/keeper_test.go b/x/precisebank/keeper/keeper_test.go index 3a980c7a..2388f884 100644 --- a/x/precisebank/keeper/keeper_test.go +++ b/x/precisebank/keeper/keeper_test.go @@ -4,7 +4,7 @@ import ( "testing" evmosencoding "github.com/cosmos/evm/encoding" - "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm/testutil/config" testconstants "github.com/cosmos/evm/testutil/constants" "github.com/cosmos/evm/x/precisebank/keeper" "github.com/cosmos/evm/x/precisebank/types" @@ -44,7 +44,7 @@ func newMockedTestData(t *testing.T) testData { cfg := evmosencoding.MakeConfig(chainID) cdc := cfg.Codec k := keeper.NewKeeper(cdc, storeKey, bk, ak) - err := evmd.EvmAppOptions(chainID) + err := config.EvmAppOptions(chainID) if err != nil { return testData{} } diff --git a/x/vm/types/msg_test.go b/x/vm/types/msg_test.go index 3483faf7..7e020d7a 100644 --- a/x/vm/types/msg_test.go +++ b/x/vm/types/msg_test.go @@ -15,7 +15,7 @@ import ( "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/encoding" - "github.com/cosmos/evm/evmd" + "github.com/cosmos/evm/testutil/config" testconstants "github.com/cosmos/evm/testutil/constants" utiltx "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/evm/x/vm/types" @@ -57,7 +57,7 @@ func (suite *MsgsTestSuite) SetupTest() { encodingConfig := encoding.MakeConfig(suite.chainID.Uint64()) suite.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig) - err := evmd.EvmAppOptions(9001) + err := config.EvmAppOptions(9001) suite.Require().NoError(err) }