From 763729dbb89eaf8535694267cf6a141e57e61aff Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 19 Sep 2025 11:19:26 -0400 Subject: [PATCH 01/11] Move types to respective folders --- ante/cosmos/eip712.go | 8 +-- ante/evm/08_gas_consume.go | 6 +- ante/evm/10_gas_wanted.go | 2 +- ante/evm/fee_checker.go | 2 +- ante/evm/fee_checker_test.go | 2 +- {types => ante/types}/block.go | 0 {types => ante/types}/dynamic_fee.go | 0 {types => ante/types}/dynamic_fee.pb.go | 11 ++-- crypto/hd/algorithm_test.go | 14 ++--- crypto/hd/benchmark_test.go | 6 +- {types => crypto/hd}/hdpath.go | 2 +- encoding/codec/codec.go | 7 +-- {types => ethereum/eip712}/codec.go | 5 +- ethereum/eip712/preprocess.go | 4 +- ethereum/eip712/preprocess_test.go | 3 +- {types => ethereum/eip712}/web3.pb.go | 43 +++++++------- evmd/ante/evm_antehandler_benchmark_test.go | 2 +- evmd/ante/validate_handler_options_test.go | 2 +- evmd/app.go | 9 +-- evmd/cmd/evmd/config/config.go | 8 +-- evmd/tests/network/network.go | 25 ++++---- evmd/testutil/eth_setup.go | 8 +-- indexer/kv_indexer.go | 14 ++--- proto/cosmos/evm/types/v1/dynamic_fee.proto | 2 +- proto/cosmos/evm/types/v1/indexer.proto | 2 +- proto/cosmos/evm/types/v1/web3.proto | 2 +- rpc/apis.go | 25 ++++---- rpc/backend/backend.go | 10 ++-- rpc/backend/blocks.go | 5 +- rpc/backend/tx_info.go | 15 ++--- rpc/backend/utils.go | 5 +- rpc/namespaces/ethereum/eth/api.go | 3 +- rpc/namespaces/ethereum/personal/api.go | 5 +- rpc/stream/rpc.go | 2 +- rpc/types/block.go | 5 +- rpc/types/events.go | 2 +- {types => rpc/types}/protocol.go | 0 rpc/types/utils.go | 21 +++++++ server/indexer_service.go | 7 +-- server/json_rpc.go | 9 ++- server/start.go | 11 ++-- {types => server/types}/indexer.go | 0 {types => server/types}/indexer.pb.go | 40 ++++++------- tests/integration/ante/test_evm_fee_market.go | 2 +- tests/integration/rpc/backend/test_tx_info.go | 2 +- testutil/config/config.go | 8 +-- {types => testutil}/genesis.go | 4 +- testutil/integration/evm/network/amounts.go | 4 +- testutil/integration/evm/network/network.go | 3 +- testutil/integration/evm/network/setup.go | 32 +++++----- testutil/tx/eip712.go | 10 ++-- types/errors.go | 11 ---- {types => utils}/int.go | 2 +- {types => utils}/power.go | 2 +- utils/utils.go | 58 +------------------ utils/utils_test.go | 6 +- {types => utils}/validation.go | 2 +- {types => utils}/validation_test.go | 13 ++--- x/erc20/client/cli/tx.go | 2 +- x/erc20/keeper/grpc_query.go | 2 +- x/erc20/types/proposal.go | 3 +- x/erc20/types/token_pair.go | 3 +- x/feemarket/keeper/eip1559.go | 4 +- x/feemarket/types/utils.go | 30 ++++++++++ x/ibc/callbacks/keeper/keeper.go | 2 +- x/vm/keeper/grpc_query.go | 4 +- x/vm/keeper/state_transition.go | 6 +- {types => x/vm/types}/gasmeter.go | 0 x/vm/types/genesis.go | 5 +- x/vm/types/logs.go | 3 +- x/vm/types/params.go | 6 +- 71 files changed, 275 insertions(+), 308 deletions(-) rename {types => ante/types}/block.go (100%) rename {types => ante/types}/dynamic_fee.go (100%) rename {types => ante/types}/dynamic_fee.pb.go (96%) rename {types => crypto/hd}/hdpath.go (98%) rename {types => ethereum/eip712}/codec.go (88%) rename {types => ethereum/eip712}/web3.pb.go (82%) rename {types => rpc/types}/protocol.go (100%) rename {types => server/types}/indexer.go (100%) rename {types => server/types}/indexer.pb.go (85%) rename {types => testutil}/genesis.go (88%) delete mode 100644 types/errors.go rename {types => utils}/int.go (99%) rename {types => utils}/power.go (96%) rename {types => utils}/validation.go (98%) rename {types => utils}/validation_test.go (87%) create mode 100644 x/feemarket/types/utils.go rename {types => x/vm/types}/gasmeter.go (100%) diff --git a/ante/cosmos/eip712.go b/ante/cosmos/eip712.go index 5a209880c..470788bbf 100644 --- a/ante/cosmos/eip712.go +++ b/ante/cosmos/eip712.go @@ -8,12 +8,10 @@ import ( "github.com/ethereum/go-ethereum/crypto/secp256k1" "github.com/ethereum/go-ethereum/signer/core/apitypes" + errorsmod "cosmossdk.io/errors" anteinterfaces "github.com/cosmos/evm/ante/interfaces" "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/ethereum/eip712" - "github.com/cosmos/evm/types" - - errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -30,7 +28,7 @@ var evmCodec codec.ProtoCodecMarshaler func init() { registry := codectypes.NewInterfaceRegistry() - types.RegisterInterfaces(registry) + eip712.RegisterInterfaces(registry) evmCodec = codec.NewProtoCodec(registry) } @@ -204,7 +202,7 @@ func VerifySignature( return errorsmod.Wrap(errortypes.ErrUnknownExtensionOptions, "tx doesn't contain expected amount of extension options") } - extOpt, ok := opts[0].GetCachedValue().(*types.ExtensionOptionsWeb3Tx) + extOpt, ok := opts[0].GetCachedValue().(*eip712.ExtensionOptionsWeb3Tx) if !ok { return errorsmod.Wrap(errortypes.ErrUnknownExtensionOptions, "unknown extension option") } diff --git a/ante/evm/08_gas_consume.go b/ante/evm/08_gas_consume.go index 6580d43e2..6a6221616 100644 --- a/ante/evm/08_gas_consume.go +++ b/ante/evm/08_gas_consume.go @@ -1,13 +1,13 @@ package evm import ( + types2 "github.com/cosmos/evm/ante/types" "math/big" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" anteinterfaces "github.com/cosmos/evm/ante/interfaces" - "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" @@ -99,7 +99,7 @@ func GetMsgPriority( // TODO: (@fedekunze) Why is this necessary? This seems to be a duplicate from the CheckGasWanted function. func CheckBlockGasLimit(ctx sdktypes.Context, gasWanted uint64, minPriority int64) (sdktypes.Context, error) { - blockGasLimit := types.BlockGasLimit(ctx) + blockGasLimit := types2.BlockGasLimit(ctx) // return error if the tx gas is greater than the block limit (max gas) @@ -122,7 +122,7 @@ func CheckBlockGasLimit(ctx sdktypes.Context, gasWanted uint64, minPriority int6 // FIXME: use a custom gas configuration that doesn't add any additional gas and only // takes into account the gas consumed at the end of the EVM transaction. ctx = ctx. - WithGasMeter(types.NewInfiniteGasMeterWithLimit(gasWanted)). + WithGasMeter(evmtypes.NewInfiniteGasMeterWithLimit(gasWanted)). WithPriority(minPriority) return ctx, nil diff --git a/ante/evm/10_gas_wanted.go b/ante/evm/10_gas_wanted.go index 4dbb1d0fe..679800d9b 100644 --- a/ante/evm/10_gas_wanted.go +++ b/ante/evm/10_gas_wanted.go @@ -1,10 +1,10 @@ package evm import ( + "github.com/cosmos/evm/ante/types" "math/big" anteinterfaces "github.com/cosmos/evm/ante/interfaces" - "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" diff --git a/ante/evm/fee_checker.go b/ante/evm/fee_checker.go index fb4467de3..5a5d617ad 100644 --- a/ante/evm/fee_checker.go +++ b/ante/evm/fee_checker.go @@ -1,12 +1,12 @@ package evm import ( + cosmosevmtypes "github.com/cosmos/evm/ante/types" "math" "github.com/ethereum/go-ethereum/params" anteinterfaces "github.com/cosmos/evm/ante/interfaces" - cosmosevmtypes "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" diff --git a/ante/evm/fee_checker_test.go b/ante/evm/fee_checker_test.go index a5cbc3734..d914966f9 100644 --- a/ante/evm/fee_checker_test.go +++ b/ante/evm/fee_checker_test.go @@ -1,6 +1,7 @@ package evm_test import ( + "github.com/cosmos/evm/ante/types" "math/big" "testing" @@ -13,7 +14,6 @@ import ( "github.com/cosmos/evm/encoding" "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" evmtypes "github.com/cosmos/evm/x/vm/types" diff --git a/types/block.go b/ante/types/block.go similarity index 100% rename from types/block.go rename to ante/types/block.go diff --git a/types/dynamic_fee.go b/ante/types/dynamic_fee.go similarity index 100% rename from types/dynamic_fee.go rename to ante/types/dynamic_fee.go diff --git a/types/dynamic_fee.pb.go b/ante/types/dynamic_fee.pb.go similarity index 96% rename from types/dynamic_fee.pb.go rename to ante/types/dynamic_fee.pb.go index 29fd6621e..479792fef 100644 --- a/types/dynamic_fee.pb.go +++ b/ante/types/dynamic_fee.pb.go @@ -75,7 +75,7 @@ func init() { } var fileDescriptor_3385bb4614fa656c = []byte{ - // 253 bytes of a gzipped FileDescriptorProto + // 259 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x2d, 0xcb, 0xd5, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0xa9, 0xcc, 0x4b, 0xcc, 0xcd, 0x4c, 0x8e, 0x4f, 0x4b, 0x4d, 0xd5, 0x2b, 0x28, 0xca, 0x2f, @@ -88,10 +88,11 @@ var fileDescriptor_3385bb4614fa656c = []byte{ 0x27, 0xcf, 0x70, 0xeb, 0x9e, 0xbc, 0x34, 0xc4, 0x01, 0xc5, 0x29, 0xd9, 0x7a, 0x99, 0xf9, 0xfa, 0xb9, 0x89, 0x25, 0x19, 0x7a, 0x3e, 0xa9, 0xe9, 0x89, 0xc9, 0x95, 0x2e, 0xa9, 0xc9, 0x2b, 0x9e, 0x6f, 0xd0, 0x62, 0x0c, 0x12, 0xc8, 0x4d, 0xac, 0x08, 0x80, 0x1a, 0x11, 0x00, 0x32, 0xc1, 0xc9, - 0xf4, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, - 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xa4, 0xd3, 0x33, 0x4b, 0x32, - 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xd1, 0x03, 0x20, 0x89, 0x0d, 0xec, 0x68, 0x63, 0x40, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x06, 0x83, 0x4f, 0xe5, 0x1b, 0x01, 0x00, 0x00, + 0xea, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, + 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x14, 0xd2, 0x33, 0x4b, 0x32, + 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x91, 0x02, 0x20, 0x31, 0xaf, 0x24, 0x15, 0x12, 0x0a, + 0x49, 0x6c, 0x60, 0x97, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x2e, 0x7a, 0xae, 0x40, 0x20, + 0x01, 0x00, 0x00, } func (m *ExtensionOptionDynamicFeeTx) Marshal() (dAtA []byte, err error) { diff --git a/crypto/hd/algorithm_test.go b/crypto/hd/algorithm_test.go index 3d736975c..f4e01db92 100644 --- a/crypto/hd/algorithm_test.go +++ b/crypto/hd/algorithm_test.go @@ -8,13 +8,11 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" - cryptocodec "github.com/cosmos/evm/crypto/codec" - enccodec "github.com/cosmos/evm/encoding/codec" - cosmosevmtypes "github.com/cosmos/evm/types" - amino "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keyring" + cryptocodec "github.com/cosmos/evm/crypto/codec" + enccodec "github.com/cosmos/evm/encoding/codec" ) var TestCodec amino.Codec @@ -49,7 +47,7 @@ func TestKeyring(t *testing.T) { require.Nil(t, info) mockIn.Reset("password\npassword\n") - info, mnemonic, err := kr.NewMnemonic("foo", keyring.English, cosmosevmtypes.BIP44HDPath, keyring.DefaultBIP39Passphrase, EthSecp256k1) + info, mnemonic, err := kr.NewMnemonic("foo", keyring.English, BIP44HDPath, keyring.DefaultBIP39Passphrase, EthSecp256k1) require.NoError(t, err) require.NotEmpty(t, mnemonic) require.Equal(t, "foo", info.Name) @@ -58,7 +56,7 @@ func TestKeyring(t *testing.T) { require.NoError(t, err) require.Equal(t, string(EthSecp256k1Type), pubKey.Type()) - hdPath := cosmosevmtypes.BIP44HDPath + hdPath := BIP44HDPath bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, hdPath) require.NoError(t, err) @@ -84,7 +82,7 @@ func TestKeyring(t *testing.T) { } func TestDerivation(t *testing.T) { - bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, cosmosevmtypes.BIP44HDPath) + bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, BIP44HDPath) require.NoError(t, err) require.NotEmpty(t, bz) @@ -102,7 +100,7 @@ func TestDerivation(t *testing.T) { wallet, err := NewFromMnemonic(mnemonic) require.NoError(t, err) - path := MustParseDerivationPath(cosmosevmtypes.BIP44HDPath) + path := MustParseDerivationPath(BIP44HDPath) account, err := wallet.Derive(path, false) require.NoError(t, err) diff --git a/crypto/hd/benchmark_test.go b/crypto/hd/benchmark_test.go index 281af9df2..66a782700 100644 --- a/crypto/hd/benchmark_test.go +++ b/crypto/hd/benchmark_test.go @@ -3,8 +3,6 @@ package hd import ( "testing" - "github.com/cosmos/evm/types" - "github.com/cosmos/cosmos-sdk/crypto/keyring" ) @@ -12,14 +10,14 @@ func BenchmarkEthSecp256k1Algo_Derive(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { deriveFn := EthSecp256k1.Derive() - if _, err := deriveFn(mnemonic, keyring.DefaultBIP39Passphrase, types.BIP44HDPath); err != nil { + if _, err := deriveFn(mnemonic, keyring.DefaultBIP39Passphrase, BIP44HDPath); err != nil { b.Fatal(err) } } } func BenchmarkEthSecp256k1Algo_Generate(b *testing.B) { - bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, types.BIP44HDPath) + bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, BIP44HDPath) if err != nil { b.Fatal(err) } diff --git a/types/hdpath.go b/crypto/hd/hdpath.go similarity index 98% rename from types/hdpath.go rename to crypto/hd/hdpath.go index 7c55ddc1a..2a7dd0566 100644 --- a/types/hdpath.go +++ b/crypto/hd/hdpath.go @@ -1,4 +1,4 @@ -package types +package hd import ( ethaccounts "github.com/ethereum/go-ethereum/accounts" diff --git a/encoding/codec/codec.go b/encoding/codec/codec.go index 4f43282c9..f33a79f88 100644 --- a/encoding/codec/codec.go +++ b/encoding/codec/codec.go @@ -1,13 +1,12 @@ package codec import ( - cryptocodec "github.com/cosmos/evm/crypto/codec" - "github.com/cosmos/evm/types" - "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/std" sdk "github.com/cosmos/cosmos-sdk/types" + cryptocodec "github.com/cosmos/evm/crypto/codec" + "github.com/cosmos/evm/ethereum/eip712" ) // RegisterLegacyAminoCodec registers Interfaces from types, crypto, and SDK std. @@ -21,5 +20,5 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { func RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) { std.RegisterInterfaces(interfaceRegistry) cryptocodec.RegisterInterfaces(interfaceRegistry) - types.RegisterInterfaces(interfaceRegistry) + eip712.RegisterInterfaces(interfaceRegistry) } diff --git a/types/codec.go b/ethereum/eip712/codec.go similarity index 88% rename from types/codec.go rename to ethereum/eip712/codec.go index d41102085..f81ce1308 100644 --- a/types/codec.go +++ b/ethereum/eip712/codec.go @@ -1,10 +1,11 @@ -package types +package eip712 import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdktypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + types2 "github.com/cosmos/evm/ante/types" ) // RegisterInterfaces registers the CometBFT concrete client-related @@ -23,6 +24,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*tx.TxExtensionOptionI)(nil), &ExtensionOptionsWeb3Tx{}, - &ExtensionOptionDynamicFeeTx{}, + &types2.ExtensionOptionDynamicFeeTx{}, ) } diff --git a/ethereum/eip712/preprocess.go b/ethereum/eip712/preprocess.go index 3e18b7f58..1c2593126 100644 --- a/ethereum/eip712/preprocess.go +++ b/ethereum/eip712/preprocess.go @@ -3,8 +3,6 @@ package eip712 import ( "fmt" - "github.com/cosmos/evm/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec/address" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -55,7 +53,7 @@ func PreprocessLedgerTx(evmChainID uint64, keyType cosmoskr.KeyType, txBuilder c } // Add ExtensionOptionsWeb3Tx extension with signature var option *codectypes.Any - option, err = codectypes.NewAnyWithValue(&types.ExtensionOptionsWeb3Tx{ + option, err = codectypes.NewAnyWithValue(&ExtensionOptionsWeb3Tx{ FeePayer: feePayerAddr, TypedDataChainID: evmChainID, FeePayerSig: sigBytes, diff --git a/ethereum/eip712/preprocess_test.go b/ethereum/eip712/preprocess_test.go index c0376fda0..f8cd93f5a 100644 --- a/ethereum/eip712/preprocess_test.go +++ b/ethereum/eip712/preprocess_test.go @@ -12,7 +12,6 @@ import ( "github.com/cosmos/evm/ethereum/eip712" "github.com/cosmos/evm/testutil/constants" utiltx "github.com/cosmos/evm/testutil/tx" - "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/math" @@ -81,7 +80,7 @@ func TestLedgerPreprocessing(t *testing.T) { require.True(t, ok) require.True(t, len(hasExtOptsTx.GetExtensionOptions()) == 1) - expectedExt := types.ExtensionOptionsWeb3Tx{ + expectedExt := eip712.ExtensionOptionsWeb3Tx{ TypedDataChainID: 9001, FeePayer: feePayerAddress, FeePayerSig: tc.expectedSignatureBytes, diff --git a/types/web3.pb.go b/ethereum/eip712/web3.pb.go similarity index 82% rename from types/web3.pb.go rename to ethereum/eip712/web3.pb.go index d48e6a634..225ae6a4f 100644 --- a/types/web3.pb.go +++ b/ethereum/eip712/web3.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: cosmos/evm/types/v1/web3.proto -package types +package eip712 import ( fmt "fmt" @@ -77,26 +77,27 @@ func init() { func init() { proto.RegisterFile("cosmos/evm/types/v1/web3.proto", fileDescriptor_8a9cacdd2daddb96) } var fileDescriptor_8a9cacdd2daddb96 = []byte{ - // 300 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x2d, 0xcb, 0xd5, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, - 0x2f, 0x4f, 0x4d, 0x32, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xc8, 0xeb, 0xa5, - 0x96, 0xe5, 0xea, 0x81, 0xe5, 0xf5, 0xca, 0x0c, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xf2, - 0xfa, 0x20, 0x16, 0x44, 0xa9, 0xd2, 0x57, 0x46, 0x2e, 0x31, 0xd7, 0x8a, 0x92, 0xd4, 0xbc, 0xe2, - 0xcc, 0xfc, 0x3c, 0xff, 0x82, 0x92, 0xcc, 0xfc, 0xbc, 0xe2, 0xf0, 0xd4, 0x24, 0xe3, 0x90, 0x0a, - 0xa1, 0x44, 0x2e, 0x61, 0x90, 0xe6, 0x94, 0xf8, 0x94, 0xc4, 0x92, 0xc4, 0xf8, 0xe4, 0x8c, 0xc4, - 0xcc, 0xbc, 0xf8, 0xcc, 0x14, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x16, 0x27, 0xa3, 0x47, 0xf7, 0xe4, - 0x05, 0x42, 0x40, 0xd2, 0x2e, 0x89, 0x25, 0x89, 0xce, 0x20, 0x49, 0x4f, 0x97, 0x57, 0xf7, 0xe4, - 0xa5, 0x4a, 0xd0, 0xc4, 0x74, 0xf2, 0x73, 0x33, 0x4b, 0x52, 0x73, 0x0b, 0x4a, 0x2a, 0x83, 0x04, - 0xd0, 0xe4, 0x52, 0x84, 0x8c, 0xb9, 0x38, 0xd3, 0x52, 0x53, 0xe3, 0x0b, 0x12, 0x2b, 0x53, 0x8b, - 0x24, 0x98, 0x14, 0x18, 0x35, 0x38, 0x9d, 0xc4, 0x5e, 0xdd, 0x93, 0x17, 0x4a, 0x4b, 0x4d, 0x0d, - 0x00, 0x89, 0x21, 0x69, 0xe6, 0x80, 0x89, 0x09, 0xd9, 0x72, 0xf1, 0xc2, 0x35, 0xc5, 0x17, 0x67, - 0xa6, 0x4b, 0x30, 0x2b, 0x30, 0x6a, 0xf0, 0x38, 0x49, 0xbe, 0xba, 0x27, 0x2f, 0x0a, 0x53, 0x14, - 0x9c, 0x99, 0x8e, 0xa4, 0x97, 0x1b, 0x49, 0xd8, 0x8a, 0xa5, 0x63, 0x81, 0x3c, 0x83, 0x93, 0xe9, - 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, - 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x49, 0xa7, 0x67, 0x96, 0x64, 0x94, - 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xa3, 0x87, 0x73, 0x12, 0x1b, 0x38, 0xd4, 0x8c, 0x01, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x3e, 0x08, 0x6e, 0x8c, 0x82, 0x01, 0x00, 0x00, + // 313 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0x31, 0x4b, 0xc3, 0x40, + 0x18, 0x86, 0x73, 0x5a, 0xc4, 0x46, 0x85, 0x92, 0x6a, 0xa9, 0x1d, 0x2e, 0x45, 0x10, 0x3a, 0x48, + 0x8e, 0x36, 0x83, 0x20, 0x88, 0x10, 0xeb, 0xe0, 0xa4, 0x68, 0x41, 0x70, 0x09, 0x97, 0xe6, 0x6b, + 0x7a, 0xc3, 0xe5, 0x8e, 0xde, 0x35, 0xb6, 0xff, 0xc0, 0xd1, 0x9f, 0xe0, 0xcf, 0x71, 0xec, 0xe8, + 0x14, 0x24, 0xdd, 0xba, 0xbb, 0x4b, 0x52, 0x2a, 0xa1, 0xdb, 0xc7, 0xf3, 0x7c, 0xcf, 0xf2, 0x9a, + 0x78, 0x28, 0x14, 0x17, 0x8a, 0x40, 0xc2, 0x89, 0x9e, 0x4b, 0x50, 0x24, 0xe9, 0x92, 0x37, 0x08, + 0x5c, 0x47, 0x4e, 0x84, 0x16, 0x56, 0x7d, 0xed, 0x1d, 0x48, 0xb8, 0x53, 0x78, 0x27, 0xe9, 0xb6, + 0x8e, 0x23, 0x11, 0x89, 0xc2, 0x93, 0xfc, 0x5a, 0xbf, 0x9e, 0xfd, 0x22, 0xb3, 0x71, 0x37, 0xd3, + 0x10, 0x2b, 0x26, 0xe2, 0x07, 0xa9, 0x99, 0x88, 0xd5, 0x0b, 0x04, 0xee, 0x60, 0x66, 0x51, 0xb3, + 0x9e, 0xc7, 0xa1, 0x1f, 0x52, 0x4d, 0xfd, 0xe1, 0x98, 0xb2, 0xd8, 0x67, 0x61, 0x13, 0xb5, 0x51, + 0xa7, 0xe2, 0xf5, 0xb2, 0xd4, 0xae, 0x0d, 0x72, 0xdd, 0xa7, 0x9a, 0xde, 0xe6, 0xf2, 0xbe, 0xbf, + 0x4a, 0xed, 0x96, 0xde, 0x62, 0x17, 0x82, 0x33, 0x0d, 0x5c, 0xea, 0xf9, 0x53, 0x6d, 0xcb, 0x85, + 0x96, 0x6b, 0x56, 0x47, 0x00, 0xbe, 0xa4, 0x73, 0x98, 0x34, 0x77, 0xda, 0xa8, 0x53, 0xf5, 0x1a, + 0xab, 0xd4, 0xb6, 0x46, 0x00, 0x8f, 0x39, 0x2b, 0xc5, 0xfb, 0x1b, 0x66, 0x5d, 0x9b, 0x47, 0xff, + 0x91, 0xaf, 0x58, 0xd4, 0xdc, 0x6d, 0xa3, 0xce, 0xa1, 0x77, 0xba, 0x4a, 0xed, 0x93, 0xcd, 0xd3, + 0x33, 0x8b, 0x4a, 0xed, 0x41, 0x09, 0x5f, 0x55, 0xde, 0x3f, 0x6d, 0xc3, 0xbb, 0xf9, 0xca, 0x30, + 0x5a, 0x64, 0x18, 0xfd, 0x64, 0x18, 0x7d, 0x2c, 0xb1, 0xb1, 0x58, 0x62, 0xe3, 0x7b, 0x89, 0x8d, + 0xd7, 0xf3, 0x88, 0xe9, 0xf1, 0x34, 0x70, 0x86, 0x82, 0x93, 0xd2, 0xce, 0xa0, 0xc7, 0x30, 0x81, + 0x29, 0x27, 0xc0, 0xe4, 0x65, 0xb7, 0x17, 0xec, 0x15, 0xfb, 0xb9, 0x7f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x6f, 0x5f, 0x74, 0x4e, 0x8c, 0x01, 0x00, 0x00, } func (m *ExtensionOptionsWeb3Tx) Marshal() (dAtA []byte, err error) { diff --git a/evmd/ante/evm_antehandler_benchmark_test.go b/evmd/ante/evm_antehandler_benchmark_test.go index 5724aa8d9..289a5f6ed 100644 --- a/evmd/ante/evm_antehandler_benchmark_test.go +++ b/evmd/ante/evm_antehandler_benchmark_test.go @@ -2,6 +2,7 @@ package ante_test import ( "fmt" + cosmosevmtypes "github.com/cosmos/evm/ante/types" "math/big" "testing" @@ -14,7 +15,6 @@ import ( "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" testkeyring "github.com/cosmos/evm/testutil/keyring" - cosmosevmtypes "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/errors" diff --git a/evmd/ante/validate_handler_options_test.go b/evmd/ante/validate_handler_options_test.go index 881f14a8a..825b1f541 100644 --- a/evmd/ante/validate_handler_options_test.go +++ b/evmd/ante/validate_handler_options_test.go @@ -1,6 +1,7 @@ package ante_test import ( + "github.com/cosmos/evm/ante/types" "testing" "github.com/ethereum/go-ethereum/common" @@ -10,7 +11,6 @@ import ( ethante "github.com/cosmos/evm/ante/evm" "github.com/cosmos/evm/evmd/tests/integration" "github.com/cosmos/evm/testutil/integration/evm/network" - "github.com/cosmos/evm/types" ) //nolint:thelper // RunValidateHandlerOptionsTest is not a helper function; it's an externally called benchmark entry point diff --git a/evmd/app.go b/evmd/app.go index e47152852..4c5d31cfd 100644 --- a/evmd/app.go +++ b/evmd/app.go @@ -4,7 +4,9 @@ import ( "encoding/json" "errors" "fmt" + types2 "github.com/cosmos/evm/ante/types" precompiletypes "github.com/cosmos/evm/precompiles/types" + "github.com/cosmos/evm/utils" "io" "os" @@ -26,7 +28,6 @@ import ( "github.com/cosmos/evm/evmd/ante" evmmempool "github.com/cosmos/evm/mempool" srvflags "github.com/cosmos/evm/server/flags" - cosmosevmtypes "github.com/cosmos/evm/types" "github.com/cosmos/evm/x/erc20" erc20keeper "github.com/cosmos/evm/x/erc20/keeper" erc20types "github.com/cosmos/evm/x/erc20/types" @@ -136,7 +137,7 @@ import ( func init() { // manually update the power reduction by replacing micro (u) -> atto (a) evmos - sdk.DefaultPowerReduction = cosmosevmtypes.AttoPowerReduction + sdk.DefaultPowerReduction = utils.AttoPowerReduction defaultNodeHome = evmdconfig.MustGetDefaultNodeHome() } @@ -821,7 +822,7 @@ func (app *EVMD) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64) { Cdc: app.appCodec, AccountKeeper: app.AccountKeeper, BankKeeper: app.BankKeeper, - ExtensionOptionChecker: cosmosevmtypes.HasDynamicFeeExtensionOption, + ExtensionOptionChecker: types2.HasDynamicFeeExtensionOption, EvmKeeper: app.EVMKeeper, FeegrantKeeper: app.FeeGrantKeeper, IBCKeeper: app.IBCKeeper, @@ -884,7 +885,7 @@ func (app *EVMD) Configurator() module.Configurator { // InitChainer application update at chain initialization func (app *EVMD) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { - var genesisState cosmosevmtypes.GenesisState + var genesisState GenesisState if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) } diff --git a/evmd/cmd/evmd/config/config.go b/evmd/cmd/evmd/config/config.go index 2699ca0b6..f14476202 100644 --- a/evmd/cmd/evmd/config/config.go +++ b/evmd/cmd/evmd/config/config.go @@ -1,7 +1,7 @@ package config import ( - "github.com/cosmos/evm/types" + "github.com/cosmos/evm/crypto/hd" evmtypes "github.com/cosmos/evm/x/vm/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -67,7 +67,7 @@ func SetBech32Prefixes(config *sdk.Config) { // 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 + config.SetCoinType(hd.Bip44CoinType) + config.SetPurpose(sdk.Purpose) // Shared + config.SetFullFundraiserPath(hd.BIP44HDPath) //nolint: staticcheck } diff --git a/evmd/tests/network/network.go b/evmd/tests/network/network.go index 51fb9133f..49c53ae57 100644 --- a/evmd/tests/network/network.go +++ b/evmd/tests/network/network.go @@ -6,6 +6,8 @@ import ( "encoding/json" "errors" "fmt" + testutil2 "github.com/cosmos/evm/testutil" + "github.com/cosmos/evm/utils" "net/http" "net/url" "os" @@ -33,7 +35,6 @@ import ( "github.com/cosmos/evm/server/config" testconfig "github.com/cosmos/evm/testutil/config" testconstants "github.com/cosmos/evm/testutil/constants" - cosmosevmtypes "github.com/cosmos/evm/types" "cosmossdk.io/log" "cosmossdk.io/math" @@ -78,14 +79,14 @@ type Config struct { InterfaceRegistry codectypes.InterfaceRegistry TxConfig client.TxConfig AccountRetriever client.AccountRetriever - AppConstructor AppConstructor // the ABCI application constructor - GenesisState cosmosevmtypes.GenesisState // custom gensis state to provide - TimeoutCommit time.Duration // the consensus commitment timeout - AccountTokens math.Int // the amount of unique validator tokens (e.g. 1000node0) - StakingTokens math.Int // the amount of tokens each validator has available to stake - BondedTokens math.Int // the amount of tokens each validator stakes - NumValidators int // the total number of validators to create and bond - ChainID string // the network chain-id + AppConstructor AppConstructor // the ABCI application constructor + GenesisState testutil2.GenesisState // custom gensis state to provide + TimeoutCommit time.Duration // the consensus commitment timeout + AccountTokens math.Int // the amount of unique validator tokens (e.g. 1000node0) + StakingTokens math.Int // the amount of tokens each validator has available to stake + BondedTokens math.Int // the amount of tokens each validator stakes + NumValidators int // the total number of validators to create and bond + ChainID string // the network chain-id EVMChainID uint64 BondDenom string // the staking bond denomination MinGasPrices string // the minimum gas prices each validator will accept @@ -125,9 +126,9 @@ func DefaultConfig() Config { NumValidators: 4, BondDenom: testconstants.ExampleAttoDenom, MinGasPrices: fmt.Sprintf("0.000006%s", testconstants.ExampleAttoDenom), - AccountTokens: sdk.TokensFromConsensusPower(1000000000000000000, cosmosevmtypes.AttoPowerReduction), - StakingTokens: sdk.TokensFromConsensusPower(500000000000000000, cosmosevmtypes.AttoPowerReduction), - BondedTokens: sdk.TokensFromConsensusPower(100000000000000000, cosmosevmtypes.AttoPowerReduction), + AccountTokens: sdk.TokensFromConsensusPower(1000000000000000000, utils.AttoPowerReduction), + StakingTokens: sdk.TokensFromConsensusPower(500000000000000000, utils.AttoPowerReduction), + BondedTokens: sdk.TokensFromConsensusPower(100000000000000000, utils.AttoPowerReduction), PruningStrategy: pruningtypes.PruningOptionNothing, CleanupDir: true, SigningAlgo: string(hd.EthSecp256k1Type), diff --git a/evmd/testutil/eth_setup.go b/evmd/testutil/eth_setup.go index 64b1f8dcb..0c7f66984 100644 --- a/evmd/testutil/eth_setup.go +++ b/evmd/testutil/eth_setup.go @@ -1,12 +1,12 @@ package testutil import ( + "github.com/cosmos/evm/testutil" "time" cmtypes "github.com/cometbft/cometbft/types" "github.com/cosmos/evm" - cosmosevmtypes "github.com/cosmos/evm/types" "cosmossdk.io/math" @@ -48,7 +48,7 @@ var EthDefaultConsensusParams = &cmtypes.ConsensusParams{ // // TODO: are these different genesis functions necessary or can they all be refactored into one? // there's also other genesis state functions; some like app.DefaultGenesis() or others in test helpers only. -func NewTestGenesisState(app evm.EvmApp) cosmosevmtypes.GenesisState { +func NewTestGenesisState(app evm.EvmApp) testutil.GenesisState { privVal := mock.NewPV() pubKey, err := privVal.GetPubKey() if err != nil { @@ -70,10 +70,10 @@ func NewTestGenesisState(app evm.EvmApp) cosmosevmtypes.GenesisState { return genesisStateWithValSet(app.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) } -func genesisStateWithValSet(codec codec.Codec, genesisState cosmosevmtypes.GenesisState, +func genesisStateWithValSet(codec codec.Codec, genesisState testutil.GenesisState, valSet *cmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance, -) cosmosevmtypes.GenesisState { +) testutil.GenesisState { // set genesis accounts authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) genesisState[authtypes.ModuleName] = codec.MustMarshalJSON(authGenesis) diff --git a/indexer/kv_indexer.go b/indexer/kv_indexer.go index ae8941acf..ff6e3f239 100644 --- a/indexer/kv_indexer.go +++ b/indexer/kv_indexer.go @@ -2,6 +2,7 @@ package indexer import ( "fmt" + "github.com/cosmos/evm/server/types" "github.com/ethereum/go-ethereum/common" @@ -10,7 +11,6 @@ import ( dbm "github.com/cosmos/cosmos-db" rpctypes "github.com/cosmos/evm/rpc/types" - cosmosevmtypes "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" @@ -30,7 +30,7 @@ const ( TxIndexKeyLength = 1 + 8 + 8 ) -var _ cosmosevmtypes.EVMTxIndexer = &KVIndexer{} +var _ types.EVMTxIndexer = &KVIndexer{} // KVIndexer implements a eth tx indexer on a KV db. type KVIndexer struct { @@ -84,7 +84,7 @@ func (kv *KVIndexer) IndexBlock(block *cmttypes.Block, txResults []*abci.ExecTxR ethMsg := msg.(*evmtypes.MsgEthereumTx) txHash := ethMsg.Hash() - txResult := cosmosevmtypes.TxResult{ + txResult := types.TxResult{ Height: height, TxIndex: uint32(txIndex), //#nosec G115 -- int overflow is not a concern here MsgIndex: uint32(msgIndex), //#nosec G115 -- int overflow is not a concern here @@ -134,7 +134,7 @@ func (kv *KVIndexer) FirstIndexedBlock() (int64, error) { } // GetByTxHash finds eth tx by eth tx hash -func (kv *KVIndexer) GetByTxHash(hash common.Hash) (*cosmosevmtypes.TxResult, error) { +func (kv *KVIndexer) GetByTxHash(hash common.Hash) (*types.TxResult, error) { bz, err := kv.db.Get(TxHashKey(hash)) if err != nil { return nil, errorsmod.Wrapf(err, "GetByTxHash %s", hash.Hex()) @@ -142,7 +142,7 @@ func (kv *KVIndexer) GetByTxHash(hash common.Hash) (*cosmosevmtypes.TxResult, er if len(bz) == 0 { return nil, fmt.Errorf("tx not found, hash: %s", hash.Hex()) } - var txKey cosmosevmtypes.TxResult + var txKey types.TxResult if err := kv.clientCtx.Codec.Unmarshal(bz, &txKey); err != nil { return nil, errorsmod.Wrapf(err, "GetByTxHash %s", hash.Hex()) } @@ -150,7 +150,7 @@ func (kv *KVIndexer) GetByTxHash(hash common.Hash) (*cosmosevmtypes.TxResult, er } // GetByBlockAndIndex finds eth tx by block number and eth tx index -func (kv *KVIndexer) GetByBlockAndIndex(blockNumber int64, txIndex int32) (*cosmosevmtypes.TxResult, error) { +func (kv *KVIndexer) GetByBlockAndIndex(blockNumber int64, txIndex int32) (*types.TxResult, error) { bz, err := kv.db.Get(TxIndexKey(blockNumber, txIndex)) if err != nil { return nil, errorsmod.Wrapf(err, "GetByBlockAndIndex %d %d", blockNumber, txIndex) @@ -213,7 +213,7 @@ func isEthTx(tx sdk.Tx) bool { } // saveTxResult index the txResult into the kv db batch -func saveTxResult(codec codec.Codec, batch dbm.Batch, txHash common.Hash, txResult *cosmosevmtypes.TxResult) error { +func saveTxResult(codec codec.Codec, batch dbm.Batch, txHash common.Hash, txResult *types.TxResult) error { bz := codec.MustMarshal(txResult) if err := batch.Set(TxHashKey(txHash), bz); err != nil { return errorsmod.Wrap(err, "set tx-hash key") diff --git a/proto/cosmos/evm/types/v1/dynamic_fee.proto b/proto/cosmos/evm/types/v1/dynamic_fee.proto index bca7e6498..e4ce481c2 100644 --- a/proto/cosmos/evm/types/v1/dynamic_fee.proto +++ b/proto/cosmos/evm/types/v1/dynamic_fee.proto @@ -5,7 +5,7 @@ package cosmos.evm.types.v1; import "amino/amino.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/cosmos/evm/types"; +option go_package = "github.com/cosmos/evm/ante/types"; // ExtensionOptionDynamicFeeTx is an extension option that specifies the // maxPrioPrice for cosmos tx diff --git a/proto/cosmos/evm/types/v1/indexer.proto b/proto/cosmos/evm/types/v1/indexer.proto index aaee57961..00a657dcf 100644 --- a/proto/cosmos/evm/types/v1/indexer.proto +++ b/proto/cosmos/evm/types/v1/indexer.proto @@ -4,7 +4,7 @@ package cosmos.evm.types.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/cosmos/evm/types"; +option go_package = "github.com/cosmos/evm/server/types"; // TxResult is the value stored in eth tx indexer message TxResult { diff --git a/proto/cosmos/evm/types/v1/web3.proto b/proto/cosmos/evm/types/v1/web3.proto index b52851dca..98fd97dd8 100644 --- a/proto/cosmos/evm/types/v1/web3.proto +++ b/proto/cosmos/evm/types/v1/web3.proto @@ -4,7 +4,7 @@ package cosmos.evm.types.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/cosmos/evm/types"; +option go_package = "github.com/cosmos/evm/ethereum/eip712"; // ExtensionOptionsWeb3Tx is an extension option that specifies the typed chain // id, the fee payer as well as its signature data. diff --git a/rpc/apis.go b/rpc/apis.go index e969f86e5..f17908000 100644 --- a/rpc/apis.go +++ b/rpc/apis.go @@ -2,9 +2,12 @@ package rpc import ( "fmt" + server2 "github.com/cosmos/evm/server/types" "github.com/ethereum/go-ethereum/rpc" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/server" evmmempool "github.com/cosmos/evm/mempool" "github.com/cosmos/evm/rpc/backend" "github.com/cosmos/evm/rpc/namespaces/ethereum/debug" @@ -16,10 +19,6 @@ import ( "github.com/cosmos/evm/rpc/namespaces/ethereum/txpool" "github.com/cosmos/evm/rpc/namespaces/ethereum/web3" "github.com/cosmos/evm/rpc/stream" - "github.com/cosmos/evm/types" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/server" ) // RPC namespaces and API version @@ -47,7 +46,7 @@ type APICreator = func( clientCtx client.Context, stream *stream.RPCStream, allowUnprotectedTxs bool, - indexer types.EVMTxIndexer, + indexer server2.EVMTxIndexer, mempool *evmmempool.ExperimentalEVMMempool, ) []rpc.API @@ -60,7 +59,7 @@ func init() { clientCtx client.Context, stream *stream.RPCStream, allowUnprotectedTxs bool, - indexer types.EVMTxIndexer, + indexer server2.EVMTxIndexer, mempool *evmmempool.ExperimentalEVMMempool, ) []rpc.API { evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer, mempool) @@ -79,7 +78,7 @@ func init() { }, } }, - Web3Namespace: func(*server.Context, client.Context, *stream.RPCStream, bool, types.EVMTxIndexer, *evmmempool.ExperimentalEVMMempool) []rpc.API { + Web3Namespace: func(*server.Context, client.Context, *stream.RPCStream, bool, server2.EVMTxIndexer, *evmmempool.ExperimentalEVMMempool) []rpc.API { return []rpc.API{ { Namespace: Web3Namespace, @@ -89,7 +88,7 @@ func init() { }, } }, - NetNamespace: func(ctx *server.Context, clientCtx client.Context, _ *stream.RPCStream, _ bool, _ types.EVMTxIndexer, _ *evmmempool.ExperimentalEVMMempool) []rpc.API { + NetNamespace: func(ctx *server.Context, clientCtx client.Context, _ *stream.RPCStream, _ bool, _ server2.EVMTxIndexer, _ *evmmempool.ExperimentalEVMMempool) []rpc.API { return []rpc.API{ { Namespace: NetNamespace, @@ -103,7 +102,7 @@ func init() { clientCtx client.Context, _ *stream.RPCStream, allowUnprotectedTxs bool, - indexer types.EVMTxIndexer, + indexer server2.EVMTxIndexer, mempool *evmmempool.ExperimentalEVMMempool, ) []rpc.API { evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer, mempool) @@ -120,7 +119,7 @@ func init() { clientCtx client.Context, _ *stream.RPCStream, allowUnprotectedTxs bool, - indexer types.EVMTxIndexer, + indexer server2.EVMTxIndexer, mempool *evmmempool.ExperimentalEVMMempool, ) []rpc.API { evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer, mempool) @@ -137,7 +136,7 @@ func init() { clientCtx client.Context, _ *stream.RPCStream, allowUnprotectedTxs bool, - indexer types.EVMTxIndexer, + indexer server2.EVMTxIndexer, mempool *evmmempool.ExperimentalEVMMempool, ) []rpc.API { evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer, mempool) @@ -154,7 +153,7 @@ func init() { clientCtx client.Context, _ *stream.RPCStream, allowUnprotectedTxs bool, - indexer types.EVMTxIndexer, + indexer server2.EVMTxIndexer, mempool *evmmempool.ExperimentalEVMMempool, ) []rpc.API { evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer, mempool) @@ -175,7 +174,7 @@ func GetRPCAPIs(ctx *server.Context, clientCtx client.Context, stream *stream.RPCStream, allowUnprotectedTxs bool, - indexer types.EVMTxIndexer, + indexer server2.EVMTxIndexer, selectedAPIs []string, mempool *evmmempool.ExperimentalEVMMempool, ) []rpc.API { diff --git a/rpc/backend/backend.go b/rpc/backend/backend.go index de169ff75..78a0f1dd8 100644 --- a/rpc/backend/backend.go +++ b/rpc/backend/backend.go @@ -3,6 +3,7 @@ package backend import ( "context" "fmt" + "github.com/cosmos/evm/server/types" "math/big" "time" @@ -20,7 +21,6 @@ import ( evmmempool "github.com/cosmos/evm/mempool" rpctypes "github.com/cosmos/evm/rpc/types" "github.com/cosmos/evm/server/config" - cosmosevmtypes "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/log" @@ -100,8 +100,8 @@ type EVMBackend interface { // Tx Info GetTransactionByHash(txHash common.Hash) (*rpctypes.RPCTransaction, error) - GetTxByEthHash(txHash common.Hash) (*cosmosevmtypes.TxResult, error) - GetTxByTxIndex(height int64, txIndex uint) (*cosmosevmtypes.TxResult, error) + GetTxByEthHash(txHash common.Hash) (*types.TxResult, error) + GetTxByTxIndex(height int64, txIndex uint) (*types.TxResult, error) GetTransactionByBlockAndIndex(block *tmrpctypes.ResultBlock, idx hexutil.Uint) (*rpctypes.RPCTransaction, error) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error) GetTransactionLogs(hash common.Hash) ([]*ethtypes.Log, error) @@ -166,7 +166,7 @@ type Backend struct { EvmChainID *big.Int Cfg config.Config AllowUnprotectedTxs bool - Indexer cosmosevmtypes.EVMTxIndexer + Indexer types.EVMTxIndexer ProcessBlocker ProcessBlocker Mempool *evmmempool.ExperimentalEVMMempool } @@ -181,7 +181,7 @@ func NewBackend( logger log.Logger, clientCtx client.Context, allowUnprotectedTxs bool, - indexer cosmosevmtypes.EVMTxIndexer, + indexer types.EVMTxIndexer, mempool *evmmempool.ExperimentalEVMMempool, ) *Backend { appConf, err := config.GetConfig(ctx.Viper) diff --git a/rpc/backend/blocks.go b/rpc/backend/blocks.go index 737fdc3f5..ce4f10e7d 100644 --- a/rpc/backend/blocks.go +++ b/rpc/backend/blocks.go @@ -2,6 +2,8 @@ package backend import ( "fmt" + "github.com/cosmos/evm/server/types" + cosmosevmtypes "github.com/cosmos/evm/utils" "math/big" "strconv" @@ -17,7 +19,6 @@ import ( cmtrpctypes "github.com/cometbft/cometbft/rpc/core/types" rpctypes "github.com/cosmos/evm/rpc/types" - cosmosevmtypes "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -581,7 +582,7 @@ func (b *Backend) GetBlockReceipts( func (b *Backend) formatTxReceipt( ethMsg *evmtypes.MsgEthereumTx, - txResult *cosmosevmtypes.TxResult, + txResult *types.TxResult, blockRes *cmtrpctypes.ResultBlockResults, blockHeaderHash string, ) (map[string]interface{}, error) { diff --git a/rpc/backend/tx_info.go b/rpc/backend/tx_info.go index e23a93086..98dd91637 100644 --- a/rpc/backend/tx_info.go +++ b/rpc/backend/tx_info.go @@ -2,6 +2,8 @@ package backend import ( "fmt" + types2 "github.com/cosmos/evm/server/types" + "github.com/cosmos/evm/utils" "math" "math/big" "time" @@ -19,7 +21,6 @@ import ( "github.com/cosmos/evm/mempool/txpool" rpctypes "github.com/cosmos/evm/rpc/types" - "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" @@ -131,7 +132,7 @@ func (b *Backend) GetTransactionByHashPending(txHash common.Hash) (*rpctypes.RPC } // GetGasUsed returns gasUsed from transaction -func (b *Backend) GetGasUsed(res *types.TxResult, price *big.Int, gas uint64) uint64 { +func (b *Backend) GetGasUsed(res *types2.TxResult, price *big.Int, gas uint64) uint64 { return res.GasUsed } @@ -144,7 +145,7 @@ func (b *Backend) GetTransactionReceipt(hash common.Hash) (map[string]interface{ maxRetries := 10 baseDelay := 50 * time.Millisecond - var res *types.TxResult + var res *types2.TxResult var err error for attempt := 0; attempt <= maxRetries; attempt++ { @@ -216,7 +217,7 @@ func (b *Backend) GetTransactionLogs(hash common.Hash) ([]*ethtypes.Log, error) b.Logger.Debug("block result not found", "number", res.Height, "error", err.Error()) return nil, nil } - height, err := types.SafeUint64(resBlockResult.Height) + height, err := utils.SafeUint64(resBlockResult.Height) if err != nil { return nil, err } @@ -277,7 +278,7 @@ func (b *Backend) GetTransactionByBlockNumberAndIndex(blockNum rpctypes.BlockNum // GetTxByEthHash uses `/tx_query` to find transaction by ethereum tx hash // TODO: Don't need to convert once hashing is fixed on CometBFT // https://github.com/cometbft/cometbft/issues/6539 -func (b *Backend) GetTxByEthHash(hash common.Hash) (*types.TxResult, error) { +func (b *Backend) GetTxByEthHash(hash common.Hash) (*types2.TxResult, error) { if b.Indexer != nil { return b.Indexer.GetByTxHash(hash) } @@ -294,7 +295,7 @@ func (b *Backend) GetTxByEthHash(hash common.Hash) (*types.TxResult, error) { } // GetTxByTxIndex uses `/tx_query` to find transaction by tx index of valid ethereum txs -func (b *Backend) GetTxByTxIndex(height int64, index uint) (*types.TxResult, error) { +func (b *Backend) GetTxByTxIndex(height int64, index uint) (*types2.TxResult, error) { int32Index := int32(index) //#nosec G115 -- checked for int overflow already if b.Indexer != nil { return b.Indexer.GetByBlockAndIndex(height, int32Index) @@ -315,7 +316,7 @@ func (b *Backend) GetTxByTxIndex(height int64, index uint) (*types.TxResult, err } // QueryCometTxIndexer query tx in CometBFT tx indexer -func (b *Backend) QueryCometTxIndexer(query string, txGetter func(*rpctypes.ParsedTxs) *rpctypes.ParsedTx) (*types.TxResult, error) { +func (b *Backend) QueryCometTxIndexer(query string, txGetter func(*rpctypes.ParsedTxs) *rpctypes.ParsedTx) (*types2.TxResult, error) { resTxs, err := b.ClientCtx.Client.TxSearch(b.Ctx, query, false, nil, nil, "") if err != nil { return nil, err diff --git a/rpc/backend/utils.go b/rpc/backend/utils.go index 6fbfd3922..d236e4cd0 100644 --- a/rpc/backend/utils.go +++ b/rpc/backend/utils.go @@ -18,7 +18,6 @@ import ( cmtrpctypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/cosmos/evm/rpc/types" - cosmosevmtypes "github.com/cosmos/evm/types" "github.com/cosmos/evm/utils" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -171,7 +170,7 @@ func (b *Backend) ProcessBlock( if err != nil { return err } - nextBaseFee, err := utils.CalcBaseFee(cfg, &header, params.Params) + nextBaseFee, err := types.CalcBaseFee(cfg, &header, params.Params) if err != nil { return err } @@ -260,7 +259,7 @@ func ShouldIgnoreGasUsed(res *abci.ExecTxResult) bool { // GetLogsFromBlockResults returns the list of event logs from the CometBFT block result response func GetLogsFromBlockResults(blockRes *cmtrpctypes.ResultBlockResults) ([][]*ethtypes.Log, error) { - height, err := cosmosevmtypes.SafeUint64(blockRes.Height) + height, err := utils.SafeUint64(blockRes.Height) if err != nil { return nil, err } diff --git a/rpc/namespaces/ethereum/eth/api.go b/rpc/namespaces/ethereum/eth/api.go index 35ea3aa24..f1a14954f 100644 --- a/rpc/namespaces/ethereum/eth/api.go +++ b/rpc/namespaces/ethereum/eth/api.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/evm/rpc/backend" rpctypes "github.com/cosmos/evm/rpc/types" - "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/log" @@ -297,7 +296,7 @@ func (e *PublicAPI) Call(args evmtypes.TransactionArgs, // ProtocolVersion returns the supported Ethereum protocol version. func (e *PublicAPI) ProtocolVersion() hexutil.Uint { e.logger.Debug("eth_protocolVersion") - return hexutil.Uint(types.ProtocolVersion) + return hexutil.Uint(rpctypes.ProtocolVersion) } // GasPrice returns the current gas price based on Cosmos EVM's gas price oracle. diff --git a/rpc/namespaces/ethereum/personal/api.go b/rpc/namespaces/ethereum/personal/api.go index 7fc22c350..63a388a9f 100644 --- a/rpc/namespaces/ethereum/personal/api.go +++ b/rpc/namespaces/ethereum/personal/api.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/evm/crypto/hd" "github.com/cosmos/evm/rpc/backend" - "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/log" @@ -26,7 +25,7 @@ import ( type PrivateAccountAPI struct { backend backend.EVMBackend logger log.Logger - hdPathIter types.HDPathIterator + hdPathIter hd.HDPathIterator } // NewAPI creates an instance of the public Personal Eth API. @@ -37,7 +36,7 @@ func NewAPI( cfg := sdk.GetConfig() basePath := cfg.GetFullBIP44Path() - iterator, err := types.NewHDPathIterator(basePath, true) + iterator, err := hd.NewHDPathIterator(basePath, true) if err != nil { panic(err) } diff --git a/rpc/stream/rpc.go b/rpc/stream/rpc.go index 621657927..3312a81d8 100644 --- a/rpc/stream/rpc.go +++ b/rpc/stream/rpc.go @@ -3,6 +3,7 @@ package stream import ( "context" "fmt" + cosmosevmtypes "github.com/cosmos/evm/utils" "sync" "github.com/ethereum/go-ethereum/common" @@ -14,7 +15,6 @@ import ( cmttypes "github.com/cometbft/cometbft/types" "github.com/cosmos/evm/rpc/types" - cosmosevmtypes "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/log" diff --git a/rpc/types/block.go b/rpc/types/block.go index 55c698569..bcc7eb872 100644 --- a/rpc/types/block.go +++ b/rpc/types/block.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/cosmos/evm/utils" "math" "math/big" "strings" @@ -14,8 +15,6 @@ import ( "github.com/spf13/cast" "google.golang.org/grpc/metadata" - "github.com/cosmos/evm/types" - grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" ) @@ -182,7 +181,7 @@ func (bnh *BlockNumberOrHash) decodeFromString(input string) error { return err } - bnInt, err := types.SafeInt64(blockNumber) + bnInt, err := utils.SafeInt64(blockNumber) if err != nil { return err } diff --git a/rpc/types/events.go b/rpc/types/events.go index 749a50bd3..0e35394f1 100644 --- a/rpc/types/events.go +++ b/rpc/types/events.go @@ -2,6 +2,7 @@ package types import ( "fmt" + "github.com/cosmos/evm/server/types" "strconv" "github.com/ethereum/go-ethereum/common" @@ -9,7 +10,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" cmtrpctypes "github.com/cometbft/cometbft/rpc/core/types" - "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/types/protocol.go b/rpc/types/protocol.go similarity index 100% rename from types/protocol.go rename to rpc/types/protocol.go diff --git a/rpc/types/utils.go b/rpc/types/utils.go index 6a600881c..7e1f94653 100644 --- a/rpc/types/utils.go +++ b/rpc/types/utils.go @@ -3,6 +3,8 @@ package types import ( "context" "fmt" + types2 "github.com/cosmos/evm/x/feemarket/types" + "github.com/pkg/errors" "math/big" "strings" @@ -334,3 +336,22 @@ func TxStateDBCommitError(res *abci.ExecTxResult) bool { func TxSucessOrExpectedFailure(res *abci.ExecTxResult) bool { return res.Code == 0 || TxExceedBlockGasLimit(res) || TxStateDBCommitError(res) } + +// CalcBaseFee calculates the basefee of the header. +func CalcBaseFee(config *params.ChainConfig, parent *ethtypes.Header, p types2.Params) (*big.Int, error) { + // If the current block is the first EIP-1559 block, return the InitialBaseFee. + if !config.IsLondon(parent.Number) { + return new(big.Int).SetUint64(params.InitialBaseFee), nil + } + if p.ElasticityMultiplier == 0 { + return nil, errors.New("ElasticityMultiplier cannot be 0 as it's checked in the params validation") + } + parentGasTarget := parent.GasLimit / uint64(p.ElasticityMultiplier) + + factor := evmtypes.GetEVMCoinDecimals().ConversionFactor() + minGasPrice := p.MinGasPrice.Mul(sdkmath.LegacyNewDecFromInt(factor)) + return types2.CalcGasBaseFee( + parent.GasUsed, parentGasTarget, uint64(p.BaseFeeChangeDenominator), + sdkmath.LegacyNewDecFromBigInt(parent.BaseFee), sdkmath.LegacyOneDec(), minGasPrice, + ).TruncateInt().BigInt(), nil +} diff --git a/server/indexer_service.go b/server/indexer_service.go index 6cfad6f56..6240eede0 100644 --- a/server/indexer_service.go +++ b/server/indexer_service.go @@ -2,14 +2,13 @@ package server import ( "context" + types2 "github.com/cosmos/evm/server/types" "time" "github.com/cometbft/cometbft/libs/service" rpcclient "github.com/cometbft/cometbft/rpc/client" coretypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/cometbft/cometbft/types" - - cosmosevmtypes "github.com/cosmos/evm/types" ) const ( @@ -22,13 +21,13 @@ const ( type EVMIndexerService struct { service.BaseService - txIdxr cosmosevmtypes.EVMTxIndexer + txIdxr types2.EVMTxIndexer client rpcclient.Client } // NewEVMIndexerService returns a new service instance. func NewEVMIndexerService( - txIdxr cosmosevmtypes.EVMTxIndexer, + txIdxr types2.EVMTxIndexer, client rpcclient.Client, ) *EVMIndexerService { is := &EVMIndexerService{txIdxr: txIdxr, client: client} diff --git a/server/json_rpc.go b/server/json_rpc.go index 802e986e0..9b71bc799 100644 --- a/server/json_rpc.go +++ b/server/json_rpc.go @@ -3,6 +3,7 @@ package server import ( "context" "fmt" + "github.com/cosmos/evm/server/types" "log/slog" "net/http" "time" @@ -15,14 +16,12 @@ import ( rpcclient "github.com/cometbft/cometbft/rpc/client" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/server" evmmempool "github.com/cosmos/evm/mempool" "github.com/cosmos/evm/rpc" "github.com/cosmos/evm/rpc/stream" serverconfig "github.com/cosmos/evm/server/config" - cosmosevmtypes "github.com/cosmos/evm/types" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/server" ) const shutdownTimeout = 200 * time.Millisecond @@ -38,7 +37,7 @@ func StartJSONRPC( clientCtx client.Context, g *errgroup.Group, config *serverconfig.Config, - indexer cosmosevmtypes.EVMTxIndexer, + indexer types.EVMTxIndexer, app AppWithPendingTxStream, mempool *evmmempool.ExperimentalEVMMempool, ) (*http.Server, error) { diff --git a/server/start.go b/server/start.go index 1a08fcb0d..3298522c6 100644 --- a/server/start.go +++ b/server/start.go @@ -3,6 +3,7 @@ package server import ( "context" "fmt" + types2 "github.com/cosmos/evm/server/types" "io" "net" "os" @@ -26,6 +27,9 @@ import ( "github.com/cometbft/cometbft/rpc/client/local" cmttypes "github.com/cometbft/cometbft/types" + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" + pruningtypes "cosmossdk.io/store/pruning/types" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/evm/indexer" evmmempool "github.com/cosmos/evm/mempool" @@ -33,11 +37,6 @@ import ( ethdebug "github.com/cosmos/evm/rpc/namespaces/ethereum/debug" cosmosevmserverconfig "github.com/cosmos/evm/server/config" srvflags "github.com/cosmos/evm/server/flags" - cosmosevmtypes "github.com/cosmos/evm/types" - - errorsmod "cosmossdk.io/errors" - "cosmossdk.io/log" - pruningtypes "cosmossdk.io/store/pruning/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -467,7 +466,7 @@ func startInProcess(svrCtx *server.Context, clientCtx client.Context, opts Start ethmetricsexp.Setup(config.JSONRPC.MetricsAddress) } - var idxer cosmosevmtypes.EVMTxIndexer + var idxer types2.EVMTxIndexer if config.JSONRPC.EnableIndexer { idxDB, err := OpenIndexerDB(home, server.GetAppDBBackend(svrCtx.Viper)) if err != nil { diff --git a/types/indexer.go b/server/types/indexer.go similarity index 100% rename from types/indexer.go rename to server/types/indexer.go diff --git a/types/indexer.pb.go b/server/types/indexer.pb.go similarity index 85% rename from types/indexer.pb.go rename to server/types/indexer.pb.go index 93ccbc8a5..3a36a31c6 100644 --- a/types/indexer.pb.go +++ b/server/types/indexer.pb.go @@ -84,26 +84,26 @@ func init() { func init() { proto.RegisterFile("cosmos/evm/types/v1/indexer.proto", fileDescriptor_b69626dfe9e578b6) } var fileDescriptor_b69626dfe9e578b6 = []byte{ - // 295 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0x31, 0x4b, 0xc3, 0x40, - 0x18, 0x86, 0x73, 0xb6, 0x4d, 0xe3, 0xa1, 0x83, 0xa9, 0x94, 0x68, 0xe1, 0x3c, 0x9d, 0x32, 0xdd, - 0x51, 0xc4, 0xc5, 0xd1, 0x45, 0x5c, 0x8f, 0xba, 0xb8, 0x84, 0xb4, 0xf9, 0xbc, 0x04, 0x7a, 0x5e, - 0xe9, 0x5d, 0x42, 0xfc, 0x07, 0x8e, 0xfe, 0x04, 0x7f, 0x8e, 0x63, 0x47, 0x47, 0x69, 0xf1, 0x7f, - 0x48, 0x2e, 0xa1, 0x82, 0xdb, 0xf7, 0xf2, 0x3c, 0x1f, 0x2f, 0xbc, 0xf8, 0x72, 0xa1, 0x8d, 0xd2, - 0x86, 0x43, 0xa5, 0xb8, 0x7d, 0x5d, 0x81, 0xe1, 0xd5, 0x94, 0x17, 0x2f, 0x19, 0xd4, 0xb0, 0x66, - 0xab, 0xb5, 0xb6, 0x3a, 0x1c, 0xb5, 0x0a, 0x83, 0x4a, 0x31, 0xa7, 0xb0, 0x6a, 0x7a, 0x7e, 0x2a, - 0xb5, 0xd4, 0x8e, 0xf3, 0xe6, 0x6a, 0xd5, 0xab, 0x1f, 0x84, 0x83, 0x59, 0x2d, 0xc0, 0x94, 0x4b, - 0x1b, 0x8e, 0xb1, 0x9f, 0x43, 0x21, 0x73, 0x1b, 0x21, 0x8a, 0xe2, 0x9e, 0xe8, 0x52, 0x78, 0x86, - 0x03, 0x5b, 0x27, 0xae, 0x23, 0x3a, 0xa0, 0x28, 0x3e, 0x16, 0x43, 0x5b, 0x3f, 0x34, 0x31, 0x9c, - 0xe0, 0x43, 0x65, 0x64, 0xc7, 0x7a, 0x8e, 0x05, 0xca, 0xc8, 0x16, 0x52, 0x7c, 0x04, 0x36, 0x4f, - 0xf6, 0xbf, 0x7d, 0x8a, 0xe2, 0x81, 0xc0, 0x60, 0xf3, 0x59, 0xf7, 0x3e, 0xc6, 0xfe, 0x73, 0x5a, - 0x2c, 0x21, 0x8b, 0x06, 0x14, 0xc5, 0x81, 0xe8, 0x52, 0xd3, 0x28, 0x53, 0x93, 0x94, 0x06, 0xb2, - 0xc8, 0xa7, 0x28, 0xee, 0x8b, 0xa1, 0x4c, 0xcd, 0xa3, 0x81, 0x2c, 0x64, 0x78, 0xb4, 0x28, 0x55, - 0xb9, 0x4c, 0x6d, 0x51, 0x41, 0xb2, 0xb7, 0x86, 0xce, 0x3a, 0xf9, 0x43, 0xf7, 0xad, 0x7f, 0xdb, - 0x7f, 0xfb, 0xb8, 0xf0, 0xee, 0x6e, 0x3e, 0xb7, 0x04, 0x6d, 0xb6, 0x04, 0x7d, 0x6f, 0x09, 0x7a, - 0xdf, 0x11, 0x6f, 0xb3, 0x23, 0xde, 0xd7, 0x8e, 0x78, 0x4f, 0x13, 0x59, 0xd8, 0xbc, 0x9c, 0xb3, - 0x85, 0x56, 0xfc, 0xff, 0xb4, 0x73, 0xdf, 0xad, 0x74, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x05, - 0x03, 0xd2, 0x18, 0x75, 0x01, 0x00, 0x00, + // 301 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xb1, 0x4e, 0xc3, 0x30, + 0x14, 0x45, 0x63, 0xda, 0xa6, 0xc1, 0x82, 0x81, 0x14, 0x55, 0x01, 0xa4, 0x60, 0x3a, 0x65, 0xb2, + 0x55, 0xb1, 0x21, 0x26, 0x16, 0xc4, 0x6a, 0x95, 0x85, 0x25, 0x4a, 0x9b, 0x87, 0x13, 0xa9, 0xc6, + 0x55, 0xec, 0x58, 0xe1, 0x0f, 0x18, 0xf9, 0x04, 0x3e, 0x87, 0xb1, 0x23, 0x23, 0x6a, 0xc5, 0x7f, + 0xa0, 0x3a, 0x51, 0x61, 0x7b, 0x57, 0xe7, 0x3c, 0x5d, 0xe9, 0xe2, 0xab, 0x85, 0xd2, 0x52, 0x69, + 0x06, 0x56, 0x32, 0xf3, 0xba, 0x02, 0xcd, 0xec, 0x94, 0x95, 0x2f, 0x39, 0x34, 0x50, 0xd1, 0x55, + 0xa5, 0x8c, 0x0a, 0x47, 0xad, 0x42, 0xc1, 0x4a, 0xea, 0x14, 0x6a, 0xa7, 0xe7, 0xa7, 0x42, 0x09, + 0xe5, 0x38, 0xdb, 0x5d, 0xad, 0x3a, 0xf9, 0x41, 0x38, 0x98, 0x35, 0x1c, 0x74, 0xbd, 0x34, 0xe1, + 0x18, 0xfb, 0x05, 0x94, 0xa2, 0x30, 0x11, 0x22, 0x28, 0xe9, 0xf1, 0x2e, 0x85, 0x67, 0x38, 0x30, + 0x4d, 0xea, 0x3a, 0xa2, 0x03, 0x82, 0x92, 0x63, 0x3e, 0x34, 0xcd, 0xc3, 0x2e, 0x86, 0x17, 0xf8, + 0x50, 0x6a, 0xd1, 0xb1, 0x9e, 0x63, 0x81, 0xd4, 0xa2, 0x85, 0x04, 0x1f, 0x81, 0x29, 0xd2, 0xfd, + 0x6f, 0x9f, 0xa0, 0x64, 0xc0, 0x31, 0x98, 0x62, 0xd6, 0xbd, 0x8f, 0xb1, 0xff, 0x9c, 0x95, 0x4b, + 0xc8, 0xa3, 0x01, 0x41, 0x49, 0xc0, 0xbb, 0xb4, 0x6b, 0x14, 0x99, 0x4e, 0x6b, 0x0d, 0x79, 0xe4, + 0x13, 0x94, 0xf4, 0xf9, 0x50, 0x64, 0xfa, 0x51, 0x43, 0x1e, 0x52, 0x3c, 0x5a, 0xd4, 0xb2, 0x5e, + 0x66, 0xa6, 0xb4, 0x90, 0xee, 0xad, 0xa1, 0xb3, 0x4e, 0xfe, 0xd0, 0x7d, 0xeb, 0xdf, 0xf4, 0xdf, + 0x3e, 0x2e, 0xbd, 0xbb, 0xdb, 0xcf, 0x4d, 0x8c, 0xd6, 0x9b, 0x18, 0x7d, 0x6f, 0x62, 0xf4, 0xbe, + 0x8d, 0xbd, 0xf5, 0x36, 0xf6, 0xbe, 0xb6, 0xb1, 0xf7, 0x34, 0x11, 0xa5, 0x29, 0xea, 0x39, 0x5d, + 0x28, 0xc9, 0xfe, 0x4d, 0xab, 0xa1, 0xb2, 0x50, 0xb5, 0x0b, 0xcf, 0x7d, 0x37, 0xd6, 0xf5, 0x6f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xb8, 0x15, 0x69, 0x03, 0x7c, 0x01, 0x00, 0x00, } func (m *TxResult) Marshal() (dAtA []byte, err error) { diff --git a/tests/integration/ante/test_evm_fee_market.go b/tests/integration/ante/test_evm_fee_market.go index 5008f0c9d..75568ef0d 100644 --- a/tests/integration/ante/test_evm_fee_market.go +++ b/tests/integration/ante/test_evm_fee_market.go @@ -1,6 +1,7 @@ package ante import ( + "github.com/cosmos/evm/ante/types" "math/big" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -10,7 +11,6 @@ import ( "github.com/cosmos/evm/testutil" testconstants "github.com/cosmos/evm/testutil/constants" utiltx "github.com/cosmos/evm/testutil/tx" - "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" sdkmath "cosmossdk.io/math" diff --git a/tests/integration/rpc/backend/test_tx_info.go b/tests/integration/rpc/backend/test_tx_info.go index 3c74471aa..376ad1ef8 100644 --- a/tests/integration/rpc/backend/test_tx_info.go +++ b/tests/integration/rpc/backend/test_tx_info.go @@ -3,6 +3,7 @@ package backend import ( "errors" "fmt" + cosmosevmtypes "github.com/cosmos/evm/server/types" "math/big" "github.com/ethereum/go-ethereum/common" @@ -18,7 +19,6 @@ import ( "github.com/cosmos/evm/indexer" "github.com/cosmos/evm/rpc/backend/mocks" rpctypes "github.com/cosmos/evm/rpc/types" - cosmosevmtypes "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/log" diff --git a/testutil/config/config.go b/testutil/config/config.go index 7ea385bdb..0369655b6 100644 --- a/testutil/config/config.go +++ b/testutil/config/config.go @@ -1,7 +1,7 @@ package config import ( - "github.com/cosmos/evm/types" + "github.com/cosmos/evm/crypto/hd" evmtypes "github.com/cosmos/evm/x/vm/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -59,7 +59,7 @@ func SetBech32Prefixes(config *sdk.Config) { // 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 + config.SetCoinType(hd.Bip44CoinType) + config.SetPurpose(sdk.Purpose) // Shared + config.SetFullFundraiserPath(hd.BIP44HDPath) //nolint: staticcheck } diff --git a/types/genesis.go b/testutil/genesis.go similarity index 88% rename from types/genesis.go rename to testutil/genesis.go index 1697c7fff..33febd28e 100644 --- a/types/genesis.go +++ b/testutil/genesis.go @@ -1,9 +1,9 @@ -package types +package testutil import "encoding/json" // GenesisState of the blockchain is represented here as a map of raw json -// messages key'd by a identifier string. +// 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 diff --git a/testutil/integration/evm/network/amounts.go b/testutil/integration/evm/network/amounts.go index a70b6d239..0f134912c 100644 --- a/testutil/integration/evm/network/amounts.go +++ b/testutil/integration/evm/network/amounts.go @@ -1,10 +1,10 @@ package network import ( + "github.com/cosmos/evm/utils" "math/big" testconstants "github.com/cosmos/evm/testutil/constants" - "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/math" @@ -54,7 +54,7 @@ func GetInitialBondedAmount(decimals evmtypes.Decimals) math.Int { // initialBondedAmount represents the amount of tokens that each validator will // have initially bonded expressed in the 18 decimals representation. sdk.DefaultPowerReduction = math.NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(decimals)), nil)) - initialBondedAmount := sdk.TokensFromConsensusPower(1, types.AttoPowerReduction) + initialBondedAmount := sdk.TokensFromConsensusPower(1, utils.AttoPowerReduction) return initialBondedAmount.Quo(decimals.ConversionFactor()) } diff --git a/testutil/integration/evm/network/network.go b/testutil/integration/evm/network/network.go index b1db05400..72fa3ad03 100644 --- a/testutil/integration/evm/network/network.go +++ b/testutil/integration/evm/network/network.go @@ -18,7 +18,6 @@ import ( "github.com/cosmos/evm" "github.com/cosmos/evm/testutil/integration" basenetwork "github.com/cosmos/evm/testutil/integration/base/network" - "github.com/cosmos/evm/types" erc20types "github.com/cosmos/evm/x/erc20/types" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -250,7 +249,7 @@ func (n *IntegrationNetwork) configureAndInitChain(evmApp evm.EvmApp) error { n.app = evmApp n.ctx = n.ctx.WithConsensusParams(*consensusParams) - n.ctx = n.ctx.WithBlockGasMeter(types.NewInfiniteGasMeterWithLimit(blockMaxGas)) + n.ctx = n.ctx.WithBlockGasMeter(evmtypes.NewInfiniteGasMeterWithLimit(blockMaxGas)) n.validators = validators n.valSet = valSet diff --git a/testutil/integration/evm/network/setup.go b/testutil/integration/evm/network/setup.go index f352bd4af..c1e9896fd 100644 --- a/testutil/integration/evm/network/setup.go +++ b/testutil/integration/evm/network/setup.go @@ -2,6 +2,7 @@ package network import ( "fmt" + "github.com/cosmos/evm/testutil" "maps" "slices" "time" @@ -10,7 +11,6 @@ import ( "github.com/cosmos/evm" testconstants "github.com/cosmos/evm/testutil/constants" - cosmosevmtypes "github.com/cosmos/evm/types" erc20types "github.com/cosmos/evm/x/erc20/types" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -34,7 +34,7 @@ import ( ) // genSetupFn is the type for the module genesis setup functions -type genSetupFn func(cosmosEVMApp evm.EvmApp, genesisState cosmosevmtypes.GenesisState, customGenesis interface{}) (cosmosevmtypes.GenesisState, error) +type genSetupFn func(cosmosEVMApp evm.EvmApp, genesisState testutil.GenesisState, customGenesis interface{}) (testutil.GenesisState, error) // defaultGenesisParams contains the params that are needed to // setup the default genesis for the testing setup @@ -59,7 +59,7 @@ var genesisSetupFunctions = map[string]genSetupFn{ minttypes.ModuleName: genStateSetter[*minttypes.GenesisState](minttypes.ModuleName), banktypes.ModuleName: setBankGenesisState, authtypes.ModuleName: setAuthGenesisState, - consensustypes.ModuleName: func(_ evm.EvmApp, genesisState cosmosevmtypes.GenesisState, _ interface{}) (cosmosevmtypes.GenesisState, error) { + consensustypes.ModuleName: func(_ evm.EvmApp, genesisState testutil.GenesisState, _ interface{}) (testutil.GenesisState, error) { // no-op. Consensus does not have a genesis state on the application // but the params are used on it // (e.g. block max gas, max bytes). @@ -70,7 +70,7 @@ var genesisSetupFunctions = map[string]genSetupFn{ // genStateSetter is a generic function to set module-specific genesis state func genStateSetter[T proto.Message](moduleName string) genSetupFn { - return func(cosmosEVMApp evm.EvmApp, genesisState cosmosevmtypes.GenesisState, customGenesis interface{}) (cosmosevmtypes.GenesisState, error) { + return func(cosmosEVMApp evm.EvmApp, genesisState testutil.GenesisState, customGenesis interface{}) (testutil.GenesisState, error) { moduleGenesis, ok := customGenesis.(T) if !ok { return nil, fmt.Errorf("invalid type %T for %s module genesis state", customGenesis, moduleName) @@ -279,7 +279,7 @@ type StakingCustomGenesisState struct { } // setDefaultStakingGenesisState sets the default staking genesis state -func setDefaultStakingGenesisState(cosmosEVMApp evm.EvmApp, genesisState cosmosevmtypes.GenesisState, overwriteParams StakingCustomGenesisState) cosmosevmtypes.GenesisState { +func setDefaultStakingGenesisState(cosmosEVMApp evm.EvmApp, genesisState testutil.GenesisState, overwriteParams StakingCustomGenesisState) testutil.GenesisState { // Set staking params stakingParams := stakingtypes.DefaultParams() stakingParams.BondDenom = overwriteParams.denom @@ -299,7 +299,7 @@ type BankCustomGenesisState struct { } // setDefaultBankGenesisState sets the default bank genesis state -func setDefaultBankGenesisState(cosmosEVMApp evm.EvmApp, genesisState cosmosevmtypes.GenesisState, overwriteParams BankCustomGenesisState) cosmosevmtypes.GenesisState { +func setDefaultBankGenesisState(cosmosEVMApp evm.EvmApp, genesisState testutil.GenesisState, overwriteParams BankCustomGenesisState) testutil.GenesisState { bankGenesis := banktypes.NewGenesisState( banktypes.DefaultGenesisState().Params, overwriteParams.balances, @@ -320,7 +320,7 @@ type SlashingCustomGenesisState struct { } // setDefaultSlashingGenesisState sets the default slashing genesis state -func setDefaultSlashingGenesisState(cosmosEVMApp evm.EvmApp, genesisState cosmosevmtypes.GenesisState, overwriteParams SlashingCustomGenesisState) cosmosevmtypes.GenesisState { +func setDefaultSlashingGenesisState(cosmosEVMApp evm.EvmApp, genesisState testutil.GenesisState, overwriteParams SlashingCustomGenesisState) testutil.GenesisState { slashingGen := slashingtypes.DefaultGenesisState() slashingGen.SigningInfos = overwriteParams.signingInfo slashingGen.MissedBlocks = overwriteParams.missedBlocks @@ -330,7 +330,7 @@ func setDefaultSlashingGenesisState(cosmosEVMApp evm.EvmApp, genesisState cosmos } // setBankGenesisState updates the bank genesis state with custom genesis state -func setBankGenesisState(cosmosEVMApp evm.EvmApp, genesisState cosmosevmtypes.GenesisState, customGenesis interface{}) (cosmosevmtypes.GenesisState, error) { +func setBankGenesisState(cosmosEVMApp evm.EvmApp, genesisState testutil.GenesisState, customGenesis interface{}) (testutil.GenesisState, error) { customGen, ok := customGenesis.(*banktypes.GenesisState) if !ok { return nil, fmt.Errorf("invalid type %T for bank module genesis state", customGenesis) @@ -382,14 +382,14 @@ func addBondedModuleAccountToFundedBalances( } // setDefaultAuthGenesisState sets the default auth genesis state -func setDefaultAuthGenesisState(cosmosEVMApp evm.EvmApp, genesisState cosmosevmtypes.GenesisState, genAccs []authtypes.GenesisAccount) cosmosevmtypes.GenesisState { +func setDefaultAuthGenesisState(cosmosEVMApp evm.EvmApp, genesisState testutil.GenesisState, genAccs []authtypes.GenesisAccount) testutil.GenesisState { defaultAuthGen := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) genesisState[authtypes.ModuleName] = cosmosEVMApp.AppCodec().MustMarshalJSON(defaultAuthGen) return genesisState } // setAuthGenesisState updates the bank genesis state with custom genesis state -func setAuthGenesisState(cosmosEVMApp evm.EvmApp, genesisState cosmosevmtypes.GenesisState, customGenesis interface{}) (cosmosevmtypes.GenesisState, error) { +func setAuthGenesisState(cosmosEVMApp evm.EvmApp, genesisState testutil.GenesisState, customGenesis interface{}) (testutil.GenesisState, error) { customGen, ok := customGenesis.(*authtypes.GenesisState) if !ok { return nil, fmt.Errorf("invalid type %T for auth module genesis state", customGenesis) @@ -414,7 +414,7 @@ type GovCustomGenesisState struct { } // setDefaultGovGenesisState sets the default gov genesis state -func setDefaultGovGenesisState(cosmosEVMApp evm.EvmApp, genesisState cosmosevmtypes.GenesisState, overwriteParams GovCustomGenesisState) cosmosevmtypes.GenesisState { +func setDefaultGovGenesisState(cosmosEVMApp evm.EvmApp, genesisState testutil.GenesisState, overwriteParams GovCustomGenesisState) testutil.GenesisState { govGen := govtypesv1.DefaultGenesisState() updatedParams := govGen.Params minDepositAmt := sdkmath.NewInt(1e18).Quo(evmtypes.GetEVMCoinDecimals().ConversionFactor()) @@ -431,7 +431,7 @@ type FeeMarketCustomGenesisState struct { } // setDefaultFeeMarketGenesisState sets the default fee market genesis state -func setDefaultFeeMarketGenesisState(cosmosEVMApp evm.EvmApp, genesisState cosmosevmtypes.GenesisState, overwriteParams FeeMarketCustomGenesisState) cosmosevmtypes.GenesisState { +func setDefaultFeeMarketGenesisState(cosmosEVMApp evm.EvmApp, genesisState testutil.GenesisState, overwriteParams FeeMarketCustomGenesisState) testutil.GenesisState { fmGen := feemarkettypes.DefaultGenesisState() fmGen.Params.BaseFee = overwriteParams.baseFee genesisState[feemarkettypes.ModuleName] = cosmosEVMApp.AppCodec().MustMarshalJSON(fmGen) @@ -448,7 +448,7 @@ type MintCustomGenesisState struct { // setDefaultGovGenesisState sets the default gov genesis state // // NOTE: for the testing network we don't want to have any minting -func setDefaultMintGenesisState(cosmosEVMApp evm.EvmApp, genesisState cosmosevmtypes.GenesisState, overwriteParams MintCustomGenesisState) cosmosevmtypes.GenesisState { +func setDefaultMintGenesisState(cosmosEVMApp evm.EvmApp, genesisState testutil.GenesisState, overwriteParams MintCustomGenesisState) testutil.GenesisState { mintGen := minttypes.DefaultGenesisState() updatedParams := mintGen.Params updatedParams.MintDenom = overwriteParams.denom @@ -460,7 +460,7 @@ func setDefaultMintGenesisState(cosmosEVMApp evm.EvmApp, genesisState cosmosevmt return genesisState } -func setDefaultErc20GenesisState(cosmosEVMApp evm.EvmApp, evmChainID uint64, genesisState cosmosevmtypes.GenesisState) cosmosevmtypes.GenesisState { +func setDefaultErc20GenesisState(cosmosEVMApp evm.EvmApp, evmChainID uint64, genesisState testutil.GenesisState) testutil.GenesisState { // NOTE: here we are using the setup from the example chain erc20Gen := newErc20GenesisState() updatedErc20Gen := updateErc20GenesisStateForChainID(testconstants.ChainID{ @@ -487,7 +487,7 @@ func newErc20GenesisState() *erc20types.GenesisState { // defaultAuthGenesisState sets the default genesis state // for the testing setup -func newDefaultGenesisState(cosmosEVMApp evm.EvmApp, evmChainID uint64, params defaultGenesisParams) cosmosevmtypes.GenesisState { +func newDefaultGenesisState(cosmosEVMApp evm.EvmApp, evmChainID uint64, params defaultGenesisParams) testutil.GenesisState { genesisState := cosmosEVMApp.DefaultGenesis() genesisState = setDefaultAuthGenesisState(cosmosEVMApp, genesisState, params.genAccounts) @@ -504,7 +504,7 @@ func newDefaultGenesisState(cosmosEVMApp evm.EvmApp, evmChainID uint64, params d // customizeGenesis modifies genesis state if there are any custom genesis state // for specific modules -func customizeGenesis(cosmosEVMApp evm.EvmApp, customGen CustomGenesisState, genesisState cosmosevmtypes.GenesisState) (cosmosevmtypes.GenesisState, error) { +func customizeGenesis(cosmosEVMApp evm.EvmApp, customGen CustomGenesisState, genesisState testutil.GenesisState) (testutil.GenesisState, error) { var err error for mod, modGenState := range customGen { if fn, found := genesisSetupFunctions[mod]; found { diff --git a/testutil/tx/eip712.go b/testutil/tx/eip712.go index 009a658ed..5ff00e2b1 100644 --- a/testutil/tx/eip712.go +++ b/testutil/tx/eip712.go @@ -6,11 +6,6 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/signer/core/apitypes" - "github.com/cosmos/evm" - cryptocodec "github.com/cosmos/evm/crypto/codec" - "github.com/cosmos/evm/ethereum/eip712" - "github.com/cosmos/evm/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -19,6 +14,9 @@ import ( signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" + "github.com/cosmos/evm" + cryptocodec "github.com/cosmos/evm/crypto/codec" + "github.com/cosmos/evm/ethereum/eip712" ) type EIP712TxArgs struct { @@ -164,7 +162,7 @@ func signCosmosEIP712Tx( func createTypedData(args typedDataArgs, useLegacy bool) (apitypes.TypedData, error) { if useLegacy { registry := codectypes.NewInterfaceRegistry() - types.RegisterInterfaces(registry) + eip712.RegisterInterfaces(registry) cryptocodec.RegisterInterfaces(registry) evmCodec := codec.NewProtoCodec(registry) diff --git a/types/errors.go b/types/errors.go deleted file mode 100644 index 37dacc870..000000000 --- a/types/errors.go +++ /dev/null @@ -1,11 +0,0 @@ -package types - -import ( - errorsmod "cosmossdk.io/errors" -) - -// RootCodespace is the codespace for all errors defined in this package -const RootCodespace = "Cosmos EVM" - -// ErrInvalidChainID returns an error resulting from an invalid chain ID. -var ErrInvalidChainID = errorsmod.Register(RootCodespace, 3, "invalid chain ID") diff --git a/types/int.go b/utils/int.go similarity index 99% rename from types/int.go rename to utils/int.go index 941963eac..b9ad3d1c0 100644 --- a/types/int.go +++ b/utils/int.go @@ -1,4 +1,4 @@ -package types +package utils import ( fmt "fmt" diff --git a/types/power.go b/utils/power.go similarity index 96% rename from types/power.go rename to utils/power.go index 7f6311eae..72c90fd3c 100644 --- a/types/power.go +++ b/utils/power.go @@ -1,4 +1,4 @@ -package types +package utils import ( "math/big" diff --git a/utils/utils.go b/utils/utils.go index 57f8bd0f4..ea347f9a8 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -7,20 +7,12 @@ import ( "sort" "strings" - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/params" - "github.com/holiman/uint256" - "github.com/pkg/errors" - "github.com/cosmos/evm/crypto/ethsecp256k1" - feemarkettypes "github.com/cosmos/evm/x/feemarket/types" - evmtypes "github.com/cosmos/evm/x/vm/types" ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" + "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" errorsmod "cosmossdk.io/errors" - sdkmath "cosmossdk.io/math" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" @@ -207,52 +199,6 @@ func Uint256FromBigInt(i *big.Int) (*uint256.Int, error) { return result, nil } -// CalcBaseFee calculates the basefee of the header. -func CalcBaseFee(config *params.ChainConfig, parent *ethtypes.Header, p feemarkettypes.Params) (*big.Int, error) { - // If the current block is the first EIP-1559 block, return the InitialBaseFee. - if !config.IsLondon(parent.Number) { - return new(big.Int).SetUint64(params.InitialBaseFee), nil - } - if p.ElasticityMultiplier == 0 { - return nil, errors.New("ElasticityMultiplier cannot be 0 as it's checked in the params validation") - } - parentGasTarget := parent.GasLimit / uint64(p.ElasticityMultiplier) - - factor := evmtypes.GetEVMCoinDecimals().ConversionFactor() - minGasPrice := p.MinGasPrice.Mul(sdkmath.LegacyNewDecFromInt(factor)) - return CalcGasBaseFee( - parent.GasUsed, parentGasTarget, uint64(p.BaseFeeChangeDenominator), - sdkmath.LegacyNewDecFromBigInt(parent.BaseFee), sdkmath.LegacyOneDec(), minGasPrice, - ).TruncateInt().BigInt(), nil -} - -func CalcGasBaseFee(gasUsed, gasTarget, baseFeeChangeDenom uint64, baseFee, minUnitGas, minGasPrice sdkmath.LegacyDec) sdkmath.LegacyDec { - // If the parent gasUsed is the same as the target, the baseFee remains unchanged. - if gasUsed == gasTarget { - return baseFee - } - - if gasTarget == 0 { - return sdkmath.LegacyZeroDec() - } - - num := sdkmath.LegacyNewDecFromInt(sdkmath.NewIntFromUint64(gasUsed).Sub(sdkmath.NewIntFromUint64(gasTarget)).Abs()) - num = num.Mul(baseFee) - num = num.QuoInt(sdkmath.NewIntFromUint64(gasTarget)) - num = num.QuoInt(sdkmath.NewIntFromUint64(baseFeeChangeDenom)) - - if gasUsed > gasTarget { - // If the parent block used more gas than its target, the baseFee should increase. - // max(1, parentBaseFee * gasUsedDelta / parentGasTarget / baseFeeChangeDenominator) - baseFeeDelta := sdkmath.LegacyMaxDec(num, minUnitGas) - return baseFee.Add(baseFeeDelta) - } - - // Otherwise if the parent block used less gas than its target, the baseFee should decrease. - // max(minGasPrice, parentBaseFee * gasUsedDelta / parentGasTarget / baseFeeChangeDenominator) - return sdkmath.LegacyMaxDec(baseFee.Sub(num), minGasPrice) -} - // Bytes32ToString converts a bytes32 value to string by trimming null bytes func Bytes32ToString(data [32]byte) string { // Find the first null byte diff --git a/utils/utils_test.go b/utils/utils_test.go index c6d7d331f..086d53222 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -3,6 +3,7 @@ package utils_test import ( "bytes" "fmt" + "github.com/cosmos/evm/rpc/types" "math/big" "testing" @@ -15,7 +16,6 @@ import ( "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/crypto/hd" "github.com/cosmos/evm/testutil/constants" - "github.com/cosmos/evm/types" "github.com/cosmos/evm/utils" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -384,7 +384,7 @@ func TestAccountEquivalence(t *testing.T) { // account using ethsecp // and coin type 60 - evmKey, err := kb.NewAccount(uid, mnemonic, keyring.DefaultBIP39Passphrase, types.BIP44HDPath, algoEvm) + evmKey, err := kb.NewAccount(uid, mnemonic, keyring.DefaultBIP39Passphrase, hd.BIP44HDPath, algoEvm) require.NoError(t, err) // verify that none of these three keys are equal @@ -721,7 +721,7 @@ func TestCalcBaseFee(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - result, err := utils.CalcBaseFee(tc.config, tc.parent, tc.params) + result, err := types.CalcBaseFee(tc.config, tc.parent, tc.params) if tc.expectedError != "" { require.Error(t, err) diff --git a/types/validation.go b/utils/validation.go similarity index 98% rename from types/validation.go rename to utils/validation.go index 2bacefc4b..346f45973 100644 --- a/types/validation.go +++ b/utils/validation.go @@ -1,4 +1,4 @@ -package types +package utils import ( "bytes" diff --git a/types/validation_test.go b/utils/validation_test.go similarity index 87% rename from types/validation_test.go rename to utils/validation_test.go index 39d49a9e9..ebbf4f762 100644 --- a/types/validation_test.go +++ b/utils/validation_test.go @@ -1,4 +1,4 @@ -package types_test +package utils_test import ( "testing" @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/require" utiltx "github.com/cosmos/evm/testutil/tx" - "github.com/cosmos/evm/types" ) func TestIsEmptyHash(t *testing.T) { @@ -29,7 +28,7 @@ func TestIsEmptyHash(t *testing.T) { } for _, tc := range testCases { - require.Equal(t, tc.expEmpty, types.IsEmptyHash(tc.hash), tc.name) + require.Equal(t, tc.expEmpty, IsEmptyHash(tc.hash), tc.name) } } @@ -52,7 +51,7 @@ func TestIsZeroAddress(t *testing.T) { } for _, tc := range testCases { - require.Equal(t, tc.expEmpty, types.IsZeroAddress(tc.address), tc.name) + require.Equal(t, tc.expEmpty, IsZeroAddress(tc.address), tc.name) } } @@ -77,7 +76,7 @@ func TestValidateAddress(t *testing.T) { } for _, tc := range testCases { - err := types.ValidateAddress(tc.address) + err := ValidateAddress(tc.address) if tc.expError { require.Error(t, err, tc.name) @@ -108,7 +107,7 @@ func TestValidateNonZeroAddress(t *testing.T) { } for _, tc := range testCases { - err := types.ValidateNonZeroAddress(tc.address) + err := ValidateNonZeroAddress(tc.address) if tc.expError { require.Error(t, err, tc.name) @@ -133,7 +132,7 @@ func TestSafeInt64(t *testing.T) { } for _, tc := range testCases { - value, err := types.SafeInt64(tc.value) + value, err := SafeInt64(tc.value) if tc.expError { require.Error(t, err, tc.name) continue diff --git a/x/erc20/client/cli/tx.go b/x/erc20/client/cli/tx.go index 647630ddd..aebea0981 100644 --- a/x/erc20/client/cli/tx.go +++ b/x/erc20/client/cli/tx.go @@ -2,11 +2,11 @@ package cli import ( "fmt" + cosmosevmtypes "github.com/cosmos/evm/utils" "github.com/ethereum/go-ethereum/common" "github.com/spf13/cobra" - cosmosevmtypes "github.com/cosmos/evm/types" "github.com/cosmos/evm/x/erc20/types" "cosmossdk.io/math" diff --git a/x/erc20/keeper/grpc_query.go b/x/erc20/keeper/grpc_query.go index 8932de2ba..c4be344bc 100644 --- a/x/erc20/keeper/grpc_query.go +++ b/x/erc20/keeper/grpc_query.go @@ -2,11 +2,11 @@ package keeper import ( "context" + cosmosevmtypes "github.com/cosmos/evm/utils" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - cosmosevmtypes "github.com/cosmos/evm/types" "github.com/cosmos/evm/x/erc20/types" "cosmossdk.io/store/prefix" diff --git a/x/erc20/types/proposal.go b/x/erc20/types/proposal.go index ac1d44b84..661f3d94a 100644 --- a/x/erc20/types/proposal.go +++ b/x/erc20/types/proposal.go @@ -3,10 +3,9 @@ package types import ( "errors" "fmt" + cosmosevmtypes "github.com/cosmos/evm/utils" "strings" - cosmosevmtypes "github.com/cosmos/evm/types" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/erc20/types/token_pair.go b/x/erc20/types/token_pair.go index 0b19df00f..4da8ba4b4 100644 --- a/x/erc20/types/token_pair.go +++ b/x/erc20/types/token_pair.go @@ -5,7 +5,6 @@ import ( "github.com/cometbft/cometbft/crypto/tmhash" - cosmosevmtypes "github.com/cosmos/evm/types" "github.com/cosmos/evm/utils" sdk "github.com/cosmos/cosmos-sdk/types" @@ -56,7 +55,7 @@ func (tp TokenPair) Validate() error { return err } - return cosmosevmtypes.ValidateAddress(tp.Erc20Address) + return utils.ValidateAddress(tp.Erc20Address) } // IsNativeCoin returns true if the owner of the ERC20 contract is the diff --git a/x/feemarket/keeper/eip1559.go b/x/feemarket/keeper/eip1559.go index d2f1d3944..dc53e8558 100644 --- a/x/feemarket/keeper/eip1559.go +++ b/x/feemarket/keeper/eip1559.go @@ -1,9 +1,9 @@ package keeper import ( + "github.com/cosmos/evm/x/feemarket/types" "math" - "github.com/cosmos/evm/utils" evmtypes "github.com/cosmos/evm/x/vm/types" sdkmath "cosmossdk.io/math" @@ -58,7 +58,7 @@ func (k Keeper) CalculateBaseFee(ctx sdk.Context) sdkmath.LegacyDec { } factor := evmtypes.GetEVMCoinDecimals().ConversionFactor() - return utils.CalcGasBaseFee( + return types.CalcGasBaseFee( parentGasUsed, parentGasTargetInt.Uint64(), uint64(params.BaseFeeChangeDenominator), diff --git a/x/feemarket/types/utils.go b/x/feemarket/types/utils.go new file mode 100644 index 000000000..cc07a1cef --- /dev/null +++ b/x/feemarket/types/utils.go @@ -0,0 +1,30 @@ +package types + +import "cosmossdk.io/math" + +func CalcGasBaseFee(gasUsed, gasTarget, baseFeeChangeDenom uint64, baseFee, minUnitGas, minGasPrice math.LegacyDec) math.LegacyDec { + // If the parent gasUsed is the same as the target, the baseFee remains unchanged. + if gasUsed == gasTarget { + return baseFee + } + + if gasTarget == 0 { + return math.LegacyZeroDec() + } + + num := math.LegacyNewDecFromInt(math.NewIntFromUint64(gasUsed).Sub(math.NewIntFromUint64(gasTarget)).Abs()) + num = num.Mul(baseFee) + num = num.QuoInt(math.NewIntFromUint64(gasTarget)) + num = num.QuoInt(math.NewIntFromUint64(baseFeeChangeDenom)) + + if gasUsed > gasTarget { + // If the parent block used more gas than its target, the baseFee should increase. + // max(1, parentBaseFee * gasUsedDelta / parentGasTarget / baseFeeChangeDenominator) + baseFeeDelta := math.LegacyMaxDec(num, minUnitGas) + return baseFee.Add(baseFeeDelta) + } + + // Otherwise if the parent block used less gas than its target, the baseFee should decrease. + // max(minGasPrice, parentBaseFee * gasUsedDelta / parentGasTarget / baseFeeChangeDenominator) + return math.LegacyMaxDec(baseFee.Sub(num), minGasPrice) +} diff --git a/x/ibc/callbacks/keeper/keeper.go b/x/ibc/callbacks/keeper/keeper.go index eab3a6d87..ea86e4630 100644 --- a/x/ibc/callbacks/keeper/keeper.go +++ b/x/ibc/callbacks/keeper/keeper.go @@ -1,6 +1,7 @@ package keeper import ( + types2 "github.com/cosmos/evm/x/vm/types" "math/big" "github.com/ethereum/go-ethereum/common" @@ -8,7 +9,6 @@ import ( "github.com/cosmos/evm/contracts" "github.com/cosmos/evm/ibc" callbacksabi "github.com/cosmos/evm/precompiles/callbacks" - types2 "github.com/cosmos/evm/types" "github.com/cosmos/evm/utils" erc20types "github.com/cosmos/evm/x/erc20/types" "github.com/cosmos/evm/x/ibc/callbacks/types" diff --git a/x/vm/keeper/grpc_query.go b/x/vm/keeper/grpc_query.go index a748d29d6..921a798b3 100644 --- a/x/vm/keeper/grpc_query.go +++ b/x/vm/keeper/grpc_query.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + cosmosevmtypes "github.com/cosmos/evm/utils" "math/big" "time" @@ -21,7 +22,6 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - cosmosevmtypes "github.com/cosmos/evm/types" evmante "github.com/cosmos/evm/x/vm/ante" "github.com/cosmos/evm/x/vm/statedb" "github.com/cosmos/evm/x/vm/types" @@ -784,5 +784,5 @@ func (k Keeper) Config(_ context.Context, _ *types.QueryConfigRequest) (*types.Q // 2. calling BuildEvmExecutionCtx to set up gas configs consistent with Ethereum transaction execution. func buildTraceCtx(ctx sdk.Context, gasLimit uint64) sdk.Context { return evmante.BuildEvmExecutionCtx(ctx). - WithGasMeter(cosmosevmtypes.NewInfiniteGasMeterWithLimit(gasLimit)) + WithGasMeter(types.NewInfiniteGasMeterWithLimit(gasLimit)) } diff --git a/x/vm/keeper/state_transition.go b/x/vm/keeper/state_transition.go index fafa49463..14589bad0 100644 --- a/x/vm/keeper/state_transition.go +++ b/x/vm/keeper/state_transition.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + types2 "github.com/cosmos/evm/ante/types" "math/big" "github.com/ethereum/go-ethereum/common" @@ -14,7 +15,6 @@ import ( cmttypes "github.com/cometbft/cometbft/types" - cosmosevmtypes "github.com/cosmos/evm/types" "github.com/cosmos/evm/utils" "github.com/cosmos/evm/x/vm/statedb" "github.com/cosmos/evm/x/vm/types" @@ -48,7 +48,7 @@ func (k *Keeper) NewEVM( Transfer: core.Transfer, GetHash: k.GetHashFn(ctx), Coinbase: cfg.CoinBase, - GasLimit: cosmosevmtypes.BlockGasLimit(ctx), + GasLimit: types2.BlockGasLimit(ctx), BlockNumber: big.NewInt(ctx.BlockHeight()), Time: uint64(ctx.BlockHeader().Time.Unix()), //#nosec G115 -- int overflow is not a concern here Difficulty: big.NewInt(0), // unused. Only required in PoW context @@ -84,7 +84,7 @@ func (k *Keeper) NewEVM( // 3. The requested height is from a height greater than the latest one func (k Keeper) GetHashFn(ctx sdk.Context) vm.GetHashFunc { return func(height uint64) common.Hash { - h, err := cosmosevmtypes.SafeInt64(height) + h, err := utils.SafeInt64(height) if err != nil { k.Logger(ctx).Error("failed to cast height to int64", "error", err) return common.Hash{} diff --git a/types/gasmeter.go b/x/vm/types/gasmeter.go similarity index 100% rename from types/gasmeter.go rename to x/vm/types/gasmeter.go diff --git a/x/vm/types/genesis.go b/x/vm/types/genesis.go index f7190d294..c3af3b44f 100644 --- a/x/vm/types/genesis.go +++ b/x/vm/types/genesis.go @@ -2,13 +2,12 @@ package types import ( "fmt" - - "github.com/cosmos/evm/types" + "github.com/cosmos/evm/utils" ) // Validate performs a basic validation of a GenesisAccount fields. func (ga GenesisAccount) Validate() error { - if err := types.ValidateAddress(ga.Address); err != nil { + if err := utils.ValidateAddress(ga.Address); err != nil { return err } return ga.Storage.Validate() diff --git a/x/vm/types/logs.go b/x/vm/types/logs.go index 5409a2097..c622c2810 100644 --- a/x/vm/types/logs.go +++ b/x/vm/types/logs.go @@ -3,11 +3,10 @@ package types import ( "errors" "fmt" + cosmosevmtypes "github.com/cosmos/evm/utils" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" - - cosmosevmtypes "github.com/cosmos/evm/types" ) // NewTransactionLogs creates a new NewTransactionLogs instance. diff --git a/x/vm/types/params.go b/x/vm/types/params.go index 5b3e8d400..8c09cf92c 100644 --- a/x/vm/types/params.go +++ b/x/vm/types/params.go @@ -2,6 +2,7 @@ package types import ( "fmt" + "github.com/cosmos/evm/utils" "math/big" "slices" @@ -9,7 +10,6 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" - "github.com/cosmos/evm/types" channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v10/modules/core/24-host" @@ -167,7 +167,7 @@ func validateAllowlistAddresses(i interface{}) error { } for _, address := range addresses { - if err := types.ValidateAddress(address); err != nil { + if err := utils.ValidateAddress(address); err != nil { return fmt.Errorf("invalid whitelist address: %s", address) } } @@ -210,7 +210,7 @@ func ValidatePrecompiles(i interface{}) error { return fmt.Errorf("duplicate precompile %s", precompile) } - if err := types.ValidateAddress(precompile); err != nil { + if err := utils.ValidateAddress(precompile); err != nil { return fmt.Errorf("invalid precompile %s", precompile) } From 3fa184ec3b9571e3388c8735fcf102dfab7cad18 Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 19 Sep 2025 12:11:40 -0400 Subject: [PATCH 02/11] fix validation test --- utils/validation_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/utils/validation_test.go b/utils/validation_test.go index ebbf4f762..5d8a726c7 100644 --- a/utils/validation_test.go +++ b/utils/validation_test.go @@ -1,6 +1,7 @@ package utils_test import ( + "github.com/cosmos/evm/utils" "testing" "github.com/ethereum/go-ethereum/common" @@ -28,7 +29,7 @@ func TestIsEmptyHash(t *testing.T) { } for _, tc := range testCases { - require.Equal(t, tc.expEmpty, IsEmptyHash(tc.hash), tc.name) + require.Equal(t, tc.expEmpty, utils.IsEmptyHash(tc.hash), tc.name) } } @@ -51,7 +52,7 @@ func TestIsZeroAddress(t *testing.T) { } for _, tc := range testCases { - require.Equal(t, tc.expEmpty, IsZeroAddress(tc.address), tc.name) + require.Equal(t, tc.expEmpty, utils.IsZeroAddress(tc.address), tc.name) } } @@ -76,7 +77,7 @@ func TestValidateAddress(t *testing.T) { } for _, tc := range testCases { - err := ValidateAddress(tc.address) + err := utils.ValidateAddress(tc.address) if tc.expError { require.Error(t, err, tc.name) @@ -107,7 +108,7 @@ func TestValidateNonZeroAddress(t *testing.T) { } for _, tc := range testCases { - err := ValidateNonZeroAddress(tc.address) + err := utils.ValidateNonZeroAddress(tc.address) if tc.expError { require.Error(t, err, tc.name) @@ -132,7 +133,7 @@ func TestSafeInt64(t *testing.T) { } for _, tc := range testCases { - value, err := SafeInt64(tc.value) + value, err := utils.SafeInt64(tc.value) if tc.expError { require.Error(t, err, tc.name) continue From 19cf9900741121cb5377708c015aa09bdbcf0c7f Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 19 Sep 2025 12:12:30 -0400 Subject: [PATCH 03/11] use genesis type --- evmd/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evmd/app.go b/evmd/app.go index 4c5d31cfd..659ec6706 100644 --- a/evmd/app.go +++ b/evmd/app.go @@ -933,7 +933,7 @@ func (app *EVMD) TxConfig() client.TxConfig { } // DefaultGenesis returns a default genesis from the registered AppModuleBasic's. -func (app *EVMD) DefaultGenesis() map[string]json.RawMessage { +func (app *EVMD) DefaultGenesis() GenesisState { genesis := app.BasicModuleManager.DefaultGenesis(app.appCodec) mintGenState := NewMintGenesisState() From bc08d5c02d069adbdfdc23a3425a55ad35f027f0 Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 19 Sep 2025 12:13:42 -0400 Subject: [PATCH 04/11] Revert "use genesis type" This reverts commit 19cf9900741121cb5377708c015aa09bdbcf0c7f. --- evmd/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evmd/app.go b/evmd/app.go index 659ec6706..4c5d31cfd 100644 --- a/evmd/app.go +++ b/evmd/app.go @@ -933,7 +933,7 @@ func (app *EVMD) TxConfig() client.TxConfig { } // DefaultGenesis returns a default genesis from the registered AppModuleBasic's. -func (app *EVMD) DefaultGenesis() GenesisState { +func (app *EVMD) DefaultGenesis() map[string]json.RawMessage { genesis := app.BasicModuleManager.DefaultGenesis(app.appCodec) mintGenState := NewMintGenesisState() From 1f8d01933aa6adaeff5e4adf45056ffcaf48b6b6 Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 19 Sep 2025 12:15:51 -0400 Subject: [PATCH 05/11] lints --- ante/cosmos/eip712.go | 3 ++- ante/evm/08_gas_consume.go | 2 +- ante/evm/10_gas_wanted.go | 2 +- ante/evm/fee_checker.go | 2 +- ante/evm/fee_checker_test.go | 2 +- crypto/hd/algorithm_test.go | 5 +++-- crypto/hd/hdpath.go | 4 ++-- encoding/codec/codec.go | 5 +++-- ethereum/eip712/codec.go | 3 ++- indexer/kv_indexer.go | 2 +- rpc/apis.go | 7 ++++--- rpc/backend/backend.go | 2 +- rpc/backend/blocks.go | 4 ++-- rpc/backend/tx_info.go | 4 ++-- rpc/namespaces/ethereum/personal/api.go | 2 +- rpc/stream/rpc.go | 2 +- rpc/types/block.go | 3 ++- rpc/types/events.go | 2 +- rpc/types/utils.go | 4 ++-- server/indexer_service.go | 3 ++- server/json_rpc.go | 7 ++++--- server/start.go | 9 +++++---- tests/integration/ante/test_evm_fee_market.go | 2 +- tests/integration/rpc/backend/test_tx_info.go | 2 +- testutil/integration/evm/network/amounts.go | 2 +- testutil/integration/evm/network/setup.go | 2 +- testutil/tx/eip712.go | 7 ++++--- utils/utils.go | 6 ++++-- utils/utils_test.go | 2 +- utils/validation_test.go | 2 +- x/erc20/client/cli/tx.go | 2 +- x/erc20/keeper/grpc_query.go | 2 +- x/erc20/types/proposal.go | 3 ++- x/feemarket/keeper/eip1559.go | 2 +- x/ibc/callbacks/keeper/keeper.go | 2 +- x/vm/keeper/grpc_query.go | 2 +- x/vm/keeper/state_transition.go | 2 +- x/vm/types/genesis.go | 1 + x/vm/types/logs.go | 3 ++- x/vm/types/params.go | 2 +- 40 files changed, 70 insertions(+), 55 deletions(-) diff --git a/ante/cosmos/eip712.go b/ante/cosmos/eip712.go index 470788bbf..e800cee0f 100644 --- a/ante/cosmos/eip712.go +++ b/ante/cosmos/eip712.go @@ -8,11 +8,12 @@ import ( "github.com/ethereum/go-ethereum/crypto/secp256k1" "github.com/ethereum/go-ethereum/signer/core/apitypes" - errorsmod "cosmossdk.io/errors" anteinterfaces "github.com/cosmos/evm/ante/interfaces" "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/ethereum/eip712" + errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" diff --git a/ante/evm/08_gas_consume.go b/ante/evm/08_gas_consume.go index 6a6221616..d55111029 100644 --- a/ante/evm/08_gas_consume.go +++ b/ante/evm/08_gas_consume.go @@ -1,13 +1,13 @@ package evm import ( - types2 "github.com/cosmos/evm/ante/types" "math/big" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" anteinterfaces "github.com/cosmos/evm/ante/interfaces" + types2 "github.com/cosmos/evm/ante/types" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" diff --git a/ante/evm/10_gas_wanted.go b/ante/evm/10_gas_wanted.go index 679800d9b..bc6cd4bd4 100644 --- a/ante/evm/10_gas_wanted.go +++ b/ante/evm/10_gas_wanted.go @@ -1,10 +1,10 @@ package evm import ( - "github.com/cosmos/evm/ante/types" "math/big" anteinterfaces "github.com/cosmos/evm/ante/interfaces" + "github.com/cosmos/evm/ante/types" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" diff --git a/ante/evm/fee_checker.go b/ante/evm/fee_checker.go index 5a5d617ad..d95e7d0a9 100644 --- a/ante/evm/fee_checker.go +++ b/ante/evm/fee_checker.go @@ -1,12 +1,12 @@ package evm import ( - cosmosevmtypes "github.com/cosmos/evm/ante/types" "math" "github.com/ethereum/go-ethereum/params" anteinterfaces "github.com/cosmos/evm/ante/interfaces" + cosmosevmtypes "github.com/cosmos/evm/ante/types" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" diff --git a/ante/evm/fee_checker_test.go b/ante/evm/fee_checker_test.go index d914966f9..4558522e8 100644 --- a/ante/evm/fee_checker_test.go +++ b/ante/evm/fee_checker_test.go @@ -1,7 +1,6 @@ package evm_test import ( - "github.com/cosmos/evm/ante/types" "math/big" "testing" @@ -11,6 +10,7 @@ import ( "github.com/cosmos/evm/ante/evm" anteinterfaces "github.com/cosmos/evm/ante/interfaces" + "github.com/cosmos/evm/ante/types" "github.com/cosmos/evm/encoding" "github.com/cosmos/evm/testutil/config" testconstants "github.com/cosmos/evm/testutil/constants" diff --git a/crypto/hd/algorithm_test.go b/crypto/hd/algorithm_test.go index f4e01db92..d518ce3d9 100644 --- a/crypto/hd/algorithm_test.go +++ b/crypto/hd/algorithm_test.go @@ -8,11 +8,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" + cryptocodec "github.com/cosmos/evm/crypto/codec" + enccodec "github.com/cosmos/evm/encoding/codec" + amino "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keyring" - cryptocodec "github.com/cosmos/evm/crypto/codec" - enccodec "github.com/cosmos/evm/encoding/codec" ) var TestCodec amino.Codec diff --git a/crypto/hd/hdpath.go b/crypto/hd/hdpath.go index 2a7dd0566..f53aff180 100644 --- a/crypto/hd/hdpath.go +++ b/crypto/hd/hdpath.go @@ -13,12 +13,12 @@ var ( ) type ( - HDPathIterator func() ethaccounts.DerivationPath + PathIterator func() ethaccounts.DerivationPath ) // NewHDPathIterator receives a base path as a string and a boolean for the desired iterator type and // returns a function that iterates over the base HD path, returning the string. -func NewHDPathIterator(basePath string, ledgerIter bool) (HDPathIterator, error) { +func NewHDPathIterator(basePath string, ledgerIter bool) (PathIterator, error) { hdPath, err := ethaccounts.ParseDerivationPath(basePath) if err != nil { return nil, err diff --git a/encoding/codec/codec.go b/encoding/codec/codec.go index f33a79f88..bd1b8dbb6 100644 --- a/encoding/codec/codec.go +++ b/encoding/codec/codec.go @@ -1,12 +1,13 @@ package codec import ( + cryptocodec "github.com/cosmos/evm/crypto/codec" + "github.com/cosmos/evm/ethereum/eip712" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/std" sdk "github.com/cosmos/cosmos-sdk/types" - cryptocodec "github.com/cosmos/evm/crypto/codec" - "github.com/cosmos/evm/ethereum/eip712" ) // RegisterLegacyAminoCodec registers Interfaces from types, crypto, and SDK std. diff --git a/ethereum/eip712/codec.go b/ethereum/eip712/codec.go index f81ce1308..aef5dfc97 100644 --- a/ethereum/eip712/codec.go +++ b/ethereum/eip712/codec.go @@ -1,11 +1,12 @@ package eip712 import ( + types2 "github.com/cosmos/evm/ante/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdktypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - types2 "github.com/cosmos/evm/ante/types" ) // RegisterInterfaces registers the CometBFT concrete client-related diff --git a/indexer/kv_indexer.go b/indexer/kv_indexer.go index ff6e3f239..759f4d9c6 100644 --- a/indexer/kv_indexer.go +++ b/indexer/kv_indexer.go @@ -2,7 +2,6 @@ package indexer import ( "fmt" - "github.com/cosmos/evm/server/types" "github.com/ethereum/go-ethereum/common" @@ -11,6 +10,7 @@ import ( dbm "github.com/cosmos/cosmos-db" rpctypes "github.com/cosmos/evm/rpc/types" + "github.com/cosmos/evm/server/types" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" diff --git a/rpc/apis.go b/rpc/apis.go index f17908000..729908b7f 100644 --- a/rpc/apis.go +++ b/rpc/apis.go @@ -2,12 +2,9 @@ package rpc import ( "fmt" - server2 "github.com/cosmos/evm/server/types" "github.com/ethereum/go-ethereum/rpc" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/server" evmmempool "github.com/cosmos/evm/mempool" "github.com/cosmos/evm/rpc/backend" "github.com/cosmos/evm/rpc/namespaces/ethereum/debug" @@ -19,6 +16,10 @@ import ( "github.com/cosmos/evm/rpc/namespaces/ethereum/txpool" "github.com/cosmos/evm/rpc/namespaces/ethereum/web3" "github.com/cosmos/evm/rpc/stream" + server2 "github.com/cosmos/evm/server/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/server" ) // RPC namespaces and API version diff --git a/rpc/backend/backend.go b/rpc/backend/backend.go index 78a0f1dd8..59c53caac 100644 --- a/rpc/backend/backend.go +++ b/rpc/backend/backend.go @@ -3,7 +3,6 @@ package backend import ( "context" "fmt" - "github.com/cosmos/evm/server/types" "math/big" "time" @@ -21,6 +20,7 @@ import ( evmmempool "github.com/cosmos/evm/mempool" rpctypes "github.com/cosmos/evm/rpc/types" "github.com/cosmos/evm/server/config" + "github.com/cosmos/evm/server/types" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/log" diff --git a/rpc/backend/blocks.go b/rpc/backend/blocks.go index ce4f10e7d..7709dbdb8 100644 --- a/rpc/backend/blocks.go +++ b/rpc/backend/blocks.go @@ -2,8 +2,6 @@ package backend import ( "fmt" - "github.com/cosmos/evm/server/types" - cosmosevmtypes "github.com/cosmos/evm/utils" "math/big" "strconv" @@ -19,6 +17,8 @@ import ( cmtrpctypes "github.com/cometbft/cometbft/rpc/core/types" rpctypes "github.com/cosmos/evm/rpc/types" + "github.com/cosmos/evm/server/types" + cosmosevmtypes "github.com/cosmos/evm/utils" evmtypes "github.com/cosmos/evm/x/vm/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/rpc/backend/tx_info.go b/rpc/backend/tx_info.go index 98dd91637..e4b00229f 100644 --- a/rpc/backend/tx_info.go +++ b/rpc/backend/tx_info.go @@ -2,8 +2,6 @@ package backend import ( "fmt" - types2 "github.com/cosmos/evm/server/types" - "github.com/cosmos/evm/utils" "math" "math/big" "time" @@ -21,6 +19,8 @@ import ( "github.com/cosmos/evm/mempool/txpool" rpctypes "github.com/cosmos/evm/rpc/types" + types2 "github.com/cosmos/evm/server/types" + "github.com/cosmos/evm/utils" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" diff --git a/rpc/namespaces/ethereum/personal/api.go b/rpc/namespaces/ethereum/personal/api.go index 63a388a9f..51a5b73c6 100644 --- a/rpc/namespaces/ethereum/personal/api.go +++ b/rpc/namespaces/ethereum/personal/api.go @@ -25,7 +25,7 @@ import ( type PrivateAccountAPI struct { backend backend.EVMBackend logger log.Logger - hdPathIter hd.HDPathIterator + hdPathIter hd.PathIterator } // NewAPI creates an instance of the public Personal Eth API. diff --git a/rpc/stream/rpc.go b/rpc/stream/rpc.go index 3312a81d8..44b028c32 100644 --- a/rpc/stream/rpc.go +++ b/rpc/stream/rpc.go @@ -3,7 +3,6 @@ package stream import ( "context" "fmt" - cosmosevmtypes "github.com/cosmos/evm/utils" "sync" "github.com/ethereum/go-ethereum/common" @@ -15,6 +14,7 @@ import ( cmttypes "github.com/cometbft/cometbft/types" "github.com/cosmos/evm/rpc/types" + cosmosevmtypes "github.com/cosmos/evm/utils" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/log" diff --git a/rpc/types/block.go b/rpc/types/block.go index bcc7eb872..f4a0400db 100644 --- a/rpc/types/block.go +++ b/rpc/types/block.go @@ -5,7 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/cosmos/evm/utils" "math" "math/big" "strings" @@ -15,6 +14,8 @@ import ( "github.com/spf13/cast" "google.golang.org/grpc/metadata" + "github.com/cosmos/evm/utils" + grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" ) diff --git a/rpc/types/events.go b/rpc/types/events.go index 0e35394f1..34761d811 100644 --- a/rpc/types/events.go +++ b/rpc/types/events.go @@ -2,7 +2,6 @@ package types import ( "fmt" - "github.com/cosmos/evm/server/types" "strconv" "github.com/ethereum/go-ethereum/common" @@ -10,6 +9,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" cmtrpctypes "github.com/cometbft/cometbft/rpc/core/types" + "github.com/cosmos/evm/server/types" evmtypes "github.com/cosmos/evm/x/vm/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/rpc/types/utils.go b/rpc/types/utils.go index 7e1f94653..8952c24a8 100644 --- a/rpc/types/utils.go +++ b/rpc/types/utils.go @@ -3,8 +3,6 @@ package types import ( "context" "fmt" - types2 "github.com/cosmos/evm/x/feemarket/types" - "github.com/pkg/errors" "math/big" "strings" @@ -12,11 +10,13 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + "github.com/pkg/errors" abci "github.com/cometbft/cometbft/abci/types" cmtrpcclient "github.com/cometbft/cometbft/rpc/client" cmttypes "github.com/cometbft/cometbft/types" + types2 "github.com/cosmos/evm/x/feemarket/types" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" diff --git a/server/indexer_service.go b/server/indexer_service.go index 6240eede0..8693c001d 100644 --- a/server/indexer_service.go +++ b/server/indexer_service.go @@ -2,13 +2,14 @@ package server import ( "context" - types2 "github.com/cosmos/evm/server/types" "time" "github.com/cometbft/cometbft/libs/service" rpcclient "github.com/cometbft/cometbft/rpc/client" coretypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/cometbft/cometbft/types" + + types2 "github.com/cosmos/evm/server/types" ) const ( diff --git a/server/json_rpc.go b/server/json_rpc.go index 9b71bc799..c490d342d 100644 --- a/server/json_rpc.go +++ b/server/json_rpc.go @@ -3,7 +3,6 @@ package server import ( "context" "fmt" - "github.com/cosmos/evm/server/types" "log/slog" "net/http" "time" @@ -16,12 +15,14 @@ import ( rpcclient "github.com/cometbft/cometbft/rpc/client" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/server" evmmempool "github.com/cosmos/evm/mempool" "github.com/cosmos/evm/rpc" "github.com/cosmos/evm/rpc/stream" serverconfig "github.com/cosmos/evm/server/config" + "github.com/cosmos/evm/server/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/server" ) const shutdownTimeout = 200 * time.Millisecond diff --git a/server/start.go b/server/start.go index 3298522c6..13e348274 100644 --- a/server/start.go +++ b/server/start.go @@ -3,7 +3,6 @@ package server import ( "context" "fmt" - types2 "github.com/cosmos/evm/server/types" "io" "net" "os" @@ -27,9 +26,6 @@ import ( "github.com/cometbft/cometbft/rpc/client/local" cmttypes "github.com/cometbft/cometbft/types" - errorsmod "cosmossdk.io/errors" - "cosmossdk.io/log" - pruningtypes "cosmossdk.io/store/pruning/types" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/evm/indexer" evmmempool "github.com/cosmos/evm/mempool" @@ -37,6 +33,11 @@ import ( ethdebug "github.com/cosmos/evm/rpc/namespaces/ethereum/debug" cosmosevmserverconfig "github.com/cosmos/evm/server/config" srvflags "github.com/cosmos/evm/server/flags" + types2 "github.com/cosmos/evm/server/types" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" + pruningtypes "cosmossdk.io/store/pruning/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/tests/integration/ante/test_evm_fee_market.go b/tests/integration/ante/test_evm_fee_market.go index 75568ef0d..1a8180986 100644 --- a/tests/integration/ante/test_evm_fee_market.go +++ b/tests/integration/ante/test_evm_fee_market.go @@ -1,12 +1,12 @@ package ante import ( - "github.com/cosmos/evm/ante/types" "math/big" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/cosmos/evm/ante/evm" + "github.com/cosmos/evm/ante/types" "github.com/cosmos/evm/server/config" "github.com/cosmos/evm/testutil" testconstants "github.com/cosmos/evm/testutil/constants" diff --git a/tests/integration/rpc/backend/test_tx_info.go b/tests/integration/rpc/backend/test_tx_info.go index 376ad1ef8..864108d19 100644 --- a/tests/integration/rpc/backend/test_tx_info.go +++ b/tests/integration/rpc/backend/test_tx_info.go @@ -3,7 +3,6 @@ package backend import ( "errors" "fmt" - cosmosevmtypes "github.com/cosmos/evm/server/types" "math/big" "github.com/ethereum/go-ethereum/common" @@ -19,6 +18,7 @@ import ( "github.com/cosmos/evm/indexer" "github.com/cosmos/evm/rpc/backend/mocks" rpctypes "github.com/cosmos/evm/rpc/types" + cosmosevmtypes "github.com/cosmos/evm/server/types" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/log" diff --git a/testutil/integration/evm/network/amounts.go b/testutil/integration/evm/network/amounts.go index 0f134912c..af440ef55 100644 --- a/testutil/integration/evm/network/amounts.go +++ b/testutil/integration/evm/network/amounts.go @@ -1,10 +1,10 @@ package network import ( - "github.com/cosmos/evm/utils" "math/big" testconstants "github.com/cosmos/evm/testutil/constants" + "github.com/cosmos/evm/utils" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/math" diff --git a/testutil/integration/evm/network/setup.go b/testutil/integration/evm/network/setup.go index c1e9896fd..992a88513 100644 --- a/testutil/integration/evm/network/setup.go +++ b/testutil/integration/evm/network/setup.go @@ -2,7 +2,6 @@ package network import ( "fmt" - "github.com/cosmos/evm/testutil" "maps" "slices" "time" @@ -10,6 +9,7 @@ import ( cmttypes "github.com/cometbft/cometbft/types" "github.com/cosmos/evm" + "github.com/cosmos/evm/testutil" 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/testutil/tx/eip712.go b/testutil/tx/eip712.go index 5ff00e2b1..89b4a57ae 100644 --- a/testutil/tx/eip712.go +++ b/testutil/tx/eip712.go @@ -6,6 +6,10 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/signer/core/apitypes" + "github.com/cosmos/evm" + cryptocodec "github.com/cosmos/evm/crypto/codec" + "github.com/cosmos/evm/ethereum/eip712" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -14,9 +18,6 @@ import ( signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" - "github.com/cosmos/evm" - cryptocodec "github.com/cosmos/evm/crypto/codec" - "github.com/cosmos/evm/ethereum/eip712" ) type EIP712TxArgs struct { diff --git a/utils/utils.go b/utils/utils.go index ea347f9a8..573b38829 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -7,12 +7,14 @@ import ( "sort" "strings" - "github.com/cosmos/evm/crypto/ethsecp256k1" - ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" "github.com/ethereum/go-ethereum/common" "github.com/holiman/uint256" + "github.com/cosmos/evm/crypto/ethsecp256k1" + ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" + errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" diff --git a/utils/utils_test.go b/utils/utils_test.go index 086d53222..f5b81274e 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -3,7 +3,6 @@ package utils_test import ( "bytes" "fmt" - "github.com/cosmos/evm/rpc/types" "math/big" "testing" @@ -15,6 +14,7 @@ import ( cryptocodec "github.com/cosmos/evm/crypto/codec" "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/crypto/hd" + "github.com/cosmos/evm/rpc/types" "github.com/cosmos/evm/testutil/constants" "github.com/cosmos/evm/utils" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" diff --git a/utils/validation_test.go b/utils/validation_test.go index 5d8a726c7..fae0aa0dc 100644 --- a/utils/validation_test.go +++ b/utils/validation_test.go @@ -1,13 +1,13 @@ package utils_test import ( - "github.com/cosmos/evm/utils" "testing" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" utiltx "github.com/cosmos/evm/testutil/tx" + "github.com/cosmos/evm/utils" ) func TestIsEmptyHash(t *testing.T) { diff --git a/x/erc20/client/cli/tx.go b/x/erc20/client/cli/tx.go index aebea0981..a139c8fa4 100644 --- a/x/erc20/client/cli/tx.go +++ b/x/erc20/client/cli/tx.go @@ -2,11 +2,11 @@ package cli import ( "fmt" - cosmosevmtypes "github.com/cosmos/evm/utils" "github.com/ethereum/go-ethereum/common" "github.com/spf13/cobra" + cosmosevmtypes "github.com/cosmos/evm/utils" "github.com/cosmos/evm/x/erc20/types" "cosmossdk.io/math" diff --git a/x/erc20/keeper/grpc_query.go b/x/erc20/keeper/grpc_query.go index c4be344bc..bfefaf314 100644 --- a/x/erc20/keeper/grpc_query.go +++ b/x/erc20/keeper/grpc_query.go @@ -2,11 +2,11 @@ package keeper import ( "context" - cosmosevmtypes "github.com/cosmos/evm/utils" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + cosmosevmtypes "github.com/cosmos/evm/utils" "github.com/cosmos/evm/x/erc20/types" "cosmossdk.io/store/prefix" diff --git a/x/erc20/types/proposal.go b/x/erc20/types/proposal.go index 661f3d94a..78d1a4b26 100644 --- a/x/erc20/types/proposal.go +++ b/x/erc20/types/proposal.go @@ -3,9 +3,10 @@ package types import ( "errors" "fmt" - cosmosevmtypes "github.com/cosmos/evm/utils" "strings" + cosmosevmtypes "github.com/cosmos/evm/utils" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/feemarket/keeper/eip1559.go b/x/feemarket/keeper/eip1559.go index dc53e8558..21e3546b7 100644 --- a/x/feemarket/keeper/eip1559.go +++ b/x/feemarket/keeper/eip1559.go @@ -1,9 +1,9 @@ package keeper import ( - "github.com/cosmos/evm/x/feemarket/types" "math" + "github.com/cosmos/evm/x/feemarket/types" evmtypes "github.com/cosmos/evm/x/vm/types" sdkmath "cosmossdk.io/math" diff --git a/x/ibc/callbacks/keeper/keeper.go b/x/ibc/callbacks/keeper/keeper.go index ea86e4630..a501e4d1d 100644 --- a/x/ibc/callbacks/keeper/keeper.go +++ b/x/ibc/callbacks/keeper/keeper.go @@ -1,7 +1,6 @@ package keeper import ( - types2 "github.com/cosmos/evm/x/vm/types" "math/big" "github.com/ethereum/go-ethereum/common" @@ -13,6 +12,7 @@ import ( erc20types "github.com/cosmos/evm/x/erc20/types" "github.com/cosmos/evm/x/ibc/callbacks/types" evmante "github.com/cosmos/evm/x/vm/ante" + types2 "github.com/cosmos/evm/x/vm/types" callbacktypes "github.com/cosmos/ibc-go/v10/modules/apps/callbacks/types" transfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" diff --git a/x/vm/keeper/grpc_query.go b/x/vm/keeper/grpc_query.go index 921a798b3..c2bbbabd3 100644 --- a/x/vm/keeper/grpc_query.go +++ b/x/vm/keeper/grpc_query.go @@ -5,7 +5,6 @@ import ( "encoding/json" "errors" "fmt" - cosmosevmtypes "github.com/cosmos/evm/utils" "math/big" "time" @@ -22,6 +21,7 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + cosmosevmtypes "github.com/cosmos/evm/utils" evmante "github.com/cosmos/evm/x/vm/ante" "github.com/cosmos/evm/x/vm/statedb" "github.com/cosmos/evm/x/vm/types" diff --git a/x/vm/keeper/state_transition.go b/x/vm/keeper/state_transition.go index 14589bad0..bf3a025b6 100644 --- a/x/vm/keeper/state_transition.go +++ b/x/vm/keeper/state_transition.go @@ -2,7 +2,6 @@ package keeper import ( "fmt" - types2 "github.com/cosmos/evm/ante/types" "math/big" "github.com/ethereum/go-ethereum/common" @@ -15,6 +14,7 @@ import ( cmttypes "github.com/cometbft/cometbft/types" + types2 "github.com/cosmos/evm/ante/types" "github.com/cosmos/evm/utils" "github.com/cosmos/evm/x/vm/statedb" "github.com/cosmos/evm/x/vm/types" diff --git a/x/vm/types/genesis.go b/x/vm/types/genesis.go index c3af3b44f..039b8f580 100644 --- a/x/vm/types/genesis.go +++ b/x/vm/types/genesis.go @@ -2,6 +2,7 @@ package types import ( "fmt" + "github.com/cosmos/evm/utils" ) diff --git a/x/vm/types/logs.go b/x/vm/types/logs.go index c622c2810..50073bf0b 100644 --- a/x/vm/types/logs.go +++ b/x/vm/types/logs.go @@ -3,10 +3,11 @@ package types import ( "errors" "fmt" - cosmosevmtypes "github.com/cosmos/evm/utils" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" + + cosmosevmtypes "github.com/cosmos/evm/utils" ) // NewTransactionLogs creates a new NewTransactionLogs instance. diff --git a/x/vm/types/params.go b/x/vm/types/params.go index 8c09cf92c..4062b6f56 100644 --- a/x/vm/types/params.go +++ b/x/vm/types/params.go @@ -2,7 +2,6 @@ package types import ( "fmt" - "github.com/cosmos/evm/utils" "math/big" "slices" @@ -10,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" + "github.com/cosmos/evm/utils" channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v10/modules/core/24-host" From 6714313c0fa1e527931d86f93c68d81cd94f09f6 Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 19 Sep 2025 12:16:18 -0400 Subject: [PATCH 06/11] lints - cont. --- crypto/hd/utils_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/hd/utils_test.go b/crypto/hd/utils_test.go index 1c1bc03cd..7a5de9f09 100644 --- a/crypto/hd/utils_test.go +++ b/crypto/hd/utils_test.go @@ -135,7 +135,7 @@ func (w *Wallet) derivePrivateKey(path accounts.DerivationPath) (*ecdsa.PrivateK if w.fixIssue172 && key.IsAffectedByIssue172() { key, err = key.Derive(n) } else { - key, err = key.DeriveNonStandard(n) //nolint:staticcheck // SA1019 this is used for testing only + key, err = key.DeriveNonStandard(n) } if err != nil { return nil, err From 454e039cefaaea51a15ad60e55e45957918785f3 Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 19 Sep 2025 12:26:25 -0400 Subject: [PATCH 07/11] changelog, reference fixes --- CHANGELOG.md | 1 + docs/migrations/v0.4.0_to_v0.5.0_UNRELEASED.md | 14 +++++++++++++- evmd/ante/evm_antehandler_benchmark_test.go | 4 ++-- evmd/ante/validate_handler_options_test.go | 6 +++--- evmd/app.go | 4 ++-- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90165d117..ba67d2d80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ - [\#609](https://github.com/cosmos/evm/pull/609) Make `erc20Keeper` optional in the EVM keeper - [\#624](https://github.com/cosmos/evm/pull/624) Cleanup unnecessary `fix-revert-gas-refund-height`. - [\#635](https://github.com/cosmos/evm/pull/635) Move DefaultStaticPrecompiles to /evm and allow projects to set it by default alongside the keeper. +- [\#639](https://github.com/cosmos/evm/pull/639) Remove `/types` from top-level repo and move files to respective areas. ### FEATURES diff --git a/docs/migrations/v0.4.0_to_v0.5.0_UNRELEASED.md b/docs/migrations/v0.4.0_to_v0.5.0_UNRELEASED.md index 10fc61266..8d4930cca 100644 --- a/docs/migrations/v0.4.0_to_v0.5.0_UNRELEASED.md +++ b/docs/migrations/v0.4.0_to_v0.5.0_UNRELEASED.md @@ -18,7 +18,19 @@ go mod tidy --- -## 2) App wiring in `app.go` +## 2) Fix `"github.com/cosmos/evm/types" imports` + +`v0.5.0` removes `github.com/cosmos/evm/types` and moves files to their respective areas. For a complete list of changes, refer to [this PR](https://github.com/cosmos/evm/pull/639). +The following are references within `evmd` that have been moved. + +- `Bip44CoinType`, `BIP44HDPath` was moved to `"github.com/cosmos/evm/crypto/hd"` +- `HasDynamicFeeExtensionOption` was moved `"github.com/cosmos/evm/ante/types"` +- `GenesisState` was removed as a duplicate object can be found in the `evmd` folder and a testing version is in `"github.com/cosmos/evm/testutil"` +- `AttoPowerReduction` was moved to `"github.com/cosmos/evm/utils"` + +--- + +## 3) App wiring in `app.go` ### Mempool diff --git a/evmd/ante/evm_antehandler_benchmark_test.go b/evmd/ante/evm_antehandler_benchmark_test.go index 289a5f6ed..011f21a1a 100644 --- a/evmd/ante/evm_antehandler_benchmark_test.go +++ b/evmd/ante/evm_antehandler_benchmark_test.go @@ -2,7 +2,7 @@ package ante_test import ( "fmt" - cosmosevmtypes "github.com/cosmos/evm/ante/types" + antetypes "github.com/cosmos/evm/ante/types" "math/big" "testing" @@ -148,7 +148,7 @@ func (s *benchmarkSuite) generateHandlerOptions() ante.HandlerOptions { Cdc: s.network.App.AppCodec(), AccountKeeper: s.network.App.GetAccountKeeper(), BankKeeper: s.network.App.GetBankKeeper(), - ExtensionOptionChecker: cosmosevmtypes.HasDynamicFeeExtensionOption, + ExtensionOptionChecker: antetypes.HasDynamicFeeExtensionOption, EvmKeeper: s.network.App.GetEVMKeeper(), FeegrantKeeper: s.network.App.GetFeeGrantKeeper(), IBCKeeper: s.network.App.GetIBCKeeper(), diff --git a/evmd/ante/validate_handler_options_test.go b/evmd/ante/validate_handler_options_test.go index 825b1f541..a894b184f 100644 --- a/evmd/ante/validate_handler_options_test.go +++ b/evmd/ante/validate_handler_options_test.go @@ -1,7 +1,7 @@ package ante_test import ( - "github.com/cosmos/evm/ante/types" + antetypes "github.com/cosmos/evm/ante/types" "testing" "github.com/ethereum/go-ethereum/common" @@ -124,7 +124,7 @@ func RunValidateHandlerOptionsTest(t *testing.T, create network.CreateEvmApp, op Cdc: nw.App.AppCodec(), AccountKeeper: nw.App.GetAccountKeeper(), BankKeeper: nw.App.GetBankKeeper(), - ExtensionOptionChecker: types.HasDynamicFeeExtensionOption, + ExtensionOptionChecker: antetypes.HasDynamicFeeExtensionOption, EvmKeeper: nw.App.GetEVMKeeper(), FeegrantKeeper: nw.App.GetFeeGrantKeeper(), IBCKeeper: nw.App.GetIBCKeeper(), @@ -143,7 +143,7 @@ func RunValidateHandlerOptionsTest(t *testing.T, create network.CreateEvmApp, op Cdc: nw.App.AppCodec(), AccountKeeper: nw.App.GetAccountKeeper(), BankKeeper: nw.App.GetBankKeeper(), - ExtensionOptionChecker: types.HasDynamicFeeExtensionOption, + ExtensionOptionChecker: antetypes.HasDynamicFeeExtensionOption, EvmKeeper: nw.App.GetEVMKeeper(), FeegrantKeeper: nw.App.GetFeeGrantKeeper(), IBCKeeper: nw.App.GetIBCKeeper(), diff --git a/evmd/app.go b/evmd/app.go index 4c5d31cfd..5163bb1ba 100644 --- a/evmd/app.go +++ b/evmd/app.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" "fmt" - types2 "github.com/cosmos/evm/ante/types" + antetypes "github.com/cosmos/evm/ante/types" precompiletypes "github.com/cosmos/evm/precompiles/types" "github.com/cosmos/evm/utils" "io" @@ -822,7 +822,7 @@ func (app *EVMD) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64) { Cdc: app.appCodec, AccountKeeper: app.AccountKeeper, BankKeeper: app.BankKeeper, - ExtensionOptionChecker: types2.HasDynamicFeeExtensionOption, + ExtensionOptionChecker: antetypes.HasDynamicFeeExtensionOption, EvmKeeper: app.EVMKeeper, FeegrantKeeper: app.FeeGrantKeeper, IBCKeeper: app.IBCKeeper, From 9f3fd127dcc9605c7c7e25123ee4bd3a74906639 Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 19 Sep 2025 12:29:23 -0400 Subject: [PATCH 08/11] migration fix --- docs/migrations/v0.4.0_to_v0.5.0_UNRELEASED.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/migrations/v0.4.0_to_v0.5.0_UNRELEASED.md b/docs/migrations/v0.4.0_to_v0.5.0_UNRELEASED.md index 8d4930cca..43be11e3c 100644 --- a/docs/migrations/v0.4.0_to_v0.5.0_UNRELEASED.md +++ b/docs/migrations/v0.4.0_to_v0.5.0_UNRELEASED.md @@ -20,8 +20,9 @@ go mod tidy ## 2) Fix `"github.com/cosmos/evm/types" imports` -`v0.5.0` removes `github.com/cosmos/evm/types` and moves files to their respective areas. For a complete list of changes, refer to [this PR](https://github.com/cosmos/evm/pull/639). -The following are references within `evmd` that have been moved. +`v0.5.0` removes `github.com/cosmos/evm/types` and moves files to their folders, respective to function. +For a complete list of changes, refer to [this PR](https://github.com/cosmos/evm/pull/639). The +following list includes references within `evmd` that have been moved. - `Bip44CoinType`, `BIP44HDPath` was moved to `"github.com/cosmos/evm/crypto/hd"` - `HasDynamicFeeExtensionOption` was moved `"github.com/cosmos/evm/ante/types"` From 2d92a92b474a75408e8fbb4c621933b3e264f3c1 Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 19 Sep 2025 12:29:59 -0400 Subject: [PATCH 09/11] lint --- crypto/hd/utils_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/hd/utils_test.go b/crypto/hd/utils_test.go index 7a5de9f09..1c1bc03cd 100644 --- a/crypto/hd/utils_test.go +++ b/crypto/hd/utils_test.go @@ -135,7 +135,7 @@ func (w *Wallet) derivePrivateKey(path accounts.DerivationPath) (*ecdsa.PrivateK if w.fixIssue172 && key.IsAffectedByIssue172() { key, err = key.Derive(n) } else { - key, err = key.DeriveNonStandard(n) + key, err = key.DeriveNonStandard(n) //nolint:staticcheck // SA1019 this is used for testing only } if err != nil { return nil, err From 64574798c7c208c836c6144529ebb4a401f4570a Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 19 Sep 2025 14:13:54 -0400 Subject: [PATCH 10/11] apply fixes --- ante/evm/08_gas_consume.go | 4 ++-- ethereum/eip712/codec.go | 4 ++-- evmd/ante/evm_antehandler_benchmark_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ante/evm/08_gas_consume.go b/ante/evm/08_gas_consume.go index d55111029..18dbad747 100644 --- a/ante/evm/08_gas_consume.go +++ b/ante/evm/08_gas_consume.go @@ -7,7 +7,7 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" anteinterfaces "github.com/cosmos/evm/ante/interfaces" - types2 "github.com/cosmos/evm/ante/types" + antetypes "github.com/cosmos/evm/ante/types" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" @@ -99,7 +99,7 @@ func GetMsgPriority( // TODO: (@fedekunze) Why is this necessary? This seems to be a duplicate from the CheckGasWanted function. func CheckBlockGasLimit(ctx sdktypes.Context, gasWanted uint64, minPriority int64) (sdktypes.Context, error) { - blockGasLimit := types2.BlockGasLimit(ctx) + blockGasLimit := antetypes.BlockGasLimit(ctx) // return error if the tx gas is greater than the block limit (max gas) diff --git a/ethereum/eip712/codec.go b/ethereum/eip712/codec.go index aef5dfc97..f8a6391f3 100644 --- a/ethereum/eip712/codec.go +++ b/ethereum/eip712/codec.go @@ -1,7 +1,7 @@ package eip712 import ( - types2 "github.com/cosmos/evm/ante/types" + antetypes "github.com/cosmos/evm/ante/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdktypes "github.com/cosmos/cosmos-sdk/types" @@ -25,6 +25,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*tx.TxExtensionOptionI)(nil), &ExtensionOptionsWeb3Tx{}, - &types2.ExtensionOptionDynamicFeeTx{}, + &antetypes.ExtensionOptionDynamicFeeTx{}, ) } diff --git a/evmd/ante/evm_antehandler_benchmark_test.go b/evmd/ante/evm_antehandler_benchmark_test.go index 011f21a1a..ae163a330 100644 --- a/evmd/ante/evm_antehandler_benchmark_test.go +++ b/evmd/ante/evm_antehandler_benchmark_test.go @@ -2,12 +2,12 @@ package ante_test import ( "fmt" - antetypes "github.com/cosmos/evm/ante/types" "math/big" "testing" "github.com/cosmos/evm/ante" ethante "github.com/cosmos/evm/ante/evm" + antetypes "github.com/cosmos/evm/ante/types" evmdante "github.com/cosmos/evm/evmd/ante" "github.com/cosmos/evm/evmd/tests/integration" basefactory "github.com/cosmos/evm/testutil/integration/base/factory" From c7747f8314cb63f1171ed90530293801a1599c7f Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 19 Sep 2025 15:31:49 -0400 Subject: [PATCH 11/11] some more 2 imports --- evmd/tests/ibc/ibc_middleware_test.go | 26 +++++++++++++------------- evmd/tests/network/network.go | 22 +++++++++++----------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/evmd/tests/ibc/ibc_middleware_test.go b/evmd/tests/ibc/ibc_middleware_test.go index f704a3704..a1acc0298 100644 --- a/evmd/tests/ibc/ibc_middleware_test.go +++ b/evmd/tests/ibc/ibc_middleware_test.go @@ -20,9 +20,9 @@ import ( "github.com/cosmos/evm/x/erc20" erc20Keeper "github.com/cosmos/evm/x/erc20/keeper" "github.com/cosmos/evm/x/erc20/types" - testutil2 "github.com/cosmos/evm/x/ibc/callbacks/testutil" - types2 "github.com/cosmos/evm/x/ibc/callbacks/types" - types3 "github.com/cosmos/evm/x/vm/types" + ibctestutil "github.com/cosmos/evm/x/ibc/callbacks/testutil" + callbacktypes "github.com/cosmos/evm/x/ibc/callbacks/types" + evmtypes "github.com/cosmos/evm/x/vm/types" ibctransfer "github.com/cosmos/ibc-go/v10/modules/apps/transfer" transfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" @@ -74,7 +74,7 @@ func TestMiddlewareTestSuite(t *testing.T) { func (suite *MiddlewareTestSuite) TestOnRecvPacketWithCallback() { var packet channeltypes.Packet - var contractData types3.CompiledContract + var contractData evmtypes.CompiledContract var contractAddr common.Address var voucherDenom string var path *evmibctesting.Path @@ -314,10 +314,10 @@ func (suite *MiddlewareTestSuite) TestOnRecvPacketWithCallback() { // Generate the isolated address for the sender sendAmt := ibctesting.DefaultCoinAmount - isolatedAddr := types2.GenerateIsolatedAddress(path.EndpointA.ChannelID, suite.chainB.SenderAccount.GetAddress().String()) + isolatedAddr := callbacktypes.GenerateIsolatedAddress(path.EndpointA.ChannelID, suite.chainB.SenderAccount.GetAddress().String()) // Get callback tester contract and deploy it - contractData, err = testutil2.LoadCounterWithCallbacksContract() + contractData, err = ibctestutil.LoadCounterWithCallbacksContract() suite.Require().NoError(err) deploymentData := testutiltypes.ContractDeploymentData{ @@ -639,12 +639,12 @@ func (suite *MiddlewareTestSuite) TestOnRecvPacketNativeErc20() { chainBNativeErc20Denom.Path(), recvAmt.String(), chainBAccount.String(), - types2.GenerateIsolatedAddress(path.EndpointA.ChannelID, suite.chainB.SenderAccount.GetAddress().String()).String(), + callbacktypes.GenerateIsolatedAddress(path.EndpointA.ChannelID, suite.chainB.SenderAccount.GetAddress().String()).String(), "", ) // get callback tester contract and deploy it - contractData, err := testutil2.LoadCounterWithCallbacksContract() + contractData, err := ibctestutil.LoadCounterWithCallbacksContract() suite.Require().NoError(err) deploymentData := testutiltypes.ContractDeploymentData{ @@ -741,7 +741,7 @@ func (suite *MiddlewareTestSuite) TestOnRecvPacketNativeErc20() { // the packet that failed conversion due to the minting restriction should instead remain as the bank token // and will be in the isolated address used to invoke the callback - trappedBal := evmApp.BankKeeper.GetBalance(evmCtx, types2.GenerateIsolatedAddress(path.EndpointA.ChannelID, + trappedBal := evmApp.BankKeeper.GetBalance(evmCtx, callbacktypes.GenerateIsolatedAddress(path.EndpointA.ChannelID, suite.chainB.SenderAccount.GetAddress().String()), nativeErc20.Denom) suite.Require().Equal(recvAmt.String(), trappedBal.Amount.String()) } @@ -751,7 +751,7 @@ func (suite *MiddlewareTestSuite) TestOnAcknowledgementPacketWithCallback() { var ( packet channeltypes.Packet ack []byte - contractData types3.CompiledContract + contractData evmtypes.CompiledContract contractAddr common.Address ) @@ -1008,7 +1008,7 @@ func (suite *MiddlewareTestSuite) TestOnAcknowledgementPacketWithCallback() { receiver := suite.chainB.SenderAccount.GetAddress() // Deploy callback contract on source chain (evmChainA) - contractData, err = testutil2.LoadCounterWithCallbacksContract() + contractData, err = ibctestutil.LoadCounterWithCallbacksContract() suite.Require().NoError(err) deploymentData := testutiltypes.ContractDeploymentData{ @@ -1624,7 +1624,7 @@ func (suite *MiddlewareTestSuite) TestOnTimeoutPacket() { func (suite *MiddlewareTestSuite) TestOnTimeoutPacketWithCallback() { var ( packet channeltypes.Packet - contractData types3.CompiledContract + contractData evmtypes.CompiledContract contractAddr common.Address ) @@ -1835,7 +1835,7 @@ func (suite *MiddlewareTestSuite) TestOnTimeoutPacketWithCallback() { receiver := suite.chainB.SenderAccount.GetAddress() // Deploy callback contract on source chain (evmChainA) - contractData, err = testutil2.LoadCounterWithCallbacksContract() + contractData, err = ibctestutil.LoadCounterWithCallbacksContract() suite.Require().NoError(err) deploymentData := testutiltypes.ContractDeploymentData{ diff --git a/evmd/tests/network/network.go b/evmd/tests/network/network.go index 49c53ae57..2a3ac7793 100644 --- a/evmd/tests/network/network.go +++ b/evmd/tests/network/network.go @@ -6,7 +6,6 @@ import ( "encoding/json" "errors" "fmt" - testutil2 "github.com/cosmos/evm/testutil" "github.com/cosmos/evm/utils" "net/http" "net/url" @@ -33,6 +32,7 @@ import ( "github.com/cosmos/evm/evmd" evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" "github.com/cosmos/evm/server/config" + evmtestutil "github.com/cosmos/evm/testutil" testconfig "github.com/cosmos/evm/testutil/config" testconstants "github.com/cosmos/evm/testutil/constants" @@ -51,7 +51,7 @@ import ( "github.com/cosmos/cosmos-sdk/server/api" srvconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/cosmos/cosmos-sdk/testutil" + sdktestutil "github.com/cosmos/cosmos-sdk/testutil" simutils "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -79,14 +79,14 @@ type Config struct { InterfaceRegistry codectypes.InterfaceRegistry TxConfig client.TxConfig AccountRetriever client.AccountRetriever - AppConstructor AppConstructor // the ABCI application constructor - GenesisState testutil2.GenesisState // custom gensis state to provide - TimeoutCommit time.Duration // the consensus commitment timeout - AccountTokens math.Int // the amount of unique validator tokens (e.g. 1000node0) - StakingTokens math.Int // the amount of tokens each validator has available to stake - BondedTokens math.Int // the amount of tokens each validator stakes - NumValidators int // the total number of validators to create and bond - ChainID string // the network chain-id + AppConstructor AppConstructor // the ABCI application constructor + GenesisState evmtestutil.GenesisState // custom gensis state to provide + TimeoutCommit time.Duration // the consensus commitment timeout + AccountTokens math.Int // the amount of unique validator tokens (e.g. 1000node0) + StakingTokens math.Int // the amount of tokens each validator has available to stake + BondedTokens math.Int // the amount of tokens each validator stakes + NumValidators int // the total number of validators to create and bond + ChainID string // the network chain-id EVMChainID uint64 BondDenom string // the staking bond denomination MinGasPrices string // the minimum gas prices each validator will accept @@ -392,7 +392,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { return nil, err } - addr, secret, err := testutil.GenerateSaveCoinKey(kb, nodeDirName, "", true, algo) + addr, secret, err := sdktestutil.GenerateSaveCoinKey(kb, nodeDirName, "", true, algo) if err != nil { return nil, err }