diff --git a/app/app.go b/app/app.go index e078157472..872310ec48 100644 --- a/app/app.go +++ b/app/app.go @@ -503,7 +503,6 @@ func NewEthermintApp( evmSs := app.GetSubspace(evmtypes.ModuleName) app.EvmKeeper = evmkeeper.NewKeeper( appCodec, - runtime.NewKVStoreService(keys[evmtypes.StoreKey]), keys[evmtypes.StoreKey], okeys[evmtypes.ObjectStoreKey], authtypes.NewModuleAddress(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper, tracer, diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 60d46d4c71..2e4bc9b924 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -18,7 +18,6 @@ package keeper import ( "math/big" - corestoretypes "cosmossdk.io/core/store" errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" @@ -41,15 +40,14 @@ type CustomContractFn func(sdk.Context, params.Rules) vm.PrecompiledContract // Keeper grants access to the EVM module state and implements the go-ethereum StateDB interface. type Keeper struct { // Protobuf codec - cdc codec.Codec - storeService corestoretypes.KVStoreService + cdc codec.Codec // Store key required for the EVM Prefix KVStore. It is required by: // - storing account's Storage State // - storing account's Code // - storing module parameters storeKey storetypes.StoreKey - // key to access the transient store, which is reset on every block during Commit + // key to access the object store, which is reset on every block during Commit objectKey storetypes.StoreKey // the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account. @@ -78,7 +76,6 @@ type Keeper struct { // NewKeeper generates new evm module keeper func NewKeeper( cdc codec.Codec, - storeService corestoretypes.KVStoreService, storeKey, objectKey storetypes.StoreKey, authority sdk.AccAddress, ak types.AccountKeeper, @@ -101,7 +98,6 @@ 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, - storeService: storeService, authority: authority, accountKeeper: ak, bankKeeper: bankKeeper, diff --git a/x/evm/keeper/params.go b/x/evm/keeper/params.go index eff1a9c5bf..17d3908a16 100644 --- a/x/evm/keeper/params.go +++ b/x/evm/keeper/params.go @@ -26,21 +26,15 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params { objStore := ctx.ObjectStore(k.objectKey) v := objStore.Get(types.KeyPrefixObjectParams) if v == nil { - store := k.storeService.OpenKVStore(ctx) - bz, err := store.Get(types.KeyPrefixParams) - if err != nil { - panic(err) - } params = new(types.Params) + bz := ctx.KVStore(k.storeKey).Get(types.KeyPrefixParams) if bz != nil { k.cdc.MustUnmarshal(bz, params) } - objStore.Set(types.KeyPrefixObjectParams, params) } else { params = v.(*types.Params) } - return *params } @@ -49,11 +43,9 @@ func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error { if err := p.Validate(); err != nil { return err } - store := k.storeService.OpenKVStore(ctx) + store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(&p) - if err := store.Set(types.KeyPrefixParams, bz); err != nil { - return err - } + store.Set(types.KeyPrefixParams, bz) // set to cache as well, decode again to be compatible with the previous behavior var params types.Params diff --git a/x/evm/spec/02_state.md b/x/evm/spec/02_state.md index 024f238f75..00e723d7a3 100644 --- a/x/evm/spec/02_state.md +++ b/x/evm/spec/02_state.md @@ -173,40 +173,38 @@ To support the interface functionality, it imports 4 module Keepers: ```go type Keeper struct { - // Protobuf codec - cdc codec.BinaryCodec - // Store key required for the EVM Prefix KVStore. It is required by: - // - storing account's Storage State - // - storing account's Code - // - storing Bloom filters by block height. Needed for the Web3 API. - // For the full list, check the module specification - storeKey sdk.StoreKey - - // key to access the transient store, which is reset on every block during Commit - transientKey sdk.StoreKey - - // module specific parameter space that can be configured through governance - paramSpace paramtypes.Subspace - // access to account state - accountKeeper types.AccountKeeper - // update balance and accounting operations with coins - bankKeeper types.BankKeeper - // access historical headers for EVM state transition execution - stakingKeeper types.StakingKeeper - // fetch EIP1559 base fee and parameters - feeMarketKeeper types.FeeMarketKeeper - - // chain ID number obtained from the context's chain id - eip155ChainID *big.Int - - // Tracer used to collect execution traces from the EVM transaction execution - tracer string - // trace EVM state transition execution. This value is obtained from the `--trace` flag. - // For more info check https://geth.ethereum.org/docs/dapp/tracing - debug bool - - // EVM Hooks for tx post-processing - hooks types.EvmHooks + // Protobuf codec + cdc codec.Codec + // Store key required for the EVM Prefix KVStore. It is required by: + // - storing account's Storage State + // - storing account's Code + // - storing module parameters + storeKey storetypes.StoreKey + + // key to access the object store, which is reset on every block during Commit + objectKey storetypes.StoreKey + + // the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account. + authority sdk.AccAddress + // access to account state + accountKeeper types.AccountKeeper + // update balance and accounting operations with coins + bankKeeper types.BankKeeper + // access historical headers for EVM state transition execution + stakingKeeper types.StakingKeeper + // fetch EIP1559 base fee and parameters + feeMarketKeeper types.FeeMarketKeeper + + // chain ID number obtained from the context's chain id + eip155ChainID *big.Int + + // Tracer used to collect execution traces from the EVM transaction execution + tracer string + + // EVM Hooks for tx post-processing + hooks types.EvmHooks + + customContractFns []CustomContractFn } ``` diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index 0b384afce0..462578a7a6 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -820,7 +820,6 @@ func newTestKeeper(t *testing.T, cms storetypes.MultiStore) (sdk.Context, *evmke ) evmKeeper := evmkeeper.NewKeeper( appCodec, - runtime.NewKVStoreService(testStoreKeys[evmtypes.StoreKey]), testStoreKeys[evmtypes.StoreKey], testObjKeys[evmtypes.ObjectStoreKey], authtypes.NewModuleAddress(govtypes.ModuleName), accountKeeper, bankKeeper, nil, nil, "",