From 1ddf4355517add1d90a8ac7459e647ee1df4efaa Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 8 Jan 2024 15:39:09 -0800 Subject: [PATCH 01/52] refactor(evm): Move StateDB types, use StateDB interface in keeper --- x/evm/genesis_test.go | 4 +- x/evm/handler_test.go | 5 ++- x/evm/keeper/config.go | 4 +- x/evm/keeper/grpc_query.go | 10 ++--- x/evm/keeper/grpc_query_test.go | 2 +- x/evm/keeper/hooks_test.go | 2 +- x/evm/keeper/keeper.go | 39 +++++++++-------- x/evm/keeper/keeper_test.go | 11 +++-- x/evm/keeper/msg_server_test.go | 4 +- x/evm/keeper/params_test.go | 4 ++ x/evm/keeper/state_transition.go | 6 +-- x/evm/keeper/state_transition_test.go | 5 ++- x/evm/keeper/statedb.go | 8 ++-- x/evm/keeper/statedb_test.go | 20 ++++----- x/evm/migrations/v3/store_test.go | 2 + x/evm/statedb/config.go | 29 ------------- x/evm/statedb/interfaces.go | 18 -------- x/evm/statedb/mock_test.go | 14 +++--- x/evm/statedb/state_object.go | 26 ++---------- x/evm/statedb/statedb.go | 12 +++--- x/evm/statedb/statedb_test.go | 44 ++++++++++--------- x/evm/types/statedb.go | 61 +++++++++++++++++++++++++++ x/evm/vm/interface.go | 44 +++++++++++++++++++ 23 files changed, 218 insertions(+), 156 deletions(-) create mode 100644 x/evm/types/statedb.go diff --git a/x/evm/genesis_test.go b/x/evm/genesis_test.go index e060c5d965..72262472e9 100644 --- a/x/evm/genesis_test.go +++ b/x/evm/genesis_test.go @@ -9,8 +9,8 @@ import ( "github.com/evmos/ethermint/crypto/ethsecp256k1" etherminttypes "github.com/evmos/ethermint/types" "github.com/evmos/ethermint/x/evm" - "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" + "github.com/evmos/ethermint/x/evm/vm" ) func (suite *EvmTestSuite) TestInitGenesis() { @@ -19,7 +19,7 @@ func (suite *EvmTestSuite) TestInitGenesis() { address := common.HexToAddress(privkey.PubKey().Address().String()) - var vmdb *statedb.StateDB + var vmdb vm.StateDB testCases := []struct { name string diff --git a/x/evm/handler_test.go b/x/evm/handler_test.go index a554c6ee6a..68b2b74a1b 100644 --- a/x/evm/handler_test.go +++ b/x/evm/handler_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/evmos/ethermint/x/evm/keeper" + "github.com/evmos/ethermint/x/evm/vm" sdkmath "cosmossdk.io/math" "github.com/gogo/protobuf/proto" @@ -181,8 +182,8 @@ func (suite *EvmTestSuite) SignTx(tx *types.MsgEthereumTx) { suite.Require().NoError(err) } -func (suite *EvmTestSuite) StateDB() *statedb.StateDB { - return statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()))) +func (suite *EvmTestSuite) StateDB() vm.StateDB { + return statedb.New(suite.ctx, suite.app.EvmKeeper, types.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()))) } func TestEvmTestSuite(t *testing.T) { diff --git a/x/evm/keeper/config.go b/x/evm/keeper/config.go index 3debb895de..1d76fd0d06 100644 --- a/x/evm/keeper/config.go +++ b/x/evm/keeper/config.go @@ -48,8 +48,8 @@ func (k *Keeper) EVMConfig(ctx sdk.Context, proposerAddress sdk.ConsAddress, cha } // TxConfig loads `TxConfig` from current transient storage -func (k *Keeper) TxConfig(ctx sdk.Context, txHash common.Hash) statedb.TxConfig { - return statedb.NewTxConfig( +func (k *Keeper) TxConfig(ctx sdk.Context, txHash common.Hash) types.TxConfig { + return types.NewTxConfig( common.BytesToHash(ctx.HeaderHash()), // BlockHash txHash, // TxHash uint(k.GetTxIndexTransient(ctx)), // TxIndex diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 5e09153b59..f9d5b5e56f 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -255,7 +255,7 @@ func (k Keeper) EthCall(c context.Context, req *types.EthCallRequest) (*types.Ms return nil, status.Error(codes.InvalidArgument, err.Error()) } - txConfig := statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash())) + txConfig := types.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash())) // pass false to not commit StateDB res, err := k.ApplyMessageWithConfig(ctx, msg, nil, false, cfg, txConfig) @@ -324,7 +324,7 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type nonce := k.GetNonce(ctx, args.GetFrom()) args.Nonce = (*hexutil.Uint64)(&nonce) - txConfig := statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())) + txConfig := types.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())) // convert the tx args to an ethereum message msg, err := args.ToMessage(req.GasCap, cfg.BaseFee) @@ -423,7 +423,7 @@ func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*typ } signer := ethtypes.MakeSigner(cfg.ChainConfig, big.NewInt(ctx.BlockHeight())) - txConfig := statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())) + txConfig := types.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())) for i, tx := range req.Predecessors { ethTx := tx.AsTransaction() msg, err := ethTx.AsMessage(signer, cfg.BaseFee) @@ -503,7 +503,7 @@ func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest) txsLength := len(req.Txs) results := make([]*types.TxTraceResult, 0, txsLength) - txConfig := statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())) + txConfig := types.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())) for i, tx := range req.Txs { result := types.TxTraceResult{} ethTx := tx.AsTransaction() @@ -533,7 +533,7 @@ func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest) func (k *Keeper) traceTx( ctx sdk.Context, cfg *statedb.EVMConfig, - txConfig statedb.TxConfig, + txConfig types.TxConfig, signer ethtypes.Signer, tx *ethtypes.Transaction, traceConfig *types.TraceConfig, diff --git a/x/evm/keeper/grpc_query_test.go b/x/evm/keeper/grpc_query_test.go index 4149aa47f3..50849abf49 100644 --- a/x/evm/keeper/grpc_query_test.go +++ b/x/evm/keeper/grpc_query_test.go @@ -392,7 +392,7 @@ func (suite *KeeperTestSuite) TestQueryTxLogs() { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset - vmdb := statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()), txHash, txIndex, logIndex)) + vmdb := statedb.New(suite.ctx, suite.app.EvmKeeper, types.NewTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()), txHash, txIndex, logIndex)) tc.malleate(vmdb) suite.Require().NoError(vmdb.Commit()) diff --git a/x/evm/keeper/hooks_test.go b/x/evm/keeper/hooks_test.go index b635cf4cd4..27f6dc58a0 100644 --- a/x/evm/keeper/hooks_test.go +++ b/x/evm/keeper/hooks_test.go @@ -66,7 +66,7 @@ func (suite *KeeperTestSuite) TestEvmHooks() { k := suite.app.EvmKeeper ctx := suite.ctx txHash := common.BigToHash(big.NewInt(1)) - vmdb := statedb.New(ctx, k, statedb.NewTxConfig( + vmdb := statedb.New(ctx, k, types.NewTxConfig( common.BytesToHash(ctx.HeaderHash().Bytes()), txHash, 0, diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 9c47491d8d..45e804dbfe 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -32,7 +32,6 @@ import ( "github.com/tendermint/tendermint/libs/log" ethermint "github.com/evmos/ethermint/types" - "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" legacytypes "github.com/evmos/ethermint/x/evm/types/legacy" evm "github.com/evmos/ethermint/x/evm/vm" @@ -77,6 +76,10 @@ type Keeper struct { // evm constructor function evmConstructor evm.Constructor + + // stateDB constructor function + stateDBConstructor evm.StateDBConstructor + // Legacy subspace ss paramstypes.Subspace } @@ -92,6 +95,7 @@ func NewKeeper( fmk types.FeeMarketKeeper, customPrecompiles evm.PrecompiledContracts, evmConstructor evm.Constructor, + stateDBConstructor evm.StateDBConstructor, tracer string, ss paramstypes.Subspace, ) *Keeper { @@ -111,18 +115,19 @@ func NewKeeper( // NOTE: we pass in the parameter space to the CommitStateDB in order to use custom denominations for the EVM operations return &Keeper{ - cdc: cdc, - authority: authority, - accountKeeper: ak, - bankKeeper: bankKeeper, - stakingKeeper: sk, - feeMarketKeeper: fmk, - storeKey: storeKey, - transientKey: transientKey, - customPrecompiles: customPrecompiles, - evmConstructor: evmConstructor, - tracer: tracer, - ss: ss, + cdc: cdc, + authority: authority, + accountKeeper: ak, + bankKeeper: bankKeeper, + stakingKeeper: sk, + feeMarketKeeper: fmk, + storeKey: storeKey, + transientKey: transientKey, + customPrecompiles: customPrecompiles, + evmConstructor: evmConstructor, + stateDBConstructor: stateDBConstructor, + tracer: tracer, + ss: ss, } } @@ -279,7 +284,7 @@ func (k Keeper) Tracer(ctx sdk.Context, msg core.Message, ethCfg *params.ChainCo // GetAccountWithoutBalance load nonce and codehash without balance, // more efficient in cases where balance is not needed. -func (k *Keeper) GetAccountWithoutBalance(ctx sdk.Context, addr common.Address) *statedb.Account { +func (k *Keeper) GetAccountWithoutBalance(ctx sdk.Context, addr common.Address) *types.StateDBAccount { cosmosAddr := sdk.AccAddress(addr.Bytes()) acct := k.accountKeeper.GetAccount(ctx, cosmosAddr) if acct == nil { @@ -292,21 +297,21 @@ func (k *Keeper) GetAccountWithoutBalance(ctx sdk.Context, addr common.Address) codeHash = ethAcct.GetCodeHash().Bytes() } - return &statedb.Account{ + return &types.StateDBAccount{ Nonce: acct.GetSequence(), CodeHash: codeHash, } } // GetAccountOrEmpty returns empty account if not exist, returns error if it's not `EthAccount` -func (k *Keeper) GetAccountOrEmpty(ctx sdk.Context, addr common.Address) statedb.Account { +func (k *Keeper) GetAccountOrEmpty(ctx sdk.Context, addr common.Address) types.StateDBAccount { acct := k.GetAccount(ctx, addr) if acct != nil { return *acct } // empty account - return statedb.Account{ + return types.StateDBAccount{ Balance: new(big.Int), CodeHash: types.EmptyCodeHash, } diff --git a/x/evm/keeper/keeper_test.go b/x/evm/keeper/keeper_test.go index 1b89527735..826a8f53cc 100644 --- a/x/evm/keeper/keeper_test.go +++ b/x/evm/keeper/keeper_test.go @@ -37,6 +37,7 @@ import ( "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/evmos/ethermint/x/evm/vm" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -252,8 +253,12 @@ func (suite *KeeperTestSuite) Commit() { suite.queryClient = types.NewQueryClient(queryHelper) } -func (suite *KeeperTestSuite) StateDB() *statedb.StateDB { - return statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()))) +func (suite *KeeperTestSuite) StateDB() vm.StateDB { + return statedb.New( + suite.ctx, + suite.app.EvmKeeper, + types.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes())), + ) } // DeployTestContract deploy a test erc20 contract and returns the contract address @@ -498,7 +503,7 @@ func (suite *KeeperTestSuite) TestGetAccountStorage() { } func (suite *KeeperTestSuite) TestGetAccountOrEmpty() { - empty := statedb.Account{ + empty := types.StateDBAccount{ Balance: new(big.Int), CodeHash: types.EmptyCodeHash, } diff --git a/x/evm/keeper/msg_server_test.go b/x/evm/keeper/msg_server_test.go index 4a8c86cefa..39e4ae5383 100644 --- a/x/evm/keeper/msg_server_test.go +++ b/x/evm/keeper/msg_server_test.go @@ -8,8 +8,8 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" - "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" + "github.com/evmos/ethermint/x/evm/vm" ) func (suite *KeeperTestSuite) TestEthereumTx() { @@ -17,7 +17,7 @@ func (suite *KeeperTestSuite) TestEthereumTx() { err error msg *types.MsgEthereumTx signer ethtypes.Signer - vmdb *statedb.StateDB + vmdb vm.StateDB chainCfg *params.ChainConfig expectedGasUsed uint64 ) diff --git a/x/evm/keeper/params_test.go b/x/evm/keeper/params_test.go index af64009aab..56b7e7b9b0 100644 --- a/x/evm/keeper/params_test.go +++ b/x/evm/keeper/params_test.go @@ -11,6 +11,7 @@ import ( "github.com/evmos/ethermint/app" "github.com/evmos/ethermint/encoding" "github.com/evmos/ethermint/x/evm/keeper" + "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" legacytypes "github.com/evmos/ethermint/x/evm/types/legacy" legacytestutil "github.com/evmos/ethermint/x/evm/types/legacy/testutil" @@ -152,6 +153,7 @@ func (suite *KeeperTestSuite) TestLegacyParamsKeyTableRegistration() { ak, nil, nil, nil, nil, // OK to pass nil in for these since we only instantiate and use params geth.NewEVM, + statedb.New, "", unregisteredSubspace, ) @@ -209,6 +211,7 @@ func (suite *KeeperTestSuite) TestRenamedFieldReturnsProperValueForLegacyParams( ak, nil, nil, nil, nil, geth.NewEVM, + statedb.New, "", subspace, ) @@ -241,6 +244,7 @@ func (suite *KeeperTestSuite) TestNilLegacyParamsDoNotPanic() { ak, nil, nil, nil, nil, // OK to pass nil in for these since we only instantiate and use params geth.NewEVM, + statedb.New, "", subspace, ) diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index ad90dba5fd..ef02cdc3c3 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -268,7 +268,7 @@ func (k *Keeper) ApplyMessage(ctx sdk.Context, msg core.Message, tracer vm.EVMLo return nil, errorsmod.Wrap(err, "failed to load evm config") } - txConfig := statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash())) + txConfig := types.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash())) return k.ApplyMessageWithConfig(ctx, msg, tracer, commit, cfg, txConfig) } @@ -315,7 +315,7 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, tracer vm.EVMLogger, commit bool, cfg *statedb.EVMConfig, - txConfig statedb.TxConfig, + txConfig types.TxConfig, ) (*types.MsgEthereumTxResponse, error) { var ( ret []byte // return bytes from evm execution @@ -329,7 +329,7 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, return nil, errorsmod.Wrap(types.ErrCallDisabled, "failed to call contract") } - stateDB := statedb.New(ctx, k, txConfig) + stateDB := k.stateDBConstructor(ctx, k, txConfig) evm := k.NewEVM(ctx, msg, cfg, tracer, stateDB) leftoverGas := msg.Gas() diff --git a/x/evm/keeper/state_transition_test.go b/x/evm/keeper/state_transition_test.go index b74f681d6b..f1fba5f00c 100644 --- a/x/evm/keeper/state_transition_test.go +++ b/x/evm/keeper/state_transition_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" "github.com/evmos/ethermint/tests" "github.com/evmos/ethermint/x/evm/keeper" @@ -574,8 +575,8 @@ func (suite *KeeperTestSuite) TestApplyMessageWithConfig() { config *statedb.EVMConfig keeperParams types.Params signer ethtypes.Signer - vmdb *statedb.StateDB - txConfig statedb.TxConfig + vmdb vm.StateDB + txConfig types.TxConfig chainCfg *params.ChainConfig ) diff --git a/x/evm/keeper/statedb.go b/x/evm/keeper/statedb.go index c2cd893c5e..7644798354 100644 --- a/x/evm/keeper/statedb.go +++ b/x/evm/keeper/statedb.go @@ -27,18 +27,18 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" ethermint "github.com/evmos/ethermint/types" - "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" + "github.com/evmos/ethermint/x/evm/vm" ) -var _ statedb.Keeper = &Keeper{} +var _ vm.StateDBKeeper = &Keeper{} // ---------------------------------------------------------------------------- // StateDB Keeper implementation // ---------------------------------------------------------------------------- // GetAccount returns nil if account is not exist, returns error if it's not `EthAccountI` -func (k *Keeper) GetAccount(ctx sdk.Context, addr common.Address) *statedb.Account { +func (k *Keeper) GetAccount(ctx sdk.Context, addr common.Address) *types.StateDBAccount { acct := k.GetAccountWithoutBalance(ctx, addr) if acct == nil { return nil @@ -119,7 +119,7 @@ func (k *Keeper) SetBalance(ctx sdk.Context, addr common.Address, amount *big.In } // SetAccount updates nonce/balance/codeHash together. -func (k *Keeper) SetAccount(ctx sdk.Context, addr common.Address, account statedb.Account) error { +func (k *Keeper) SetAccount(ctx sdk.Context, addr common.Address, account types.StateDBAccount) error { // update account cosmosAddr := sdk.AccAddress(addr.Bytes()) acct := k.accountKeeper.GetAccount(ctx, cosmosAddr) diff --git a/x/evm/keeper/statedb_test.go b/x/evm/keeper/statedb_test.go index fecb8392f5..af60a73d9c 100644 --- a/x/evm/keeper/statedb_test.go +++ b/x/evm/keeper/statedb_test.go @@ -233,55 +233,55 @@ func (suite *KeeperTestSuite) TestSetAccount() { testCases := []struct { name string address common.Address - account statedb.Account + account types.StateDBAccount expectedErr error }{ { "new account, non-contract account", tests.GenerateAddress(), - statedb.Account{10, big.NewInt(100), types.EmptyCodeHash}, + types.StateDBAccount{10, big.NewInt(100), types.EmptyCodeHash}, nil, }, { "new account, contract account", tests.GenerateAddress(), - statedb.Account{10, big.NewInt(100), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, + types.StateDBAccount{10, big.NewInt(100), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, nil, }, { "existing eth account, non-contract account", ethAddr, - statedb.Account{10, big.NewInt(1), types.EmptyCodeHash}, + types.StateDBAccount{10, big.NewInt(1), types.EmptyCodeHash}, nil, }, { "existing eth account, contract account", ethAddr, - statedb.Account{10, big.NewInt(0), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, + types.StateDBAccount{10, big.NewInt(0), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, nil, }, { "existing base account, non-contract account", baseAddr, - statedb.Account{10, big.NewInt(10), types.EmptyCodeHash}, + types.StateDBAccount{10, big.NewInt(10), types.EmptyCodeHash}, nil, }, { "existing base account, contract account", baseAddr, - statedb.Account{10, big.NewInt(99), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, + types.StateDBAccount{10, big.NewInt(99), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, nil, }, { "existing vesting account, non-contract account", vestingAddr, - statedb.Account{10, big.NewInt(1000), types.EmptyCodeHash}, + types.StateDBAccount{10, big.NewInt(1000), types.EmptyCodeHash}, nil, }, { "existing vesting account, contract account", vestingAddr, - statedb.Account{10, big.NewInt(1001), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, + types.StateDBAccount{10, big.NewInt(1001), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, types.ErrInvalidAccount, }, } @@ -791,7 +791,7 @@ func (suite *KeeperTestSuite) TestAddLog() { for _, tc := range testCases { suite.Run(tc.name, func() { suite.SetupTest() - vmdb := statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewTxConfig( + vmdb := statedb.New(suite.ctx, suite.app.EvmKeeper, types.NewTxConfig( common.BytesToHash(suite.ctx.HeaderHash().Bytes()), tc.hash, 0, 0, diff --git a/x/evm/migrations/v3/store_test.go b/x/evm/migrations/v3/store_test.go index a01916a6f7..12ff79409a 100644 --- a/x/evm/migrations/v3/store_test.go +++ b/x/evm/migrations/v3/store_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/evmos/ethermint/x/evm/keeper" + "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" "github.com/evmos/ethermint/x/evm/vm/geth" "github.com/stretchr/testify/require" @@ -151,6 +152,7 @@ func TestKeyTableCompatiabilityWithKeeper(t *testing.T) { ak, nil, nil, nil, nil, geth.NewEVM, + statedb.New, "", subspace, ) diff --git a/x/evm/statedb/config.go b/x/evm/statedb/config.go index d9baa5387f..445ae0d47c 100644 --- a/x/evm/statedb/config.go +++ b/x/evm/statedb/config.go @@ -23,35 +23,6 @@ import ( "github.com/evmos/ethermint/x/evm/types" ) -// TxConfig encapulates the readonly information of current tx for `StateDB`. -type TxConfig struct { - BlockHash common.Hash // hash of current block - TxHash common.Hash // hash of current tx - TxIndex uint // the index of current transaction - LogIndex uint // the index of next log within current block -} - -// NewTxConfig returns a TxConfig -func NewTxConfig(bhash, thash common.Hash, txIndex, logIndex uint) TxConfig { - return TxConfig{ - BlockHash: bhash, - TxHash: thash, - TxIndex: txIndex, - LogIndex: logIndex, - } -} - -// NewEmptyTxConfig construct an empty TxConfig, -// used in context where there's no transaction, e.g. `eth_call`/`eth_estimateGas`. -func NewEmptyTxConfig(bhash common.Hash) TxConfig { - return TxConfig{ - BlockHash: bhash, - TxHash: common.Hash{}, - TxIndex: 0, - LogIndex: 0, - } -} - // EVMConfig encapsulates common parameters needed to create an EVM to execute a message // It's mainly to reduce the number of method parameters type EVMConfig struct { diff --git a/x/evm/statedb/interfaces.go b/x/evm/statedb/interfaces.go index e4e83e09c3..eb8494d719 100644 --- a/x/evm/statedb/interfaces.go +++ b/x/evm/statedb/interfaces.go @@ -16,8 +16,6 @@ package statedb import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" ) @@ -30,19 +28,3 @@ type ExtStateDB interface { vm.StateDB AppendJournalEntry(JournalEntry) } - -// Keeper provide underlying storage of StateDB -type Keeper interface { - // Read methods - GetAccount(ctx sdk.Context, addr common.Address) *Account - GetState(ctx sdk.Context, addr common.Address, key common.Hash) common.Hash - GetCode(ctx sdk.Context, codeHash common.Hash) []byte - // the callback returns false to break early - ForEachStorage(ctx sdk.Context, addr common.Address, cb func(key, value common.Hash) bool) - - // Write methods, only called by `StateDB.Commit()` - SetAccount(ctx sdk.Context, addr common.Address, account Account) error - SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte) - SetCode(ctx sdk.Context, codeHash []byte, code []byte) - DeleteAccount(ctx sdk.Context, addr common.Address) error -} diff --git a/x/evm/statedb/mock_test.go b/x/evm/statedb/mock_test.go index 544cbfa1b4..88c270ed5e 100644 --- a/x/evm/statedb/mock_test.go +++ b/x/evm/statedb/mock_test.go @@ -9,16 +9,18 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/evmos/ethermint/x/evm/statedb" + "github.com/evmos/ethermint/x/evm/types" + "github.com/evmos/ethermint/x/evm/vm" ) var ( - _ statedb.Keeper = &MockKeeper{} - errAddress common.Address = common.BigToAddress(big.NewInt(100)) - emptyCodeHash = crypto.Keccak256(nil) + _ vm.StateDBKeeper = &MockKeeper{} + errAddress common.Address = common.BigToAddress(big.NewInt(100)) + emptyCodeHash = crypto.Keccak256(nil) ) type MockAcount struct { - account statedb.Account + account types.StateDBAccount states statedb.Storage } @@ -34,7 +36,7 @@ func NewMockKeeper() *MockKeeper { } } -func (k MockKeeper) GetAccount(ctx sdk.Context, addr common.Address) *statedb.Account { +func (k MockKeeper) GetAccount(ctx sdk.Context, addr common.Address) *types.StateDBAccount { acct, ok := k.accounts[addr] if !ok { return nil @@ -60,7 +62,7 @@ func (k MockKeeper) ForEachStorage(ctx sdk.Context, addr common.Address, cb func } } -func (k MockKeeper) SetAccount(ctx sdk.Context, addr common.Address, account statedb.Account) error { +func (k MockKeeper) SetAccount(ctx sdk.Context, addr common.Address, account types.StateDBAccount) error { if addr == errAddress { return errors.New("mock db error") } diff --git a/x/evm/statedb/state_object.go b/x/evm/statedb/state_object.go index dd344dfadb..485e836191 100644 --- a/x/evm/statedb/state_object.go +++ b/x/evm/statedb/state_object.go @@ -22,31 +22,11 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/evmos/ethermint/x/evm/types" ) var emptyCodeHash = crypto.Keccak256(nil) -// Account is the Ethereum consensus representation of accounts. -// These objects are stored in the storage of auth module. -type Account struct { - Nonce uint64 - Balance *big.Int - CodeHash []byte -} - -// NewEmptyAccount returns an empty account. -func NewEmptyAccount() *Account { - return &Account{ - Balance: new(big.Int), - CodeHash: emptyCodeHash, - } -} - -// IsContract returns if the account contains contract code. -func (acct Account) IsContract() bool { - return !bytes.Equal(acct.CodeHash, emptyCodeHash) -} - // Storage represents in-memory cache/buffer of contract storage. type Storage map[common.Hash]common.Hash @@ -68,7 +48,7 @@ func (s Storage) SortedKeys() []common.Hash { type stateObject struct { db *StateDB - account Account + account types.StateDBAccount code []byte // state storage @@ -83,7 +63,7 @@ type stateObject struct { } // newObject creates a state object. -func newObject(db *StateDB, address common.Address, account Account) *stateObject { +func newObject(db *StateDB, address common.Address, account types.StateDBAccount) *stateObject { if account.Balance == nil { account.Balance = new(big.Int) } diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 941cb0c21b..5a254efc18 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -26,6 +26,8 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" + "github.com/evmos/ethermint/x/evm/types" + evm "github.com/evmos/ethermint/x/evm/vm" ) // revision is the identifier of a version of state. @@ -44,7 +46,7 @@ var _ vm.StateDB = &StateDB{} // * Contracts // * Accounts type StateDB struct { - keeper Keeper + keeper evm.StateDBKeeper ctx sdk.Context // Journal of state modifications. This is the backbone of @@ -55,7 +57,7 @@ type StateDB struct { stateObjects map[common.Address]*stateObject - txConfig TxConfig + txConfig types.TxConfig // The refund counter, also used by state transitioning. refund uint64 @@ -68,7 +70,7 @@ type StateDB struct { } // New creates a new state from a given trie. -func New(ctx sdk.Context, keeper Keeper, txConfig TxConfig) *StateDB { +func New(ctx sdk.Context, keeper evm.StateDBKeeper, txConfig types.TxConfig) evm.StateDB { return &StateDB{ keeper: keeper, ctx: ctx, @@ -81,7 +83,7 @@ func New(ctx sdk.Context, keeper Keeper, txConfig TxConfig) *StateDB { } // Keeper returns the underlying `Keeper` -func (s *StateDB) Keeper() Keeper { +func (s *StateDB) Keeper() evm.StateDBKeeper { return s.keeper } @@ -246,7 +248,7 @@ func (s *StateDB) getOrNewStateObject(addr common.Address) *stateObject { func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject) { prev = s.getStateObject(addr) - newobj = newObject(s, addr, Account{}) + newobj = newObject(s, addr, types.StateDBAccount{}) if prev == nil { s.journal.append(createObjectChange{account: &addr}) } else { diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index 3a491aa8cc..cac980e92e 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -10,15 +10,17 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/evmos/ethermint/x/evm/statedb" + "github.com/evmos/ethermint/x/evm/types" + evm "github.com/evmos/ethermint/x/evm/vm" "github.com/stretchr/testify/suite" ) var ( - address common.Address = common.BigToAddress(big.NewInt(101)) - address2 common.Address = common.BigToAddress(big.NewInt(102)) - address3 common.Address = common.BigToAddress(big.NewInt(103)) - blockHash common.Hash = common.BigToHash(big.NewInt(9999)) - emptyTxConfig statedb.TxConfig = statedb.NewEmptyTxConfig(blockHash) + address common.Address = common.BigToAddress(big.NewInt(101)) + address2 common.Address = common.BigToAddress(big.NewInt(102)) + address3 common.Address = common.BigToAddress(big.NewInt(103)) + blockHash common.Hash = common.BigToHash(big.NewInt(9999)) + emptyTxConfig types.TxConfig = types.NewEmptyTxConfig(blockHash) ) type StateDBTestSuite struct { @@ -32,9 +34,9 @@ func (suite *StateDBTestSuite) TestAccount() { value2 := common.BigToHash(big.NewInt(4)) testCases := []struct { name string - malleate func(*statedb.StateDB) + malleate func(evm.StateDB) }{ - {"non-exist account", func(db *statedb.StateDB) { + {"non-exist account", func(db evm.StateDB) { suite.Require().Equal(false, db.Exist(address)) suite.Require().Equal(true, db.Empty(address)) suite.Require().Equal(big.NewInt(0), db.GetBalance(address)) @@ -42,13 +44,13 @@ func (suite *StateDBTestSuite) TestAccount() { suite.Require().Equal(common.Hash{}, db.GetCodeHash(address)) suite.Require().Equal(uint64(0), db.GetNonce(address)) }}, - {"empty account", func(db *statedb.StateDB) { + {"empty account", func(db evm.StateDB) { db.CreateAccount(address) suite.Require().NoError(db.Commit()) keeper := db.Keeper().(*MockKeeper) acct := keeper.accounts[address] - suite.Require().Equal(statedb.NewEmptyAccount(), &acct.account) + suite.Require().Equal(types.NewEmptyAccount(), &acct.account) suite.Require().Empty(acct.states) suite.Require().False(acct.account.IsContract()) @@ -60,7 +62,7 @@ func (suite *StateDBTestSuite) TestAccount() { suite.Require().Equal(common.BytesToHash(emptyCodeHash), db.GetCodeHash(address)) suite.Require().Equal(uint64(0), db.GetNonce(address)) }}, - {"suicide", func(db *statedb.StateDB) { + {"suicide", func(db evm.StateDB) { // non-exist account. suite.Require().False(db.Suicide(address)) suite.Require().False(db.HasSuicided(address)) @@ -150,22 +152,22 @@ func (suite *StateDBTestSuite) TestBalance() { // NOTE: no need to test overflow/underflow, that is guaranteed by evm implementation. testCases := []struct { name string - malleate func(*statedb.StateDB) + malleate func(evm.StateDB) expBalance *big.Int }{ - {"add balance", func(db *statedb.StateDB) { + {"add balance", func(db evm.StateDB) { db.AddBalance(address, big.NewInt(10)) }, big.NewInt(10)}, - {"sub balance", func(db *statedb.StateDB) { + {"sub balance", func(db evm.StateDB) { db.AddBalance(address, big.NewInt(10)) // get dirty balance suite.Require().Equal(big.NewInt(10), db.GetBalance(address)) db.SubBalance(address, big.NewInt(2)) }, big.NewInt(8)}, - {"add zero balance", func(db *statedb.StateDB) { + {"add zero balance", func(db evm.StateDB) { db.AddBalance(address, big.NewInt(0)) }, big.NewInt(0)}, - {"sub zero balance", func(db *statedb.StateDB) { + {"sub zero balance", func(db evm.StateDB) { db.SubBalance(address, big.NewInt(0)) }, big.NewInt(0)}, } @@ -190,19 +192,19 @@ func (suite *StateDBTestSuite) TestState() { value1 := common.BigToHash(big.NewInt(1)) testCases := []struct { name string - malleate func(*statedb.StateDB) + malleate func(evm.StateDB) expStates statedb.Storage }{ - {"empty state", func(db *statedb.StateDB) { + {"empty state", func(db evm.StateDB) { }, nil}, - {"set empty value", func(db *statedb.StateDB) { + {"set empty value", func(db evm.StateDB) { db.SetState(address, key1, common.Hash{}) }, statedb.Storage{}}, - {"noop state change", func(db *statedb.StateDB) { + {"noop state change", func(db evm.StateDB) { db.SetState(address, key1, value1) db.SetState(address, key1, common.Hash{}) }, statedb.Storage{}}, - {"set state", func(db *statedb.StateDB) { + {"set state", func(db evm.StateDB) { // check empty initial state suite.Require().Equal(common.Hash{}, db.GetState(address, key1)) suite.Require().Equal(common.Hash{}, db.GetCommittedState(address, key1)) @@ -466,7 +468,7 @@ func (suite *StateDBTestSuite) TestAccessList() { func (suite *StateDBTestSuite) TestLog() { txHash := common.BytesToHash([]byte("tx")) // use a non-default tx config - txConfig := statedb.NewTxConfig( + txConfig := types.NewTxConfig( blockHash, txHash, 1, 1, diff --git a/x/evm/types/statedb.go b/x/evm/types/statedb.go new file mode 100644 index 0000000000..866cfd3441 --- /dev/null +++ b/x/evm/types/statedb.go @@ -0,0 +1,61 @@ +package types + +import ( + "bytes" + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" +) + +var emptyCodeHash = crypto.Keccak256(nil) + +// StateDBAccount is the Ethereum consensus representation of accounts. +// These objects are stored in the storage of auth module. +type StateDBAccount struct { + Nonce uint64 + Balance *big.Int + CodeHash []byte +} + +// NewEmptyAccount returns an empty account. +func NewEmptyAccount() *StateDBAccount { + return &StateDBAccount{ + Balance: new(big.Int), + CodeHash: emptyCodeHash, + } +} + +// IsContract returns if the account contains contract code. +func (acct StateDBAccount) IsContract() bool { + return !bytes.Equal(acct.CodeHash, emptyCodeHash) +} + +// TxConfig encapulates the readonly information of current tx for `StateDB`. +type TxConfig struct { + BlockHash common.Hash // hash of current block + TxHash common.Hash // hash of current tx + TxIndex uint // the index of current transaction + LogIndex uint // the index of next log within current block +} + +// NewTxConfig returns a TxConfig +func NewTxConfig(bhash, thash common.Hash, txIndex, logIndex uint) TxConfig { + return TxConfig{ + BlockHash: bhash, + TxHash: thash, + TxIndex: txIndex, + LogIndex: logIndex, + } +} + +// NewEmptyTxConfig construct an empty TxConfig, +// used in context where there's no transaction, e.g. `eth_call`/`eth_estimateGas`. +func NewEmptyTxConfig(bhash common.Hash) TxConfig { + return TxConfig{ + BlockHash: bhash, + TxHash: common.Hash{}, + TxIndex: 0, + LogIndex: 0, + } +} diff --git a/x/evm/vm/interface.go b/x/evm/vm/interface.go index f1a6f4f707..9e5d05e6d4 100644 --- a/x/evm/vm/interface.go +++ b/x/evm/vm/interface.go @@ -18,7 +18,11 @@ package vm import ( "math/big" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/evmos/ethermint/x/evm/types" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" "github.com/holiman/uint256" @@ -79,3 +83,43 @@ type Constructor func( config vm.Config, customPrecompiles PrecompiledContracts, ) EVM + +// StateDBKeeper provide underlying storage of StateDB +type StateDBKeeper interface { + // Read methods + GetAccount(ctx sdk.Context, addr common.Address) *types.StateDBAccount + GetState(ctx sdk.Context, addr common.Address, key common.Hash) common.Hash + GetCode(ctx sdk.Context, codeHash common.Hash) []byte + // the callback returns false to break early + ForEachStorage(ctx sdk.Context, addr common.Address, cb func(key, value common.Hash) bool) + + // Write methods, only called by `StateDB.Commit()` + SetAccount(ctx sdk.Context, addr common.Address, account types.StateDBAccount) error + SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte) + SetCode(ctx sdk.Context, codeHash []byte, code []byte) + DeleteAccount(ctx sdk.Context, addr common.Address) error +} + +type StateDB interface { + vm.StateDB + + Keeper() StateDBKeeper + + // Additional methods required by x/evm Keeper + Commit() error + Logs() []*ethtypes.Log +} + +// TxConfig provides readonly information of current tx for `StateDB`. +type TxConfig interface { + BlockHash() common.Hash // hash of current block + TxHash() common.Hash // hash of current tx + TxIndex() uint // the index of current transaction + LogIndex() uint // the index of next log within current block +} + +type StateDBConstructor func( + ctx sdk.Context, + keeper StateDBKeeper, + txConfig types.TxConfig, +) StateDB From 8644185d9826dafae0c41a8500e4c2ea07ab2008 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 8 Jan 2024 15:46:41 -0800 Subject: [PATCH 02/52] Update statedb usage in app --- app/ante/eth.go | 5 +++-- app/ante/eth_test.go | 8 ++++---- app/ante/interfaces.go | 2 +- app/ante/sigs_test.go | 4 ++-- app/ante/utils_test.go | 5 +++-- app/app.go | 3 ++- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/ante/eth.go b/app/ante/eth.go index 2402167be7..90a1c45e54 100644 --- a/app/ante/eth.go +++ b/app/ante/eth.go @@ -28,6 +28,7 @@ import ( ethermint "github.com/evmos/ethermint/types" "github.com/evmos/ethermint/x/evm/keeper" "github.com/evmos/ethermint/x/evm/statedb" + "github.com/evmos/ethermint/x/evm/types" evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/ethereum/go-ethereum/common" @@ -88,7 +89,7 @@ func (avd EthAccountVerificationDecorator) AnteHandle( if acct == nil { acc := avd.ak.NewAccountWithAddress(ctx, from) avd.ak.SetAccount(ctx, acc) - acct = statedb.NewEmptyAccount() + acct = types.NewEmptyAccount() } else if acct.IsContract() { return ctx, errorsmod.Wrapf(errortypes.ErrInvalidType, "the sender is not EOA: address %s, codeHash <%s>", fromAddr, acct.CodeHash) @@ -302,7 +303,7 @@ func (ctd CanTransferDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate BaseFee: baseFee, } - stateDB := statedb.New(ctx, ctd.evmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes()))) + stateDB := statedb.New(ctx, ctd.evmKeeper, types.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes()))) evm := ctd.evmKeeper.NewEVM(ctx, coreMsg, cfg, evmtypes.NewNoOpTracer(), stateDB) // check that caller has enough balance to cover asset transfer for **topmost** call diff --git a/app/ante/eth_test.go b/app/ante/eth_test.go index 0fb9ea8b20..b5dd9dd7f1 100644 --- a/app/ante/eth_test.go +++ b/app/ante/eth_test.go @@ -10,8 +10,8 @@ import ( "github.com/evmos/ethermint/server/config" "github.com/evmos/ethermint/tests" ethermint "github.com/evmos/ethermint/types" - "github.com/evmos/ethermint/x/evm/statedb" evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/evmos/ethermint/x/evm/vm" ethtypes "github.com/ethereum/go-ethereum/core/types" ) @@ -26,7 +26,7 @@ func (suite AnteTestSuite) TestNewEthAccountVerificationDecorator() { tx := evmtypes.NewTxContract(suite.app.EvmKeeper.ChainID(), 1, big.NewInt(10), 1000, big.NewInt(1), nil, nil, nil, nil) tx.From = addr.Hex() - var vmdb *statedb.StateDB + var vmdb vm.StateDB testCases := []struct { name string @@ -192,7 +192,7 @@ func (suite AnteTestSuite) TestEthGasConsumeDecorator() { dynamicFeeTx.From = addr.Hex() dynamicFeeTxPriority := int64(1) - var vmdb *statedb.StateDB + var vmdb vm.StateDB testCases := []struct { name string @@ -352,7 +352,7 @@ func (suite AnteTestSuite) TestCanTransferDecorator() { err := tx.Sign(suite.ethSigner, tests.NewSigner(privKey)) suite.Require().NoError(err) - var vmdb *statedb.StateDB + var vmdb vm.StateDB testCases := []struct { name string diff --git a/app/ante/interfaces.go b/app/ante/interfaces.go index e48e0a50a4..c2bb63cd62 100644 --- a/app/ante/interfaces.go +++ b/app/ante/interfaces.go @@ -41,7 +41,7 @@ type DynamicFeeEVMKeeper interface { // EVMKeeper defines the expected keeper interface used on the Eth AnteHandler type EVMKeeper interface { - statedb.Keeper + evm.StateDBKeeper DynamicFeeEVMKeeper NewEVM(ctx sdk.Context, msg core.Message, cfg *statedb.EVMConfig, tracer vm.EVMLogger, stateDB vm.StateDB) evm.EVM diff --git a/app/ante/sigs_test.go b/app/ante/sigs_test.go index 0c7b0539c8..be87ab15f3 100644 --- a/app/ante/sigs_test.go +++ b/app/ante/sigs_test.go @@ -4,7 +4,7 @@ import ( "math/big" "github.com/evmos/ethermint/tests" - "github.com/evmos/ethermint/x/evm/statedb" + "github.com/evmos/ethermint/x/evm/types" evmtypes "github.com/evmos/ethermint/x/evm/types" ) @@ -15,7 +15,7 @@ func (suite AnteTestSuite) TestSignatures() { addr, privKey := tests.NewAddrKey() to := tests.GenerateAddress() - acc := statedb.NewEmptyAccount() + acc := types.NewEmptyAccount() acc.Nonce = 1 acc.Balance = big.NewInt(10000000000) diff --git a/app/ante/utils_test.go b/app/ante/utils_test.go index c92961c391..e87c82e839 100644 --- a/app/ante/utils_test.go +++ b/app/ante/utils_test.go @@ -53,6 +53,7 @@ import ( "github.com/evmos/ethermint/tests" "github.com/evmos/ethermint/x/evm/statedb" evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/evmos/ethermint/x/evm/vm" feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -73,8 +74,8 @@ type AnteTestSuite struct { const TestGasLimit uint64 = 100000 -func (suite *AnteTestSuite) StateDB() *statedb.StateDB { - return statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()))) +func (suite *AnteTestSuite) StateDB() vm.StateDB { + return statedb.New(suite.ctx, suite.app.EvmKeeper, evmtypes.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()))) } func (suite *AnteTestSuite) SetupTest() { diff --git a/app/app.go b/app/app.go index 7b5f98d319..7191014db5 100644 --- a/app/app.go +++ b/app/app.go @@ -123,6 +123,7 @@ import ( ethermint "github.com/evmos/ethermint/types" "github.com/evmos/ethermint/x/evm" evmkeeper "github.com/evmos/ethermint/x/evm/keeper" + "github.com/evmos/ethermint/x/evm/statedb" evmtypes "github.com/evmos/ethermint/x/evm/types" legacyevmtypes "github.com/evmos/ethermint/x/evm/types/legacy" "github.com/evmos/ethermint/x/evm/vm/geth" @@ -422,7 +423,7 @@ func NewEthermintApp( appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper, - nil, geth.NewEVM, tracer, evmSs, + nil, geth.NewEVM, statedb.New, tracer, evmSs, ) // Create IBC Keeper From f18fd53909e929a63d31e98fb328b699087e0f91 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 8 Feb 2024 13:28:25 -0800 Subject: [PATCH 03/52] fix: Resolve importer test Statedb types --- tests/importer/importer_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/importer/importer_test.go b/tests/importer/importer_test.go index a32a730206..04e8918e29 100644 --- a/tests/importer/importer_test.go +++ b/tests/importer/importer_test.go @@ -18,6 +18,8 @@ import ( evmkeeper "github.com/evmos/ethermint/x/evm/keeper" "github.com/evmos/ethermint/x/evm/statedb" + evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/evmos/ethermint/x/evm/vm" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus/ethash" @@ -140,7 +142,7 @@ func (suite *ImporterTestSuite) TestImportBlocks() { }) ctx := suite.app.NewContext(false, tmheader) ctx = ctx.WithBlockHeight(tmheader.Height) - vmdb := statedb.New(ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes()))) + vmdb := statedb.New(ctx, suite.app.EvmKeeper, evmtypes.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes()))) if chainConfig.DAOForkSupport && chainConfig.DAOForkBlock != nil && chainConfig.DAOForkBlock.Cmp(block.Number()) == 0 { applyDAOHardFork(vmdb) @@ -226,7 +228,7 @@ func applyDAOHardFork(vmdb ethvm.StateDB) { // Ref: https://github.com/ethereum/go-ethereum/blob/52f2461774bcb8cdd310f86b4bc501df5b783852/core/state_processor.go#L88 func applyTransaction( ctx sdk.Context, config *ethparams.ChainConfig, bc ethcore.ChainContext, author *common.Address, - gp *ethcore.GasPool, evmKeeper *evmkeeper.Keeper, vmdb *statedb.StateDB, header *ethtypes.Header, + gp *ethcore.GasPool, evmKeeper *evmkeeper.Keeper, vmdb vm.StateDB, header *ethtypes.Header, tx *ethtypes.Transaction, usedGas *uint64, cfg ethvm.Config, ) (*ethtypes.Receipt, uint64, error) { msg, err := tx.AsMessage(ethtypes.MakeSigner(config, header.Number), sdk.ZeroInt().BigInt()) From 19a0c79189033e8db6aec5f1b58ef669e517d68e Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 8 Feb 2024 13:30:12 -0800 Subject: [PATCH 04/52] Resolve multi import --- app/ante/eth.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/ante/eth.go b/app/ante/eth.go index 90a1c45e54..669afccf3c 100644 --- a/app/ante/eth.go +++ b/app/ante/eth.go @@ -28,7 +28,6 @@ import ( ethermint "github.com/evmos/ethermint/types" "github.com/evmos/ethermint/x/evm/keeper" "github.com/evmos/ethermint/x/evm/statedb" - "github.com/evmos/ethermint/x/evm/types" evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/ethereum/go-ethereum/common" @@ -89,7 +88,7 @@ func (avd EthAccountVerificationDecorator) AnteHandle( if acct == nil { acc := avd.ak.NewAccountWithAddress(ctx, from) avd.ak.SetAccount(ctx, acc) - acct = types.NewEmptyAccount() + acct = evmtypes.NewEmptyAccount() } else if acct.IsContract() { return ctx, errorsmod.Wrapf(errortypes.ErrInvalidType, "the sender is not EOA: address %s, codeHash <%s>", fromAddr, acct.CodeHash) @@ -303,7 +302,7 @@ func (ctd CanTransferDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate BaseFee: baseFee, } - stateDB := statedb.New(ctx, ctd.evmKeeper, types.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes()))) + stateDB := statedb.New(ctx, ctd.evmKeeper, evmtypes.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes()))) evm := ctd.evmKeeper.NewEVM(ctx, coreMsg, cfg, evmtypes.NewNoOpTracer(), stateDB) // check that caller has enough balance to cover asset transfer for **topmost** call From 037a78ba46267aaf2e73ff323361e403f6d07435 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 8 Feb 2024 13:55:49 -0800 Subject: [PATCH 05/52] Remove unused allow-leading-space nolintlint option removed from golangci-lint in v1.49.0 --- .golangci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 96e1bc311f..5765ec22e0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -61,7 +61,6 @@ linters-settings: locale: US nolintlint: allow-unused: false - allow-leading-space: true require-explanation: false require-specific: false gofumpt: From 4410e3a5411a9cf7ef0a43abc2687ceddb285beb Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 8 Feb 2024 14:10:35 -0800 Subject: [PATCH 06/52] resolve lint errors --- app/upgrades.go | 2 +- rpc/websockets.go | 2 +- x/feemarket/client/cli/query.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index 6b6fe2f803..deded1ad3f 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -23,7 +23,7 @@ import ( func (app *EthermintApp) RegisterUpgradeHandlers() { planName := "integration-test-upgrade" - app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { return app.mm.RunMigrations(ctx, app.configurator, fromVM) }) } diff --git a/rpc/websockets.go b/rpc/websockets.go index f13e2c2b77..1904855043 100644 --- a/rpc/websockets.go +++ b/rpc/websockets.go @@ -128,7 +128,7 @@ func (s *websocketsServer) Start() { func (s *websocketsServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { upgrader := websocket.Upgrader{ - CheckOrigin: func(r *http.Request) bool { + CheckOrigin: func(_ *http.Request) bool { return true }, } diff --git a/x/feemarket/client/cli/query.go b/x/feemarket/client/cli/query.go index 79c281f879..78a5b1159e 100644 --- a/x/feemarket/client/cli/query.go +++ b/x/feemarket/client/cli/query.go @@ -50,7 +50,7 @@ func GetBlockGasCmd() *cobra.Command { Long: `Get the block gas used at a given block height. If the height is not provided, it will use the latest height from context`, Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err @@ -108,7 +108,7 @@ func GetBaseFeeCmd() *cobra.Command { Long: `Get the base fee amount at a given block height. If the height is not provided, it will use the latest height from context.`, Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err From 288e48c6e218b35ea40b9f66a1ecb8a338ee7cb7 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 8 Feb 2024 14:13:46 -0800 Subject: [PATCH 07/52] ci: Run workflows on kava/release/** branches --- .github/workflows/build.yml | 3 ++- .github/workflows/labeler.yml | 6 +++--- .github/workflows/lint.yml | 5 +++-- .github/workflows/security.yml | 1 + .github/workflows/test.yml | 1 + 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a1df90ae6..22c0381905 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,6 +3,7 @@ on: pull_request: branches: - main + - kava/release/** jobs: cleanup-runs: @@ -19,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: '1.20' + go-version: "1.20" check-latest: true - uses: technote-space/get-diff-action@v6.1.2 id: git_diff diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index a897fd5d16..4dc39dd5af 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -9,6 +9,6 @@ jobs: triage: runs-on: ubuntu-latest steps: - - uses: actions/labeler@v4 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" + - uses: actions/labeler@v4 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1c23449110..6a60177f4f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,6 +7,7 @@ on: push: branches: - main + - kava/release/** jobs: golangci: name: Run golangci-lint @@ -16,7 +17,7 @@ jobs: # Required: setup-go, for all versions v3.0.0+ of golangci-lint - uses: actions/setup-go@v3 with: - go-version: '1.20' + go-version: "1.20" check-latest: true - uses: actions/checkout@v3 - uses: technote-space/get-diff-action@v6.1.2 @@ -25,7 +26,7 @@ jobs: **/**.go go.mod go.sum - - uses: golangci/golangci-lint-action@v3.3.1 + - uses: golangci/golangci-lint-action@v3.7.0 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: latest diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index c0541dd72a..856520c133 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - kava/release/** jobs: Gosec: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 70099b6b8e..ffa6e9d1e5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,7 @@ on: branches: - main - release/** + - kava/release/** jobs: cleanup-runs: From df33692b6f54a27423343f6a6c3a25d8b4a60018 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 11 Jan 2024 17:17:11 -0800 Subject: [PATCH 08/52] Add basic benchmark --- x/evm/statedb/benchmark_test.go | 103 ++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 x/evm/statedb/benchmark_test.go diff --git a/x/evm/statedb/benchmark_test.go b/x/evm/statedb/benchmark_test.go new file mode 100644 index 0000000000..4da5451309 --- /dev/null +++ b/x/evm/statedb/benchmark_test.go @@ -0,0 +1,103 @@ +package statedb_test + +import ( + "math/big" + "testing" + + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/evmos/ethermint/x/evm/statedb" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + dbm "github.com/tendermint/tm-db" +) + +func NewTestContext() sdk.Context { + storeKey := storetypes.NewKVStoreKey("test") + + db := dbm.NewMemDB() + cms := store.NewCommitMultiStore(db) + + cms.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + if err := cms.LoadLatestVersion(); err != nil { + panic(err) + } + + return sdk.NewContext(cms, tmproto.Header{}, false, log.NewNopLogger()) +} + +func benchmarkNestedSnapshot(b *testing.B, layers int) { + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + + for i := 0; i < layers; i++ { + db.Snapshot() + + key := common.BigToHash(big.NewInt(int64(i))) + value := common.BigToHash(big.NewInt(int64(i + 1))) + db.SetState(address, key, value) + } + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + db.ForEachStorage(address, func(k, v common.Hash) bool { + return true + }) + } +} + +func BenchmarkNestedSnapshot1(b *testing.B) { + benchmarkNestedSnapshot(b, 1) +} + +func BenchmarkNestedSnapshot4(b *testing.B) { + benchmarkNestedSnapshot(b, 4) +} + +func BenchmarkNestedSnapshot8(b *testing.B) { + benchmarkNestedSnapshot(b, 8) +} + +func BenchmarkNestedSnapshot16(b *testing.B) { + benchmarkNestedSnapshot(b, 16) +} + +func benchmarkRevertToSnapshot(b *testing.B, layers int) { + for i := 0; i < b.N; i++ { + // Stop timer for setup -- can't be done before loop since we need to + // reset the database after each revert + // TODO: This takes way too long since RevertToSnapshot is really quick + // compared to the setup + b.StopTimer() + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + + for i := 0; i < layers; i++ { + db.Snapshot() + + key := common.BigToHash(big.NewInt(int64(i))) + value := common.BigToHash(big.NewInt(int64(i + 1))) + db.SetState(address, key, value) + } + b.StartTimer() + + db.RevertToSnapshot(0) + } +} + +func BenchmarkRevertToSnapshot1(b *testing.B) { + benchmarkRevertToSnapshot(b, 1) +} + +func BenchmarkRevertToSnapshot4(b *testing.B) { + benchmarkRevertToSnapshot(b, 4) +} + +func BenchmarkRevertToSnapshot8(b *testing.B) { + benchmarkRevertToSnapshot(b, 8) +} + +func BenchmarkRevertToSnapshot16(b *testing.B) { + benchmarkRevertToSnapshot(b, 16) +} From 6e5e56094595f370d481e5be91122097fcdbd49d Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 11 Jan 2024 17:18:31 -0800 Subject: [PATCH 09/52] Add ctx snapshots and state commits --- x/evm/statedb/state_object.go | 4 +- x/evm/statedb/statedb.go | 95 ++++++++++++++++++++++++++++------- 2 files changed, 79 insertions(+), 20 deletions(-) diff --git a/x/evm/statedb/state_object.go b/x/evm/statedb/state_object.go index 485e836191..e6c7841282 100644 --- a/x/evm/statedb/state_object.go +++ b/x/evm/statedb/state_object.go @@ -136,7 +136,7 @@ func (s *stateObject) Code() []byte { if bytes.Equal(s.CodeHash(), emptyCodeHash) { return nil } - code := s.db.keeper.GetCode(s.db.ctx, common.BytesToHash(s.CodeHash())) + code := s.db.keeper.GetCode(s.db.currentCtx, common.BytesToHash(s.CodeHash())) s.code = code return code } @@ -198,7 +198,7 @@ func (s *stateObject) GetCommittedState(key common.Hash) common.Hash { return value } // If no live objects are available, load it from keeper - value := s.db.keeper.GetState(s.db.ctx, s.Address(), key) + value := s.db.keeper.GetState(s.db.currentCtx, s.Address(), key) s.originStorage[key] = value return value } diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 5a254efc18..7a61334746 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -38,6 +38,12 @@ type revision struct { journalIndex int } +type ctxSnapshot struct { + id int + ctx sdk.Context + write func() +} + var _ vm.StateDB = &StateDB{} // StateDB structs within the ethereum protocol are used to store anything @@ -47,7 +53,15 @@ var _ vm.StateDB = &StateDB{} // * Accounts type StateDB struct { keeper evm.StateDBKeeper - ctx sdk.Context + + // Current currentCtx of the state -- branched on creation and each snapshot + currentCtx sdk.Context + + // Current currentCtxWrite of the state -- calling will apply the state changes to + // the parent ctx + currentCtxWrite func() + + ctxSnapshots []ctxSnapshot // Journal of state modifications. This is the backbone of // Snapshot and RevertToSnapshot. @@ -71,15 +85,25 @@ type StateDB struct { // New creates a new state from a given trie. func New(ctx sdk.Context, keeper evm.StateDBKeeper, txConfig types.TxConfig) evm.StateDB { - return &StateDB{ - keeper: keeper, - ctx: ctx, + statedb := &StateDB{ + keeper: keeper, + currentCtx: ctx, + currentCtxWrite: nil, + + ctxSnapshots: []ctxSnapshot{}, + stateObjects: make(map[common.Address]*stateObject), journal: newJournal(), accessList: newAccessList(), txConfig: txConfig, } + + // Create an initial cache ctx branch so we don't modify parent Context + // without calling Commit() + _ = statedb.Snapshot() + + return statedb } // Keeper returns the underlying `Keeper` @@ -224,7 +248,7 @@ func (s *StateDB) getStateObject(addr common.Address) *stateObject { return obj } // If no live objects are available, load it from keeper - account := s.keeper.GetAccount(s.ctx, addr) + account := s.keeper.GetAccount(s.currentCtx, addr) if account == nil { return nil } @@ -284,7 +308,7 @@ func (s *StateDB) ForEachStorage(addr common.Address, cb func(key, value common. if so == nil { return nil } - s.keeper.ForEachStorage(s.ctx, addr, func(key, value common.Hash) bool { + s.keeper.ForEachStorage(s.currentCtx, addr, func(key, value common.Hash) bool { if value, dirty := so.dirtyStorage[key]; dirty { return cb(key, value) } @@ -431,39 +455,74 @@ func (s *StateDB) Snapshot() int { id := s.nextRevisionID s.nextRevisionID++ s.validRevisions = append(s.validRevisions, revision{id, s.journal.length()}) + + // Save the current context (cached multi-store and events) + write function + // to apply the snapshot to the parent store + s.ctxSnapshots = append(s.ctxSnapshots, ctxSnapshot{ + id: id, + ctx: s.currentCtx, + write: s.currentCtxWrite, + }) + + // Branch off a new CacheMultiStore + write function + newCtx, write := s.currentCtx.CacheContext() + + // Update ctx to the new branch + s.currentCtx = newCtx + s.currentCtxWrite = write + return id } // RevertToSnapshot reverts all state changes made since the given revision. func (s *StateDB) RevertToSnapshot(revid int) { // Find the snapshot in the stack of valid snapshots. - idx := sort.Search(len(s.validRevisions), func(i int) bool { - return s.validRevisions[i].id >= revid + idx := sort.Search(len(s.ctxSnapshots), func(i int) bool { + return s.ctxSnapshots[i].id >= revid }) - if idx == len(s.validRevisions) || s.validRevisions[idx].id != revid { + + if idx == len(s.ctxSnapshots) || s.ctxSnapshots[idx].id != revid { panic(fmt.Errorf("revision id %v cannot be reverted", revid)) } - snapshot := s.validRevisions[idx].journalIndex - // Replay the journal to undo changes and remove invalidated snapshots - s.journal.Revert(s, snapshot) - s.validRevisions = s.validRevisions[:idx] + // Update current ctx to the snapshot ctx + s.currentCtx = s.ctxSnapshots[idx].ctx + + // Remove invalidated snapshots + s.ctxSnapshots = s.ctxSnapshots[:idx] } -// Commit writes the dirty states to keeper // the StateDB object should be discarded after committed. func (s *StateDB) Commit() error { + // Write snapshots from newest to oldest. + // Each store.Write() applies the state changes to its parent / previous snapshot + for i := len(s.ctxSnapshots) - 1; i >= 0; i-- { + snapshot := s.ctxSnapshots[i] + + // write() will be nil for the root snapshot that was created on New() + // Root ctx won't need write() since it isn't a CacheContext + if snapshot.write != nil { + snapshot.write() + } + } + + return nil +} + +// Commit writes the dirty states to keeper +// the StateDB object should be discarded after committed. +func (s *StateDB) CommitOld() error { for _, addr := range s.journal.sortedDirties() { obj := s.stateObjects[addr] if obj.suicided { - if err := s.keeper.DeleteAccount(s.ctx, obj.Address()); err != nil { + if err := s.keeper.DeleteAccount(s.currentCtx, obj.Address()); err != nil { return errorsmod.Wrap(err, "failed to delete account") } } else { if obj.code != nil && obj.dirtyCode { - s.keeper.SetCode(s.ctx, obj.CodeHash(), obj.code) + s.keeper.SetCode(s.currentCtx, obj.CodeHash(), obj.code) } - if err := s.keeper.SetAccount(s.ctx, obj.Address(), obj.account); err != nil { + if err := s.keeper.SetAccount(s.currentCtx, obj.Address(), obj.account); err != nil { return errorsmod.Wrap(err, "failed to set account") } for _, key := range obj.dirtyStorage.SortedKeys() { @@ -472,7 +531,7 @@ func (s *StateDB) Commit() error { if value == obj.originStorage[key] { continue } - s.keeper.SetState(s.ctx, obj.Address(), key, value.Bytes()) + s.keeper.SetState(s.currentCtx, obj.Address(), key, value.Bytes()) } } } From 527026e57b74683d5341da35ccf9c63e9da3b002 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Fri, 12 Jan 2024 13:54:28 -0800 Subject: [PATCH 10/52] Create access list with sdk store --- x/evm/statedb/store_access_list.go | 104 +++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 x/evm/statedb/store_access_list.go diff --git a/x/evm/statedb/store_access_list.go b/x/evm/statedb/store_access_list.go new file mode 100644 index 0000000000..f549704533 --- /dev/null +++ b/x/evm/statedb/store_access_list.go @@ -0,0 +1,104 @@ +// Copyright 2020 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package statedb + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + "github.com/ethereum/go-ethereum/common" + + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + storeKey = sdk.NewKVStoreKey("evm-statedb-accesslist") + + AddressKey = []byte{0x01} // common.Address + AddressSlotKey = []byte{0x02} // (common.Address, common.Hash) +) + +type accessList struct { + key storetypes.StoreKey +} + +// ContainsAddress returns true if the address is in the access list. +func (al *accessList) ContainsAddress(ctx sdk.Context, address common.Address) bool { + store := prefix.NewStore(ctx.KVStore(al.key), AddressKey) + return store.Has(address.Bytes()) +} + +// Contains checks if a slot within an account is present in the access list, returning +// separate flags for the presence of the account and the slot respectively. +func (al *accessList) Contains( + ctx sdk.Context, + address common.Address, + slot common.Hash, +) (addressPresent bool, slotPresent bool) { + addressPresent = al.ContainsAddress(ctx, address) + if !addressPresent { + // no address so no slots + return false, false + } + + store := prefix.NewStore(ctx.KVStore(al.key), AddressSlotKey) + slotPresent = store.Has(append(address.Bytes(), slot.Bytes()...)) + + return true, slotPresent +} + +// newAccessList creates a new accessList. +func newAccessList(storeKey storetypes.StoreKey) *accessList { + return &accessList{ + key: storeKey, + } +} + +// AddAddress adds an address to the access list, and returns 'true' if the operation +// caused a change (addr was not previously in the list). +func (al *accessList) AddAddress(ctx sdk.Context, address common.Address) bool { + store := prefix.NewStore(ctx.KVStore(al.key), AddressKey) + if store.Has(address.Bytes()) { + return false + } + + store.Set(address.Bytes(), []byte{}) + return true +} + +// AddSlot adds the specified (addr, slot) combo to the access list. +// Return values are: +// - address added +// - slot added +// For any 'true' value returned, a corresponding journal entry must be made. +func (al *accessList) AddSlot( + ctx sdk.Context, + address common.Address, + slot common.Hash, +) (addrChange bool, slotChange bool) { + // Add address if not present + addrChange = al.AddAddress(ctx, address) + + // Add slot if not present + store := prefix.NewStore(ctx.KVStore(al.key), AddressSlotKey) + if store.Has(append(address.Bytes(), slot.Bytes()...)) { + // Already contains the slot + return addrChange, false + } + + store.Set(append(address.Bytes(), slot.Bytes()...), []byte{}) + return addrChange, true +} From 827de28ad441541fc36859fd0084f71dd47b6868 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Fri, 12 Jan 2024 14:55:02 -0800 Subject: [PATCH 11/52] Add prototype store for logs and refund --- x/evm/statedb/{journal.go => _journal.go} | 0 x/evm/statedb/access_list.go | 20 ++-- x/evm/statedb/benchmark_test.go | 120 ++++++++++++++++++++++ x/evm/statedb/statedb.go | 118 ++++++++------------- x/evm/statedb/store.go | 99 ++++++++++++++++++ x/evm/statedb/store_access_list.go | 15 +-- 6 files changed, 274 insertions(+), 98 deletions(-) rename x/evm/statedb/{journal.go => _journal.go} (100%) create mode 100644 x/evm/statedb/store.go diff --git a/x/evm/statedb/journal.go b/x/evm/statedb/_journal.go similarity index 100% rename from x/evm/statedb/journal.go rename to x/evm/statedb/_journal.go diff --git a/x/evm/statedb/access_list.go b/x/evm/statedb/access_list.go index 4513a91641..de67fc9181 100644 --- a/x/evm/statedb/access_list.go +++ b/x/evm/statedb/access_list.go @@ -20,20 +20,20 @@ import ( "github.com/ethereum/go-ethereum/common" ) -type accessList struct { +type accessListOld struct { addresses map[common.Address]int slots []map[common.Hash]struct{} } // ContainsAddress returns true if the address is in the access list. -func (al *accessList) ContainsAddress(address common.Address) bool { +func (al *accessListOld) ContainsAddress(address common.Address) bool { _, ok := al.addresses[address] return ok } // Contains checks if a slot within an account is present in the access list, returning // separate flags for the presence of the account and the slot respectively. -func (al *accessList) Contains(address common.Address, slot common.Hash) (addressPresent bool, slotPresent bool) { +func (al *accessListOld) Contains(address common.Address, slot common.Hash) (addressPresent bool, slotPresent bool) { idx, ok := al.addresses[address] if !ok { // no such address (and hence zero slots) @@ -47,16 +47,16 @@ func (al *accessList) Contains(address common.Address, slot common.Hash) (addres return true, slotPresent } -// newAccessList creates a new accessList. -func newAccessList() *accessList { - return &accessList{ +// newaccessListOld creates a new accessListOld. +func newaccessListOld() *accessListOld { + return &accessListOld{ addresses: make(map[common.Address]int), } } // AddAddress adds an address to the access list, and returns 'true' if the operation // caused a change (addr was not previously in the list). -func (al *accessList) AddAddress(address common.Address) bool { +func (al *accessListOld) AddAddress(address common.Address) bool { if _, present := al.addresses[address]; present { return false } @@ -69,7 +69,7 @@ func (al *accessList) AddAddress(address common.Address) bool { // - address added // - slot added // For any 'true' value returned, a corresponding journal entry must be made. -func (al *accessList) AddSlot(address common.Address, slot common.Hash) (addrChange bool, slotChange bool) { +func (al *accessListOld) AddSlot(address common.Address, slot common.Hash) (addrChange bool, slotChange bool) { idx, addrPresent := al.addresses[address] if !addrPresent || idx == -1 { // Address not present, or addr present but no slots there @@ -93,7 +93,7 @@ func (al *accessList) AddSlot(address common.Address, slot common.Hash) (addrCha // This operation needs to be performed in the same order as the addition happened. // This method is meant to be used by the journal, which maintains ordering of // operations. -func (al *accessList) DeleteSlot(address common.Address, slot common.Hash) { +func (al *accessListOld) DeleteSlot(address common.Address, slot common.Hash) { idx, addrOk := al.addresses[address] if !addrOk { panic("reverting slot change, address not present in list") @@ -113,6 +113,6 @@ func (al *accessList) DeleteSlot(address common.Address, slot common.Hash) { // needs to be performed in the same order as the addition happened. // This method is meant to be used by the journal, which maintains ordering of // operations. -func (al *accessList) DeleteAddress(address common.Address) { +func (al *accessListOld) DeleteAddress(address common.Address) { delete(al.addresses, address) } diff --git a/x/evm/statedb/benchmark_test.go b/x/evm/statedb/benchmark_test.go index 4da5451309..fe48645efb 100644 --- a/x/evm/statedb/benchmark_test.go +++ b/x/evm/statedb/benchmark_test.go @@ -12,6 +12,8 @@ import ( "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" + + ethtypes "github.com/ethereum/go-ethereum/core/types" ) func NewTestContext() sdk.Context { @@ -101,3 +103,121 @@ func BenchmarkRevertToSnapshot8(b *testing.B) { func BenchmarkRevertToSnapshot16(b *testing.B) { benchmarkRevertToSnapshot(b, 16) } + +func BenchmarkAddBalance(b *testing.B) { + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + db.AddBalance(address, big.NewInt(1)) + } +} + +func BenchmarkSubBalance(b *testing.B) { + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + db.SubBalance(address, big.NewInt(1)) + } +} + +func BenchmarkGetBalance(b *testing.B) { + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + db.GetBalance(address) + } +} + +func BenchmarkGetNonce(b *testing.B) { + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + db.GetNonce(address) + } +} + +func BenchmarkSetNonce(b *testing.B) { + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + db.SetNonce(address, 1) + } +} + +func BenchmarkGetCodeHash(b *testing.B) { + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + db.GetCodeHash(address) + } +} + +func BenchmarkGetCode(b *testing.B) { + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + db.GetCode(address) + } +} + +func BenchmarkAddLog(b *testing.B) { + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + log := ðtypes.Log{ + Address: address, + Topics: []common.Hash{common.BigToHash(big.NewInt(1))}, + } + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + db.AddLog(log) + } +} + +func benchmarkGetLogs(b *testing.B, logEntries int) { + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + + for i := 0; i < logEntries; i++ { + log := ðtypes.Log{ + Address: address, + Topics: []common.Hash{common.BigToHash(big.NewInt(int64(i)))}, + } + db.AddLog(log) + } + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + db.Logs() + } +} + +func BenchmarkGetLogs1(b *testing.B) { + benchmarkGetLogs(b, 1) +} + +func BenchmarkGetLogs8(b *testing.B) { + benchmarkGetLogs(b, 8) +} + +func BenchmarkGetLogs64(b *testing.B) { + benchmarkGetLogs(b, 64) +} + +func BenchmarkGetLogs512(b *testing.B) { + benchmarkGetLogs(b, 512) +} diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 7a61334746..374df36ede 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -20,7 +20,8 @@ import ( "math/big" "sort" - errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -28,6 +29,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/evmos/ethermint/x/evm/types" evm "github.com/evmos/ethermint/x/evm/vm" + dbm "github.com/tendermint/tm-db" ) // revision is the identifier of a version of state. @@ -54,22 +56,24 @@ var _ vm.StateDB = &StateDB{} type StateDB struct { keeper evm.StateDBKeeper - // Current currentCtx of the state -- branched on creation and each snapshot + // current branched sdk.Context -- branched on creation and each snapshot currentCtx sdk.Context - - // Current currentCtxWrite of the state -- calling will apply the state changes to - // the parent ctx + // write function of currentCtx currentCtxWrite func() - ctxSnapshots []ctxSnapshot + // Snapshots of Ctx, each a CacheContext branch of the previous one + ctxSnapshots []ctxSnapshot + nextSnapshotID int + + logStore *StateDBStore // Journal of state modifications. This is the backbone of // Snapshot and RevertToSnapshot. - journal *journal - validRevisions []revision - nextRevisionID int + // journal *journal + // validRevisions []revision + // nextRevisionID int - stateObjects map[common.Address]*stateObject + // stateObjects map[common.Address]*stateObject txConfig types.TxConfig @@ -85,16 +89,27 @@ type StateDB struct { // New creates a new state from a given trie. func New(ctx sdk.Context, keeper evm.StateDBKeeper, txConfig types.TxConfig) evm.StateDB { + // Create an in-memory DB for accessList which does not need to be committed + // to underlying state. + // + // Why do we use this instead of a simple map? + // Because Snapshot() will then also apply to the accessList without needing + // to keep a separate snapshot of the accessList. + db := dbm.NewMemDB() + cms := store.NewCommitMultiStore(db) + cms.MountStoreWithDB(storeKey, storetypes.StoreTypeMemory, db) + statedb := &StateDB{ keeper: keeper, currentCtx: ctx, currentCtxWrite: nil, - ctxSnapshots: []ctxSnapshot{}, + ctxSnapshots: []ctxSnapshot{}, + nextSnapshotID: 0, + + accessList: newAccessList(storeKey), - stateObjects: make(map[common.Address]*stateObject), - journal: newJournal(), - accessList: newAccessList(), + logStore: NewStateDBStore(storeKey), txConfig: txConfig, } @@ -113,34 +128,28 @@ func (s *StateDB) Keeper() evm.StateDBKeeper { // AddLog adds a log, called by evm. func (s *StateDB) AddLog(log *ethtypes.Log) { - s.journal.append(addLogChange{}) - log.TxHash = s.txConfig.TxHash log.BlockHash = s.txConfig.BlockHash log.TxIndex = s.txConfig.TxIndex log.Index = s.txConfig.LogIndex + uint(len(s.logs)) - s.logs = append(s.logs, log) + + s.logStore.AddLog(s.currentCtx, log) } // Logs returns the logs of current transaction. func (s *StateDB) Logs() []*ethtypes.Log { - return s.logs + return s.logStore.GetAllLogs(s.currentCtx) } // AddRefund adds gas to the refund counter func (s *StateDB) AddRefund(gas uint64) { - s.journal.append(refundChange{prev: s.refund}) - s.refund += gas + s.logStore.AddRefund(s.currentCtx, gas) } // SubRefund removes gas from the refund counter. // This method will panic if the refund counter goes below zero func (s *StateDB) SubRefund(gas uint64) { - s.journal.append(refundChange{prev: s.refund}) - if gas > s.refund { - panic(fmt.Sprintf("Refund counter below zero (gas: %d > refund: %d)", gas, s.refund)) - } - s.refund -= gas + s.logStore.SubRefund(s.currentCtx, gas) } // Exist reports whether the given account address exists in the state. @@ -222,7 +231,7 @@ func (s *StateDB) GetCommittedState(addr common.Address, hash common.Hash) commo // GetRefund returns the current value of the refund counter. func (s *StateDB) GetRefund() uint64 { - return s.refund + return s.logStore.GetRefund(s.currentCtx) } // HasSuicided returns if the contract is suicided in current transaction. @@ -417,44 +426,28 @@ func (s *StateDB) PrepareAccessList(sender common.Address, dst *common.Address, // AddAddressToAccessList adds the given address to the access list func (s *StateDB) AddAddressToAccessList(addr common.Address) { - if s.accessList.AddAddress(addr) { - s.journal.append(accessListAddAccountChange{&addr}) - } + _ = s.accessList.AddAddress(s.currentCtx, addr) } // AddSlotToAccessList adds the given (address, slot)-tuple to the access list func (s *StateDB) AddSlotToAccessList(addr common.Address, slot common.Hash) { - addrMod, slotMod := s.accessList.AddSlot(addr, slot) - if addrMod { - // In practice, this should not happen, since there is no way to enter the - // scope of 'address' without having the 'address' become already added - // to the access list (via call-variant, create, etc). - // Better safe than sorry, though - s.journal.append(accessListAddAccountChange{&addr}) - } - if slotMod { - s.journal.append(accessListAddSlotChange{ - address: &addr, - slot: &slot, - }) - } + _, _ = s.accessList.AddSlot(s.currentCtx, addr, slot) } // AddressInAccessList returns true if the given address is in the access list. func (s *StateDB) AddressInAccessList(addr common.Address) bool { - return s.accessList.ContainsAddress(addr) + return s.accessList.ContainsAddress(s.currentCtx, addr) } // SlotInAccessList returns true if the given (address, slot)-tuple is in the access list. func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addressPresent bool, slotPresent bool) { - return s.accessList.Contains(addr, slot) + return s.accessList.Contains(s.currentCtx, addr, slot) } // Snapshot returns an identifier for the current revision of the state. func (s *StateDB) Snapshot() int { - id := s.nextRevisionID - s.nextRevisionID++ - s.validRevisions = append(s.validRevisions, revision{id, s.journal.length()}) + id := s.nextSnapshotID + s.nextSnapshotID++ // Save the current context (cached multi-store and events) + write function // to apply the snapshot to the parent store @@ -508,32 +501,3 @@ func (s *StateDB) Commit() error { return nil } - -// Commit writes the dirty states to keeper -// the StateDB object should be discarded after committed. -func (s *StateDB) CommitOld() error { - for _, addr := range s.journal.sortedDirties() { - obj := s.stateObjects[addr] - if obj.suicided { - if err := s.keeper.DeleteAccount(s.currentCtx, obj.Address()); err != nil { - return errorsmod.Wrap(err, "failed to delete account") - } - } else { - if obj.code != nil && obj.dirtyCode { - s.keeper.SetCode(s.currentCtx, obj.CodeHash(), obj.code) - } - if err := s.keeper.SetAccount(s.currentCtx, obj.Address(), obj.account); err != nil { - return errorsmod.Wrap(err, "failed to set account") - } - for _, key := range obj.dirtyStorage.SortedKeys() { - value := obj.dirtyStorage[key] - // Skip noop changes, persist actual changes - if value == obj.originStorage[key] { - continue - } - s.keeper.SetState(s.currentCtx, obj.Address(), key, value.Bytes()) - } - } - } - return nil -} diff --git a/x/evm/statedb/store.go b/x/evm/statedb/store.go new file mode 100644 index 0000000000..03f1fbe58a --- /dev/null +++ b/x/evm/statedb/store.go @@ -0,0 +1,99 @@ +package statedb + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + ethtypes "github.com/ethereum/go-ethereum/core/types" +) + +var ( + storeKey = sdk.NewKVStoreKey("evm-statedb") + + AccessListAddressKey = []byte{0x01} // common.Address + AccessListAddressSlotKey = []byte{0x02} // (common.Address, common.Hash) + + LogKey = []byte{0x03} + + RefundKey = []byte{0x04} +) + +type StateDBStore struct { + key storetypes.StoreKey +} + +func NewStateDBStore(storeKey storetypes.StoreKey) *StateDBStore { + return &StateDBStore{ + key: storeKey, + } +} + +// AddLog adds a log to the store. +func (ls *StateDBStore) AddLog(ctx sdk.Context, log *ethtypes.Log) { + store := prefix.NewStore(ctx.KVStore(ls.key), LogKey) + + bz, err := log.MarshalJSON() + if err != nil { + panic(err) + } + store.Set(log.Address.Bytes(), bz) +} + +func (ls *StateDBStore) GetAllLogs(ctx sdk.Context) []*ethtypes.Log { + store := prefix.NewStore(ctx.KVStore(ls.key), LogKey) + + logs := make([]*ethtypes.Log, 0) + + iter := sdk.KVStorePrefixIterator(store, []byte{}) + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + var log ethtypes.Log + err := log.UnmarshalJSON(iter.Value()) + if err != nil { + panic(err) + } + logs = append(logs, &log) + } + + return logs +} + +// AddRefund adds a refund to the store. +func (ls *StateDBStore) AddRefund(ctx sdk.Context, gas uint64) { + store := prefix.NewStore(ctx.KVStore(ls.key), RefundKey) + // Add to existing refund + bz := store.Get([]byte{}) + if bz != nil { + gas += sdk.BigEndianToUint64(bz) + } + + store.Set([]byte{}, sdk.Uint64ToBigEndian(gas)) +} + +func (ls *StateDBStore) SubRefund(ctx sdk.Context, gas uint64) { + store := prefix.NewStore(ctx.KVStore(ls.key), RefundKey) + // Subtract from existing refund + bz := store.Get([]byte{}) + if bz == nil { + panic("no refund to subtract from") + } + + refund := sdk.BigEndianToUint64(bz) + + if refund < gas { + panic("refund is less than gas") + } + + gas = refund - gas + store.Set([]byte{}, sdk.Uint64ToBigEndian(gas)) +} + +func (ls *StateDBStore) GetRefund(ctx sdk.Context) uint64 { + store := prefix.NewStore(ctx.KVStore(ls.key), RefundKey) + bz := store.Get([]byte{}) + if bz == nil { + return 0 + } + return sdk.BigEndianToUint64(bz) +} diff --git a/x/evm/statedb/store_access_list.go b/x/evm/statedb/store_access_list.go index f549704533..20637ae2b4 100644 --- a/x/evm/statedb/store_access_list.go +++ b/x/evm/statedb/store_access_list.go @@ -24,20 +24,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -var ( - storeKey = sdk.NewKVStoreKey("evm-statedb-accesslist") - - AddressKey = []byte{0x01} // common.Address - AddressSlotKey = []byte{0x02} // (common.Address, common.Hash) -) - type accessList struct { key storetypes.StoreKey } // ContainsAddress returns true if the address is in the access list. func (al *accessList) ContainsAddress(ctx sdk.Context, address common.Address) bool { - store := prefix.NewStore(ctx.KVStore(al.key), AddressKey) + store := prefix.NewStore(ctx.KVStore(al.key), AccessListAddressKey) return store.Has(address.Bytes()) } @@ -54,7 +47,7 @@ func (al *accessList) Contains( return false, false } - store := prefix.NewStore(ctx.KVStore(al.key), AddressSlotKey) + store := prefix.NewStore(ctx.KVStore(al.key), AccessListAddressSlotKey) slotPresent = store.Has(append(address.Bytes(), slot.Bytes()...)) return true, slotPresent @@ -70,7 +63,7 @@ func newAccessList(storeKey storetypes.StoreKey) *accessList { // AddAddress adds an address to the access list, and returns 'true' if the operation // caused a change (addr was not previously in the list). func (al *accessList) AddAddress(ctx sdk.Context, address common.Address) bool { - store := prefix.NewStore(ctx.KVStore(al.key), AddressKey) + store := prefix.NewStore(ctx.KVStore(al.key), AccessListAddressKey) if store.Has(address.Bytes()) { return false } @@ -93,7 +86,7 @@ func (al *accessList) AddSlot( addrChange = al.AddAddress(ctx, address) // Add slot if not present - store := prefix.NewStore(ctx.KVStore(al.key), AddressSlotKey) + store := prefix.NewStore(ctx.KVStore(al.key), AccessListAddressSlotKey) if store.Has(append(address.Bytes(), slot.Bytes()...)) { // Already contains the slot return addrChange, false From 76536071200e14c424d28a3eb56661024a88ccb8 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Fri, 12 Jan 2024 16:29:00 -0800 Subject: [PATCH 12/52] Reuse journal for logs and refund, update account methods --- x/evm/statedb/access_list.go | 18 +- x/evm/statedb/{_journal.go => journal.go} | 0 x/evm/statedb/statedb.go | 227 ++++++++++------------ x/evm/statedb/store_access_list.go | 16 +- 4 files changed, 120 insertions(+), 141 deletions(-) rename x/evm/statedb/{_journal.go => journal.go} (100%) diff --git a/x/evm/statedb/access_list.go b/x/evm/statedb/access_list.go index de67fc9181..e5f2c497b8 100644 --- a/x/evm/statedb/access_list.go +++ b/x/evm/statedb/access_list.go @@ -20,20 +20,20 @@ import ( "github.com/ethereum/go-ethereum/common" ) -type accessListOld struct { +type accessList struct { addresses map[common.Address]int slots []map[common.Hash]struct{} } // ContainsAddress returns true if the address is in the access list. -func (al *accessListOld) ContainsAddress(address common.Address) bool { +func (al *accessList) ContainsAddress(address common.Address) bool { _, ok := al.addresses[address] return ok } // Contains checks if a slot within an account is present in the access list, returning // separate flags for the presence of the account and the slot respectively. -func (al *accessListOld) Contains(address common.Address, slot common.Hash) (addressPresent bool, slotPresent bool) { +func (al *accessList) Contains(address common.Address, slot common.Hash) (addressPresent bool, slotPresent bool) { idx, ok := al.addresses[address] if !ok { // no such address (and hence zero slots) @@ -48,15 +48,15 @@ func (al *accessListOld) Contains(address common.Address, slot common.Hash) (add } // newaccessListOld creates a new accessListOld. -func newaccessListOld() *accessListOld { - return &accessListOld{ +func newAccessList() *accessList { + return &accessList{ addresses: make(map[common.Address]int), } } // AddAddress adds an address to the access list, and returns 'true' if the operation // caused a change (addr was not previously in the list). -func (al *accessListOld) AddAddress(address common.Address) bool { +func (al *accessList) AddAddress(address common.Address) bool { if _, present := al.addresses[address]; present { return false } @@ -69,7 +69,7 @@ func (al *accessListOld) AddAddress(address common.Address) bool { // - address added // - slot added // For any 'true' value returned, a corresponding journal entry must be made. -func (al *accessListOld) AddSlot(address common.Address, slot common.Hash) (addrChange bool, slotChange bool) { +func (al *accessList) AddSlot(address common.Address, slot common.Hash) (addrChange bool, slotChange bool) { idx, addrPresent := al.addresses[address] if !addrPresent || idx == -1 { // Address not present, or addr present but no slots there @@ -93,7 +93,7 @@ func (al *accessListOld) AddSlot(address common.Address, slot common.Hash) (addr // This operation needs to be performed in the same order as the addition happened. // This method is meant to be used by the journal, which maintains ordering of // operations. -func (al *accessListOld) DeleteSlot(address common.Address, slot common.Hash) { +func (al *accessList) DeleteSlot(address common.Address, slot common.Hash) { idx, addrOk := al.addresses[address] if !addrOk { panic("reverting slot change, address not present in list") @@ -113,6 +113,6 @@ func (al *accessListOld) DeleteSlot(address common.Address, slot common.Hash) { // needs to be performed in the same order as the addition happened. // This method is meant to be used by the journal, which maintains ordering of // operations. -func (al *accessListOld) DeleteAddress(address common.Address) { +func (al *accessList) DeleteAddress(address common.Address) { delete(al.addresses, address) } diff --git a/x/evm/statedb/_journal.go b/x/evm/statedb/journal.go similarity index 100% rename from x/evm/statedb/_journal.go rename to x/evm/statedb/journal.go diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 374df36ede..46837d9790 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -16,6 +16,7 @@ package statedb import ( + "bytes" "fmt" "math/big" "sort" @@ -69,7 +70,7 @@ type StateDB struct { // Journal of state modifications. This is the backbone of // Snapshot and RevertToSnapshot. - // journal *journal + journal *journal // validRevisions []revision // nextRevisionID int @@ -107,9 +108,9 @@ func New(ctx sdk.Context, keeper evm.StateDBKeeper, txConfig types.TxConfig) evm ctxSnapshots: []ctxSnapshot{}, nextSnapshotID: 0, - accessList: newAccessList(storeKey), - - logStore: NewStateDBStore(storeKey), + journal: newJournal(), + accessList: newAccessList(), + logStore: NewStateDBStore(storeKey), txConfig: txConfig, } @@ -155,30 +156,36 @@ func (s *StateDB) SubRefund(gas uint64) { // Exist reports whether the given account address exists in the state. // Notably this also returns true for suicided accounts. func (s *StateDB) Exist(addr common.Address) bool { - return s.getStateObject(addr) != nil + account := s.keeper.GetAccount(s.currentCtx, addr) + return account != nil } // Empty returns whether the state object is either non-existent // or empty according to the EIP161 specification (balance = nonce = code = 0) func (s *StateDB) Empty(addr common.Address) bool { - so := s.getStateObject(addr) - return so == nil || so.empty() + account := s.keeper.GetAccount(s.currentCtx, addr) + if account == nil { + return true + } + + return account.Balance.Sign() == 0 && account.Nonce == 0 && bytes.Equal(account.CodeHash, emptyCodeHash) } // GetBalance retrieves the balance from the given address or 0 if object not found func (s *StateDB) GetBalance(addr common.Address) *big.Int { - stateObject := s.getStateObject(addr) - if stateObject != nil { - return stateObject.Balance() + account := s.keeper.GetAccount(s.currentCtx, addr) + if account != nil { + return account.Balance } + return common.Big0 } // GetNonce returns the nonce of account, 0 if not exists. func (s *StateDB) GetNonce(addr common.Address) uint64 { - stateObject := s.getStateObject(addr) - if stateObject != nil { - return stateObject.Nonce() + account := s.keeper.GetAccount(s.currentCtx, addr) + if account != nil { + return account.Nonce } return 0 @@ -186,47 +193,49 @@ func (s *StateDB) GetNonce(addr common.Address) uint64 { // GetCode returns the code of account, nil if not exists. func (s *StateDB) GetCode(addr common.Address) []byte { - stateObject := s.getStateObject(addr) - if stateObject != nil { - return stateObject.Code() + account := s.keeper.GetAccount(s.currentCtx, addr) + if account == nil { + return nil } - return nil + + if bytes.Equal(account.CodeHash, emptyCodeHash) { + return nil + } + + return s.keeper.GetCode(s.currentCtx, common.BytesToHash(account.CodeHash)) } // GetCodeSize returns the code size of account. func (s *StateDB) GetCodeSize(addr common.Address) int { - stateObject := s.getStateObject(addr) - if stateObject != nil { - return stateObject.CodeSize() - } - return 0 + code := s.GetCode(addr) + return len(code) } // GetCodeHash returns the code hash of account. func (s *StateDB) GetCodeHash(addr common.Address) common.Hash { - stateObject := s.getStateObject(addr) - if stateObject == nil { + account := s.keeper.GetAccount(s.currentCtx, addr) + if account == nil { return common.Hash{} } - return common.BytesToHash(stateObject.CodeHash()) + + return common.BytesToHash(account.CodeHash) } // GetState retrieves a value from the given account's storage trie. func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash { - stateObject := s.getStateObject(addr) - if stateObject != nil { - return stateObject.GetState(hash) + account := s.getOrNewAccount(addr) + if account == nil { + return common.Hash{} } - return common.Hash{} + + return s.keeper.GetState(s.currentCtx, addr, hash) } // GetCommittedState retrieves a value from the given account's committed storage trie. func (s *StateDB) GetCommittedState(addr common.Address, hash common.Hash) common.Hash { - stateObject := s.getStateObject(addr) - if stateObject != nil { - return stateObject.GetCommittedState(hash) - } - return common.Hash{} + // TODO: Double check or find a cleaner way + // This gets the state from the parent ctx which is the state before Commit() + return s.keeper.GetState(s.ctxSnapshots[0].ctx, addr, hash) } // GetRefund returns the current value of the refund counter. @@ -236,6 +245,9 @@ func (s *StateDB) GetRefund() uint64 { // HasSuicided returns if the contract is suicided in current transaction. func (s *StateDB) HasSuicided(addr common.Address) bool { + // Could be created and then suicided in the same transaction, so we can't + // rely on the existence of the account before the current transaction. + stateObject := s.getStateObject(addr) if stateObject != nil { return stateObject.suicided @@ -249,49 +261,14 @@ func (s *StateDB) HasSuicided(addr common.Address) bool { // to the database. func (s *StateDB) AddPreimage(hash common.Hash, preimage []byte) {} //nolint: revive -// getStateObject retrieves a state object given by the address, returning nil if -// the object is not found. -func (s *StateDB) getStateObject(addr common.Address) *stateObject { - // Prefer live objects if any is available - if obj := s.stateObjects[addr]; obj != nil { - return obj - } - // If no live objects are available, load it from keeper +// getOrNewAccount retrieves a state account or create a new account if nil. +func (s *StateDB) getOrNewAccount(addr common.Address) *types.StateDBAccount { account := s.keeper.GetAccount(s.currentCtx, addr) if account == nil { - return nil + account = &types.StateDBAccount{} } - // Insert into the live set - obj := newObject(s, addr, *account) - s.setStateObject(obj) - return obj -} -// getOrNewStateObject retrieves a state object or create a new state object if nil. -func (s *StateDB) getOrNewStateObject(addr common.Address) *stateObject { - stateObject := s.getStateObject(addr) - if stateObject == nil { - stateObject, _ = s.createObject(addr) - } - return stateObject -} - -// createObject creates a new state object. If there is an existing account with -// the given address, it is overwritten and returned as the second return value. -func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject) { - prev = s.getStateObject(addr) - - newobj = newObject(s, addr, types.StateDBAccount{}) - if prev == nil { - s.journal.append(createObjectChange{account: &addr}) - } else { - s.journal.append(resetObjectChange{prev: prev}) - } - s.setStateObject(newobj) - if prev != nil { - return newobj, prev - } - return newobj, nil + return account } // CreateAccount explicitly creates a state object. If a state object with the address @@ -305,76 +282,65 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject) // // Carrying over the balance ensures that Ether doesn't disappear. func (s *StateDB) CreateAccount(addr common.Address) { - newObj, prev := s.createObject(addr) - if prev != nil { - newObj.setBalance(prev.account.Balance) + account := s.keeper.GetAccount(s.currentCtx, addr) + + if account != nil { + // Only carry over balance, other values are zero'd out ? + account.Balance = account.Balance + s.keeper.SetAccount(s.currentCtx, addr, *account) } } // ForEachStorage iterate the contract storage, the iteration order is not defined. func (s *StateDB) ForEachStorage(addr common.Address, cb func(key, value common.Hash) bool) error { - so := s.getStateObject(addr) - if so == nil { - return nil - } - s.keeper.ForEachStorage(s.currentCtx, addr, func(key, value common.Hash) bool { - if value, dirty := so.dirtyStorage[key]; dirty { - return cb(key, value) - } - if len(value) > 0 { - return cb(key, value) - } - return true - }) + s.keeper.ForEachStorage(s.currentCtx, addr, cb) return nil } -func (s *StateDB) setStateObject(object *stateObject) { - s.stateObjects[object.Address()] = object -} - /* * SETTERS */ // AddBalance adds amount to the account associated with addr. func (s *StateDB) AddBalance(addr common.Address, amount *big.Int) { - stateObject := s.getOrNewStateObject(addr) - if stateObject != nil { - stateObject.AddBalance(amount) + if amount.Sign() == 0 { + return } + + account := s.getOrNewAccount(addr) + + account.Balance = new(big.Int).Add(account.Balance, amount) + s.keeper.SetAccount(s.currentCtx, addr, *account) } // SubBalance subtracts amount from the account associated with addr. func (s *StateDB) SubBalance(addr common.Address, amount *big.Int) { - stateObject := s.getOrNewStateObject(addr) - if stateObject != nil { - stateObject.SubBalance(amount) + if amount.Sign() == 0 { + return } + + account := s.getOrNewAccount(addr) + + account.Balance = new(big.Int).Sub(account.Balance, amount) + s.keeper.SetAccount(s.currentCtx, addr, *account) } // SetNonce sets the nonce of account. func (s *StateDB) SetNonce(addr common.Address, nonce uint64) { - stateObject := s.getOrNewStateObject(addr) - if stateObject != nil { - stateObject.SetNonce(nonce) - } + account := s.getOrNewAccount(addr) + + account.Nonce = nonce + s.keeper.SetAccount(s.currentCtx, addr, *account) } // SetCode sets the code of account. func (s *StateDB) SetCode(addr common.Address, code []byte) { - stateObject := s.getOrNewStateObject(addr) - if stateObject != nil { - stateObject.SetCode(crypto.Keccak256Hash(code), code) - } + s.keeper.SetCode(s.currentCtx, crypto.Keccak256Hash(code).Bytes(), code) } // SetState sets the contract state. func (s *StateDB) SetState(addr common.Address, key, value common.Hash) { - stateObject := s.getOrNewStateObject(addr) - if stateObject != nil { - stateObject.SetState(key, value) - } + s.keeper.SetState(s.currentCtx, addr, key, value.Bytes()) } // Suicide marks the given account as suicided. @@ -383,17 +349,15 @@ func (s *StateDB) SetState(addr common.Address, key, value common.Hash) { // The account's state object is still available until the state is committed, // getStateObject will return a non-nil account after Suicide. func (s *StateDB) Suicide(addr common.Address) bool { - stateObject := s.getStateObject(addr) - if stateObject == nil { + account := s.keeper.GetAccount(s.currentCtx, addr) + + if account == nil { return false } - s.journal.append(suicideChange{ - account: &addr, - prev: stateObject.suicided, - prevbalance: new(big.Int).Set(stateObject.Balance()), - }) - stateObject.markSuicided() - stateObject.account.Balance = new(big.Int) + + if err := s.keeper.DeleteAccount(s.currentCtx, addr); err != nil { + panic(fmt.Errorf("failed to delete account in Suicide(): %w", err)) + } return true } @@ -426,22 +390,37 @@ func (s *StateDB) PrepareAccessList(sender common.Address, dst *common.Address, // AddAddressToAccessList adds the given address to the access list func (s *StateDB) AddAddressToAccessList(addr common.Address) { - _ = s.accessList.AddAddress(s.currentCtx, addr) + if s.accessList.AddAddress(addr) { + s.journal.append(accessListAddAccountChange{&addr}) + } } // AddSlotToAccessList adds the given (address, slot)-tuple to the access list func (s *StateDB) AddSlotToAccessList(addr common.Address, slot common.Hash) { - _, _ = s.accessList.AddSlot(s.currentCtx, addr, slot) + addrMod, slotMod := s.accessList.AddSlot(addr, slot) + if addrMod { + // In practice, this should not happen, since there is no way to enter the + // scope of 'address' without having the 'address' become already added + // to the access list (via call-variant, create, etc). + // Better safe than sorry, though + s.journal.append(accessListAddAccountChange{&addr}) + } + if slotMod { + s.journal.append(accessListAddSlotChange{ + address: &addr, + slot: &slot, + }) + } } // AddressInAccessList returns true if the given address is in the access list. func (s *StateDB) AddressInAccessList(addr common.Address) bool { - return s.accessList.ContainsAddress(s.currentCtx, addr) + return s.accessList.ContainsAddress(addr) } // SlotInAccessList returns true if the given (address, slot)-tuple is in the access list. func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addressPresent bool, slotPresent bool) { - return s.accessList.Contains(s.currentCtx, addr, slot) + return s.accessList.Contains(addr, slot) } // Snapshot returns an identifier for the current revision of the state. diff --git a/x/evm/statedb/store_access_list.go b/x/evm/statedb/store_access_list.go index 20637ae2b4..bd84ee0778 100644 --- a/x/evm/statedb/store_access_list.go +++ b/x/evm/statedb/store_access_list.go @@ -24,19 +24,19 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -type accessList struct { +type sdkAccessList struct { key storetypes.StoreKey } // ContainsAddress returns true if the address is in the access list. -func (al *accessList) ContainsAddress(ctx sdk.Context, address common.Address) bool { +func (al *sdkAccessList) ContainsAddress(ctx sdk.Context, address common.Address) bool { store := prefix.NewStore(ctx.KVStore(al.key), AccessListAddressKey) return store.Has(address.Bytes()) } // Contains checks if a slot within an account is present in the access list, returning // separate flags for the presence of the account and the slot respectively. -func (al *accessList) Contains( +func (al *sdkAccessList) Contains( ctx sdk.Context, address common.Address, slot common.Hash, @@ -53,16 +53,16 @@ func (al *accessList) Contains( return true, slotPresent } -// newAccessList creates a new accessList. -func newAccessList(storeKey storetypes.StoreKey) *accessList { - return &accessList{ +// newSdkAccessList creates a new accessList. +func newSdkAccessList(storeKey storetypes.StoreKey) *sdkAccessList { + return &sdkAccessList{ key: storeKey, } } // AddAddress adds an address to the access list, and returns 'true' if the operation // caused a change (addr was not previously in the list). -func (al *accessList) AddAddress(ctx sdk.Context, address common.Address) bool { +func (al *sdkAccessList) AddAddress(ctx sdk.Context, address common.Address) bool { store := prefix.NewStore(ctx.KVStore(al.key), AccessListAddressKey) if store.Has(address.Bytes()) { return false @@ -77,7 +77,7 @@ func (al *accessList) AddAddress(ctx sdk.Context, address common.Address) bool { // - address added // - slot added // For any 'true' value returned, a corresponding journal entry must be made. -func (al *accessList) AddSlot( +func (al *sdkAccessList) AddSlot( ctx sdk.Context, address common.Address, slot common.Hash, From 1680d77114830ec9c2df7e171606236c931e323c Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 18 Jan 2024 12:45:24 -0800 Subject: [PATCH 13/52] refactor: Move snapshottable ctx to separate struct --- x/evm/statedb/benchmark_test.go | 8 +- x/evm/statedb/ctx.go | 114 ++++++++++++++++++++ x/evm/statedb/ctx_test.go | 69 ++++++++++++ x/evm/statedb/journal.go | 91 ++-------------- x/evm/statedb/state_object.go | 166 +---------------------------- x/evm/statedb/statedb.go | 180 ++++++++++++++------------------ 6 files changed, 279 insertions(+), 349 deletions(-) create mode 100644 x/evm/statedb/ctx.go create mode 100644 x/evm/statedb/ctx_test.go diff --git a/x/evm/statedb/benchmark_test.go b/x/evm/statedb/benchmark_test.go index fe48645efb..29736cac09 100644 --- a/x/evm/statedb/benchmark_test.go +++ b/x/evm/statedb/benchmark_test.go @@ -16,13 +16,15 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" ) -func NewTestContext() sdk.Context { - storeKey := storetypes.NewKVStoreKey("test") +var ( + testKvStoreKey = sdk.NewKVStoreKey("test") +) +func NewTestContext() sdk.Context { db := dbm.NewMemDB() cms := store.NewCommitMultiStore(db) - cms.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + cms.MountStoreWithDB(testKvStoreKey, storetypes.StoreTypeIAVL, db) if err := cms.LoadLatestVersion(); err != nil { panic(err) } diff --git a/x/evm/statedb/ctx.go b/x/evm/statedb/ctx.go new file mode 100644 index 0000000000..2ec5c816ac --- /dev/null +++ b/x/evm/statedb/ctx.go @@ -0,0 +1,114 @@ +package statedb + +import ( + "fmt" + "sort" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SnapshotCommitCtx provides a way to create snapshots of branched contexts and +// only write state to the initial context when Commit() is called. +type SnapshotCommitCtx struct { + initialCtx sdk.Context + snapshots []ctxSnapshot + + nextSnapshotID int +} + +// NewSnapshotCtx creates a new SnapshotCtx from the initial context. +func NewSnapshotCtx(initialCtx sdk.Context) *SnapshotCommitCtx { + sCtx := &SnapshotCommitCtx{ + initialCtx: initialCtx, + snapshots: nil, + nextSnapshotID: 0, + } + + // Create an initial snapshot of the initialCtx so no state is written until + // Commit() is called. + _ = sCtx.Snapshot() + + return sCtx +} + +// CurrentCtx returns the current ctx, either the latest branched ctx, or the +// initial ctx if there are no snapshots. +func (c *SnapshotCommitCtx) CurrentCtx() sdk.Context { + if len(c.snapshots) == 0 { + return c.initialCtx + } + + return c.snapshots[len(c.snapshots)-1].ctx +} + +func (c *SnapshotCommitCtx) CurrentSnapshot() (ctxSnapshot, bool) { + if len(c.snapshots) == 0 { + return ctxSnapshot{}, false + } + + return c.snapshots[len(c.snapshots)-1], true +} + +// Snapshot creates a new branched context and returns the revision id. +func (c *SnapshotCommitCtx) Snapshot() int { + id := c.nextSnapshotID + c.nextSnapshotID++ + + // Branch off a new CacheMultiStore + write function + newCtx, newWrite := c.CurrentCtx().CacheContext() + + // Save the new snapshot to the list + c.snapshots = append(c.snapshots, ctxSnapshot{ + id: id, + ctx: newCtx, + write: newWrite, + + // TODO: If still used later + // journalIndex: s.journal.length(), + }) + + return id +} + +// Revert reverts the state to the given revision id. +func (c *SnapshotCommitCtx) Revert(revid int) { + // Find the snapshot in the stack of valid snapshots. + idx := sort.Search(len(c.snapshots), func(i int) bool { + return c.snapshots[i].id >= revid + }) + + if idx == -1 { + panic(fmt.Errorf("revision id %v does not exist", revid)) + } + + // Index is invalid or the revision id is not the same somehow + if idx >= len(c.snapshots) || c.snapshots[idx].id != revid { + panic(fmt.Errorf("revision id %v is invalid", revid)) + } + + // Remove invalidated snapshots + c.snapshots = c.snapshots[:idx] +} + +// Commit writes all the branched contexts to the initialContext. +func (c *SnapshotCommitCtx) Commit() { + // Write snapshots from newest to oldest. + // Each store.Write() applies the state changes to its parent / previous snapshot + for i := len(c.snapshots) - 1; i >= 0; i-- { + snapshot := c.snapshots[i] + snapshot.write() + + // initialCtx should not be considered as a snapshot, so we don't need + // to call Write() on it to apply the changes. + } +} + +// ctxSnapshot is a single snapshot with a branched context. +type ctxSnapshot struct { + id int + ctx sdk.Context + write func() + + // Journal used only for in-memory things like logs and access list + journalIndex int +} diff --git a/x/evm/statedb/ctx_test.go b/x/evm/statedb/ctx_test.go new file mode 100644 index 0000000000..886e0b2b8e --- /dev/null +++ b/x/evm/statedb/ctx_test.go @@ -0,0 +1,69 @@ +package statedb_test + +import ( + "testing" + + "github.com/evmos/ethermint/x/evm/statedb" + "github.com/stretchr/testify/require" +) + +func TestSnapshotCommitCtx(t *testing.T) { + initialCtx := NewTestContext() + snapshotCtx := statedb.NewSnapshotCtx(initialCtx) + + // Write to the snapshot + store := snapshotCtx.CurrentCtx().KVStore(testKvStoreKey) + + key := []byte("key") + value := []byte("value") + store.Set(key, value) + + require.Equal(t, value, store.Get(key), "store should have value") + + // Fetch from initial context + parentStore := initialCtx.KVStore(testKvStoreKey) + require.Nil(t, parentStore.Get(key), "parent store should not have value") + + // Make a snapshot + previousCtx := snapshotCtx.CurrentCtx() + snapshotID := snapshotCtx.Snapshot() + require.Equal(t, 1, snapshotID, "snapshot id should be 1") + require.NotEqual(t, previousCtx, snapshotCtx.CurrentCtx(), "CurrentCtx should be branched") + + // Write to the snapshot + store = snapshotCtx.CurrentCtx().KVStore(testKvStoreKey) + key2 := []byte("key2") + value2 := []byte("value2") + store.Set(key2, value2) + + require.Equal(t, value2, store.Get(key2), "store should have value") + require.Nil(t, parentStore.Get(key2), "parent store should not have value") + + // Commit snapshots + snapshotCtx.Commit() + + // Fetch from initial context + require.Equal(t, value, parentStore.Get(key), "parent store should have value") + require.Equal(t, value2, parentStore.Get(key2), "parent store should have value from snapshot") +} + +func TestRevert(t *testing.T) { + initialCtx := NewTestContext() + snapshotCtx := statedb.NewSnapshotCtx(initialCtx) + + // Make a snapshot + snapshotID := snapshotCtx.Snapshot() + + // Revert to the snapshot + snapshotCtx.Revert(snapshotID) + + // Try to revert to the same snapshot again, which should panic + require.Panics(t, func() { + snapshotCtx.Revert(snapshotID) + }, "Reverting to the same snapshot should panic") + + // Try to revert to a non-existent snapshot, which should also panic + require.Panics(t, func() { + snapshotCtx.Revert(999) + }, "Reverting to a non-existent snapshot should panic") +} diff --git a/x/evm/statedb/journal.go b/x/evm/statedb/journal.go index 49f61c0040..26c963dda8 100644 --- a/x/evm/statedb/journal.go +++ b/x/evm/statedb/journal.go @@ -18,7 +18,6 @@ package statedb import ( "bytes" - "math/big" "sort" "github.com/ethereum/go-ethereum/common" @@ -102,27 +101,9 @@ type ( prev *stateObject } suicideChange struct { - account *common.Address - prev bool // whether account had already suicided - prevbalance *big.Int - } - - // Changes to individual accounts. - balanceChange struct { - account *common.Address - prev *big.Int - } - nonceChange struct { account *common.Address - prev uint64 - } - storageChange struct { - account *common.Address - key, prevalue common.Hash - } - codeChange struct { - account *common.Address - prevcode, prevhash []byte + prev bool // whether account had already suicided + // prevBalance not needed, in cache ctx } // Changes to other state values. @@ -141,66 +122,6 @@ type ( } ) -func (ch createObjectChange) Revert(s *StateDB) { - delete(s.stateObjects, *ch.account) -} - -func (ch createObjectChange) Dirtied() *common.Address { - return ch.account -} - -func (ch resetObjectChange) Revert(s *StateDB) { - s.setStateObject(ch.prev) -} - -func (ch resetObjectChange) Dirtied() *common.Address { - return nil -} - -func (ch suicideChange) Revert(s *StateDB) { - obj := s.getStateObject(*ch.account) - if obj != nil { - obj.suicided = ch.prev - obj.setBalance(ch.prevbalance) - } -} - -func (ch suicideChange) Dirtied() *common.Address { - return ch.account -} - -func (ch balanceChange) Revert(s *StateDB) { - s.getStateObject(*ch.account).setBalance(ch.prev) -} - -func (ch balanceChange) Dirtied() *common.Address { - return ch.account -} - -func (ch nonceChange) Revert(s *StateDB) { - s.getStateObject(*ch.account).setNonce(ch.prev) -} - -func (ch nonceChange) Dirtied() *common.Address { - return ch.account -} - -func (ch codeChange) Revert(s *StateDB) { - s.getStateObject(*ch.account).setCode(common.BytesToHash(ch.prevhash), ch.prevcode) -} - -func (ch codeChange) Dirtied() *common.Address { - return ch.account -} - -func (ch storageChange) Revert(s *StateDB) { - s.getStateObject(*ch.account).setState(ch.key, ch.prevalue) -} - -func (ch storageChange) Dirtied() *common.Address { - return ch.account -} - func (ch refundChange) Revert(s *StateDB) { s.refund = ch.prev } @@ -241,3 +162,11 @@ func (ch accessListAddSlotChange) Revert(s *StateDB) { func (ch accessListAddSlotChange) Dirtied() *common.Address { return nil } + +func (ch suicideChange) Revert(s *StateDB) { + s.suicidedAddresses[*ch.account] = ch.prev +} + +func (ch suicideChange) Dirtied() *common.Address { + return nil +} diff --git a/x/evm/statedb/state_object.go b/x/evm/statedb/state_object.go index e6c7841282..1bffc96519 100644 --- a/x/evm/statedb/state_object.go +++ b/x/evm/statedb/state_object.go @@ -48,18 +48,9 @@ func (s Storage) SortedKeys() []common.Hash { type stateObject struct { db *StateDB - account types.StateDBAccount - code []byte - - // state storage - originStorage Storage - dirtyStorage Storage - address common.Address - // flags - dirtyCode bool - suicided bool + suicided bool } // newObject creates a state object. @@ -71,162 +62,11 @@ func newObject(db *StateDB, address common.Address, account types.StateDBAccount account.CodeHash = emptyCodeHash } return &stateObject{ - db: db, - address: address, - account: account, - originStorage: make(Storage), - dirtyStorage: make(Storage), + db: db, + address: address, } } -// empty returns whether the account is considered empty. -func (s *stateObject) empty() bool { - return s.account.Nonce == 0 && s.account.Balance.Sign() == 0 && bytes.Equal(s.account.CodeHash, emptyCodeHash) -} - func (s *stateObject) markSuicided() { s.suicided = true } - -// AddBalance adds amount to s's balance. -// It is used to add funds to the destination account of a transfer. -func (s *stateObject) AddBalance(amount *big.Int) { - if amount.Sign() == 0 { - return - } - s.SetBalance(new(big.Int).Add(s.Balance(), amount)) -} - -// SubBalance removes amount from s's balance. -// It is used to remove funds from the origin account of a transfer. -func (s *stateObject) SubBalance(amount *big.Int) { - if amount.Sign() == 0 { - return - } - s.SetBalance(new(big.Int).Sub(s.Balance(), amount)) -} - -// SetBalance update account balance. -func (s *stateObject) SetBalance(amount *big.Int) { - s.db.journal.append(balanceChange{ - account: &s.address, - prev: new(big.Int).Set(s.account.Balance), - }) - s.setBalance(amount) -} - -func (s *stateObject) setBalance(amount *big.Int) { - s.account.Balance = amount -} - -// -// Attribute accessors -// - -// Returns the address of the contract/account -func (s *stateObject) Address() common.Address { - return s.address -} - -// Code returns the contract code associated with this object, if any. -func (s *stateObject) Code() []byte { - if s.code != nil { - return s.code - } - if bytes.Equal(s.CodeHash(), emptyCodeHash) { - return nil - } - code := s.db.keeper.GetCode(s.db.currentCtx, common.BytesToHash(s.CodeHash())) - s.code = code - return code -} - -// CodeSize returns the size of the contract code associated with this object, -// or zero if none. -func (s *stateObject) CodeSize() int { - return len(s.Code()) -} - -// SetCode set contract code to account -func (s *stateObject) SetCode(codeHash common.Hash, code []byte) { - prevcode := s.Code() - s.db.journal.append(codeChange{ - account: &s.address, - prevhash: s.CodeHash(), - prevcode: prevcode, - }) - s.setCode(codeHash, code) -} - -func (s *stateObject) setCode(codeHash common.Hash, code []byte) { - s.code = code - s.account.CodeHash = codeHash[:] - s.dirtyCode = true -} - -// SetCode set nonce to account -func (s *stateObject) SetNonce(nonce uint64) { - s.db.journal.append(nonceChange{ - account: &s.address, - prev: s.account.Nonce, - }) - s.setNonce(nonce) -} - -func (s *stateObject) setNonce(nonce uint64) { - s.account.Nonce = nonce -} - -// CodeHash returns the code hash of account -func (s *stateObject) CodeHash() []byte { - return s.account.CodeHash -} - -// Balance returns the balance of account -func (s *stateObject) Balance() *big.Int { - return s.account.Balance -} - -// Nonce returns the nonce of account -func (s *stateObject) Nonce() uint64 { - return s.account.Nonce -} - -// GetCommittedState query the committed state -func (s *stateObject) GetCommittedState(key common.Hash) common.Hash { - if value, cached := s.originStorage[key]; cached { - return value - } - // If no live objects are available, load it from keeper - value := s.db.keeper.GetState(s.db.currentCtx, s.Address(), key) - s.originStorage[key] = value - return value -} - -// GetState query the current state (including dirty state) -func (s *stateObject) GetState(key common.Hash) common.Hash { - if value, dirty := s.dirtyStorage[key]; dirty { - return value - } - return s.GetCommittedState(key) -} - -// SetState sets the contract state -func (s *stateObject) SetState(key common.Hash, value common.Hash) { - // If the new value is the same as old, don't set - prev := s.GetState(key) - if prev == value { - return - } - // New value is different, update and journal the change - s.db.journal.append(storageChange{ - account: &s.address, - key: key, - prevalue: prev, - }) - s.setState(key, value) -} - -func (s *stateObject) setState(key, value common.Hash) { - s.dirtyStorage[key] = value -} diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 46837d9790..4cb87e7949 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -19,7 +19,6 @@ import ( "bytes" "fmt" "math/big" - "sort" "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -41,12 +40,6 @@ type revision struct { journalIndex int } -type ctxSnapshot struct { - id int - ctx sdk.Context - write func() -} - var _ vm.StateDB = &StateDB{} // StateDB structs within the ethereum protocol are used to store anything @@ -57,14 +50,7 @@ var _ vm.StateDB = &StateDB{} type StateDB struct { keeper evm.StateDBKeeper - // current branched sdk.Context -- branched on creation and each snapshot - currentCtx sdk.Context - // write function of currentCtx - currentCtxWrite func() - - // Snapshots of Ctx, each a CacheContext branch of the previous one - ctxSnapshots []ctxSnapshot - nextSnapshotID int + ctx *SnapshotCommitCtx logStore *StateDBStore @@ -86,6 +72,9 @@ type StateDB struct { // Per-transaction access list accessList *accessList + + // Suicided accounts - true if suicided in current transaction. + suicidedAddresses map[common.Address]bool } // New creates a new state from a given trie. @@ -101,24 +90,19 @@ func New(ctx sdk.Context, keeper evm.StateDBKeeper, txConfig types.TxConfig) evm cms.MountStoreWithDB(storeKey, storetypes.StoreTypeMemory, db) statedb := &StateDB{ - keeper: keeper, - currentCtx: ctx, - currentCtxWrite: nil, - - ctxSnapshots: []ctxSnapshot{}, - nextSnapshotID: 0, + keeper: keeper, + // This internally creates a branched ctx so Commit() is still required + // to write state to the ctx here. + ctx: NewSnapshotCtx(ctx), - journal: newJournal(), - accessList: newAccessList(), - logStore: NewStateDBStore(storeKey), + journal: newJournal(), + accessList: newAccessList(), + logStore: NewStateDBStore(storeKey), + suicidedAddresses: make(map[common.Address]bool), txConfig: txConfig, } - // Create an initial cache ctx branch so we don't modify parent Context - // without calling Commit() - _ = statedb.Snapshot() - return statedb } @@ -134,36 +118,36 @@ func (s *StateDB) AddLog(log *ethtypes.Log) { log.TxIndex = s.txConfig.TxIndex log.Index = s.txConfig.LogIndex + uint(len(s.logs)) - s.logStore.AddLog(s.currentCtx, log) + s.logStore.AddLog(s.ctx.CurrentCtx(), log) } // Logs returns the logs of current transaction. func (s *StateDB) Logs() []*ethtypes.Log { - return s.logStore.GetAllLogs(s.currentCtx) + return s.logStore.GetAllLogs(s.ctx.CurrentCtx()) } // AddRefund adds gas to the refund counter func (s *StateDB) AddRefund(gas uint64) { - s.logStore.AddRefund(s.currentCtx, gas) + s.logStore.AddRefund(s.ctx.CurrentCtx(), gas) } // SubRefund removes gas from the refund counter. // This method will panic if the refund counter goes below zero func (s *StateDB) SubRefund(gas uint64) { - s.logStore.SubRefund(s.currentCtx, gas) + s.logStore.SubRefund(s.ctx.CurrentCtx(), gas) } // Exist reports whether the given account address exists in the state. // Notably this also returns true for suicided accounts. func (s *StateDB) Exist(addr common.Address) bool { - account := s.keeper.GetAccount(s.currentCtx, addr) + account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) return account != nil } // Empty returns whether the state object is either non-existent // or empty according to the EIP161 specification (balance = nonce = code = 0) func (s *StateDB) Empty(addr common.Address) bool { - account := s.keeper.GetAccount(s.currentCtx, addr) + account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) if account == nil { return true } @@ -173,7 +157,7 @@ func (s *StateDB) Empty(addr common.Address) bool { // GetBalance retrieves the balance from the given address or 0 if object not found func (s *StateDB) GetBalance(addr common.Address) *big.Int { - account := s.keeper.GetAccount(s.currentCtx, addr) + account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) if account != nil { return account.Balance } @@ -183,7 +167,7 @@ func (s *StateDB) GetBalance(addr common.Address) *big.Int { // GetNonce returns the nonce of account, 0 if not exists. func (s *StateDB) GetNonce(addr common.Address) uint64 { - account := s.keeper.GetAccount(s.currentCtx, addr) + account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) if account != nil { return account.Nonce } @@ -193,7 +177,7 @@ func (s *StateDB) GetNonce(addr common.Address) uint64 { // GetCode returns the code of account, nil if not exists. func (s *StateDB) GetCode(addr common.Address) []byte { - account := s.keeper.GetAccount(s.currentCtx, addr) + account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) if account == nil { return nil } @@ -202,7 +186,7 @@ func (s *StateDB) GetCode(addr common.Address) []byte { return nil } - return s.keeper.GetCode(s.currentCtx, common.BytesToHash(account.CodeHash)) + return s.keeper.GetCode(s.ctx.CurrentCtx(), common.BytesToHash(account.CodeHash)) } // GetCodeSize returns the code size of account. @@ -213,7 +197,7 @@ func (s *StateDB) GetCodeSize(addr common.Address) int { // GetCodeHash returns the code hash of account. func (s *StateDB) GetCodeHash(addr common.Address) common.Hash { - account := s.keeper.GetAccount(s.currentCtx, addr) + account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) if account == nil { return common.Hash{} } @@ -228,31 +212,30 @@ func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash { return common.Hash{} } - return s.keeper.GetState(s.currentCtx, addr, hash) + return s.keeper.GetState(s.ctx.CurrentCtx(), addr, hash) } // GetCommittedState retrieves a value from the given account's committed storage trie. func (s *StateDB) GetCommittedState(addr common.Address, hash common.Hash) common.Hash { - // TODO: Double check or find a cleaner way // This gets the state from the parent ctx which is the state before Commit() - return s.keeper.GetState(s.ctxSnapshots[0].ctx, addr, hash) + return s.keeper.GetState(s.ctx.initialCtx, addr, hash) } // GetRefund returns the current value of the refund counter. func (s *StateDB) GetRefund() uint64 { - return s.logStore.GetRefund(s.currentCtx) + return s.logStore.GetRefund(s.ctx.CurrentCtx()) } // HasSuicided returns if the contract is suicided in current transaction. func (s *StateDB) HasSuicided(addr common.Address) bool { // Could be created and then suicided in the same transaction, so we can't // rely on the existence of the account before the current transaction. - - stateObject := s.getStateObject(addr) - if stateObject != nil { - return stateObject.suicided + suicidedAccount, found := s.suicidedAddresses[addr] + if !found { + return false } - return false + + return suicidedAccount } // AddPreimage records a SHA3 preimage seen by the VM. @@ -263,7 +246,7 @@ func (s *StateDB) AddPreimage(hash common.Hash, preimage []byte) {} //nolint: re // getOrNewAccount retrieves a state account or create a new account if nil. func (s *StateDB) getOrNewAccount(addr common.Address) *types.StateDBAccount { - account := s.keeper.GetAccount(s.currentCtx, addr) + account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) if account == nil { account = &types.StateDBAccount{} } @@ -282,18 +265,26 @@ func (s *StateDB) getOrNewAccount(addr common.Address) *types.StateDBAccount { // // Carrying over the balance ensures that Ether doesn't disappear. func (s *StateDB) CreateAccount(addr common.Address) { - account := s.keeper.GetAccount(s.currentCtx, addr) + account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) if account != nil { - // Only carry over balance, other values are zero'd out ? - account.Balance = account.Balance - s.keeper.SetAccount(s.currentCtx, addr, *account) + // If there is already an account, zero out everything except for the balance ? + // This is done in previous StateDB + + // Create a new account -- Must use NewEmptyAccount() so that the + // CodeHash is the actual hash of nil, not an empty byte slice + newAccount := types.NewEmptyAccount() + newAccount.Balance = account.Balance + + s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *newAccount) } + + s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *types.NewEmptyAccount()) } // ForEachStorage iterate the contract storage, the iteration order is not defined. func (s *StateDB) ForEachStorage(addr common.Address, cb func(key, value common.Hash) bool) error { - s.keeper.ForEachStorage(s.currentCtx, addr, cb) + s.keeper.ForEachStorage(s.ctx.CurrentCtx(), addr, cb) return nil } @@ -310,7 +301,7 @@ func (s *StateDB) AddBalance(addr common.Address, amount *big.Int) { account := s.getOrNewAccount(addr) account.Balance = new(big.Int).Add(account.Balance, amount) - s.keeper.SetAccount(s.currentCtx, addr, *account) + s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account) } // SubBalance subtracts amount from the account associated with addr. @@ -322,7 +313,7 @@ func (s *StateDB) SubBalance(addr common.Address, amount *big.Int) { account := s.getOrNewAccount(addr) account.Balance = new(big.Int).Sub(account.Balance, amount) - s.keeper.SetAccount(s.currentCtx, addr, *account) + s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account) } // SetNonce sets the nonce of account. @@ -330,17 +321,17 @@ func (s *StateDB) SetNonce(addr common.Address, nonce uint64) { account := s.getOrNewAccount(addr) account.Nonce = nonce - s.keeper.SetAccount(s.currentCtx, addr, *account) + s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account) } // SetCode sets the code of account. func (s *StateDB) SetCode(addr common.Address, code []byte) { - s.keeper.SetCode(s.currentCtx, crypto.Keccak256Hash(code).Bytes(), code) + s.keeper.SetCode(s.ctx.CurrentCtx(), crypto.Keccak256Hash(code).Bytes(), code) } // SetState sets the contract state. func (s *StateDB) SetState(addr common.Address, key, value common.Hash) { - s.keeper.SetState(s.currentCtx, addr, key, value.Bytes()) + s.keeper.SetState(s.ctx.CurrentCtx(), addr, key, value.Bytes()) } // Suicide marks the given account as suicided. @@ -349,15 +340,20 @@ func (s *StateDB) SetState(addr common.Address, key, value common.Hash) { // The account's state object is still available until the state is committed, // getStateObject will return a non-nil account after Suicide. func (s *StateDB) Suicide(addr common.Address) bool { - account := s.keeper.GetAccount(s.currentCtx, addr) + account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) if account == nil { return false } - if err := s.keeper.DeleteAccount(s.currentCtx, addr); err != nil { - panic(fmt.Errorf("failed to delete account in Suicide(): %w", err)) - } + // We add to journal, but KEEP the account in the ctx.CurrentCtx() as it should + // still be accessible in state until it's committed. + s.journal.append(suicideChange{ + account: &addr, + prev: s.suicidedAddresses[addr], + }) + + s.suicidedAddresses[addr] = true return true } @@ -425,56 +421,36 @@ func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addre // Snapshot returns an identifier for the current revision of the state. func (s *StateDB) Snapshot() int { - id := s.nextSnapshotID - s.nextSnapshotID++ - - // Save the current context (cached multi-store and events) + write function - // to apply the snapshot to the parent store - s.ctxSnapshots = append(s.ctxSnapshots, ctxSnapshot{ - id: id, - ctx: s.currentCtx, - write: s.currentCtxWrite, - }) - - // Branch off a new CacheMultiStore + write function - newCtx, write := s.currentCtx.CacheContext() - - // Update ctx to the new branch - s.currentCtx = newCtx - s.currentCtxWrite = write - - return id + return s.ctx.Snapshot() } // RevertToSnapshot reverts all state changes made since the given revision. func (s *StateDB) RevertToSnapshot(revid int) { - // Find the snapshot in the stack of valid snapshots. - idx := sort.Search(len(s.ctxSnapshots), func(i int) bool { - return s.ctxSnapshots[i].id >= revid - }) + s.ctx.Revert(revid) - if idx == len(s.ctxSnapshots) || s.ctxSnapshots[idx].id != revid { - panic(fmt.Errorf("revision id %v cannot be reverted", revid)) + currentSnapshot, found := s.ctx.CurrentSnapshot() + if !found { + panic(fmt.Errorf("current snapshot with id %d not found", revid)) } - // Update current ctx to the snapshot ctx - s.currentCtx = s.ctxSnapshots[idx].ctx - - // Remove invalidated snapshots - s.ctxSnapshots = s.ctxSnapshots[:idx] + // Revert journal to the latest snapshot's journal index + s.journal.Revert(s, currentSnapshot.journalIndex) } // the StateDB object should be discarded after committed. func (s *StateDB) Commit() error { - // Write snapshots from newest to oldest. - // Each store.Write() applies the state changes to its parent / previous snapshot - for i := len(s.ctxSnapshots) - 1; i >= 0; i-- { - snapshot := s.ctxSnapshots[i] - - // write() will be nil for the root snapshot that was created on New() - // Root ctx won't need write() since it isn't a CacheContext - if snapshot.write != nil { - snapshot.write() + s.ctx.Commit() + + // Commit suicided accounts + for addr, isSuicided := range s.suicidedAddresses { + // Might be false if a snapshot was reverted + if !isSuicided { + continue + } + + // Balance is also cleared as part of Keeper.DeleteAccount + if err := s.keeper.DeleteAccount(s.ctx.CurrentCtx(), addr); err != nil { + panic(fmt.Errorf("failed to delete suicided account: %w", err)) } } From fe948261801aeda3578c03304ef7f5ae71d2badc Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 18 Jan 2024 15:19:08 -0800 Subject: [PATCH 14/52] Store suicided state in store, use transient store --- x/evm/keeper/keeper.go | 4 ++ x/evm/statedb/ctx.go | 3 ++ x/evm/statedb/journal.go | 13 ------ x/evm/statedb/mock_test.go | 18 +++++++++ x/evm/statedb/statedb.go | 75 ++++++++++++----------------------- x/evm/statedb/statedb_test.go | 37 +++++++++-------- x/evm/statedb/store.go | 35 +++++++++++++--- x/evm/vm/interface.go | 4 ++ 8 files changed, 102 insertions(+), 87 deletions(-) diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 45e804dbfe..9a27b55ff4 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -403,3 +403,7 @@ func (k Keeper) AddTransientGasUsed(ctx sdk.Context, gasUsed uint64) (uint64, er k.SetTransientGasUsed(ctx, result) return result, nil } + +func (k Keeper) GetTransientKey() storetypes.StoreKey { + return k.transientKey +} diff --git a/x/evm/statedb/ctx.go b/x/evm/statedb/ctx.go index 2ec5c816ac..b2c2aef45b 100644 --- a/x/evm/statedb/ctx.go +++ b/x/evm/statedb/ctx.go @@ -13,6 +13,7 @@ type SnapshotCommitCtx struct { initialCtx sdk.Context snapshots []ctxSnapshot + // always incrementing snapshot ID, used to identify snapshots. nextSnapshotID int } @@ -41,6 +42,8 @@ func (c *SnapshotCommitCtx) CurrentCtx() sdk.Context { return c.snapshots[len(c.snapshots)-1].ctx } +// CurrentSnapshot returns the current snapshot and true if there is one, or +// false if there are no snapshots. func (c *SnapshotCommitCtx) CurrentSnapshot() (ctxSnapshot, bool) { if len(c.snapshots) == 0 { return ctxSnapshot{}, false diff --git a/x/evm/statedb/journal.go b/x/evm/statedb/journal.go index 26c963dda8..027a38fd30 100644 --- a/x/evm/statedb/journal.go +++ b/x/evm/statedb/journal.go @@ -100,11 +100,6 @@ type ( resetObjectChange struct { prev *stateObject } - suicideChange struct { - account *common.Address - prev bool // whether account had already suicided - // prevBalance not needed, in cache ctx - } // Changes to other state values. refundChange struct { @@ -162,11 +157,3 @@ func (ch accessListAddSlotChange) Revert(s *StateDB) { func (ch accessListAddSlotChange) Dirtied() *common.Address { return nil } - -func (ch suicideChange) Revert(s *StateDB) { - s.suicidedAddresses[*ch.account] = ch.prev -} - -func (ch suicideChange) Dirtied() *common.Address { - return nil -} diff --git a/x/evm/statedb/mock_test.go b/x/evm/statedb/mock_test.go index 88c270ed5e..43d6e3b1d3 100644 --- a/x/evm/statedb/mock_test.go +++ b/x/evm/statedb/mock_test.go @@ -5,6 +5,7 @@ import ( "errors" "math/big" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -91,6 +92,19 @@ func (k MockKeeper) SetCode(ctx sdk.Context, codeHash []byte, code []byte) { k.codes[common.BytesToHash(codeHash)] = code } +func (k MockKeeper) SetBalance(ctx sdk.Context, addr common.Address, amount *big.Int) error { + if addr == errAddress { + return errors.New("mock db error") + } + acct, ok := k.accounts[addr] + if !ok { + return errors.New("account not found") + } + acct.account.Balance = amount + k.accounts[addr] = acct + return nil +} + func (k MockKeeper) DeleteAccount(ctx sdk.Context, addr common.Address) error { if addr == errAddress { return errors.New("mock db error") @@ -114,3 +128,7 @@ func (k MockKeeper) Clone() *MockKeeper { } return &MockKeeper{accounts, codes} } + +func (k MockKeeper) GetTransientKey() storetypes.StoreKey { + return testKvStoreKey +} diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 4cb87e7949..02890797af 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -20,8 +20,6 @@ import ( "fmt" "math/big" - "github.com/cosmos/cosmos-sdk/store" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -29,7 +27,6 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/evmos/ethermint/x/evm/types" evm "github.com/evmos/ethermint/x/evm/vm" - dbm "github.com/tendermint/tm-db" ) // revision is the identifier of a version of state. @@ -52,7 +49,7 @@ type StateDB struct { ctx *SnapshotCommitCtx - logStore *StateDBStore + ephemeralStore *StateDBStore // Journal of state modifications. This is the backbone of // Snapshot and RevertToSnapshot. @@ -72,33 +69,19 @@ type StateDB struct { // Per-transaction access list accessList *accessList - - // Suicided accounts - true if suicided in current transaction. - suicidedAddresses map[common.Address]bool } // New creates a new state from a given trie. func New(ctx sdk.Context, keeper evm.StateDBKeeper, txConfig types.TxConfig) evm.StateDB { - // Create an in-memory DB for accessList which does not need to be committed - // to underlying state. - // - // Why do we use this instead of a simple map? - // Because Snapshot() will then also apply to the accessList without needing - // to keep a separate snapshot of the accessList. - db := dbm.NewMemDB() - cms := store.NewCommitMultiStore(db) - cms.MountStoreWithDB(storeKey, storetypes.StoreTypeMemory, db) - statedb := &StateDB{ keeper: keeper, // This internally creates a branched ctx so Commit() is still required // to write state to the ctx here. ctx: NewSnapshotCtx(ctx), - journal: newJournal(), - accessList: newAccessList(), - logStore: NewStateDBStore(storeKey), - suicidedAddresses: make(map[common.Address]bool), + journal: newJournal(), + accessList: newAccessList(), + ephemeralStore: NewStateDBStore(keeper.GetTransientKey()), txConfig: txConfig, } @@ -118,23 +101,23 @@ func (s *StateDB) AddLog(log *ethtypes.Log) { log.TxIndex = s.txConfig.TxIndex log.Index = s.txConfig.LogIndex + uint(len(s.logs)) - s.logStore.AddLog(s.ctx.CurrentCtx(), log) + s.ephemeralStore.AddLog(s.ctx.CurrentCtx(), log) } // Logs returns the logs of current transaction. func (s *StateDB) Logs() []*ethtypes.Log { - return s.logStore.GetAllLogs(s.ctx.CurrentCtx()) + return s.ephemeralStore.GetAllLogs(s.ctx.CurrentCtx()) } // AddRefund adds gas to the refund counter func (s *StateDB) AddRefund(gas uint64) { - s.logStore.AddRefund(s.ctx.CurrentCtx(), gas) + s.ephemeralStore.AddRefund(s.ctx.CurrentCtx(), gas) } // SubRefund removes gas from the refund counter. // This method will panic if the refund counter goes below zero func (s *StateDB) SubRefund(gas uint64) { - s.logStore.SubRefund(s.ctx.CurrentCtx(), gas) + s.ephemeralStore.SubRefund(s.ctx.CurrentCtx(), gas) } // Exist reports whether the given account address exists in the state. @@ -223,19 +206,12 @@ func (s *StateDB) GetCommittedState(addr common.Address, hash common.Hash) commo // GetRefund returns the current value of the refund counter. func (s *StateDB) GetRefund() uint64 { - return s.logStore.GetRefund(s.ctx.CurrentCtx()) + return s.ephemeralStore.GetRefund(s.ctx.CurrentCtx()) } // HasSuicided returns if the contract is suicided in current transaction. func (s *StateDB) HasSuicided(addr common.Address) bool { - // Could be created and then suicided in the same transaction, so we can't - // rely on the existence of the account before the current transaction. - suicidedAccount, found := s.suicidedAddresses[addr] - if !found { - return false - } - - return suicidedAccount + return s.ephemeralStore.GetAccountSuicided(s.ctx.CurrentCtx(), addr) } // AddPreimage records a SHA3 preimage seen by the VM. @@ -248,7 +224,9 @@ func (s *StateDB) AddPreimage(hash common.Hash, preimage []byte) {} //nolint: re func (s *StateDB) getOrNewAccount(addr common.Address) *types.StateDBAccount { account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) if account == nil { - account = &types.StateDBAccount{} + account = &types.StateDBAccount{ + Balance: new(big.Int), + } } return account @@ -326,7 +304,11 @@ func (s *StateDB) SetNonce(addr common.Address, nonce uint64) { // SetCode sets the code of account. func (s *StateDB) SetCode(addr common.Address, code []byte) { - s.keeper.SetCode(s.ctx.CurrentCtx(), crypto.Keccak256Hash(code).Bytes(), code) + account := s.getOrNewAccount(addr) + account.CodeHash = crypto.Keccak256Hash(code).Bytes() + s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account) + + s.keeper.SetCode(s.ctx.CurrentCtx(), account.CodeHash, code) } // SetState sets the contract state. @@ -341,19 +323,16 @@ func (s *StateDB) SetState(addr common.Address, key, value common.Hash) { // getStateObject will return a non-nil account after Suicide. func (s *StateDB) Suicide(addr common.Address) bool { account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) - if account == nil { return false } - // We add to journal, but KEEP the account in the ctx.CurrentCtx() as it should - // still be accessible in state until it's committed. - s.journal.append(suicideChange{ - account: &addr, - prev: s.suicidedAddresses[addr], - }) + // Balance cleared, but code and state should still be available until Commit() + if err := s.keeper.SetBalance(s.ctx.CurrentCtx(), addr, common.Big0); err != nil { + panic(fmt.Errorf("failed to delete suicided account: %w", err)) + } - s.suicidedAddresses[addr] = true + s.ephemeralStore.SetAccountSuicided(s.ctx.CurrentCtx(), addr) return true } @@ -442,12 +421,8 @@ func (s *StateDB) Commit() error { s.ctx.Commit() // Commit suicided accounts - for addr, isSuicided := range s.suicidedAddresses { - // Might be false if a snapshot was reverted - if !isSuicided { - continue - } - + suicidedAddrs := s.ephemeralStore.GetAllSuicided(s.ctx.CurrentCtx()) + for _, addr := range suicidedAddrs { // Balance is also cleared as part of Keeper.DeleteAccount if err := s.keeper.DeleteAccount(s.ctx.CurrentCtx(), addr); err != nil { panic(fmt.Errorf("failed to delete suicided account: %w", err)) diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index cac980e92e..1c16b90ded 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -4,7 +4,6 @@ import ( "math/big" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -54,7 +53,7 @@ func (suite *StateDBTestSuite) TestAccount() { suite.Require().Empty(acct.states) suite.Require().False(acct.account.IsContract()) - db = statedb.New(sdk.Context{}, keeper, emptyTxConfig) + db = statedb.New(NewTestContext(), keeper, emptyTxConfig) suite.Require().Equal(true, db.Exist(address)) suite.Require().Equal(true, db.Empty(address)) suite.Require().Equal(big.NewInt(0), db.GetBalance(address)) @@ -76,7 +75,7 @@ func (suite *StateDBTestSuite) TestAccount() { suite.Require().NoError(db.Commit()) // suicide - db = statedb.New(sdk.Context{}, db.Keeper(), emptyTxConfig) + db = statedb.New(NewTestContext(), db.Keeper(), emptyTxConfig) suite.Require().False(db.HasSuicided(address)) suite.Require().True(db.Suicide(address)) @@ -91,7 +90,7 @@ func (suite *StateDBTestSuite) TestAccount() { suite.Require().NoError(db.Commit()) // not accessible from StateDB anymore - db = statedb.New(sdk.Context{}, db.Keeper(), emptyTxConfig) + db = statedb.New(NewTestContext(), db.Keeper(), emptyTxConfig) suite.Require().False(db.Exist(address)) // and cleared in keeper too @@ -103,7 +102,7 @@ func (suite *StateDBTestSuite) TestAccount() { for _, tc := range testCases { suite.Run(tc.name, func() { keeper := NewMockKeeper() - db := statedb.New(sdk.Context{}, keeper, emptyTxConfig) + db := statedb.New(NewTestContext(), keeper, emptyTxConfig) tc.malleate(db) }) } @@ -111,7 +110,7 @@ func (suite *StateDBTestSuite) TestAccount() { func (suite *StateDBTestSuite) TestAccountOverride() { keeper := NewMockKeeper() - db := statedb.New(sdk.Context{}, keeper, emptyTxConfig) + db := statedb.New(NewTestContext(), keeper, emptyTxConfig) // test balance carry over when overwritten amount := big.NewInt(1) @@ -142,7 +141,7 @@ func (suite *StateDBTestSuite) TestDBError() { }}, } for _, tc := range testCases { - db := statedb.New(sdk.Context{}, NewMockKeeper(), emptyTxConfig) + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) tc.malleate(db) suite.Require().Error(db.Commit()) } @@ -175,7 +174,7 @@ func (suite *StateDBTestSuite) TestBalance() { for _, tc := range testCases { suite.Run(tc.name, func() { keeper := NewMockKeeper() - db := statedb.New(sdk.Context{}, keeper, emptyTxConfig) + db := statedb.New(NewTestContext(), keeper, emptyTxConfig) tc.malleate(db) // check dirty state @@ -227,7 +226,7 @@ func (suite *StateDBTestSuite) TestState() { for _, tc := range testCases { suite.Run(tc.name, func() { keeper := NewMockKeeper() - db := statedb.New(sdk.Context{}, keeper, emptyTxConfig) + db := statedb.New(NewTestContext(), keeper, emptyTxConfig) tc.malleate(db) suite.Require().NoError(db.Commit()) @@ -235,7 +234,7 @@ func (suite *StateDBTestSuite) TestState() { suite.Require().Equal(tc.expStates, keeper.accounts[address].states) // check ForEachStorage - db = statedb.New(sdk.Context{}, keeper, emptyTxConfig) + db = statedb.New(NewTestContext(), keeper, emptyTxConfig) collected := CollectContractStorage(db) if len(tc.expStates) > 0 { suite.Require().Equal(tc.expStates, collected) @@ -268,7 +267,7 @@ func (suite *StateDBTestSuite) TestCode() { for _, tc := range testCases { suite.Run(tc.name, func() { keeper := NewMockKeeper() - db := statedb.New(sdk.Context{}, keeper, emptyTxConfig) + db := statedb.New(NewTestContext(), keeper, emptyTxConfig) tc.malleate(db) // check dirty state @@ -279,7 +278,7 @@ func (suite *StateDBTestSuite) TestCode() { suite.Require().NoError(db.Commit()) // check again - db = statedb.New(sdk.Context{}, keeper, emptyTxConfig) + db = statedb.New(NewTestContext(), keeper, emptyTxConfig) suite.Require().Equal(tc.expCode, db.GetCode(address)) suite.Require().Equal(len(tc.expCode), db.GetCodeSize(address)) suite.Require().Equal(tc.expCodeHash, db.GetCodeHash(address)) @@ -332,7 +331,7 @@ func (suite *StateDBTestSuite) TestRevertSnapshot() { } for _, tc := range testCases { suite.Run(tc.name, func() { - ctx := sdk.Context{} + ctx := NewTestContext() keeper := NewMockKeeper() { @@ -371,7 +370,7 @@ func (suite *StateDBTestSuite) TestNestedSnapshot() { value1 := common.BigToHash(big.NewInt(1)) value2 := common.BigToHash(big.NewInt(2)) - db := statedb.New(sdk.Context{}, NewMockKeeper(), emptyTxConfig) + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) rev1 := db.Snapshot() db.SetState(address, key, value1) @@ -388,7 +387,7 @@ func (suite *StateDBTestSuite) TestNestedSnapshot() { } func (suite *StateDBTestSuite) TestInvalidSnapshotId() { - db := statedb.New(sdk.Context{}, NewMockKeeper(), emptyTxConfig) + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) suite.Require().Panics(func() { db.RevertToSnapshot(1) }) @@ -460,7 +459,7 @@ func (suite *StateDBTestSuite) TestAccessList() { } for _, tc := range testCases { - db := statedb.New(sdk.Context{}, NewMockKeeper(), emptyTxConfig) + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) tc.malleate(db) } } @@ -473,7 +472,7 @@ func (suite *StateDBTestSuite) TestLog() { txHash, 1, 1, ) - db := statedb.New(sdk.Context{}, NewMockKeeper(), txConfig) + db := statedb.New(NewTestContext(), NewMockKeeper(), txConfig) data := []byte("hello world") db.AddLog(ðtypes.Log{ Address: address, @@ -525,7 +524,7 @@ func (suite *StateDBTestSuite) TestRefund() { }, 0, true}, } for _, tc := range testCases { - db := statedb.New(sdk.Context{}, NewMockKeeper(), emptyTxConfig) + db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) if !tc.expPanic { tc.malleate(db) suite.Require().Equal(tc.expRefund, db.GetRefund()) @@ -544,7 +543,7 @@ func (suite *StateDBTestSuite) TestIterateStorage() { value2 := common.BigToHash(big.NewInt(4)) keeper := NewMockKeeper() - db := statedb.New(sdk.Context{}, keeper, emptyTxConfig) + db := statedb.New(NewTestContext(), keeper, emptyTxConfig) db.SetState(address, key1, value1) db.SetState(address, key2, value2) diff --git a/x/evm/statedb/store.go b/x/evm/statedb/store.go index 03f1fbe58a..8f09bbc427 100644 --- a/x/evm/statedb/store.go +++ b/x/evm/statedb/store.go @@ -4,18 +4,17 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" ) var ( - storeKey = sdk.NewKVStoreKey("evm-statedb") - AccessListAddressKey = []byte{0x01} // common.Address AccessListAddressSlotKey = []byte{0x02} // (common.Address, common.Hash) - LogKey = []byte{0x03} - - RefundKey = []byte{0x04} + LogKey = []byte{0x03} + RefundKey = []byte{0x04} + SuicidedKey = []byte{0x05} ) type StateDBStore struct { @@ -97,3 +96,29 @@ func (ls *StateDBStore) GetRefund(ctx sdk.Context) uint64 { } return sdk.BigEndianToUint64(bz) } + +func (ls *StateDBStore) SetAccountSuicided(ctx sdk.Context, addr common.Address) { + store := prefix.NewStore(ctx.KVStore(ls.key), SuicidedKey) + store.Set(addr.Bytes(), []byte{1}) +} + +func (ls *StateDBStore) GetAccountSuicided(ctx sdk.Context, addr common.Address) bool { + store := prefix.NewStore(ctx.KVStore(ls.key), SuicidedKey) + return store.Has(addr.Bytes()) +} + +func (ls *StateDBStore) GetAllSuicided(ctx sdk.Context) []common.Address { + store := prefix.NewStore(ctx.KVStore(ls.key), SuicidedKey) + + addrs := make([]common.Address, 0) + + iter := sdk.KVStorePrefixIterator(store, []byte{}) + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + addr := common.BytesToAddress(iter.Key()) + addrs = append(addrs, addr) + } + + return addrs +} diff --git a/x/evm/vm/interface.go b/x/evm/vm/interface.go index 9e5d05e6d4..6fec1a0d6c 100644 --- a/x/evm/vm/interface.go +++ b/x/evm/vm/interface.go @@ -18,6 +18,7 @@ package vm import ( "math/big" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/evmos/ethermint/x/evm/types" @@ -97,7 +98,10 @@ type StateDBKeeper interface { SetAccount(ctx sdk.Context, addr common.Address, account types.StateDBAccount) error SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte) SetCode(ctx sdk.Context, codeHash []byte, code []byte) + SetBalance(ctx sdk.Context, addr common.Address, amount *big.Int) error DeleteAccount(ctx sdk.Context, addr common.Address) error + + GetTransientKey() storetypes.StoreKey } type StateDB interface { From 57fbcf697d458cf8650a4e7314cbfc79c5391f67 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 18 Jan 2024 15:37:43 -0800 Subject: [PATCH 15/52] Fix reflect test error --- x/evm/keeper/keeper.go | 1 + x/evm/statedb/journal.go | 8 ------ x/evm/statedb/mock_test.go | 44 ++++++++++++++++---------------- x/evm/statedb/statedb.go | 47 ++++++++++++----------------------- x/evm/statedb/statedb_test.go | 12 ++++----- 5 files changed, 45 insertions(+), 67 deletions(-) diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 9a27b55ff4..0f8560d412 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -300,6 +300,7 @@ func (k *Keeper) GetAccountWithoutBalance(ctx sdk.Context, addr common.Address) return &types.StateDBAccount{ Nonce: acct.GetSequence(), CodeHash: codeHash, + Balance: nil, } } diff --git a/x/evm/statedb/journal.go b/x/evm/statedb/journal.go index 027a38fd30..f07a3e0706 100644 --- a/x/evm/statedb/journal.go +++ b/x/evm/statedb/journal.go @@ -117,14 +117,6 @@ type ( } ) -func (ch refundChange) Revert(s *StateDB) { - s.refund = ch.prev -} - -func (ch refundChange) Dirtied() *common.Address { - return nil -} - func (ch addLogChange) Revert(s *StateDB) { s.logs = s.logs[:len(s.logs)-1] } diff --git a/x/evm/statedb/mock_test.go b/x/evm/statedb/mock_test.go index 43d6e3b1d3..5f7d0fb9ed 100644 --- a/x/evm/statedb/mock_test.go +++ b/x/evm/statedb/mock_test.go @@ -26,19 +26,19 @@ type MockAcount struct { } type MockKeeper struct { - accounts map[common.Address]MockAcount - codes map[common.Hash][]byte + Accounts map[common.Address]MockAcount + Codes map[common.Hash][]byte } func NewMockKeeper() *MockKeeper { return &MockKeeper{ - accounts: make(map[common.Address]MockAcount), - codes: make(map[common.Hash][]byte), + Accounts: make(map[common.Address]MockAcount), + Codes: make(map[common.Hash][]byte), } } func (k MockKeeper) GetAccount(ctx sdk.Context, addr common.Address) *types.StateDBAccount { - acct, ok := k.accounts[addr] + acct, ok := k.Accounts[addr] if !ok { return nil } @@ -46,15 +46,15 @@ func (k MockKeeper) GetAccount(ctx sdk.Context, addr common.Address) *types.Stat } func (k MockKeeper) GetState(ctx sdk.Context, addr common.Address, key common.Hash) common.Hash { - return k.accounts[addr].states[key] + return k.Accounts[addr].states[key] } func (k MockKeeper) GetCode(ctx sdk.Context, codeHash common.Hash) []byte { - return k.codes[codeHash] + return k.Codes[codeHash] } func (k MockKeeper) ForEachStorage(ctx sdk.Context, addr common.Address, cb func(key, value common.Hash) bool) { - if acct, ok := k.accounts[addr]; ok { + if acct, ok := k.Accounts[addr]; ok { for k, v := range acct.states { if !cb(k, v) { return @@ -67,19 +67,19 @@ func (k MockKeeper) SetAccount(ctx sdk.Context, addr common.Address, account typ if addr == errAddress { return errors.New("mock db error") } - acct, exists := k.accounts[addr] + acct, exists := k.Accounts[addr] if exists { // update acct.account = account - k.accounts[addr] = acct + k.Accounts[addr] = acct } else { - k.accounts[addr] = MockAcount{account: account, states: make(statedb.Storage)} + k.Accounts[addr] = MockAcount{account: account, states: make(statedb.Storage)} } return nil } func (k MockKeeper) SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte) { - if acct, ok := k.accounts[addr]; ok { + if acct, ok := k.Accounts[addr]; ok { if len(value) == 0 { delete(acct.states, key) } else { @@ -89,19 +89,19 @@ func (k MockKeeper) SetState(ctx sdk.Context, addr common.Address, key common.Ha } func (k MockKeeper) SetCode(ctx sdk.Context, codeHash []byte, code []byte) { - k.codes[common.BytesToHash(codeHash)] = code + k.Codes[common.BytesToHash(codeHash)] = code } func (k MockKeeper) SetBalance(ctx sdk.Context, addr common.Address, amount *big.Int) error { if addr == errAddress { return errors.New("mock db error") } - acct, ok := k.accounts[addr] + acct, ok := k.Accounts[addr] if !ok { return errors.New("account not found") } acct.account.Balance = amount - k.accounts[addr] = acct + k.Accounts[addr] = acct return nil } @@ -109,21 +109,21 @@ func (k MockKeeper) DeleteAccount(ctx sdk.Context, addr common.Address) error { if addr == errAddress { return errors.New("mock db error") } - old := k.accounts[addr] - delete(k.accounts, addr) + old := k.Accounts[addr] + delete(k.Accounts, addr) if !bytes.Equal(old.account.CodeHash, emptyCodeHash) { - delete(k.codes, common.BytesToHash(old.account.CodeHash)) + delete(k.Codes, common.BytesToHash(old.account.CodeHash)) } return nil } func (k MockKeeper) Clone() *MockKeeper { - accounts := make(map[common.Address]MockAcount, len(k.accounts)) - for k, v := range k.accounts { + accounts := make(map[common.Address]MockAcount, len(k.Accounts)) + for k, v := range k.Accounts { accounts[k] = v } - codes := make(map[common.Hash][]byte, len(k.codes)) - for k, v := range k.codes { + codes := make(map[common.Hash][]byte, len(k.Codes)) + for k, v := range k.Codes { codes[k] = v } return &MockKeeper{accounts, codes} diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 02890797af..af6692295e 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -29,14 +29,6 @@ import ( evm "github.com/evmos/ethermint/x/evm/vm" ) -// revision is the identifier of a version of state. -// it consists of an auto-increment id and a journal index. -// it's safer to use than using journal index alone. -type revision struct { - id int - journalIndex int -} - var _ vm.StateDB = &StateDB{} // StateDB structs within the ethereum protocol are used to store anything @@ -47,23 +39,15 @@ var _ vm.StateDB = &StateDB{} type StateDB struct { keeper evm.StateDBKeeper - ctx *SnapshotCommitCtx - - ephemeralStore *StateDBStore + ctx *SnapshotCommitCtx // snapshot-able ctx manager + ephemeralStore *StateDBStore // store for ephemeral data // Journal of state modifications. This is the backbone of // Snapshot and RevertToSnapshot. journal *journal - // validRevisions []revision - // nextRevisionID int - - // stateObjects map[common.Address]*stateObject txConfig types.TxConfig - // The refund counter, also used by state transitioning. - refund uint64 - // Per-transaction logs logs []*ethtypes.Log @@ -75,8 +59,8 @@ type StateDB struct { func New(ctx sdk.Context, keeper evm.StateDBKeeper, txConfig types.TxConfig) evm.StateDB { statedb := &StateDB{ keeper: keeper, - // This internally creates a branched ctx so Commit() is still required - // to write state to the ctx here. + // This internally creates a branched ctx so calling Commit() is required + // to write state to the incoming ctx. ctx: NewSnapshotCtx(ctx), journal: newJournal(), @@ -244,20 +228,21 @@ func (s *StateDB) getOrNewAccount(addr common.Address) *types.StateDBAccount { // Carrying over the balance ensures that Ether doesn't disappear. func (s *StateDB) CreateAccount(addr common.Address) { account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) + if account == nil { + // No account found, create a new one + s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *types.NewEmptyAccount()) + return + } - if account != nil { - // If there is already an account, zero out everything except for the balance ? - // This is done in previous StateDB - - // Create a new account -- Must use NewEmptyAccount() so that the - // CodeHash is the actual hash of nil, not an empty byte slice - newAccount := types.NewEmptyAccount() - newAccount.Balance = account.Balance + // If there is already an account, zero out everything except for the balance ? + // This is done in previous StateDB - s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *newAccount) - } + // Create a new account -- Must use NewEmptyAccount() so that the + // CodeHash is the actual hash of nil, not an empty byte slice + newAccount := types.NewEmptyAccount() + newAccount.Balance = account.Balance - s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *types.NewEmptyAccount()) + s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *newAccount) } // ForEachStorage iterate the contract storage, the iteration order is not defined. diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index 1c16b90ded..04021173ff 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -48,7 +48,7 @@ func (suite *StateDBTestSuite) TestAccount() { suite.Require().NoError(db.Commit()) keeper := db.Keeper().(*MockKeeper) - acct := keeper.accounts[address] + acct := keeper.Accounts[address] suite.Require().Equal(types.NewEmptyAccount(), &acct.account) suite.Require().Empty(acct.states) suite.Require().False(acct.account.IsContract()) @@ -95,8 +95,8 @@ func (suite *StateDBTestSuite) TestAccount() { // and cleared in keeper too keeper := db.Keeper().(*MockKeeper) - suite.Require().Empty(keeper.accounts) - suite.Require().Empty(keeper.codes) + suite.Require().Empty(keeper.Accounts) + suite.Require().Empty(keeper.Codes) }}, } for _, tc := range testCases { @@ -181,7 +181,7 @@ func (suite *StateDBTestSuite) TestBalance() { suite.Require().Equal(tc.expBalance, db.GetBalance(address)) suite.Require().NoError(db.Commit()) // check committed balance too - suite.Require().Equal(tc.expBalance, keeper.accounts[address].account.Balance) + suite.Require().Equal(tc.expBalance, keeper.Accounts[address].account.Balance) }) } } @@ -231,7 +231,7 @@ func (suite *StateDBTestSuite) TestState() { suite.Require().NoError(db.Commit()) // check committed states in keeper - suite.Require().Equal(tc.expStates, keeper.accounts[address].states) + suite.Require().Equal(tc.expStates, keeper.Accounts[address].states) // check ForEachStorage db = statedb.New(NewTestContext(), keeper, emptyTxConfig) @@ -554,7 +554,7 @@ func (suite *StateDBTestSuite) TestIterateStorage() { storage := CollectContractStorage(db) suite.Require().Equal(2, len(storage)) - suite.Require().Equal(keeper.accounts[address].states, storage) + suite.Require().Equal(keeper.Accounts[address].states, storage) // break early iteration storage = make(statedb.Storage) From 4711c8ea92e12df154efe919968cafadc0c41958 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 18 Jan 2024 16:08:05 -0800 Subject: [PATCH 16/52] Update StateDBTestSuite.TestBalance to use real keeper --- x/evm/statedb/statedb.go | 4 +--- x/evm/statedb/statedb_test.go | 11 +++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index af6692295e..06b53b622e 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -208,9 +208,7 @@ func (s *StateDB) AddPreimage(hash common.Hash, preimage []byte) {} //nolint: re func (s *StateDB) getOrNewAccount(addr common.Address) *types.StateDBAccount { account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) if account == nil { - account = &types.StateDBAccount{ - Balance: new(big.Int), - } + account = types.NewEmptyAccount() } return account diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index 04021173ff..bcbd9cd81d 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/evmos/ethermint/x/evm/statedb" + "github.com/evmos/ethermint/x/evm/testutil" "github.com/evmos/ethermint/x/evm/types" evm "github.com/evmos/ethermint/x/evm/vm" "github.com/stretchr/testify/suite" @@ -23,7 +24,7 @@ var ( ) type StateDBTestSuite struct { - suite.Suite + testutil.KeeperTestSuite } func (suite *StateDBTestSuite) TestAccount() { @@ -173,15 +174,17 @@ func (suite *StateDBTestSuite) TestBalance() { for _, tc := range testCases { suite.Run(tc.name, func() { - keeper := NewMockKeeper() - db := statedb.New(NewTestContext(), keeper, emptyTxConfig) + suite.SetupTest() + + keeper := suite.App.EvmKeeper + db := statedb.New(suite.Ctx, keeper, emptyTxConfig) tc.malleate(db) // check dirty state suite.Require().Equal(tc.expBalance, db.GetBalance(address)) suite.Require().NoError(db.Commit()) // check committed balance too - suite.Require().Equal(tc.expBalance, keeper.Accounts[address].account.Balance) + suite.Require().Equal(tc.expBalance, keeper.GetBalance(suite.Ctx, address)) }) } } From f1c3b0493d67a51a21f97f361591511f7c31ac04 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Fri, 19 Jan 2024 13:00:25 -0800 Subject: [PATCH 17/52] Fix tests with real keeper --- x/evm/statedb/journal.go | 8 - x/evm/statedb/statedb.go | 15 +- x/evm/statedb/statedb_test.go | 117 ++++++---- x/evm/statedb/store.go | 40 +++- x/evm/testutil/suite.go | 425 ++++++++++++++++++++++++++++++++++ 5 files changed, 532 insertions(+), 73 deletions(-) create mode 100644 x/evm/testutil/suite.go diff --git a/x/evm/statedb/journal.go b/x/evm/statedb/journal.go index f07a3e0706..a305e872d2 100644 --- a/x/evm/statedb/journal.go +++ b/x/evm/statedb/journal.go @@ -117,14 +117,6 @@ type ( } ) -func (ch addLogChange) Revert(s *StateDB) { - s.logs = s.logs[:len(s.logs)-1] -} - -func (ch addLogChange) Dirtied() *common.Address { - return nil -} - func (ch accessListAddAccountChange) Revert(s *StateDB) { /* One important invariant here, is that whenever a (addr, slot) is added, if the diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 06b53b622e..2b00f92074 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -48,9 +48,6 @@ type StateDB struct { txConfig types.TxConfig - // Per-transaction logs - logs []*ethtypes.Log - // Per-transaction access list accessList *accessList } @@ -83,9 +80,10 @@ func (s *StateDB) AddLog(log *ethtypes.Log) { log.TxHash = s.txConfig.TxHash log.BlockHash = s.txConfig.BlockHash log.TxIndex = s.txConfig.TxIndex - log.Index = s.txConfig.LogIndex + uint(len(s.logs)) + log.Index = s.txConfig.LogIndex + uint(s.ephemeralStore.GetLogIndex(s.ctx.CurrentCtx())) s.ephemeralStore.AddLog(s.ctx.CurrentCtx(), log) + s.ephemeralStore.SetLogIndex(s.ctx.CurrentCtx(), log.Index) } // Logs returns the logs of current transaction. @@ -245,7 +243,7 @@ func (s *StateDB) CreateAccount(addr common.Address) { // ForEachStorage iterate the contract storage, the iteration order is not defined. func (s *StateDB) ForEachStorage(addr common.Address, cb func(key, value common.Hash) bool) error { - s.keeper.ForEachStorage(s.ctx.CurrentCtx(), addr, cb) + s.keeper.ForEachStorage(s.ctx.initialCtx, addr, cb) return nil } @@ -401,9 +399,7 @@ func (s *StateDB) RevertToSnapshot(revid int) { // the StateDB object should be discarded after committed. func (s *StateDB) Commit() error { - s.ctx.Commit() - - // Commit suicided accounts + // Delete suicided accounts suicidedAddrs := s.ephemeralStore.GetAllSuicided(s.ctx.CurrentCtx()) for _, addr := range suicidedAddrs { // Balance is also cleared as part of Keeper.DeleteAccount @@ -412,5 +408,8 @@ func (s *StateDB) Commit() error { } } + // Commit after account deletions + s.ctx.Commit() + return nil } diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index bcbd9cd81d..97a6527b81 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -8,6 +8,8 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" + xevm "github.com/evmos/ethermint/x/evm" + "github.com/evmos/ethermint/x/evm/keeper" "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/testutil" "github.com/evmos/ethermint/x/evm/types" @@ -48,13 +50,15 @@ func (suite *StateDBTestSuite) TestAccount() { db.CreateAccount(address) suite.Require().NoError(db.Commit()) - keeper := db.Keeper().(*MockKeeper) - acct := keeper.Accounts[address] - suite.Require().Equal(types.NewEmptyAccount(), &acct.account) - suite.Require().Empty(acct.states) - suite.Require().False(acct.account.IsContract()) + keeper := db.Keeper().(*keeper.Keeper) + acct := keeper.GetAccount(suite.Ctx, address) + states := suite.GetAllAccountStorage(suite.Ctx, address) - db = statedb.New(NewTestContext(), keeper, emptyTxConfig) + suite.Require().Equal(types.NewEmptyAccount(), acct) + suite.Require().Empty(states) + suite.Require().False(acct.IsContract()) + + db = statedb.New(suite.Ctx, keeper, emptyTxConfig) suite.Require().Equal(true, db.Exist(address)) suite.Require().Equal(true, db.Empty(address)) suite.Require().Equal(big.NewInt(0), db.GetBalance(address)) @@ -76,7 +80,7 @@ func (suite *StateDBTestSuite) TestAccount() { suite.Require().NoError(db.Commit()) // suicide - db = statedb.New(NewTestContext(), db.Keeper(), emptyTxConfig) + db = statedb.New(suite.Ctx, db.Keeper(), emptyTxConfig) suite.Require().False(db.HasSuicided(address)) suite.Require().True(db.Suicide(address)) @@ -91,27 +95,32 @@ func (suite *StateDBTestSuite) TestAccount() { suite.Require().NoError(db.Commit()) // not accessible from StateDB anymore - db = statedb.New(NewTestContext(), db.Keeper(), emptyTxConfig) + db = statedb.New(suite.Ctx, db.Keeper(), emptyTxConfig) suite.Require().False(db.Exist(address)) // and cleared in keeper too - keeper := db.Keeper().(*MockKeeper) - suite.Require().Empty(keeper.Accounts) - suite.Require().Empty(keeper.Codes) + keeper := db.Keeper().(*keeper.Keeper) + acc := keeper.GetAccount(suite.Ctx, address) + states := suite.GetAllAccountStorage(suite.Ctx, address) + + suite.Require().Empty(acc) + suite.Require().Empty(states) }}, } for _, tc := range testCases { suite.Run(tc.name, func() { - keeper := NewMockKeeper() - db := statedb.New(NewTestContext(), keeper, emptyTxConfig) + suite.SetupTest() + + keeper := suite.App.EvmKeeper + db := statedb.New(suite.Ctx, keeper, emptyTxConfig) tc.malleate(db) }) } } func (suite *StateDBTestSuite) TestAccountOverride() { - keeper := NewMockKeeper() - db := statedb.New(NewTestContext(), keeper, emptyTxConfig) + keeper := suite.App.EvmKeeper + db := statedb.New(suite.Ctx, keeper, emptyTxConfig) // test balance carry over when overwritten amount := big.NewInt(1) @@ -142,7 +151,8 @@ func (suite *StateDBTestSuite) TestDBError() { }}, } for _, tc := range testCases { - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + suite.SetupTest() + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) tc.malleate(db) suite.Require().Error(db.Commit()) } @@ -195,17 +205,19 @@ func (suite *StateDBTestSuite) TestState() { testCases := []struct { name string malleate func(evm.StateDB) - expStates statedb.Storage + expStates map[common.Hash]common.Hash }{ {"empty state", func(db evm.StateDB) { }, nil}, {"set empty value", func(db evm.StateDB) { db.SetState(address, key1, common.Hash{}) - }, statedb.Storage{}}, + }, map[common.Hash]common.Hash(nil)}, {"noop state change", func(db evm.StateDB) { + // TODO: This doesn't actually change anything compared to committed state + // so it shouldn't be written to the keeper db.SetState(address, key1, value1) db.SetState(address, key1, common.Hash{}) - }, statedb.Storage{}}, + }, map[common.Hash]common.Hash(nil)}, {"set state", func(db evm.StateDB) { // check empty initial state suite.Require().Equal(common.Hash{}, db.GetState(address, key1)) @@ -221,23 +233,26 @@ func (suite *StateDBTestSuite) TestState() { // set same value again, should be noop db.SetState(address, key1, value1) suite.Require().Equal(value1, db.GetState(address, key1)) - }, statedb.Storage{ + }, map[common.Hash]common.Hash{ key1: value1, }}, } for _, tc := range testCases { suite.Run(tc.name, func() { - keeper := NewMockKeeper() - db := statedb.New(NewTestContext(), keeper, emptyTxConfig) + suite.SetupTest() + + keeper := suite.App.EvmKeeper + db := statedb.New(suite.Ctx, keeper, emptyTxConfig) tc.malleate(db) suite.Require().NoError(db.Commit()) // check committed states in keeper - suite.Require().Equal(tc.expStates, keeper.Accounts[address].states) + states := suite.GetAllAccountStorage(suite.Ctx, address) + suite.Require().Equal(tc.expStates, states) // check ForEachStorage - db = statedb.New(NewTestContext(), keeper, emptyTxConfig) + db = statedb.New(suite.Ctx, keeper, emptyTxConfig) collected := CollectContractStorage(db) if len(tc.expStates) > 0 { suite.Require().Equal(tc.expStates, collected) @@ -269,8 +284,8 @@ func (suite *StateDBTestSuite) TestCode() { for _, tc := range testCases { suite.Run(tc.name, func() { - keeper := NewMockKeeper() - db := statedb.New(NewTestContext(), keeper, emptyTxConfig) + keeper := suite.App.EvmKeeper + db := statedb.New(suite.Ctx, keeper, emptyTxConfig) tc.malleate(db) // check dirty state @@ -281,7 +296,7 @@ func (suite *StateDBTestSuite) TestCode() { suite.Require().NoError(db.Commit()) // check again - db = statedb.New(NewTestContext(), keeper, emptyTxConfig) + db = statedb.New(suite.Ctx, keeper, emptyTxConfig) suite.Require().Equal(tc.expCode, db.GetCode(address)) suite.Require().Equal(len(tc.expCode), db.GetCodeSize(address)) suite.Require().Equal(tc.expCodeHash, db.GetCodeHash(address)) @@ -334,8 +349,10 @@ func (suite *StateDBTestSuite) TestRevertSnapshot() { } for _, tc := range testCases { suite.Run(tc.name, func() { - ctx := NewTestContext() - keeper := NewMockKeeper() + suite.SetupTest() + + ctx := suite.Ctx + keeper := suite.App.EvmKeeper { // do some arbitrary changes to the storage @@ -348,7 +365,7 @@ func (suite *StateDBTestSuite) TestRevertSnapshot() { suite.Require().NoError(db.Commit()) } - originalKeeper := keeper.Clone() + originalState := xevm.ExportGenesis(suite.Ctx, keeper, suite.App.AccountKeeper) // run test db := statedb.New(ctx, keeper, emptyTxConfig) @@ -362,8 +379,10 @@ func (suite *StateDBTestSuite) TestRevertSnapshot() { suite.Require().NoError(db.Commit()) - // check keeper should stay the same - suite.Require().Equal(originalKeeper, keeper) + revertState := xevm.ExportGenesis(suite.Ctx, keeper, suite.App.AccountKeeper) + + // check keeper state should stay the same + suite.Require().Equal(originalState, revertState) }) } } @@ -373,7 +392,7 @@ func (suite *StateDBTestSuite) TestNestedSnapshot() { value1 := common.BigToHash(big.NewInt(1)) value2 := common.BigToHash(big.NewInt(2)) - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) rev1 := db.Snapshot() db.SetState(address, key, value1) @@ -390,7 +409,7 @@ func (suite *StateDBTestSuite) TestNestedSnapshot() { } func (suite *StateDBTestSuite) TestInvalidSnapshotId() { - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) suite.Require().Panics(func() { db.RevertToSnapshot(1) }) @@ -439,6 +458,8 @@ func (suite *StateDBTestSuite) TestAccessList() { suite.Require().True(slotPresent) }}, {"prepare access list", func(db vm.StateDB) { + suite.SetupTest() + al := ethtypes.AccessList{{ Address: address3, StorageKeys: []common.Hash{value1}, @@ -462,7 +483,7 @@ func (suite *StateDBTestSuite) TestAccessList() { } for _, tc := range testCases { - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) tc.malleate(db) } } @@ -475,7 +496,7 @@ func (suite *StateDBTestSuite) TestLog() { txHash, 1, 1, ) - db := statedb.New(NewTestContext(), NewMockKeeper(), txConfig) + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, txConfig) data := []byte("hello world") db.AddLog(ðtypes.Log{ Address: address, @@ -484,7 +505,7 @@ func (suite *StateDBTestSuite) TestLog() { BlockNumber: 1, }) suite.Require().Equal(1, len(db.Logs())) - expecedLog := ðtypes.Log{ + expectedLog := ðtypes.Log{ Address: address, Topics: []common.Hash{}, Data: data, @@ -494,7 +515,7 @@ func (suite *StateDBTestSuite) TestLog() { TxIndex: 1, Index: 1, } - suite.Require().Equal(expecedLog, db.Logs()[0]) + suite.Require().Equal(expectedLog, db.Logs()[0]) db.AddLog(ðtypes.Log{ Address: address, @@ -503,8 +524,8 @@ func (suite *StateDBTestSuite) TestLog() { BlockNumber: 1, }) suite.Require().Equal(2, len(db.Logs())) - expecedLog.Index++ - suite.Require().Equal(expecedLog, db.Logs()[1]) + expectedLog.Index++ + suite.Require().Equal(expectedLog, db.Logs()[1]) } func (suite *StateDBTestSuite) TestRefund() { @@ -527,7 +548,9 @@ func (suite *StateDBTestSuite) TestRefund() { }, 0, true}, } for _, tc := range testCases { - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + suite.SetupTest() + + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) if !tc.expPanic { tc.malleate(db) suite.Require().Equal(tc.expRefund, db.GetRefund()) @@ -545,8 +568,8 @@ func (suite *StateDBTestSuite) TestIterateStorage() { key2 := common.BigToHash(big.NewInt(3)) value2 := common.BigToHash(big.NewInt(4)) - keeper := NewMockKeeper() - db := statedb.New(NewTestContext(), keeper, emptyTxConfig) + keeper := suite.App.EvmKeeper + db := statedb.New(suite.Ctx, keeper, emptyTxConfig) db.SetState(address, key1, value1) db.SetState(address, key2, value2) @@ -557,7 +580,9 @@ func (suite *StateDBTestSuite) TestIterateStorage() { storage := CollectContractStorage(db) suite.Require().Equal(2, len(storage)) - suite.Require().Equal(keeper.Accounts[address].states, storage) + + accStorages := suite.GetAllAccountStorage(suite.Ctx, address) + suite.Require().Equal(accStorages, storage) // break early iteration storage = make(statedb.Storage) @@ -569,8 +594,8 @@ func (suite *StateDBTestSuite) TestIterateStorage() { suite.Require().Equal(1, len(storage)) } -func CollectContractStorage(db vm.StateDB) statedb.Storage { - storage := make(statedb.Storage) +func CollectContractStorage(db vm.StateDB) map[common.Hash]common.Hash { + storage := make(map[common.Hash]common.Hash) db.ForEachStorage(address, func(k, v common.Hash) bool { storage[k] = v return true diff --git a/x/evm/statedb/store.go b/x/evm/statedb/store.go index 8f09bbc427..0ab331a338 100644 --- a/x/evm/statedb/store.go +++ b/x/evm/statedb/store.go @@ -13,8 +13,9 @@ var ( AccessListAddressSlotKey = []byte{0x02} // (common.Address, common.Hash) LogKey = []byte{0x03} - RefundKey = []byte{0x04} - SuicidedKey = []byte{0x05} + LogIndexKey = []byte{0x04} + RefundKey = []byte{0x05} + SuicidedKey = []byte{0x06} ) type StateDBStore struct { @@ -27,21 +28,38 @@ func NewStateDBStore(storeKey storetypes.StoreKey) *StateDBStore { } } +// GetLogIndex returns the current log index. +func (ls *StateDBStore) GetLogIndex(ctx sdk.Context) uint { + store := prefix.NewStore(ctx.KVStore(ls.key), LogIndexKey) + bz := store.Get(LogIndexKey) + if bz == nil { + return 0 + } + + index := sdk.BigEndianToUint64(bz) + return uint(index) +} + +func (ls *StateDBStore) SetLogIndex(ctx sdk.Context, index uint) { + store := prefix.NewStore(ctx.KVStore(ls.key), LogIndexKey) + store.Set(LogIndexKey, sdk.Uint64ToBigEndian(uint64(index))) +} + // AddLog adds a log to the store. func (ls *StateDBStore) AddLog(ctx sdk.Context, log *ethtypes.Log) { store := prefix.NewStore(ctx.KVStore(ls.key), LogKey) - bz, err := log.MarshalJSON() if err != nil { panic(err) } - store.Set(log.Address.Bytes(), bz) + + store.Set(sdk.Uint64ToBigEndian(uint64(log.Index)), bz) } func (ls *StateDBStore) GetAllLogs(ctx sdk.Context) []*ethtypes.Log { store := prefix.NewStore(ctx.KVStore(ls.key), LogKey) - logs := make([]*ethtypes.Log, 0) + var logs []*ethtypes.Log iter := sdk.KVStorePrefixIterator(store, []byte{}) defer iter.Close() @@ -62,18 +80,18 @@ func (ls *StateDBStore) GetAllLogs(ctx sdk.Context) []*ethtypes.Log { func (ls *StateDBStore) AddRefund(ctx sdk.Context, gas uint64) { store := prefix.NewStore(ctx.KVStore(ls.key), RefundKey) // Add to existing refund - bz := store.Get([]byte{}) + bz := store.Get(RefundKey) if bz != nil { gas += sdk.BigEndianToUint64(bz) } - store.Set([]byte{}, sdk.Uint64ToBigEndian(gas)) + store.Set(RefundKey, sdk.Uint64ToBigEndian(gas)) } func (ls *StateDBStore) SubRefund(ctx sdk.Context, gas uint64) { store := prefix.NewStore(ctx.KVStore(ls.key), RefundKey) // Subtract from existing refund - bz := store.Get([]byte{}) + bz := store.Get(RefundKey) if bz == nil { panic("no refund to subtract from") } @@ -85,12 +103,12 @@ func (ls *StateDBStore) SubRefund(ctx sdk.Context, gas uint64) { } gas = refund - gas - store.Set([]byte{}, sdk.Uint64ToBigEndian(gas)) + store.Set(RefundKey, sdk.Uint64ToBigEndian(gas)) } func (ls *StateDBStore) GetRefund(ctx sdk.Context) uint64 { store := prefix.NewStore(ctx.KVStore(ls.key), RefundKey) - bz := store.Get([]byte{}) + bz := store.Get(RefundKey) if bz == nil { return 0 } @@ -110,7 +128,7 @@ func (ls *StateDBStore) GetAccountSuicided(ctx sdk.Context, addr common.Address) func (ls *StateDBStore) GetAllSuicided(ctx sdk.Context) []common.Address { store := prefix.NewStore(ctx.KVStore(ls.key), SuicidedKey) - addrs := make([]common.Address, 0) + var addrs []common.Address iter := sdk.KVStorePrefixIterator(store, []byte{}) defer iter.Close() diff --git a/x/evm/testutil/suite.go b/x/evm/testutil/suite.go new file mode 100644 index 0000000000..94a88ca575 --- /dev/null +++ b/x/evm/testutil/suite.go @@ -0,0 +1,425 @@ +package testutil + +import ( + _ "embed" + "encoding/json" + "math" + "math/big" + "time" + + sdkmath "cosmossdk.io/math" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" + tmjson "github.com/tendermint/tendermint/libs/json" + + "github.com/evmos/ethermint/app" + "github.com/evmos/ethermint/crypto/ethsecp256k1" + "github.com/evmos/ethermint/encoding" + "github.com/evmos/ethermint/server/config" + "github.com/evmos/ethermint/tests" + ethermint "github.com/evmos/ethermint/types" + "github.com/evmos/ethermint/x/evm/statedb" + "github.com/evmos/ethermint/x/evm/types" + evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/evmos/ethermint/x/evm/vm" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/params" + + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/crypto/tmhash" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmversion "github.com/tendermint/tendermint/proto/tendermint/version" + "github.com/tendermint/tendermint/version" +) + +var testTokens = sdkmath.NewIntWithDecimal(1000, 18) + +type KeeperTestSuite struct { + suite.Suite + + Ctx sdk.Context + App *app.EthermintApp + QueryClient types.QueryClient + Address common.Address + ConsAddress sdk.ConsAddress + + // for generate test tx + ClientCtx client.Context + EthSigner ethtypes.Signer + + appCodec codec.Codec + signer keyring.Signer + + enableFeemarket bool + enableLondonHF bool + mintFeeCollector bool + denom string +} + +var s *KeeperTestSuite + +func (suite *KeeperTestSuite) SetupTest() { + checkTx := false + suite.App = app.Setup(checkTx, nil) + suite.SetupApp(checkTx) +} + +func (suite *KeeperTestSuite) SetupTestWithT(t require.TestingT) { + checkTx := false + suite.App = app.Setup(checkTx, nil) + suite.SetupAppWithT(checkTx, t) +} + +func (suite *KeeperTestSuite) SetupApp(checkTx bool) { + suite.SetupAppWithT(checkTx, suite.T()) +} + +// SetupApp setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`. +func (suite *KeeperTestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { + // account key, use a constant account to keep unit test deterministic. + ecdsaPriv, err := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + require.NoError(t, err) + priv := ðsecp256k1.PrivKey{ + Key: crypto.FromECDSA(ecdsaPriv), + } + suite.Address = common.BytesToAddress(priv.PubKey().Address().Bytes()) + suite.signer = tests.NewSigner(priv) + + // consensus key + priv, err = ethsecp256k1.GenerateKey() + require.NoError(t, err) + suite.ConsAddress = sdk.ConsAddress(priv.PubKey().Address()) + + suite.App = app.Setup(checkTx, func(app *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState { + feemarketGenesis := feemarkettypes.DefaultGenesisState() + if suite.enableFeemarket { + feemarketGenesis.Params.EnableHeight = 1 + feemarketGenesis.Params.NoBaseFee = false + } else { + feemarketGenesis.Params.NoBaseFee = true + } + genesis[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(feemarketGenesis) + if !suite.enableLondonHF { + evmGenesis := types.DefaultGenesisState() + maxInt := sdkmath.NewInt(math.MaxInt64) + evmGenesis.Params.ChainConfig.LondonBlock = &maxInt + evmGenesis.Params.ChainConfig.ArrowGlacierBlock = &maxInt + evmGenesis.Params.ChainConfig.GrayGlacierBlock = &maxInt + evmGenesis.Params.ChainConfig.MergeNetsplitBlock = &maxInt + evmGenesis.Params.ChainConfig.ShanghaiBlock = &maxInt + evmGenesis.Params.ChainConfig.CancunBlock = &maxInt + genesis[types.ModuleName] = app.AppCodec().MustMarshalJSON(evmGenesis) + } + return genesis + }) + + if suite.mintFeeCollector { + // mint some coin to fee collector + coins := sdk.NewCoins(sdk.NewCoin(types.DefaultEVMDenom, sdkmath.NewInt(int64(params.TxGas)-1))) + genesisState := app.NewTestGenesisState(suite.App.AppCodec()) + balances := []banktypes.Balance{ + { + Address: suite.App.AccountKeeper.GetModuleAddress(authtypes.FeeCollectorName).String(), + Coins: coins, + }, + } + var bankGenesis banktypes.GenesisState + suite.App.AppCodec().MustUnmarshalJSON(genesisState[banktypes.ModuleName], &bankGenesis) + // Update balances and total supply + bankGenesis.Balances = append(bankGenesis.Balances, balances...) + bankGenesis.Supply = bankGenesis.Supply.Add(coins...) + genesisState[banktypes.ModuleName] = suite.App.AppCodec().MustMarshalJSON(&bankGenesis) + + // we marshal the genesisState of all module to a byte array + stateBytes, err := tmjson.MarshalIndent(genesisState, "", " ") + require.NoError(t, err) + + // Initialize the chain + suite.App.InitChain( + abci.RequestInitChain{ + ChainId: "ethermint_9000-1", + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: app.DefaultConsensusParams, + AppStateBytes: stateBytes, + }, + ) + } + + suite.Ctx = suite.App.BaseApp.NewContext(checkTx, tmproto.Header{ + Height: 1, + ChainID: "ethermint_9000-1", + Time: time.Now().UTC(), + ProposerAddress: suite.ConsAddress.Bytes(), + Version: tmversion.Consensus{ + Block: version.BlockProtocol, + }, + LastBlockId: tmproto.BlockID{ + Hash: tmhash.Sum([]byte("block_id")), + PartSetHeader: tmproto.PartSetHeader{ + Total: 11, + Hash: tmhash.Sum([]byte("partset_header")), + }, + }, + AppHash: tmhash.Sum([]byte("app")), + DataHash: tmhash.Sum([]byte("data")), + EvidenceHash: tmhash.Sum([]byte("evidence")), + ValidatorsHash: tmhash.Sum([]byte("validators")), + NextValidatorsHash: tmhash.Sum([]byte("next_validators")), + ConsensusHash: tmhash.Sum([]byte("consensus")), + LastResultsHash: tmhash.Sum([]byte("last_result")), + }) + + queryHelper := baseapp.NewQueryServerTestHelper(suite.Ctx, suite.App.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, suite.App.EvmKeeper) + suite.QueryClient = types.NewQueryClient(queryHelper) + + acc := ðermint.EthAccount{ + BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(suite.Address.Bytes()), nil, 0, 0), + CodeHash: common.BytesToHash(crypto.Keccak256(nil)).String(), + } + + suite.App.AccountKeeper.SetAccount(suite.Ctx, acc) + + valAddr := sdk.ValAddress(suite.Address.Bytes()) + validator, err := stakingtypes.NewValidator(valAddr, priv.PubKey(), stakingtypes.Description{}) + require.NoError(t, err) + err = suite.App.StakingKeeper.SetValidatorByConsAddr(suite.Ctx, validator) + require.NoError(t, err) + err = suite.App.StakingKeeper.SetValidatorByConsAddr(suite.Ctx, validator) + require.NoError(t, err) + suite.App.StakingKeeper.SetValidator(suite.Ctx, validator) + + encodingConfig := encoding.MakeConfig(app.ModuleBasics) + suite.ClientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig) + suite.EthSigner = ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) + suite.appCodec = encodingConfig.Codec + suite.denom = evmtypes.DefaultEVMDenom +} + +func (suite *KeeperTestSuite) EvmDenom() string { + ctx := sdk.WrapSDKContext(suite.Ctx) + rsp, _ := suite.QueryClient.Params(ctx, &types.QueryParamsRequest{}) + return rsp.Params.EvmDenom +} + +// Commit and begin new block +func (suite *KeeperTestSuite) Commit() { + _ = suite.App.Commit() + header := suite.Ctx.BlockHeader() + header.Height += 1 + suite.App.BeginBlock(abci.RequestBeginBlock{ + Header: header, + }) + + // update ctx + suite.Ctx = suite.App.BaseApp.NewContext(false, header) + + queryHelper := baseapp.NewQueryServerTestHelper(suite.Ctx, suite.App.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, suite.App.EvmKeeper) + suite.QueryClient = types.NewQueryClient(queryHelper) +} + +func (suite *KeeperTestSuite) StateDB() vm.StateDB { + return statedb.New( + suite.Ctx, + suite.App.EvmKeeper, + types.NewEmptyTxConfig(common.BytesToHash(suite.Ctx.HeaderHash().Bytes())), + ) +} + +// DeployTestContract deploy a test erc20 contract and returns the contract address +func (suite *KeeperTestSuite) DeployTestContract(t require.TestingT, owner common.Address, supply *big.Int) common.Address { + ctx := sdk.WrapSDKContext(suite.Ctx) + chainID := suite.App.EvmKeeper.ChainID() + + ctorArgs, err := types.ERC20Contract.ABI.Pack("", owner, supply) + require.NoError(t, err) + + nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) + + data := append(types.ERC20Contract.Bin, ctorArgs...) + args, err := json.Marshal(&types.TransactionArgs{ + From: &suite.Address, + Data: (*hexutil.Bytes)(&data), + }) + require.NoError(t, err) + res, err := suite.QueryClient.EstimateGas(ctx, &types.EthCallRequest{ + Args: args, + GasCap: uint64(config.DefaultGasCap), + ProposerAddress: suite.Ctx.BlockHeader().ProposerAddress, + }) + require.NoError(t, err) + + var erc20DeployTx *types.MsgEthereumTx + if suite.enableFeemarket { + erc20DeployTx = types.NewTxContract( + chainID, + nonce, + nil, // amount + res.Gas, // gasLimit + nil, // gasPrice + suite.App.FeeMarketKeeper.GetBaseFee(suite.Ctx), + big.NewInt(1), + data, // input + ðtypes.AccessList{}, // accesses + ) + } else { + erc20DeployTx = types.NewTxContract( + chainID, + nonce, + nil, // amount + res.Gas, // gasLimit + nil, // gasPrice + nil, nil, + data, // input + nil, // accesses + ) + } + + erc20DeployTx.From = suite.Address.Hex() + err = erc20DeployTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.signer) + require.NoError(t, err) + rsp, err := suite.App.EvmKeeper.EthereumTx(ctx, erc20DeployTx) + require.NoError(t, err) + require.Empty(t, rsp.VmError) + return crypto.CreateAddress(suite.Address, nonce) +} + +func (suite *KeeperTestSuite) TransferERC20Token(t require.TestingT, contractAddr, from, to common.Address, amount *big.Int) *types.MsgEthereumTx { + ctx := sdk.WrapSDKContext(suite.Ctx) + chainID := suite.App.EvmKeeper.ChainID() + + transferData, err := types.ERC20Contract.ABI.Pack("transfer", to, amount) + require.NoError(t, err) + args, err := json.Marshal(&types.TransactionArgs{To: &contractAddr, From: &from, Data: (*hexutil.Bytes)(&transferData)}) + require.NoError(t, err) + res, err := suite.QueryClient.EstimateGas(ctx, &types.EthCallRequest{ + Args: args, + GasCap: 25_000_000, + ProposerAddress: suite.Ctx.BlockHeader().ProposerAddress, + }) + require.NoError(t, err) + + nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) + + var ercTransferTx *types.MsgEthereumTx + if suite.enableFeemarket { + ercTransferTx = types.NewTx( + chainID, + nonce, + &contractAddr, + nil, + res.Gas, + nil, + suite.App.FeeMarketKeeper.GetBaseFee(suite.Ctx), + big.NewInt(1), + transferData, + ðtypes.AccessList{}, // accesses + ) + } else { + ercTransferTx = types.NewTx( + chainID, + nonce, + &contractAddr, + nil, + res.Gas, + nil, + nil, nil, + transferData, + nil, + ) + } + + ercTransferTx.From = suite.Address.Hex() + err = ercTransferTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.signer) + require.NoError(t, err) + rsp, err := suite.App.EvmKeeper.EthereumTx(ctx, ercTransferTx) + require.NoError(t, err) + require.Empty(t, rsp.VmError) + return ercTransferTx +} + +// DeployTestMessageCall deploy a test erc20 contract and returns the contract address +func (suite *KeeperTestSuite) DeployTestMessageCall(t require.TestingT) common.Address { + ctx := sdk.WrapSDKContext(suite.Ctx) + chainID := suite.App.EvmKeeper.ChainID() + + data := types.TestMessageCall.Bin + args, err := json.Marshal(&types.TransactionArgs{ + From: &suite.Address, + Data: (*hexutil.Bytes)(&data), + }) + require.NoError(t, err) + + res, err := suite.QueryClient.EstimateGas(ctx, &types.EthCallRequest{ + Args: args, + GasCap: uint64(config.DefaultGasCap), + ProposerAddress: suite.Ctx.BlockHeader().ProposerAddress, + }) + require.NoError(t, err) + + nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) + + var erc20DeployTx *types.MsgEthereumTx + if suite.enableFeemarket { + erc20DeployTx = types.NewTxContract( + chainID, + nonce, + nil, // amount + res.Gas, // gasLimit + nil, // gasPrice + suite.App.FeeMarketKeeper.GetBaseFee(suite.Ctx), + big.NewInt(1), + data, // input + ðtypes.AccessList{}, // accesses + ) + } else { + erc20DeployTx = types.NewTxContract( + chainID, + nonce, + nil, // amount + res.Gas, // gasLimit + nil, // gasPrice + nil, nil, + data, // input + nil, // accesses + ) + } + + erc20DeployTx.From = suite.Address.Hex() + err = erc20DeployTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.signer) + require.NoError(t, err) + rsp, err := suite.App.EvmKeeper.EthereumTx(ctx, erc20DeployTx) + require.NoError(t, err) + require.Empty(t, rsp.VmError) + return crypto.CreateAddress(suite.Address, nonce) +} + +func (suite *KeeperTestSuite) GetAllAccountStorage( + ctx sdk.Context, + addr common.Address, +) map[common.Hash]common.Hash { + states := make(map[common.Hash]common.Hash) + suite.App.EvmKeeper.ForEachStorage(ctx, addr, func(key, value common.Hash) bool { + states[key] = value + // Iterate all + return true + }) + + return states +} From 4db07a41e01b655fbfbcbecceaa4f4fc03774961 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Fri, 19 Jan 2024 13:13:30 -0800 Subject: [PATCH 18/52] Update all tests to work --- x/evm/statedb/statedb_test.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index 97a6527b81..e44e422768 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -138,6 +138,8 @@ func (suite *StateDBTestSuite) TestAccountOverride() { } func (suite *StateDBTestSuite) TestDBError() { + suite.T().Skip("Commit() no longer returns error") + testCases := []struct { name string malleate func(vm.StateDB) @@ -211,13 +213,19 @@ func (suite *StateDBTestSuite) TestState() { }, nil}, {"set empty value", func(db evm.StateDB) { db.SetState(address, key1, common.Hash{}) - }, map[common.Hash]common.Hash(nil)}, + }, map[common.Hash]common.Hash{ + // empty value still persisted + key1: common.Hash{}, + }}, {"noop state change", func(db evm.StateDB) { - // TODO: This doesn't actually change anything compared to committed state - // so it shouldn't be written to the keeper + // TODO: This doesn't actually change anything compared to committed state. + // Is this okay? db.SetState(address, key1, value1) db.SetState(address, key1, common.Hash{}) - }, map[common.Hash]common.Hash(nil)}, + }, map[common.Hash]common.Hash{ + // Still sets the key to an empty value even if there is no overall change + key1: common.Hash{}, + }}, {"set state", func(db evm.StateDB) { // check empty initial state suite.Require().Equal(common.Hash{}, db.GetState(address, key1)) @@ -249,7 +257,11 @@ func (suite *StateDBTestSuite) TestState() { // check committed states in keeper states := suite.GetAllAccountStorage(suite.Ctx, address) - suite.Require().Equal(tc.expStates, states) + if len(tc.expStates) > 0 { + suite.Require().Equal(tc.expStates, states) + } else { + suite.Require().Empty(states) + } // check ForEachStorage db = statedb.New(suite.Ctx, keeper, emptyTxConfig) From a8572e55e027ff509e51afe8204505ffcb3de8e5 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Fri, 19 Jan 2024 13:30:05 -0800 Subject: [PATCH 19/52] no-op when AddBalance with negative amounts --- x/evm/keeper/statedb_test.go | 4 +++- x/evm/statedb/statedb.go | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/x/evm/keeper/statedb_test.go b/x/evm/keeper/statedb_test.go index af60a73d9c..3a4acfc57c 100644 --- a/x/evm/keeper/statedb_test.go +++ b/x/evm/keeper/statedb_test.go @@ -84,7 +84,9 @@ func (suite *KeeperTestSuite) TestAddBalance() { { "negative amount", big.NewInt(-1), - false, // seems to be consistent with go-ethereum's implementation + // Pre-cache-ctx implementation allowed negative amounts, which + // seems to be consistent with go-ethereum's implementation + true, }, } diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 2b00f92074..9b2f04ae3c 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -253,14 +253,19 @@ func (s *StateDB) ForEachStorage(addr common.Address, cb func(key, value common. // AddBalance adds amount to the account associated with addr. func (s *StateDB) AddBalance(addr common.Address, amount *big.Int) { - if amount.Sign() == 0 { + // Only allow positive amounts. + // TODO: Geth apparently allows negative amounts, but can cause negative + // balance which is not allowed in bank keeper + if amount.Sign() != 1 { return } account := s.getOrNewAccount(addr) account.Balance = new(big.Int).Add(account.Balance, amount) - s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account) + if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account); err != nil { + panic(fmt.Errorf("failed to set account for balance addition: %w", err)) + } } // SubBalance subtracts amount from the account associated with addr. From 439ca8645d127504fb852225660264cbe7b90c78 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Fri, 19 Jan 2024 15:18:03 -0800 Subject: [PATCH 20/52] Remove unused journal types --- x/evm/statedb/access_list.go | 2 +- x/evm/statedb/journal.go | 14 -------------- x/evm/statedb/statedb.go | 4 +++- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/x/evm/statedb/access_list.go b/x/evm/statedb/access_list.go index e5f2c497b8..cf5953360c 100644 --- a/x/evm/statedb/access_list.go +++ b/x/evm/statedb/access_list.go @@ -47,7 +47,7 @@ func (al *accessList) Contains(address common.Address, slot common.Hash) (addres return true, slotPresent } -// newaccessListOld creates a new accessListOld. +// newAccessList creates a new newAccessList. func newAccessList() *accessList { return &accessList{ addresses: make(map[common.Address]int), diff --git a/x/evm/statedb/journal.go b/x/evm/statedb/journal.go index a305e872d2..ad22e0e7da 100644 --- a/x/evm/statedb/journal.go +++ b/x/evm/statedb/journal.go @@ -93,20 +93,6 @@ func (j *journal) length() int { } type ( - // Changes to the account trie. - createObjectChange struct { - account *common.Address - } - resetObjectChange struct { - prev *stateObject - } - - // Changes to other state values. - refundChange struct { - prev uint64 - } - addLogChange struct{} - // Changes to the access list accessListAddAccountChange struct { address *common.Address diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 9b2f04ae3c..1ae39ee2e5 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -404,7 +404,7 @@ func (s *StateDB) RevertToSnapshot(revid int) { // the StateDB object should be discarded after committed. func (s *StateDB) Commit() error { - // Delete suicided accounts + // Delete suicided accounts -- these still need to be committed suicidedAddrs := s.ephemeralStore.GetAllSuicided(s.ctx.CurrentCtx()) for _, addr := range suicidedAddrs { // Balance is also cleared as part of Keeper.DeleteAccount @@ -416,5 +416,7 @@ func (s *StateDB) Commit() error { // Commit after account deletions s.ctx.Commit() + // Journal only contains non-state content, so nothing to commit. + return nil } From b145c07d557d232e8658f8b6c971c159f971bef8 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 22 Jan 2024 10:40:21 -0800 Subject: [PATCH 21/52] fix: Include journal index in snapshot --- x/evm/statedb/ctx.go | 9 +++++---- x/evm/statedb/statedb.go | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/x/evm/statedb/ctx.go b/x/evm/statedb/ctx.go index b2c2aef45b..5c603a05b7 100644 --- a/x/evm/statedb/ctx.go +++ b/x/evm/statedb/ctx.go @@ -27,7 +27,7 @@ func NewSnapshotCtx(initialCtx sdk.Context) *SnapshotCommitCtx { // Create an initial snapshot of the initialCtx so no state is written until // Commit() is called. - _ = sCtx.Snapshot() + _ = sCtx.Snapshot(0) return sCtx } @@ -53,7 +53,9 @@ func (c *SnapshotCommitCtx) CurrentSnapshot() (ctxSnapshot, bool) { } // Snapshot creates a new branched context and returns the revision id. -func (c *SnapshotCommitCtx) Snapshot() int { +func (c *SnapshotCommitCtx) Snapshot( + journalIndex int, +) int { id := c.nextSnapshotID c.nextSnapshotID++ @@ -66,8 +68,7 @@ func (c *SnapshotCommitCtx) Snapshot() int { ctx: newCtx, write: newWrite, - // TODO: If still used later - // journalIndex: s.journal.length(), + journalIndex: journalIndex, }) return id diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 1ae39ee2e5..efba025270 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -386,7 +386,7 @@ func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addre // Snapshot returns an identifier for the current revision of the state. func (s *StateDB) Snapshot() int { - return s.ctx.Snapshot() + return s.ctx.Snapshot(s.journal.length()) } // RevertToSnapshot reverts all state changes made since the given revision. From c101b64077547d655a206f80c05c1fffe55ef539 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 22 Jan 2024 11:29:40 -0800 Subject: [PATCH 22/52] Start actual snapshots at id 0 --- x/evm/statedb/ctx.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/x/evm/statedb/ctx.go b/x/evm/statedb/ctx.go index 5c603a05b7..c75c89b1e8 100644 --- a/x/evm/statedb/ctx.go +++ b/x/evm/statedb/ctx.go @@ -20,9 +20,10 @@ type SnapshotCommitCtx struct { // NewSnapshotCtx creates a new SnapshotCtx from the initial context. func NewSnapshotCtx(initialCtx sdk.Context) *SnapshotCommitCtx { sCtx := &SnapshotCommitCtx{ - initialCtx: initialCtx, - snapshots: nil, - nextSnapshotID: 0, + initialCtx: initialCtx, + snapshots: nil, + // Starts at -1 so the first snapshot is 0 + nextSnapshotID: -1, } // Create an initial snapshot of the initialCtx so no state is written until From 6e3d16a0039d81ae418791fc1b994881847e9fbf Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 22 Jan 2024 11:50:58 -0800 Subject: [PATCH 23/52] Handle keeper errors, fix lints, remove use of MockKeeper --- x/evm/statedb/{mock_test.go => _mock_test.go} | 0 x/evm/statedb/benchmark_test.go | 56 ++++++++--- x/evm/statedb/ctx.go | 12 +-- x/evm/statedb/ctx_test.go | 4 +- x/evm/statedb/journal.go | 17 ---- x/evm/statedb/state_object.go | 29 ------ x/evm/statedb/statedb.go | 24 +++-- x/evm/statedb/statedb_test.go | 3 + x/evm/statedb/store.go | 26 ++--- x/evm/statedb/store_access_list.go | 97 ------------------- x/evm/testutil/suite.go | 2 - 11 files changed, 86 insertions(+), 184 deletions(-) rename x/evm/statedb/{mock_test.go => _mock_test.go} (100%) delete mode 100644 x/evm/statedb/store_access_list.go diff --git a/x/evm/statedb/mock_test.go b/x/evm/statedb/_mock_test.go similarity index 100% rename from x/evm/statedb/mock_test.go rename to x/evm/statedb/_mock_test.go diff --git a/x/evm/statedb/benchmark_test.go b/x/evm/statedb/benchmark_test.go index 29736cac09..300fbf5677 100644 --- a/x/evm/statedb/benchmark_test.go +++ b/x/evm/statedb/benchmark_test.go @@ -8,7 +8,9 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" + "github.com/evmos/ethermint/x/evm/keeper" "github.com/evmos/ethermint/x/evm/statedb" + "github.com/evmos/ethermint/x/evm/testutil" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" @@ -33,7 +35,9 @@ func NewTestContext() sdk.Context { } func benchmarkNestedSnapshot(b *testing.B, layers int) { - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + suite := GetTestSuite() + + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) for i := 0; i < layers; i++ { db.Snapshot() @@ -69,13 +73,17 @@ func BenchmarkNestedSnapshot16(b *testing.B) { } func benchmarkRevertToSnapshot(b *testing.B, layers int) { + suite := GetTestSuite() + + b.ResetTimer() + for i := 0; i < b.N; i++ { // Stop timer for setup -- can't be done before loop since we need to // reset the database after each revert // TODO: This takes way too long since RevertToSnapshot is really quick // compared to the setup b.StopTimer() - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) for i := 0; i < layers; i++ { db.Snapshot() @@ -107,7 +115,9 @@ func BenchmarkRevertToSnapshot16(b *testing.B) { } func BenchmarkAddBalance(b *testing.B) { - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + suite := GetTestSuite() + + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) b.ResetTimer() @@ -117,7 +127,8 @@ func BenchmarkAddBalance(b *testing.B) { } func BenchmarkSubBalance(b *testing.B) { - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + suite := GetTestSuite() + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) b.ResetTimer() @@ -127,7 +138,8 @@ func BenchmarkSubBalance(b *testing.B) { } func BenchmarkGetBalance(b *testing.B) { - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + suite := GetTestSuite() + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) b.ResetTimer() @@ -137,7 +149,8 @@ func BenchmarkGetBalance(b *testing.B) { } func BenchmarkGetNonce(b *testing.B) { - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + suite := GetTestSuite() + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) b.ResetTimer() @@ -147,7 +160,8 @@ func BenchmarkGetNonce(b *testing.B) { } func BenchmarkSetNonce(b *testing.B) { - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + suite := GetTestSuite() + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) b.ResetTimer() @@ -157,7 +171,8 @@ func BenchmarkSetNonce(b *testing.B) { } func BenchmarkGetCodeHash(b *testing.B) { - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + suite := GetTestSuite() + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) b.ResetTimer() @@ -167,7 +182,8 @@ func BenchmarkGetCodeHash(b *testing.B) { } func BenchmarkGetCode(b *testing.B) { - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + suite := GetTestSuite() + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) b.ResetTimer() @@ -177,7 +193,8 @@ func BenchmarkGetCode(b *testing.B) { } func BenchmarkAddLog(b *testing.B) { - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + suite := GetTestSuite() + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) log := ðtypes.Log{ Address: address, Topics: []common.Hash{common.BigToHash(big.NewInt(1))}, @@ -191,7 +208,8 @@ func BenchmarkAddLog(b *testing.B) { } func benchmarkGetLogs(b *testing.B, logEntries int) { - db := statedb.New(NewTestContext(), NewMockKeeper(), emptyTxConfig) + suite := GetTestSuite() + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) for i := 0; i < logEntries; i++ { log := ðtypes.Log{ @@ -223,3 +241,19 @@ func BenchmarkGetLogs64(b *testing.B) { func BenchmarkGetLogs512(b *testing.B) { benchmarkGetLogs(b, 512) } + +func GetTestSuite() *testutil.KeeperTestSuite { + // Just reuse the keeper test suite to setup and create a testing app + suite := testutil.KeeperTestSuite{} + suite.SetupTest() + + return &suite +} + +func GetTestKeeper() *keeper.Keeper { + // Just reuse the keeper test suite to setup and create a keeper + suite := testutil.KeeperTestSuite{} + suite.SetupTest() + + return suite.App.EvmKeeper +} diff --git a/x/evm/statedb/ctx.go b/x/evm/statedb/ctx.go index c75c89b1e8..6db3b6a214 100644 --- a/x/evm/statedb/ctx.go +++ b/x/evm/statedb/ctx.go @@ -11,7 +11,7 @@ import ( // only write state to the initial context when Commit() is called. type SnapshotCommitCtx struct { initialCtx sdk.Context - snapshots []ctxSnapshot + snapshots []CtxSnapshot // always incrementing snapshot ID, used to identify snapshots. nextSnapshotID int @@ -45,9 +45,9 @@ func (c *SnapshotCommitCtx) CurrentCtx() sdk.Context { // CurrentSnapshot returns the current snapshot and true if there is one, or // false if there are no snapshots. -func (c *SnapshotCommitCtx) CurrentSnapshot() (ctxSnapshot, bool) { +func (c *SnapshotCommitCtx) CurrentSnapshot() (CtxSnapshot, bool) { if len(c.snapshots) == 0 { - return ctxSnapshot{}, false + return CtxSnapshot{}, false } return c.snapshots[len(c.snapshots)-1], true @@ -64,7 +64,7 @@ func (c *SnapshotCommitCtx) Snapshot( newCtx, newWrite := c.CurrentCtx().CacheContext() // Save the new snapshot to the list - c.snapshots = append(c.snapshots, ctxSnapshot{ + c.snapshots = append(c.snapshots, CtxSnapshot{ id: id, ctx: newCtx, write: newWrite, @@ -108,8 +108,8 @@ func (c *SnapshotCommitCtx) Commit() { } } -// ctxSnapshot is a single snapshot with a branched context. -type ctxSnapshot struct { +// CtxSnapshot is a single snapshot with a branched context. +type CtxSnapshot struct { id int ctx sdk.Context write func() diff --git a/x/evm/statedb/ctx_test.go b/x/evm/statedb/ctx_test.go index 886e0b2b8e..67cd879eb6 100644 --- a/x/evm/statedb/ctx_test.go +++ b/x/evm/statedb/ctx_test.go @@ -26,7 +26,7 @@ func TestSnapshotCommitCtx(t *testing.T) { // Make a snapshot previousCtx := snapshotCtx.CurrentCtx() - snapshotID := snapshotCtx.Snapshot() + snapshotID := snapshotCtx.Snapshot(0) require.Equal(t, 1, snapshotID, "snapshot id should be 1") require.NotEqual(t, previousCtx, snapshotCtx.CurrentCtx(), "CurrentCtx should be branched") @@ -52,7 +52,7 @@ func TestRevert(t *testing.T) { snapshotCtx := statedb.NewSnapshotCtx(initialCtx) // Make a snapshot - snapshotID := snapshotCtx.Snapshot() + snapshotID := snapshotCtx.Snapshot(0) // Revert to the snapshot snapshotCtx.Revert(snapshotID) diff --git a/x/evm/statedb/journal.go b/x/evm/statedb/journal.go index ad22e0e7da..59162de4d2 100644 --- a/x/evm/statedb/journal.go +++ b/x/evm/statedb/journal.go @@ -17,9 +17,6 @@ package statedb import ( - "bytes" - "sort" - "github.com/ethereum/go-ethereum/common" ) @@ -48,20 +45,6 @@ func newJournal() *journal { } } -// sortedDirties sort the dirty addresses for deterministic iteration -func (j *journal) sortedDirties() []common.Address { - keys := make([]common.Address, len(j.dirties)) - i := 0 - for k := range j.dirties { - keys[i] = k - i++ - } - sort.Slice(keys, func(i, j int) bool { - return bytes.Compare(keys[i].Bytes(), keys[j].Bytes()) < 0 - }) - return keys -} - // append inserts a new modification entry to the end of the change journal. func (j *journal) append(entry JournalEntry) { j.entries = append(j.entries, entry) diff --git a/x/evm/statedb/state_object.go b/x/evm/statedb/state_object.go index 1bffc96519..9c19d7eb45 100644 --- a/x/evm/statedb/state_object.go +++ b/x/evm/statedb/state_object.go @@ -17,12 +17,10 @@ package statedb import ( "bytes" - "math/big" "sort" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/evmos/ethermint/x/evm/types" ) var emptyCodeHash = crypto.Keccak256(nil) @@ -43,30 +41,3 @@ func (s Storage) SortedKeys() []common.Hash { }) return keys } - -// stateObject is the state of an acount -type stateObject struct { - db *StateDB - - address common.Address - - suicided bool -} - -// newObject creates a state object. -func newObject(db *StateDB, address common.Address, account types.StateDBAccount) *stateObject { - if account.Balance == nil { - account.Balance = new(big.Int) - } - if account.CodeHash == nil { - account.CodeHash = emptyCodeHash - } - return &stateObject{ - db: db, - address: address, - } -} - -func (s *stateObject) markSuicided() { - s.suicided = true -} diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index efba025270..446e8d8b7e 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -40,7 +40,7 @@ type StateDB struct { keeper evm.StateDBKeeper ctx *SnapshotCommitCtx // snapshot-able ctx manager - ephemeralStore *StateDBStore // store for ephemeral data + ephemeralStore *Store // store for ephemeral data // Journal of state modifications. This is the backbone of // Snapshot and RevertToSnapshot. @@ -80,7 +80,7 @@ func (s *StateDB) AddLog(log *ethtypes.Log) { log.TxHash = s.txConfig.TxHash log.BlockHash = s.txConfig.BlockHash log.TxIndex = s.txConfig.TxIndex - log.Index = s.txConfig.LogIndex + uint(s.ephemeralStore.GetLogIndex(s.ctx.CurrentCtx())) + log.Index = s.txConfig.LogIndex + s.ephemeralStore.GetLogIndex(s.ctx.CurrentCtx()) s.ephemeralStore.AddLog(s.ctx.CurrentCtx(), log) s.ephemeralStore.SetLogIndex(s.ctx.CurrentCtx(), log.Index) @@ -226,7 +226,9 @@ func (s *StateDB) CreateAccount(addr common.Address) { account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) if account == nil { // No account found, create a new one - s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *types.NewEmptyAccount()) + if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *types.NewEmptyAccount()); err != nil { + panic(fmt.Errorf("failed to create account: %w", err)) + } return } @@ -238,7 +240,9 @@ func (s *StateDB) CreateAccount(addr common.Address) { newAccount := types.NewEmptyAccount() newAccount.Balance = account.Balance - s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *newAccount) + if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *newAccount); err != nil { + panic(fmt.Errorf("failed to create account: %w", err)) + } } // ForEachStorage iterate the contract storage, the iteration order is not defined. @@ -277,7 +281,9 @@ func (s *StateDB) SubBalance(addr common.Address, amount *big.Int) { account := s.getOrNewAccount(addr) account.Balance = new(big.Int).Sub(account.Balance, amount) - s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account) + if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account); err != nil { + panic(fmt.Errorf("failed to set account for balance subtraction: %w", err)) + } } // SetNonce sets the nonce of account. @@ -285,15 +291,19 @@ func (s *StateDB) SetNonce(addr common.Address, nonce uint64) { account := s.getOrNewAccount(addr) account.Nonce = nonce - s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account) + if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account); err != nil { + panic(fmt.Errorf("failed to set account for nonce: %w", err)) + } } // SetCode sets the code of account. func (s *StateDB) SetCode(addr common.Address, code []byte) { account := s.getOrNewAccount(addr) account.CodeHash = crypto.Keccak256Hash(code).Bytes() - s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account) + if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account); err != nil { + panic(fmt.Errorf("failed to set account for code: %w", err)) + } s.keeper.SetCode(s.ctx.CurrentCtx(), account.CodeHash, code) } diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index e44e422768..cb90e6c95c 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -23,6 +23,9 @@ var ( address3 common.Address = common.BigToAddress(big.NewInt(103)) blockHash common.Hash = common.BigToHash(big.NewInt(9999)) emptyTxConfig types.TxConfig = types.NewEmptyTxConfig(blockHash) + + errAddress common.Address = common.BigToAddress(big.NewInt(100)) + emptyCodeHash = crypto.Keccak256(nil) ) type StateDBTestSuite struct { diff --git a/x/evm/statedb/store.go b/x/evm/statedb/store.go index 0ab331a338..dea457095d 100644 --- a/x/evm/statedb/store.go +++ b/x/evm/statedb/store.go @@ -18,18 +18,18 @@ var ( SuicidedKey = []byte{0x06} ) -type StateDBStore struct { +type Store struct { key storetypes.StoreKey } -func NewStateDBStore(storeKey storetypes.StoreKey) *StateDBStore { - return &StateDBStore{ +func NewStateDBStore(storeKey storetypes.StoreKey) *Store { + return &Store{ key: storeKey, } } // GetLogIndex returns the current log index. -func (ls *StateDBStore) GetLogIndex(ctx sdk.Context) uint { +func (ls *Store) GetLogIndex(ctx sdk.Context) uint { store := prefix.NewStore(ctx.KVStore(ls.key), LogIndexKey) bz := store.Get(LogIndexKey) if bz == nil { @@ -40,13 +40,13 @@ func (ls *StateDBStore) GetLogIndex(ctx sdk.Context) uint { return uint(index) } -func (ls *StateDBStore) SetLogIndex(ctx sdk.Context, index uint) { +func (ls *Store) SetLogIndex(ctx sdk.Context, index uint) { store := prefix.NewStore(ctx.KVStore(ls.key), LogIndexKey) store.Set(LogIndexKey, sdk.Uint64ToBigEndian(uint64(index))) } // AddLog adds a log to the store. -func (ls *StateDBStore) AddLog(ctx sdk.Context, log *ethtypes.Log) { +func (ls *Store) AddLog(ctx sdk.Context, log *ethtypes.Log) { store := prefix.NewStore(ctx.KVStore(ls.key), LogKey) bz, err := log.MarshalJSON() if err != nil { @@ -56,7 +56,7 @@ func (ls *StateDBStore) AddLog(ctx sdk.Context, log *ethtypes.Log) { store.Set(sdk.Uint64ToBigEndian(uint64(log.Index)), bz) } -func (ls *StateDBStore) GetAllLogs(ctx sdk.Context) []*ethtypes.Log { +func (ls *Store) GetAllLogs(ctx sdk.Context) []*ethtypes.Log { store := prefix.NewStore(ctx.KVStore(ls.key), LogKey) var logs []*ethtypes.Log @@ -77,7 +77,7 @@ func (ls *StateDBStore) GetAllLogs(ctx sdk.Context) []*ethtypes.Log { } // AddRefund adds a refund to the store. -func (ls *StateDBStore) AddRefund(ctx sdk.Context, gas uint64) { +func (ls *Store) AddRefund(ctx sdk.Context, gas uint64) { store := prefix.NewStore(ctx.KVStore(ls.key), RefundKey) // Add to existing refund bz := store.Get(RefundKey) @@ -88,7 +88,7 @@ func (ls *StateDBStore) AddRefund(ctx sdk.Context, gas uint64) { store.Set(RefundKey, sdk.Uint64ToBigEndian(gas)) } -func (ls *StateDBStore) SubRefund(ctx sdk.Context, gas uint64) { +func (ls *Store) SubRefund(ctx sdk.Context, gas uint64) { store := prefix.NewStore(ctx.KVStore(ls.key), RefundKey) // Subtract from existing refund bz := store.Get(RefundKey) @@ -106,7 +106,7 @@ func (ls *StateDBStore) SubRefund(ctx sdk.Context, gas uint64) { store.Set(RefundKey, sdk.Uint64ToBigEndian(gas)) } -func (ls *StateDBStore) GetRefund(ctx sdk.Context) uint64 { +func (ls *Store) GetRefund(ctx sdk.Context) uint64 { store := prefix.NewStore(ctx.KVStore(ls.key), RefundKey) bz := store.Get(RefundKey) if bz == nil { @@ -115,17 +115,17 @@ func (ls *StateDBStore) GetRefund(ctx sdk.Context) uint64 { return sdk.BigEndianToUint64(bz) } -func (ls *StateDBStore) SetAccountSuicided(ctx sdk.Context, addr common.Address) { +func (ls *Store) SetAccountSuicided(ctx sdk.Context, addr common.Address) { store := prefix.NewStore(ctx.KVStore(ls.key), SuicidedKey) store.Set(addr.Bytes(), []byte{1}) } -func (ls *StateDBStore) GetAccountSuicided(ctx sdk.Context, addr common.Address) bool { +func (ls *Store) GetAccountSuicided(ctx sdk.Context, addr common.Address) bool { store := prefix.NewStore(ctx.KVStore(ls.key), SuicidedKey) return store.Has(addr.Bytes()) } -func (ls *StateDBStore) GetAllSuicided(ctx sdk.Context) []common.Address { +func (ls *Store) GetAllSuicided(ctx sdk.Context) []common.Address { store := prefix.NewStore(ctx.KVStore(ls.key), SuicidedKey) var addrs []common.Address diff --git a/x/evm/statedb/store_access_list.go b/x/evm/statedb/store_access_list.go deleted file mode 100644 index bd84ee0778..0000000000 --- a/x/evm/statedb/store_access_list.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2020 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package statedb - -import ( - "github.com/cosmos/cosmos-sdk/store/prefix" - "github.com/ethereum/go-ethereum/common" - - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type sdkAccessList struct { - key storetypes.StoreKey -} - -// ContainsAddress returns true if the address is in the access list. -func (al *sdkAccessList) ContainsAddress(ctx sdk.Context, address common.Address) bool { - store := prefix.NewStore(ctx.KVStore(al.key), AccessListAddressKey) - return store.Has(address.Bytes()) -} - -// Contains checks if a slot within an account is present in the access list, returning -// separate flags for the presence of the account and the slot respectively. -func (al *sdkAccessList) Contains( - ctx sdk.Context, - address common.Address, - slot common.Hash, -) (addressPresent bool, slotPresent bool) { - addressPresent = al.ContainsAddress(ctx, address) - if !addressPresent { - // no address so no slots - return false, false - } - - store := prefix.NewStore(ctx.KVStore(al.key), AccessListAddressSlotKey) - slotPresent = store.Has(append(address.Bytes(), slot.Bytes()...)) - - return true, slotPresent -} - -// newSdkAccessList creates a new accessList. -func newSdkAccessList(storeKey storetypes.StoreKey) *sdkAccessList { - return &sdkAccessList{ - key: storeKey, - } -} - -// AddAddress adds an address to the access list, and returns 'true' if the operation -// caused a change (addr was not previously in the list). -func (al *sdkAccessList) AddAddress(ctx sdk.Context, address common.Address) bool { - store := prefix.NewStore(ctx.KVStore(al.key), AccessListAddressKey) - if store.Has(address.Bytes()) { - return false - } - - store.Set(address.Bytes(), []byte{}) - return true -} - -// AddSlot adds the specified (addr, slot) combo to the access list. -// Return values are: -// - address added -// - slot added -// For any 'true' value returned, a corresponding journal entry must be made. -func (al *sdkAccessList) AddSlot( - ctx sdk.Context, - address common.Address, - slot common.Hash, -) (addrChange bool, slotChange bool) { - // Add address if not present - addrChange = al.AddAddress(ctx, address) - - // Add slot if not present - store := prefix.NewStore(ctx.KVStore(al.key), AccessListAddressSlotKey) - if store.Has(append(address.Bytes(), slot.Bytes()...)) { - // Already contains the slot - return addrChange, false - } - - store.Set(append(address.Bytes(), slot.Bytes()...), []byte{}) - return addrChange, true -} diff --git a/x/evm/testutil/suite.go b/x/evm/testutil/suite.go index 94a88ca575..36b7472117 100644 --- a/x/evm/testutil/suite.go +++ b/x/evm/testutil/suite.go @@ -71,8 +71,6 @@ type KeeperTestSuite struct { denom string } -var s *KeeperTestSuite - func (suite *KeeperTestSuite) SetupTest() { checkTx := false suite.App = app.Setup(checkTx, nil) From 3bb8587ac8c7e3f58e9146bd860a015b69771102 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 22 Jan 2024 11:59:15 -0800 Subject: [PATCH 24/52] Fix statedb benchmarks --- x/evm/keeper/statedb_benchmark_test.go | 3 ++ x/evm/statedb/benchmark_test.go | 66 +++++--------------------- x/evm/statedb/ctx_test.go | 2 +- 3 files changed, 16 insertions(+), 55 deletions(-) diff --git a/x/evm/keeper/statedb_benchmark_test.go b/x/evm/keeper/statedb_benchmark_test.go index bf141052aa..fd9cba03dd 100644 --- a/x/evm/keeper/statedb_benchmark_test.go +++ b/x/evm/keeper/statedb_benchmark_test.go @@ -141,6 +141,9 @@ func BenchmarkSubBalance(b *testing.B) { amt := big.NewInt(10) + // Add enough balance to cover all subtractions + vmdb.AddBalance(suite.address, new(big.Int).Mul(amt, big.NewInt(int64(b.N)))) + b.ResetTimer() b.ReportAllocs() diff --git a/x/evm/statedb/benchmark_test.go b/x/evm/statedb/benchmark_test.go index 300fbf5677..ec4073f54a 100644 --- a/x/evm/statedb/benchmark_test.go +++ b/x/evm/statedb/benchmark_test.go @@ -35,7 +35,7 @@ func NewTestContext() sdk.Context { } func benchmarkNestedSnapshot(b *testing.B, layers int) { - suite := GetTestSuite() + suite := GetTestSuite(b) db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) @@ -72,50 +72,8 @@ func BenchmarkNestedSnapshot16(b *testing.B) { benchmarkNestedSnapshot(b, 16) } -func benchmarkRevertToSnapshot(b *testing.B, layers int) { - suite := GetTestSuite() - - b.ResetTimer() - - for i := 0; i < b.N; i++ { - // Stop timer for setup -- can't be done before loop since we need to - // reset the database after each revert - // TODO: This takes way too long since RevertToSnapshot is really quick - // compared to the setup - b.StopTimer() - db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) - - for i := 0; i < layers; i++ { - db.Snapshot() - - key := common.BigToHash(big.NewInt(int64(i))) - value := common.BigToHash(big.NewInt(int64(i + 1))) - db.SetState(address, key, value) - } - b.StartTimer() - - db.RevertToSnapshot(0) - } -} - -func BenchmarkRevertToSnapshot1(b *testing.B) { - benchmarkRevertToSnapshot(b, 1) -} - -func BenchmarkRevertToSnapshot4(b *testing.B) { - benchmarkRevertToSnapshot(b, 4) -} - -func BenchmarkRevertToSnapshot8(b *testing.B) { - benchmarkRevertToSnapshot(b, 8) -} - -func BenchmarkRevertToSnapshot16(b *testing.B) { - benchmarkRevertToSnapshot(b, 16) -} - func BenchmarkAddBalance(b *testing.B) { - suite := GetTestSuite() + suite := GetTestSuite(b) db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) @@ -127,7 +85,7 @@ func BenchmarkAddBalance(b *testing.B) { } func BenchmarkSubBalance(b *testing.B) { - suite := GetTestSuite() + suite := GetTestSuite(b) db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) b.ResetTimer() @@ -138,7 +96,7 @@ func BenchmarkSubBalance(b *testing.B) { } func BenchmarkGetBalance(b *testing.B) { - suite := GetTestSuite() + suite := GetTestSuite(b) db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) b.ResetTimer() @@ -149,7 +107,7 @@ func BenchmarkGetBalance(b *testing.B) { } func BenchmarkGetNonce(b *testing.B) { - suite := GetTestSuite() + suite := GetTestSuite(b) db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) b.ResetTimer() @@ -160,7 +118,7 @@ func BenchmarkGetNonce(b *testing.B) { } func BenchmarkSetNonce(b *testing.B) { - suite := GetTestSuite() + suite := GetTestSuite(b) db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) b.ResetTimer() @@ -171,7 +129,7 @@ func BenchmarkSetNonce(b *testing.B) { } func BenchmarkGetCodeHash(b *testing.B) { - suite := GetTestSuite() + suite := GetTestSuite(b) db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) b.ResetTimer() @@ -182,7 +140,7 @@ func BenchmarkGetCodeHash(b *testing.B) { } func BenchmarkGetCode(b *testing.B) { - suite := GetTestSuite() + suite := GetTestSuite(b) db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) b.ResetTimer() @@ -193,7 +151,7 @@ func BenchmarkGetCode(b *testing.B) { } func BenchmarkAddLog(b *testing.B) { - suite := GetTestSuite() + suite := GetTestSuite(b) db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) log := ðtypes.Log{ Address: address, @@ -208,7 +166,7 @@ func BenchmarkAddLog(b *testing.B) { } func benchmarkGetLogs(b *testing.B, logEntries int) { - suite := GetTestSuite() + suite := GetTestSuite(b) db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) for i := 0; i < logEntries; i++ { @@ -242,10 +200,10 @@ func BenchmarkGetLogs512(b *testing.B) { benchmarkGetLogs(b, 512) } -func GetTestSuite() *testutil.KeeperTestSuite { +func GetTestSuite(b *testing.B) *testutil.KeeperTestSuite { // Just reuse the keeper test suite to setup and create a testing app suite := testutil.KeeperTestSuite{} - suite.SetupTest() + suite.SetupTestWithT(b) return &suite } diff --git a/x/evm/statedb/ctx_test.go b/x/evm/statedb/ctx_test.go index 67cd879eb6..17d3a66c50 100644 --- a/x/evm/statedb/ctx_test.go +++ b/x/evm/statedb/ctx_test.go @@ -27,7 +27,7 @@ func TestSnapshotCommitCtx(t *testing.T) { // Make a snapshot previousCtx := snapshotCtx.CurrentCtx() snapshotID := snapshotCtx.Snapshot(0) - require.Equal(t, 1, snapshotID, "snapshot id should be 1") + require.Equal(t, 0, snapshotID, "initial snapshot id should be 0") require.NotEqual(t, previousCtx, snapshotCtx.CurrentCtx(), "CurrentCtx should be branched") // Write to the snapshot From a97d3d5d0a4fd2e027fa1b0a675dc2aad21bf5a1 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 22 Jan 2024 11:59:34 -0800 Subject: [PATCH 25/52] Delete mock keeper --- x/evm/statedb/_mock_test.go | 134 ------------------------------------ 1 file changed, 134 deletions(-) delete mode 100644 x/evm/statedb/_mock_test.go diff --git a/x/evm/statedb/_mock_test.go b/x/evm/statedb/_mock_test.go deleted file mode 100644 index 5f7d0fb9ed..0000000000 --- a/x/evm/statedb/_mock_test.go +++ /dev/null @@ -1,134 +0,0 @@ -package statedb_test - -import ( - "bytes" - "errors" - "math/big" - - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/evmos/ethermint/x/evm/statedb" - "github.com/evmos/ethermint/x/evm/types" - "github.com/evmos/ethermint/x/evm/vm" -) - -var ( - _ vm.StateDBKeeper = &MockKeeper{} - errAddress common.Address = common.BigToAddress(big.NewInt(100)) - emptyCodeHash = crypto.Keccak256(nil) -) - -type MockAcount struct { - account types.StateDBAccount - states statedb.Storage -} - -type MockKeeper struct { - Accounts map[common.Address]MockAcount - Codes map[common.Hash][]byte -} - -func NewMockKeeper() *MockKeeper { - return &MockKeeper{ - Accounts: make(map[common.Address]MockAcount), - Codes: make(map[common.Hash][]byte), - } -} - -func (k MockKeeper) GetAccount(ctx sdk.Context, addr common.Address) *types.StateDBAccount { - acct, ok := k.Accounts[addr] - if !ok { - return nil - } - return &acct.account -} - -func (k MockKeeper) GetState(ctx sdk.Context, addr common.Address, key common.Hash) common.Hash { - return k.Accounts[addr].states[key] -} - -func (k MockKeeper) GetCode(ctx sdk.Context, codeHash common.Hash) []byte { - return k.Codes[codeHash] -} - -func (k MockKeeper) ForEachStorage(ctx sdk.Context, addr common.Address, cb func(key, value common.Hash) bool) { - if acct, ok := k.Accounts[addr]; ok { - for k, v := range acct.states { - if !cb(k, v) { - return - } - } - } -} - -func (k MockKeeper) SetAccount(ctx sdk.Context, addr common.Address, account types.StateDBAccount) error { - if addr == errAddress { - return errors.New("mock db error") - } - acct, exists := k.Accounts[addr] - if exists { - // update - acct.account = account - k.Accounts[addr] = acct - } else { - k.Accounts[addr] = MockAcount{account: account, states: make(statedb.Storage)} - } - return nil -} - -func (k MockKeeper) SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte) { - if acct, ok := k.Accounts[addr]; ok { - if len(value) == 0 { - delete(acct.states, key) - } else { - acct.states[key] = common.BytesToHash(value) - } - } -} - -func (k MockKeeper) SetCode(ctx sdk.Context, codeHash []byte, code []byte) { - k.Codes[common.BytesToHash(codeHash)] = code -} - -func (k MockKeeper) SetBalance(ctx sdk.Context, addr common.Address, amount *big.Int) error { - if addr == errAddress { - return errors.New("mock db error") - } - acct, ok := k.Accounts[addr] - if !ok { - return errors.New("account not found") - } - acct.account.Balance = amount - k.Accounts[addr] = acct - return nil -} - -func (k MockKeeper) DeleteAccount(ctx sdk.Context, addr common.Address) error { - if addr == errAddress { - return errors.New("mock db error") - } - old := k.Accounts[addr] - delete(k.Accounts, addr) - if !bytes.Equal(old.account.CodeHash, emptyCodeHash) { - delete(k.Codes, common.BytesToHash(old.account.CodeHash)) - } - return nil -} - -func (k MockKeeper) Clone() *MockKeeper { - accounts := make(map[common.Address]MockAcount, len(k.Accounts)) - for k, v := range k.Accounts { - accounts[k] = v - } - codes := make(map[common.Hash][]byte, len(k.Codes)) - for k, v := range k.Codes { - codes[k] = v - } - return &MockKeeper{accounts, codes} -} - -func (k MockKeeper) GetTransientKey() storetypes.StoreKey { - return testKvStoreKey -} From 7c175f6ccff6a0a0c7375c379a90672de0139938 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 25 Jan 2024 11:26:48 -0800 Subject: [PATCH 26/52] Keep logs in slice instead of sdk store --- x/evm/statedb/ctx.go | 4 ++- x/evm/statedb/ctx_test.go | 4 +-- x/evm/statedb/statedb.go | 15 +++++++---- x/evm/statedb/store.go | 55 ++------------------------------------- 4 files changed, 17 insertions(+), 61 deletions(-) diff --git a/x/evm/statedb/ctx.go b/x/evm/statedb/ctx.go index 6db3b6a214..ac434cf363 100644 --- a/x/evm/statedb/ctx.go +++ b/x/evm/statedb/ctx.go @@ -28,7 +28,7 @@ func NewSnapshotCtx(initialCtx sdk.Context) *SnapshotCommitCtx { // Create an initial snapshot of the initialCtx so no state is written until // Commit() is called. - _ = sCtx.Snapshot(0) + _ = sCtx.Snapshot(0, 0) return sCtx } @@ -56,6 +56,7 @@ func (c *SnapshotCommitCtx) CurrentSnapshot() (CtxSnapshot, bool) { // Snapshot creates a new branched context and returns the revision id. func (c *SnapshotCommitCtx) Snapshot( journalIndex int, + logsIndex int, ) int { id := c.nextSnapshotID c.nextSnapshotID++ @@ -116,4 +117,5 @@ type CtxSnapshot struct { // Journal used only for in-memory things like logs and access list journalIndex int + logsIndex int } diff --git a/x/evm/statedb/ctx_test.go b/x/evm/statedb/ctx_test.go index 17d3a66c50..8155da4dd0 100644 --- a/x/evm/statedb/ctx_test.go +++ b/x/evm/statedb/ctx_test.go @@ -26,7 +26,7 @@ func TestSnapshotCommitCtx(t *testing.T) { // Make a snapshot previousCtx := snapshotCtx.CurrentCtx() - snapshotID := snapshotCtx.Snapshot(0) + snapshotID := snapshotCtx.Snapshot(0, 0) require.Equal(t, 0, snapshotID, "initial snapshot id should be 0") require.NotEqual(t, previousCtx, snapshotCtx.CurrentCtx(), "CurrentCtx should be branched") @@ -52,7 +52,7 @@ func TestRevert(t *testing.T) { snapshotCtx := statedb.NewSnapshotCtx(initialCtx) // Make a snapshot - snapshotID := snapshotCtx.Snapshot(0) + snapshotID := snapshotCtx.Snapshot(0, 0) // Revert to the snapshot snapshotCtx.Revert(snapshotID) diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 446e8d8b7e..438176c792 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -50,6 +50,8 @@ type StateDB struct { // Per-transaction access list accessList *accessList + + logs []*ethtypes.Log } // New creates a new state from a given trie. @@ -65,6 +67,7 @@ func New(ctx sdk.Context, keeper evm.StateDBKeeper, txConfig types.TxConfig) evm ephemeralStore: NewStateDBStore(keeper.GetTransientKey()), txConfig: txConfig, + logs: nil, } return statedb @@ -80,15 +83,14 @@ func (s *StateDB) AddLog(log *ethtypes.Log) { log.TxHash = s.txConfig.TxHash log.BlockHash = s.txConfig.BlockHash log.TxIndex = s.txConfig.TxIndex - log.Index = s.txConfig.LogIndex + s.ephemeralStore.GetLogIndex(s.ctx.CurrentCtx()) + log.Index = s.txConfig.LogIndex + uint(len(s.logs)) - s.ephemeralStore.AddLog(s.ctx.CurrentCtx(), log) - s.ephemeralStore.SetLogIndex(s.ctx.CurrentCtx(), log.Index) + s.logs = append(s.logs, log) } // Logs returns the logs of current transaction. func (s *StateDB) Logs() []*ethtypes.Log { - return s.ephemeralStore.GetAllLogs(s.ctx.CurrentCtx()) + return s.logs } // AddRefund adds gas to the refund counter @@ -396,7 +398,7 @@ func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addre // Snapshot returns an identifier for the current revision of the state. func (s *StateDB) Snapshot() int { - return s.ctx.Snapshot(s.journal.length()) + return s.ctx.Snapshot(s.journal.length(), len(s.logs)) } // RevertToSnapshot reverts all state changes made since the given revision. @@ -410,6 +412,9 @@ func (s *StateDB) RevertToSnapshot(revid int) { // Revert journal to the latest snapshot's journal index s.journal.Revert(s, currentSnapshot.journalIndex) + + // Revert logs to the latest snapshot's logs index + s.logs = s.logs[:currentSnapshot.logsIndex] } // the StateDB object should be discarded after committed. diff --git a/x/evm/statedb/store.go b/x/evm/statedb/store.go index dea457095d..bece8b33f1 100644 --- a/x/evm/statedb/store.go +++ b/x/evm/statedb/store.go @@ -5,17 +5,14 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" ) var ( AccessListAddressKey = []byte{0x01} // common.Address AccessListAddressSlotKey = []byte{0x02} // (common.Address, common.Hash) - LogKey = []byte{0x03} - LogIndexKey = []byte{0x04} - RefundKey = []byte{0x05} - SuicidedKey = []byte{0x06} + RefundKey = []byte{0x03} + SuicidedKey = []byte{0x04} ) type Store struct { @@ -28,54 +25,6 @@ func NewStateDBStore(storeKey storetypes.StoreKey) *Store { } } -// GetLogIndex returns the current log index. -func (ls *Store) GetLogIndex(ctx sdk.Context) uint { - store := prefix.NewStore(ctx.KVStore(ls.key), LogIndexKey) - bz := store.Get(LogIndexKey) - if bz == nil { - return 0 - } - - index := sdk.BigEndianToUint64(bz) - return uint(index) -} - -func (ls *Store) SetLogIndex(ctx sdk.Context, index uint) { - store := prefix.NewStore(ctx.KVStore(ls.key), LogIndexKey) - store.Set(LogIndexKey, sdk.Uint64ToBigEndian(uint64(index))) -} - -// AddLog adds a log to the store. -func (ls *Store) AddLog(ctx sdk.Context, log *ethtypes.Log) { - store := prefix.NewStore(ctx.KVStore(ls.key), LogKey) - bz, err := log.MarshalJSON() - if err != nil { - panic(err) - } - - store.Set(sdk.Uint64ToBigEndian(uint64(log.Index)), bz) -} - -func (ls *Store) GetAllLogs(ctx sdk.Context) []*ethtypes.Log { - store := prefix.NewStore(ctx.KVStore(ls.key), LogKey) - - var logs []*ethtypes.Log - - iter := sdk.KVStorePrefixIterator(store, []byte{}) - defer iter.Close() - - for ; iter.Valid(); iter.Next() { - var log ethtypes.Log - err := log.UnmarshalJSON(iter.Value()) - if err != nil { - panic(err) - } - logs = append(logs, &log) - } - - return logs -} - // AddRefund adds a refund to the store. func (ls *Store) AddRefund(ctx sdk.Context, gas uint64) { store := prefix.NewStore(ctx.KVStore(ls.key), RefundKey) From 5846760d648f8c8646ffb7e3b2082e7af5572ecf Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 29 Jan 2024 10:53:42 -0800 Subject: [PATCH 27/52] feat: Return error on Commit() instead of panic on individual methods --- x/evm/keeper/statedb_test.go | 2 +- x/evm/statedb/statedb.go | 28 ++++++++++++++++++---------- x/evm/statedb/statedb_test.go | 2 -- x/evm/statedb/store.go | 7 ++----- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/x/evm/keeper/statedb_test.go b/x/evm/keeper/statedb_test.go index 3a4acfc57c..1374e553de 100644 --- a/x/evm/keeper/statedb_test.go +++ b/x/evm/keeper/statedb_test.go @@ -117,7 +117,7 @@ func (suite *KeeperTestSuite) TestSubBalance() { "positive amount, below zero", big.NewInt(100), func(vm.StateDB) {}, - false, + true, }, { "positive amount, above zero", diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 438176c792..035a1c30c8 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -50,8 +50,9 @@ type StateDB struct { // Per-transaction access list accessList *accessList + logs []*ethtypes.Log - logs []*ethtypes.Log + sdkError error } // New creates a new state from a given trie. @@ -229,8 +230,9 @@ func (s *StateDB) CreateAccount(addr common.Address) { if account == nil { // No account found, create a new one if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *types.NewEmptyAccount()); err != nil { - panic(fmt.Errorf("failed to create account: %w", err)) + s.sdkError = fmt.Errorf("failed to create account: %w", err) } + return } @@ -243,7 +245,7 @@ func (s *StateDB) CreateAccount(addr common.Address) { newAccount.Balance = account.Balance if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *newAccount); err != nil { - panic(fmt.Errorf("failed to create account: %w", err)) + s.sdkError = fmt.Errorf("failed to create account: %w", err) } } @@ -270,7 +272,7 @@ func (s *StateDB) AddBalance(addr common.Address, amount *big.Int) { account.Balance = new(big.Int).Add(account.Balance, amount) if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account); err != nil { - panic(fmt.Errorf("failed to set account for balance addition: %w", err)) + s.sdkError = fmt.Errorf("failed to set account for balance addition: %w", err) } } @@ -284,7 +286,7 @@ func (s *StateDB) SubBalance(addr common.Address, amount *big.Int) { account.Balance = new(big.Int).Sub(account.Balance, amount) if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account); err != nil { - panic(fmt.Errorf("failed to set account for balance subtraction: %w", err)) + s.sdkError = fmt.Errorf("failed to set account for balance subtraction: %w", err) } } @@ -294,7 +296,7 @@ func (s *StateDB) SetNonce(addr common.Address, nonce uint64) { account.Nonce = nonce if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account); err != nil { - panic(fmt.Errorf("failed to set account for nonce: %w", err)) + s.sdkError = fmt.Errorf("failed to set account for nonce: %w", err) } } @@ -304,7 +306,7 @@ func (s *StateDB) SetCode(addr common.Address, code []byte) { account.CodeHash = crypto.Keccak256Hash(code).Bytes() if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account); err != nil { - panic(fmt.Errorf("failed to set account for code: %w", err)) + s.sdkError = fmt.Errorf("failed to set account for code: %w", err) } s.keeper.SetCode(s.ctx.CurrentCtx(), account.CodeHash, code) } @@ -327,7 +329,7 @@ func (s *StateDB) Suicide(addr common.Address) bool { // Balance cleared, but code and state should still be available until Commit() if err := s.keeper.SetBalance(s.ctx.CurrentCtx(), addr, common.Big0); err != nil { - panic(fmt.Errorf("failed to delete suicided account: %w", err)) + s.sdkError = fmt.Errorf("failed to delete suicided account: %w", err) } s.ephemeralStore.SetAccountSuicided(s.ctx.CurrentCtx(), addr) @@ -419,12 +421,19 @@ func (s *StateDB) RevertToSnapshot(revid int) { // the StateDB object should be discarded after committed. func (s *StateDB) Commit() error { + // If there was an error during execution, commit will return error without + // persisting any changes to the underlying ctx. Instead of panicking at the + // call, we return the error here so it is more visible. + if s.sdkError != nil { + return s.sdkError + } + // Delete suicided accounts -- these still need to be committed suicidedAddrs := s.ephemeralStore.GetAllSuicided(s.ctx.CurrentCtx()) for _, addr := range suicidedAddrs { // Balance is also cleared as part of Keeper.DeleteAccount if err := s.keeper.DeleteAccount(s.ctx.CurrentCtx(), addr); err != nil { - panic(fmt.Errorf("failed to delete suicided account: %w", err)) + return fmt.Errorf("failed to delete suicided account: %w", err) } } @@ -432,6 +441,5 @@ func (s *StateDB) Commit() error { s.ctx.Commit() // Journal only contains non-state content, so nothing to commit. - return nil } diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index cb90e6c95c..17e09e1a74 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -141,8 +141,6 @@ func (suite *StateDBTestSuite) TestAccountOverride() { } func (suite *StateDBTestSuite) TestDBError() { - suite.T().Skip("Commit() no longer returns error") - testCases := []struct { name string malleate func(vm.StateDB) diff --git a/x/evm/statedb/store.go b/x/evm/statedb/store.go index bece8b33f1..35ee58a9e4 100644 --- a/x/evm/statedb/store.go +++ b/x/evm/statedb/store.go @@ -8,11 +8,8 @@ import ( ) var ( - AccessListAddressKey = []byte{0x01} // common.Address - AccessListAddressSlotKey = []byte{0x02} // (common.Address, common.Hash) - - RefundKey = []byte{0x03} - SuicidedKey = []byte{0x04} + RefundKey = []byte{0x01} + SuicidedKey = []byte{0x02} ) type Store struct { From f0df7e74991b497388649d9f39fad134c14bfb68 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 29 Jan 2024 11:05:40 -0800 Subject: [PATCH 28/52] Update db error test --- x/evm/statedb/statedb.go | 2 +- x/evm/statedb/statedb_test.go | 36 ++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 035a1c30c8..309c5802d5 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -329,7 +329,7 @@ func (s *StateDB) Suicide(addr common.Address) bool { // Balance cleared, but code and state should still be available until Commit() if err := s.keeper.SetBalance(s.ctx.CurrentCtx(), addr, common.Big0); err != nil { - s.sdkError = fmt.Errorf("failed to delete suicided account: %w", err) + s.sdkError = fmt.Errorf("failed to remove suicide account balance: %w", err) } s.ephemeralStore.SetAccountSuicided(s.ctx.CurrentCtx(), addr) diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index 17e09e1a74..3917ab831a 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -24,8 +24,7 @@ var ( blockHash common.Hash = common.BigToHash(big.NewInt(9999)) emptyTxConfig types.TxConfig = types.NewEmptyTxConfig(blockHash) - errAddress common.Address = common.BigToAddress(big.NewInt(100)) - emptyCodeHash = crypto.Keccak256(nil) + emptyCodeHash = crypto.Keccak256(nil) ) type StateDBTestSuite struct { @@ -142,22 +141,29 @@ func (suite *StateDBTestSuite) TestAccountOverride() { func (suite *StateDBTestSuite) TestDBError() { testCases := []struct { - name string - malleate func(vm.StateDB) + name string + malleate func(vm.StateDB) + errContains string }{ - {"set account", func(db vm.StateDB) { - db.SetNonce(errAddress, 1) - }}, - {"delete account", func(db vm.StateDB) { - db.SetNonce(errAddress, 1) - suite.Require().True(db.Suicide(errAddress)) - }}, + { + "negative balance", + func(db vm.StateDB) { + db.SubBalance(address, big.NewInt(1)) + }, + "failed to set account for balance subtraction: 0aphoton is smaller than 1aphoton", + }, } for _, tc := range testCases { - suite.SetupTest() - db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) - tc.malleate(db) - suite.Require().Error(db.Commit()) + suite.Run(tc.name, func() { + suite.SetupTest() + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) + tc.malleate(db) + + err := db.Commit() + + suite.Require().Error(err) + suite.Require().ErrorContains(err, tc.errContains) + }) } } From 80f21eb302473ba54985b485958ce88e35e9dbbd Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 29 Jan 2024 11:24:40 -0800 Subject: [PATCH 29/52] Preserve initial sdk error instead of replacing --- x/evm/statedb/statedb.go | 26 +++++++++++++++++++------- x/evm/statedb/statedb_test.go | 8 ++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 309c5802d5..f0719bf5c7 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -230,7 +230,7 @@ func (s *StateDB) CreateAccount(addr common.Address) { if account == nil { // No account found, create a new one if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *types.NewEmptyAccount()); err != nil { - s.sdkError = fmt.Errorf("failed to create account: %w", err) + s.SetError(fmt.Errorf("failed to create account: %w", err)) } return @@ -245,7 +245,7 @@ func (s *StateDB) CreateAccount(addr common.Address) { newAccount.Balance = account.Balance if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *newAccount); err != nil { - s.sdkError = fmt.Errorf("failed to create account: %w", err) + s.SetError(fmt.Errorf("failed to create account: %w", err)) } } @@ -272,7 +272,7 @@ func (s *StateDB) AddBalance(addr common.Address, amount *big.Int) { account.Balance = new(big.Int).Add(account.Balance, amount) if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account); err != nil { - s.sdkError = fmt.Errorf("failed to set account for balance addition: %w", err) + s.SetError(fmt.Errorf("failed to set account for balance addition: %w", err)) } } @@ -286,7 +286,7 @@ func (s *StateDB) SubBalance(addr common.Address, amount *big.Int) { account.Balance = new(big.Int).Sub(account.Balance, amount) if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account); err != nil { - s.sdkError = fmt.Errorf("failed to set account for balance subtraction: %w", err) + s.SetError(fmt.Errorf("failed to set account for balance subtraction: %w", err)) } } @@ -296,7 +296,7 @@ func (s *StateDB) SetNonce(addr common.Address, nonce uint64) { account.Nonce = nonce if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account); err != nil { - s.sdkError = fmt.Errorf("failed to set account for nonce: %w", err) + s.SetError(fmt.Errorf("failed to set account for nonce: %w", err)) } } @@ -306,7 +306,7 @@ func (s *StateDB) SetCode(addr common.Address, code []byte) { account.CodeHash = crypto.Keccak256Hash(code).Bytes() if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account); err != nil { - s.sdkError = fmt.Errorf("failed to set account for code: %w", err) + s.SetError(fmt.Errorf("failed to set account for code: %w", err)) } s.keeper.SetCode(s.ctx.CurrentCtx(), account.CodeHash, code) } @@ -329,7 +329,7 @@ func (s *StateDB) Suicide(addr common.Address) bool { // Balance cleared, but code and state should still be available until Commit() if err := s.keeper.SetBalance(s.ctx.CurrentCtx(), addr, common.Big0); err != nil { - s.sdkError = fmt.Errorf("failed to remove suicide account balance: %w", err) + s.SetError(fmt.Errorf("failed to remove suicide account balance: %w", err)) } s.ephemeralStore.SetAccountSuicided(s.ctx.CurrentCtx(), addr) @@ -443,3 +443,15 @@ func (s *StateDB) Commit() error { // Journal only contains non-state content, so nothing to commit. return nil } + +// SetError sets the error in the StateDB which will be returned on Commit. This +// only sets the first error that occurs. Subsequent calls to SetError will be +// ignored as the initial error is the most important. Any errors that occur +// after the first error may be due to invalid state caused by the first error. +func (s *StateDB) SetError(err error) { + if s.sdkError != nil { + return + } + + s.sdkError = err +} diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index 3917ab831a..ac06e36d51 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -152,6 +152,14 @@ func (suite *StateDBTestSuite) TestDBError() { }, "failed to set account for balance subtraction: 0aphoton is smaller than 1aphoton", }, + { + "multiple errors persist first error", + func(db vm.StateDB) { + db.SubBalance(address, big.NewInt(200)) + db.SubBalance(address2, big.NewInt(500)) + }, + "failed to set account for balance subtraction: 0aphoton is smaller than 200aphoton", + }, } for _, tc := range testCases { suite.Run(tc.name, func() { From f17296e1c69de61946183b9107a5e93e7514cc22 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 29 Jan 2024 14:15:46 -0800 Subject: [PATCH 30/52] Remove use of transient store, use in memory slices instead --- x/evm/statedb/ctx.go | 14 ++-- x/evm/statedb/ctx_test.go | 4 +- x/evm/statedb/statedb.go | 19 +++--- x/evm/statedb/store.go | 133 +++++++++++++++++++++++--------------- 4 files changed, 101 insertions(+), 69 deletions(-) diff --git a/x/evm/statedb/ctx.go b/x/evm/statedb/ctx.go index ac434cf363..55149fca4d 100644 --- a/x/evm/statedb/ctx.go +++ b/x/evm/statedb/ctx.go @@ -28,7 +28,7 @@ func NewSnapshotCtx(initialCtx sdk.Context) *SnapshotCommitCtx { // Create an initial snapshot of the initialCtx so no state is written until // Commit() is called. - _ = sCtx.Snapshot(0, 0) + _ = sCtx.Snapshot(0, 0, StoreRevertKey{0, 0}) return sCtx } @@ -57,6 +57,7 @@ func (c *SnapshotCommitCtx) CurrentSnapshot() (CtxSnapshot, bool) { func (c *SnapshotCommitCtx) Snapshot( journalIndex int, logsIndex int, + storeRevertKey StoreRevertKey, ) int { id := c.nextSnapshotID c.nextSnapshotID++ @@ -70,7 +71,9 @@ func (c *SnapshotCommitCtx) Snapshot( ctx: newCtx, write: newWrite, - journalIndex: journalIndex, + journalIndex: journalIndex, + logsIndex: logsIndex, + storeRevertKey: storeRevertKey, }) return id @@ -115,7 +118,8 @@ type CtxSnapshot struct { ctx sdk.Context write func() - // Journal used only for in-memory things like logs and access list - journalIndex int - logsIndex int + // In-memory things like logs, access list + journalIndex int + logsIndex int + storeRevertKey StoreRevertKey } diff --git a/x/evm/statedb/ctx_test.go b/x/evm/statedb/ctx_test.go index 8155da4dd0..5fe2babceb 100644 --- a/x/evm/statedb/ctx_test.go +++ b/x/evm/statedb/ctx_test.go @@ -26,7 +26,7 @@ func TestSnapshotCommitCtx(t *testing.T) { // Make a snapshot previousCtx := snapshotCtx.CurrentCtx() - snapshotID := snapshotCtx.Snapshot(0, 0) + snapshotID := snapshotCtx.Snapshot(0, 0, statedb.StoreRevertKey{}) require.Equal(t, 0, snapshotID, "initial snapshot id should be 0") require.NotEqual(t, previousCtx, snapshotCtx.CurrentCtx(), "CurrentCtx should be branched") @@ -52,7 +52,7 @@ func TestRevert(t *testing.T) { snapshotCtx := statedb.NewSnapshotCtx(initialCtx) // Make a snapshot - snapshotID := snapshotCtx.Snapshot(0, 0) + snapshotID := snapshotCtx.Snapshot(0, 0, statedb.StoreRevertKey{0, 0}) // Revert to the snapshot snapshotCtx.Revert(snapshotID) diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index f0719bf5c7..bdf00e2ab6 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -40,7 +40,7 @@ type StateDB struct { keeper evm.StateDBKeeper ctx *SnapshotCommitCtx // snapshot-able ctx manager - ephemeralStore *Store // store for ephemeral data + ephemeralStore *EphemeralStore // store for ephemeral data // Journal of state modifications. This is the backbone of // Snapshot and RevertToSnapshot. @@ -65,7 +65,7 @@ func New(ctx sdk.Context, keeper evm.StateDBKeeper, txConfig types.TxConfig) evm journal: newJournal(), accessList: newAccessList(), - ephemeralStore: NewStateDBStore(keeper.GetTransientKey()), + ephemeralStore: NewStateDBStore(), txConfig: txConfig, logs: nil, @@ -96,13 +96,13 @@ func (s *StateDB) Logs() []*ethtypes.Log { // AddRefund adds gas to the refund counter func (s *StateDB) AddRefund(gas uint64) { - s.ephemeralStore.AddRefund(s.ctx.CurrentCtx(), gas) + s.ephemeralStore.AddRefund(gas) } // SubRefund removes gas from the refund counter. // This method will panic if the refund counter goes below zero func (s *StateDB) SubRefund(gas uint64) { - s.ephemeralStore.SubRefund(s.ctx.CurrentCtx(), gas) + s.ephemeralStore.SubRefund(gas) } // Exist reports whether the given account address exists in the state. @@ -191,12 +191,12 @@ func (s *StateDB) GetCommittedState(addr common.Address, hash common.Hash) commo // GetRefund returns the current value of the refund counter. func (s *StateDB) GetRefund() uint64 { - return s.ephemeralStore.GetRefund(s.ctx.CurrentCtx()) + return s.ephemeralStore.GetRefund() } // HasSuicided returns if the contract is suicided in current transaction. func (s *StateDB) HasSuicided(addr common.Address) bool { - return s.ephemeralStore.GetAccountSuicided(s.ctx.CurrentCtx(), addr) + return s.ephemeralStore.GetAccountSuicided(addr) } // AddPreimage records a SHA3 preimage seen by the VM. @@ -332,7 +332,7 @@ func (s *StateDB) Suicide(addr common.Address) bool { s.SetError(fmt.Errorf("failed to remove suicide account balance: %w", err)) } - s.ephemeralStore.SetAccountSuicided(s.ctx.CurrentCtx(), addr) + s.ephemeralStore.SetAccountSuicided(addr) return true } @@ -400,7 +400,7 @@ func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addre // Snapshot returns an identifier for the current revision of the state. func (s *StateDB) Snapshot() int { - return s.ctx.Snapshot(s.journal.length(), len(s.logs)) + return s.ctx.Snapshot(s.journal.length(), len(s.logs), s.ephemeralStore.GetRevertKey()) } // RevertToSnapshot reverts all state changes made since the given revision. @@ -414,6 +414,7 @@ func (s *StateDB) RevertToSnapshot(revid int) { // Revert journal to the latest snapshot's journal index s.journal.Revert(s, currentSnapshot.journalIndex) + s.ephemeralStore.Revert(currentSnapshot.storeRevertKey) // Revert logs to the latest snapshot's logs index s.logs = s.logs[:currentSnapshot.logsIndex] @@ -429,7 +430,7 @@ func (s *StateDB) Commit() error { } // Delete suicided accounts -- these still need to be committed - suicidedAddrs := s.ephemeralStore.GetAllSuicided(s.ctx.CurrentCtx()) + suicidedAddrs := s.ephemeralStore.GetAllSuicided() for _, addr := range suicidedAddrs { // Balance is also cleared as part of Keeper.DeleteAccount if err := s.keeper.DeleteAccount(s.ctx.CurrentCtx(), addr); err != nil { diff --git a/x/evm/statedb/store.go b/x/evm/statedb/store.go index 35ee58a9e4..cb7e78abcd 100644 --- a/x/evm/statedb/store.go +++ b/x/evm/statedb/store.go @@ -1,88 +1,115 @@ package statedb import ( - "github.com/cosmos/cosmos-sdk/store/prefix" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" + "fmt" + "github.com/ethereum/go-ethereum/common" ) -var ( - RefundKey = []byte{0x01} - SuicidedKey = []byte{0x02} -) +// StoreRevertKey defines the required information to revert to a previous state. +type StoreRevertKey struct { + RefundIndex int + SuicidedAccountsIndex int +} -type Store struct { - key storetypes.StoreKey +// EphemeralStore provides in-memory state of the refund and suicided accounts +// state with the ability to revert to a previous state. +type EphemeralStore struct { + refundStates []uint64 + suicidedAccountStates []common.Address } -func NewStateDBStore(storeKey storetypes.StoreKey) *Store { - return &Store{ - key: storeKey, +// NewStateDBStore creates a new EphemeralStore. +func NewStateDBStore() *EphemeralStore { + return &EphemeralStore{ + refundStates: []uint64{}, + suicidedAccountStates: []common.Address{}, } } -// AddRefund adds a refund to the store. -func (ls *Store) AddRefund(ctx sdk.Context, gas uint64) { - store := prefix.NewStore(ctx.KVStore(ls.key), RefundKey) - // Add to existing refund - bz := store.Get(RefundKey) - if bz != nil { - gas += sdk.BigEndianToUint64(bz) +// GetRevertKey returns the identifier of the current state of the store. +func (ls *EphemeralStore) GetRevertKey() StoreRevertKey { + return StoreRevertKey{ + RefundIndex: len(ls.refundStates), + SuicidedAccountsIndex: len(ls.suicidedAccountStates), } - - store.Set(RefundKey, sdk.Uint64ToBigEndian(gas)) } -func (ls *Store) SubRefund(ctx sdk.Context, gas uint64) { - store := prefix.NewStore(ctx.KVStore(ls.key), RefundKey) - // Subtract from existing refund - bz := store.Get(RefundKey) - if bz == nil { - panic("no refund to subtract from") +// Revert reverts the state to the given key. +func (ls *EphemeralStore) Revert(key StoreRevertKey) { + if key.RefundIndex > len(ls.refundStates) { + panic(fmt.Errorf( + "invalid RefundIndex, %d is greater than the length of the refund states (%d)", + key.RefundIndex, len(ls.refundStates), + )) } - refund := sdk.BigEndianToUint64(bz) - - if refund < gas { - panic("refund is less than gas") + if key.SuicidedAccountsIndex > len(ls.suicidedAccountStates) { + panic(fmt.Errorf( + "invalid SuicidedAccountsIndex, %d is greater than the length of the suicided accounts (%d)", + key.SuicidedAccountsIndex, len(ls.suicidedAccountStates), + )) } - gas = refund - gas - store.Set(RefundKey, sdk.Uint64ToBigEndian(gas)) + ls.refundStates = ls.refundStates[:key.RefundIndex] + ls.suicidedAccountStates = ls.suicidedAccountStates[:key.SuicidedAccountsIndex] } -func (ls *Store) GetRefund(ctx sdk.Context) uint64 { - store := prefix.NewStore(ctx.KVStore(ls.key), RefundKey) - bz := store.Get(RefundKey) - if bz == nil { +// ----------------------------------------------------------------------------- +// Refund + +// GetRefund returns the current refund value, which is the last element. +func (ls *EphemeralStore) GetRefund() uint64 { + if len(ls.refundStates) == 0 { return 0 } - return sdk.BigEndianToUint64(bz) + + return ls.refundStates[len(ls.refundStates)-1] } -func (ls *Store) SetAccountSuicided(ctx sdk.Context, addr common.Address) { - store := prefix.NewStore(ctx.KVStore(ls.key), SuicidedKey) - store.Set(addr.Bytes(), []byte{1}) +// AddRefund adds a refund to the store. +func (ls *EphemeralStore) AddRefund(gas uint64) { + newRefund := ls.GetRefund() + gas + ls.refundStates = append(ls.refundStates, newRefund) } -func (ls *Store) GetAccountSuicided(ctx sdk.Context, addr common.Address) bool { - store := prefix.NewStore(ctx.KVStore(ls.key), SuicidedKey) - return store.Has(addr.Bytes()) +// SubRefund subtracts a refund from the store. +func (ls *EphemeralStore) SubRefund(gas uint64) { + currentRefund := ls.GetRefund() + + if currentRefund < gas { + panic("current refund is less than gas") + } + + newRefund := currentRefund - gas + ls.refundStates = append(ls.refundStates, newRefund) } -func (ls *Store) GetAllSuicided(ctx sdk.Context) []common.Address { - store := prefix.NewStore(ctx.KVStore(ls.key), SuicidedKey) +// ----------------------------------------------------------------------------- +// Suicided accounts - var addrs []common.Address +// SetAccountSuicided sets the given account as suicided. +func (ls *EphemeralStore) SetAccountSuicided(addr common.Address) { + // If already in the list, ignore + if ls.GetAccountSuicided(addr) { + return + } - iter := sdk.KVStorePrefixIterator(store, []byte{}) - defer iter.Close() + ls.suicidedAccountStates = append(ls.suicidedAccountStates, addr) +} - for ; iter.Valid(); iter.Next() { - addr := common.BytesToAddress(iter.Key()) - addrs = append(addrs, addr) +// GetAccountSuicided returns true if the given account is suicided. +func (ls *EphemeralStore) GetAccountSuicided(addr common.Address) bool { + for _, a := range ls.suicidedAccountStates { + if a == addr { + return true + } } - return addrs + return false +} + +// GetAllSuicided returns all suicided accounts. +func (ls *EphemeralStore) GetAllSuicided() []common.Address { + return ls.suicidedAccountStates } From db7dcead2684db9bd35e4f01e1692f0be3324600 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 29 Jan 2024 14:53:01 -0800 Subject: [PATCH 31/52] Remove GetTransientKey() --- x/evm/keeper/keeper.go | 4 ---- x/evm/statedb/access_list.go | 2 +- x/evm/vm/interface.go | 3 --- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 0f8560d412..42400ee27b 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -404,7 +404,3 @@ func (k Keeper) AddTransientGasUsed(ctx sdk.Context, gasUsed uint64) (uint64, er k.SetTransientGasUsed(ctx, result) return result, nil } - -func (k Keeper) GetTransientKey() storetypes.StoreKey { - return k.transientKey -} diff --git a/x/evm/statedb/access_list.go b/x/evm/statedb/access_list.go index cf5953360c..4513a91641 100644 --- a/x/evm/statedb/access_list.go +++ b/x/evm/statedb/access_list.go @@ -47,7 +47,7 @@ func (al *accessList) Contains(address common.Address, slot common.Hash) (addres return true, slotPresent } -// newAccessList creates a new newAccessList. +// newAccessList creates a new accessList. func newAccessList() *accessList { return &accessList{ addresses: make(map[common.Address]int), diff --git a/x/evm/vm/interface.go b/x/evm/vm/interface.go index 6fec1a0d6c..b9e4c22138 100644 --- a/x/evm/vm/interface.go +++ b/x/evm/vm/interface.go @@ -18,7 +18,6 @@ package vm import ( "math/big" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/evmos/ethermint/x/evm/types" @@ -100,8 +99,6 @@ type StateDBKeeper interface { SetCode(ctx sdk.Context, codeHash []byte, code []byte) SetBalance(ctx sdk.Context, addr common.Address, amount *big.Int) error DeleteAccount(ctx sdk.Context, addr common.Address) error - - GetTransientKey() storetypes.StoreKey } type StateDB interface { From 7f6d46bcd8a29f250326201f35b5b0b6d0c703d2 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 29 Jan 2024 15:42:33 -0800 Subject: [PATCH 32/52] reorganize statedb fields --- x/evm/statedb/statedb.go | 34 +++++++++++------------- x/evm/statedb/store.go | 56 ++++++++++++++++++++-------------------- 2 files changed, 43 insertions(+), 47 deletions(-) diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index bdf00e2ab6..4abb7b7c06 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -37,41 +37,37 @@ var _ vm.StateDB = &StateDB{} // * Contracts // * Accounts type StateDB struct { - keeper evm.StateDBKeeper + keeper evm.StateDBKeeper + txConfig types.TxConfig ctx *SnapshotCommitCtx // snapshot-able ctx manager - ephemeralStore *EphemeralStore // store for ephemeral data - - // Journal of state modifications. This is the backbone of - // Snapshot and RevertToSnapshot. - journal *journal - - txConfig types.TxConfig + ephemeralStore *EphemeralStore // in-memory temporary data - // Per-transaction access list + // Journal is currently only used for tracking accessList + journal *journal accessList *accessList - logs []*ethtypes.Log + logs []*ethtypes.Log sdkError error } // New creates a new state from a given trie. func New(ctx sdk.Context, keeper evm.StateDBKeeper, txConfig types.TxConfig) evm.StateDB { - statedb := &StateDB{ - keeper: keeper, + return &StateDB{ + keeper: keeper, + txConfig: txConfig, + // This internally creates a branched ctx so calling Commit() is required // to write state to the incoming ctx. - ctx: NewSnapshotCtx(ctx), + ctx: NewSnapshotCtx(ctx), + ephemeralStore: NewEphemeralStore(), - journal: newJournal(), - accessList: newAccessList(), - ephemeralStore: NewStateDBStore(), + journal: newJournal(), + accessList: newAccessList(), - txConfig: txConfig, logs: nil, + sdkError: nil, } - - return statedb } // Keeper returns the underlying `Keeper` diff --git a/x/evm/statedb/store.go b/x/evm/statedb/store.go index cb7e78abcd..b9c09bd7b0 100644 --- a/x/evm/statedb/store.go +++ b/x/evm/statedb/store.go @@ -19,8 +19,8 @@ type EphemeralStore struct { suicidedAccountStates []common.Address } -// NewStateDBStore creates a new EphemeralStore. -func NewStateDBStore() *EphemeralStore { +// NewEphemeralStore creates a new EphemeralStore. +func NewEphemeralStore() *EphemeralStore { return &EphemeralStore{ refundStates: []uint64{}, suicidedAccountStates: []common.Address{}, @@ -28,79 +28,79 @@ func NewStateDBStore() *EphemeralStore { } // GetRevertKey returns the identifier of the current state of the store. -func (ls *EphemeralStore) GetRevertKey() StoreRevertKey { +func (es *EphemeralStore) GetRevertKey() StoreRevertKey { return StoreRevertKey{ - RefundIndex: len(ls.refundStates), - SuicidedAccountsIndex: len(ls.suicidedAccountStates), + RefundIndex: len(es.refundStates), + SuicidedAccountsIndex: len(es.suicidedAccountStates), } } // Revert reverts the state to the given key. -func (ls *EphemeralStore) Revert(key StoreRevertKey) { - if key.RefundIndex > len(ls.refundStates) { +func (es *EphemeralStore) Revert(key StoreRevertKey) { + if key.RefundIndex > len(es.refundStates) { panic(fmt.Errorf( "invalid RefundIndex, %d is greater than the length of the refund states (%d)", - key.RefundIndex, len(ls.refundStates), + key.RefundIndex, len(es.refundStates), )) } - if key.SuicidedAccountsIndex > len(ls.suicidedAccountStates) { + if key.SuicidedAccountsIndex > len(es.suicidedAccountStates) { panic(fmt.Errorf( "invalid SuicidedAccountsIndex, %d is greater than the length of the suicided accounts (%d)", - key.SuicidedAccountsIndex, len(ls.suicidedAccountStates), + key.SuicidedAccountsIndex, len(es.suicidedAccountStates), )) } - ls.refundStates = ls.refundStates[:key.RefundIndex] - ls.suicidedAccountStates = ls.suicidedAccountStates[:key.SuicidedAccountsIndex] + es.refundStates = es.refundStates[:key.RefundIndex] + es.suicidedAccountStates = es.suicidedAccountStates[:key.SuicidedAccountsIndex] } // ----------------------------------------------------------------------------- // Refund // GetRefund returns the current refund value, which is the last element. -func (ls *EphemeralStore) GetRefund() uint64 { - if len(ls.refundStates) == 0 { +func (es *EphemeralStore) GetRefund() uint64 { + if len(es.refundStates) == 0 { return 0 } - return ls.refundStates[len(ls.refundStates)-1] + return es.refundStates[len(es.refundStates)-1] } // AddRefund adds a refund to the store. -func (ls *EphemeralStore) AddRefund(gas uint64) { - newRefund := ls.GetRefund() + gas - ls.refundStates = append(ls.refundStates, newRefund) +func (es *EphemeralStore) AddRefund(gas uint64) { + newRefund := es.GetRefund() + gas + es.refundStates = append(es.refundStates, newRefund) } // SubRefund subtracts a refund from the store. -func (ls *EphemeralStore) SubRefund(gas uint64) { - currentRefund := ls.GetRefund() +func (es *EphemeralStore) SubRefund(gas uint64) { + currentRefund := es.GetRefund() if currentRefund < gas { panic("current refund is less than gas") } newRefund := currentRefund - gas - ls.refundStates = append(ls.refundStates, newRefund) + es.refundStates = append(es.refundStates, newRefund) } // ----------------------------------------------------------------------------- // Suicided accounts // SetAccountSuicided sets the given account as suicided. -func (ls *EphemeralStore) SetAccountSuicided(addr common.Address) { +func (es *EphemeralStore) SetAccountSuicided(addr common.Address) { // If already in the list, ignore - if ls.GetAccountSuicided(addr) { + if es.GetAccountSuicided(addr) { return } - ls.suicidedAccountStates = append(ls.suicidedAccountStates, addr) + es.suicidedAccountStates = append(es.suicidedAccountStates, addr) } // GetAccountSuicided returns true if the given account is suicided. -func (ls *EphemeralStore) GetAccountSuicided(addr common.Address) bool { - for _, a := range ls.suicidedAccountStates { +func (es *EphemeralStore) GetAccountSuicided(addr common.Address) bool { + for _, a := range es.suicidedAccountStates { if a == addr { return true } @@ -110,6 +110,6 @@ func (ls *EphemeralStore) GetAccountSuicided(addr common.Address) bool { } // GetAllSuicided returns all suicided accounts. -func (ls *EphemeralStore) GetAllSuicided() []common.Address { - return ls.suicidedAccountStates +func (es *EphemeralStore) GetAllSuicided() []common.Address { + return es.suicidedAccountStates } From 29b8de353c003038624dbe595e3e5f084476d78d Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 29 Jan 2024 17:14:26 -0800 Subject: [PATCH 33/52] Move logs to ephemeral store, add tests --- x/evm/statedb/ctx.go | 5 +- x/evm/statedb/ctx_test.go | 4 +- x/evm/statedb/statedb.go | 18 +-- x/evm/statedb/store.go | 85 +++++++--- x/evm/statedb/store_test.go | 315 ++++++++++++++++++++++++++++++++++++ 5 files changed, 389 insertions(+), 38 deletions(-) create mode 100644 x/evm/statedb/store_test.go diff --git a/x/evm/statedb/ctx.go b/x/evm/statedb/ctx.go index 55149fca4d..6e29e1ff87 100644 --- a/x/evm/statedb/ctx.go +++ b/x/evm/statedb/ctx.go @@ -28,7 +28,7 @@ func NewSnapshotCtx(initialCtx sdk.Context) *SnapshotCommitCtx { // Create an initial snapshot of the initialCtx so no state is written until // Commit() is called. - _ = sCtx.Snapshot(0, 0, StoreRevertKey{0, 0}) + _ = sCtx.Snapshot(0, StoreRevertKey{0, 0, 0}) return sCtx } @@ -56,7 +56,6 @@ func (c *SnapshotCommitCtx) CurrentSnapshot() (CtxSnapshot, bool) { // Snapshot creates a new branched context and returns the revision id. func (c *SnapshotCommitCtx) Snapshot( journalIndex int, - logsIndex int, storeRevertKey StoreRevertKey, ) int { id := c.nextSnapshotID @@ -72,7 +71,6 @@ func (c *SnapshotCommitCtx) Snapshot( write: newWrite, journalIndex: journalIndex, - logsIndex: logsIndex, storeRevertKey: storeRevertKey, }) @@ -120,6 +118,5 @@ type CtxSnapshot struct { // In-memory things like logs, access list journalIndex int - logsIndex int storeRevertKey StoreRevertKey } diff --git a/x/evm/statedb/ctx_test.go b/x/evm/statedb/ctx_test.go index 5fe2babceb..bf14cdc4df 100644 --- a/x/evm/statedb/ctx_test.go +++ b/x/evm/statedb/ctx_test.go @@ -26,7 +26,7 @@ func TestSnapshotCommitCtx(t *testing.T) { // Make a snapshot previousCtx := snapshotCtx.CurrentCtx() - snapshotID := snapshotCtx.Snapshot(0, 0, statedb.StoreRevertKey{}) + snapshotID := snapshotCtx.Snapshot(0, statedb.StoreRevertKey{}) require.Equal(t, 0, snapshotID, "initial snapshot id should be 0") require.NotEqual(t, previousCtx, snapshotCtx.CurrentCtx(), "CurrentCtx should be branched") @@ -52,7 +52,7 @@ func TestRevert(t *testing.T) { snapshotCtx := statedb.NewSnapshotCtx(initialCtx) // Make a snapshot - snapshotID := snapshotCtx.Snapshot(0, 0, statedb.StoreRevertKey{0, 0}) + snapshotID := snapshotCtx.Snapshot(0, statedb.StoreRevertKey{}) // Revert to the snapshot snapshotCtx.Revert(snapshotID) diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 4abb7b7c06..77d6bc39ad 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -47,7 +47,6 @@ type StateDB struct { journal *journal accessList *accessList - logs []*ethtypes.Log sdkError error } @@ -65,7 +64,6 @@ func New(ctx sdk.Context, keeper evm.StateDBKeeper, txConfig types.TxConfig) evm journal: newJournal(), accessList: newAccessList(), - logs: nil, sdkError: nil, } } @@ -80,14 +78,14 @@ func (s *StateDB) AddLog(log *ethtypes.Log) { log.TxHash = s.txConfig.TxHash log.BlockHash = s.txConfig.BlockHash log.TxIndex = s.txConfig.TxIndex - log.Index = s.txConfig.LogIndex + uint(len(s.logs)) + log.Index = s.txConfig.LogIndex + uint(s.ephemeralStore.GetLogsCount()) - s.logs = append(s.logs, log) + s.ephemeralStore.AddLog(log) } // Logs returns the logs of current transaction. func (s *StateDB) Logs() []*ethtypes.Log { - return s.logs + return s.ephemeralStore.GetLogs() } // AddRefund adds gas to the refund counter @@ -396,7 +394,10 @@ func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addre // Snapshot returns an identifier for the current revision of the state. func (s *StateDB) Snapshot() int { - return s.ctx.Snapshot(s.journal.length(), len(s.logs), s.ephemeralStore.GetRevertKey()) + return s.ctx.Snapshot( + s.journal.length(), + s.ephemeralStore.GetRevertKey(), + ) } // RevertToSnapshot reverts all state changes made since the given revision. @@ -410,10 +411,9 @@ func (s *StateDB) RevertToSnapshot(revid int) { // Revert journal to the latest snapshot's journal index s.journal.Revert(s, currentSnapshot.journalIndex) - s.ephemeralStore.Revert(currentSnapshot.storeRevertKey) - // Revert logs to the latest snapshot's logs index - s.logs = s.logs[:currentSnapshot.logsIndex] + // Revert ephemeral store: refunds, logs, suicided accounts + s.ephemeralStore.Revert(currentSnapshot.storeRevertKey) } // the StateDB object should be discarded after committed. diff --git a/x/evm/statedb/store.go b/x/evm/statedb/store.go index b9c09bd7b0..40e11043f8 100644 --- a/x/evm/statedb/store.go +++ b/x/evm/statedb/store.go @@ -4,55 +4,94 @@ import ( "fmt" "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) // StoreRevertKey defines the required information to revert to a previous state. type StoreRevertKey struct { RefundIndex int SuicidedAccountsIndex int + LogsIndex int } // EphemeralStore provides in-memory state of the refund and suicided accounts // state with the ability to revert to a previous state. type EphemeralStore struct { - refundStates []uint64 - suicidedAccountStates []common.Address + RefundStates []uint64 + SuicidedAccountStates []common.Address + Logs []*ethtypes.Log } // NewEphemeralStore creates a new EphemeralStore. func NewEphemeralStore() *EphemeralStore { return &EphemeralStore{ - refundStates: []uint64{}, - suicidedAccountStates: []common.Address{}, + RefundStates: nil, + SuicidedAccountStates: nil, + Logs: nil, } } // GetRevertKey returns the identifier of the current state of the store. func (es *EphemeralStore) GetRevertKey() StoreRevertKey { return StoreRevertKey{ - RefundIndex: len(es.refundStates), - SuicidedAccountsIndex: len(es.suicidedAccountStates), + RefundIndex: len(es.RefundStates), + SuicidedAccountsIndex: len(es.SuicidedAccountStates), + LogsIndex: len(es.Logs), } } // Revert reverts the state to the given key. func (es *EphemeralStore) Revert(key StoreRevertKey) { - if key.RefundIndex > len(es.refundStates) { - panic(fmt.Errorf( + if err := es.ValidateRevertKey(key); err != nil { + panic(err) + } + + es.RefundStates = es.RefundStates[:key.RefundIndex] + es.SuicidedAccountStates = es.SuicidedAccountStates[:key.SuicidedAccountsIndex] + es.Logs = es.Logs[:key.LogsIndex] +} + +func (es *EphemeralStore) ValidateRevertKey(key StoreRevertKey) error { + if key.RefundIndex > len(es.RefundStates) { + return fmt.Errorf( "invalid RefundIndex, %d is greater than the length of the refund states (%d)", - key.RefundIndex, len(es.refundStates), - )) + key.RefundIndex, len(es.RefundStates), + ) } - if key.SuicidedAccountsIndex > len(es.suicidedAccountStates) { - panic(fmt.Errorf( + if key.SuicidedAccountsIndex > len(es.SuicidedAccountStates) { + return fmt.Errorf( "invalid SuicidedAccountsIndex, %d is greater than the length of the suicided accounts (%d)", - key.SuicidedAccountsIndex, len(es.suicidedAccountStates), - )) + key.SuicidedAccountsIndex, len(es.SuicidedAccountStates), + ) } - es.refundStates = es.refundStates[:key.RefundIndex] - es.suicidedAccountStates = es.suicidedAccountStates[:key.SuicidedAccountsIndex] + if key.LogsIndex > len(es.Logs) { + return fmt.Errorf( + "invalid LogsIndex, %d is greater than the length of the logs (%d)", + key.LogsIndex, len(es.Logs), + ) + } + + return nil +} + +// ----------------------------------------------------------------------------- +// Logs + +// AddLog adds a log to the store. +func (es *EphemeralStore) AddLog(log *ethtypes.Log) { + es.Logs = append(es.Logs, log) +} + +// GetLogsCount returns the number of logs. +func (es *EphemeralStore) GetLogsCount() int { + return len(es.Logs) +} + +// GetLogs returns all logs. +func (es *EphemeralStore) GetLogs() []*ethtypes.Log { + return es.Logs } // ----------------------------------------------------------------------------- @@ -60,17 +99,17 @@ func (es *EphemeralStore) Revert(key StoreRevertKey) { // GetRefund returns the current refund value, which is the last element. func (es *EphemeralStore) GetRefund() uint64 { - if len(es.refundStates) == 0 { + if len(es.RefundStates) == 0 { return 0 } - return es.refundStates[len(es.refundStates)-1] + return es.RefundStates[len(es.RefundStates)-1] } // AddRefund adds a refund to the store. func (es *EphemeralStore) AddRefund(gas uint64) { newRefund := es.GetRefund() + gas - es.refundStates = append(es.refundStates, newRefund) + es.RefundStates = append(es.RefundStates, newRefund) } // SubRefund subtracts a refund from the store. @@ -82,7 +121,7 @@ func (es *EphemeralStore) SubRefund(gas uint64) { } newRefund := currentRefund - gas - es.refundStates = append(es.refundStates, newRefund) + es.RefundStates = append(es.RefundStates, newRefund) } // ----------------------------------------------------------------------------- @@ -95,12 +134,12 @@ func (es *EphemeralStore) SetAccountSuicided(addr common.Address) { return } - es.suicidedAccountStates = append(es.suicidedAccountStates, addr) + es.SuicidedAccountStates = append(es.SuicidedAccountStates, addr) } // GetAccountSuicided returns true if the given account is suicided. func (es *EphemeralStore) GetAccountSuicided(addr common.Address) bool { - for _, a := range es.suicidedAccountStates { + for _, a := range es.SuicidedAccountStates { if a == addr { return true } @@ -111,5 +150,5 @@ func (es *EphemeralStore) GetAccountSuicided(addr common.Address) bool { // GetAllSuicided returns all suicided accounts. func (es *EphemeralStore) GetAllSuicided() []common.Address { - return es.suicidedAccountStates + return es.SuicidedAccountStates } diff --git a/x/evm/statedb/store_test.go b/x/evm/statedb/store_test.go new file mode 100644 index 0000000000..2c7e5ec6a6 --- /dev/null +++ b/x/evm/statedb/store_test.go @@ -0,0 +1,315 @@ +package statedb_test + +import ( + "testing" + + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/evmos/ethermint/x/evm/statedb" + "github.com/stretchr/testify/require" +) + +func TestNewEphemeralStore_GetRevertKey(t *testing.T) { + tests := []struct { + name string + maleate func(store *statedb.EphemeralStore) + expected statedb.StoreRevertKey + }{ + { + "empty store", + func(store *statedb.EphemeralStore) {}, + statedb.StoreRevertKey{}, + }, + { + "store with refund", + func(store *statedb.EphemeralStore) { + store.AddRefund(1) + }, + statedb.StoreRevertKey{ + RefundIndex: 1, + SuicidedAccountsIndex: 0, + LogsIndex: 0, + }, + }, + { + "store with suicided account", + func(store *statedb.EphemeralStore) { + store.SetAccountSuicided(address) + }, + statedb.StoreRevertKey{ + RefundIndex: 0, + SuicidedAccountsIndex: 1, + LogsIndex: 0, + }, + }, + { + "store with log", + func(store *statedb.EphemeralStore) { + store.AddLog(ðtypes.Log{}) + }, + statedb.StoreRevertKey{ + RefundIndex: 0, + SuicidedAccountsIndex: 0, + LogsIndex: 1, + }, + }, + { + "store with refund, suicided account and log", + func(store *statedb.EphemeralStore) { + store.AddRefund(1) + store.SetAccountSuicided(address) + store.AddLog(ðtypes.Log{}) + }, + statedb.StoreRevertKey{ + RefundIndex: 1, + SuicidedAccountsIndex: 1, + LogsIndex: 1, + }, + }, + { + "store with multiple refund, suicided account and log", + func(store *statedb.EphemeralStore) { + store.AddRefund(1) + store.AddRefund(2) + store.AddRefund(3) + store.SetAccountSuicided(address) + store.SetAccountSuicided(address2) + + store.AddLog(ðtypes.Log{}) + store.AddLog(ðtypes.Log{}) + }, + statedb.StoreRevertKey{ + RefundIndex: 3, + SuicidedAccountsIndex: 2, + LogsIndex: 2, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + + store := statedb.NewEphemeralStore() + + store.AddLog(ðtypes.Log{}) + store.AddRefund(1) + store.SetAccountSuicided(address) + + key := store.GetRevertKey() + expected := statedb.StoreRevertKey{ + RefundIndex: 1, + SuicidedAccountsIndex: 1, + LogsIndex: 1, + } + + require.Equal(t, expected, key) + }) + } +} + +func TestEphemeralStore_Revert(t *testing.T) { + tests := []struct { + name string + init func(store *statedb.EphemeralStore) + afterSnapshot func(store *statedb.EphemeralStore) + wantState *statedb.EphemeralStore + }{ + { + "empty store", + func(store *statedb.EphemeralStore) {}, + func(store *statedb.EphemeralStore) {}, + &statedb.EphemeralStore{ + RefundStates: nil, + SuicidedAccountStates: nil, + Logs: nil, + }, + }, + { + "empty store snapshot - reverts", + func(store *statedb.EphemeralStore) {}, + func(store *statedb.EphemeralStore) { + store.AddRefund(1) + store.SetAccountSuicided(address) + store.AddLog(ðtypes.Log{}) + }, + &statedb.EphemeralStore{ + RefundStates: []uint64{}, + SuicidedAccountStates: []common.Address{}, + Logs: []*ethtypes.Log{}, + }, + }, + { + "non-empty store snapshot - reverts", + func(store *statedb.EphemeralStore) { + store.AddRefund(1) + store.AddRefund(3) + store.AddRefund(10) + store.SubRefund(2) + store.SubRefund(1) + + store.SetAccountSuicided(address) + store.SetAccountSuicided(address2) + store.AddLog(ðtypes.Log{ + Index: 1, + }) + store.AddLog(ðtypes.Log{ + Index: 2, + }) + store.AddLog(ðtypes.Log{ + Index: 3, + }) + }, + func(store *statedb.EphemeralStore) { + store.AddRefund(20) + store.SubRefund(5) + store.SetAccountSuicided(address3) + store.AddLog(ðtypes.Log{ + Index: 4, + }) + }, + &statedb.EphemeralStore{ + // RefundStates get added up to the previous state + RefundStates: []uint64{1, 4, 14, 12, 11}, + SuicidedAccountStates: []common.Address{address, address2}, + Logs: []*ethtypes.Log{ + ðtypes.Log{Index: 1}, + ðtypes.Log{Index: 2}, + ðtypes.Log{Index: 3}, + }, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + store := statedb.NewEphemeralStore() + + // Initialize the store + tt.init(store) + + // Get the revert key before changing state + revertKey := store.GetRevertKey() + + // Perform some operations on the store + tt.afterSnapshot(store) + + // Revert the store to the previous state + store.Revert(revertKey) + + // Verify that the store has been reverted correctly + require.Equal(t, tt.wantState, store) + }) + } +} + +func TestEphemeralStore_Revert_InvalidKey(t *testing.T) { + store := statedb.NewEphemeralStore() + + // Revert with an invalid key + require.Panics(t, func() { + store.Revert(statedb.StoreRevertKey{ + RefundIndex: 1, + SuicidedAccountsIndex: 2, + LogsIndex: 3, + }) + }, "reverting with an invalid key should panic") +} + +func TestEphemeralStore_GetLogs(t *testing.T) { + store := statedb.NewEphemeralStore() + + // Add some logs + store.AddLog(ðtypes.Log{ + Index: 1, + }) + store.AddLog(ðtypes.Log{ + Index: 2, + }) + store.AddLog(ðtypes.Log{ + Index: 3, + }) + + // Get the logs + logs := store.GetLogs() + + // Verify that the logs are correct + require.Equal(t, []*ethtypes.Log{ + ðtypes.Log{Index: 1}, + ðtypes.Log{Index: 2}, + ðtypes.Log{Index: 3}, + }, logs) + + require.Equal(t, len(logs), store.GetLogsCount()) +} + +func TestEphemeralStore_AddRefund(t *testing.T) { + store := statedb.NewEphemeralStore() + + refunds := []uint64{1, 2, 3, 4, 5} + refundSum := uint64(0) + + // Add some refunds + for _, refund := range refunds { + store.AddRefund(refund) + refundSum += refund + } + + // Get the current refund amount + refund := store.GetRefund() + + require.Equal(t, refundSum, refund) +} + +func TestEphemeralStore_SubRefund(t *testing.T) { + store := statedb.NewEphemeralStore() + + refundAdds := []uint64{10, 20, 30, 40, 50} + refundSubs := []uint64{1, 2, 3, 4, 5} + + refundSum := uint64(0) + + // Add some refunds + for _, refund := range refundAdds { + store.AddRefund(refund) + refundSum += refund + } + + // Subtract some refunds + for _, refund := range refundSubs { + store.SubRefund(refund) + refundSum -= refund + } + + // Get the current refund amount + refund := store.GetRefund() + + require.Equal(t, refundSum, refund) +} + +func TestEphemeralStore_AccountSuicided(t *testing.T) { + store := statedb.NewEphemeralStore() + + // Set the account suicided + store.SetAccountSuicided(address) + + // Verify that the account is suicided + require.True(t, store.GetAccountSuicided(address)) + + // No duplicate entries for the same account + store.SetAccountSuicided(address) + store.SetAccountSuicided(address) + + store.SetAccountSuicided(address2) + + require.Equal( + t, + []common.Address{address, address2}, + store.SuicidedAccountStates, + "repeated calls to SetAccountSuicided should not add duplicate entries", + ) + + // Remove + allAddrs := store.GetAllSuicided() + + require.Equal(t, []common.Address{address, address2}, allAddrs) +} From 6ee8597a21fd2a5f11c49e74766970d79d76a1e6 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Tue, 30 Jan 2024 15:39:09 -0800 Subject: [PATCH 34/52] Remove GetLogsCount method --- x/evm/statedb/ctx.go | 3 ++- x/evm/statedb/statedb.go | 2 +- x/evm/statedb/store.go | 5 ----- x/evm/statedb/store_test.go | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/x/evm/statedb/ctx.go b/x/evm/statedb/ctx.go index 6e29e1ff87..9ff05e0881 100644 --- a/x/evm/statedb/ctx.go +++ b/x/evm/statedb/ctx.go @@ -27,7 +27,8 @@ func NewSnapshotCtx(initialCtx sdk.Context) *SnapshotCommitCtx { } // Create an initial snapshot of the initialCtx so no state is written until - // Commit() is called. + // Commit() is called. The ID is -1 but disregarded along with the + // StoreRevertKey indices as this is only to branch the ctx. _ = sCtx.Snapshot(0, StoreRevertKey{0, 0, 0}) return sCtx diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 77d6bc39ad..d4d0a0b2aa 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -78,7 +78,7 @@ func (s *StateDB) AddLog(log *ethtypes.Log) { log.TxHash = s.txConfig.TxHash log.BlockHash = s.txConfig.BlockHash log.TxIndex = s.txConfig.TxIndex - log.Index = s.txConfig.LogIndex + uint(s.ephemeralStore.GetLogsCount()) + log.Index = s.txConfig.LogIndex + uint(len(s.ephemeralStore.Logs)) s.ephemeralStore.AddLog(log) } diff --git a/x/evm/statedb/store.go b/x/evm/statedb/store.go index 40e11043f8..6ec6c08822 100644 --- a/x/evm/statedb/store.go +++ b/x/evm/statedb/store.go @@ -84,11 +84,6 @@ func (es *EphemeralStore) AddLog(log *ethtypes.Log) { es.Logs = append(es.Logs, log) } -// GetLogsCount returns the number of logs. -func (es *EphemeralStore) GetLogsCount() int { - return len(es.Logs) -} - // GetLogs returns all logs. func (es *EphemeralStore) GetLogs() []*ethtypes.Log { return es.Logs diff --git a/x/evm/statedb/store_test.go b/x/evm/statedb/store_test.go index 2c7e5ec6a6..499fd0947d 100644 --- a/x/evm/statedb/store_test.go +++ b/x/evm/statedb/store_test.go @@ -239,7 +239,7 @@ func TestEphemeralStore_GetLogs(t *testing.T) { ðtypes.Log{Index: 3}, }, logs) - require.Equal(t, len(logs), store.GetLogsCount()) + require.Equal(t, len(logs), len(store.Logs)) } func TestEphemeralStore_AddRefund(t *testing.T) { From 91068593769ca0030e9d5d36155a1e16421e4e35 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Tue, 6 Feb 2024 14:16:03 -0800 Subject: [PATCH 35/52] Increase BenchmarkNestedSnapshot iterations, time Commit() instead of iteration --- x/evm/statedb/benchmark_test.go | 42 ++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/x/evm/statedb/benchmark_test.go b/x/evm/statedb/benchmark_test.go index ec4073f54a..33991c8611 100644 --- a/x/evm/statedb/benchmark_test.go +++ b/x/evm/statedb/benchmark_test.go @@ -11,6 +11,7 @@ import ( "github.com/evmos/ethermint/x/evm/keeper" "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/testutil" + "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" @@ -37,22 +38,23 @@ func NewTestContext() sdk.Context { func benchmarkNestedSnapshot(b *testing.B, layers int) { suite := GetTestSuite(b) - db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) + for i := 0; i < b.N; i++ { + b.StopTimer() + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) - for i := 0; i < layers; i++ { - db.Snapshot() + // Create layers of nested snapshots + for i := 0; i < layers; i++ { + db.Snapshot() - key := common.BigToHash(big.NewInt(int64(i))) - value := common.BigToHash(big.NewInt(int64(i + 1))) - db.SetState(address, key, value) - } + // Some state change each snapshot + key := common.BigToHash(big.NewInt(int64(i + 1))) + value := common.BigToHash(big.NewInt(int64(i + 1))) + db.SetState(address, key, value) + } - b.ResetTimer() + b.StartTimer() - for i := 0; i < b.N; i++ { - db.ForEachStorage(address, func(k, v common.Hash) bool { - return true - }) + require.NoError(b, db.Commit()) } } @@ -64,12 +66,20 @@ func BenchmarkNestedSnapshot4(b *testing.B) { benchmarkNestedSnapshot(b, 4) } -func BenchmarkNestedSnapshot8(b *testing.B) { - benchmarkNestedSnapshot(b, 8) +func BenchmarkNestedSnapshot10(b *testing.B) { + benchmarkNestedSnapshot(b, 10) +} + +func BenchmarkNestedSnapshot100(b *testing.B) { + benchmarkNestedSnapshot(b, 100) +} + +func BenchmarkNestedSnapshot1000(b *testing.B) { + benchmarkNestedSnapshot(b, 1000) } -func BenchmarkNestedSnapshot16(b *testing.B) { - benchmarkNestedSnapshot(b, 16) +func BenchmarkNestedSnapshot10000(b *testing.B) { + benchmarkNestedSnapshot(b, 10000) } func BenchmarkAddBalance(b *testing.B) { From dc342afe50329cc8cfe09d7af300ccb59a7e801f Mon Sep 17 00:00:00 2001 From: drklee3 Date: Tue, 6 Feb 2024 15:53:17 -0800 Subject: [PATCH 36/52] Update benchmarks to use subbenchmarks instead of parent calls --- x/evm/statedb/benchmark_test.go | 109 ++++++++++++-------------------- 1 file changed, 41 insertions(+), 68 deletions(-) diff --git a/x/evm/statedb/benchmark_test.go b/x/evm/statedb/benchmark_test.go index 33991c8611..de1e8aa40b 100644 --- a/x/evm/statedb/benchmark_test.go +++ b/x/evm/statedb/benchmark_test.go @@ -1,6 +1,7 @@ package statedb_test import ( + "fmt" "math/big" "testing" @@ -35,51 +36,33 @@ func NewTestContext() sdk.Context { return sdk.NewContext(cms, tmproto.Header{}, false, log.NewNopLogger()) } -func benchmarkNestedSnapshot(b *testing.B, layers int) { - suite := GetTestSuite(b) - - for i := 0; i < b.N; i++ { - b.StopTimer() - db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) - - // Create layers of nested snapshots - for i := 0; i < layers; i++ { - db.Snapshot() +func BenchmarkNestedSnapshot(b *testing.B) { + benches := []int{1, 4, 10, 100, 1000, 10000} - // Some state change each snapshot - key := common.BigToHash(big.NewInt(int64(i + 1))) - value := common.BigToHash(big.NewInt(int64(i + 1))) - db.SetState(address, key, value) - } + for _, layers := range benches { + b.Run(fmt.Sprintf("%d layers", layers), func(b *testing.B) { + suite := GetTestSuite(b) - b.StartTimer() + for i := 0; i < b.N; i++ { + b.StopTimer() + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) - require.NoError(b, db.Commit()) - } -} + // Create layers of nested snapshots + for i := 0; i < layers; i++ { + db.Snapshot() -func BenchmarkNestedSnapshot1(b *testing.B) { - benchmarkNestedSnapshot(b, 1) -} + // Some state change each snapshot + key := common.BigToHash(big.NewInt(int64(i + 1))) + value := common.BigToHash(big.NewInt(int64(i + 1))) + db.SetState(address, key, value) + } -func BenchmarkNestedSnapshot4(b *testing.B) { - benchmarkNestedSnapshot(b, 4) -} + b.StartTimer() -func BenchmarkNestedSnapshot10(b *testing.B) { - benchmarkNestedSnapshot(b, 10) -} - -func BenchmarkNestedSnapshot100(b *testing.B) { - benchmarkNestedSnapshot(b, 100) -} - -func BenchmarkNestedSnapshot1000(b *testing.B) { - benchmarkNestedSnapshot(b, 1000) -} - -func BenchmarkNestedSnapshot10000(b *testing.B) { - benchmarkNestedSnapshot(b, 10000) + require.NoError(b, db.Commit()) + } + }) + } } func BenchmarkAddBalance(b *testing.B) { @@ -175,39 +158,29 @@ func BenchmarkAddLog(b *testing.B) { } } -func benchmarkGetLogs(b *testing.B, logEntries int) { - suite := GetTestSuite(b) - db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) +func BenchmarkGetLogs(b *testing.B) { + benches := []int{1, 4, 64, 512, 1024} - for i := 0; i < logEntries; i++ { - log := ðtypes.Log{ - Address: address, - Topics: []common.Hash{common.BigToHash(big.NewInt(int64(i)))}, - } - db.AddLog(log) - } + for _, entries := range benches { + b.Run(fmt.Sprintf("%d entries", entries), func(b *testing.B) { + suite := GetTestSuite(b) + db := statedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig) - b.ResetTimer() + for i := 0; i < entries; i++ { + log := ðtypes.Log{ + Address: address, + Topics: []common.Hash{common.BigToHash(big.NewInt(int64(i)))}, + } + db.AddLog(log) + } - for i := 0; i < b.N; i++ { - db.Logs() - } -} + b.ResetTimer() -func BenchmarkGetLogs1(b *testing.B) { - benchmarkGetLogs(b, 1) -} - -func BenchmarkGetLogs8(b *testing.B) { - benchmarkGetLogs(b, 8) -} - -func BenchmarkGetLogs64(b *testing.B) { - benchmarkGetLogs(b, 64) -} - -func BenchmarkGetLogs512(b *testing.B) { - benchmarkGetLogs(b, 512) + for i := 0; i < b.N; i++ { + db.Logs() + } + }) + } } func GetTestSuite(b *testing.B) *testutil.KeeperTestSuite { From c7871fa9f0d34eefd392082b979c3f2ec3bb7aa2 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 8 Feb 2024 10:21:00 -0800 Subject: [PATCH 37/52] fix GetRevertKey test to use actual test cases --- x/evm/statedb/store_test.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/x/evm/statedb/store_test.go b/x/evm/statedb/store_test.go index 499fd0947d..f2592e9873 100644 --- a/x/evm/statedb/store_test.go +++ b/x/evm/statedb/store_test.go @@ -88,21 +88,12 @@ func TestNewEphemeralStore_GetRevertKey(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := statedb.NewEphemeralStore() - store.AddLog(ðtypes.Log{}) - store.AddRefund(1) - store.SetAccountSuicided(address) + tt.maleate(store) key := store.GetRevertKey() - expected := statedb.StoreRevertKey{ - RefundIndex: 1, - SuicidedAccountsIndex: 1, - LogsIndex: 1, - } - - require.Equal(t, expected, key) + require.Equal(t, tt.expected, key) }) } } From 43b638485cad371038148c177958ea6169768f9a Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 8 Feb 2024 13:14:45 -0800 Subject: [PATCH 38/52] refactor: Use testutil test Suite for keeper tests --- x/evm/keeper/abci_test.go | 4 +- x/evm/keeper/benchmark_test.go | 52 +-- x/evm/keeper/grpc_query_test.go | 212 ++++----- x/evm/keeper/hooks_test.go | 8 +- x/evm/keeper/integration_test.go | 28 +- x/evm/keeper/keeper_test.go | 420 +----------------- x/evm/keeper/msg_server_test.go | 20 +- x/evm/keeper/params_benchmark_test.go | 4 +- x/evm/keeper/params_test.go | 32 +- .../keeper/state_transition_benchmark_test.go | 117 +++-- x/evm/keeper/state_transition_test.go | 176 ++++---- x/evm/keeper/statedb_benchmark_test.go | 16 +- x/evm/keeper/statedb_test.go | 172 +++---- x/evm/keeper/utils_test.go | 124 +++--- x/evm/testutil/suite.go | 36 +- 15 files changed, 532 insertions(+), 889 deletions(-) diff --git a/x/evm/keeper/abci_test.go b/x/evm/keeper/abci_test.go index dc7c265cec..9013a3c88d 100644 --- a/x/evm/keeper/abci_test.go +++ b/x/evm/keeper/abci_test.go @@ -6,10 +6,10 @@ import ( ) func (suite *KeeperTestSuite) TestEndBlock() { - em := suite.ctx.EventManager() + em := suite.Ctx.EventManager() suite.Require().Equal(0, len(em.Events())) - res := suite.app.EvmKeeper.EndBlock(suite.ctx, types.RequestEndBlock{}) + res := suite.App.EvmKeeper.EndBlock(suite.Ctx, types.RequestEndBlock{}) suite.Require().Equal([]types.ValidatorUpdate{}, res) // should emit 1 EventTypeBlockBloom event on EndBlock diff --git a/x/evm/keeper/benchmark_test.go b/x/evm/keeper/benchmark_test.go index 9264629bcf..40c39ac2a5 100644 --- a/x/evm/keeper/benchmark_test.go +++ b/x/evm/keeper/benchmark_test.go @@ -21,12 +21,12 @@ func SetupContract(b *testing.B) (*KeeperTestSuite, common.Address) { suite.SetupTestWithT(b) amt := sdk.Coins{ethermint.NewPhotonCoinInt64(1000000000000000000)} - err := suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, amt) + err := suite.App.BankKeeper.MintCoins(suite.Ctx, types.ModuleName, amt) require.NoError(b, err) - err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, types.ModuleName, suite.address.Bytes(), amt) + err = suite.App.BankKeeper.SendCoinsFromModuleToAccount(suite.Ctx, types.ModuleName, suite.Address.Bytes(), amt) require.NoError(b, err) - contractAddr := suite.DeployTestContract(b, suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) + contractAddr := suite.DeployTestContract(b, suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) suite.Commit() return &suite, contractAddr @@ -37,9 +37,9 @@ func SetupTestMessageCall(b *testing.B) (*KeeperTestSuite, common.Address) { suite.SetupTestWithT(b) amt := sdk.Coins{ethermint.NewPhotonCoinInt64(1000000000000000000)} - err := suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, amt) + err := suite.App.BankKeeper.MintCoins(suite.Ctx, types.ModuleName, amt) require.NoError(b, err) - err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, types.ModuleName, suite.address.Bytes(), amt) + err = suite.App.BankKeeper.SendCoinsFromModuleToAccount(suite.Ctx, types.ModuleName, suite.Address.Bytes(), amt) require.NoError(b, err) contractAddr := suite.DeployTestMessageCall(b) @@ -54,24 +54,24 @@ func DoBenchmark(b *testing.B, txBuilder TxBuilder) { suite, contractAddr := SetupContract(b) msg := txBuilder(suite, contractAddr) - msg.From = suite.address.Hex() - err := msg.Sign(ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()), suite.signer) + msg.From = suite.Address.Hex() + err := msg.Sign(ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()), suite.Signer) require.NoError(b, err) b.ResetTimer() b.StartTimer() for i := 0; i < b.N; i++ { - ctx, _ := suite.ctx.CacheContext() + ctx, _ := suite.Ctx.CacheContext() // deduct fee first txData, err := types.UnpackTxData(msg.Data) require.NoError(b, err) fees := sdk.Coins{sdk.NewCoin(suite.EvmDenom(), sdkmath.NewIntFromBigInt(txData.Fee()))} - err = authante.DeductFees(suite.app.BankKeeper, suite.ctx, suite.app.AccountKeeper.GetAccount(ctx, msg.GetFrom()), fees) + err = authante.DeductFees(suite.App.BankKeeper, suite.Ctx, suite.App.AccountKeeper.GetAccount(ctx, msg.GetFrom()), fees) require.NoError(b, err) - rsp, err := suite.app.EvmKeeper.EthereumTx(sdk.WrapSDKContext(ctx), msg) + rsp, err := suite.App.EvmKeeper.EthereumTx(sdk.WrapSDKContext(ctx), msg) require.NoError(b, err) require.False(b, rsp.Failed()) } @@ -81,8 +81,8 @@ func BenchmarkTokenTransfer(b *testing.B) { DoBenchmark(b, func(suite *KeeperTestSuite, contract common.Address) *types.MsgEthereumTx { input, err := types.ERC20Contract.ABI.Pack("transfer", common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), big.NewInt(1000)) require.NoError(b, err) - nonce := suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address) - return types.NewTx(suite.app.EvmKeeper.ChainID(), nonce, &contract, big.NewInt(0), 410000, big.NewInt(1), nil, nil, input, nil) + nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) + return types.NewTx(suite.App.EvmKeeper.ChainID(), nonce, &contract, big.NewInt(0), 410000, big.NewInt(1), nil, nil, input, nil) }) } @@ -90,17 +90,17 @@ func BenchmarkEmitLogs(b *testing.B) { DoBenchmark(b, func(suite *KeeperTestSuite, contract common.Address) *types.MsgEthereumTx { input, err := types.ERC20Contract.ABI.Pack("benchmarkLogs", big.NewInt(1000)) require.NoError(b, err) - nonce := suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address) - return types.NewTx(suite.app.EvmKeeper.ChainID(), nonce, &contract, big.NewInt(0), 4100000, big.NewInt(1), nil, nil, input, nil) + nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) + return types.NewTx(suite.App.EvmKeeper.ChainID(), nonce, &contract, big.NewInt(0), 4100000, big.NewInt(1), nil, nil, input, nil) }) } func BenchmarkTokenTransferFrom(b *testing.B) { DoBenchmark(b, func(suite *KeeperTestSuite, contract common.Address) *types.MsgEthereumTx { - input, err := types.ERC20Contract.ABI.Pack("transferFrom", suite.address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), big.NewInt(0)) + input, err := types.ERC20Contract.ABI.Pack("transferFrom", suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), big.NewInt(0)) require.NoError(b, err) - nonce := suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address) - return types.NewTx(suite.app.EvmKeeper.ChainID(), nonce, &contract, big.NewInt(0), 410000, big.NewInt(1), nil, nil, input, nil) + nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) + return types.NewTx(suite.App.EvmKeeper.ChainID(), nonce, &contract, big.NewInt(0), 410000, big.NewInt(1), nil, nil, input, nil) }) } @@ -108,8 +108,8 @@ func BenchmarkTokenMint(b *testing.B) { DoBenchmark(b, func(suite *KeeperTestSuite, contract common.Address) *types.MsgEthereumTx { input, err := types.ERC20Contract.ABI.Pack("mint", common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), big.NewInt(1000)) require.NoError(b, err) - nonce := suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address) - return types.NewTx(suite.app.EvmKeeper.ChainID(), nonce, &contract, big.NewInt(0), 410000, big.NewInt(1), nil, nil, input, nil) + nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) + return types.NewTx(suite.App.EvmKeeper.ChainID(), nonce, &contract, big.NewInt(0), 410000, big.NewInt(1), nil, nil, input, nil) }) } @@ -118,27 +118,27 @@ func BenchmarkMessageCall(b *testing.B) { input, err := types.TestMessageCall.ABI.Pack("benchmarkMessageCall", big.NewInt(10000)) require.NoError(b, err) - nonce := suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address) - msg := types.NewTx(suite.app.EvmKeeper.ChainID(), nonce, &contract, big.NewInt(0), 25000000, big.NewInt(1), nil, nil, input, nil) + nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) + msg := types.NewTx(suite.App.EvmKeeper.ChainID(), nonce, &contract, big.NewInt(0), 25000000, big.NewInt(1), nil, nil, input, nil) - msg.From = suite.address.Hex() - err = msg.Sign(ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()), suite.signer) + msg.From = suite.Address.Hex() + err = msg.Sign(ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()), suite.Signer) require.NoError(b, err) b.ResetTimer() b.StartTimer() for i := 0; i < b.N; i++ { - ctx, _ := suite.ctx.CacheContext() + ctx, _ := suite.Ctx.CacheContext() // deduct fee first txData, err := types.UnpackTxData(msg.Data) require.NoError(b, err) fees := sdk.Coins{sdk.NewCoin(suite.EvmDenom(), sdkmath.NewIntFromBigInt(txData.Fee()))} - err = authante.DeductFees(suite.app.BankKeeper, suite.ctx, suite.app.AccountKeeper.GetAccount(ctx, msg.GetFrom()), fees) + err = authante.DeductFees(suite.App.BankKeeper, suite.Ctx, suite.App.AccountKeeper.GetAccount(ctx, msg.GetFrom()), fees) require.NoError(b, err) - rsp, err := suite.app.EvmKeeper.EthereumTx(sdk.WrapSDKContext(ctx), msg) + rsp, err := suite.App.EvmKeeper.EthereumTx(sdk.WrapSDKContext(ctx), msg) require.NoError(b, err) require.False(b, rsp.Failed()) } diff --git a/x/evm/keeper/grpc_query_test.go b/x/evm/keeper/grpc_query_test.go index 50849abf49..e0f7248475 100644 --- a/x/evm/keeper/grpc_query_test.go +++ b/x/evm/keeper/grpc_query_test.go @@ -55,9 +55,9 @@ func (suite *KeeperTestSuite) TestQueryAccount() { "success", func() { amt := sdk.Coins{ethermint.NewPhotonCoinInt64(100)} - err := suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, amt) + err := suite.App.BankKeeper.MintCoins(suite.Ctx, types.ModuleName, amt) suite.Require().NoError(err) - err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, types.ModuleName, suite.address.Bytes(), amt) + err = suite.App.BankKeeper.SendCoinsFromModuleToAccount(suite.Ctx, types.ModuleName, suite.Address.Bytes(), amt) suite.Require().NoError(err) expAccount = &types.QueryAccountResponse{ @@ -66,7 +66,7 @@ func (suite *KeeperTestSuite) TestQueryAccount() { Nonce: 0, } req = &types.QueryAccountRequest{ - Address: suite.address.String(), + Address: suite.Address.String(), } }, true, @@ -78,8 +78,8 @@ func (suite *KeeperTestSuite) TestQueryAccount() { suite.SetupTest() // reset tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.Account(ctx, req) + ctx := sdk.WrapSDKContext(suite.Ctx) + res, err := suite.QueryClient.Account(ctx, req) if tc.expPass { suite.Require().NoError(err) @@ -120,12 +120,12 @@ func (suite *KeeperTestSuite) TestQueryCosmosAccount() { "success", func() { expAccount = &types.QueryCosmosAccountResponse{ - CosmosAddress: sdk.AccAddress(suite.address.Bytes()).String(), + CosmosAddress: sdk.AccAddress(suite.Address.Bytes()).String(), Sequence: 0, AccountNumber: 0, } req = &types.QueryCosmosAccountRequest{ - Address: suite.address.String(), + Address: suite.Address.String(), } }, true, @@ -133,18 +133,18 @@ func (suite *KeeperTestSuite) TestQueryCosmosAccount() { { "success with seq and account number", func() { - acc := suite.app.AccountKeeper.GetAccount(suite.ctx, suite.address.Bytes()) + acc := suite.App.AccountKeeper.GetAccount(suite.Ctx, suite.Address.Bytes()) suite.Require().NoError(acc.SetSequence(10)) suite.Require().NoError(acc.SetAccountNumber(1)) - suite.app.AccountKeeper.SetAccount(suite.ctx, acc) + suite.App.AccountKeeper.SetAccount(suite.Ctx, acc) expAccount = &types.QueryCosmosAccountResponse{ - CosmosAddress: sdk.AccAddress(suite.address.Bytes()).String(), + CosmosAddress: sdk.AccAddress(suite.Address.Bytes()).String(), Sequence: 10, AccountNumber: 1, } req = &types.QueryCosmosAccountRequest{ - Address: suite.address.String(), + Address: suite.Address.String(), } }, true, @@ -156,8 +156,8 @@ func (suite *KeeperTestSuite) TestQueryCosmosAccount() { suite.SetupTest() // reset tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.CosmosAccount(ctx, req) + ctx := sdk.WrapSDKContext(suite.Ctx) + res, err := suite.QueryClient.CosmosAccount(ctx, req) if tc.expPass { suite.Require().NoError(err) @@ -196,14 +196,14 @@ func (suite *KeeperTestSuite) TestQueryBalance() { "success", func() { amt := sdk.Coins{ethermint.NewPhotonCoinInt64(100)} - err := suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, amt) + err := suite.App.BankKeeper.MintCoins(suite.Ctx, types.ModuleName, amt) suite.Require().NoError(err) - err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, types.ModuleName, suite.address.Bytes(), amt) + err = suite.App.BankKeeper.SendCoinsFromModuleToAccount(suite.Ctx, types.ModuleName, suite.Address.Bytes(), amt) suite.Require().NoError(err) expBalance = "100" req = &types.QueryBalanceRequest{ - Address: suite.address.String(), + Address: suite.Address.String(), } }, true, @@ -215,8 +215,8 @@ func (suite *KeeperTestSuite) TestQueryBalance() { suite.SetupTest() // reset tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.Balance(ctx, req) + ctx := sdk.WrapSDKContext(suite.Ctx) + res, err := suite.QueryClient.Balance(ctx, req) if tc.expPass { suite.Require().NoError(err) @@ -256,9 +256,9 @@ func (suite *KeeperTestSuite) TestQueryStorage() { key := common.BytesToHash([]byte("key")) value := common.BytesToHash([]byte("value")) expValue = value.String() - vmdb.SetState(suite.address, key, value) + vmdb.SetState(suite.Address, key, value) req = &types.QueryStorageRequest{ - Address: suite.address.String(), + Address: suite.Address.String(), Key: key.String(), } }, @@ -274,8 +274,8 @@ func (suite *KeeperTestSuite) TestQueryStorage() { tc.malleate(vmdb) suite.Require().NoError(vmdb.Commit()) - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.Storage(ctx, req) + ctx := sdk.WrapSDKContext(suite.Ctx) + res, err := suite.QueryClient.Storage(ctx, req) if tc.expPass { suite.Require().NoError(err) @@ -315,10 +315,10 @@ func (suite *KeeperTestSuite) TestQueryCode() { "success", func(vmdb vm.StateDB) { expCode = []byte("code") - vmdb.SetCode(suite.address, expCode) + vmdb.SetCode(suite.Address, expCode) req = &types.QueryCodeRequest{ - Address: suite.address.String(), + Address: suite.Address.String(), } }, true, @@ -333,8 +333,8 @@ func (suite *KeeperTestSuite) TestQueryCode() { tc.malleate(vmdb) suite.Require().NoError(vmdb.Commit()) - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.Code(ctx, req) + ctx := sdk.WrapSDKContext(suite.Ctx) + res, err := suite.QueryClient.Code(ctx, req) if tc.expPass { suite.Require().NoError(err) @@ -369,13 +369,13 @@ func (suite *KeeperTestSuite) TestQueryTxLogs() { func(vmdb vm.StateDB) { expLogs = []*types.Log{ { - Address: suite.address.String(), + Address: suite.Address.String(), Topics: []string{common.BytesToHash([]byte("topic")).String()}, Data: []byte("data"), BlockNumber: 1, TxHash: txHash.String(), TxIndex: uint64(txIndex), - BlockHash: common.BytesToHash(suite.ctx.HeaderHash()).Hex(), + BlockHash: common.BytesToHash(suite.Ctx.HeaderHash()).Hex(), Index: uint64(logIndex), Removed: false, }, @@ -392,7 +392,7 @@ func (suite *KeeperTestSuite) TestQueryTxLogs() { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset - vmdb := statedb.New(suite.ctx, suite.app.EvmKeeper, types.NewTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()), txHash, txIndex, logIndex)) + vmdb := statedb.New(suite.Ctx, suite.App.EvmKeeper, types.NewTxConfig(common.BytesToHash(suite.Ctx.HeaderHash().Bytes()), txHash, txIndex, logIndex)) tc.malleate(vmdb) suite.Require().NoError(vmdb.Commit()) @@ -403,11 +403,11 @@ func (suite *KeeperTestSuite) TestQueryTxLogs() { } func (suite *KeeperTestSuite) TestQueryParams() { - ctx := sdk.WrapSDKContext(suite.ctx) + ctx := sdk.WrapSDKContext(suite.Ctx) expParams := types.DefaultParams() expParams.EIP712AllowedMsgs = nil - res, err := suite.queryClient.Params(ctx, &types.QueryParamsRequest{}) + res, err := suite.QueryClient.Params(ctx, &types.QueryParamsRequest{}) suite.Require().NoError(err) suite.Require().Equal(expParams, res.Params) } @@ -439,12 +439,12 @@ func (suite *KeeperTestSuite) TestQueryValidatorAccount() { "success", func() { expAccount = &types.QueryValidatorAccountResponse{ - AccountAddress: sdk.AccAddress(suite.address.Bytes()).String(), + AccountAddress: sdk.AccAddress(suite.Address.Bytes()).String(), Sequence: 0, AccountNumber: 0, } req = &types.QueryValidatorAccountRequest{ - ConsAddress: suite.consAddress.String(), + ConsAddress: suite.ConsAddress.String(), } }, true, @@ -452,18 +452,18 @@ func (suite *KeeperTestSuite) TestQueryValidatorAccount() { { "success with seq and account number", func() { - acc := suite.app.AccountKeeper.GetAccount(suite.ctx, suite.address.Bytes()) + acc := suite.App.AccountKeeper.GetAccount(suite.Ctx, suite.Address.Bytes()) suite.Require().NoError(acc.SetSequence(10)) suite.Require().NoError(acc.SetAccountNumber(1)) - suite.app.AccountKeeper.SetAccount(suite.ctx, acc) + suite.App.AccountKeeper.SetAccount(suite.Ctx, acc) expAccount = &types.QueryValidatorAccountResponse{ - AccountAddress: sdk.AccAddress(suite.address.Bytes()).String(), + AccountAddress: sdk.AccAddress(suite.Address.Bytes()).String(), Sequence: 10, AccountNumber: 1, } req = &types.QueryValidatorAccountRequest{ - ConsAddress: suite.consAddress.String(), + ConsAddress: suite.ConsAddress.String(), } }, true, @@ -475,8 +475,8 @@ func (suite *KeeperTestSuite) TestQueryValidatorAccount() { suite.SetupTest() // reset tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.ValidatorAccount(ctx, req) + ctx := sdk.WrapSDKContext(suite.Ctx) + res, err := suite.QueryClient.ValidatorAccount(ctx, req) if tc.expPass { suite.Require().NoError(err) @@ -540,7 +540,7 @@ func (suite *KeeperTestSuite) TestEstimateGas() { { "enough balance", func() { - args = types.TransactionArgs{To: &common.Address{}, From: &suite.address, Value: (*hexutil.Big)(big.NewInt(100))} + args = types.TransactionArgs{To: &common.Address{}, From: &suite.Address, Value: (*hexutil.Big)(big.NewInt(100))} }, false, 0, false, }, // should success, because gas limit lower than 21000 is ignored @@ -568,11 +568,11 @@ func (suite *KeeperTestSuite) TestEstimateGas() { { "contract deployment", func() { - ctorArgs, err := types.ERC20Contract.ABI.Pack("", &suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) + ctorArgs, err := types.ERC20Contract.ABI.Pack("", &suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) suite.Require().NoError(err) data := append(types.ERC20Contract.Bin, ctorArgs...) args = types.TransactionArgs{ - From: &suite.address, + From: &suite.Address, Data: (*hexutil.Bytes)(&data), } }, @@ -584,11 +584,11 @@ func (suite *KeeperTestSuite) TestEstimateGas() { { "erc20 transfer", func() { - contractAddr := suite.DeployTestContract(suite.T(), suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) + contractAddr := suite.DeployTestContract(suite.T(), suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) suite.Commit() transferData, err := types.ERC20Contract.ABI.Pack("transfer", common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), big.NewInt(1000)) suite.Require().NoError(err) - args = types.TransactionArgs{To: &contractAddr, From: &suite.address, Data: (*hexutil.Bytes)(&transferData)} + args = types.TransactionArgs{To: &contractAddr, From: &suite.Address, Data: (*hexutil.Bytes)(&transferData)} }, true, 51880, @@ -616,7 +616,7 @@ func (suite *KeeperTestSuite) TestEstimateGas() { { "enough balance w/ enableFeemarket", func() { - args = types.TransactionArgs{To: &common.Address{}, From: &suite.address, Value: (*hexutil.Big)(big.NewInt(100))} + args = types.TransactionArgs{To: &common.Address{}, From: &suite.Address, Value: (*hexutil.Big)(big.NewInt(100))} }, false, 0, @@ -644,11 +644,11 @@ func (suite *KeeperTestSuite) TestEstimateGas() { { "contract deployment w/ enableFeemarket", func() { - ctorArgs, err := types.ERC20Contract.ABI.Pack("", &suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) + ctorArgs, err := types.ERC20Contract.ABI.Pack("", &suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) suite.Require().NoError(err) data := append(types.ERC20Contract.Bin, ctorArgs...) args = types.TransactionArgs{ - From: &suite.address, + From: &suite.Address, Data: (*hexutil.Bytes)(&data), } }, @@ -659,11 +659,11 @@ func (suite *KeeperTestSuite) TestEstimateGas() { { "erc20 transfer w/ enableFeemarket", func() { - contractAddr := suite.DeployTestContract(suite.T(), suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) + contractAddr := suite.DeployTestContract(suite.T(), suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) suite.Commit() transferData, err := types.ERC20Contract.ABI.Pack("transfer", common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), big.NewInt(1000)) suite.Require().NoError(err) - args = types.TransactionArgs{To: &contractAddr, From: &suite.address, Data: (*hexutil.Bytes)(&transferData)} + args = types.TransactionArgs{To: &contractAddr, From: &suite.Address, Data: (*hexutil.Bytes)(&transferData)} }, true, 51880, @@ -672,16 +672,16 @@ func (suite *KeeperTestSuite) TestEstimateGas() { { "contract creation but 'create' param disabled", func() { - ctorArgs, err := types.ERC20Contract.ABI.Pack("", &suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) + ctorArgs, err := types.ERC20Contract.ABI.Pack("", &suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) suite.Require().NoError(err) data := append(types.ERC20Contract.Bin, ctorArgs...) args = types.TransactionArgs{ - From: &suite.address, + From: &suite.Address, Data: (*hexutil.Bytes)(&data), } - params := suite.app.EvmKeeper.GetParams(suite.ctx) + params := suite.App.EvmKeeper.GetParams(suite.Ctx) params.EnableCreate = false - suite.app.EvmKeeper.SetParams(suite.ctx, params) + suite.App.EvmKeeper.SetParams(suite.Ctx, params) }, false, 0, @@ -729,7 +729,7 @@ func (suite *KeeperTestSuite) TestEstimateGas() { for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.enableFeemarket = tc.enableFeemarket + suite.EnableFeemarket = tc.enableFeemarket suite.SetupTest() gasCap = 25_000_000 tc.malleate() @@ -739,10 +739,10 @@ func (suite *KeeperTestSuite) TestEstimateGas() { req := types.EthCallRequest{ Args: args, GasCap: gasCap, - ProposerAddress: suite.ctx.BlockHeader().ProposerAddress, + ProposerAddress: suite.Ctx.BlockHeader().ProposerAddress, } - rsp, err := suite.queryClient.EstimateGas(sdk.WrapSDKContext(suite.ctx), &req) + rsp, err := suite.QueryClient.EstimateGas(sdk.WrapSDKContext(suite.Ctx), &req) if tc.expPass { suite.Require().NoError(err) suite.Require().Equal(int64(tc.expGas), int64(rsp.Gas)) @@ -751,7 +751,7 @@ func (suite *KeeperTestSuite) TestEstimateGas() { } }) } - suite.enableFeemarket = false // reset flag + suite.EnableFeemarket = false // reset flag } func (suite *KeeperTestSuite) TestTraceTx() { @@ -837,14 +837,14 @@ func (suite *KeeperTestSuite) TestTraceTx() { // increase nonce to avoid address collision vmdb := suite.StateDB() - vmdb.SetNonce(suite.address, vmdb.GetNonce(suite.address)+1) + vmdb.SetNonce(suite.Address, vmdb.GetNonce(suite.Address)+1) suite.Require().NoError(vmdb.Commit()) - contractAddr := suite.DeployTestContract(suite.T(), suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) + contractAddr := suite.DeployTestContract(suite.T(), suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) suite.Commit() // Generate token transfer transaction - firstTx := suite.TransferERC20Token(suite.T(), contractAddr, suite.address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) - txMsg = suite.TransferERC20Token(suite.T(), contractAddr, suite.address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + firstTx := suite.TransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + txMsg = suite.TransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) suite.Commit() predecessors = append(predecessors, firstTx) @@ -896,11 +896,11 @@ func (suite *KeeperTestSuite) TestTraceTx() { // increase nonce to avoid address collision vmdb := suite.StateDB() - vmdb.SetNonce(suite.address, vmdb.GetNonce(suite.address)+1) + vmdb.SetNonce(suite.Address, vmdb.GetNonce(suite.Address)+1) suite.Require().NoError(vmdb.Commit()) - chainID := suite.app.EvmKeeper.ChainID() - nonce := suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address) + chainID := suite.App.EvmKeeper.ChainID() + nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) data := types.ERC20Contract.Bin contractTx := types.NewTxContract( chainID, @@ -916,9 +916,9 @@ func (suite *KeeperTestSuite) TestTraceTx() { predecessors = append(predecessors, contractTx) suite.Commit() - params := suite.app.EvmKeeper.GetParams(suite.ctx) + params := suite.App.EvmKeeper.GetParams(suite.Ctx) params.EnableCreate = false - suite.app.EvmKeeper.SetParams(suite.ctx, params) + suite.App.EvmKeeper.SetParams(suite.Ctx, params) }, expPass: true, traceResponse: "{\"gas\":34828,\"failed\":false,\"returnValue\":\"0000000000000000000000000000000000000000000000000000000000000001\",\"structLogs\":[{\"pc\":0,\"op\":\"PUSH1\",\"gas\":", @@ -937,13 +937,13 @@ func (suite *KeeperTestSuite) TestTraceTx() { for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.enableFeemarket = tc.enableFeemarket + suite.EnableFeemarket = tc.enableFeemarket suite.SetupTest() // Deploy contract - contractAddr := suite.DeployTestContract(suite.T(), suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) + contractAddr := suite.DeployTestContract(suite.T(), suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) suite.Commit() // Generate token transfer transaction - txMsg = suite.TransferERC20Token(suite.T(), contractAddr, suite.address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + txMsg = suite.TransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) suite.Commit() tc.malleate() @@ -956,7 +956,7 @@ func (suite *KeeperTestSuite) TestTraceTx() { if chainID != nil { traceReq.ChainId = chainID.Int64() } - res, err := suite.queryClient.TraceTx(sdk.WrapSDKContext(suite.ctx), &traceReq) + res, err := suite.QueryClient.TraceTx(sdk.WrapSDKContext(suite.Ctx), &traceReq) if tc.expPass { suite.Require().NoError(err) @@ -979,7 +979,7 @@ func (suite *KeeperTestSuite) TestTraceTx() { }) } - suite.enableFeemarket = false // reset flag + suite.EnableFeemarket = false // reset flag } func (suite *KeeperTestSuite) TestTraceBlock() { @@ -1057,14 +1057,14 @@ func (suite *KeeperTestSuite) TestTraceBlock() { // increase nonce to avoid address collision vmdb := suite.StateDB() - vmdb.SetNonce(suite.address, vmdb.GetNonce(suite.address)+1) + vmdb.SetNonce(suite.Address, vmdb.GetNonce(suite.Address)+1) suite.Require().NoError(vmdb.Commit()) - contractAddr := suite.DeployTestContract(suite.T(), suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) + contractAddr := suite.DeployTestContract(suite.T(), suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) suite.Commit() // create multiple transactions in the same block - firstTx := suite.TransferERC20Token(suite.T(), contractAddr, suite.address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) - secondTx := suite.TransferERC20Token(suite.T(), contractAddr, suite.address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + firstTx := suite.TransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + secondTx := suite.TransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) suite.Commit() // overwrite txs to include only the ones on new block txs = append([]*types.MsgEthereumTx{}, firstTx, secondTx) @@ -1113,13 +1113,13 @@ func (suite *KeeperTestSuite) TestTraceBlock() { for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { txs = []*types.MsgEthereumTx{} - suite.enableFeemarket = tc.enableFeemarket + suite.EnableFeemarket = tc.enableFeemarket suite.SetupTest() // Deploy contract - contractAddr := suite.DeployTestContract(suite.T(), suite.address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) + contractAddr := suite.DeployTestContract(suite.T(), suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) suite.Commit() // Generate token transfer transaction - txMsg := suite.TransferERC20Token(suite.T(), contractAddr, suite.address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + txMsg := suite.TransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) suite.Commit() txs = append(txs, txMsg) @@ -1134,7 +1134,7 @@ func (suite *KeeperTestSuite) TestTraceBlock() { traceReq.ChainId = chainID.Int64() } - res, err := suite.queryClient.TraceBlock(sdk.WrapSDKContext(suite.ctx), &traceReq) + res, err := suite.QueryClient.TraceBlock(sdk.WrapSDKContext(suite.Ctx), &traceReq) if tc.expPass { suite.Require().NoError(err) @@ -1152,12 +1152,12 @@ func (suite *KeeperTestSuite) TestTraceBlock() { }) } - suite.enableFeemarket = false // reset flag + suite.EnableFeemarket = false // reset flag } func (suite *KeeperTestSuite) TestNonceInQuery() { address := tests.GenerateAddress() - suite.Require().Equal(uint64(0), suite.app.EvmKeeper.GetNonce(suite.ctx, address)) + suite.Require().Equal(uint64(0), suite.App.EvmKeeper.GetNonce(suite.Ctx, address)) supply := sdkmath.NewIntWithDecimal(1000, 18).BigInt() // accupy nonce 0 @@ -1173,15 +1173,15 @@ func (suite *KeeperTestSuite) TestNonceInQuery() { Data: (*hexutil.Bytes)(&data), }) suite.Require().NoError(err) - proposerAddress := suite.ctx.BlockHeader().ProposerAddress - _, err = suite.queryClient.EstimateGas(sdk.WrapSDKContext(suite.ctx), &types.EthCallRequest{ + proposerAddress := suite.Ctx.BlockHeader().ProposerAddress + _, err = suite.QueryClient.EstimateGas(sdk.WrapSDKContext(suite.Ctx), &types.EthCallRequest{ Args: args, GasCap: uint64(config.DefaultGasCap), ProposerAddress: proposerAddress, }) suite.Require().NoError(err) - _, err = suite.queryClient.EthCall(sdk.WrapSDKContext(suite.ctx), &types.EthCallRequest{ + _, err = suite.QueryClient.EthCall(sdk.WrapSDKContext(suite.Ctx), &types.EthCallRequest{ Args: args, GasCap: uint64(config.DefaultGasCap), ProposerAddress: proposerAddress, @@ -1214,7 +1214,7 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { "pass - non-nil Base Fee", func() { baseFee := sdk.OneInt().BigInt() - suite.app.FeeMarketKeeper.SetBaseFee(suite.ctx, baseFee) + suite.App.FeeMarketKeeper.SetBaseFee(suite.Ctx, baseFee) aux = sdkmath.NewIntFromBigInt(baseFee) expRes = &types.QueryBaseFeeResponse{BaseFee: &aux} @@ -1225,7 +1225,7 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { "pass - nil Base Fee when london hardfork not activated", func() { baseFee := sdk.OneInt().BigInt() - suite.app.FeeMarketKeeper.SetBaseFee(suite.ctx, baseFee) + suite.App.FeeMarketKeeper.SetBaseFee(suite.Ctx, baseFee) expRes = &types.QueryBaseFeeResponse{} }, @@ -1242,13 +1242,13 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { } for _, tc := range testCases { suite.Run(tc.name, func() { - suite.enableFeemarket = tc.enableFeemarket - suite.enableLondonHF = tc.enableLondonHF + suite.EnableFeemarket = tc.enableFeemarket + suite.EnableLondonHF = tc.enableLondonHF suite.SetupTest() tc.malleate() - res, err := suite.queryClient.BaseFee(suite.ctx.Context(), &types.QueryBaseFeeRequest{}) + res, err := suite.QueryClient.BaseFee(suite.Ctx.Context(), &types.QueryBaseFeeRequest{}) if tc.expPass { suite.Require().NotNil(res) suite.Require().Equal(expRes, res, tc.name) @@ -1258,15 +1258,15 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { } }) } - suite.enableFeemarket = false - suite.enableLondonHF = true + suite.EnableFeemarket = false + suite.EnableLondonHF = true } func (suite *KeeperTestSuite) TestEthCall() { var req *types.EthCallRequest address := tests.GenerateAddress() - suite.Require().Equal(uint64(0), suite.app.EvmKeeper.GetNonce(suite.ctx, address)) + suite.Require().Equal(uint64(0), suite.App.EvmKeeper.GetNonce(suite.Ctx, address)) supply := sdkmath.NewIntWithDecimal(1000, 18).BigInt() hexBigInt := hexutil.Big(*big.NewInt(1)) @@ -1313,9 +1313,9 @@ func (suite *KeeperTestSuite) TestEthCall() { suite.Require().NoError(err) req = &types.EthCallRequest{Args: args, GasCap: uint64(config.DefaultGasCap)} - params := suite.app.EvmKeeper.GetParams(suite.ctx) + params := suite.App.EvmKeeper.GetParams(suite.Ctx) params.EnableCreate = false - suite.app.EvmKeeper.SetParams(suite.ctx, params) + suite.App.EvmKeeper.SetParams(suite.Ctx, params) }, false, }, @@ -1325,7 +1325,7 @@ func (suite *KeeperTestSuite) TestEthCall() { suite.SetupTest() tc.malleate() - res, err := suite.queryClient.EthCall(suite.ctx, req) + res, err := suite.QueryClient.EthCall(suite.Ctx, req) if tc.expPass { suite.Require().NotNil(res) suite.Require().NoError(err) @@ -1337,7 +1337,7 @@ func (suite *KeeperTestSuite) TestEthCall() { } func (suite *KeeperTestSuite) TestEmptyRequest() { - k := suite.app.EvmKeeper + k := suite.App.EvmKeeper testCases := []struct { name string @@ -1346,61 +1346,61 @@ func (suite *KeeperTestSuite) TestEmptyRequest() { { "Account method", func() (interface{}, error) { - return k.Account(suite.ctx, nil) + return k.Account(suite.Ctx, nil) }, }, { "CosmosAccount method", func() (interface{}, error) { - return k.CosmosAccount(suite.ctx, nil) + return k.CosmosAccount(suite.Ctx, nil) }, }, { "ValidatorAccount method", func() (interface{}, error) { - return k.ValidatorAccount(suite.ctx, nil) + return k.ValidatorAccount(suite.Ctx, nil) }, }, { "Balance method", func() (interface{}, error) { - return k.Balance(suite.ctx, nil) + return k.Balance(suite.Ctx, nil) }, }, { "Storage method", func() (interface{}, error) { - return k.Storage(suite.ctx, nil) + return k.Storage(suite.Ctx, nil) }, }, { "Code method", func() (interface{}, error) { - return k.Code(suite.ctx, nil) + return k.Code(suite.Ctx, nil) }, }, { "EthCall method", func() (interface{}, error) { - return k.EthCall(suite.ctx, nil) + return k.EthCall(suite.Ctx, nil) }, }, { "EstimateGas method", func() (interface{}, error) { - return k.EstimateGas(suite.ctx, nil) + return k.EstimateGas(suite.Ctx, nil) }, }, { "TraceTx method", func() (interface{}, error) { - return k.TraceTx(suite.ctx, nil) + return k.TraceTx(suite.Ctx, nil) }, }, { "TraceBlock method", func() (interface{}, error) { - return k.TraceBlock(suite.ctx, nil) + return k.TraceBlock(suite.Ctx, nil) }, }, } diff --git a/x/evm/keeper/hooks_test.go b/x/evm/keeper/hooks_test.go index 27f6dc58a0..d3d198d9fa 100644 --- a/x/evm/keeper/hooks_test.go +++ b/x/evm/keeper/hooks_test.go @@ -61,10 +61,10 @@ func (suite *KeeperTestSuite) TestEvmHooks() { for _, tc := range testCases { suite.SetupTest() hook := tc.setupHook() - suite.app.EvmKeeper.SetHooks(keeper.NewMultiEvmHooks(hook)) + suite.App.EvmKeeper.SetHooks(keeper.NewMultiEvmHooks(hook)) - k := suite.app.EvmKeeper - ctx := suite.ctx + k := suite.App.EvmKeeper + ctx := suite.Ctx txHash := common.BigToHash(big.NewInt(1)) vmdb := statedb.New(ctx, k, types.NewTxConfig( common.BytesToHash(ctx.HeaderHash().Bytes()), @@ -75,7 +75,7 @@ func (suite *KeeperTestSuite) TestEvmHooks() { vmdb.AddLog(ðtypes.Log{ Topics: []common.Hash{}, - Address: suite.address, + Address: suite.Address, }) logs := vmdb.Logs() receipt := ðtypes.Receipt{ diff --git a/x/evm/keeper/integration_test.go b/x/evm/keeper/integration_test.go index 6c51680449..ce5cdf56c0 100644 --- a/x/evm/keeper/integration_test.go +++ b/x/evm/keeper/integration_test.go @@ -130,11 +130,11 @@ var _ = Describe("Feemarket", func() { // setupTestWithContext sets up a test chain with an example Cosmos send msg, // given a local (validator config) and a gloabl (feemarket param) minGasPrice func setupTestWithContext(valMinGasPrice string, minGasPrice sdk.Dec, baseFee sdk.Int) (*ethsecp256k1.PrivKey, banktypes.MsgSend) { - privKey, msg := setupTest(valMinGasPrice + s.denom) + privKey, msg := setupTest(valMinGasPrice + s.Denom) params := types.DefaultParams() params.MinGasPrice = minGasPrice - s.app.FeeMarketKeeper.SetParams(s.ctx, params) - s.app.FeeMarketKeeper.SetBaseFee(s.ctx, baseFee.BigInt()) + s.App.FeeMarketKeeper.SetParams(s.Ctx, params) + s.App.FeeMarketKeeper.SetBaseFee(s.Ctx, baseFee.BigInt()) s.Commit() return privKey, msg @@ -147,16 +147,16 @@ func setupTest(localMinGasPrices string) (*ethsecp256k1.PrivKey, banktypes.MsgSe amount, ok := sdk.NewIntFromString("10000000000000000000") s.Require().True(ok) initBalance := sdk.Coins{sdk.Coin{ - Denom: s.denom, + Denom: s.Denom, Amount: amount, }} - testutil.FundAccount(s.app.BankKeeper, s.ctx, address, initBalance) + testutil.FundAccount(s.App.BankKeeper, s.Ctx, address, initBalance) msg := banktypes.MsgSend{ FromAddress: address.String(), ToAddress: address.String(), Amount: sdk.Coins{sdk.Coin{ - Denom: s.denom, + Denom: s.Denom, Amount: sdk.NewInt(10000), }}, } @@ -197,7 +197,7 @@ func setupChain(localMinGasPricesStr string) { }, ) - s.app = newapp + s.App = newapp s.SetupApp(false) } @@ -207,8 +207,8 @@ func generateKey() (*ethsecp256k1.PrivKey, sdk.AccAddress) { } func getNonce(addressBytes []byte) uint64 { - return s.app.EvmKeeper.GetNonce( - s.ctx, + return s.App.EvmKeeper.GetNonce( + s.Ctx, common.BytesToAddress(addressBytes), ) } @@ -222,7 +222,7 @@ func buildEthTx( gasTipCap *big.Int, accesses *ethtypes.AccessList, ) *evmtypes.MsgEthereumTx { - chainID := s.app.EvmKeeper.ChainID() + chainID := s.App.EvmKeeper.ChainID() from := common.BytesToAddress(priv.PubKey().Address().Bytes()) nonce := getNonce(from.Bytes()) data := make([]byte, 0) @@ -252,7 +252,7 @@ func prepareEthTx(priv *ethsecp256k1.PrivKey, msgEthereumTx *evmtypes.MsgEthereu s.Require().True(ok) builder.SetExtensionOptions(option) - err = msgEthereumTx.Sign(s.ethSigner, tests.NewSigner(priv)) + err = msgEthereumTx.Sign(s.EthSigner, tests.NewSigner(priv)) s.Require().NoError(err) // A valid msg should have empty `From` @@ -263,7 +263,7 @@ func prepareEthTx(priv *ethsecp256k1.PrivKey, msgEthereumTx *evmtypes.MsgEthereu txData, err := evmtypes.UnpackTxData(msgEthereumTx.Data) s.Require().NoError(err) - evmDenom := s.app.EvmKeeper.GetParams(s.ctx).EvmDenom + evmDenom := s.App.EvmKeeper.GetParams(s.Ctx).EvmDenom fees := sdk.Coins{{Denom: evmDenom, Amount: sdk.NewIntFromBigInt(txData.Fee())}} builder.SetFeeAmount(fees) builder.SetGasLimit(msgEthereumTx.GetGas()) @@ -278,13 +278,13 @@ func prepareEthTx(priv *ethsecp256k1.PrivKey, msgEthereumTx *evmtypes.MsgEthereu func checkEthTx(priv *ethsecp256k1.PrivKey, msgEthereumTx *evmtypes.MsgEthereumTx) abci.ResponseCheckTx { bz := prepareEthTx(priv, msgEthereumTx) req := abci.RequestCheckTx{Tx: bz} - res := s.app.BaseApp.CheckTx(req) + res := s.App.BaseApp.CheckTx(req) return res } func deliverEthTx(priv *ethsecp256k1.PrivKey, msgEthereumTx *evmtypes.MsgEthereumTx) abci.ResponseDeliverTx { bz := prepareEthTx(priv, msgEthereumTx) req := abci.RequestDeliverTx{Tx: bz} - res := s.app.BaseApp.DeliverTx(req) + res := s.App.BaseApp.DeliverTx(req) return res } diff --git a/x/evm/keeper/keeper_test.go b/x/evm/keeper/keeper_test.go index 826a8f53cc..4d13dce5b3 100644 --- a/x/evm/keeper/keeper_test.go +++ b/x/evm/keeper/keeper_test.go @@ -2,78 +2,31 @@ package keeper_test import ( _ "embed" - "encoding/json" - "math" "math/big" "os" "testing" - "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" sdkmath "cosmossdk.io/math" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/cosmos/cosmos-sdk/simapp" - sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" - tmjson "github.com/tendermint/tendermint/libs/json" + "github.com/evmos/ethermint/x/evm/testutil" + "github.com/stretchr/testify/suite" - "github.com/evmos/ethermint/app" - "github.com/evmos/ethermint/crypto/ethsecp256k1" - "github.com/evmos/ethermint/encoding" - "github.com/evmos/ethermint/server/config" - "github.com/evmos/ethermint/tests" ethermint "github.com/evmos/ethermint/types" - "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" - evmtypes "github.com/evmos/ethermint/x/evm/types" - "github.com/evmos/ethermint/x/evm/vm" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/params" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto/tmhash" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmversion "github.com/tendermint/tendermint/proto/tendermint/version" - "github.com/tendermint/tendermint/version" ) var testTokens = sdkmath.NewIntWithDecimal(1000, 18) type KeeperTestSuite struct { - suite.Suite - - ctx sdk.Context - app *app.EthermintApp - queryClient types.QueryClient - address common.Address - consAddress sdk.ConsAddress - - // for generate test tx - clientCtx client.Context - ethSigner ethtypes.Signer - - appCodec codec.Codec - signer keyring.Signer - - enableFeemarket bool - enableLondonHF bool - mintFeeCollector bool - denom string + testutil.KeeperTestSuite } var s *KeeperTestSuite @@ -83,8 +36,8 @@ func TestKeeperTestSuite(t *testing.T) { t.Skip("Skipping Gingko Test") } s = new(KeeperTestSuite) - s.enableFeemarket = false - s.enableLondonHF = true + s.EnableFeemarket = false + s.EnableLondonHF = true suite.Run(t, s) // Run Ginkgo integration tests @@ -92,343 +45,6 @@ func TestKeeperTestSuite(t *testing.T) { RunSpecs(t, "Keeper Suite") } -func (suite *KeeperTestSuite) SetupTest() { - checkTx := false - suite.app = app.Setup(checkTx, nil) - suite.SetupApp(checkTx) -} - -func (suite *KeeperTestSuite) SetupTestWithT(t require.TestingT) { - checkTx := false - suite.app = app.Setup(checkTx, nil) - suite.SetupAppWithT(checkTx, t) -} - -func (suite *KeeperTestSuite) SetupApp(checkTx bool) { - suite.SetupAppWithT(checkTx, suite.T()) -} - -// SetupApp setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`. -func (suite *KeeperTestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { - // account key, use a constant account to keep unit test deterministic. - ecdsaPriv, err := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") - require.NoError(t, err) - priv := ðsecp256k1.PrivKey{ - Key: crypto.FromECDSA(ecdsaPriv), - } - suite.address = common.BytesToAddress(priv.PubKey().Address().Bytes()) - suite.signer = tests.NewSigner(priv) - - // consensus key - priv, err = ethsecp256k1.GenerateKey() - require.NoError(t, err) - suite.consAddress = sdk.ConsAddress(priv.PubKey().Address()) - - suite.app = app.Setup(checkTx, func(app *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState { - feemarketGenesis := feemarkettypes.DefaultGenesisState() - if suite.enableFeemarket { - feemarketGenesis.Params.EnableHeight = 1 - feemarketGenesis.Params.NoBaseFee = false - } else { - feemarketGenesis.Params.NoBaseFee = true - } - genesis[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(feemarketGenesis) - if !suite.enableLondonHF { - evmGenesis := types.DefaultGenesisState() - maxInt := sdkmath.NewInt(math.MaxInt64) - evmGenesis.Params.ChainConfig.LondonBlock = &maxInt - evmGenesis.Params.ChainConfig.ArrowGlacierBlock = &maxInt - evmGenesis.Params.ChainConfig.GrayGlacierBlock = &maxInt - evmGenesis.Params.ChainConfig.MergeNetsplitBlock = &maxInt - evmGenesis.Params.ChainConfig.ShanghaiBlock = &maxInt - evmGenesis.Params.ChainConfig.CancunBlock = &maxInt - genesis[types.ModuleName] = app.AppCodec().MustMarshalJSON(evmGenesis) - } - return genesis - }) - - if suite.mintFeeCollector { - // mint some coin to fee collector - coins := sdk.NewCoins(sdk.NewCoin(types.DefaultEVMDenom, sdkmath.NewInt(int64(params.TxGas)-1))) - genesisState := app.NewTestGenesisState(suite.app.AppCodec()) - balances := []banktypes.Balance{ - { - Address: suite.app.AccountKeeper.GetModuleAddress(authtypes.FeeCollectorName).String(), - Coins: coins, - }, - } - var bankGenesis banktypes.GenesisState - suite.app.AppCodec().MustUnmarshalJSON(genesisState[banktypes.ModuleName], &bankGenesis) - // Update balances and total supply - bankGenesis.Balances = append(bankGenesis.Balances, balances...) - bankGenesis.Supply = bankGenesis.Supply.Add(coins...) - genesisState[banktypes.ModuleName] = suite.app.AppCodec().MustMarshalJSON(&bankGenesis) - - // we marshal the genesisState of all module to a byte array - stateBytes, err := tmjson.MarshalIndent(genesisState, "", " ") - require.NoError(t, err) - - // Initialize the chain - suite.app.InitChain( - abci.RequestInitChain{ - ChainId: "ethermint_9000-1", - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: app.DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) - } - - suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{ - Height: 1, - ChainID: "ethermint_9000-1", - Time: time.Now().UTC(), - ProposerAddress: suite.consAddress.Bytes(), - Version: tmversion.Consensus{ - Block: version.BlockProtocol, - }, - LastBlockId: tmproto.BlockID{ - Hash: tmhash.Sum([]byte("block_id")), - PartSetHeader: tmproto.PartSetHeader{ - Total: 11, - Hash: tmhash.Sum([]byte("partset_header")), - }, - }, - AppHash: tmhash.Sum([]byte("app")), - DataHash: tmhash.Sum([]byte("data")), - EvidenceHash: tmhash.Sum([]byte("evidence")), - ValidatorsHash: tmhash.Sum([]byte("validators")), - NextValidatorsHash: tmhash.Sum([]byte("next_validators")), - ConsensusHash: tmhash.Sum([]byte("consensus")), - LastResultsHash: tmhash.Sum([]byte("last_result")), - }) - - queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, suite.app.EvmKeeper) - suite.queryClient = types.NewQueryClient(queryHelper) - - acc := ðermint.EthAccount{ - BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(suite.address.Bytes()), nil, 0, 0), - CodeHash: common.BytesToHash(crypto.Keccak256(nil)).String(), - } - - suite.app.AccountKeeper.SetAccount(suite.ctx, acc) - - valAddr := sdk.ValAddress(suite.address.Bytes()) - validator, err := stakingtypes.NewValidator(valAddr, priv.PubKey(), stakingtypes.Description{}) - require.NoError(t, err) - err = suite.app.StakingKeeper.SetValidatorByConsAddr(suite.ctx, validator) - require.NoError(t, err) - err = suite.app.StakingKeeper.SetValidatorByConsAddr(suite.ctx, validator) - require.NoError(t, err) - suite.app.StakingKeeper.SetValidator(suite.ctx, validator) - - encodingConfig := encoding.MakeConfig(app.ModuleBasics) - suite.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig) - suite.ethSigner = ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) - suite.appCodec = encodingConfig.Codec - suite.denom = evmtypes.DefaultEVMDenom -} - -func (suite *KeeperTestSuite) EvmDenom() string { - ctx := sdk.WrapSDKContext(suite.ctx) - rsp, _ := suite.queryClient.Params(ctx, &types.QueryParamsRequest{}) - return rsp.Params.EvmDenom -} - -// Commit and begin new block -func (suite *KeeperTestSuite) Commit() { - _ = suite.app.Commit() - header := suite.ctx.BlockHeader() - header.Height += 1 - suite.app.BeginBlock(abci.RequestBeginBlock{ - Header: header, - }) - - // update ctx - suite.ctx = suite.app.BaseApp.NewContext(false, header) - - queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, suite.app.EvmKeeper) - suite.queryClient = types.NewQueryClient(queryHelper) -} - -func (suite *KeeperTestSuite) StateDB() vm.StateDB { - return statedb.New( - suite.ctx, - suite.app.EvmKeeper, - types.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes())), - ) -} - -// DeployTestContract deploy a test erc20 contract and returns the contract address -func (suite *KeeperTestSuite) DeployTestContract(t require.TestingT, owner common.Address, supply *big.Int) common.Address { - ctx := sdk.WrapSDKContext(suite.ctx) - chainID := suite.app.EvmKeeper.ChainID() - - ctorArgs, err := types.ERC20Contract.ABI.Pack("", owner, supply) - require.NoError(t, err) - - nonce := suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address) - - data := append(types.ERC20Contract.Bin, ctorArgs...) - args, err := json.Marshal(&types.TransactionArgs{ - From: &suite.address, - Data: (*hexutil.Bytes)(&data), - }) - require.NoError(t, err) - res, err := suite.queryClient.EstimateGas(ctx, &types.EthCallRequest{ - Args: args, - GasCap: uint64(config.DefaultGasCap), - ProposerAddress: suite.ctx.BlockHeader().ProposerAddress, - }) - require.NoError(t, err) - - var erc20DeployTx *types.MsgEthereumTx - if suite.enableFeemarket { - erc20DeployTx = types.NewTxContract( - chainID, - nonce, - nil, // amount - res.Gas, // gasLimit - nil, // gasPrice - suite.app.FeeMarketKeeper.GetBaseFee(suite.ctx), - big.NewInt(1), - data, // input - ðtypes.AccessList{}, // accesses - ) - } else { - erc20DeployTx = types.NewTxContract( - chainID, - nonce, - nil, // amount - res.Gas, // gasLimit - nil, // gasPrice - nil, nil, - data, // input - nil, // accesses - ) - } - - erc20DeployTx.From = suite.address.Hex() - err = erc20DeployTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.signer) - require.NoError(t, err) - rsp, err := suite.app.EvmKeeper.EthereumTx(ctx, erc20DeployTx) - require.NoError(t, err) - require.Empty(t, rsp.VmError) - return crypto.CreateAddress(suite.address, nonce) -} - -func (suite *KeeperTestSuite) TransferERC20Token(t require.TestingT, contractAddr, from, to common.Address, amount *big.Int) *types.MsgEthereumTx { - ctx := sdk.WrapSDKContext(suite.ctx) - chainID := suite.app.EvmKeeper.ChainID() - - transferData, err := types.ERC20Contract.ABI.Pack("transfer", to, amount) - require.NoError(t, err) - args, err := json.Marshal(&types.TransactionArgs{To: &contractAddr, From: &from, Data: (*hexutil.Bytes)(&transferData)}) - require.NoError(t, err) - res, err := suite.queryClient.EstimateGas(ctx, &types.EthCallRequest{ - Args: args, - GasCap: 25_000_000, - ProposerAddress: suite.ctx.BlockHeader().ProposerAddress, - }) - require.NoError(t, err) - - nonce := suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address) - - var ercTransferTx *types.MsgEthereumTx - if suite.enableFeemarket { - ercTransferTx = types.NewTx( - chainID, - nonce, - &contractAddr, - nil, - res.Gas, - nil, - suite.app.FeeMarketKeeper.GetBaseFee(suite.ctx), - big.NewInt(1), - transferData, - ðtypes.AccessList{}, // accesses - ) - } else { - ercTransferTx = types.NewTx( - chainID, - nonce, - &contractAddr, - nil, - res.Gas, - nil, - nil, nil, - transferData, - nil, - ) - } - - ercTransferTx.From = suite.address.Hex() - err = ercTransferTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.signer) - require.NoError(t, err) - rsp, err := suite.app.EvmKeeper.EthereumTx(ctx, ercTransferTx) - require.NoError(t, err) - require.Empty(t, rsp.VmError) - return ercTransferTx -} - -// DeployTestMessageCall deploy a test erc20 contract and returns the contract address -func (suite *KeeperTestSuite) DeployTestMessageCall(t require.TestingT) common.Address { - ctx := sdk.WrapSDKContext(suite.ctx) - chainID := suite.app.EvmKeeper.ChainID() - - data := types.TestMessageCall.Bin - args, err := json.Marshal(&types.TransactionArgs{ - From: &suite.address, - Data: (*hexutil.Bytes)(&data), - }) - require.NoError(t, err) - - res, err := suite.queryClient.EstimateGas(ctx, &types.EthCallRequest{ - Args: args, - GasCap: uint64(config.DefaultGasCap), - ProposerAddress: suite.ctx.BlockHeader().ProposerAddress, - }) - require.NoError(t, err) - - nonce := suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address) - - var erc20DeployTx *types.MsgEthereumTx - if suite.enableFeemarket { - erc20DeployTx = types.NewTxContract( - chainID, - nonce, - nil, // amount - res.Gas, // gasLimit - nil, // gasPrice - suite.app.FeeMarketKeeper.GetBaseFee(suite.ctx), - big.NewInt(1), - data, // input - ðtypes.AccessList{}, // accesses - ) - } else { - erc20DeployTx = types.NewTxContract( - chainID, - nonce, - nil, // amount - res.Gas, // gasLimit - nil, // gasPrice - nil, nil, - data, // input - nil, // accesses - ) - } - - erc20DeployTx.From = suite.address.Hex() - err = erc20DeployTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.signer) - require.NoError(t, err) - rsp, err := suite.app.EvmKeeper.EthereumTx(ctx, erc20DeployTx) - require.NoError(t, err) - require.Empty(t, rsp.VmError) - return crypto.CreateAddress(suite.address, nonce) -} - func (suite *KeeperTestSuite) TestBaseFee() { testCases := []struct { name string @@ -444,18 +60,18 @@ func (suite *KeeperTestSuite) TestBaseFee() { for _, tc := range testCases { suite.Run(tc.name, func() { - suite.enableFeemarket = tc.enableFeemarket - suite.enableLondonHF = tc.enableLondonHF + suite.EnableFeemarket = tc.enableFeemarket + suite.EnableLondonHF = tc.enableLondonHF suite.SetupTest() - suite.app.EvmKeeper.BeginBlock(suite.ctx, abci.RequestBeginBlock{}) - params := suite.app.EvmKeeper.GetParams(suite.ctx) - ethCfg := params.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID()) - baseFee := suite.app.EvmKeeper.GetBaseFee(suite.ctx, ethCfg) + suite.App.EvmKeeper.BeginBlock(suite.Ctx, abci.RequestBeginBlock{}) + params := suite.App.EvmKeeper.GetParams(suite.Ctx) + ethCfg := params.ChainConfig.EthereumConfig(suite.App.EvmKeeper.ChainID()) + baseFee := suite.App.EvmKeeper.GetBaseFee(suite.Ctx, ethCfg) suite.Require().Equal(tc.expectBaseFee, baseFee) }) } - suite.enableFeemarket = false - suite.enableLondonHF = true + suite.EnableFeemarket = false + suite.EnableLondonHF = true } func (suite *KeeperTestSuite) TestGetAccountStorage() { @@ -473,7 +89,7 @@ func (suite *KeeperTestSuite) TestGetAccountStorage() { "Two accounts - one contract (with storage), one wallet", func() { supply := big.NewInt(100) - suite.DeployTestContract(suite.T(), suite.address, supply) + suite.DeployTestContract(suite.T(), suite.Address, supply) }, []int{2, 0}, }, @@ -484,7 +100,7 @@ func (suite *KeeperTestSuite) TestGetAccountStorage() { suite.SetupTest() tc.malleate() i := 0 - suite.app.AccountKeeper.IterateAccounts(suite.ctx, func(account authtypes.AccountI) bool { + suite.App.AccountKeeper.IterateAccounts(suite.Ctx, func(account authtypes.AccountI) bool { ethAccount, ok := account.(ethermint.EthAccountI) if !ok { // ignore non EthAccounts @@ -492,7 +108,7 @@ func (suite *KeeperTestSuite) TestGetAccountStorage() { } addr := ethAccount.EthAddress() - storage := suite.app.EvmKeeper.GetAccountStorage(suite.ctx, addr) + storage := suite.App.EvmKeeper.GetAccountStorage(suite.Ctx, addr) suite.Require().Equal(tc.expRes[i], len(storage)) i++ @@ -509,7 +125,7 @@ func (suite *KeeperTestSuite) TestGetAccountOrEmpty() { } supply := big.NewInt(100) - contractAddr := suite.DeployTestContract(suite.T(), suite.address, supply) + contractAddr := suite.DeployTestContract(suite.T(), suite.Address, supply) testCases := []struct { name string @@ -530,7 +146,7 @@ func (suite *KeeperTestSuite) TestGetAccountOrEmpty() { for _, tc := range testCases { suite.Run(tc.name, func() { - res := suite.app.EvmKeeper.GetAccountOrEmpty(suite.ctx, tc.addr) + res := suite.App.EvmKeeper.GetAccountOrEmpty(suite.Ctx, tc.addr) if tc.expEmpty { suite.Require().Equal(empty, res) } else { diff --git a/x/evm/keeper/msg_server_test.go b/x/evm/keeper/msg_server_test.go index 39e4ae5383..bf71af77df 100644 --- a/x/evm/keeper/msg_server_test.go +++ b/x/evm/keeper/msg_server_test.go @@ -31,7 +31,7 @@ func (suite *KeeperTestSuite) TestEthereumTx() { "Deploy contract tx - insufficient gas", func() { msg, err = suite.createContractMsgTx( - vmdb.GetNonce(suite.address), + vmdb.GetNonce(suite.Address), signer, chainCfg, big.NewInt(1), @@ -44,11 +44,11 @@ func (suite *KeeperTestSuite) TestEthereumTx() { "Transfer funds tx", func() { msg, _, err = newEthMsgTx( - vmdb.GetNonce(suite.address), - suite.ctx.BlockHeight(), - suite.address, + vmdb.GetNonce(suite.Address), + suite.Ctx.BlockHeight(), + suite.Address, chainCfg, - suite.signer, + suite.Signer, signer, ethtypes.AccessListTxType, nil, @@ -64,13 +64,13 @@ func (suite *KeeperTestSuite) TestEthereumTx() { for _, tc := range testCases { suite.Run(tc.name, func() { suite.SetupTest() - keeperParams := suite.app.EvmKeeper.GetParams(suite.ctx) - chainCfg = keeperParams.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID()) - signer = ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) + keeperParams := suite.App.EvmKeeper.GetParams(suite.Ctx) + chainCfg = keeperParams.ChainConfig.EthereumConfig(suite.App.EvmKeeper.ChainID()) + signer = ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) vmdb = suite.StateDB() tc.malleate() - res, err := suite.app.EvmKeeper.EthereumTx(suite.ctx, msg) + res, err := suite.App.EvmKeeper.EthereumTx(suite.Ctx, msg) if tc.expErr { suite.Require().Error(err) return @@ -106,7 +106,7 @@ func (suite *KeeperTestSuite) TestUpdateParams() { for _, tc := range testCases { tc := tc suite.Run("MsgUpdateParams", func() { - _, err := suite.app.EvmKeeper.UpdateParams(suite.ctx, tc.request) + _, err := suite.App.EvmKeeper.UpdateParams(suite.Ctx, tc.request) if tc.expectErr { suite.Require().Error(err) } else { diff --git a/x/evm/keeper/params_benchmark_test.go b/x/evm/keeper/params_benchmark_test.go index b42529e482..8100eb9669 100644 --- a/x/evm/keeper/params_benchmark_test.go +++ b/x/evm/keeper/params_benchmark_test.go @@ -14,7 +14,7 @@ func BenchmarkSetParams(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - _ = suite.app.EvmKeeper.SetParams(suite.ctx, params) + _ = suite.App.EvmKeeper.SetParams(suite.Ctx, params) } } @@ -25,6 +25,6 @@ func BenchmarkGetParams(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - _ = suite.app.EvmKeeper.GetParams(suite.ctx) + _ = suite.App.EvmKeeper.GetParams(suite.Ctx) } } diff --git a/x/evm/keeper/params_test.go b/x/evm/keeper/params_test.go index 56b7e7b9b0..9c110e4c03 100644 --- a/x/evm/keeper/params_test.go +++ b/x/evm/keeper/params_test.go @@ -19,8 +19,8 @@ import ( ) func (suite *KeeperTestSuite) TestParams() { - params := suite.app.EvmKeeper.GetParams(suite.ctx) - suite.app.EvmKeeper.SetParams(suite.ctx, params) + params := suite.App.EvmKeeper.GetParams(suite.Ctx) + suite.App.EvmKeeper.SetParams(suite.Ctx, params) testCases := []struct { name string paramsFun func() interface{} @@ -33,7 +33,7 @@ func (suite *KeeperTestSuite) TestParams() { return types.DefaultParams() }, func() interface{} { - return suite.app.EvmKeeper.GetParams(suite.ctx) + return suite.App.EvmKeeper.GetParams(suite.Ctx) }, true, }, @@ -41,11 +41,11 @@ func (suite *KeeperTestSuite) TestParams() { "success - EvmDenom param is set to \"inj\" and can be retrieved correctly", func() interface{} { params.EvmDenom = "inj" - suite.app.EvmKeeper.SetParams(suite.ctx, params) + suite.App.EvmKeeper.SetParams(suite.Ctx, params) return params.EvmDenom }, func() interface{} { - evmParams := suite.app.EvmKeeper.GetParams(suite.ctx) + evmParams := suite.App.EvmKeeper.GetParams(suite.Ctx) return evmParams.GetEvmDenom() }, true, @@ -54,11 +54,11 @@ func (suite *KeeperTestSuite) TestParams() { "success - Check EnableCreate param is set to false and can be retrieved correctly", func() interface{} { params.EnableCreate = false - suite.app.EvmKeeper.SetParams(suite.ctx, params) + suite.App.EvmKeeper.SetParams(suite.Ctx, params) return params.EnableCreate }, func() interface{} { - evmParams := suite.app.EvmKeeper.GetParams(suite.ctx) + evmParams := suite.App.EvmKeeper.GetParams(suite.Ctx) return evmParams.GetEnableCreate() }, true, @@ -67,11 +67,11 @@ func (suite *KeeperTestSuite) TestParams() { "success - Check EnableCall param is set to false and can be retrieved correctly", func() interface{} { params.EnableCall = false - suite.app.EvmKeeper.SetParams(suite.ctx, params) + suite.App.EvmKeeper.SetParams(suite.Ctx, params) return params.EnableCall }, func() interface{} { - evmParams := suite.app.EvmKeeper.GetParams(suite.ctx) + evmParams := suite.App.EvmKeeper.GetParams(suite.Ctx) return evmParams.GetEnableCall() }, true, @@ -80,11 +80,11 @@ func (suite *KeeperTestSuite) TestParams() { "success - Check AllowUnprotectedTxs param is set to false and can be retrieved correctly", func() interface{} { params.AllowUnprotectedTxs = false - suite.app.EvmKeeper.SetParams(suite.ctx, params) + suite.App.EvmKeeper.SetParams(suite.Ctx, params) return params.AllowUnprotectedTxs }, func() interface{} { - evmParams := suite.app.EvmKeeper.GetParams(suite.ctx) + evmParams := suite.App.EvmKeeper.GetParams(suite.Ctx) return evmParams.GetAllowUnprotectedTxs() }, true, @@ -93,11 +93,11 @@ func (suite *KeeperTestSuite) TestParams() { "success - Check ChainConfig param is set to the default value and can be retrieved correctly", func() interface{} { params.ChainConfig = types.DefaultChainConfig() - suite.app.EvmKeeper.SetParams(suite.ctx, params) + suite.App.EvmKeeper.SetParams(suite.Ctx, params) return params.ChainConfig }, func() interface{} { - evmParams := suite.app.EvmKeeper.GetParams(suite.ctx) + evmParams := suite.App.EvmKeeper.GetParams(suite.Ctx) return evmParams.GetChainConfig() }, true, @@ -119,7 +119,7 @@ func (suite *KeeperTestSuite) TestLegacyParamsKeyTableRegistration() { paramStoreKey := sdk.NewKVStoreKey(paramtypes.ModuleName) paramStoreTKey := sdk.NewTransientStoreKey(paramtypes.TStoreKey) ctx := legacytestutil.NewDBContext([]storetypes.StoreKey{storeKey, paramStoreKey}, []storetypes.StoreKey{tKey, paramStoreTKey}) - ak := suite.app.AccountKeeper + ak := suite.App.AccountKeeper // paramspace used only for setting legacy parameters (not given to keeper) setParamSpace := paramtypes.NewSubspace( @@ -180,7 +180,7 @@ func (suite *KeeperTestSuite) TestRenamedFieldReturnsProperValueForLegacyParams( paramStoreKey := sdk.NewKVStoreKey(paramtypes.ModuleName) paramStoreTKey := sdk.NewTransientStoreKey(paramtypes.TStoreKey) ctx := legacytestutil.NewDBContext([]storetypes.StoreKey{storeKey, paramStoreKey}, []storetypes.StoreKey{tKey, paramStoreTKey}) - ak := suite.app.AccountKeeper + ak := suite.App.AccountKeeper // paramspace used only for setting legacy parameters (not given to keeper) legacyParamstore := paramtypes.NewSubspace( @@ -229,7 +229,7 @@ func (suite *KeeperTestSuite) TestNilLegacyParamsDoNotPanic() { paramStoreKey := sdk.NewKVStoreKey(paramtypes.ModuleName) paramStoreTKey := sdk.NewTransientStoreKey(paramtypes.TStoreKey) ctx := legacytestutil.NewDBContext([]storetypes.StoreKey{storeKey, paramStoreKey}, []storetypes.StoreKey{tKey, paramStoreTKey}) - ak := suite.app.AccountKeeper + ak := suite.App.AccountKeeper subspace := paramtypes.NewSubspace( cdc, diff --git a/x/evm/keeper/state_transition_benchmark_test.go b/x/evm/keeper/state_transition_benchmark_test.go index 77df3af9ef..5b6a22dd58 100644 --- a/x/evm/keeper/state_transition_benchmark_test.go +++ b/x/evm/keeper/state_transition_benchmark_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + "github.com/evmos/ethermint/x/evm/testutil" evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/stretchr/testify/require" ) @@ -156,25 +157,29 @@ func newNativeMessage( } func BenchmarkApplyTransaction(b *testing.B) { - suite := KeeperTestSuite{enableLondonHF: true} + suite := KeeperTestSuite{ + KeeperTestSuite: testutil.KeeperTestSuite{ + EnableLondonHF: true, + }, + } suite.SetupTestWithT(b) - ethSigner := ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) + ethSigner := ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { b.StopTimer() tx, err := newSignedEthTx(templateAccessListTx, - suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address), - sdk.AccAddress(suite.address.Bytes()), - suite.signer, + suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address), + sdk.AccAddress(suite.Address.Bytes()), + suite.Signer, ethSigner, ) require.NoError(b, err) b.StartTimer() - resp, err := suite.app.EvmKeeper.ApplyTransaction(suite.ctx, tx) + resp, err := suite.App.EvmKeeper.ApplyTransaction(suite.Ctx, tx) b.StopTimer() require.NoError(b, err) @@ -183,25 +188,29 @@ func BenchmarkApplyTransaction(b *testing.B) { } func BenchmarkApplyTransactionWithLegacyTx(b *testing.B) { - suite := KeeperTestSuite{enableLondonHF: true} + suite := KeeperTestSuite{ + KeeperTestSuite: testutil.KeeperTestSuite{ + EnableLondonHF: true, + }, + } suite.SetupTestWithT(b) - ethSigner := ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) + ethSigner := ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { b.StopTimer() tx, err := newSignedEthTx(templateLegacyTx, - suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address), - sdk.AccAddress(suite.address.Bytes()), - suite.signer, + suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address), + sdk.AccAddress(suite.Address.Bytes()), + suite.Signer, ethSigner, ) require.NoError(b, err) b.StartTimer() - resp, err := suite.app.EvmKeeper.ApplyTransaction(suite.ctx, tx) + resp, err := suite.App.EvmKeeper.ApplyTransaction(suite.Ctx, tx) b.StopTimer() require.NoError(b, err) @@ -210,25 +219,30 @@ func BenchmarkApplyTransactionWithLegacyTx(b *testing.B) { } func BenchmarkApplyTransactionWithDynamicFeeTx(b *testing.B) { - suite := KeeperTestSuite{enableFeemarket: true, enableLondonHF: true} + suite := KeeperTestSuite{ + KeeperTestSuite: testutil.KeeperTestSuite{ + EnableFeemarket: true, + EnableLondonHF: true, + }, + } suite.SetupTestWithT(b) - ethSigner := ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) + ethSigner := ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { b.StopTimer() tx, err := newSignedEthTx(templateDynamicFeeTx, - suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address), - sdk.AccAddress(suite.address.Bytes()), - suite.signer, + suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address), + sdk.AccAddress(suite.Address.Bytes()), + suite.Signer, ethSigner, ) require.NoError(b, err) b.StartTimer() - resp, err := suite.app.EvmKeeper.ApplyTransaction(suite.ctx, tx) + resp, err := suite.App.EvmKeeper.ApplyTransaction(suite.Ctx, tx) b.StopTimer() require.NoError(b, err) @@ -237,12 +251,16 @@ func BenchmarkApplyTransactionWithDynamicFeeTx(b *testing.B) { } func BenchmarkApplyMessage(b *testing.B) { - suite := KeeperTestSuite{enableLondonHF: true} + suite := KeeperTestSuite{ + KeeperTestSuite: testutil.KeeperTestSuite{ + EnableLondonHF: true, + }, + } suite.SetupTestWithT(b) - params := suite.app.EvmKeeper.GetParams(suite.ctx) - ethCfg := params.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID()) - signer := ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) + params := suite.App.EvmKeeper.GetParams(suite.Ctx) + ethCfg := params.ChainConfig.EthereumConfig(suite.App.EvmKeeper.ChainID()) + signer := ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) b.ResetTimer() b.ReportAllocs() @@ -250,11 +268,11 @@ func BenchmarkApplyMessage(b *testing.B) { b.StopTimer() m, err := newNativeMessage( - suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address), - suite.ctx.BlockHeight(), - suite.address, + suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address), + suite.Ctx.BlockHeight(), + suite.Address, ethCfg, - suite.signer, + suite.Signer, signer, ethtypes.AccessListTxType, nil, @@ -263,7 +281,7 @@ func BenchmarkApplyMessage(b *testing.B) { require.NoError(b, err) b.StartTimer() - resp, err := suite.app.EvmKeeper.ApplyMessage(suite.ctx, m, nil, true) + resp, err := suite.App.EvmKeeper.ApplyMessage(suite.Ctx, m, nil, true) b.StopTimer() require.NoError(b, err) @@ -272,12 +290,16 @@ func BenchmarkApplyMessage(b *testing.B) { } func BenchmarkApplyMessageWithLegacyTx(b *testing.B) { - suite := KeeperTestSuite{enableLondonHF: true} + suite := KeeperTestSuite{ + KeeperTestSuite: testutil.KeeperTestSuite{ + EnableLondonHF: true, + }, + } suite.SetupTestWithT(b) - params := suite.app.EvmKeeper.GetParams(suite.ctx) - ethCfg := params.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID()) - signer := ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) + params := suite.App.EvmKeeper.GetParams(suite.Ctx) + ethCfg := params.ChainConfig.EthereumConfig(suite.App.EvmKeeper.ChainID()) + signer := ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) b.ResetTimer() b.ReportAllocs() @@ -285,11 +307,11 @@ func BenchmarkApplyMessageWithLegacyTx(b *testing.B) { b.StopTimer() m, err := newNativeMessage( - suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address), - suite.ctx.BlockHeight(), - suite.address, + suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address), + suite.Ctx.BlockHeight(), + suite.Address, ethCfg, - suite.signer, + suite.Signer, signer, ethtypes.LegacyTxType, nil, @@ -298,7 +320,7 @@ func BenchmarkApplyMessageWithLegacyTx(b *testing.B) { require.NoError(b, err) b.StartTimer() - resp, err := suite.app.EvmKeeper.ApplyMessage(suite.ctx, m, nil, true) + resp, err := suite.App.EvmKeeper.ApplyMessage(suite.Ctx, m, nil, true) b.StopTimer() require.NoError(b, err) @@ -307,12 +329,17 @@ func BenchmarkApplyMessageWithLegacyTx(b *testing.B) { } func BenchmarkApplyMessageWithDynamicFeeTx(b *testing.B) { - suite := KeeperTestSuite{enableFeemarket: true, enableLondonHF: true} + suite := KeeperTestSuite{ + KeeperTestSuite: testutil.KeeperTestSuite{ + EnableFeemarket: true, + EnableLondonHF: true, + }, + } suite.SetupTestWithT(b) - params := suite.app.EvmKeeper.GetParams(suite.ctx) - ethCfg := params.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID()) - signer := ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) + params := suite.App.EvmKeeper.GetParams(suite.Ctx) + ethCfg := params.ChainConfig.EthereumConfig(suite.App.EvmKeeper.ChainID()) + signer := ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) b.ResetTimer() b.ReportAllocs() @@ -320,11 +347,11 @@ func BenchmarkApplyMessageWithDynamicFeeTx(b *testing.B) { b.StopTimer() m, err := newNativeMessage( - suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address), - suite.ctx.BlockHeight(), - suite.address, + suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address), + suite.Ctx.BlockHeight(), + suite.Address, ethCfg, - suite.signer, + suite.Signer, signer, ethtypes.DynamicFeeTxType, nil, @@ -333,7 +360,7 @@ func BenchmarkApplyMessageWithDynamicFeeTx(b *testing.B) { require.NoError(b, err) b.StartTimer() - resp, err := suite.app.EvmKeeper.ApplyMessage(suite.ctx, m, nil, true) + resp, err := suite.App.EvmKeeper.ApplyMessage(suite.Ctx, m, nil, true) b.StopTimer() require.NoError(b, err) diff --git a/x/evm/keeper/state_transition_test.go b/x/evm/keeper/state_transition_test.go index f1fba5f00c..9fd2a707d1 100644 --- a/x/evm/keeper/state_transition_test.go +++ b/x/evm/keeper/state_transition_test.go @@ -23,7 +23,7 @@ import ( ) func (suite *KeeperTestSuite) TestGetHashFn() { - header := suite.ctx.BlockHeader() + header := suite.Ctx.BlockHeader() h, _ := tmtypes.HeaderFromProto(&header) hash := h.Hash() @@ -35,27 +35,27 @@ func (suite *KeeperTestSuite) TestGetHashFn() { }{ { "case 1.1: context hash cached", - uint64(suite.ctx.BlockHeight()), + uint64(suite.Ctx.BlockHeight()), func() { - suite.ctx = suite.ctx.WithHeaderHash(tmhash.Sum([]byte("header"))) + suite.Ctx = suite.Ctx.WithHeaderHash(tmhash.Sum([]byte("header"))) }, common.BytesToHash(tmhash.Sum([]byte("header"))), }, { "case 1.2: failed to cast Tendermint header", - uint64(suite.ctx.BlockHeight()), + uint64(suite.Ctx.BlockHeight()), func() { header := tmproto.Header{} - header.Height = suite.ctx.BlockHeight() - suite.ctx = suite.ctx.WithBlockHeader(header) + header.Height = suite.Ctx.BlockHeight() + suite.Ctx = suite.Ctx.WithBlockHeader(header) }, common.Hash{}, }, { "case 1.3: hash calculated from Tendermint header", - uint64(suite.ctx.BlockHeight()), + uint64(suite.Ctx.BlockHeight()), func() { - suite.ctx = suite.ctx.WithBlockHeader(header) + suite.Ctx = suite.Ctx.WithBlockHeader(header) }, common.BytesToHash(hash), }, @@ -63,7 +63,7 @@ func (suite *KeeperTestSuite) TestGetHashFn() { "case 2.1: height lower than current one, hist info not found", 1, func() { - suite.ctx = suite.ctx.WithBlockHeight(10) + suite.Ctx = suite.Ctx.WithBlockHeight(10) }, common.Hash{}, }, @@ -71,8 +71,8 @@ func (suite *KeeperTestSuite) TestGetHashFn() { "case 2.2: height lower than current one, invalid hist info header", 1, func() { - suite.app.StakingKeeper.SetHistoricalInfo(suite.ctx, 1, &stakingtypes.HistoricalInfo{}) - suite.ctx = suite.ctx.WithBlockHeight(10) + suite.App.StakingKeeper.SetHistoricalInfo(suite.Ctx, 1, &stakingtypes.HistoricalInfo{}) + suite.Ctx = suite.Ctx.WithBlockHeight(10) }, common.Hash{}, }, @@ -83,8 +83,8 @@ func (suite *KeeperTestSuite) TestGetHashFn() { histInfo := &stakingtypes.HistoricalInfo{ Header: header, } - suite.app.StakingKeeper.SetHistoricalInfo(suite.ctx, 1, histInfo) - suite.ctx = suite.ctx.WithBlockHeight(10) + suite.App.StakingKeeper.SetHistoricalInfo(suite.Ctx, 1, histInfo) + suite.Ctx = suite.Ctx.WithBlockHeight(10) }, common.BytesToHash(hash), }, @@ -102,7 +102,7 @@ func (suite *KeeperTestSuite) TestGetHashFn() { tc.malleate() - hash := suite.app.EvmKeeper.GetHashFn(suite.ctx)(tc.height) + hash := suite.App.EvmKeeper.GetHashFn(suite.Ctx)(tc.height) suite.Require().Equal(tc.expHash, hash) }) } @@ -119,9 +119,9 @@ func (suite *KeeperTestSuite) TestGetCoinbaseAddress() { { "validator not found", func() { - header := suite.ctx.BlockHeader() + header := suite.Ctx.BlockHeader() header.ProposerAddress = []byte{} - suite.ctx = suite.ctx.WithBlockHeader(header) + suite.Ctx = suite.Ctx.WithBlockHeader(header) }, false, }, @@ -138,18 +138,18 @@ func (suite *KeeperTestSuite) TestGetCoinbaseAddress() { ConsensusPubkey: pkAny, } - suite.app.StakingKeeper.SetValidator(suite.ctx, validator) - err = suite.app.StakingKeeper.SetValidatorByConsAddr(suite.ctx, validator) + suite.App.StakingKeeper.SetValidator(suite.Ctx, validator) + err = suite.App.StakingKeeper.SetValidatorByConsAddr(suite.Ctx, validator) suite.Require().NoError(err) - header := suite.ctx.BlockHeader() + header := suite.Ctx.BlockHeader() header.ProposerAddress = valConsAddr.Bytes() - suite.ctx = suite.ctx.WithBlockHeader(header) + suite.Ctx = suite.Ctx.WithBlockHeader(header) - _, found := suite.app.StakingKeeper.GetValidatorByConsAddr(suite.ctx, valConsAddr.Bytes()) + _, found := suite.App.StakingKeeper.GetValidatorByConsAddr(suite.Ctx, valConsAddr.Bytes()) suite.Require().True(found) - suite.Require().NotEmpty(suite.ctx.BlockHeader().ProposerAddress) + suite.Require().NotEmpty(suite.Ctx.BlockHeader().ProposerAddress) }, true, }, @@ -160,8 +160,8 @@ func (suite *KeeperTestSuite) TestGetCoinbaseAddress() { suite.SetupTest() // reset tc.malleate() - proposerAddress := suite.ctx.BlockHeader().ProposerAddress - coinbase, err := suite.app.EvmKeeper.GetCoinbaseAddress(suite.ctx, sdk.ConsAddress(proposerAddress)) + proposerAddress := suite.Ctx.BlockHeader().ProposerAddress + coinbase, err := suite.App.EvmKeeper.GetCoinbaseAddress(suite.Ctx, sdk.ConsAddress(proposerAddress)) if tc.expPass { suite.Require().NoError(err) suite.Require().Equal(valOpAddr, coinbase) @@ -255,21 +255,21 @@ func (suite *KeeperTestSuite) TestGetEthIntrinsicGas() { suite.Run(fmt.Sprintf("Case %s", tc.name), func() { suite.SetupTest() // reset - params := suite.app.EvmKeeper.GetParams(suite.ctx) - ethCfg := params.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID()) + params := suite.App.EvmKeeper.GetParams(suite.Ctx) + ethCfg := params.ChainConfig.EthereumConfig(suite.App.EvmKeeper.ChainID()) ethCfg.HomesteadBlock = big.NewInt(2) ethCfg.IstanbulBlock = big.NewInt(3) - signer := ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) + signer := ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) - suite.ctx = suite.ctx.WithBlockHeight(tc.height) + suite.Ctx = suite.Ctx.WithBlockHeight(tc.height) - nonce := suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address) + nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) m, err := newNativeMessage( nonce, - suite.ctx.BlockHeight(), - suite.address, + suite.Ctx.BlockHeight(), + suite.Address, ethCfg, - suite.signer, + suite.Signer, signer, ethtypes.AccessListTxType, tc.data, @@ -277,7 +277,7 @@ func (suite *KeeperTestSuite) TestGetEthIntrinsicGas() { ) suite.Require().NoError(err) - gas, err := suite.app.EvmKeeper.GetEthIntrinsicGas(suite.ctx, m, ethCfg, tc.isContractCreation) + gas, err := suite.App.EvmKeeper.GetEthIntrinsicGas(suite.Ctx, m, ethCfg, tc.isContractCreation) if tc.noError { suite.Require().NoError(err) } else { @@ -329,7 +329,7 @@ func (suite *KeeperTestSuite) TestGasToRefund() { for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.name), func() { - suite.mintFeeCollector = true + suite.MintFeeCollector = true suite.SetupTest() // reset vmdb := suite.StateDB() vmdb.AddRefund(10) @@ -345,7 +345,7 @@ func (suite *KeeperTestSuite) TestGasToRefund() { } }) } - suite.mintFeeCollector = false + suite.MintFeeCollector = false } func (suite *KeeperTestSuite) TestRefundGas() { @@ -397,11 +397,11 @@ func (suite *KeeperTestSuite) TestRefundGas() { noError: false, expGasRefund: params.TxGas, malleate: func() { - keeperParams := suite.app.EvmKeeper.GetParams(suite.ctx) + keeperParams := suite.App.EvmKeeper.GetParams(suite.Ctx) m, err = suite.createContractGethMsg( - suite.StateDB().GetNonce(suite.address), - ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()), - keeperParams.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID()), + suite.StateDB().GetNonce(suite.Address), + ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()), + keeperParams.ChainConfig.EthereumConfig(suite.App.EvmKeeper.ChainID()), big.NewInt(-100), ) suite.Require().NoError(err) @@ -411,20 +411,20 @@ func (suite *KeeperTestSuite) TestRefundGas() { for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.name), func() { - suite.mintFeeCollector = true + suite.MintFeeCollector = true suite.SetupTest() // reset - keeperParams := suite.app.EvmKeeper.GetParams(suite.ctx) - ethCfg := keeperParams.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID()) - signer := ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) + keeperParams := suite.App.EvmKeeper.GetParams(suite.Ctx) + ethCfg := keeperParams.ChainConfig.EthereumConfig(suite.App.EvmKeeper.ChainID()) + signer := ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) vmdb := suite.StateDB() m, err = newNativeMessage( - vmdb.GetNonce(suite.address), - suite.ctx.BlockHeight(), - suite.address, + vmdb.GetNonce(suite.Address), + suite.Ctx.BlockHeight(), + suite.Address, ethCfg, - suite.signer, + suite.Signer, signer, ethtypes.AccessListTxType, nil, @@ -446,7 +446,7 @@ func (suite *KeeperTestSuite) TestRefundGas() { refund := keeper.GasToRefund(vmdb.GetRefund(), gasUsed, tc.refundQuotient) suite.Require().Equal(tc.expGasRefund, refund) - err = suite.app.EvmKeeper.RefundGas(suite.ctx, m, refund, "aphoton") + err = suite.App.EvmKeeper.RefundGas(suite.Ctx, m, refund, "aphoton") if tc.noError { suite.Require().NoError(err) } else { @@ -454,7 +454,7 @@ func (suite *KeeperTestSuite) TestRefundGas() { } }) } - suite.mintFeeCollector = false + suite.MintFeeCollector = false } func (suite *KeeperTestSuite) TestResetGasMeterAndConsumeGas() { @@ -503,8 +503,8 @@ func (suite *KeeperTestSuite) TestResetGasMeterAndConsumeGas() { panicF := func() { gm := sdk.NewGasMeter(10) gm.ConsumeGas(tc.gasConsumed, "") - ctx := suite.ctx.WithGasMeter(gm) - suite.app.EvmKeeper.ResetGasMeterAndConsumeGas(ctx, tc.gasUsed) + ctx := suite.Ctx.WithGasMeter(gm) + suite.App.EvmKeeper.ResetGasMeterAndConsumeGas(ctx, tc.gasUsed) } if tc.expPanic { @@ -517,18 +517,18 @@ func (suite *KeeperTestSuite) TestResetGasMeterAndConsumeGas() { } func (suite *KeeperTestSuite) TestEVMConfig() { - proposerAddress := suite.ctx.BlockHeader().ProposerAddress - cfg, err := suite.app.EvmKeeper.EVMConfig(suite.ctx, proposerAddress, big.NewInt(9000)) + proposerAddress := suite.Ctx.BlockHeader().ProposerAddress + cfg, err := suite.App.EvmKeeper.EVMConfig(suite.Ctx, proposerAddress, big.NewInt(9000)) suite.Require().NoError(err) suite.Require().Equal(types.DefaultParams(), cfg.Params) // london hardfork is enabled by default suite.Require().Equal(big.NewInt(0), cfg.BaseFee) - suite.Require().Equal(suite.address, cfg.CoinBase) + suite.Require().Equal(suite.Address, cfg.CoinBase) suite.Require().Equal(types.DefaultParams().ChainConfig.EthereumConfig(big.NewInt(9000)), cfg.ChainConfig) } func (suite *KeeperTestSuite) TestContractDeployment() { - contractAddress := suite.DeployTestContract(suite.T(), suite.address, big.NewInt(10000000000000)) + contractAddress := suite.DeployTestContract(suite.T(), suite.Address, big.NewInt(10000000000000)) db := suite.StateDB() suite.Require().Greater(db.GetCodeSize(contractAddress), 0) } @@ -537,22 +537,22 @@ func (suite *KeeperTestSuite) TestApplyMessage() { expectedGasUsed := params.TxGas var msg core.Message - proposerAddress := suite.ctx.BlockHeader().ProposerAddress - config, err := suite.app.EvmKeeper.EVMConfig(suite.ctx, proposerAddress, big.NewInt(9000)) + proposerAddress := suite.Ctx.BlockHeader().ProposerAddress + config, err := suite.App.EvmKeeper.EVMConfig(suite.Ctx, proposerAddress, big.NewInt(9000)) suite.Require().NoError(err) - keeperParams := suite.app.EvmKeeper.GetParams(suite.ctx) - chainCfg := keeperParams.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID()) - signer := ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) - tracer := suite.app.EvmKeeper.Tracer(suite.ctx, msg, config.ChainConfig) + keeperParams := suite.App.EvmKeeper.GetParams(suite.Ctx) + chainCfg := keeperParams.ChainConfig.EthereumConfig(suite.App.EvmKeeper.ChainID()) + signer := ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) + tracer := suite.App.EvmKeeper.Tracer(suite.Ctx, msg, config.ChainConfig) vmdb := suite.StateDB() msg, err = newNativeMessage( - vmdb.GetNonce(suite.address), - suite.ctx.BlockHeight(), - suite.address, + vmdb.GetNonce(suite.Address), + suite.Ctx.BlockHeight(), + suite.Address, chainCfg, - suite.signer, + suite.Signer, signer, ethtypes.AccessListTxType, nil, @@ -560,7 +560,7 @@ func (suite *KeeperTestSuite) TestApplyMessage() { ) suite.Require().NoError(err) - res, err := suite.app.EvmKeeper.ApplyMessage(suite.ctx, msg, tracer, true) + res, err := suite.App.EvmKeeper.ApplyMessage(suite.Ctx, msg, tracer, true) suite.Require().NoError(err) suite.Require().Equal(expectedGasUsed, res.GasUsed) @@ -589,11 +589,11 @@ func (suite *KeeperTestSuite) TestApplyMessageWithConfig() { "messsage applied ok", func() { msg, err = newNativeMessage( - vmdb.GetNonce(suite.address), - suite.ctx.BlockHeight(), - suite.address, + vmdb.GetNonce(suite.Address), + suite.Ctx.BlockHeight(), + suite.Address, chainCfg, - suite.signer, + suite.Signer, signer, ethtypes.AccessListTxType, nil, @@ -608,11 +608,11 @@ func (suite *KeeperTestSuite) TestApplyMessageWithConfig() { func() { config.Params.EnableCall = false msg, err = newNativeMessage( - vmdb.GetNonce(suite.address), - suite.ctx.BlockHeight(), - suite.address, + vmdb.GetNonce(suite.Address), + suite.Ctx.BlockHeight(), + suite.Address, chainCfg, - suite.signer, + suite.Signer, signer, ethtypes.AccessListTxType, nil, @@ -625,7 +625,7 @@ func (suite *KeeperTestSuite) TestApplyMessageWithConfig() { { "create contract tx with config param EnableCreate = false", func() { - msg, err = suite.createContractGethMsg(vmdb.GetNonce(suite.address), signer, chainCfg, big.NewInt(1)) + msg, err = suite.createContractGethMsg(vmdb.GetNonce(suite.Address), signer, chainCfg, big.NewInt(1)) suite.Require().NoError(err) config.Params.EnableCreate = false }, @@ -638,18 +638,18 @@ func (suite *KeeperTestSuite) TestApplyMessageWithConfig() { suite.SetupTest() expectedGasUsed = params.TxGas - proposerAddress := suite.ctx.BlockHeader().ProposerAddress - config, err = suite.app.EvmKeeper.EVMConfig(suite.ctx, proposerAddress, big.NewInt(9000)) + proposerAddress := suite.Ctx.BlockHeader().ProposerAddress + config, err = suite.App.EvmKeeper.EVMConfig(suite.Ctx, proposerAddress, big.NewInt(9000)) suite.Require().NoError(err) - keeperParams = suite.app.EvmKeeper.GetParams(suite.ctx) - chainCfg = keeperParams.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID()) - signer = ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) + keeperParams = suite.App.EvmKeeper.GetParams(suite.Ctx) + chainCfg = keeperParams.ChainConfig.EthereumConfig(suite.App.EvmKeeper.ChainID()) + signer = ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) vmdb = suite.StateDB() - txConfig = suite.app.EvmKeeper.TxConfig(suite.ctx, common.Hash{}) + txConfig = suite.App.EvmKeeper.TxConfig(suite.Ctx, common.Hash{}) tc.malleate() - res, err := suite.app.EvmKeeper.ApplyMessageWithConfig(suite.ctx, msg, nil, true, config, txConfig) + res, err := suite.App.EvmKeeper.ApplyMessageWithConfig(suite.Ctx, msg, nil, true, config, txConfig) if tc.expErr { suite.Require().Error(err) @@ -669,7 +669,7 @@ func (suite *KeeperTestSuite) createContractGethMsg(nonce uint64, signer ethtype return nil, err } - msgSigner := ethtypes.MakeSigner(cfg, big.NewInt(suite.ctx.BlockHeight())) + msgSigner := ethtypes.MakeSigner(cfg, big.NewInt(suite.Ctx.BlockHeight())) return ethMsg.AsMessage(msgSigner, nil) } @@ -684,15 +684,15 @@ func (suite *KeeperTestSuite) createContractMsgTx(nonce uint64, signer ethtypes. ethTx := ethtypes.NewTx(contractCreateTx) ethMsg := &types.MsgEthereumTx{} ethMsg.FromEthereumTx(ethTx) - ethMsg.From = suite.address.Hex() + ethMsg.From = suite.Address.Hex() - return ethMsg, ethMsg.Sign(signer, suite.signer) + return ethMsg, ethMsg.Sign(signer, suite.Signer) } func (suite *KeeperTestSuite) TestGetProposerAddress() { var a sdk.ConsAddress - address := sdk.ConsAddress(suite.address.Bytes()) - proposerAddress := sdk.ConsAddress(suite.ctx.BlockHeader().ProposerAddress) + address := sdk.ConsAddress(suite.Address.Bytes()) + proposerAddress := sdk.ConsAddress(suite.Ctx.BlockHeader().ProposerAddress) testCases := []struct { msg string adr sdk.ConsAddress @@ -716,7 +716,7 @@ func (suite *KeeperTestSuite) TestGetProposerAddress() { } for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.Require().Equal(tc.expAdr, keeper.GetProposerAddress(suite.ctx, tc.adr)) + suite.Require().Equal(tc.expAdr, keeper.GetProposerAddress(suite.Ctx, tc.adr)) }) } } diff --git a/x/evm/keeper/statedb_benchmark_test.go b/x/evm/keeper/statedb_benchmark_test.go index fd9cba03dd..962e3411fd 100644 --- a/x/evm/keeper/statedb_benchmark_test.go +++ b/x/evm/keeper/statedb_benchmark_test.go @@ -38,7 +38,7 @@ func BenchmarkCreateAccountExisting(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - vmdb.CreateAccount(suite.address) + vmdb.CreateAccount(suite.Address) } } @@ -53,7 +53,7 @@ func BenchmarkAddBalance(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - vmdb.AddBalance(suite.address, amt) + vmdb.AddBalance(suite.Address, amt) } } @@ -68,7 +68,7 @@ func BenchmarkSetCode(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - vmdb.SetCode(suite.address, hash) + vmdb.SetCode(suite.Address, hash) } } @@ -83,7 +83,7 @@ func BenchmarkSetState(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - vmdb.SetCode(suite.address, hash) + vmdb.SetCode(suite.Address, hash) } } @@ -101,7 +101,7 @@ func BenchmarkAddLog(b *testing.B) { for i := 0; i < b.N; i++ { vmdb.AddLog(ðtypes.Log{ - Address: suite.address, + Address: suite.Address, Topics: []common.Hash{topic}, Data: []byte("data"), BlockNumber: 1, @@ -142,13 +142,13 @@ func BenchmarkSubBalance(b *testing.B) { amt := big.NewInt(10) // Add enough balance to cover all subtractions - vmdb.AddBalance(suite.address, new(big.Int).Mul(amt, big.NewInt(int64(b.N)))) + vmdb.AddBalance(suite.Address, new(big.Int).Mul(amt, big.NewInt(int64(b.N)))) b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { - vmdb.SubBalance(suite.address, amt) + vmdb.SubBalance(suite.Address, amt) } } @@ -161,7 +161,7 @@ func BenchmarkSetNonce(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - vmdb.SetNonce(suite.address, 1) + vmdb.SetNonce(suite.Address, 1) } } diff --git a/x/evm/keeper/statedb_test.go b/x/evm/keeper/statedb_test.go index 1374e553de..a014566fc2 100644 --- a/x/evm/keeper/statedb_test.go +++ b/x/evm/keeper/statedb_test.go @@ -34,7 +34,7 @@ func (suite *KeeperTestSuite) TestCreateAccount() { }{ { "reset account (keep balance)", - suite.address, + suite.Address, func(vmdb vm.StateDB, addr common.Address) { vmdb.AddBalance(addr, big.NewInt(100)) suite.Require().NotZero(vmdb.GetBalance(addr).Int64()) @@ -93,9 +93,9 @@ func (suite *KeeperTestSuite) TestAddBalance() { for _, tc := range testCases { suite.Run(tc.name, func() { vmdb := suite.StateDB() - prev := vmdb.GetBalance(suite.address) - vmdb.AddBalance(suite.address, tc.amount) - post := vmdb.GetBalance(suite.address) + prev := vmdb.GetBalance(suite.Address) + vmdb.AddBalance(suite.Address, tc.amount) + post := vmdb.GetBalance(suite.Address) if tc.isNoOp { suite.Require().Equal(prev.Int64(), post.Int64()) @@ -123,7 +123,7 @@ func (suite *KeeperTestSuite) TestSubBalance() { "positive amount, above zero", big.NewInt(50), func(vmdb vm.StateDB) { - vmdb.AddBalance(suite.address, big.NewInt(100)) + vmdb.AddBalance(suite.Address, big.NewInt(100)) }, false, }, @@ -146,9 +146,9 @@ func (suite *KeeperTestSuite) TestSubBalance() { vmdb := suite.StateDB() tc.malleate(vmdb) - prev := vmdb.GetBalance(suite.address) - vmdb.SubBalance(suite.address, tc.amount) - post := vmdb.GetBalance(suite.address) + prev := vmdb.GetBalance(suite.Address) + vmdb.SubBalance(suite.Address, tc.amount) + post := vmdb.GetBalance(suite.Address) if tc.isNoOp { suite.Require().Equal(prev.Int64(), post.Int64()) @@ -174,10 +174,10 @@ func (suite *KeeperTestSuite) TestGetNonce() { }, { "existing account", - suite.address, + suite.Address, 1, func(vmdb vm.StateDB) { - vmdb.SetNonce(suite.address, 1) + vmdb.SetNonce(suite.Address, 1) }, }, } @@ -208,7 +208,7 @@ func (suite *KeeperTestSuite) TestSetNonce() { }, { "existing account", - suite.address, + suite.Address, 99, func() {}, }, @@ -291,17 +291,17 @@ func (suite *KeeperTestSuite) TestSetAccount() { for _, tc := range testCases { suite.Run(tc.name, func() { if tc.address == baseAddr { - suite.app.AccountKeeper.SetAccount(suite.ctx, baseAcc) + suite.App.AccountKeeper.SetAccount(suite.Ctx, baseAcc) } if tc.address == ethAddr { - suite.app.AccountKeeper.SetAccount(suite.ctx, ethAcc) + suite.App.AccountKeeper.SetAccount(suite.Ctx, ethAcc) } if tc.address == vestingAddr { - suite.app.AccountKeeper.SetAccount(suite.ctx, vestingAcc) + suite.App.AccountKeeper.SetAccount(suite.Ctx, vestingAcc) } vmdb := suite.StateDB() - err := vmdb.Keeper().SetAccount(suite.ctx, tc.address, tc.account) + err := vmdb.Keeper().SetAccount(suite.Ctx, tc.address, tc.account) if tc.expectedErr == nil { suite.Require().NoError(err) @@ -325,7 +325,7 @@ func (suite *KeeperTestSuite) TestSetAccount() { func (suite *KeeperTestSuite) TestGetCodeHash() { addr := tests.GenerateAddress() baseAcc := &authtypes.BaseAccount{Address: sdk.AccAddress(addr.Bytes()).String()} - suite.app.AccountKeeper.SetAccount(suite.ctx, baseAcc) + suite.App.AccountKeeper.SetAccount(suite.Ctx, baseAcc) testCases := []struct { name string @@ -347,10 +347,10 @@ func (suite *KeeperTestSuite) TestGetCodeHash() { }, { "existing account", - suite.address, + suite.Address, crypto.Keccak256Hash([]byte("codeHash")), func(vmdb vm.StateDB) { - vmdb.SetCode(suite.address, []byte("codeHash")) + vmdb.SetCode(suite.Address, []byte("codeHash")) }, }, } @@ -369,7 +369,7 @@ func (suite *KeeperTestSuite) TestGetCodeHash() { func (suite *KeeperTestSuite) TestSetCode() { addr := tests.GenerateAddress() baseAcc := &authtypes.BaseAccount{Address: sdk.AccAddress(addr.Bytes()).String()} - suite.app.AccountKeeper.SetAccount(suite.ctx, baseAcc) + suite.App.AccountKeeper.SetAccount(suite.Ctx, baseAcc) testCases := []struct { name string @@ -391,13 +391,13 @@ func (suite *KeeperTestSuite) TestSetCode() { }, { "existing account", - suite.address, + suite.Address, []byte("code"), false, }, { "existing account, code deleted from store", - suite.address, + suite.Address, nil, false, }, @@ -424,7 +424,7 @@ func (suite *KeeperTestSuite) TestSetCode() { func (suite *KeeperTestSuite) TestKeeperSetCode() { addr := tests.GenerateAddress() baseAcc := &authtypes.BaseAccount{Address: sdk.AccAddress(addr.Bytes()).String()} - suite.app.AccountKeeper.SetAccount(suite.ctx, baseAcc) + suite.App.AccountKeeper.SetAccount(suite.Ctx, baseAcc) testCases := []struct { name string @@ -445,9 +445,9 @@ func (suite *KeeperTestSuite) TestKeeperSetCode() { for _, tc := range testCases { suite.Run(tc.name, func() { - suite.app.EvmKeeper.SetCode(suite.ctx, tc.codeHash, tc.code) - key := suite.app.GetKey(types.StoreKey) - store := prefix.NewStore(suite.ctx.KVStore(key), types.KeyPrefixCode) + suite.App.EvmKeeper.SetCode(suite.Ctx, tc.codeHash, tc.code) + key := suite.App.GetKey(types.StoreKey) + store := prefix.NewStore(suite.Ctx.KVStore(key), types.KeyPrefixCode) code := store.Get(tc.codeHash) suite.Require().Equal(tc.code, code) @@ -514,8 +514,8 @@ func (suite *KeeperTestSuite) TestState() { for _, tc := range testCases { suite.Run(tc.name, func() { vmdb := suite.StateDB() - vmdb.SetState(suite.address, tc.key, tc.value) - value := vmdb.GetState(suite.address, tc.key) + vmdb.SetState(suite.Address, tc.key, tc.value) + value := vmdb.GetState(suite.Address, tc.key) suite.Require().Equal(tc.value, value) }) } @@ -527,19 +527,19 @@ func (suite *KeeperTestSuite) TestCommittedState() { value2 := common.BytesToHash([]byte("value2")) vmdb := suite.StateDB() - vmdb.SetState(suite.address, key, value1) + vmdb.SetState(suite.Address, key, value1) vmdb.Commit() vmdb = suite.StateDB() - vmdb.SetState(suite.address, key, value2) - tmp := vmdb.GetState(suite.address, key) + vmdb.SetState(suite.Address, key, value2) + tmp := vmdb.GetState(suite.Address, key) suite.Require().Equal(value2, tmp) - tmp = vmdb.GetCommittedState(suite.address, key) + tmp = vmdb.GetCommittedState(suite.Address, key) suite.Require().Equal(value1, tmp) vmdb.Commit() vmdb = suite.StateDB() - tmp = vmdb.GetCommittedState(suite.address, key) + tmp = vmdb.GetCommittedState(suite.Address, key) suite.Require().Equal(value2, tmp) } @@ -547,11 +547,11 @@ func (suite *KeeperTestSuite) TestSuicide() { code := []byte("code") db := suite.StateDB() // Add code to account - db.SetCode(suite.address, code) - suite.Require().Equal(code, db.GetCode(suite.address)) + db.SetCode(suite.Address, code) + suite.Require().Equal(code, db.GetCode(suite.Address)) // Add state to account for i := 0; i < 5; i++ { - db.SetState(suite.address, common.BytesToHash([]byte(fmt.Sprintf("key%d", i))), common.BytesToHash([]byte(fmt.Sprintf("value%d", i)))) + db.SetState(suite.Address, common.BytesToHash([]byte(fmt.Sprintf("key%d", i))), common.BytesToHash([]byte(fmt.Sprintf("value%d", i)))) } suite.Require().NoError(db.Commit()) @@ -571,27 +571,27 @@ func (suite *KeeperTestSuite) TestSuicide() { } // Call Suicide - suite.Require().Equal(true, db.Suicide(suite.address)) + suite.Require().Equal(true, db.Suicide(suite.Address)) // Check suicided is marked - suite.Require().Equal(true, db.HasSuicided(suite.address)) + suite.Require().Equal(true, db.HasSuicided(suite.Address)) // Commit state suite.Require().NoError(db.Commit()) db = suite.StateDB() // Check code is deleted - suite.Require().Nil(db.GetCode(suite.address)) + suite.Require().Nil(db.GetCode(suite.Address)) // Check state is deleted var storage types.Storage - suite.app.EvmKeeper.ForEachStorage(suite.ctx, suite.address, func(key, value common.Hash) bool { + suite.App.EvmKeeper.ForEachStorage(suite.Ctx, suite.Address, func(key, value common.Hash) bool { storage = append(storage, types.NewState(key, value)) return true }) suite.Require().Equal(0, len(storage)) // Check account is deleted - suite.Require().Equal(common.Hash{}, db.GetCodeHash(suite.address)) + suite.Require().Equal(common.Hash{}, db.GetCodeHash(suite.Address)) // Check code is still present in addr2 and suicided is false suite.Require().NotNil(db.GetCode(addr2)) @@ -605,9 +605,9 @@ func (suite *KeeperTestSuite) TestExist() { malleate func(vm.StateDB) exists bool }{ - {"success, account exists", suite.address, func(vm.StateDB) {}, true}, - {"success, has suicided", suite.address, func(vmdb vm.StateDB) { - vmdb.Suicide(suite.address) + {"success, account exists", suite.Address, func(vm.StateDB) {}, true}, + {"success, has suicided", suite.Address, func(vmdb vm.StateDB) { + vmdb.Suicide(suite.Address) }, true}, {"success, account doesn't exist", tests.GenerateAddress(), func(vm.StateDB) {}, false}, } @@ -629,11 +629,11 @@ func (suite *KeeperTestSuite) TestEmpty() { malleate func(vm.StateDB) empty bool }{ - {"empty, account exists", suite.address, func(vm.StateDB) {}, true}, + {"empty, account exists", suite.Address, func(vm.StateDB) {}, true}, { "not empty, positive balance", - suite.address, - func(vmdb vm.StateDB) { vmdb.AddBalance(suite.address, big.NewInt(100)) }, + suite.Address, + func(vmdb vm.StateDB) { vmdb.AddBalance(suite.Address, big.NewInt(100)) }, false, }, {"empty, account doesn't exist", tests.GenerateAddress(), func(vm.StateDB) {}, true}, @@ -663,38 +663,38 @@ func (suite *KeeperTestSuite) TestSnapshot() { revision := vmdb.Snapshot() suite.Require().Zero(revision) - vmdb.SetState(suite.address, key, value1) - suite.Require().Equal(value1, vmdb.GetState(suite.address, key)) + vmdb.SetState(suite.Address, key, value1) + suite.Require().Equal(value1, vmdb.GetState(suite.Address, key)) vmdb.RevertToSnapshot(revision) // reverted - suite.Require().Equal(common.Hash{}, vmdb.GetState(suite.address, key)) + suite.Require().Equal(common.Hash{}, vmdb.GetState(suite.Address, key)) }}, {"nested snapshot/revert", func(vmdb vm.StateDB) { revision1 := vmdb.Snapshot() suite.Require().Zero(revision1) - vmdb.SetState(suite.address, key, value1) + vmdb.SetState(suite.Address, key, value1) revision2 := vmdb.Snapshot() - vmdb.SetState(suite.address, key, value2) - suite.Require().Equal(value2, vmdb.GetState(suite.address, key)) + vmdb.SetState(suite.Address, key, value2) + suite.Require().Equal(value2, vmdb.GetState(suite.Address, key)) vmdb.RevertToSnapshot(revision2) - suite.Require().Equal(value1, vmdb.GetState(suite.address, key)) + suite.Require().Equal(value1, vmdb.GetState(suite.Address, key)) vmdb.RevertToSnapshot(revision1) - suite.Require().Equal(common.Hash{}, vmdb.GetState(suite.address, key)) + suite.Require().Equal(common.Hash{}, vmdb.GetState(suite.Address, key)) }}, {"jump revert", func(vmdb vm.StateDB) { revision1 := vmdb.Snapshot() - vmdb.SetState(suite.address, key, value1) + vmdb.SetState(suite.Address, key, value1) vmdb.Snapshot() - vmdb.SetState(suite.address, key, value2) + vmdb.SetState(suite.Address, key, value2) vmdb.RevertToSnapshot(revision1) - suite.Require().Equal(common.Hash{}, vmdb.GetState(suite.address, key)) + suite.Require().Equal(common.Hash{}, vmdb.GetState(suite.Address, key)) }}, } @@ -711,13 +711,13 @@ func (suite *KeeperTestSuite) CreateTestTx(msg *types.MsgEthereumTx, priv crypto option, err := codectypes.NewAnyWithValue(&types.ExtensionOptionsEthereumTx{}) suite.Require().NoError(err) - txBuilder := suite.clientCtx.TxConfig.NewTxBuilder() + txBuilder := suite.ClientCtx.TxConfig.NewTxBuilder() builder, ok := txBuilder.(authtx.ExtensionOptionsTxBuilder) suite.Require().True(ok) builder.SetExtensionOptions(option) - err = msg.Sign(suite.ethSigner, tests.NewSigner(priv)) + err = msg.Sign(suite.EthSigner, tests.NewSigner(priv)) suite.Require().NoError(err) err = txBuilder.SetMsgs(msg) @@ -728,27 +728,27 @@ func (suite *KeeperTestSuite) CreateTestTx(msg *types.MsgEthereumTx, priv crypto func (suite *KeeperTestSuite) TestAddLog() { addr, privKey := tests.NewAddrKey() - msg := types.NewTx(big.NewInt(1), 0, &suite.address, big.NewInt(1), 100000, big.NewInt(1), nil, nil, []byte("test"), nil) + msg := types.NewTx(big.NewInt(1), 0, &suite.Address, big.NewInt(1), 100000, big.NewInt(1), nil, nil, []byte("test"), nil) msg.From = addr.Hex() tx := suite.CreateTestTx(msg, privKey) msg, _ = tx.GetMsgs()[0].(*types.MsgEthereumTx) txHash := msg.AsTransaction().Hash() - msg2 := types.NewTx(big.NewInt(1), 1, &suite.address, big.NewInt(1), 100000, big.NewInt(1), nil, nil, []byte("test"), nil) + msg2 := types.NewTx(big.NewInt(1), 1, &suite.Address, big.NewInt(1), 100000, big.NewInt(1), nil, nil, []byte("test"), nil) msg2.From = addr.Hex() tx2 := suite.CreateTestTx(msg2, privKey) msg2, _ = tx2.GetMsgs()[0].(*types.MsgEthereumTx) - msg3 := types.NewTx(big.NewInt(1), 0, &suite.address, big.NewInt(1), 100000, nil, big.NewInt(1), big.NewInt(1), []byte("test"), nil) + msg3 := types.NewTx(big.NewInt(1), 0, &suite.Address, big.NewInt(1), 100000, nil, big.NewInt(1), big.NewInt(1), []byte("test"), nil) msg3.From = addr.Hex() tx3 := suite.CreateTestTx(msg3, privKey) msg3, _ = tx3.GetMsgs()[0].(*types.MsgEthereumTx) txHash3 := msg3.AsTransaction().Hash() - msg4 := types.NewTx(big.NewInt(1), 1, &suite.address, big.NewInt(1), 100000, nil, big.NewInt(1), big.NewInt(1), []byte("test"), nil) + msg4 := types.NewTx(big.NewInt(1), 1, &suite.Address, big.NewInt(1), 100000, nil, big.NewInt(1), big.NewInt(1), []byte("test"), nil) msg4.From = addr.Hex() tx4 := suite.CreateTestTx(msg4, privKey) @@ -793,8 +793,8 @@ func (suite *KeeperTestSuite) TestAddLog() { for _, tc := range testCases { suite.Run(tc.name, func() { suite.SetupTest() - vmdb := statedb.New(suite.ctx, suite.app.EvmKeeper, types.NewTxConfig( - common.BytesToHash(suite.ctx.HeaderHash().Bytes()), + vmdb := statedb.New(suite.Ctx, suite.App.EvmKeeper, types.NewTxConfig( + common.BytesToHash(suite.Ctx.HeaderHash().Bytes()), tc.hash, 0, 0, )) @@ -817,9 +817,9 @@ func (suite *KeeperTestSuite) TestPrepareAccessList() { } vmdb := suite.StateDB() - vmdb.PrepareAccessList(suite.address, &dest, precompiles, accesses) + vmdb.PrepareAccessList(suite.Address, &dest, precompiles, accesses) - suite.Require().True(vmdb.AddressInAccessList(suite.address)) + suite.Require().True(vmdb.AddressInAccessList(suite.Address)) suite.Require().True(vmdb.AddressInAccessList(dest)) for _, precompile := range precompiles { @@ -840,8 +840,8 @@ func (suite *KeeperTestSuite) TestAddAddressToAccessList() { name string addr common.Address }{ - {"new address", suite.address}, - {"existing address", suite.address}, + {"new address", suite.Address}, + {"existing address", suite.Address}, } for _, tc := range testCases { @@ -861,9 +861,9 @@ func (suite *KeeperTestSuite) AddSlotToAccessList() { slot common.Hash }{ {"new address and slot (1)", tests.GenerateAddress(), common.BytesToHash([]byte("hash"))}, - {"new address and slot (2)", suite.address, common.Hash{}}, - {"existing address and slot", suite.address, common.Hash{}}, - {"existing address, new slot", suite.address, common.BytesToHash([]byte("hash"))}, + {"new address and slot (2)", suite.Address, common.Hash{}}, + {"existing address and slot", suite.Address, common.Hash{}}, + {"existing address, new slot", suite.Address, common.BytesToHash([]byte("hash"))}, } for _, tc := range testCases { @@ -891,7 +891,7 @@ func (suite *KeeperTestSuite) _TestForEachStorage() { "aggregate state", func(vmdb vm.StateDB) { for i := 0; i < 5; i++ { - vmdb.SetState(suite.address, common.BytesToHash([]byte(fmt.Sprintf("key%d", i))), common.BytesToHash([]byte(fmt.Sprintf("value%d", i)))) + vmdb.SetState(suite.Address, common.BytesToHash([]byte(fmt.Sprintf("key%d", i))), common.BytesToHash([]byte(fmt.Sprintf("value%d", i)))) } }, func(key, value common.Hash) bool { @@ -909,8 +909,8 @@ func (suite *KeeperTestSuite) _TestForEachStorage() { { "filter state", func(vmdb vm.StateDB) { - vmdb.SetState(suite.address, common.BytesToHash([]byte("key")), common.BytesToHash([]byte("value"))) - vmdb.SetState(suite.address, common.BytesToHash([]byte("filterkey")), common.BytesToHash([]byte("filtervalue"))) + vmdb.SetState(suite.Address, common.BytesToHash([]byte("key")), common.BytesToHash([]byte("value"))) + vmdb.SetState(suite.Address, common.BytesToHash([]byte("filterkey")), common.BytesToHash([]byte("filtervalue"))) }, func(key, value common.Hash) bool { if value == common.BytesToHash([]byte("filtervalue")) { @@ -931,7 +931,7 @@ func (suite *KeeperTestSuite) _TestForEachStorage() { vmdb := suite.StateDB() tc.malleate(vmdb) - err := vmdb.ForEachStorage(suite.address, tc.callback) + err := vmdb.ForEachStorage(suite.Address, tc.callback) suite.Require().NoError(err) suite.Require().Equal(len(tc.expValues), len(storage), fmt.Sprintf("Expected values:\n%v\nStorage Values\n%v", tc.expValues, storage)) @@ -958,13 +958,13 @@ func (suite *KeeperTestSuite) TestSetBalance() { }{ { "address without funds - invalid amount", - suite.address, + suite.Address, func() {}, true, }, { "mint to address", - suite.address, + suite.Address, func() { amount = big.NewInt(100) }, @@ -972,7 +972,7 @@ func (suite *KeeperTestSuite) TestSetBalance() { }, { "burn from address", - suite.address, + suite.Address, func() { amount = big.NewInt(60) }, @@ -980,7 +980,7 @@ func (suite *KeeperTestSuite) TestSetBalance() { }, { "address with funds - invalid amount", - suite.address, + suite.Address, func() { amount = big.NewInt(-10) }, @@ -992,11 +992,11 @@ func (suite *KeeperTestSuite) TestSetBalance() { suite.Run(tc.name, func() { suite.SetupTest() tc.malleate() - err := suite.app.EvmKeeper.SetBalance(suite.ctx, tc.addr, amount) + err := suite.App.EvmKeeper.SetBalance(suite.Ctx, tc.addr, amount) if tc.expErr { suite.Require().Error(err) } else { - balance := suite.app.EvmKeeper.GetBalance(suite.ctx, tc.addr) + balance := suite.App.EvmKeeper.GetBalance(suite.Ctx, tc.addr) suite.Require().NoError(err) suite.Require().Equal(amount, balance) } @@ -1006,7 +1006,7 @@ func (suite *KeeperTestSuite) TestSetBalance() { func (suite *KeeperTestSuite) TestDeleteAccount() { supply := big.NewInt(100) - contractAddr := suite.DeployTestContract(suite.T(), suite.address, supply) + contractAddr := suite.DeployTestContract(suite.T(), suite.Address, supply) testCases := []struct { name string @@ -1015,7 +1015,7 @@ func (suite *KeeperTestSuite) TestDeleteAccount() { }{ { "remove address", - suite.address, + suite.Address, false, }, { @@ -1033,12 +1033,12 @@ func (suite *KeeperTestSuite) TestDeleteAccount() { for _, tc := range testCases { suite.Run(tc.name, func() { suite.SetupTest() - err := suite.app.EvmKeeper.DeleteAccount(suite.ctx, tc.addr) + err := suite.App.EvmKeeper.DeleteAccount(suite.Ctx, tc.addr) if tc.expErr { suite.Require().Error(err) } else { suite.Require().NoError(err) - balance := suite.app.EvmKeeper.GetBalance(suite.ctx, tc.addr) + balance := suite.App.EvmKeeper.GetBalance(suite.Ctx, tc.addr) suite.Require().Equal(new(big.Int), balance) } }) diff --git a/x/evm/keeper/utils_test.go b/x/evm/keeper/utils_test.go index f14e119f29..39d8a5c562 100644 --- a/x/evm/keeper/utils_test.go +++ b/x/evm/keeper/utils_test.go @@ -35,168 +35,168 @@ func (suite *KeeperTestSuite) TestCheckSenderBalance() { }{ { name: "Enough balance", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 10, gasPrice: &oneInt, cost: &oneInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: true, }, { name: "Equal balance", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 99, gasPrice: &oneInt, cost: &oneInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: true, }, { name: "negative cost", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 1, gasPrice: &oneInt, cost: &negInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: false, }, { name: "Higher gas limit, not enough balance", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 100, gasPrice: &oneInt, cost: &oneInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: false, }, { name: "Higher gas price, enough balance", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 10, gasPrice: &fiveInt, cost: &oneInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: true, }, { name: "Higher gas price, not enough balance", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 20, gasPrice: &fiveInt, cost: &oneInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: false, }, { name: "Higher cost, enough balance", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 10, gasPrice: &fiveInt, cost: &fiftyInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: true, }, { name: "Higher cost, not enough balance", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 10, gasPrice: &fiveInt, cost: &hundredInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: false, }, { name: "Enough balance w/ enableFeemarket", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 10, gasFeeCap: big.NewInt(1), cost: &oneInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: true, enableFeemarket: true, }, { name: "Equal balance w/ enableFeemarket", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 99, gasFeeCap: big.NewInt(1), cost: &oneInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: true, enableFeemarket: true, }, { name: "negative cost w/ enableFeemarket", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 1, gasFeeCap: big.NewInt(1), cost: &negInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: false, enableFeemarket: true, }, { name: "Higher gas limit, not enough balance w/ enableFeemarket", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 100, gasFeeCap: big.NewInt(1), cost: &oneInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: false, enableFeemarket: true, }, { name: "Higher gas price, enough balance w/ enableFeemarket", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 10, gasFeeCap: big.NewInt(5), cost: &oneInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: true, enableFeemarket: true, }, { name: "Higher gas price, not enough balance w/ enableFeemarket", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 20, gasFeeCap: big.NewInt(5), cost: &oneInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: false, enableFeemarket: true, }, { name: "Higher cost, enough balance w/ enableFeemarket", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 10, gasFeeCap: big.NewInt(5), cost: &fiftyInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: true, enableFeemarket: true, }, { name: "Higher cost, not enough balance w/ enableFeemarket", - to: suite.address.String(), + to: suite.Address.String(), gasLimit: 10, gasFeeCap: big.NewInt(5), cost: &hundredInt, - from: suite.address.String(), + from: suite.Address.String(), accessList: ðtypes.AccessList{}, expectPass: false, enableFeemarket: true, @@ -204,8 +204,8 @@ func (suite *KeeperTestSuite) TestCheckSenderBalance() { } vmdb := suite.StateDB() - vmdb.AddBalance(suite.address, hundredInt.BigInt()) - balance := vmdb.GetBalance(suite.address) + vmdb.AddBalance(suite.Address, hundredInt.BigInt()) + balance := vmdb.GetBalance(suite.Address) suite.Require().Equal(balance, hundredInt.BigInt()) err := vmdb.Commit() suite.Require().NoError(err, "Unexpected error while committing to vmdb: %d", err) @@ -237,7 +237,7 @@ func (suite *KeeperTestSuite) TestCheckSenderBalance() { txData, _ := evmtypes.UnpackTxData(tx.Data) - acct := suite.app.EvmKeeper.GetAccountOrEmpty(suite.ctx, suite.address) + acct := suite.App.EvmKeeper.GetAccountOrEmpty(suite.Ctx, suite.Address) err := keeper.CheckSenderBalance( sdkmath.NewIntFromBigInt(acct.Balance), txData, @@ -290,7 +290,7 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { accessList: ðtypes.AccessList{}, expectPassVerify: true, expectPassDeduct: true, - from: suite.address.String(), + from: suite.Address.String(), }, { name: "Equal balance", @@ -300,7 +300,7 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { accessList: ðtypes.AccessList{}, expectPassVerify: true, expectPassDeduct: true, - from: suite.address.String(), + from: suite.Address.String(), }, { name: "Higher gas limit, not enough balance", @@ -310,7 +310,7 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { accessList: ðtypes.AccessList{}, expectPassVerify: true, expectPassDeduct: false, - from: suite.address.String(), + from: suite.Address.String(), }, { name: "Higher gas price, enough balance", @@ -320,7 +320,7 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { accessList: ðtypes.AccessList{}, expectPassVerify: true, expectPassDeduct: true, - from: suite.address.String(), + from: suite.Address.String(), }, { name: "Higher gas price, not enough balance", @@ -330,7 +330,7 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { accessList: ðtypes.AccessList{}, expectPassVerify: true, expectPassDeduct: false, - from: suite.address.String(), + from: suite.Address.String(), }, // This case is expected to be true because the fees can be deducted, but the tx // execution is going to fail because there is no more balance to pay the cost @@ -342,7 +342,7 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { accessList: ðtypes.AccessList{}, expectPassVerify: true, expectPassDeduct: true, - from: suite.address.String(), + from: suite.Address.String(), }, // testcases with enableFeemarket enabled. { @@ -355,7 +355,7 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { expectPassVerify: false, expectPassDeduct: true, enableFeemarket: true, - from: suite.address.String(), + from: suite.Address.String(), }, { name: "empty tip fee is valid to deduct", @@ -367,7 +367,7 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { expectPassVerify: true, expectPassDeduct: true, enableFeemarket: true, - from: suite.address.String(), + from: suite.Address.String(), }, { name: "effectiveTip equal to gasTipCap", @@ -378,7 +378,7 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { expectPassVerify: true, expectPassDeduct: true, enableFeemarket: true, - from: suite.address.String(), + from: suite.Address.String(), }, { name: "effectiveTip equal to (gasFeeCap - baseFee)", @@ -390,7 +390,7 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { expectPassVerify: true, expectPassDeduct: true, enableFeemarket: true, - from: suite.address.String(), + from: suite.Address.String(), }, { name: "Invalid from address", @@ -409,13 +409,13 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { cost: &oneInt, accessList: ðtypes.AccessList{ ethtypes.AccessTuple{ - Address: suite.address, + Address: suite.Address, StorageKeys: []common.Hash{}, }, }, expectPassVerify: true, expectPassDeduct: true, - from: suite.address.String(), + from: suite.Address.String(), }, { name: "gasLimit < intrinsicGas during IsCheckTx", @@ -425,16 +425,16 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { accessList: ðtypes.AccessList{}, expectPassVerify: false, expectPassDeduct: true, - from: suite.address.String(), + from: suite.Address.String(), malleate: func() { - suite.ctx = suite.ctx.WithIsCheckTx(true) + suite.Ctx = suite.Ctx.WithIsCheckTx(true) }, }, } for i, tc := range testCases { suite.Run(tc.name, func() { - suite.enableFeemarket = tc.enableFeemarket + suite.EnableFeemarket = tc.enableFeemarket suite.SetupTest() vmdb := suite.StateDB() @@ -446,7 +446,7 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { amount = tc.cost.BigInt() } - if suite.enableFeemarket { + if suite.EnableFeemarket { if tc.gasFeeCap != nil { gasFeeCap = tc.gasFeeCap } @@ -455,36 +455,36 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { } else { gasTipCap = tc.gasTipCap } - vmdb.AddBalance(suite.address, initBalance.BigInt()) - balance := vmdb.GetBalance(suite.address) + vmdb.AddBalance(suite.Address, initBalance.BigInt()) + balance := vmdb.GetBalance(suite.Address) suite.Require().Equal(balance, initBalance.BigInt()) } else { if tc.gasPrice != nil { gasPrice = tc.gasPrice.BigInt() } - vmdb.AddBalance(suite.address, hundredInt.BigInt()) - balance := vmdb.GetBalance(suite.address) + vmdb.AddBalance(suite.Address, hundredInt.BigInt()) + balance := vmdb.GetBalance(suite.Address) suite.Require().Equal(balance, hundredInt.BigInt()) } err := vmdb.Commit() suite.Require().NoError(err, "Unexpected error while committing to vmdb: %d", err) - tx := evmtypes.NewTx(zeroInt.BigInt(), 1, &suite.address, amount, tc.gasLimit, gasPrice, gasFeeCap, gasTipCap, nil, tc.accessList) + tx := evmtypes.NewTx(zeroInt.BigInt(), 1, &suite.Address, amount, tc.gasLimit, gasPrice, gasFeeCap, gasTipCap, nil, tc.accessList) tx.From = tc.from txData, _ := evmtypes.UnpackTxData(tx.Data) - evmParams := suite.app.EvmKeeper.GetParams(suite.ctx) + evmParams := suite.App.EvmKeeper.GetParams(suite.Ctx) ethCfg := evmParams.GetChainConfig().EthereumConfig(nil) - baseFee := suite.app.EvmKeeper.GetBaseFee(suite.ctx, ethCfg) + baseFee := suite.App.EvmKeeper.GetBaseFee(suite.Ctx, ethCfg) priority := evmtypes.GetTxPriority(txData, baseFee) - fees, err := keeper.VerifyFee(txData, evmtypes.DefaultEVMDenom, baseFee, false, false, suite.ctx.IsCheckTx()) + fees, err := keeper.VerifyFee(txData, evmtypes.DefaultEVMDenom, baseFee, false, false, suite.Ctx.IsCheckTx()) if tc.expectPassVerify { suite.Require().NoError(err, "valid test %d failed - '%s'", i, tc.name) if tc.enableFeemarket { - baseFee := suite.app.FeeMarketKeeper.GetBaseFee(suite.ctx) + baseFee := suite.App.FeeMarketKeeper.GetBaseFee(suite.Ctx) suite.Require().Equal( fees, sdk.NewCoins( @@ -507,7 +507,7 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { suite.Require().Nil(fees, "invalid test %d passed. fees value must be nil - '%s'", i, tc.name) } - err = suite.app.EvmKeeper.DeductTxCostsFromUserBalance(suite.ctx, fees, common.HexToAddress(tx.From)) + err = suite.App.EvmKeeper.DeductTxCostsFromUserBalance(suite.Ctx, fees, common.HexToAddress(tx.From)) if tc.expectPassDeduct { suite.Require().NoError(err, "valid test %d failed - '%s'", i, tc.name) } else { @@ -515,5 +515,5 @@ func (suite *KeeperTestSuite) TestVerifyFeeAndDeductTxCostsFromUserBalance() { } }) } - suite.enableFeemarket = false // reset flag + suite.EnableFeemarket = false // reset flag } diff --git a/x/evm/testutil/suite.go b/x/evm/testutil/suite.go index 36b7472117..db33a76d3b 100644 --- a/x/evm/testutil/suite.go +++ b/x/evm/testutil/suite.go @@ -62,13 +62,13 @@ type KeeperTestSuite struct { ClientCtx client.Context EthSigner ethtypes.Signer - appCodec codec.Codec - signer keyring.Signer + AppCodec codec.Codec + Signer keyring.Signer - enableFeemarket bool - enableLondonHF bool - mintFeeCollector bool - denom string + EnableFeemarket bool + EnableLondonHF bool + MintFeeCollector bool + Denom string } func (suite *KeeperTestSuite) SetupTest() { @@ -96,7 +96,7 @@ func (suite *KeeperTestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { Key: crypto.FromECDSA(ecdsaPriv), } suite.Address = common.BytesToAddress(priv.PubKey().Address().Bytes()) - suite.signer = tests.NewSigner(priv) + suite.Signer = tests.NewSigner(priv) // consensus key priv, err = ethsecp256k1.GenerateKey() @@ -105,14 +105,14 @@ func (suite *KeeperTestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { suite.App = app.Setup(checkTx, func(app *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState { feemarketGenesis := feemarkettypes.DefaultGenesisState() - if suite.enableFeemarket { + if suite.EnableFeemarket { feemarketGenesis.Params.EnableHeight = 1 feemarketGenesis.Params.NoBaseFee = false } else { feemarketGenesis.Params.NoBaseFee = true } genesis[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(feemarketGenesis) - if !suite.enableLondonHF { + if !suite.EnableLondonHF { evmGenesis := types.DefaultGenesisState() maxInt := sdkmath.NewInt(math.MaxInt64) evmGenesis.Params.ChainConfig.LondonBlock = &maxInt @@ -126,7 +126,7 @@ func (suite *KeeperTestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { return genesis }) - if suite.mintFeeCollector { + if suite.MintFeeCollector { // mint some coin to fee collector coins := sdk.NewCoins(sdk.NewCoin(types.DefaultEVMDenom, sdkmath.NewInt(int64(params.TxGas)-1))) genesisState := app.NewTestGenesisState(suite.App.AppCodec()) @@ -205,8 +205,8 @@ func (suite *KeeperTestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { encodingConfig := encoding.MakeConfig(app.ModuleBasics) suite.ClientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig) suite.EthSigner = ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) - suite.appCodec = encodingConfig.Codec - suite.denom = evmtypes.DefaultEVMDenom + suite.AppCodec = encodingConfig.Codec + suite.Denom = evmtypes.DefaultEVMDenom } func (suite *KeeperTestSuite) EvmDenom() string { @@ -264,7 +264,7 @@ func (suite *KeeperTestSuite) DeployTestContract(t require.TestingT, owner commo require.NoError(t, err) var erc20DeployTx *types.MsgEthereumTx - if suite.enableFeemarket { + if suite.EnableFeemarket { erc20DeployTx = types.NewTxContract( chainID, nonce, @@ -290,7 +290,7 @@ func (suite *KeeperTestSuite) DeployTestContract(t require.TestingT, owner commo } erc20DeployTx.From = suite.Address.Hex() - err = erc20DeployTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.signer) + err = erc20DeployTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.Signer) require.NoError(t, err) rsp, err := suite.App.EvmKeeper.EthereumTx(ctx, erc20DeployTx) require.NoError(t, err) @@ -316,7 +316,7 @@ func (suite *KeeperTestSuite) TransferERC20Token(t require.TestingT, contractAdd nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) var ercTransferTx *types.MsgEthereumTx - if suite.enableFeemarket { + if suite.EnableFeemarket { ercTransferTx = types.NewTx( chainID, nonce, @@ -344,7 +344,7 @@ func (suite *KeeperTestSuite) TransferERC20Token(t require.TestingT, contractAdd } ercTransferTx.From = suite.Address.Hex() - err = ercTransferTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.signer) + err = ercTransferTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.Signer) require.NoError(t, err) rsp, err := suite.App.EvmKeeper.EthereumTx(ctx, ercTransferTx) require.NoError(t, err) @@ -374,7 +374,7 @@ func (suite *KeeperTestSuite) DeployTestMessageCall(t require.TestingT) common.A nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) var erc20DeployTx *types.MsgEthereumTx - if suite.enableFeemarket { + if suite.EnableFeemarket { erc20DeployTx = types.NewTxContract( chainID, nonce, @@ -400,7 +400,7 @@ func (suite *KeeperTestSuite) DeployTestMessageCall(t require.TestingT) common.A } erc20DeployTx.From = suite.Address.Hex() - err = erc20DeployTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.signer) + err = erc20DeployTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.Signer) require.NoError(t, err) rsp, err := suite.App.EvmKeeper.EthereumTx(ctx, erc20DeployTx) require.NoError(t, err) From 096ffe903174fbdbc1acea81c8ffdfc1dd0d0414 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 8 Feb 2024 13:15:20 -0800 Subject: [PATCH 39/52] rename testutil suite --- x/evm/keeper/keeper_test.go | 2 +- .../keeper/state_transition_benchmark_test.go | 12 +++++----- x/evm/statedb/benchmark_test.go | 6 ++--- x/evm/statedb/statedb_test.go | 2 +- x/evm/testutil/suite.go | 24 +++++++++---------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/x/evm/keeper/keeper_test.go b/x/evm/keeper/keeper_test.go index 4d13dce5b3..a27a724da9 100644 --- a/x/evm/keeper/keeper_test.go +++ b/x/evm/keeper/keeper_test.go @@ -26,7 +26,7 @@ import ( var testTokens = sdkmath.NewIntWithDecimal(1000, 18) type KeeperTestSuite struct { - testutil.KeeperTestSuite + testutil.TestSuite } var s *KeeperTestSuite diff --git a/x/evm/keeper/state_transition_benchmark_test.go b/x/evm/keeper/state_transition_benchmark_test.go index 5b6a22dd58..2fae5d4c35 100644 --- a/x/evm/keeper/state_transition_benchmark_test.go +++ b/x/evm/keeper/state_transition_benchmark_test.go @@ -158,7 +158,7 @@ func newNativeMessage( func BenchmarkApplyTransaction(b *testing.B) { suite := KeeperTestSuite{ - KeeperTestSuite: testutil.KeeperTestSuite{ + TestSuite: testutil.TestSuite{ EnableLondonHF: true, }, } @@ -189,7 +189,7 @@ func BenchmarkApplyTransaction(b *testing.B) { func BenchmarkApplyTransactionWithLegacyTx(b *testing.B) { suite := KeeperTestSuite{ - KeeperTestSuite: testutil.KeeperTestSuite{ + TestSuite: testutil.TestSuite{ EnableLondonHF: true, }, } @@ -220,7 +220,7 @@ func BenchmarkApplyTransactionWithLegacyTx(b *testing.B) { func BenchmarkApplyTransactionWithDynamicFeeTx(b *testing.B) { suite := KeeperTestSuite{ - KeeperTestSuite: testutil.KeeperTestSuite{ + TestSuite: testutil.TestSuite{ EnableFeemarket: true, EnableLondonHF: true, }, @@ -252,7 +252,7 @@ func BenchmarkApplyTransactionWithDynamicFeeTx(b *testing.B) { func BenchmarkApplyMessage(b *testing.B) { suite := KeeperTestSuite{ - KeeperTestSuite: testutil.KeeperTestSuite{ + TestSuite: testutil.TestSuite{ EnableLondonHF: true, }, } @@ -291,7 +291,7 @@ func BenchmarkApplyMessage(b *testing.B) { func BenchmarkApplyMessageWithLegacyTx(b *testing.B) { suite := KeeperTestSuite{ - KeeperTestSuite: testutil.KeeperTestSuite{ + TestSuite: testutil.TestSuite{ EnableLondonHF: true, }, } @@ -330,7 +330,7 @@ func BenchmarkApplyMessageWithLegacyTx(b *testing.B) { func BenchmarkApplyMessageWithDynamicFeeTx(b *testing.B) { suite := KeeperTestSuite{ - KeeperTestSuite: testutil.KeeperTestSuite{ + TestSuite: testutil.TestSuite{ EnableFeemarket: true, EnableLondonHF: true, }, diff --git a/x/evm/statedb/benchmark_test.go b/x/evm/statedb/benchmark_test.go index de1e8aa40b..27c5680abc 100644 --- a/x/evm/statedb/benchmark_test.go +++ b/x/evm/statedb/benchmark_test.go @@ -183,9 +183,9 @@ func BenchmarkGetLogs(b *testing.B) { } } -func GetTestSuite(b *testing.B) *testutil.KeeperTestSuite { +func GetTestSuite(b *testing.B) *testutil.TestSuite { // Just reuse the keeper test suite to setup and create a testing app - suite := testutil.KeeperTestSuite{} + suite := testutil.TestSuite{} suite.SetupTestWithT(b) return &suite @@ -193,7 +193,7 @@ func GetTestSuite(b *testing.B) *testutil.KeeperTestSuite { func GetTestKeeper() *keeper.Keeper { // Just reuse the keeper test suite to setup and create a keeper - suite := testutil.KeeperTestSuite{} + suite := testutil.TestSuite{} suite.SetupTest() return suite.App.EvmKeeper diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index ac06e36d51..bf34305b3c 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -28,7 +28,7 @@ var ( ) type StateDBTestSuite struct { - testutil.KeeperTestSuite + testutil.TestSuite } func (suite *StateDBTestSuite) TestAccount() { diff --git a/x/evm/testutil/suite.go b/x/evm/testutil/suite.go index db33a76d3b..7568b6a981 100644 --- a/x/evm/testutil/suite.go +++ b/x/evm/testutil/suite.go @@ -49,7 +49,7 @@ import ( var testTokens = sdkmath.NewIntWithDecimal(1000, 18) -type KeeperTestSuite struct { +type TestSuite struct { suite.Suite Ctx sdk.Context @@ -71,24 +71,24 @@ type KeeperTestSuite struct { Denom string } -func (suite *KeeperTestSuite) SetupTest() { +func (suite *TestSuite) SetupTest() { checkTx := false suite.App = app.Setup(checkTx, nil) suite.SetupApp(checkTx) } -func (suite *KeeperTestSuite) SetupTestWithT(t require.TestingT) { +func (suite *TestSuite) SetupTestWithT(t require.TestingT) { checkTx := false suite.App = app.Setup(checkTx, nil) suite.SetupAppWithT(checkTx, t) } -func (suite *KeeperTestSuite) SetupApp(checkTx bool) { +func (suite *TestSuite) SetupApp(checkTx bool) { suite.SetupAppWithT(checkTx, suite.T()) } // SetupApp setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`. -func (suite *KeeperTestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { +func (suite *TestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { // account key, use a constant account to keep unit test deterministic. ecdsaPriv, err := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") require.NoError(t, err) @@ -209,14 +209,14 @@ func (suite *KeeperTestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { suite.Denom = evmtypes.DefaultEVMDenom } -func (suite *KeeperTestSuite) EvmDenom() string { +func (suite *TestSuite) EvmDenom() string { ctx := sdk.WrapSDKContext(suite.Ctx) rsp, _ := suite.QueryClient.Params(ctx, &types.QueryParamsRequest{}) return rsp.Params.EvmDenom } // Commit and begin new block -func (suite *KeeperTestSuite) Commit() { +func (suite *TestSuite) Commit() { _ = suite.App.Commit() header := suite.Ctx.BlockHeader() header.Height += 1 @@ -232,7 +232,7 @@ func (suite *KeeperTestSuite) Commit() { suite.QueryClient = types.NewQueryClient(queryHelper) } -func (suite *KeeperTestSuite) StateDB() vm.StateDB { +func (suite *TestSuite) StateDB() vm.StateDB { return statedb.New( suite.Ctx, suite.App.EvmKeeper, @@ -241,7 +241,7 @@ func (suite *KeeperTestSuite) StateDB() vm.StateDB { } // DeployTestContract deploy a test erc20 contract and returns the contract address -func (suite *KeeperTestSuite) DeployTestContract(t require.TestingT, owner common.Address, supply *big.Int) common.Address { +func (suite *TestSuite) DeployTestContract(t require.TestingT, owner common.Address, supply *big.Int) common.Address { ctx := sdk.WrapSDKContext(suite.Ctx) chainID := suite.App.EvmKeeper.ChainID() @@ -298,7 +298,7 @@ func (suite *KeeperTestSuite) DeployTestContract(t require.TestingT, owner commo return crypto.CreateAddress(suite.Address, nonce) } -func (suite *KeeperTestSuite) TransferERC20Token(t require.TestingT, contractAddr, from, to common.Address, amount *big.Int) *types.MsgEthereumTx { +func (suite *TestSuite) TransferERC20Token(t require.TestingT, contractAddr, from, to common.Address, amount *big.Int) *types.MsgEthereumTx { ctx := sdk.WrapSDKContext(suite.Ctx) chainID := suite.App.EvmKeeper.ChainID() @@ -353,7 +353,7 @@ func (suite *KeeperTestSuite) TransferERC20Token(t require.TestingT, contractAdd } // DeployTestMessageCall deploy a test erc20 contract and returns the contract address -func (suite *KeeperTestSuite) DeployTestMessageCall(t require.TestingT) common.Address { +func (suite *TestSuite) DeployTestMessageCall(t require.TestingT) common.Address { ctx := sdk.WrapSDKContext(suite.Ctx) chainID := suite.App.EvmKeeper.ChainID() @@ -408,7 +408,7 @@ func (suite *KeeperTestSuite) DeployTestMessageCall(t require.TestingT) common.A return crypto.CreateAddress(suite.Address, nonce) } -func (suite *KeeperTestSuite) GetAllAccountStorage( +func (suite *TestSuite) GetAllAccountStorage( ctx sdk.Context, addr common.Address, ) map[common.Hash]common.Hash { From 9988fb937d33226e853ec00892fcbb8956d1d328 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 8 Feb 2024 14:27:20 -0800 Subject: [PATCH 40/52] resolve lint errors --- x/evm/testutil/suite.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/x/evm/testutil/suite.go b/x/evm/testutil/suite.go index 7568b6a981..9b14e01a83 100644 --- a/x/evm/testutil/suite.go +++ b/x/evm/testutil/suite.go @@ -1,7 +1,6 @@ package testutil import ( - _ "embed" "encoding/json" "math" "math/big" @@ -31,7 +30,6 @@ import ( ethermint "github.com/evmos/ethermint/types" "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" - evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/evmos/ethermint/x/evm/vm" "github.com/ethereum/go-ethereum/common" @@ -47,8 +45,6 @@ import ( "github.com/tendermint/tendermint/version" ) -var testTokens = sdkmath.NewIntWithDecimal(1000, 18) - type TestSuite struct { suite.Suite @@ -206,7 +202,7 @@ func (suite *TestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { suite.ClientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig) suite.EthSigner = ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) suite.AppCodec = encodingConfig.Codec - suite.Denom = evmtypes.DefaultEVMDenom + suite.Denom = types.DefaultEVMDenom } func (suite *TestSuite) EvmDenom() string { @@ -219,7 +215,7 @@ func (suite *TestSuite) EvmDenom() string { func (suite *TestSuite) Commit() { _ = suite.App.Commit() header := suite.Ctx.BlockHeader() - header.Height += 1 + header.Height++ suite.App.BeginBlock(abci.RequestBeginBlock{ Header: header, }) @@ -250,7 +246,8 @@ func (suite *TestSuite) DeployTestContract(t require.TestingT, owner common.Addr nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) - data := append(types.ERC20Contract.Bin, ctorArgs...) + data := types.ERC20Contract.Bin + data = append(data, ctorArgs...) args, err := json.Marshal(&types.TransactionArgs{ From: &suite.Address, Data: (*hexutil.Bytes)(&data), @@ -258,7 +255,7 @@ func (suite *TestSuite) DeployTestContract(t require.TestingT, owner common.Addr require.NoError(t, err) res, err := suite.QueryClient.EstimateGas(ctx, &types.EthCallRequest{ Args: args, - GasCap: uint64(config.DefaultGasCap), + GasCap: config.DefaultGasCap, ProposerAddress: suite.Ctx.BlockHeader().ProposerAddress, }) require.NoError(t, err) @@ -366,7 +363,7 @@ func (suite *TestSuite) DeployTestMessageCall(t require.TestingT) common.Address res, err := suite.QueryClient.EstimateGas(ctx, &types.EthCallRequest{ Args: args, - GasCap: uint64(config.DefaultGasCap), + GasCap: config.DefaultGasCap, ProposerAddress: suite.Ctx.BlockHeader().ProposerAddress, }) require.NoError(t, err) From f505a412cf8c1b52b8dd72c83c8e7538a16eb234 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Fri, 9 Feb 2024 15:17:21 -0800 Subject: [PATCH 41/52] Manually revert statedb type migration changes --- app/ante/eth.go | 4 +- app/ante/eth_test.go | 8 +-- app/ante/interfaces.go | 2 +- app/ante/sigs_test.go | 4 +- app/ante/utils_test.go | 5 +- app/app.go | 3 +- tests/importer/importer_test.go | 6 +- x/evm/genesis_test.go | 4 +- x/evm/handler_test.go | 5 +- x/evm/keeper/config.go | 4 +- x/evm/keeper/grpc_query.go | 10 +-- x/evm/keeper/grpc_query_test.go | 21 +++--- x/evm/keeper/hooks_test.go | 2 +- x/evm/keeper/keeper.go | 38 +++++----- x/evm/keeper/keeper_test.go | 3 +- x/evm/keeper/msg_server_test.go | 4 +- x/evm/keeper/params_test.go | 4 -- x/evm/keeper/state_transition.go | 6 +- x/evm/keeper/state_transition_test.go | 5 +- x/evm/keeper/statedb.go | 8 +-- x/evm/keeper/statedb_test.go | 99 +++++++++++++-------------- x/evm/migrations/v3/store_test.go | 2 - x/evm/statedb/account.go | 27 ++++++++ x/evm/statedb/config.go | 29 ++++++++ x/evm/statedb/interfaces.go | 21 ++++++ x/evm/statedb/statedb.go | 18 +++-- x/evm/statedb/statedb_test.go | 96 +++++++++++++------------- x/evm/testutil/suite.go | 5 +- x/evm/types/statedb.go | 61 ----------------- x/evm/vm/interface.go | 45 ------------ 30 files changed, 249 insertions(+), 300 deletions(-) create mode 100644 x/evm/statedb/account.go delete mode 100644 x/evm/types/statedb.go diff --git a/app/ante/eth.go b/app/ante/eth.go index 669afccf3c..2402167be7 100644 --- a/app/ante/eth.go +++ b/app/ante/eth.go @@ -88,7 +88,7 @@ func (avd EthAccountVerificationDecorator) AnteHandle( if acct == nil { acc := avd.ak.NewAccountWithAddress(ctx, from) avd.ak.SetAccount(ctx, acc) - acct = evmtypes.NewEmptyAccount() + acct = statedb.NewEmptyAccount() } else if acct.IsContract() { return ctx, errorsmod.Wrapf(errortypes.ErrInvalidType, "the sender is not EOA: address %s, codeHash <%s>", fromAddr, acct.CodeHash) @@ -302,7 +302,7 @@ func (ctd CanTransferDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate BaseFee: baseFee, } - stateDB := statedb.New(ctx, ctd.evmKeeper, evmtypes.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes()))) + stateDB := statedb.New(ctx, ctd.evmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes()))) evm := ctd.evmKeeper.NewEVM(ctx, coreMsg, cfg, evmtypes.NewNoOpTracer(), stateDB) // check that caller has enough balance to cover asset transfer for **topmost** call diff --git a/app/ante/eth_test.go b/app/ante/eth_test.go index b5dd9dd7f1..0fb9ea8b20 100644 --- a/app/ante/eth_test.go +++ b/app/ante/eth_test.go @@ -10,8 +10,8 @@ import ( "github.com/evmos/ethermint/server/config" "github.com/evmos/ethermint/tests" ethermint "github.com/evmos/ethermint/types" + "github.com/evmos/ethermint/x/evm/statedb" evmtypes "github.com/evmos/ethermint/x/evm/types" - "github.com/evmos/ethermint/x/evm/vm" ethtypes "github.com/ethereum/go-ethereum/core/types" ) @@ -26,7 +26,7 @@ func (suite AnteTestSuite) TestNewEthAccountVerificationDecorator() { tx := evmtypes.NewTxContract(suite.app.EvmKeeper.ChainID(), 1, big.NewInt(10), 1000, big.NewInt(1), nil, nil, nil, nil) tx.From = addr.Hex() - var vmdb vm.StateDB + var vmdb *statedb.StateDB testCases := []struct { name string @@ -192,7 +192,7 @@ func (suite AnteTestSuite) TestEthGasConsumeDecorator() { dynamicFeeTx.From = addr.Hex() dynamicFeeTxPriority := int64(1) - var vmdb vm.StateDB + var vmdb *statedb.StateDB testCases := []struct { name string @@ -352,7 +352,7 @@ func (suite AnteTestSuite) TestCanTransferDecorator() { err := tx.Sign(suite.ethSigner, tests.NewSigner(privKey)) suite.Require().NoError(err) - var vmdb vm.StateDB + var vmdb *statedb.StateDB testCases := []struct { name string diff --git a/app/ante/interfaces.go b/app/ante/interfaces.go index c2bb63cd62..e48e0a50a4 100644 --- a/app/ante/interfaces.go +++ b/app/ante/interfaces.go @@ -41,7 +41,7 @@ type DynamicFeeEVMKeeper interface { // EVMKeeper defines the expected keeper interface used on the Eth AnteHandler type EVMKeeper interface { - evm.StateDBKeeper + statedb.Keeper DynamicFeeEVMKeeper NewEVM(ctx sdk.Context, msg core.Message, cfg *statedb.EVMConfig, tracer vm.EVMLogger, stateDB vm.StateDB) evm.EVM diff --git a/app/ante/sigs_test.go b/app/ante/sigs_test.go index be87ab15f3..0c7b0539c8 100644 --- a/app/ante/sigs_test.go +++ b/app/ante/sigs_test.go @@ -4,7 +4,7 @@ import ( "math/big" "github.com/evmos/ethermint/tests" - "github.com/evmos/ethermint/x/evm/types" + "github.com/evmos/ethermint/x/evm/statedb" evmtypes "github.com/evmos/ethermint/x/evm/types" ) @@ -15,7 +15,7 @@ func (suite AnteTestSuite) TestSignatures() { addr, privKey := tests.NewAddrKey() to := tests.GenerateAddress() - acc := types.NewEmptyAccount() + acc := statedb.NewEmptyAccount() acc.Nonce = 1 acc.Balance = big.NewInt(10000000000) diff --git a/app/ante/utils_test.go b/app/ante/utils_test.go index e87c82e839..c92961c391 100644 --- a/app/ante/utils_test.go +++ b/app/ante/utils_test.go @@ -53,7 +53,6 @@ import ( "github.com/evmos/ethermint/tests" "github.com/evmos/ethermint/x/evm/statedb" evmtypes "github.com/evmos/ethermint/x/evm/types" - "github.com/evmos/ethermint/x/evm/vm" feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -74,8 +73,8 @@ type AnteTestSuite struct { const TestGasLimit uint64 = 100000 -func (suite *AnteTestSuite) StateDB() vm.StateDB { - return statedb.New(suite.ctx, suite.app.EvmKeeper, evmtypes.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()))) +func (suite *AnteTestSuite) StateDB() *statedb.StateDB { + return statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()))) } func (suite *AnteTestSuite) SetupTest() { diff --git a/app/app.go b/app/app.go index 7191014db5..7b5f98d319 100644 --- a/app/app.go +++ b/app/app.go @@ -123,7 +123,6 @@ import ( ethermint "github.com/evmos/ethermint/types" "github.com/evmos/ethermint/x/evm" evmkeeper "github.com/evmos/ethermint/x/evm/keeper" - "github.com/evmos/ethermint/x/evm/statedb" evmtypes "github.com/evmos/ethermint/x/evm/types" legacyevmtypes "github.com/evmos/ethermint/x/evm/types/legacy" "github.com/evmos/ethermint/x/evm/vm/geth" @@ -423,7 +422,7 @@ func NewEthermintApp( appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper, - nil, geth.NewEVM, statedb.New, tracer, evmSs, + nil, geth.NewEVM, tracer, evmSs, ) // Create IBC Keeper diff --git a/tests/importer/importer_test.go b/tests/importer/importer_test.go index 04e8918e29..a32a730206 100644 --- a/tests/importer/importer_test.go +++ b/tests/importer/importer_test.go @@ -18,8 +18,6 @@ import ( evmkeeper "github.com/evmos/ethermint/x/evm/keeper" "github.com/evmos/ethermint/x/evm/statedb" - evmtypes "github.com/evmos/ethermint/x/evm/types" - "github.com/evmos/ethermint/x/evm/vm" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus/ethash" @@ -142,7 +140,7 @@ func (suite *ImporterTestSuite) TestImportBlocks() { }) ctx := suite.app.NewContext(false, tmheader) ctx = ctx.WithBlockHeight(tmheader.Height) - vmdb := statedb.New(ctx, suite.app.EvmKeeper, evmtypes.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes()))) + vmdb := statedb.New(ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes()))) if chainConfig.DAOForkSupport && chainConfig.DAOForkBlock != nil && chainConfig.DAOForkBlock.Cmp(block.Number()) == 0 { applyDAOHardFork(vmdb) @@ -228,7 +226,7 @@ func applyDAOHardFork(vmdb ethvm.StateDB) { // Ref: https://github.com/ethereum/go-ethereum/blob/52f2461774bcb8cdd310f86b4bc501df5b783852/core/state_processor.go#L88 func applyTransaction( ctx sdk.Context, config *ethparams.ChainConfig, bc ethcore.ChainContext, author *common.Address, - gp *ethcore.GasPool, evmKeeper *evmkeeper.Keeper, vmdb vm.StateDB, header *ethtypes.Header, + gp *ethcore.GasPool, evmKeeper *evmkeeper.Keeper, vmdb *statedb.StateDB, header *ethtypes.Header, tx *ethtypes.Transaction, usedGas *uint64, cfg ethvm.Config, ) (*ethtypes.Receipt, uint64, error) { msg, err := tx.AsMessage(ethtypes.MakeSigner(config, header.Number), sdk.ZeroInt().BigInt()) diff --git a/x/evm/genesis_test.go b/x/evm/genesis_test.go index 72262472e9..e060c5d965 100644 --- a/x/evm/genesis_test.go +++ b/x/evm/genesis_test.go @@ -9,8 +9,8 @@ import ( "github.com/evmos/ethermint/crypto/ethsecp256k1" etherminttypes "github.com/evmos/ethermint/types" "github.com/evmos/ethermint/x/evm" + "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" - "github.com/evmos/ethermint/x/evm/vm" ) func (suite *EvmTestSuite) TestInitGenesis() { @@ -19,7 +19,7 @@ func (suite *EvmTestSuite) TestInitGenesis() { address := common.HexToAddress(privkey.PubKey().Address().String()) - var vmdb vm.StateDB + var vmdb *statedb.StateDB testCases := []struct { name string diff --git a/x/evm/handler_test.go b/x/evm/handler_test.go index 68b2b74a1b..a554c6ee6a 100644 --- a/x/evm/handler_test.go +++ b/x/evm/handler_test.go @@ -7,7 +7,6 @@ import ( "time" "github.com/evmos/ethermint/x/evm/keeper" - "github.com/evmos/ethermint/x/evm/vm" sdkmath "cosmossdk.io/math" "github.com/gogo/protobuf/proto" @@ -182,8 +181,8 @@ func (suite *EvmTestSuite) SignTx(tx *types.MsgEthereumTx) { suite.Require().NoError(err) } -func (suite *EvmTestSuite) StateDB() vm.StateDB { - return statedb.New(suite.ctx, suite.app.EvmKeeper, types.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()))) +func (suite *EvmTestSuite) StateDB() *statedb.StateDB { + return statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()))) } func TestEvmTestSuite(t *testing.T) { diff --git a/x/evm/keeper/config.go b/x/evm/keeper/config.go index 1d76fd0d06..3debb895de 100644 --- a/x/evm/keeper/config.go +++ b/x/evm/keeper/config.go @@ -48,8 +48,8 @@ func (k *Keeper) EVMConfig(ctx sdk.Context, proposerAddress sdk.ConsAddress, cha } // TxConfig loads `TxConfig` from current transient storage -func (k *Keeper) TxConfig(ctx sdk.Context, txHash common.Hash) types.TxConfig { - return types.NewTxConfig( +func (k *Keeper) TxConfig(ctx sdk.Context, txHash common.Hash) statedb.TxConfig { + return statedb.NewTxConfig( common.BytesToHash(ctx.HeaderHash()), // BlockHash txHash, // TxHash uint(k.GetTxIndexTransient(ctx)), // TxIndex diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index f9d5b5e56f..5e09153b59 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -255,7 +255,7 @@ func (k Keeper) EthCall(c context.Context, req *types.EthCallRequest) (*types.Ms return nil, status.Error(codes.InvalidArgument, err.Error()) } - txConfig := types.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash())) + txConfig := statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash())) // pass false to not commit StateDB res, err := k.ApplyMessageWithConfig(ctx, msg, nil, false, cfg, txConfig) @@ -324,7 +324,7 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type nonce := k.GetNonce(ctx, args.GetFrom()) args.Nonce = (*hexutil.Uint64)(&nonce) - txConfig := types.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())) + txConfig := statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())) // convert the tx args to an ethereum message msg, err := args.ToMessage(req.GasCap, cfg.BaseFee) @@ -423,7 +423,7 @@ func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*typ } signer := ethtypes.MakeSigner(cfg.ChainConfig, big.NewInt(ctx.BlockHeight())) - txConfig := types.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())) + txConfig := statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())) for i, tx := range req.Predecessors { ethTx := tx.AsTransaction() msg, err := ethTx.AsMessage(signer, cfg.BaseFee) @@ -503,7 +503,7 @@ func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest) txsLength := len(req.Txs) results := make([]*types.TxTraceResult, 0, txsLength) - txConfig := types.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())) + txConfig := statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())) for i, tx := range req.Txs { result := types.TxTraceResult{} ethTx := tx.AsTransaction() @@ -533,7 +533,7 @@ func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest) func (k *Keeper) traceTx( ctx sdk.Context, cfg *statedb.EVMConfig, - txConfig types.TxConfig, + txConfig statedb.TxConfig, signer ethtypes.Signer, tx *ethtypes.Transaction, traceConfig *types.TraceConfig, diff --git a/x/evm/keeper/grpc_query_test.go b/x/evm/keeper/grpc_query_test.go index e0f7248475..520dc79f67 100644 --- a/x/evm/keeper/grpc_query_test.go +++ b/x/evm/keeper/grpc_query_test.go @@ -9,7 +9,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" ethlogger "github.com/ethereum/go-ethereum/eth/tracers/logger" ethparams "github.com/ethereum/go-ethereum/params" @@ -238,12 +237,12 @@ func (suite *KeeperTestSuite) TestQueryStorage() { testCases := []struct { msg string - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) expPass bool }{ { "invalid address", - func(vm.StateDB) { + func(*statedb.StateDB) { req = &types.QueryStorageRequest{ Address: invalidAddress, } @@ -252,7 +251,7 @@ func (suite *KeeperTestSuite) TestQueryStorage() { }, { "success", - func(vmdb vm.StateDB) { + func(vmdb *statedb.StateDB) { key := common.BytesToHash([]byte("key")) value := common.BytesToHash([]byte("value")) expValue = value.String() @@ -297,12 +296,12 @@ func (suite *KeeperTestSuite) TestQueryCode() { testCases := []struct { msg string - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) expPass bool }{ { "invalid address", - func(vm.StateDB) { + func(*statedb.StateDB) { req = &types.QueryCodeRequest{ Address: invalidAddress, } @@ -313,7 +312,7 @@ func (suite *KeeperTestSuite) TestQueryCode() { }, { "success", - func(vmdb vm.StateDB) { + func(vmdb *statedb.StateDB) { expCode = []byte("code") vmdb.SetCode(suite.Address, expCode) @@ -356,17 +355,17 @@ func (suite *KeeperTestSuite) TestQueryTxLogs() { testCases := []struct { msg string - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) }{ { "empty logs", - func(vm.StateDB) { + func(*statedb.StateDB) { expLogs = nil }, }, { "success", - func(vmdb vm.StateDB) { + func(vmdb *statedb.StateDB) { expLogs = []*types.Log{ { Address: suite.Address.String(), @@ -392,7 +391,7 @@ func (suite *KeeperTestSuite) TestQueryTxLogs() { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset - vmdb := statedb.New(suite.Ctx, suite.App.EvmKeeper, types.NewTxConfig(common.BytesToHash(suite.Ctx.HeaderHash().Bytes()), txHash, txIndex, logIndex)) + vmdb := statedb.New(suite.Ctx, suite.App.EvmKeeper, statedb.NewTxConfig(common.BytesToHash(suite.Ctx.HeaderHash().Bytes()), txHash, txIndex, logIndex)) tc.malleate(vmdb) suite.Require().NoError(vmdb.Commit()) diff --git a/x/evm/keeper/hooks_test.go b/x/evm/keeper/hooks_test.go index d3d198d9fa..d8d0dafd35 100644 --- a/x/evm/keeper/hooks_test.go +++ b/x/evm/keeper/hooks_test.go @@ -66,7 +66,7 @@ func (suite *KeeperTestSuite) TestEvmHooks() { k := suite.App.EvmKeeper ctx := suite.Ctx txHash := common.BigToHash(big.NewInt(1)) - vmdb := statedb.New(ctx, k, types.NewTxConfig( + vmdb := statedb.New(ctx, k, statedb.NewTxConfig( common.BytesToHash(ctx.HeaderHash().Bytes()), txHash, 0, diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 42400ee27b..187d547274 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -32,6 +32,7 @@ import ( "github.com/tendermint/tendermint/libs/log" ethermint "github.com/evmos/ethermint/types" + "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" legacytypes "github.com/evmos/ethermint/x/evm/types/legacy" evm "github.com/evmos/ethermint/x/evm/vm" @@ -77,9 +78,6 @@ type Keeper struct { // evm constructor function evmConstructor evm.Constructor - // stateDB constructor function - stateDBConstructor evm.StateDBConstructor - // Legacy subspace ss paramstypes.Subspace } @@ -95,7 +93,6 @@ func NewKeeper( fmk types.FeeMarketKeeper, customPrecompiles evm.PrecompiledContracts, evmConstructor evm.Constructor, - stateDBConstructor evm.StateDBConstructor, tracer string, ss paramstypes.Subspace, ) *Keeper { @@ -115,19 +112,18 @@ func NewKeeper( // NOTE: we pass in the parameter space to the CommitStateDB in order to use custom denominations for the EVM operations return &Keeper{ - cdc: cdc, - authority: authority, - accountKeeper: ak, - bankKeeper: bankKeeper, - stakingKeeper: sk, - feeMarketKeeper: fmk, - storeKey: storeKey, - transientKey: transientKey, - customPrecompiles: customPrecompiles, - evmConstructor: evmConstructor, - stateDBConstructor: stateDBConstructor, - tracer: tracer, - ss: ss, + cdc: cdc, + authority: authority, + accountKeeper: ak, + bankKeeper: bankKeeper, + stakingKeeper: sk, + feeMarketKeeper: fmk, + storeKey: storeKey, + transientKey: transientKey, + customPrecompiles: customPrecompiles, + evmConstructor: evmConstructor, + tracer: tracer, + ss: ss, } } @@ -284,7 +280,7 @@ func (k Keeper) Tracer(ctx sdk.Context, msg core.Message, ethCfg *params.ChainCo // GetAccountWithoutBalance load nonce and codehash without balance, // more efficient in cases where balance is not needed. -func (k *Keeper) GetAccountWithoutBalance(ctx sdk.Context, addr common.Address) *types.StateDBAccount { +func (k *Keeper) GetAccountWithoutBalance(ctx sdk.Context, addr common.Address) *statedb.Account { cosmosAddr := sdk.AccAddress(addr.Bytes()) acct := k.accountKeeper.GetAccount(ctx, cosmosAddr) if acct == nil { @@ -297,7 +293,7 @@ func (k *Keeper) GetAccountWithoutBalance(ctx sdk.Context, addr common.Address) codeHash = ethAcct.GetCodeHash().Bytes() } - return &types.StateDBAccount{ + return &statedb.Account{ Nonce: acct.GetSequence(), CodeHash: codeHash, Balance: nil, @@ -305,14 +301,14 @@ func (k *Keeper) GetAccountWithoutBalance(ctx sdk.Context, addr common.Address) } // GetAccountOrEmpty returns empty account if not exist, returns error if it's not `EthAccount` -func (k *Keeper) GetAccountOrEmpty(ctx sdk.Context, addr common.Address) types.StateDBAccount { +func (k *Keeper) GetAccountOrEmpty(ctx sdk.Context, addr common.Address) statedb.Account { acct := k.GetAccount(ctx, addr) if acct != nil { return *acct } // empty account - return types.StateDBAccount{ + return statedb.Account{ Balance: new(big.Int), CodeHash: types.EmptyCodeHash, } diff --git a/x/evm/keeper/keeper_test.go b/x/evm/keeper/keeper_test.go index a27a724da9..549d103a5f 100644 --- a/x/evm/keeper/keeper_test.go +++ b/x/evm/keeper/keeper_test.go @@ -12,6 +12,7 @@ import ( sdkmath "cosmossdk.io/math" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/testutil" "github.com/stretchr/testify/suite" @@ -119,7 +120,7 @@ func (suite *KeeperTestSuite) TestGetAccountStorage() { } func (suite *KeeperTestSuite) TestGetAccountOrEmpty() { - empty := types.StateDBAccount{ + empty := statedb.Account{ Balance: new(big.Int), CodeHash: types.EmptyCodeHash, } diff --git a/x/evm/keeper/msg_server_test.go b/x/evm/keeper/msg_server_test.go index bf71af77df..756426442b 100644 --- a/x/evm/keeper/msg_server_test.go +++ b/x/evm/keeper/msg_server_test.go @@ -8,8 +8,8 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" - "github.com/evmos/ethermint/x/evm/vm" ) func (suite *KeeperTestSuite) TestEthereumTx() { @@ -17,7 +17,7 @@ func (suite *KeeperTestSuite) TestEthereumTx() { err error msg *types.MsgEthereumTx signer ethtypes.Signer - vmdb vm.StateDB + vmdb *statedb.StateDB chainCfg *params.ChainConfig expectedGasUsed uint64 ) diff --git a/x/evm/keeper/params_test.go b/x/evm/keeper/params_test.go index 9c110e4c03..f7e8926b22 100644 --- a/x/evm/keeper/params_test.go +++ b/x/evm/keeper/params_test.go @@ -11,7 +11,6 @@ import ( "github.com/evmos/ethermint/app" "github.com/evmos/ethermint/encoding" "github.com/evmos/ethermint/x/evm/keeper" - "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" legacytypes "github.com/evmos/ethermint/x/evm/types/legacy" legacytestutil "github.com/evmos/ethermint/x/evm/types/legacy/testutil" @@ -153,7 +152,6 @@ func (suite *KeeperTestSuite) TestLegacyParamsKeyTableRegistration() { ak, nil, nil, nil, nil, // OK to pass nil in for these since we only instantiate and use params geth.NewEVM, - statedb.New, "", unregisteredSubspace, ) @@ -211,7 +209,6 @@ func (suite *KeeperTestSuite) TestRenamedFieldReturnsProperValueForLegacyParams( ak, nil, nil, nil, nil, geth.NewEVM, - statedb.New, "", subspace, ) @@ -244,7 +241,6 @@ func (suite *KeeperTestSuite) TestNilLegacyParamsDoNotPanic() { ak, nil, nil, nil, nil, // OK to pass nil in for these since we only instantiate and use params geth.NewEVM, - statedb.New, "", subspace, ) diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index ef02cdc3c3..ad90dba5fd 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -268,7 +268,7 @@ func (k *Keeper) ApplyMessage(ctx sdk.Context, msg core.Message, tracer vm.EVMLo return nil, errorsmod.Wrap(err, "failed to load evm config") } - txConfig := types.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash())) + txConfig := statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash())) return k.ApplyMessageWithConfig(ctx, msg, tracer, commit, cfg, txConfig) } @@ -315,7 +315,7 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, tracer vm.EVMLogger, commit bool, cfg *statedb.EVMConfig, - txConfig types.TxConfig, + txConfig statedb.TxConfig, ) (*types.MsgEthereumTxResponse, error) { var ( ret []byte // return bytes from evm execution @@ -329,7 +329,7 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, return nil, errorsmod.Wrap(types.ErrCallDisabled, "failed to call contract") } - stateDB := k.stateDBConstructor(ctx, k, txConfig) + stateDB := statedb.New(ctx, k, txConfig) evm := k.NewEVM(ctx, msg, cfg, tracer, stateDB) leftoverGas := msg.Gas() diff --git a/x/evm/keeper/state_transition_test.go b/x/evm/keeper/state_transition_test.go index 9fd2a707d1..76334d40fd 100644 --- a/x/evm/keeper/state_transition_test.go +++ b/x/evm/keeper/state_transition_test.go @@ -11,7 +11,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" "github.com/evmos/ethermint/tests" "github.com/evmos/ethermint/x/evm/keeper" @@ -575,8 +574,8 @@ func (suite *KeeperTestSuite) TestApplyMessageWithConfig() { config *statedb.EVMConfig keeperParams types.Params signer ethtypes.Signer - vmdb vm.StateDB - txConfig types.TxConfig + vmdb *statedb.StateDB + txConfig statedb.TxConfig chainCfg *params.ChainConfig ) diff --git a/x/evm/keeper/statedb.go b/x/evm/keeper/statedb.go index 7644798354..c2cd893c5e 100644 --- a/x/evm/keeper/statedb.go +++ b/x/evm/keeper/statedb.go @@ -27,18 +27,18 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" ethermint "github.com/evmos/ethermint/types" + "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" - "github.com/evmos/ethermint/x/evm/vm" ) -var _ vm.StateDBKeeper = &Keeper{} +var _ statedb.Keeper = &Keeper{} // ---------------------------------------------------------------------------- // StateDB Keeper implementation // ---------------------------------------------------------------------------- // GetAccount returns nil if account is not exist, returns error if it's not `EthAccountI` -func (k *Keeper) GetAccount(ctx sdk.Context, addr common.Address) *types.StateDBAccount { +func (k *Keeper) GetAccount(ctx sdk.Context, addr common.Address) *statedb.Account { acct := k.GetAccountWithoutBalance(ctx, addr) if acct == nil { return nil @@ -119,7 +119,7 @@ func (k *Keeper) SetBalance(ctx sdk.Context, addr common.Address, amount *big.In } // SetAccount updates nonce/balance/codeHash together. -func (k *Keeper) SetAccount(ctx sdk.Context, addr common.Address, account types.StateDBAccount) error { +func (k *Keeper) SetAccount(ctx sdk.Context, addr common.Address, account statedb.Account) error { // update account cosmosAddr := sdk.AccAddress(addr.Bytes()) acct := k.accountKeeper.GetAccount(ctx, cosmosAddr) diff --git a/x/evm/keeper/statedb_test.go b/x/evm/keeper/statedb_test.go index a014566fc2..b34950d760 100644 --- a/x/evm/keeper/statedb_test.go +++ b/x/evm/keeper/statedb_test.go @@ -16,7 +16,6 @@ import ( "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/evmos/ethermint/crypto/ethsecp256k1" "github.com/evmos/ethermint/tests" @@ -29,27 +28,27 @@ func (suite *KeeperTestSuite) TestCreateAccount() { testCases := []struct { name string addr common.Address - malleate func(vm.StateDB, common.Address) - callback func(vm.StateDB, common.Address) + malleate func(*statedb.StateDB, common.Address) + callback func(*statedb.StateDB, common.Address) }{ { "reset account (keep balance)", suite.Address, - func(vmdb vm.StateDB, addr common.Address) { + func(vmdb *statedb.StateDB, addr common.Address) { vmdb.AddBalance(addr, big.NewInt(100)) suite.Require().NotZero(vmdb.GetBalance(addr).Int64()) }, - func(vmdb vm.StateDB, addr common.Address) { + func(vmdb *statedb.StateDB, addr common.Address) { suite.Require().Equal(vmdb.GetBalance(addr).Int64(), int64(100)) }, }, { "create account", tests.GenerateAddress(), - func(vmdb vm.StateDB, addr common.Address) { + func(vmdb *statedb.StateDB, addr common.Address) { suite.Require().False(vmdb.Exist(addr)) }, - func(vmdb vm.StateDB, addr common.Address) { + func(vmdb *statedb.StateDB, addr common.Address) { suite.Require().True(vmdb.Exist(addr)) }, }, @@ -110,19 +109,19 @@ func (suite *KeeperTestSuite) TestSubBalance() { testCases := []struct { name string amount *big.Int - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) isNoOp bool }{ { "positive amount, below zero", big.NewInt(100), - func(vm.StateDB) {}, + func(*statedb.StateDB) {}, true, }, { "positive amount, above zero", big.NewInt(50), - func(vmdb vm.StateDB) { + func(vmdb *statedb.StateDB) { vmdb.AddBalance(suite.Address, big.NewInt(100)) }, false, @@ -130,13 +129,13 @@ func (suite *KeeperTestSuite) TestSubBalance() { { "zero amount", big.NewInt(0), - func(vm.StateDB) {}, + func(*statedb.StateDB) {}, true, }, { "negative amount", big.NewInt(-1), - func(vm.StateDB) {}, + func(*statedb.StateDB) {}, false, }, } @@ -164,19 +163,19 @@ func (suite *KeeperTestSuite) TestGetNonce() { name string address common.Address expectedNonce uint64 - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) }{ { "account not found", tests.GenerateAddress(), 0, - func(vm.StateDB) {}, + func(*statedb.StateDB) {}, }, { "existing account", suite.Address, 1, - func(vmdb vm.StateDB) { + func(vmdb *statedb.StateDB) { vmdb.SetNonce(suite.Address, 1) }, }, @@ -235,55 +234,55 @@ func (suite *KeeperTestSuite) TestSetAccount() { testCases := []struct { name string address common.Address - account types.StateDBAccount + account statedb.Account expectedErr error }{ { "new account, non-contract account", tests.GenerateAddress(), - types.StateDBAccount{10, big.NewInt(100), types.EmptyCodeHash}, + statedb.Account{10, big.NewInt(100), types.EmptyCodeHash}, nil, }, { "new account, contract account", tests.GenerateAddress(), - types.StateDBAccount{10, big.NewInt(100), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, + statedb.Account{10, big.NewInt(100), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, nil, }, { "existing eth account, non-contract account", ethAddr, - types.StateDBAccount{10, big.NewInt(1), types.EmptyCodeHash}, + statedb.Account{10, big.NewInt(1), types.EmptyCodeHash}, nil, }, { "existing eth account, contract account", ethAddr, - types.StateDBAccount{10, big.NewInt(0), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, + statedb.Account{10, big.NewInt(0), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, nil, }, { "existing base account, non-contract account", baseAddr, - types.StateDBAccount{10, big.NewInt(10), types.EmptyCodeHash}, + statedb.Account{10, big.NewInt(10), types.EmptyCodeHash}, nil, }, { "existing base account, contract account", baseAddr, - types.StateDBAccount{10, big.NewInt(99), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, + statedb.Account{10, big.NewInt(99), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, nil, }, { "existing vesting account, non-contract account", vestingAddr, - types.StateDBAccount{10, big.NewInt(1000), types.EmptyCodeHash}, + statedb.Account{10, big.NewInt(1000), types.EmptyCodeHash}, nil, }, { "existing vesting account, contract account", vestingAddr, - types.StateDBAccount{10, big.NewInt(1001), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, + statedb.Account{10, big.NewInt(1001), crypto.Keccak256Hash([]byte("some code hash")).Bytes()}, types.ErrInvalidAccount, }, } @@ -331,25 +330,25 @@ func (suite *KeeperTestSuite) TestGetCodeHash() { name string address common.Address expHash common.Hash - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) }{ { "account not found", tests.GenerateAddress(), common.Hash{}, - func(vm.StateDB) {}, + func(*statedb.StateDB) {}, }, { "account not EthAccount type, EmptyCodeHash", addr, common.BytesToHash(types.EmptyCodeHash), - func(vm.StateDB) {}, + func(*statedb.StateDB) {}, }, { "existing account", suite.Address, crypto.Keccak256Hash([]byte("codeHash")), - func(vmdb vm.StateDB) { + func(vmdb *statedb.StateDB) { vmdb.SetCode(suite.Address, []byte("codeHash")) }, }, @@ -458,13 +457,13 @@ func (suite *KeeperTestSuite) TestKeeperSetCode() { func (suite *KeeperTestSuite) TestRefund() { testCases := []struct { name string - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) expRefund uint64 expPanic bool }{ { "success - add and subtract refund", - func(vmdb vm.StateDB) { + func(vmdb *statedb.StateDB) { vmdb.AddRefund(11) }, 1, @@ -472,7 +471,7 @@ func (suite *KeeperTestSuite) TestRefund() { }, { "fail - subtract amount > current refund", - func(vm.StateDB) { + func(*statedb.StateDB) { }, 0, true, @@ -602,14 +601,14 @@ func (suite *KeeperTestSuite) TestExist() { testCases := []struct { name string address common.Address - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) exists bool }{ - {"success, account exists", suite.Address, func(vm.StateDB) {}, true}, - {"success, has suicided", suite.Address, func(vmdb vm.StateDB) { + {"success, account exists", suite.Address, func(*statedb.StateDB) {}, true}, + {"success, has suicided", suite.Address, func(vmdb *statedb.StateDB) { vmdb.Suicide(suite.Address) }, true}, - {"success, account doesn't exist", tests.GenerateAddress(), func(vm.StateDB) {}, false}, + {"success, account doesn't exist", tests.GenerateAddress(), func(*statedb.StateDB) {}, false}, } for _, tc := range testCases { @@ -626,17 +625,17 @@ func (suite *KeeperTestSuite) TestEmpty() { testCases := []struct { name string address common.Address - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) empty bool }{ - {"empty, account exists", suite.Address, func(vm.StateDB) {}, true}, + {"empty, account exists", suite.Address, func(*statedb.StateDB) {}, true}, { "not empty, positive balance", suite.Address, - func(vmdb vm.StateDB) { vmdb.AddBalance(suite.Address, big.NewInt(100)) }, + func(vmdb *statedb.StateDB) { vmdb.AddBalance(suite.Address, big.NewInt(100)) }, false, }, - {"empty, account doesn't exist", tests.GenerateAddress(), func(vm.StateDB) {}, true}, + {"empty, account doesn't exist", tests.GenerateAddress(), func(*statedb.StateDB) {}, true}, } for _, tc := range testCases { @@ -657,9 +656,9 @@ func (suite *KeeperTestSuite) TestSnapshot() { testCases := []struct { name string - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) }{ - {"simple revert", func(vmdb vm.StateDB) { + {"simple revert", func(vmdb *statedb.StateDB) { revision := vmdb.Snapshot() suite.Require().Zero(revision) @@ -671,7 +670,7 @@ func (suite *KeeperTestSuite) TestSnapshot() { // reverted suite.Require().Equal(common.Hash{}, vmdb.GetState(suite.Address, key)) }}, - {"nested snapshot/revert", func(vmdb vm.StateDB) { + {"nested snapshot/revert", func(vmdb *statedb.StateDB) { revision1 := vmdb.Snapshot() suite.Require().Zero(revision1) @@ -688,7 +687,7 @@ func (suite *KeeperTestSuite) TestSnapshot() { vmdb.RevertToSnapshot(revision1) suite.Require().Equal(common.Hash{}, vmdb.GetState(suite.Address, key)) }}, - {"jump revert", func(vmdb vm.StateDB) { + {"jump revert", func(vmdb *statedb.StateDB) { revision1 := vmdb.Snapshot() vmdb.SetState(suite.Address, key, value1) vmdb.Snapshot() @@ -758,7 +757,7 @@ func (suite *KeeperTestSuite) TestAddLog() { name string hash common.Hash log, expLog *ethtypes.Log // pre and post populating log fields - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) }{ { "tx hash from message", @@ -772,7 +771,7 @@ func (suite *KeeperTestSuite) TestAddLog() { TxHash: txHash, Topics: make([]common.Hash, 0), }, - func(vm.StateDB) {}, + func(*statedb.StateDB) {}, }, { "dynamicfee tx hash from message", @@ -786,14 +785,14 @@ func (suite *KeeperTestSuite) TestAddLog() { TxHash: txHash3, Topics: make([]common.Hash, 0), }, - func(vm.StateDB) {}, + func(*statedb.StateDB) {}, }, } for _, tc := range testCases { suite.Run(tc.name, func() { suite.SetupTest() - vmdb := statedb.New(suite.Ctx, suite.App.EvmKeeper, types.NewTxConfig( + vmdb := statedb.New(suite.Ctx, suite.App.EvmKeeper, statedb.NewTxConfig( common.BytesToHash(suite.Ctx.HeaderHash().Bytes()), tc.hash, 0, 0, @@ -883,13 +882,13 @@ func (suite *KeeperTestSuite) _TestForEachStorage() { testCase := []struct { name string - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) callback func(key, value common.Hash) (stop bool) expValues []common.Hash }{ { "aggregate state", - func(vmdb vm.StateDB) { + func(vmdb *statedb.StateDB) { for i := 0; i < 5; i++ { vmdb.SetState(suite.Address, common.BytesToHash([]byte(fmt.Sprintf("key%d", i))), common.BytesToHash([]byte(fmt.Sprintf("value%d", i)))) } @@ -908,7 +907,7 @@ func (suite *KeeperTestSuite) _TestForEachStorage() { }, { "filter state", - func(vmdb vm.StateDB) { + func(vmdb *statedb.StateDB) { vmdb.SetState(suite.Address, common.BytesToHash([]byte("key")), common.BytesToHash([]byte("value"))) vmdb.SetState(suite.Address, common.BytesToHash([]byte("filterkey")), common.BytesToHash([]byte("filtervalue"))) }, diff --git a/x/evm/migrations/v3/store_test.go b/x/evm/migrations/v3/store_test.go index 12ff79409a..a01916a6f7 100644 --- a/x/evm/migrations/v3/store_test.go +++ b/x/evm/migrations/v3/store_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/evmos/ethermint/x/evm/keeper" - "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" "github.com/evmos/ethermint/x/evm/vm/geth" "github.com/stretchr/testify/require" @@ -152,7 +151,6 @@ func TestKeyTableCompatiabilityWithKeeper(t *testing.T) { ak, nil, nil, nil, nil, geth.NewEVM, - statedb.New, "", subspace, ) diff --git a/x/evm/statedb/account.go b/x/evm/statedb/account.go new file mode 100644 index 0000000000..26ff52a574 --- /dev/null +++ b/x/evm/statedb/account.go @@ -0,0 +1,27 @@ +package statedb + +import ( + "bytes" + "math/big" +) + +// Account is the Ethereum consensus representation of accounts. +// These objects are stored in the storage of auth module. +type Account struct { + Nonce uint64 + Balance *big.Int + CodeHash []byte +} + +// NewEmptyAccount returns an empty account. +func NewEmptyAccount() *Account { + return &Account{ + Balance: new(big.Int), + CodeHash: emptyCodeHash, + } +} + +// IsContract returns if the account contains contract code. +func (acct Account) IsContract() bool { + return !bytes.Equal(acct.CodeHash, emptyCodeHash) +} diff --git a/x/evm/statedb/config.go b/x/evm/statedb/config.go index 445ae0d47c..d9baa5387f 100644 --- a/x/evm/statedb/config.go +++ b/x/evm/statedb/config.go @@ -23,6 +23,35 @@ import ( "github.com/evmos/ethermint/x/evm/types" ) +// TxConfig encapulates the readonly information of current tx for `StateDB`. +type TxConfig struct { + BlockHash common.Hash // hash of current block + TxHash common.Hash // hash of current tx + TxIndex uint // the index of current transaction + LogIndex uint // the index of next log within current block +} + +// NewTxConfig returns a TxConfig +func NewTxConfig(bhash, thash common.Hash, txIndex, logIndex uint) TxConfig { + return TxConfig{ + BlockHash: bhash, + TxHash: thash, + TxIndex: txIndex, + LogIndex: logIndex, + } +} + +// NewEmptyTxConfig construct an empty TxConfig, +// used in context where there's no transaction, e.g. `eth_call`/`eth_estimateGas`. +func NewEmptyTxConfig(bhash common.Hash) TxConfig { + return TxConfig{ + BlockHash: bhash, + TxHash: common.Hash{}, + TxIndex: 0, + LogIndex: 0, + } +} + // EVMConfig encapsulates common parameters needed to create an EVM to execute a message // It's mainly to reduce the number of method parameters type EVMConfig struct { diff --git a/x/evm/statedb/interfaces.go b/x/evm/statedb/interfaces.go index eb8494d719..6de9599406 100644 --- a/x/evm/statedb/interfaces.go +++ b/x/evm/statedb/interfaces.go @@ -16,6 +16,10 @@ package statedb import ( + "math/big" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" ) @@ -28,3 +32,20 @@ type ExtStateDB interface { vm.StateDB AppendJournalEntry(JournalEntry) } + +// Keeper provide underlying storage of StateDB +type Keeper interface { + // Read methods + GetAccount(ctx sdk.Context, addr common.Address) *Account + GetState(ctx sdk.Context, addr common.Address, key common.Hash) common.Hash + GetCode(ctx sdk.Context, codeHash common.Hash) []byte + // the callback returns false to break early + ForEachStorage(ctx sdk.Context, addr common.Address, cb func(key, value common.Hash) bool) + + // Write methods, only called by `StateDB.Commit()` + SetAccount(ctx sdk.Context, addr common.Address, account Account) error + SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte) + SetCode(ctx sdk.Context, codeHash []byte, code []byte) + SetBalance(ctx sdk.Context, addr common.Address, amount *big.Int) error + DeleteAccount(ctx sdk.Context, addr common.Address) error +} diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index d4d0a0b2aa..0bb391cad6 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -25,8 +25,6 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" - "github.com/evmos/ethermint/x/evm/types" - evm "github.com/evmos/ethermint/x/evm/vm" ) var _ vm.StateDB = &StateDB{} @@ -37,8 +35,8 @@ var _ vm.StateDB = &StateDB{} // * Contracts // * Accounts type StateDB struct { - keeper evm.StateDBKeeper - txConfig types.TxConfig + keeper Keeper + txConfig TxConfig ctx *SnapshotCommitCtx // snapshot-able ctx manager ephemeralStore *EphemeralStore // in-memory temporary data @@ -51,7 +49,7 @@ type StateDB struct { } // New creates a new state from a given trie. -func New(ctx sdk.Context, keeper evm.StateDBKeeper, txConfig types.TxConfig) evm.StateDB { +func New(ctx sdk.Context, keeper Keeper, txConfig TxConfig) *StateDB { return &StateDB{ keeper: keeper, txConfig: txConfig, @@ -69,7 +67,7 @@ func New(ctx sdk.Context, keeper evm.StateDBKeeper, txConfig types.TxConfig) evm } // Keeper returns the underlying `Keeper` -func (s *StateDB) Keeper() evm.StateDBKeeper { +func (s *StateDB) Keeper() Keeper { return s.keeper } @@ -200,10 +198,10 @@ func (s *StateDB) HasSuicided(addr common.Address) bool { func (s *StateDB) AddPreimage(hash common.Hash, preimage []byte) {} //nolint: revive // getOrNewAccount retrieves a state account or create a new account if nil. -func (s *StateDB) getOrNewAccount(addr common.Address) *types.StateDBAccount { +func (s *StateDB) getOrNewAccount(addr common.Address) *Account { account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) if account == nil { - account = types.NewEmptyAccount() + account = NewEmptyAccount() } return account @@ -223,7 +221,7 @@ func (s *StateDB) CreateAccount(addr common.Address) { account := s.keeper.GetAccount(s.ctx.CurrentCtx(), addr) if account == nil { // No account found, create a new one - if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *types.NewEmptyAccount()); err != nil { + if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *NewEmptyAccount()); err != nil { s.SetError(fmt.Errorf("failed to create account: %w", err)) } @@ -235,7 +233,7 @@ func (s *StateDB) CreateAccount(addr common.Address) { // Create a new account -- Must use NewEmptyAccount() so that the // CodeHash is the actual hash of nil, not an empty byte slice - newAccount := types.NewEmptyAccount() + newAccount := NewEmptyAccount() newAccount.Balance = account.Balance if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *newAccount); err != nil { diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index bf34305b3c..08c8f48898 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -12,17 +12,15 @@ import ( "github.com/evmos/ethermint/x/evm/keeper" "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/testutil" - "github.com/evmos/ethermint/x/evm/types" - evm "github.com/evmos/ethermint/x/evm/vm" "github.com/stretchr/testify/suite" ) var ( - address common.Address = common.BigToAddress(big.NewInt(101)) - address2 common.Address = common.BigToAddress(big.NewInt(102)) - address3 common.Address = common.BigToAddress(big.NewInt(103)) - blockHash common.Hash = common.BigToHash(big.NewInt(9999)) - emptyTxConfig types.TxConfig = types.NewEmptyTxConfig(blockHash) + address common.Address = common.BigToAddress(big.NewInt(101)) + address2 common.Address = common.BigToAddress(big.NewInt(102)) + address3 common.Address = common.BigToAddress(big.NewInt(103)) + blockHash common.Hash = common.BigToHash(big.NewInt(9999)) + emptyTxConfig statedb.TxConfig = statedb.NewEmptyTxConfig(blockHash) emptyCodeHash = crypto.Keccak256(nil) ) @@ -38,9 +36,9 @@ func (suite *StateDBTestSuite) TestAccount() { value2 := common.BigToHash(big.NewInt(4)) testCases := []struct { name string - malleate func(evm.StateDB) + malleate func(*statedb.StateDB) }{ - {"non-exist account", func(db evm.StateDB) { + {"non-exist account", func(db *statedb.StateDB) { suite.Require().Equal(false, db.Exist(address)) suite.Require().Equal(true, db.Empty(address)) suite.Require().Equal(big.NewInt(0), db.GetBalance(address)) @@ -48,7 +46,7 @@ func (suite *StateDBTestSuite) TestAccount() { suite.Require().Equal(common.Hash{}, db.GetCodeHash(address)) suite.Require().Equal(uint64(0), db.GetNonce(address)) }}, - {"empty account", func(db evm.StateDB) { + {"empty account", func(db *statedb.StateDB) { db.CreateAccount(address) suite.Require().NoError(db.Commit()) @@ -56,7 +54,7 @@ func (suite *StateDBTestSuite) TestAccount() { acct := keeper.GetAccount(suite.Ctx, address) states := suite.GetAllAccountStorage(suite.Ctx, address) - suite.Require().Equal(types.NewEmptyAccount(), acct) + suite.Require().Equal(statedb.NewEmptyAccount(), acct) suite.Require().Empty(states) suite.Require().False(acct.IsContract()) @@ -68,7 +66,7 @@ func (suite *StateDBTestSuite) TestAccount() { suite.Require().Equal(common.BytesToHash(emptyCodeHash), db.GetCodeHash(address)) suite.Require().Equal(uint64(0), db.GetNonce(address)) }}, - {"suicide", func(db evm.StateDB) { + {"suicide", func(db *statedb.StateDB) { // non-exist account. suite.Require().False(db.Suicide(address)) suite.Require().False(db.HasSuicided(address)) @@ -142,19 +140,19 @@ func (suite *StateDBTestSuite) TestAccountOverride() { func (suite *StateDBTestSuite) TestDBError() { testCases := []struct { name string - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) errContains string }{ { "negative balance", - func(db vm.StateDB) { + func(db *statedb.StateDB) { db.SubBalance(address, big.NewInt(1)) }, "failed to set account for balance subtraction: 0aphoton is smaller than 1aphoton", }, { "multiple errors persist first error", - func(db vm.StateDB) { + func(db *statedb.StateDB) { db.SubBalance(address, big.NewInt(200)) db.SubBalance(address2, big.NewInt(500)) }, @@ -179,22 +177,22 @@ func (suite *StateDBTestSuite) TestBalance() { // NOTE: no need to test overflow/underflow, that is guaranteed by evm implementation. testCases := []struct { name string - malleate func(evm.StateDB) + malleate func(*statedb.StateDB) expBalance *big.Int }{ - {"add balance", func(db evm.StateDB) { + {"add balance", func(db *statedb.StateDB) { db.AddBalance(address, big.NewInt(10)) }, big.NewInt(10)}, - {"sub balance", func(db evm.StateDB) { + {"sub balance", func(db *statedb.StateDB) { db.AddBalance(address, big.NewInt(10)) // get dirty balance suite.Require().Equal(big.NewInt(10), db.GetBalance(address)) db.SubBalance(address, big.NewInt(2)) }, big.NewInt(8)}, - {"add zero balance", func(db evm.StateDB) { + {"add zero balance", func(db *statedb.StateDB) { db.AddBalance(address, big.NewInt(0)) }, big.NewInt(0)}, - {"sub zero balance", func(db evm.StateDB) { + {"sub zero balance", func(db *statedb.StateDB) { db.SubBalance(address, big.NewInt(0)) }, big.NewInt(0)}, } @@ -221,18 +219,18 @@ func (suite *StateDBTestSuite) TestState() { value1 := common.BigToHash(big.NewInt(1)) testCases := []struct { name string - malleate func(evm.StateDB) + malleate func(*statedb.StateDB) expStates map[common.Hash]common.Hash }{ - {"empty state", func(db evm.StateDB) { + {"empty state", func(db *statedb.StateDB) { }, nil}, - {"set empty value", func(db evm.StateDB) { + {"set empty value", func(db *statedb.StateDB) { db.SetState(address, key1, common.Hash{}) }, map[common.Hash]common.Hash{ // empty value still persisted key1: common.Hash{}, }}, - {"noop state change", func(db evm.StateDB) { + {"noop state change", func(db *statedb.StateDB) { // TODO: This doesn't actually change anything compared to committed state. // Is this okay? db.SetState(address, key1, value1) @@ -241,7 +239,7 @@ func (suite *StateDBTestSuite) TestState() { // Still sets the key to an empty value even if there is no overall change key1: common.Hash{}, }}, - {"set state", func(db evm.StateDB) { + {"set state", func(db *statedb.StateDB) { // check empty initial state suite.Require().Equal(common.Hash{}, db.GetState(address, key1)) suite.Require().Equal(common.Hash{}, db.GetCommittedState(address, key1)) @@ -296,15 +294,15 @@ func (suite *StateDBTestSuite) TestCode() { testCases := []struct { name string - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) expCode []byte expCodeHash common.Hash }{ - {"non-exist account", func(vm.StateDB) {}, nil, common.Hash{}}, - {"empty account", func(db vm.StateDB) { + {"non-exist account", func(*statedb.StateDB) {}, nil, common.Hash{}}, + {"empty account", func(db *statedb.StateDB) { db.CreateAccount(address) }, nil, common.BytesToHash(emptyCodeHash)}, - {"set code", func(db vm.StateDB) { + {"set code", func(db *statedb.StateDB) { db.SetCode(address, code) }, code, codeHash}, } @@ -337,39 +335,39 @@ func (suite *StateDBTestSuite) TestRevertSnapshot() { v3 := common.BigToHash(big.NewInt(3)) testCases := []struct { name string - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) }{ - {"set state", func(db vm.StateDB) { + {"set state", func(db *statedb.StateDB) { db.SetState(address, v1, v3) }}, - {"set nonce", func(db vm.StateDB) { + {"set nonce", func(db *statedb.StateDB) { db.SetNonce(address, 10) }}, - {"change balance", func(db vm.StateDB) { + {"change balance", func(db *statedb.StateDB) { db.AddBalance(address, big.NewInt(10)) db.SubBalance(address, big.NewInt(5)) }}, - {"override account", func(db vm.StateDB) { + {"override account", func(db *statedb.StateDB) { db.CreateAccount(address) }}, - {"set code", func(db vm.StateDB) { + {"set code", func(db *statedb.StateDB) { db.SetCode(address, []byte("hello world")) }}, - {"suicide", func(db vm.StateDB) { + {"suicide", func(db *statedb.StateDB) { db.SetState(address, v1, v2) db.SetCode(address, []byte("hello world")) suite.Require().True(db.Suicide(address)) }}, - {"add log", func(db vm.StateDB) { + {"add log", func(db *statedb.StateDB) { db.AddLog(ðtypes.Log{ Address: address, }) }}, - {"add refund", func(db vm.StateDB) { + {"add refund", func(db *statedb.StateDB) { db.AddRefund(10) db.SubRefund(5) }}, - {"access list", func(db vm.StateDB) { + {"access list", func(db *statedb.StateDB) { db.AddAddressToAccessList(address) db.AddSlotToAccessList(address, v1) }}, @@ -448,9 +446,9 @@ func (suite *StateDBTestSuite) TestAccessList() { testCases := []struct { name string - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) }{ - {"add address", func(db vm.StateDB) { + {"add address", func(db *statedb.StateDB) { suite.Require().False(db.AddressInAccessList(address)) db.AddAddressToAccessList(address) suite.Require().True(db.AddressInAccessList(address)) @@ -463,7 +461,7 @@ func (suite *StateDBTestSuite) TestAccessList() { db.AddAddressToAccessList(address) suite.Require().True(db.AddressInAccessList(address)) }}, - {"add slot", func(db vm.StateDB) { + {"add slot", func(db *statedb.StateDB) { addrPresent, slotPresent := db.SlotInAccessList(address, value1) suite.Require().False(addrPresent) suite.Require().False(slotPresent) @@ -484,7 +482,7 @@ func (suite *StateDBTestSuite) TestAccessList() { suite.Require().True(addrPresent) suite.Require().True(slotPresent) }}, - {"prepare access list", func(db vm.StateDB) { + {"prepare access list", func(db *statedb.StateDB) { suite.SetupTest() al := ethtypes.AccessList{{ @@ -518,7 +516,7 @@ func (suite *StateDBTestSuite) TestAccessList() { func (suite *StateDBTestSuite) TestLog() { txHash := common.BytesToHash([]byte("tx")) // use a non-default tx config - txConfig := types.NewTxConfig( + txConfig := statedb.NewTxConfig( blockHash, txHash, 1, 1, @@ -558,18 +556,18 @@ func (suite *StateDBTestSuite) TestLog() { func (suite *StateDBTestSuite) TestRefund() { testCases := []struct { name string - malleate func(vm.StateDB) + malleate func(*statedb.StateDB) expRefund uint64 expPanic bool }{ - {"add refund", func(db vm.StateDB) { + {"add refund", func(db *statedb.StateDB) { db.AddRefund(uint64(10)) }, 10, false}, - {"sub refund", func(db vm.StateDB) { + {"sub refund", func(db *statedb.StateDB) { db.AddRefund(uint64(10)) db.SubRefund(uint64(5)) }, 5, false}, - {"negative refund counter", func(db vm.StateDB) { + {"negative refund counter", func(db *statedb.StateDB) { db.AddRefund(uint64(5)) db.SubRefund(uint64(10)) }, 0, true}, @@ -621,7 +619,7 @@ func (suite *StateDBTestSuite) TestIterateStorage() { suite.Require().Equal(1, len(storage)) } -func CollectContractStorage(db vm.StateDB) map[common.Hash]common.Hash { +func CollectContractStorage(db *statedb.StateDB) map[common.Hash]common.Hash { storage := make(map[common.Hash]common.Hash) db.ForEachStorage(address, func(k, v common.Hash) bool { storage[k] = v diff --git a/x/evm/testutil/suite.go b/x/evm/testutil/suite.go index 9b14e01a83..93da489a21 100644 --- a/x/evm/testutil/suite.go +++ b/x/evm/testutil/suite.go @@ -30,7 +30,6 @@ import ( ethermint "github.com/evmos/ethermint/types" "github.com/evmos/ethermint/x/evm/statedb" "github.com/evmos/ethermint/x/evm/types" - "github.com/evmos/ethermint/x/evm/vm" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -228,11 +227,11 @@ func (suite *TestSuite) Commit() { suite.QueryClient = types.NewQueryClient(queryHelper) } -func (suite *TestSuite) StateDB() vm.StateDB { +func (suite *TestSuite) StateDB() *statedb.StateDB { return statedb.New( suite.Ctx, suite.App.EvmKeeper, - types.NewEmptyTxConfig(common.BytesToHash(suite.Ctx.HeaderHash().Bytes())), + statedb.NewEmptyTxConfig(common.BytesToHash(suite.Ctx.HeaderHash().Bytes())), ) } diff --git a/x/evm/types/statedb.go b/x/evm/types/statedb.go deleted file mode 100644 index 866cfd3441..0000000000 --- a/x/evm/types/statedb.go +++ /dev/null @@ -1,61 +0,0 @@ -package types - -import ( - "bytes" - "math/big" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" -) - -var emptyCodeHash = crypto.Keccak256(nil) - -// StateDBAccount is the Ethereum consensus representation of accounts. -// These objects are stored in the storage of auth module. -type StateDBAccount struct { - Nonce uint64 - Balance *big.Int - CodeHash []byte -} - -// NewEmptyAccount returns an empty account. -func NewEmptyAccount() *StateDBAccount { - return &StateDBAccount{ - Balance: new(big.Int), - CodeHash: emptyCodeHash, - } -} - -// IsContract returns if the account contains contract code. -func (acct StateDBAccount) IsContract() bool { - return !bytes.Equal(acct.CodeHash, emptyCodeHash) -} - -// TxConfig encapulates the readonly information of current tx for `StateDB`. -type TxConfig struct { - BlockHash common.Hash // hash of current block - TxHash common.Hash // hash of current tx - TxIndex uint // the index of current transaction - LogIndex uint // the index of next log within current block -} - -// NewTxConfig returns a TxConfig -func NewTxConfig(bhash, thash common.Hash, txIndex, logIndex uint) TxConfig { - return TxConfig{ - BlockHash: bhash, - TxHash: thash, - TxIndex: txIndex, - LogIndex: logIndex, - } -} - -// NewEmptyTxConfig construct an empty TxConfig, -// used in context where there's no transaction, e.g. `eth_call`/`eth_estimateGas`. -func NewEmptyTxConfig(bhash common.Hash) TxConfig { - return TxConfig{ - BlockHash: bhash, - TxHash: common.Hash{}, - TxIndex: 0, - LogIndex: 0, - } -} diff --git a/x/evm/vm/interface.go b/x/evm/vm/interface.go index b9e4c22138..f1a6f4f707 100644 --- a/x/evm/vm/interface.go +++ b/x/evm/vm/interface.go @@ -18,11 +18,7 @@ package vm import ( "math/big" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/evmos/ethermint/x/evm/types" - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" "github.com/holiman/uint256" @@ -83,44 +79,3 @@ type Constructor func( config vm.Config, customPrecompiles PrecompiledContracts, ) EVM - -// StateDBKeeper provide underlying storage of StateDB -type StateDBKeeper interface { - // Read methods - GetAccount(ctx sdk.Context, addr common.Address) *types.StateDBAccount - GetState(ctx sdk.Context, addr common.Address, key common.Hash) common.Hash - GetCode(ctx sdk.Context, codeHash common.Hash) []byte - // the callback returns false to break early - ForEachStorage(ctx sdk.Context, addr common.Address, cb func(key, value common.Hash) bool) - - // Write methods, only called by `StateDB.Commit()` - SetAccount(ctx sdk.Context, addr common.Address, account types.StateDBAccount) error - SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte) - SetCode(ctx sdk.Context, codeHash []byte, code []byte) - SetBalance(ctx sdk.Context, addr common.Address, amount *big.Int) error - DeleteAccount(ctx sdk.Context, addr common.Address) error -} - -type StateDB interface { - vm.StateDB - - Keeper() StateDBKeeper - - // Additional methods required by x/evm Keeper - Commit() error - Logs() []*ethtypes.Log -} - -// TxConfig provides readonly information of current tx for `StateDB`. -type TxConfig interface { - BlockHash() common.Hash // hash of current block - TxHash() common.Hash // hash of current tx - TxIndex() uint // the index of current transaction - LogIndex() uint // the index of next log within current block -} - -type StateDBConstructor func( - ctx sdk.Context, - keeper StateDBKeeper, - txConfig types.TxConfig, -) StateDB From 3f257053c82673e868fb906fb0205068ac97960f Mon Sep 17 00:00:00 2001 From: drklee3 Date: Fri, 9 Feb 2024 15:30:55 -0800 Subject: [PATCH 42/52] Temporary Revert "update to latest cometbft and cosmos-sdk forks w/ iavl 1.0" This reverts commit b439e9bcdb9d4b0b59876707e7c51cfb6032b174. --- go.mod | 110 +++++++++----------- go.sum | 312 +++++++++++++++++++-------------------------------------- 2 files changed, 147 insertions(+), 275 deletions(-) diff --git a/go.mod b/go.mod index 82c299c7ab..6319508cf3 100644 --- a/go.mod +++ b/go.mod @@ -4,12 +4,12 @@ go 1.20 require ( cosmossdk.io/errors v1.0.0-beta.7 - cosmossdk.io/math v1.0.0-rc.0 + cosmossdk.io/math v1.0.0-beta.4 github.com/armon/go-metrics v0.4.1 github.com/btcsuite/btcd v0.23.4 github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cosmos/cosmos-proto v1.0.0-beta.3 - github.com/cosmos/cosmos-sdk v0.46.16 + github.com/cosmos/cosmos-sdk v0.46.11 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/gogoproto v1.4.3 github.com/cosmos/ibc-go/v6 v6.1.1 @@ -27,32 +27,29 @@ require ( github.com/pkg/errors v0.9.1 github.com/rakyll/statik v0.1.7 github.com/rs/cors v1.8.3 - github.com/spf13/cast v1.5.1 + github.com/spf13/cast v1.5.0 github.com/spf13/cobra v1.6.1 github.com/spf13/viper v1.15.0 github.com/status-im/keycard-go v0.2.0 - github.com/stretchr/testify v1.8.4 - github.com/tendermint/tendermint v0.34.31 + github.com/stretchr/testify v1.8.2 + github.com/tendermint/tendermint v0.34.27 github.com/tendermint/tm-db v0.6.7 github.com/tyler-smith/go-bip39 v1.1.0 - golang.org/x/net v0.18.0 - google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13 - google.golang.org/grpc v1.59.0 + golang.org/x/net v0.8.0 + google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef + google.golang.org/grpc v1.52.0 sigs.k8s.io/yaml v1.3.0 ) require ( - cloud.google.com/go v0.110.8 // indirect - cloud.google.com/go/compute v1.23.0 // indirect + cloud.google.com/go v0.105.0 // indirect + cloud.google.com/go/compute v1.14.0 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v1.1.2 // indirect - cloud.google.com/go/storage v1.30.1 // indirect - cosmossdk.io/log v1.2.0 // indirect + cloud.google.com/go/iam v0.8.0 // indirect + cloud.google.com/go/storage v1.27.0 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/keyring v1.2.1 // indirect - github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect - github.com/DataDog/zstd v1.5.0 // indirect - github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect + github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect github.com/VictoriaMetrics/fastcache v1.6.0 // indirect github.com/Workiva/go-datastructures v1.0.53 // indirect @@ -64,37 +61,29 @@ require ( github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/cespare/xxhash v1.1.0 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect github.com/cockroachdb/apd/v2 v2.0.2 // indirect - github.com/cockroachdb/errors v1.8.1 // indirect - github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect - github.com/cockroachdb/pebble v0.0.0-20220817183557-09c6e030a677 // indirect - github.com/cockroachdb/redact v1.0.8 // indirect - github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect - github.com/cometbft/cometbft-db v0.9.1 // indirect + github.com/cometbft/cometbft-db v0.7.0 // indirect github.com/confio/ics23/go v0.9.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect - github.com/cosmos/cosmos-db v1.0.0 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect - github.com/cosmos/iavl v1.0.0 // indirect - github.com/cosmos/ics23/go v0.10.0 // indirect - github.com/cosmos/ledger-cosmos-go v0.13.1 // indirect + github.com/cosmos/iavl v0.19.5 // indirect + github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/deckarep/golang-set v1.8.0 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgraph-io/badger/v2 v2.2007.4 // indirect github.com/dgraph-io/ristretto v0.1.0 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 // indirect github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf // indirect - github.com/dustin/go-humanize v1.0.1 // indirect + github.com/dustin/go-humanize v1.0.0 // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect github.com/edsrzf/mmap-go v1.0.0 // indirect - github.com/emicklei/dot v1.4.2 // indirect github.com/felixge/httpsnoop v1.0.1 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect @@ -108,17 +97,16 @@ require ( github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/gateway v1.1.0 // indirect - github.com/golang/glog v1.1.2 // indirect + github.com/golang/glog v1.0.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect - github.com/google/s2a-go v0.1.4 // indirect - github.com/google/uuid v1.3.1 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.2.4 // indirect - github.com/googleapis/gax-go/v2 v2.12.0 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.2.1 // indirect + github.com/googleapis/gax-go/v2 v2.7.0 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect @@ -139,18 +127,15 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect - github.com/klauspost/compress v1.16.0 // indirect - github.com/kr/pretty v0.3.1 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/lib/pq v1.10.7 // indirect + github.com/klauspost/compress v1.15.11 // indirect + github.com/lib/pq v1.10.6 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/linxGnu/grocksdb v1.8.6 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/manifoldco/promptui v0.9.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect @@ -158,19 +143,18 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/pelletier/go-toml/v2 v2.0.7 // indirect - github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect + github.com/pelletier/go-toml/v2 v2.0.6 // indirect + github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.14.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.42.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect + github.com/prometheus/common v0.37.0 // indirect + github.com/prometheus/procfs v0.8.0 // indirect github.com/prometheus/tsdb v0.7.1 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/regen-network/cosmos-proto v0.3.1 // indirect github.com/rjeczalik/notify v0.9.1 // indirect - github.com/rogpeppe/go-internal v1.9.0 // indirect - github.com/rs/zerolog v1.30.0 // indirect + github.com/rs/zerolog v1.27.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/spf13/afero v1.9.3 // indirect @@ -178,30 +162,29 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/subosito/gotenv v1.4.2 // indirect - github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect + github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect + github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.5.0 // indirect github.com/tklauser/go-sysconf v0.3.10 // indirect github.com/tklauser/numcpus v0.4.0 // indirect github.com/ulikunitz/xz v0.5.10 // indirect github.com/zondax/hid v0.9.1 // indirect - github.com/zondax/ledger-go v0.14.2 // indirect - go.etcd.io/bbolt v1.3.8 // indirect + github.com/zondax/ledger-go v0.14.1 // indirect + go.etcd.io/bbolt v1.3.6 // indirect go.opencensus.io v0.24.0 // indirect - golang.org/x/crypto v0.15.0 // indirect + golang.org/x/crypto v0.5.0 // indirect golang.org/x/exp v0.0.0-20230131160201-f062dba9d201 // indirect - golang.org/x/oauth2 v0.11.0 // indirect - golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.14.0 // indirect - golang.org/x/term v0.14.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/oauth2 v0.4.0 // indirect + golang.org/x/sync v0.1.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/term v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect golang.org/x/tools v0.7.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/api v0.128.0 // indirect + google.golang.org/api v0.107.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/yaml.v2 v2.4.0 // indirect @@ -213,14 +196,13 @@ replace ( // use cosmos keyring github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 // Use cosmos-sdk fork with staking transfer events, and custom tally handler support - github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.46.16-iavl-v1-kava.1 + github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.46.11-kava.1 // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. // TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0 // use cosmos flavored protobufs github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 - // Downgraded to avoid bugs in following commits which causes "version does not exist" errors github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - github.com/tendermint/tendermint => github.com/kava-labs/cometbft v0.34.31-kava.2 + github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.27 ) diff --git a/go.sum b/go.sum index 4eb67e1005..199cc11e6a 100644 --- a/go.sum +++ b/go.sum @@ -34,8 +34,8 @@ cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w9 cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= -cloud.google.com/go v0.110.8 h1:tyNdfIxjzaWctIiLYOTalaLKZ17SI44SKFW26QbOhME= -cloud.google.com/go v0.110.8/go.mod h1:Iz8AkXJf1qmxC3Oxoep8R1T36w8B92yU29PcBhHO5fk= +cloud.google.com/go v0.105.0 h1:DNtEKRBAAzeS4KyIory52wWHuClNaXJ5x1F7xa4q+5Y= +cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw= cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI= @@ -73,8 +73,8 @@ cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= -cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= -cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= +cloud.google.com/go/compute v1.14.0 h1:hfm2+FfxVmnRlh6LpB7cg1ZNU+5edAHmW679JePztk0= +cloud.google.com/go/compute v1.14.0/go.mod h1:YfLtxrj9sU4Yxv+sXzZkyPjEyPBZfXHUvjxega5vAdo= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= @@ -114,12 +114,13 @@ cloud.google.com/go/gkehub v0.10.0/go.mod h1:UIPwxI0DsrpsVoWpLB0stwKCP+WFVG9+y97 cloud.google.com/go/grafeas v0.2.0/go.mod h1:KhxgtF2hb0P191HlY5besjYm6MqTSTj3LSI+M+ByZHc= cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= cloud.google.com/go/iam v0.5.0/go.mod h1:wPU9Vt0P4UmCux7mqtRu6jcpPAb74cP1fh50J3QpkUc= -cloud.google.com/go/iam v1.1.2 h1:gacbrBdWcoVmGLozRuStX45YKvJtzIjJdAolzUs1sm4= -cloud.google.com/go/iam v1.1.2/go.mod h1:A5avdyVL2tCppe4unb0951eI9jreack+RJ0/d+KUZOU= +cloud.google.com/go/iam v0.8.0 h1:E2osAkZzxI/+8pZcxVLcDtAQx/u+hZXVryUaYQ5O0Kk= +cloud.google.com/go/iam v0.8.0/go.mod h1:lga0/y3iH6CX7sYqypWJ33hf7kkfXJag67naqGESjkE= cloud.google.com/go/language v1.4.0/go.mod h1:F9dRpNFQmJbkaop6g0JhSBXCNlO90e1KWx5iDdxbWic= cloud.google.com/go/language v1.6.0/go.mod h1:6dJ8t3B+lUYfStgls25GusK04NLh3eDLQnWM3mdEbhI= cloud.google.com/go/lifesciences v0.5.0/go.mod h1:3oIKy8ycWGPUyZDR/8RNnTOYevhaMLqh5vLUXs9zvT8= cloud.google.com/go/lifesciences v0.6.0/go.mod h1:ddj6tSX/7BOnhxCSd3ZcETvtNr8NZ6t/iPhY2Tyfu08= +cloud.google.com/go/longrunning v0.3.0 h1:NjljC+FYPV3uh5/OwWT6pVU+doBqMg2x/rZlE+CamDs= cloud.google.com/go/mediatranslation v0.5.0/go.mod h1:jGPUhGTybqsPQn91pNXw0xVHfuJ3leR1wj37oU3y1f4= cloud.google.com/go/mediatranslation v0.6.0/go.mod h1:hHdBCTYNigsBxshbznuIMFNe5QXEowAuNmmC7h8pu5w= cloud.google.com/go/memcache v1.4.0/go.mod h1:rTOfiGZtJX1AaFUrOgsMHX5kAzaTQ8azHiuDoTPzNsE= @@ -176,9 +177,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= cloud.google.com/go/storage v1.23.0/go.mod h1:vOEEDNFnciUMhBeT6hsJIn3ieU5cFRmzeLgDvXzfIXc= +cloud.google.com/go/storage v1.27.0 h1:YOO045NZI9RKfCj1c5A/ZtuuENUc8OAW+gHdGnDgyMQ= cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s= -cloud.google.com/go/storage v1.30.1 h1:uOdMxAs8HExqBlnLtnQyP0YkvbiDpdGShGKtx6U/oNM= -cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7BiccwkR7+P7gN8E= cloud.google.com/go/talent v1.1.0/go.mod h1:Vl4pt9jiHKvOgF9KoZo6Kob9oV4lwd/ZD5Cto54zDRw= cloud.google.com/go/talent v1.2.0/go.mod h1:MoNF9bhFQbiJ6eFD3uSsg0uBALw4n4gaCaEjBw9zo8g= cloud.google.com/go/videointelligence v1.6.0/go.mod h1:w0DIDlVRKtwPCn/C4iwZIJdvC69yInhW0cfi+p546uU= @@ -193,41 +193,29 @@ cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoIS collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/log v1.2.0 h1:BbykkDsutXPSy8RojFB3KZEWyvMsToLy0ykb/ZhsLqQ= -cosmossdk.io/log v1.2.0/go.mod h1:GNSCc/6+DhFIj1aLn/j7Id7PaO8DzNylUZoOYBL9+I4= -cosmossdk.io/math v1.0.0-rc.0 h1:ml46ukocrAAoBpYKMidF0R2tQJ1Uxfns0yH8wqgMAFc= -cosmossdk.io/math v1.0.0-rc.0/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k= +cosmossdk.io/math v1.0.0-beta.4 h1:JtKedVLGzA0vv84xjYmZ75RKG35Kf2WwcFu8IjRkIIw= +cosmossdk.io/math v1.0.0-beta.4/go.mod h1:An0MllWJY6PxibUpnwGk8jOm+a/qIxlKmL5Zyp9NnaM= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFNuPos7vHmWXfszqImLppbc0wEhh6JBfJIUgw= git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA= -github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ+S5sOiDlINkp7+Ef339+Nz5L5XO+cnOHo= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= -github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= -github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw= -github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= +github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= +github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= -github.com/DataDog/zstd v1.5.0 h1:+K/VEwIAaPcHiMtQvpLD4lqW7f0Gk3xdYZmI1hD+CXo= github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= -github.com/HdrHistogram/hdrhistogram-go v1.1.2 h1:5IcZpTvzydCQeHzK4Ef/D5rrSqwxob0t8PQPMybUNFM= -github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= -github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= -github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4KhCrqr6GRJjdC/gNfTdxkIXvuGZZda2VM= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= @@ -242,7 +230,6 @@ github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6/go.mod h1: github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= -github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -277,7 +264,6 @@ github.com/aws/aws-sdk-go-v2/service/route53 v1.1.1/go.mod h1:rLiOUrPLW/Er5kRcQ7 github.com/aws/aws-sdk-go-v2/service/sso v1.1.1/go.mod h1:SuZJxklHxLAXgLTc1iFXbEWkXs7QRTQpCLGaKIprQW0= github.com/aws/aws-sdk-go-v2/service/sts v1.1.1/go.mod h1:Wi0EBZwiz/K44YliU0EKxqTCJGUfYTWXrrBwkq736bM= github.com/aws/smithy-go v1.1.0/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw= -github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -320,7 +306,6 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/bufbuild/protocompile v0.1.0 h1:HjgJBI85hY/qmW5tw/66sNDZ7z0UDdVSi/5r40WHw4s= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= @@ -335,8 +320,8 @@ github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -361,25 +346,14 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/cockroachdb/datadriven v1.0.0/go.mod h1:5Ib8Meh+jk1RlHIXej6Pzevx/NLlNvQB9pmSBZErGA4= -github.com/cockroachdb/errors v1.6.1/go.mod h1:tm6FTP5G81vwJ5lC0SizQo374JNCOPrHyXGitRJoDqM= -github.com/cockroachdb/errors v1.8.1 h1:A5+txlVZfOqFBDa4mGz2bUWSp0aHElvHX2bKkdbQu+Y= -github.com/cockroachdb/errors v1.8.1/go.mod h1:qGwQn6JmZ+oMjuLwjWzUNqblqk0xl4CVV3SQbGwK7Ac= -github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOiXqcou5a3rIlMc7oJbMQkeLk0VQJ7zgqY= -github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= -github.com/cockroachdb/pebble v0.0.0-20220817183557-09c6e030a677 h1:qbb/AE938DFhOajUYh9+OXELpSF9KZw2ZivtmW6eX1Q= -github.com/cockroachdb/pebble v0.0.0-20220817183557-09c6e030a677/go.mod h1:890yq1fUb9b6dGNwssgeUO5vQV9qfXnCPxAJhBQfXw0= -github.com/cockroachdb/redact v1.0.8 h1:8QG/764wK+vmEYoOlfobpe12EQcS81ukx/a4hdVMxNw= -github.com/cockroachdb/redact v1.0.8/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 h1:IKgmqgMQlVJIZj19CdocBeSfSaiCbEBZGKODaixqtHM= -github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2/go.mod h1:8BT+cPK6xvFOcRlk0R8eg+OTkcqI6baNH4xAkpiYVvQ= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI= github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA= github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M= -github.com/cometbft/cometbft-db v0.9.1 h1:MIhVX5ja5bXNHF8EYrThkG9F7r9kSfv8BX4LWaxWJ4M= -github.com/cometbft/cometbft-db v0.9.1/go.mod h1:iliyWaoV0mRwBJoizElCwwRA9Tf7jZJOURcRZF9m60U= +github.com/cometbft/cometbft v0.34.27 h1:ri6BvmwjWR0gurYjywcBqRe4bbwc3QVs9KRcCzgh/J0= +github.com/cometbft/cometbft v0.34.27/go.mod h1:BcCbhKv7ieM0KEddnYXvQZR+pZykTKReJJYf7YC7qhw= +github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo= +github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= @@ -391,12 +365,10 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= -github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0E= -github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= @@ -406,16 +378,14 @@ github.com/cosmos/gogoproto v1.4.3 h1:RP3yyVREh9snv/lsOvmsAPQt8f44LgL281X0IOIhhc github.com/cosmos/gogoproto v1.4.3/go.mod h1:0hLIG5TR7IvV1fme1HCFKjfzW9X2x0Mo+RooWXCnOWU= github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= -github.com/cosmos/iavl v1.0.0 h1:bw6t0Mv/mVCJvlMTOPHWLs5uUE3BRBfVWCRelOzl+so= -github.com/cosmos/iavl v1.0.0/go.mod h1:CmTGqMnRnucjxbjduneZXT+0vPgNElYvdefjX2q9tYc= +github.com/cosmos/iavl v0.19.5 h1:rGA3hOrgNxgRM5wYcSCxgQBap7fW82WZgY78V9po/iY= +github.com/cosmos/iavl v0.19.5/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= github.com/cosmos/ibc-go/v6 v6.1.1 h1:oqqMNyjj6SLQF8rvgCaDGwfdITEIsbhs8F77/8xvRIo= github.com/cosmos/ibc-go/v6 v6.1.1/go.mod h1:NL17FpFAaWjRFVb1T7LUKuOoMSsATPpu+Icc4zL5/Ik= -github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= -github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU= github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIoZuQ7uBoospo5Q9zIpqq6rYCPJDSUdeCJvPM8= -github.com/cosmos/ledger-cosmos-go v0.13.1 h1:12ac9+GwBb9BjP7X5ygpFk09Itwzjzfmg6A2CWFjoVs= -github.com/cosmos/ledger-cosmos-go v0.13.1/go.mod h1:5tv2RVJEd2+Y38TIQN4CRjJeQGyqOEiKJDfqhk5UjqE= +github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA= +github.com/cosmos/ledger-cosmos-go v0.12.2/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI= github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -438,15 +408,13 @@ github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsP github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M= github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= -github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= @@ -471,9 +439,8 @@ github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf h1:Yt+4K30SdjOkRoRRm3v github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= -github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= @@ -483,9 +450,6 @@ github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFP github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts= github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= -github.com/emicklei/dot v1.4.2 h1:UbK6gX4yvrpHKlxuUQicwoAis4zl8Dzwit9SnbBAXWw= -github.com/emicklei/dot v1.4.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -497,37 +461,31 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0= github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s= github.com/ethereum/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= -github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= -github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= -github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= -github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= @@ -535,10 +493,7 @@ github.com/gin-gonic/gin v1.7.0 h1:jGB9xAJQ12AIGNB4HguylppmDK1Am9ppF7XnGXXJuoU= github.com/gin-gonic/gin v1.7.0/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= -github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs= -github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -547,6 +502,8 @@ github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= @@ -556,7 +513,6 @@ github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNV github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= @@ -590,16 +546,14 @@ github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= -github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= -github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog= github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= -github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= +github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -641,7 +595,6 @@ github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219/go.mod h1:/X8TswGSh1pIozq4ZwCfxS0WA5JGXguxk94ar/4c87Y= -github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= @@ -663,7 +616,6 @@ github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8 github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64= @@ -672,8 +624,8 @@ github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPg github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.2.1 h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= -github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -693,20 +645,17 @@ github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= -github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= -github.com/googleapis/enterprise-certificate-proxy v0.2.4 h1:uGy6JWR/uMIILU8wbf+OkstIrNiMjGpEIyhx8f6W7s4= -github.com/googleapis/enterprise-certificate-proxy v0.2.4/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= +github.com/googleapis/enterprise-certificate-proxy v0.2.1 h1:RY7tHKZcRlk788d5WSo/e83gOyyy742E8GSs771ySpg= +github.com/googleapis/enterprise-certificate-proxy v0.2.1/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= @@ -716,8 +665,8 @@ github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99 github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqEF02fYlzkUCyo= github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY= -github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas= -github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU= +github.com/googleapis/gax-go/v2 v2.7.0 h1:IcsPKeInNvYi7eqSaDjiZqDDKu5rsmunY0Y1YupQSSQ= +github.com/googleapis/gax-go/v2 v2.7.0/go.mod h1:TEop28CZZQ2y+c0VxMUmu1lV+fQx57QpBWsYpwqHJx8= github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -729,7 +678,6 @@ github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= @@ -803,10 +751,8 @@ github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204/go.mod h1:ZxNlw5WqJj github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= -github.com/hydrogen18/memlistener v0.0.0-20141126152155-54553eb933fb/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= @@ -824,16 +770,12 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= -github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= -github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= -github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= +github.com/jhump/protoreflect v1.12.1-0.20220721211354-060cc04fc18b h1:izTof8BKh/nE1wrKOrloNA5q4odOarjf+Xpe+4qow98= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -849,44 +791,32 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jsternberg/zap-logfmt v1.0.0/go.mod h1:uvPs/4X51zdkcm5jXl5SYoN+4RK21K8mysFmDaM/h+o= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= -github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= -github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= -github.com/kataras/golog v0.0.9/go.mod h1:12HJgwBIZFNGL0EJnMRhmvGA0PQGx8VFwrZtM4CqbAk= -github.com/kataras/iris/v12 v12.0.1/go.mod h1:udK4vLQKkdDqMGJJVd/msuMtN6hpYJhg/lSzuxjhO+U= -github.com/kataras/neffos v0.0.10/go.mod h1:ZYmJC07hQPW67eKuzlfY7SO3bC0mw83A3j6im82hfqw= -github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d/go.mod h1:NV88laa9UiiDuX9AhMbDPkGYSPugBOV6yTZB1l2K9Z0= -github.com/kava-labs/cometbft v0.34.31-kava.2 h1:jLwdCwCWTrxbvAOvWJ4a01PmnCgT6rgiyk5VO4D0Ku0= -github.com/kava-labs/cometbft v0.34.31-kava.2/go.mod h1:9g9utLtQwhADtb5IgbYbH+FzS1jjpR3P4pjg9q6ehy4= -github.com/kava-labs/cosmos-sdk v0.46.16-iavl-v1-kava.1 h1:ihwrzwhRJe1TGSXkUlQ8psfb/b4c6LnX6UZrca2pm00= -github.com/kava-labs/cosmos-sdk v0.46.16-iavl-v1-kava.1/go.mod h1:7hHfS8oEDY8Hq4ivmDG60uhs1Minv48esUDUKszU058= +github.com/kava-labs/cosmos-sdk v0.46.11-kava.1 h1:3VRpm4zf/gQgmpRVd1p99/2P8ZecAu2FVAXHru5caIo= +github.com/kava-labs/cosmos-sdk v0.46.11-kava.1/go.mod h1:bG4AkW9bqc8ycrryyKGQEl3YV9BY2wr6HggGq8kvcgM= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.9.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= -github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= -github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -895,28 +825,24 @@ github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/labstack/echo/v4 v4.1.11/go.mod h1:i541M3Fj6f76NZtHSj7TXnyM8n2gaodfvfxNnFqi74g= github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4FW1e6jwpg= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= -github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs= +github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/linxGnu/grocksdb v1.8.6 h1:O7I6SIGPrypf3f/gmrrLUBQDKfO8uOoYdWf4gLS06tc= -github.com/linxGnu/grocksdb v1.8.6/go.mod h1:xZCIb5Muw+nhbDK4Y5UJuOrin5MceOuiXkVUR7vp4WY= github.com/lucasjones/reggen v0.0.0-20180717132126-cdb49ff09d77/go.mod h1:5ELEyG+X8f+meRWHuqUOewBOhvHkl7M76pdGEansxW4= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= @@ -941,9 +867,8 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= @@ -951,13 +876,9 @@ github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/Qd github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-tty v0.0.0-20180907095812-13ff1204f104/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE= -github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed/go.mod h1:dSsfyI2zABAdhcbvkXqgxOxrCsbYeHCPgrZkku60dSg= -github.com/mediocregopher/radix/v3 v3.3.0/go.mod h1:EmfVyvspXz1uZEyPBMyGK+kjWiKQGvsUt6O3Pj+LDCQ= -github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 h1:QRUSJEgZn2Snx0EmT/QLXibWjSUDjKWvXIT19NBVp94= @@ -987,8 +908,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= -github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= @@ -1001,9 +922,7 @@ github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= -github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM= github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= -github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4= github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= @@ -1020,7 +939,6 @@ github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0= github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo/v2 v2.9.1 h1:zie5Ly042PD3bsCvsSOPvRnFwyo3rKe64TJlD6nu0mk= @@ -1052,21 +970,17 @@ github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144T github.com/paulbellamy/ratecounter v0.2.0/go.mod h1:Hfx1hDpSGoqxkVVpBi/IlYD7kChlfo5C6hzIHwPqfFE= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us= -github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= +github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= +github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/peterh/liner v1.0.1-0.20180619022028-8c1271fcf47f/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc= github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= +github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= -github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 h1:hDSdbBuw3Lefr6R18ax0tZ2BJeNB3NehB3trOwYBsdU= -github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= -github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -1083,6 +997,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -1101,16 +1017,20 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= +github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= +github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= @@ -1128,31 +1048,27 @@ github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRr github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo= github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= -github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= -github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= +github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.27.0 h1:1T7qCieN22GVc8S4Q2yuexzBb1EqjbgjSH9RohbMjKs= +github.com/rs/zerolog v1.27.0/go.mod h1:7frBqO0oezxmnO7GF86FY++uy8I0Tk/If5ni1G9Qc0U= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= -github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -1172,8 +1088,8 @@ github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk= github.com/spf13/afero v1.9.3/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= -github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= +github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= @@ -1210,12 +1126,14 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tendermint/tm-db v0.6.7 h1:fE00Cbl0jayAoqlExN6oyQJ7fR/ZtoVOmvPJ//+shu8= @@ -1254,27 +1172,17 @@ github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/cli/v2 v2.10.2 h1:x3p8awjp/2arX+Nl/G2040AZpOCHS/eMJJ1/a+mye4Y= -github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/willf/bitset v1.1.3/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= -github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE= -github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -1283,11 +1191,11 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo= github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= -github.com/zondax/ledger-go v0.14.2 h1:NDaba434N7JUVKg4P4nFv6TOjSkUosYb9sdiw3c61Zk= -github.com/zondax/ledger-go v0.14.2/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2feOQv8K320= +github.com/zondax/ledger-go v0.14.1 h1:Pip65OOl4iJ84WTpA4BKChvOufMhhbxED3BaihoZN4c= +github.com/zondax/ledger-go v0.14.1/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2feOQv8K320= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= -go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= +go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= +go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -1333,9 +1241,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= +golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1350,7 +1257,6 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20200513190911-00229845015e/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/exp v0.0.0-20230131160201-f062dba9d201 h1:BEABXpNXLEz0WxtA+6CQIz2xkg80e+1zrhWyMcq8VzE= golang.org/x/exp v0.0.0-20230131160201-f062dba9d201/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= @@ -1393,7 +1299,6 @@ golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -1403,7 +1308,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1433,10 +1337,10 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -1449,8 +1353,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= -golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1476,8 +1380,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.11.0 h1:vPL4xzxBM4niKCW6g9whtaWVXTJf1U5e4aZxxFx/gbU= -golang.org/x/oauth2 v0.11.0/go.mod h1:LdF7O/8bLR/qWK9DrpXmbHLTouvRHK0SgJl0GmDBchk= +golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M= +golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1492,8 +1396,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1550,6 +1454,7 @@ golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1569,6 +1474,7 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1579,12 +1485,12 @@ golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210909193231-528a39cd75f3/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1601,15 +1507,14 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8= -golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= +golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1619,10 +1524,9 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1633,14 +1537,12 @@ golang.org/x/time v0.1.0 h1:xYY+Bajn2a7VBmTM5GikTmnK8ZuX8YgnQCqZpbBNtmA= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190327201419-c70d86f8b7cf/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= @@ -1710,8 +1612,6 @@ golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNq gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.6.0/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU= -gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= -gonum.org/v1/gonum v0.11.0 h1:f1IJhK4Km5tBJmaiJXtk/PkL4cdVX6J+tGiM187uT5E= gonum.org/v1/netlib v0.0.0-20181029234149-ec6d1f5cefe6/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= @@ -1764,8 +1664,8 @@ google.golang.org/api v0.96.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ google.golang.org/api v0.97.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= google.golang.org/api v0.98.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= google.golang.org/api v0.100.0/go.mod h1:ZE3Z2+ZOr87Rx7dqFsdRQkRBk36kDtp/h+QpHbB7a70= -google.golang.org/api v0.128.0 h1:RjPESny5CnQRn9V6siglged+DZCgfu9l6mO9dkX9VOg= -google.golang.org/api v0.128.0/go.mod h1:Y611qgqaE92On/7g65MQgxYul3c0rEB894kniWLY750= +google.golang.org/api v0.107.0 h1:I2SlFjD8ZWabaIFOfeEDg3pf0BHJDh6iYQ1ic3Yu/UU= +google.golang.org/api v0.107.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1775,7 +1675,6 @@ google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCID google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -1886,13 +1785,8 @@ google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqw google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0= -google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk= -google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13 h1:U7+wNaVuSTaUqNvK2+osJ9ejEZxbjHHk8F2b6Hpx0AE= -google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:RdyHbowztCGQySiCvQPgWQWgWhGnouTdCflKoDBt32U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c h1:jHkCUWkseRf+W+edG5hMzr/Uh1xkDREY4caybAq4dpY= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c/go.mod h1:4cYg8o5yUbm77w8ZX00LhMVNl/YVBFJRYWDc0uYWMs0= -google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef h1:uQ2vjV/sHTsWSqdKeLqmwitzgvjMl7o4IdtHwUDXSJY= +google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1935,8 +1829,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= -google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= +google.golang.org/grpc v1.52.0 h1:kd48UiU7EHsV4rnLyOJRuP/Il/UHE7gdDAQ+SZI7nZk= +google.golang.org/grpc v1.52.0/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1953,13 +1847,12 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 h1:KR8+MyP7/qOlV+8Af01LtjL04bu7on42eVsxT4EyBQk= +google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -1970,7 +1863,6 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= @@ -1993,9 +1885,7 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= -gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From 757e3570d278ea719c2993ed1983178350f81737 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Tue, 13 Feb 2024 10:47:44 -0800 Subject: [PATCH 43/52] Add temp test for logging tracing state --- x/evm/keeper/keeper_test.go | 8 ++--- x/evm/keeper/state_transition_test.go | 49 +++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/x/evm/keeper/keeper_test.go b/x/evm/keeper/keeper_test.go index 549d103a5f..a0c9a95cf6 100644 --- a/x/evm/keeper/keeper_test.go +++ b/x/evm/keeper/keeper_test.go @@ -6,8 +6,8 @@ import ( "os" "testing" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" + // . "github.com/onsi/ginkgo/v2" + // . "github.com/onsi/gomega" sdkmath "cosmossdk.io/math" @@ -42,8 +42,8 @@ func TestKeeperTestSuite(t *testing.T) { suite.Run(t, s) // Run Ginkgo integration tests - RegisterFailHandler(Fail) - RunSpecs(t, "Keeper Suite") + // RegisterFailHandler(Fail) + // RunSpecs(t, "Keeper Suite") } func (suite *KeeperTestSuite) TestBaseFee() { diff --git a/x/evm/keeper/state_transition_test.go b/x/evm/keeper/state_transition_test.go index 76334d40fd..52365fb929 100644 --- a/x/evm/keeper/state_transition_test.go +++ b/x/evm/keeper/state_transition_test.go @@ -1,9 +1,12 @@ package keeper_test import ( + "bytes" "fmt" "math" "math/big" + "os" + "time" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -675,10 +678,14 @@ func (suite *KeeperTestSuite) createContractGethMsg(nonce uint64, signer ethtype func (suite *KeeperTestSuite) createContractMsgTx(nonce uint64, signer ethtypes.Signer, cfg *params.ChainConfig, gasPrice *big.Int) (*types.MsgEthereumTx, error) { contractCreateTx := ðtypes.AccessListTx{ GasPrice: gasPrice, - Gas: params.TxGasContractCreation, + Gas: params.TxGasContractCreation * 2, To: nil, - Data: []byte("contract_data"), - Nonce: nonce, + // Minimal contract data + // https://ethereum.stackexchange.com/questions/40757/what-is-the-shortest-bytecode-that-will-publish-a-contract-with-non-zero-bytecod + // Using the previous string "contract_data" as contract code may cause + // an error as it includes 0x5f which is PUSH0, only on Shanghai and later + Data: common.Hex2Bytes("0x3859818153F3"), + Nonce: nonce, } ethTx := ethtypes.NewTx(contractCreateTx) ethMsg := &types.MsgEthereumTx{} @@ -719,3 +726,39 @@ func (suite *KeeperTestSuite) TestGetProposerAddress() { }) } } + +func (suite *KeeperTestSuite) TestConsistency() { + keeperParams := suite.App.EvmKeeper.GetParams(suite.Ctx) + msg, err := suite.createContractGethMsg( + suite.StateDB().GetNonce(suite.Address), + ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()), + keeperParams.ChainConfig.EthereumConfig(suite.App.EvmKeeper.ChainID()), + big.NewInt(1), + ) + suite.Require().NoError(err) + + var tracer bytes.Buffer + + suite.App.SetCommitMultiStoreTracer(&tracer) + // Commit so the ctx is updated with the tracer + suite.Commit() + + suite.Require().True( + suite.Ctx.MultiStore().TracingEnabled(), + "tracer should be enabled", + ) + + res, err := suite.App.EvmKeeper.ApplyMessage(suite.Ctx, msg, nil, true) + suite.Require().NoError(err) + suite.Require().Empty(res.VmError) + + suite.Require().NotEmpty(tracer.Bytes(), "tracer should have recorded something") + suite.T().Logf("Logs: %v", res.Logs) + + // Log the tracer contents + suite.T().Logf("Tracer (%v): %s", tracer.Len(), tracer.String()) + + // Write tracer contents to file + err = os.WriteFile(fmt.Sprintf("tracer-%v.log", time.Now().Unix()), tracer.Bytes(), 0644) + suite.Require().NoError(err) +} From da96446b22b95b30676dfaba9c15484c7fb0eea5 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Tue, 13 Feb 2024 14:52:46 -0800 Subject: [PATCH 44/52] temp: Prevent trace in snapshots, deploy test contract & log commit hash --- x/evm/keeper/state_transition_test.go | 24 ++++++++++-------------- x/evm/statedb/ctx.go | 4 ++++ x/evm/testutil/suite.go | 6 ++++-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/x/evm/keeper/state_transition_test.go b/x/evm/keeper/state_transition_test.go index 52365fb929..8c18291f71 100644 --- a/x/evm/keeper/state_transition_test.go +++ b/x/evm/keeper/state_transition_test.go @@ -728,15 +728,6 @@ func (suite *KeeperTestSuite) TestGetProposerAddress() { } func (suite *KeeperTestSuite) TestConsistency() { - keeperParams := suite.App.EvmKeeper.GetParams(suite.Ctx) - msg, err := suite.createContractGethMsg( - suite.StateDB().GetNonce(suite.Address), - ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()), - keeperParams.ChainConfig.EthereumConfig(suite.App.EvmKeeper.ChainID()), - big.NewInt(1), - ) - suite.Require().NoError(err) - var tracer bytes.Buffer suite.App.SetCommitMultiStoreTracer(&tracer) @@ -748,17 +739,22 @@ func (suite *KeeperTestSuite) TestConsistency() { "tracer should be enabled", ) - res, err := suite.App.EvmKeeper.ApplyMessage(suite.Ctx, msg, nil, true) - suite.Require().NoError(err) - suite.Require().Empty(res.VmError) + addr := suite.DeployTestContract(suite.T(), suite.Address, big.NewInt(10000000000000)) + res := suite.Commit() suite.Require().NotEmpty(tracer.Bytes(), "tracer should have recorded something") - suite.T().Logf("Logs: %v", res.Logs) // Log the tracer contents suite.T().Logf("Tracer (%v): %s", tracer.Len(), tracer.String()) // Write tracer contents to file - err = os.WriteFile(fmt.Sprintf("tracer-%v.log", time.Now().Unix()), tracer.Bytes(), 0644) + err := os.WriteFile(fmt.Sprintf("tracer-%v.log", time.Now().Unix()), tracer.Bytes(), 0644) suite.Require().NoError(err) + + // Get block hash + suite.T().Logf("commitID.Hash: %x", res.Data) + + // Check the state + acc := suite.App.EvmKeeper.GetAccount(suite.Ctx, addr) + suite.Require().True(acc.IsContract()) } diff --git a/x/evm/statedb/ctx.go b/x/evm/statedb/ctx.go index 9ff05e0881..3439cf34b9 100644 --- a/x/evm/statedb/ctx.go +++ b/x/evm/statedb/ctx.go @@ -65,6 +65,10 @@ func (c *SnapshotCommitCtx) Snapshot( // Branch off a new CacheMultiStore + write function newCtx, newWrite := c.CurrentCtx().CacheContext() + // Disable tracing for the branched context + ms := newCtx.MultiStore().SetTracer(nil) + newCtx = newCtx.WithMultiStore(ms) + // Save the new snapshot to the list c.snapshots = append(c.snapshots, CtxSnapshot{ id: id, diff --git a/x/evm/testutil/suite.go b/x/evm/testutil/suite.go index 93da489a21..cfd245afb2 100644 --- a/x/evm/testutil/suite.go +++ b/x/evm/testutil/suite.go @@ -211,8 +211,8 @@ func (suite *TestSuite) EvmDenom() string { } // Commit and begin new block -func (suite *TestSuite) Commit() { - _ = suite.App.Commit() +func (suite *TestSuite) Commit() abci.ResponseCommit { + res := suite.App.Commit() header := suite.Ctx.BlockHeader() header.Height++ suite.App.BeginBlock(abci.RequestBeginBlock{ @@ -225,6 +225,8 @@ func (suite *TestSuite) Commit() { queryHelper := baseapp.NewQueryServerTestHelper(suite.Ctx, suite.App.InterfaceRegistry()) types.RegisterQueryServer(queryHelper, suite.App.EvmKeeper) suite.QueryClient = types.NewQueryClient(queryHelper) + + return res } func (suite *TestSuite) StateDB() *statedb.StateDB { From fbb061d802b2b3610e4df704cc033c3921cac680 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Tue, 13 Feb 2024 15:53:35 -0800 Subject: [PATCH 45/52] Make tests deterministic for consistent output hash, use fixed val keys --- app/utils.go | 12 ++++++++++-- x/evm/keeper/state_transition_test.go | 2 -- x/evm/testutil/suite.go | 18 ++++++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/utils.go b/app/utils.go index b2f4f181e5..1115013318 100644 --- a/app/utils.go +++ b/app/utils.go @@ -17,17 +17,20 @@ package app import ( "encoding/json" + "fmt" "time" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/mock" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/ethereum/go-ethereum/common" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/evmos/ethermint/encoding" @@ -101,7 +104,9 @@ func SetupWithDB(isCheckTx bool, patchGenesis func(*EthermintApp, simapp.Genesis // NewTestGenesisState generate genesis state with single validator func NewTestGenesisState(codec codec.Codec) simapp.GenesisState { - privVal := mock.NewPV() + key := ed25519.GenPrivKeyFromSecret([]byte("constant seed")) + privVal := mock.PV{PrivKey: key} + pubKey, err := privVal.GetPubKey() if err != nil { panic(err) @@ -111,7 +116,10 @@ func NewTestGenesisState(codec codec.Codec) simapp.GenesisState { valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) // generate genesis account - senderPrivKey := secp256k1.GenPrivKey() + senderPrivKey := secp256k1.PrivKey{ + Key: common.Hex2Bytes("6b65793a225c745c3337355c33363627365c333735476c5c3331375f5c323530305c3031375c303237375c3337365c3234315c3336355c323136247d475c3237316a3c5c3336365f785c3337353b5c3336305c3031362220"), + } + fmt.Printf("senderPrivKey: %x\n", senderPrivKey) acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), diff --git a/x/evm/keeper/state_transition_test.go b/x/evm/keeper/state_transition_test.go index 8c18291f71..d31c0b7de5 100644 --- a/x/evm/keeper/state_transition_test.go +++ b/x/evm/keeper/state_transition_test.go @@ -751,10 +751,8 @@ func (suite *KeeperTestSuite) TestConsistency() { err := os.WriteFile(fmt.Sprintf("tracer-%v.log", time.Now().Unix()), tracer.Bytes(), 0644) suite.Require().NoError(err) - // Get block hash suite.T().Logf("commitID.Hash: %x", res.Data) - // Check the state acc := suite.App.EvmKeeper.GetAccount(suite.Ctx, addr) suite.Require().True(acc.IsContract()) } diff --git a/x/evm/testutil/suite.go b/x/evm/testutil/suite.go index cfd245afb2..33b53920f4 100644 --- a/x/evm/testutil/suite.go +++ b/x/evm/testutil/suite.go @@ -93,11 +93,17 @@ func (suite *TestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { suite.Address = common.BytesToAddress(priv.PubKey().Address().Bytes()) suite.Signer = tests.NewSigner(priv) + suite.Require().Equal("0x71562b71999873DB5b286dF957af199Ec94617F7", suite.Address.Hex()) + // consensus key - priv, err = ethsecp256k1.GenerateKey() + priv = ðsecp256k1.PrivKey{ + Key: common.Hex2Bytes("a249d5fbd4516fde5765dbd763b93c3542bf2748b6cd512eb96e0862b3583261"), + } require.NoError(t, err) suite.ConsAddress = sdk.ConsAddress(priv.PubKey().Address()) + suite.Require().Equal("cosmosvalcons1505eel9r7tnacxyzsqysysudwgucvhl53t7p70", suite.ConsAddress.String()) + suite.App = app.Setup(checkTx, func(app *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState { feemarketGenesis := feemarkettypes.DefaultGenesisState() if suite.EnableFeemarket { @@ -154,9 +160,10 @@ func (suite *TestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { } suite.Ctx = suite.App.BaseApp.NewContext(checkTx, tmproto.Header{ - Height: 1, - ChainID: "ethermint_9000-1", - Time: time.Now().UTC(), + Height: 1, + ChainID: "ethermint_9000-1", + // Fixed date to have deterministic tests + Time: time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC), ProposerAddress: suite.ConsAddress.Bytes(), Version: tmversion.Consensus{ Block: version.BlockProtocol, @@ -189,6 +196,9 @@ func (suite *TestSuite) SetupAppWithT(checkTx bool, t require.TestingT) { suite.App.AccountKeeper.SetAccount(suite.Ctx, acc) valAddr := sdk.ValAddress(suite.Address.Bytes()) + + suite.Equal("cosmosvaloper1w9tzkuvenpeakkegdhu40tcenmy5v9lhc9rt8k", valAddr.String()) + validator, err := stakingtypes.NewValidator(valAddr, priv.PubKey(), stakingtypes.Description{}) require.NoError(t, err) err = suite.App.StakingKeeper.SetValidatorByConsAddr(suite.Ctx, validator) From 625b99488c2117e06d75cb065f88bb88d8a2c69c Mon Sep 17 00:00:00 2001 From: drklee3 Date: Tue, 13 Feb 2024 15:59:10 -0800 Subject: [PATCH 46/52] Add hash check --- x/evm/keeper/state_transition_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/x/evm/keeper/state_transition_test.go b/x/evm/keeper/state_transition_test.go index d31c0b7de5..466fc43c9b 100644 --- a/x/evm/keeper/state_transition_test.go +++ b/x/evm/keeper/state_transition_test.go @@ -753,6 +753,12 @@ func (suite *KeeperTestSuite) TestConsistency() { suite.T().Logf("commitID.Hash: %x", res.Data) + suite.Require().Equal( + common.Hex2Bytes("e14ebe2d29a2ddef2a782f0c80b0c7d8d2caa68727b6b990ed348014374fe937"), + res.Data, + "commitID.Hash should match", + ) + acc := suite.App.EvmKeeper.GetAccount(suite.Ctx, addr) suite.Require().True(acc.IsContract()) } From 98a08ffeffb4a283971bb95b150f668644b90c30 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Wed, 14 Feb 2024 15:30:23 -0800 Subject: [PATCH 47/52] Create reverted tx --- x/evm/keeper/grpc_query_test.go | 12 +++++----- x/evm/keeper/state_transition_test.go | 23 +++++++++++-------- x/evm/testutil/suite.go | 33 ++++++++++++++++++++------- 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/x/evm/keeper/grpc_query_test.go b/x/evm/keeper/grpc_query_test.go index 520dc79f67..53230928c9 100644 --- a/x/evm/keeper/grpc_query_test.go +++ b/x/evm/keeper/grpc_query_test.go @@ -842,8 +842,8 @@ func (suite *KeeperTestSuite) TestTraceTx() { contractAddr := suite.DeployTestContract(suite.T(), suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) suite.Commit() // Generate token transfer transaction - firstTx := suite.TransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) - txMsg = suite.TransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + firstTx := suite.MustTransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + txMsg = suite.MustTransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) suite.Commit() predecessors = append(predecessors, firstTx) @@ -942,7 +942,7 @@ func (suite *KeeperTestSuite) TestTraceTx() { contractAddr := suite.DeployTestContract(suite.T(), suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) suite.Commit() // Generate token transfer transaction - txMsg = suite.TransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + txMsg = suite.MustTransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) suite.Commit() tc.malleate() @@ -1062,8 +1062,8 @@ func (suite *KeeperTestSuite) TestTraceBlock() { contractAddr := suite.DeployTestContract(suite.T(), suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) suite.Commit() // create multiple transactions in the same block - firstTx := suite.TransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) - secondTx := suite.TransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + firstTx := suite.MustTransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + secondTx := suite.MustTransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) suite.Commit() // overwrite txs to include only the ones on new block txs = append([]*types.MsgEthereumTx{}, firstTx, secondTx) @@ -1118,7 +1118,7 @@ func (suite *KeeperTestSuite) TestTraceBlock() { contractAddr := suite.DeployTestContract(suite.T(), suite.Address, sdkmath.NewIntWithDecimal(1000, 18).BigInt()) suite.Commit() // Generate token transfer transaction - txMsg := suite.TransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) + txMsg := suite.MustTransferERC20Token(suite.T(), contractAddr, suite.Address, common.HexToAddress("0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec"), sdkmath.NewIntWithDecimal(1, 18).BigInt()) suite.Commit() txs = append(txs, txMsg) diff --git a/x/evm/keeper/state_transition_test.go b/x/evm/keeper/state_transition_test.go index 466fc43c9b..635c5bdd19 100644 --- a/x/evm/keeper/state_transition_test.go +++ b/x/evm/keeper/state_transition_test.go @@ -729,7 +729,6 @@ func (suite *KeeperTestSuite) TestGetProposerAddress() { func (suite *KeeperTestSuite) TestConsistency() { var tracer bytes.Buffer - suite.App.SetCommitMultiStoreTracer(&tracer) // Commit so the ctx is updated with the tracer suite.Commit() @@ -739,26 +738,32 @@ func (suite *KeeperTestSuite) TestConsistency() { "tracer should be enabled", ) - addr := suite.DeployTestContract(suite.T(), suite.Address, big.NewInt(10000000000000)) - res := suite.Commit() - + contractAddr := suite.DeployTestContract(suite.T(), suite.Address, big.NewInt(100)) suite.Require().NotEmpty(tracer.Bytes(), "tracer should have recorded something") + _, _, err := suite.TransferERC20Token(contractAddr, suite.Address, common.Address{1}, big.NewInt(1000)) + suite.Require().Error(err) + + res := suite.Commit() + // Log the tracer contents suite.T().Logf("Tracer (%v): %s", tracer.Len(), tracer.String()) // Write tracer contents to file - err := os.WriteFile(fmt.Sprintf("tracer-%v.log", time.Now().Unix()), tracer.Bytes(), 0644) + err = os.WriteFile(fmt.Sprintf("tracer-ctx-%v.log", time.Now().Unix()), tracer.Bytes(), 0644) suite.Require().NoError(err) suite.T().Logf("commitID.Hash: %x", res.Data) - suite.Require().Equal( - common.Hex2Bytes("e14ebe2d29a2ddef2a782f0c80b0c7d8d2caa68727b6b990ed348014374fe937"), + expectedHash := common.Hex2Bytes("10eaacd8ba1a2763c7ef1ac1090f7687baa299d2330ea1d593860a7aece3ecb5") + suite.Require().Equalf( + expectedHash, + res.Data, + "commitID.Hash should match, expected %x, got %x", + expectedHash, res.Data, - "commitID.Hash should match", ) - acc := suite.App.EvmKeeper.GetAccount(suite.Ctx, addr) + acc := suite.App.EvmKeeper.GetAccount(suite.Ctx, contractAddr) suite.Require().True(acc.IsContract()) } diff --git a/x/evm/testutil/suite.go b/x/evm/testutil/suite.go index 33b53920f4..26ac7ff0c6 100644 --- a/x/evm/testutil/suite.go +++ b/x/evm/testutil/suite.go @@ -306,20 +306,33 @@ func (suite *TestSuite) DeployTestContract(t require.TestingT, owner common.Addr return crypto.CreateAddress(suite.Address, nonce) } -func (suite *TestSuite) TransferERC20Token(t require.TestingT, contractAddr, from, to common.Address, amount *big.Int) *types.MsgEthereumTx { +func (suite *TestSuite) MustTransferERC20Token(t require.TestingT, contractAddr, from, to common.Address, amount *big.Int) *types.MsgEthereumTx { + ercTransferTx, rsp, err := suite.TransferERC20Token(contractAddr, from, to, amount) + require.NoError(t, err) + require.Empty(t, rsp.VmError) + return ercTransferTx +} + +func (suite *TestSuite) TransferERC20Token(contractAddr, from, to common.Address, amount *big.Int) (*types.MsgEthereumTx, *types.MsgEthereumTxResponse, error) { ctx := sdk.WrapSDKContext(suite.Ctx) chainID := suite.App.EvmKeeper.ChainID() transferData, err := types.ERC20Contract.ABI.Pack("transfer", to, amount) - require.NoError(t, err) + if err != nil { + return nil, nil, err + } args, err := json.Marshal(&types.TransactionArgs{To: &contractAddr, From: &from, Data: (*hexutil.Bytes)(&transferData)}) - require.NoError(t, err) + if err != nil { + return nil, nil, err + } res, err := suite.QueryClient.EstimateGas(ctx, &types.EthCallRequest{ Args: args, GasCap: 25_000_000, ProposerAddress: suite.Ctx.BlockHeader().ProposerAddress, }) - require.NoError(t, err) + if err != nil { + return nil, nil, err + } nonce := suite.App.EvmKeeper.GetNonce(suite.Ctx, suite.Address) @@ -353,11 +366,15 @@ func (suite *TestSuite) TransferERC20Token(t require.TestingT, contractAddr, fro ercTransferTx.From = suite.Address.Hex() err = ercTransferTx.Sign(ethtypes.LatestSignerForChainID(chainID), suite.Signer) - require.NoError(t, err) + if err != nil { + return nil, nil, err + } rsp, err := suite.App.EvmKeeper.EthereumTx(ctx, ercTransferTx) - require.NoError(t, err) - require.Empty(t, rsp.VmError) - return ercTransferTx + if err != nil { + return nil, rsp, err + } + + return ercTransferTx, rsp, nil } // DeployTestMessageCall deploy a test erc20 contract and returns the contract address From 0e03788ff11ecfd59dc5b6c8cb80d666c9d326ac Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 15 Feb 2024 10:39:16 -0800 Subject: [PATCH 48/52] Revert go.mod changes to match mainnet version --- go.mod | 14 +-- go.sum | 391 +++------------------------------------------------------ 2 files changed, 25 insertions(+), 380 deletions(-) diff --git a/go.mod b/go.mod index 6319508cf3..b4c276a53b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/evmos/ethermint -go 1.20 +go 1.19 require ( cosmossdk.io/errors v1.0.0-beta.7 @@ -12,7 +12,7 @@ require ( github.com/cosmos/cosmos-sdk v0.46.11 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/gogoproto v1.4.3 - github.com/cosmos/ibc-go/v6 v6.1.1 + github.com/cosmos/ibc-go/v6 v6.1.0 github.com/davecgh/go-spew v1.1.1 github.com/ethereum/go-ethereum v1.10.26 github.com/gogo/protobuf v1.3.3 @@ -53,7 +53,7 @@ require ( github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect github.com/VictoriaMetrics/fastcache v1.6.0 // indirect github.com/Workiva/go-datastructures v1.0.53 // indirect - github.com/aws/aws-sdk-go v1.44.122 // indirect + github.com/aws/aws-sdk-go v1.40.45 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.0 // indirect @@ -103,7 +103,7 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/orderedcode v0.0.1 // indirect - github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect + github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.1 // indirect github.com/googleapis/gax-go/v2 v2.7.0 // indirect @@ -113,7 +113,7 @@ require ( github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.7.1 // indirect + github.com/hashicorp/go-getter v1.6.1 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.6.0 // indirect @@ -139,7 +139,7 @@ require ( github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/mitchellh/go-testing-interface v1.14.1 // indirect + github.com/mitchellh/go-testing-interface v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect @@ -168,7 +168,7 @@ require ( github.com/tidwall/btree v1.5.0 // indirect github.com/tklauser/go-sysconf v0.3.10 // indirect github.com/tklauser/numcpus v0.4.0 // indirect - github.com/ulikunitz/xz v0.5.10 // indirect + github.com/ulikunitz/xz v0.5.8 // indirect github.com/zondax/hid v0.9.1 // indirect github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.6 // indirect diff --git a/go.sum b/go.sum index 199cc11e6a..45c94faa47 100644 --- a/go.sum +++ b/go.sum @@ -19,177 +19,36 @@ cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHOb cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= -cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= -cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= -cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= -cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= -cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= -cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= cloud.google.com/go v0.105.0 h1:DNtEKRBAAzeS4KyIory52wWHuClNaXJ5x1F7xa4q+5Y= cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= -cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw= -cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= -cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI= -cloud.google.com/go/analytics v0.12.0/go.mod h1:gkfj9h6XRf9+TS4bmuhPEShsh3hH8PAZzm/41OOhQd4= -cloud.google.com/go/area120 v0.5.0/go.mod h1:DE/n4mp+iqVyvxHN41Vf1CR602GiHQjFPusMFW6bGR4= -cloud.google.com/go/area120 v0.6.0/go.mod h1:39yFJqWVgm0UZqWTOdqkLhjoC7uFfgXRC8g/ZegeAh0= -cloud.google.com/go/artifactregistry v1.6.0/go.mod h1:IYt0oBPSAGYj/kprzsBjZ/4LnG/zOcHyFHjWPCi6SAQ= -cloud.google.com/go/artifactregistry v1.7.0/go.mod h1:mqTOFOnGZx8EtSqK/ZWcsm/4U8B77rbcLP6ruDU2Ixk= -cloud.google.com/go/asset v1.5.0/go.mod h1:5mfs8UvcM5wHhqtSv8J1CtxxaQq3AdBxxQi2jGW/K4o= -cloud.google.com/go/asset v1.7.0/go.mod h1:YbENsRK4+xTiL+Ofoj5Ckf+O17kJtgp3Y3nn4uzZz5s= -cloud.google.com/go/asset v1.8.0/go.mod h1:mUNGKhiqIdbr8X7KNayoYvyc4HbbFO9URsjbytpUaW0= -cloud.google.com/go/assuredworkloads v1.5.0/go.mod h1:n8HOZ6pff6re5KYfBXcFvSViQjDwxFkAkmUFffJRbbY= -cloud.google.com/go/assuredworkloads v1.6.0/go.mod h1:yo2YOk37Yc89Rsd5QMVECvjaMKymF9OP+QXWlKXUkXw= -cloud.google.com/go/assuredworkloads v1.7.0/go.mod h1:z/736/oNmtGAyU47reJgGN+KVoYoxeLBoj4XkKYscNI= -cloud.google.com/go/automl v1.5.0/go.mod h1:34EjfoFGMZ5sgJ9EoLsRtdPSNZLcfflJR39VbVNS2M0= -cloud.google.com/go/automl v1.6.0/go.mod h1:ugf8a6Fx+zP0D59WLhqgTDsQI9w07o64uf/Is3Nh5p8= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/bigquery v1.42.0/go.mod h1:8dRTJxhtG+vwBKzE5OseQn/hiydoQN3EedCaOdYmxRA= cloud.google.com/go/bigtable v1.2.0/go.mod h1:JcVAOl45lrTmQfLj7T6TxyMzIN/3FGGcFm+2xVAli2o= -cloud.google.com/go/billing v1.4.0/go.mod h1:g9IdKBEFlItS8bTtlrZdVLWSSdSyFUZKXNS02zKMOZY= -cloud.google.com/go/billing v1.5.0/go.mod h1:mztb1tBc3QekhjSgmpf/CV4LzWXLzCArwpLmP2Gm88s= -cloud.google.com/go/binaryauthorization v1.1.0/go.mod h1:xwnoWu3Y84jbuHa0zd526MJYmtnVXn0syOjaJgy4+dM= -cloud.google.com/go/binaryauthorization v1.2.0/go.mod h1:86WKkJHtRcv5ViNABtYMhhNWRrD1Vpi//uKEy7aYEfI= -cloud.google.com/go/cloudtasks v1.5.0/go.mod h1:fD92REy1x5woxkKEkLdvavGnPJGEn8Uic9nWuLzqCpY= -cloud.google.com/go/cloudtasks v1.6.0/go.mod h1:C6Io+sxuke9/KNRkbQpihnW93SWDU3uXt92nu85HkYI= -cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= -cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= -cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= -cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= -cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= -cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= -cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= cloud.google.com/go/compute v1.14.0 h1:hfm2+FfxVmnRlh6LpB7cg1ZNU+5edAHmW679JePztk0= cloud.google.com/go/compute v1.14.0/go.mod h1:YfLtxrj9sU4Yxv+sXzZkyPjEyPBZfXHUvjxega5vAdo= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= -cloud.google.com/go/containeranalysis v0.6.0/go.mod h1:HEJoiEIu+lEXM+k7+qLCci0h33lX3ZqoYFdmPcoO7s4= -cloud.google.com/go/datacatalog v1.3.0/go.mod h1:g9svFY6tuR+j+hrTw3J2dNcmI0dzmSiyOzm8kpLq0a0= -cloud.google.com/go/datacatalog v1.5.0/go.mod h1:M7GPLNQeLfWqeIm3iuiruhPzkt65+Bx8dAKvScX8jvs= -cloud.google.com/go/datacatalog v1.6.0/go.mod h1:+aEyF8JKg+uXcIdAmmaMUmZ3q1b/lKLtXCmXdnc0lbc= -cloud.google.com/go/dataflow v0.6.0/go.mod h1:9QwV89cGoxjjSR9/r7eFDqqjtvbKxAK2BaYU6PVk9UM= -cloud.google.com/go/dataflow v0.7.0/go.mod h1:PX526vb4ijFMesO1o202EaUmouZKBpjHsTlCtB4parQ= -cloud.google.com/go/dataform v0.3.0/go.mod h1:cj8uNliRlHpa6L3yVhDOBrUXH+BPAO1+KFMQQNSThKo= -cloud.google.com/go/dataform v0.4.0/go.mod h1:fwV6Y4Ty2yIFL89huYlEkwUPtS7YZinZbzzj5S9FzCE= -cloud.google.com/go/datalabeling v0.5.0/go.mod h1:TGcJ0G2NzcsXSE/97yWjIZO0bXj0KbVlINXMG9ud42I= -cloud.google.com/go/datalabeling v0.6.0/go.mod h1:WqdISuk/+WIGeMkpw/1q7bK/tFEZxsrFJOJdY2bXvTQ= -cloud.google.com/go/dataqna v0.5.0/go.mod h1:90Hyk596ft3zUQ8NkFfvICSIfHFh1Bc7C4cK3vbhkeo= -cloud.google.com/go/dataqna v0.6.0/go.mod h1:1lqNpM7rqNLVgWBJyk5NF6Uen2PHym0jtVJonplVsDA= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/datastream v1.2.0/go.mod h1:i/uTP8/fZwgATHS/XFu0TcNUhuA0twZxxQ3EyCUQMwo= -cloud.google.com/go/datastream v1.3.0/go.mod h1:cqlOX8xlyYF/uxhiKn6Hbv6WjwPPuI9W2M9SAXwaLLQ= -cloud.google.com/go/dialogflow v1.15.0/go.mod h1:HbHDWs33WOGJgn6rfzBW1Kv807BE3O1+xGbn59zZWI4= -cloud.google.com/go/dialogflow v1.16.1/go.mod h1:po6LlzGfK+smoSmTBnbkIZY2w8ffjz/RcGSS+sh1el0= -cloud.google.com/go/dialogflow v1.17.0/go.mod h1:YNP09C/kXA1aZdBgC/VtXX74G/TKn7XVCcVumTflA+8= -cloud.google.com/go/documentai v1.7.0/go.mod h1:lJvftZB5NRiFSX4moiye1SMxHx0Bc3x1+p9e/RfXYiU= -cloud.google.com/go/documentai v1.8.0/go.mod h1:xGHNEB7CtsnySCNrCFdCyyMz44RhFEEX2Q7UD0c5IhU= -cloud.google.com/go/domains v0.6.0/go.mod h1:T9Rz3GasrpYk6mEGHh4rymIhjlnIuB4ofT1wTxDeT4Y= -cloud.google.com/go/domains v0.7.0/go.mod h1:PtZeqS1xjnXuRPKE/88Iru/LdfoRyEHYA9nFQf4UKpg= -cloud.google.com/go/edgecontainer v0.1.0/go.mod h1:WgkZ9tp10bFxqO8BLPqv2LlfmQF1X8lZqwW4r1BTajk= -cloud.google.com/go/edgecontainer v0.2.0/go.mod h1:RTmLijy+lGpQ7BXuTDa4C4ssxyXT34NIuHIgKuP4s5w= -cloud.google.com/go/functions v1.6.0/go.mod h1:3H1UA3qiIPRWD7PeZKLvHZ9SaQhR26XIJcC0A5GbvAk= -cloud.google.com/go/functions v1.7.0/go.mod h1:+d+QBcWM+RsrgZfV9xo6KfA1GlzJfxcfZcRPEhDDfzg= -cloud.google.com/go/gaming v1.5.0/go.mod h1:ol7rGcxP/qHTRQE/RO4bxkXq+Fix0j6D4LFPzYTIrDM= -cloud.google.com/go/gaming v1.6.0/go.mod h1:YMU1GEvA39Qt3zWGyAVA9bpYz/yAhTvaQ1t2sK4KPUA= -cloud.google.com/go/gkeconnect v0.5.0/go.mod h1:c5lsNAg5EwAy7fkqX/+goqFsU1Da/jQFqArp+wGNr/o= -cloud.google.com/go/gkeconnect v0.6.0/go.mod h1:Mln67KyU/sHJEBY8kFZ0xTeyPtzbq9StAVvEULYK16A= -cloud.google.com/go/gkehub v0.9.0/go.mod h1:WYHN6WG8w9bXU0hqNxt8rm5uxnk8IH+lPY9J2TV7BK0= -cloud.google.com/go/gkehub v0.10.0/go.mod h1:UIPwxI0DsrpsVoWpLB0stwKCP+WFVG9+y977wO+hBH0= -cloud.google.com/go/grafeas v0.2.0/go.mod h1:KhxgtF2hb0P191HlY5besjYm6MqTSTj3LSI+M+ByZHc= -cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= -cloud.google.com/go/iam v0.5.0/go.mod h1:wPU9Vt0P4UmCux7mqtRu6jcpPAb74cP1fh50J3QpkUc= cloud.google.com/go/iam v0.8.0 h1:E2osAkZzxI/+8pZcxVLcDtAQx/u+hZXVryUaYQ5O0Kk= cloud.google.com/go/iam v0.8.0/go.mod h1:lga0/y3iH6CX7sYqypWJ33hf7kkfXJag67naqGESjkE= -cloud.google.com/go/language v1.4.0/go.mod h1:F9dRpNFQmJbkaop6g0JhSBXCNlO90e1KWx5iDdxbWic= -cloud.google.com/go/language v1.6.0/go.mod h1:6dJ8t3B+lUYfStgls25GusK04NLh3eDLQnWM3mdEbhI= -cloud.google.com/go/lifesciences v0.5.0/go.mod h1:3oIKy8ycWGPUyZDR/8RNnTOYevhaMLqh5vLUXs9zvT8= -cloud.google.com/go/lifesciences v0.6.0/go.mod h1:ddj6tSX/7BOnhxCSd3ZcETvtNr8NZ6t/iPhY2Tyfu08= cloud.google.com/go/longrunning v0.3.0 h1:NjljC+FYPV3uh5/OwWT6pVU+doBqMg2x/rZlE+CamDs= -cloud.google.com/go/mediatranslation v0.5.0/go.mod h1:jGPUhGTybqsPQn91pNXw0xVHfuJ3leR1wj37oU3y1f4= -cloud.google.com/go/mediatranslation v0.6.0/go.mod h1:hHdBCTYNigsBxshbznuIMFNe5QXEowAuNmmC7h8pu5w= -cloud.google.com/go/memcache v1.4.0/go.mod h1:rTOfiGZtJX1AaFUrOgsMHX5kAzaTQ8azHiuDoTPzNsE= -cloud.google.com/go/memcache v1.5.0/go.mod h1:dk3fCK7dVo0cUU2c36jKb4VqKPS22BTkf81Xq617aWM= -cloud.google.com/go/metastore v1.5.0/go.mod h1:2ZNrDcQwghfdtCwJ33nM0+GrBGlVuh8rakL3vdPY3XY= -cloud.google.com/go/metastore v1.6.0/go.mod h1:6cyQTls8CWXzk45G55x57DVQ9gWg7RiH65+YgPsNh9s= -cloud.google.com/go/networkconnectivity v1.4.0/go.mod h1:nOl7YL8odKyAOtzNX73/M5/mGZgqqMeryi6UPZTk/rA= -cloud.google.com/go/networkconnectivity v1.5.0/go.mod h1:3GzqJx7uhtlM3kln0+x5wyFvuVH1pIBJjhCpjzSt75o= -cloud.google.com/go/networksecurity v0.5.0/go.mod h1:xS6fOCoqpVC5zx15Z/MqkfDwH4+m/61A3ODiDV1xmiQ= -cloud.google.com/go/networksecurity v0.6.0/go.mod h1:Q5fjhTr9WMI5mbpRYEbiexTzROf7ZbDzvzCrNl14nyU= -cloud.google.com/go/notebooks v1.2.0/go.mod h1:9+wtppMfVPUeJ8fIWPOq1UnATHISkGXGqTkxeieQ6UY= -cloud.google.com/go/notebooks v1.3.0/go.mod h1:bFR5lj07DtCPC7YAAJ//vHskFBxA5JzYlH68kXVdk34= -cloud.google.com/go/osconfig v1.7.0/go.mod h1:oVHeCeZELfJP7XLxcBGTMBvRO+1nQ5tFG9VQTmYS2Fs= -cloud.google.com/go/osconfig v1.8.0/go.mod h1:EQqZLu5w5XA7eKizepumcvWx+m8mJUhEwiPqWiZeEdg= -cloud.google.com/go/oslogin v1.4.0/go.mod h1:YdgMXWRaElXz/lDk1Na6Fh5orF7gvmJ0FGLIs9LId4E= -cloud.google.com/go/oslogin v1.5.0/go.mod h1:D260Qj11W2qx/HVF29zBg+0fd6YCSjSqLUkY/qEenQU= -cloud.google.com/go/phishingprotection v0.5.0/go.mod h1:Y3HZknsK9bc9dMi+oE8Bim0lczMU6hrX0UpADuMefr0= -cloud.google.com/go/phishingprotection v0.6.0/go.mod h1:9Y3LBLgy0kDTcYET8ZH3bq/7qni15yVUoAxiFxnlSUA= -cloud.google.com/go/privatecatalog v0.5.0/go.mod h1:XgosMUvvPyxDjAVNDYxJ7wBW8//hLDDYmnsNcMGq1K0= -cloud.google.com/go/privatecatalog v0.6.0/go.mod h1:i/fbkZR0hLN29eEWiiwue8Pb+GforiEIBnV9yrRUOKI= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/recaptchaenterprise v1.3.1/go.mod h1:OdD+q+y4XGeAlxRaMn1Y7/GveP6zmq76byL6tjPE7d4= -cloud.google.com/go/recaptchaenterprise/v2 v2.1.0/go.mod h1:w9yVqajwroDNTfGuhmOjPDN//rZGySaf6PtFVcSCa7o= -cloud.google.com/go/recaptchaenterprise/v2 v2.2.0/go.mod h1:/Zu5jisWGeERrd5HnlS3EUGb/D335f9k51B/FVil0jk= -cloud.google.com/go/recaptchaenterprise/v2 v2.3.0/go.mod h1:O9LwGCjrhGHBQET5CA7dd5NwwNQUErSgEDit1DLNTdo= -cloud.google.com/go/recommendationengine v0.5.0/go.mod h1:E5756pJcVFeVgaQv3WNpImkFP8a+RptV6dDLGPILjvg= -cloud.google.com/go/recommendationengine v0.6.0/go.mod h1:08mq2umu9oIqc7tDy8sx+MNJdLG0fUi3vaSVbztHgJ4= -cloud.google.com/go/recommender v1.5.0/go.mod h1:jdoeiBIVrJe9gQjwd759ecLJbxCDED4A6p+mqoqDvTg= -cloud.google.com/go/recommender v1.6.0/go.mod h1:+yETpm25mcoiECKh9DEScGzIRyDKpZ0cEhWGo+8bo+c= -cloud.google.com/go/redis v1.7.0/go.mod h1:V3x5Jq1jzUcg+UNsRvdmsfuFnit1cfe3Z/PGyq/lm4Y= -cloud.google.com/go/redis v1.8.0/go.mod h1:Fm2szCDavWzBk2cDKxrkmWBqoCiL1+Ctwq7EyqBCA/A= -cloud.google.com/go/retail v1.8.0/go.mod h1:QblKS8waDmNUhghY2TI9O3JLlFk8jybHeV4BF19FrE4= -cloud.google.com/go/retail v1.9.0/go.mod h1:g6jb6mKuCS1QKnH/dpu7isX253absFl6iE92nHwlBUY= -cloud.google.com/go/scheduler v1.4.0/go.mod h1:drcJBmxF3aqZJRhmkHQ9b3uSSpQoltBPGPxGAWROx6s= -cloud.google.com/go/scheduler v1.5.0/go.mod h1:ri073ym49NW3AfT6DZi21vLZrG07GXr5p3H1KxN5QlI= -cloud.google.com/go/secretmanager v1.6.0/go.mod h1:awVa/OXF6IiyaU1wQ34inzQNc4ISIDIrId8qE5QGgKA= -cloud.google.com/go/security v1.5.0/go.mod h1:lgxGdyOKKjHL4YG3/YwIL2zLqMFCKs0UbQwgyZmfJl4= -cloud.google.com/go/security v1.7.0/go.mod h1:mZklORHl6Bg7CNnnjLH//0UlAlaXqiG7Lb9PsPXLfD0= -cloud.google.com/go/security v1.8.0/go.mod h1:hAQOwgmaHhztFhiQ41CjDODdWP0+AE1B3sX4OFlq+GU= -cloud.google.com/go/securitycenter v1.13.0/go.mod h1:cv5qNAqjY84FCN6Y9z28WlkKXyWsgLO832YiWwkCWcU= -cloud.google.com/go/securitycenter v1.14.0/go.mod h1:gZLAhtyKv85n52XYWt6RmeBdydyxfPeTrpToDPw4Auc= -cloud.google.com/go/servicedirectory v1.4.0/go.mod h1:gH1MUaZCgtP7qQiI+F+A+OpeKF/HQWgtAddhTbhL2bs= -cloud.google.com/go/servicedirectory v1.5.0/go.mod h1:QMKFL0NUySbpZJ1UZs3oFAmdvVxhhxB6eJ/Vlp73dfg= -cloud.google.com/go/speech v1.6.0/go.mod h1:79tcr4FHCimOp56lwC01xnt/WPJZc4v3gzyT7FoBkCM= -cloud.google.com/go/speech v1.7.0/go.mod h1:KptqL+BAQIhMsj1kOP2la5DSEEerPDuOP/2mmkhHhZQ= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= -cloud.google.com/go/storage v1.23.0/go.mod h1:vOEEDNFnciUMhBeT6hsJIn3ieU5cFRmzeLgDvXzfIXc= cloud.google.com/go/storage v1.27.0 h1:YOO045NZI9RKfCj1c5A/ZtuuENUc8OAW+gHdGnDgyMQ= cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s= -cloud.google.com/go/talent v1.1.0/go.mod h1:Vl4pt9jiHKvOgF9KoZo6Kob9oV4lwd/ZD5Cto54zDRw= -cloud.google.com/go/talent v1.2.0/go.mod h1:MoNF9bhFQbiJ6eFD3uSsg0uBALw4n4gaCaEjBw9zo8g= -cloud.google.com/go/videointelligence v1.6.0/go.mod h1:w0DIDlVRKtwPCn/C4iwZIJdvC69yInhW0cfi+p546uU= -cloud.google.com/go/videointelligence v1.7.0/go.mod h1:k8pI/1wAhjznARtVT9U1llUaFNPh7muw8QyOUpavru4= -cloud.google.com/go/vision v1.2.0/go.mod h1:SmNwgObm5DpFBme2xpyOyasvBc1aPdjvMk2bBk0tKD0= -cloud.google.com/go/vision/v2 v2.2.0/go.mod h1:uCdV4PpN1S0jyCyq8sIM42v2Y6zOLkZs+4R9LrGYwFo= -cloud.google.com/go/vision/v2 v2.3.0/go.mod h1:UO61abBx9QRMFkNBbf1D8B1LXdS2cGiiCRx0vSpZoUo= -cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xXZmFiHmGE= -cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= -cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= -cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= @@ -251,9 +110,10 @@ github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= +github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.44.122 h1:p6mw01WBaNpbdP2xrisz5tIkcNwzj/HysobNoaAHjgo= -github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= +github.com/aws/aws-sdk-go v1.40.45 h1:QN1nsY27ssD/JmW4s83qmSb+uL6DG4GmCDzjmJB4xUI= +github.com/aws/aws-sdk-go v1.40.45/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.2.0/go.mod h1:zEQs02YRBw1DjK0PoJv3ygDYOFTre1ejlJWl8FwAuQo= github.com/aws/aws-sdk-go-v2/config v1.1.1/go.mod h1:0XsVy9lBI/BCXm+2Tuvt39YmdHwS5unDQmxZOYe8F5Y= @@ -337,12 +197,6 @@ github.com/cloudflare/cloudflare-go v0.14.0/go.mod h1:EnwdgGMaFOruiPZRFSgn+TsQ3h github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= @@ -380,8 +234,8 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4 github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.19.5 h1:rGA3hOrgNxgRM5wYcSCxgQBap7fW82WZgY78V9po/iY= github.com/cosmos/iavl v0.19.5/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= -github.com/cosmos/ibc-go/v6 v6.1.1 h1:oqqMNyjj6SLQF8rvgCaDGwfdITEIsbhs8F77/8xvRIo= -github.com/cosmos/ibc-go/v6 v6.1.1/go.mod h1:NL17FpFAaWjRFVb1T7LUKuOoMSsATPpu+Icc4zL5/Ik= +github.com/cosmos/ibc-go/v6 v6.1.0 h1:o7oXws2vKkKfOFzJI+oNylRn44PCNt5wzHd/zKQKbvQ= +github.com/cosmos/ibc-go/v6 v6.1.0/go.mod h1:CY3zh2HLfetRiW8LY6kVHMATe90Wj/UOoY8T6cuB0is= github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU= github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIoZuQ7uBoospo5Q9zIpqq6rYCPJDSUdeCJvPM8= github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA= @@ -456,10 +310,6 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0= github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s= @@ -567,9 +417,7 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -586,7 +434,6 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= @@ -611,9 +458,6 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= @@ -625,7 +469,6 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.2.1 h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ= -github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -638,12 +481,8 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -651,23 +490,12 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= -github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= -github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= github.com/googleapis/enterprise-certificate-proxy v0.2.1 h1:RY7tHKZcRlk788d5WSo/e83gOyyy742E8GSs771ySpg= github.com/googleapis/enterprise-certificate-proxy v0.2.1/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= -github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= -github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= -github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqEF02fYlzkUCyo= -github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY= github.com/googleapis/gax-go/v2 v2.7.0 h1:IcsPKeInNvYi7eqSaDjiZqDDKu5rsmunY0Y1YupQSSQ= github.com/googleapis/gax-go/v2 v2.7.0/go.mod h1:TEop28CZZQ2y+c0VxMUmu1lV+fQx57QpBWsYpwqHJx8= -github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= @@ -708,8 +536,8 @@ github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.7.1 h1:SWiSWN/42qdpR0MdhaOc/bLR48PLuP1ZQtYLRlM69uY= -github.com/hashicorp/go-getter v1.7.1/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-getter v1.6.1 h1:NASsgP4q6tL94WH6nJxKWj8As2H/2kop/bB1d8JMyRY= +github.com/hashicorp/go-getter v1.6.1/go.mod h1:IZCrswsZPeWv9IkVnLElzRU/gz/QPi6pZHn4tv6vbwA= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -724,6 +552,7 @@ github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdv github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= @@ -776,6 +605,7 @@ github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1C github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jhump/protoreflect v1.12.1-0.20220721211354-060cc04fc18b h1:izTof8BKh/nE1wrKOrloNA5q4odOarjf+Xpe+4qow98= +github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -812,6 +642,7 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c= @@ -889,9 +720,8 @@ github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceT github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= -github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= @@ -1165,8 +995,8 @@ github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVM github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8= -github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ= +github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= @@ -1188,7 +1018,6 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo= github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.1 h1:Pip65OOl4iJ84WTpA4BKChvOufMhhbxED3BaihoZN4c= @@ -1205,10 +1034,8 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1239,7 +1066,6 @@ golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= @@ -1273,7 +1099,6 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -1285,7 +1110,6 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1334,25 +1158,14 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1364,22 +1177,8 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M= golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1393,9 +1192,6 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1461,58 +1257,33 @@ golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1524,7 +1295,6 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1592,21 +1362,13 @@ golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= @@ -1635,35 +1397,6 @@ google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz513 google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= -google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= -google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= -google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= -google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= -google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= -google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.77.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= -google.golang.org/api v0.80.0/go.mod h1:xY3nI94gbvBrE0J6NHXhxOmW97HG7Khjkku6AFB3Hyg= -google.golang.org/api v0.84.0/go.mod h1:NTsGnUFJMYROtiquksZHBWtHfeMC7iYthki7Eq3pa8o= -google.golang.org/api v0.85.0/go.mod h1:AqZf8Ep9uZ2pyTvgL+x0D3Zt0eoT9b5E8fmzfu6FO2g= -google.golang.org/api v0.90.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= -google.golang.org/api v0.93.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= -google.golang.org/api v0.95.0/go.mod h1:eADj+UBuxkh5zlrSntJghuNeg8HwQ1w5lTKkuqaETEI= -google.golang.org/api v0.96.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= -google.golang.org/api v0.97.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= -google.golang.org/api v0.98.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= -google.golang.org/api v0.100.0/go.mod h1:ZE3Z2+ZOr87Rx7dqFsdRQkRBk36kDtp/h+QpHbB7a70= google.golang.org/api v0.107.0 h1:I2SlFjD8ZWabaIFOfeEDg3pf0BHJDh6iYQ1ic3Yu/UU= google.golang.org/api v0.107.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= @@ -1718,73 +1451,7 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210329143202-679c6ae281ee/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220518221133-4f43b3371335/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220523171625-347a074981d8/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220628213854-d9e0b6570c03/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220722212130-b98a9ff5e252/go.mod h1:GkXuJDJ6aQ7lnJcRF+SJVgFdQhypqgl3LB1C9vabdRE= -google.golang.org/genproto v0.0.0-20220801145646-83ce21fca29f/go.mod h1:iHe1svFLAZg9VWz891+QbRMwUv9O/1Ww+/mngYeThbc= -google.golang.org/genproto v0.0.0-20220815135757-37a418bb8959/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220817144833-d7fd3f11b9b1/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220829144015-23454907ede3/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220829175752-36a9c930ecbf/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220913154956-18f8339a66a5/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220914142337-ca0e39ece12f/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220915135415-7fd63a7952de/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220916172020-2692e8806bfa/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220919141832-68c03719ef51/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220920201722-2b89144ce006/go.mod h1:ht8XFiar2npT/g4vkk7O0WYS1sHOHbdujxbEp7CJWbw= -google.golang.org/genproto v0.0.0-20220926165614-551eb538f295/go.mod h1:woMGP53BroOrRY3xTxlbr8Y3eB/nzAvvFM83q7kG2OI= -google.golang.org/genproto v0.0.0-20220926220553-6981cbe3cfce/go.mod h1:woMGP53BroOrRY3xTxlbr8Y3eB/nzAvvFM83q7kG2OI= -google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqwhZAwq4wsRUaVG555sVgsNmIjRtO7t/JH29U= -google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= -google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= -google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef h1:uQ2vjV/sHTsWSqdKeLqmwitzgvjMl7o4IdtHwUDXSJY= google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= @@ -1811,27 +1478,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.52.0 h1:kd48UiU7EHsV4rnLyOJRuP/Il/UHE7gdDAQ+SZI7nZk= google.golang.org/grpc v1.52.0/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1844,9 +1492,6 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 h1:KR8+MyP7/qOlV+8Af01LtjL04bu7on42eVsxT4EyBQk= google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= @@ -1906,4 +1551,4 @@ rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= -sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= +sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= \ No newline at end of file From 5cf3bc531490ba69c047b9344153aefd56423c93 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Tue, 20 Feb 2024 17:13:23 -0800 Subject: [PATCH 49/52] Skip noop state changes on SetState --- x/evm/statedb/statedb.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 0bb391cad6..86fe676a1b 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -297,14 +297,23 @@ func (s *StateDB) SetCode(addr common.Address, code []byte) { account := s.getOrNewAccount(addr) account.CodeHash = crypto.Keccak256Hash(code).Bytes() + // Set account so CodeHash is updated if err := s.keeper.SetAccount(s.ctx.CurrentCtx(), addr, *account); err != nil { s.SetError(fmt.Errorf("failed to set account for code: %w", err)) } + s.keeper.SetCode(s.ctx.CurrentCtx(), account.CodeHash, code) } // SetState sets the contract state. func (s *StateDB) SetState(addr common.Address, key, value common.Hash) { + commitedState := s.GetCommittedState(addr, key) + + // Skip noop state changes + if commitedState == value { + return + } + s.keeper.SetState(s.ctx.CurrentCtx(), addr, key, value.Bytes()) } From 09ccdecc9b5bfe2c39786fcc5b0293d9840a934f Mon Sep 17 00:00:00 2001 From: drklee3 Date: Tue, 20 Feb 2024 18:26:08 -0800 Subject: [PATCH 50/52] Also skip dirty noop state changes on SetState --- x/evm/statedb/statedb.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 86fe676a1b..1ff6cf43fa 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -307,9 +307,14 @@ func (s *StateDB) SetCode(addr common.Address, code []byte) { // SetState sets the contract state. func (s *StateDB) SetState(addr common.Address, key, value common.Hash) { - commitedState := s.GetCommittedState(addr, key) + // Skip dirty noop state changes + currentState := s.keeper.GetState(s.ctx.CurrentCtx(), addr, key) + if currentState == value { + return + } - // Skip noop state changes + // Skip committed noop state changes + commitedState := s.GetCommittedState(addr, key) if commitedState == value { return } From ed9f446ba15e714166307e4b5b23180ed254e135 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 22 Feb 2024 11:55:13 -0800 Subject: [PATCH 51/52] fix: Delete state on empty common.Hash{} Previous to this change, keeper SetState() only deletes when the len(value) == 0. However, since value in the StateDB is a common.Hash{}, this will always be the HashLength. Deleting the value when the empty hash is set will also ensure specific no-op changes will not be committed, e.g. Creating a state, then deleting it in the same tx will result in no state added. --- x/evm/genesis.go | 2 +- x/evm/keeper/statedb.go | 10 ++++++---- x/evm/statedb/interfaces.go | 2 +- x/evm/statedb/statedb.go | 22 +++++++++------------- x/evm/statedb/statedb_test.go | 17 ++++++----------- 5 files changed, 23 insertions(+), 30 deletions(-) diff --git a/x/evm/genesis.go b/x/evm/genesis.go index 772ede4360..20e7c5cb0f 100644 --- a/x/evm/genesis.go +++ b/x/evm/genesis.go @@ -79,7 +79,7 @@ func InitGenesis( k.SetCode(ctx, codeHash.Bytes(), code) for _, storage := range account.Storage { - k.SetState(ctx, address, common.HexToHash(storage.Key), common.HexToHash(storage.Value).Bytes()) + k.SetState(ctx, address, common.HexToHash(storage.Key), common.HexToHash(storage.Value)) } } diff --git a/x/evm/keeper/statedb.go b/x/evm/keeper/statedb.go index c2cd893c5e..5dcefc0066 100644 --- a/x/evm/keeper/statedb.go +++ b/x/evm/keeper/statedb.go @@ -168,14 +168,16 @@ func (k *Keeper) SetAccount(ctx sdk.Context, addr common.Address, account stated } // SetState update contract storage, delete if value is empty. -func (k *Keeper) SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte) { +func (k *Keeper) SetState(ctx sdk.Context, addr common.Address, key, value common.Hash) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AddressStoragePrefix(addr)) action := "updated" - if len(value) == 0 { + + // Value is always HashLength long, so check if empty by comparing to zero hash + if (value == common.Hash{}) { store.Delete(key.Bytes()) action = "deleted" } else { - store.Set(key.Bytes(), value) + store.Set(key.Bytes(), value.Bytes()) } k.Logger(ctx).Debug( fmt.Sprintf("state %s", action), @@ -227,7 +229,7 @@ func (k *Keeper) DeleteAccount(ctx sdk.Context, addr common.Address) error { // clear storage k.ForEachStorage(ctx, addr, func(key, _ common.Hash) bool { - k.SetState(ctx, addr, key, nil) + k.SetState(ctx, addr, key, common.Hash{}) return true }) diff --git a/x/evm/statedb/interfaces.go b/x/evm/statedb/interfaces.go index 6de9599406..bdf0ef55e8 100644 --- a/x/evm/statedb/interfaces.go +++ b/x/evm/statedb/interfaces.go @@ -44,7 +44,7 @@ type Keeper interface { // Write methods, only called by `StateDB.Commit()` SetAccount(ctx sdk.Context, addr common.Address, account Account) error - SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte) + SetState(ctx sdk.Context, addr common.Address, key, value common.Hash) SetCode(ctx sdk.Context, codeHash []byte, code []byte) SetBalance(ctx sdk.Context, addr common.Address, amount *big.Int) error DeleteAccount(ctx sdk.Context, addr common.Address) error diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go index 1ff6cf43fa..634c7a5dfa 100644 --- a/x/evm/statedb/statedb.go +++ b/x/evm/statedb/statedb.go @@ -307,19 +307,15 @@ func (s *StateDB) SetCode(addr common.Address, code []byte) { // SetState sets the contract state. func (s *StateDB) SetState(addr common.Address, key, value common.Hash) { - // Skip dirty noop state changes - currentState := s.keeper.GetState(s.ctx.CurrentCtx(), addr, key) - if currentState == value { - return - } - - // Skip committed noop state changes - commitedState := s.GetCommittedState(addr, key) - if commitedState == value { - return - } - - s.keeper.SetState(s.ctx.CurrentCtx(), addr, key, value.Bytes()) + // We cannot attempt to skip noop changes by just checking committed state + // Example: + // 1. With committed state to 0x0 + // 2. Dirty change to 0x1 + // 3. Dirty change to 0x0 - cannot skip this + // 4. Commit + // + // End result: 0x0, but we cannot skip step 3 or it will be incorrectly 0x1 + s.keeper.SetState(s.ctx.CurrentCtx(), addr, key, value) } // Suicide marks the given account as suicided. diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index 08c8f48898..655d2ffb59 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -224,21 +224,16 @@ func (suite *StateDBTestSuite) TestState() { }{ {"empty state", func(db *statedb.StateDB) { }, nil}, - {"set empty value", func(db *statedb.StateDB) { + + {"set empty value deletes", func(db *statedb.StateDB) { db.SetState(address, key1, common.Hash{}) - }, map[common.Hash]common.Hash{ - // empty value still persisted - key1: common.Hash{}, - }}, + }, map[common.Hash]common.Hash{}}, + {"noop state change", func(db *statedb.StateDB) { - // TODO: This doesn't actually change anything compared to committed state. - // Is this okay? db.SetState(address, key1, value1) db.SetState(address, key1, common.Hash{}) - }, map[common.Hash]common.Hash{ - // Still sets the key to an empty value even if there is no overall change - key1: common.Hash{}, - }}, + }, map[common.Hash]common.Hash{}}, + {"set state", func(db *statedb.StateDB) { // check empty initial state suite.Require().Equal(common.Hash{}, db.GetState(address, key1)) From 29a4996a4f84ff98c10f18420c8dc2b2b0d2df55 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 22 Feb 2024 12:19:07 -0800 Subject: [PATCH 52/52] test: Add case for non-empty noop state change --- x/evm/statedb/statedb_test.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index 655d2ffb59..3cbedae2bb 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -229,11 +229,23 @@ func (suite *StateDBTestSuite) TestState() { db.SetState(address, key1, common.Hash{}) }, map[common.Hash]common.Hash{}}, - {"noop state change", func(db *statedb.StateDB) { + {"noop state change - empty", func(db *statedb.StateDB) { db.SetState(address, key1, value1) db.SetState(address, key1, common.Hash{}) }, map[common.Hash]common.Hash{}}, + {"noop state change - non-empty", func(db *statedb.StateDB) { + // Start with non-empty committed state + db.SetState(address, key1, value1) + suite.Require().NoError(db.Commit()) + + db.SetState(address, key1, common.Hash{}) + db.SetState(address, key1, value1) + }, map[common.Hash]common.Hash{ + // Shouldn't be modified - Commit() may still write it again though + key1: value1, + }}, + {"set state", func(db *statedb.StateDB) { // check empty initial state suite.Require().Equal(common.Hash{}, db.GetState(address, key1))