Skip to content

Commit 4e8c133

Browse files
authored
Problem: get set params are not align in evm (#456)
* Problem: get set params are not align in feemarket * align doc * Apply suggestions from code review
1 parent c684a04 commit 4e8c133

File tree

5 files changed

+37
-53
lines changed

5 files changed

+37
-53
lines changed

app/app.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,6 @@ func NewEthermintApp(
503503
evmSs := app.GetSubspace(evmtypes.ModuleName)
504504
app.EvmKeeper = evmkeeper.NewKeeper(
505505
appCodec,
506-
runtime.NewKVStoreService(keys[evmtypes.StoreKey]),
507506
keys[evmtypes.StoreKey], okeys[evmtypes.ObjectStoreKey], authtypes.NewModuleAddress(govtypes.ModuleName),
508507
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper,
509508
tracer,

x/evm/keeper/keeper.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package keeper
1818
import (
1919
"math/big"
2020

21-
corestoretypes "cosmossdk.io/core/store"
2221
errorsmod "cosmossdk.io/errors"
2322
"cosmossdk.io/log"
2423
storetypes "cosmossdk.io/store/types"
@@ -41,15 +40,14 @@ type CustomContractFn func(sdk.Context, params.Rules) vm.PrecompiledContract
4140
// Keeper grants access to the EVM module state and implements the go-ethereum StateDB interface.
4241
type Keeper struct {
4342
// Protobuf codec
44-
cdc codec.Codec
45-
storeService corestoretypes.KVStoreService
43+
cdc codec.Codec
4644
// Store key required for the EVM Prefix KVStore. It is required by:
4745
// - storing account's Storage State
4846
// - storing account's Code
4947
// - storing module parameters
5048
storeKey storetypes.StoreKey
5149

52-
// key to access the transient store, which is reset on every block during Commit
50+
// key to access the object store, which is reset on every block during Commit
5351
objectKey storetypes.StoreKey
5452

5553
// the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account.
@@ -78,7 +76,6 @@ type Keeper struct {
7876
// NewKeeper generates new evm module keeper
7977
func NewKeeper(
8078
cdc codec.Codec,
81-
storeService corestoretypes.KVStoreService,
8279
storeKey, objectKey storetypes.StoreKey,
8380
authority sdk.AccAddress,
8481
ak types.AccountKeeper,
@@ -101,7 +98,6 @@ func NewKeeper(
10198
// NOTE: we pass in the parameter space to the CommitStateDB in order to use custom denominations for the EVM operations
10299
return &Keeper{
103100
cdc: cdc,
104-
storeService: storeService,
105101
authority: authority,
106102
accountKeeper: ak,
107103
bankKeeper: bankKeeper,

x/evm/keeper/params.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,15 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params {
2626
objStore := ctx.ObjectStore(k.objectKey)
2727
v := objStore.Get(types.KeyPrefixObjectParams)
2828
if v == nil {
29-
store := k.storeService.OpenKVStore(ctx)
30-
bz, err := store.Get(types.KeyPrefixParams)
31-
if err != nil {
32-
panic(err)
33-
}
3429
params = new(types.Params)
30+
bz := ctx.KVStore(k.storeKey).Get(types.KeyPrefixParams)
3531
if bz != nil {
3632
k.cdc.MustUnmarshal(bz, params)
3733
}
38-
3934
objStore.Set(types.KeyPrefixObjectParams, params)
4035
} else {
4136
params = v.(*types.Params)
4237
}
43-
4438
return *params
4539
}
4640

@@ -49,11 +43,9 @@ func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error {
4943
if err := p.Validate(); err != nil {
5044
return err
5145
}
52-
store := k.storeService.OpenKVStore(ctx)
46+
store := ctx.KVStore(k.storeKey)
5347
bz := k.cdc.MustMarshal(&p)
54-
if err := store.Set(types.KeyPrefixParams, bz); err != nil {
55-
return err
56-
}
48+
store.Set(types.KeyPrefixParams, bz)
5749

5850
// set to cache as well, decode again to be compatible with the previous behavior
5951
var params types.Params

x/evm/spec/02_state.md

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -173,40 +173,38 @@ To support the interface functionality, it imports 4 module Keepers:
173173

174174
```go
175175
type Keeper struct {
176-
// Protobuf codec
177-
cdc codec.BinaryCodec
178-
// Store key required for the EVM Prefix KVStore. It is required by:
179-
// - storing account's Storage State
180-
// - storing account's Code
181-
// - storing Bloom filters by block height. Needed for the Web3 API.
182-
// For the full list, check the module specification
183-
storeKey sdk.StoreKey
184-
185-
// key to access the transient store, which is reset on every block during Commit
186-
transientKey sdk.StoreKey
187-
188-
// module specific parameter space that can be configured through governance
189-
paramSpace paramtypes.Subspace
190-
// access to account state
191-
accountKeeper types.AccountKeeper
192-
// update balance and accounting operations with coins
193-
bankKeeper types.BankKeeper
194-
// access historical headers for EVM state transition execution
195-
stakingKeeper types.StakingKeeper
196-
// fetch EIP1559 base fee and parameters
197-
feeMarketKeeper types.FeeMarketKeeper
198-
199-
// chain ID number obtained from the context's chain id
200-
eip155ChainID *big.Int
201-
202-
// Tracer used to collect execution traces from the EVM transaction execution
203-
tracer string
204-
// trace EVM state transition execution. This value is obtained from the `--trace` flag.
205-
// For more info check https://geth.ethereum.org/docs/dapp/tracing
206-
debug bool
207-
208-
// EVM Hooks for tx post-processing
209-
hooks types.EvmHooks
176+
// Protobuf codec
177+
cdc codec.Codec
178+
// Store key required for the EVM Prefix KVStore. It is required by:
179+
// - storing account's Storage State
180+
// - storing account's Code
181+
// - storing module parameters
182+
storeKey storetypes.StoreKey
183+
184+
// key to access the object store, which is reset on every block during Commit
185+
objectKey storetypes.StoreKey
186+
187+
// the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account.
188+
authority sdk.AccAddress
189+
// access to account state
190+
accountKeeper types.AccountKeeper
191+
// update balance and accounting operations with coins
192+
bankKeeper types.BankKeeper
193+
// access historical headers for EVM state transition execution
194+
stakingKeeper types.StakingKeeper
195+
// fetch EIP1559 base fee and parameters
196+
feeMarketKeeper types.FeeMarketKeeper
197+
198+
// chain ID number obtained from the context's chain id
199+
eip155ChainID *big.Int
200+
201+
// Tracer used to collect execution traces from the EVM transaction execution
202+
tracer string
203+
204+
// EVM Hooks for tx post-processing
205+
hooks types.EvmHooks
206+
207+
customContractFns []CustomContractFn
210208
}
211209
```
212210

x/evm/statedb/statedb_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,6 @@ func newTestKeeper(t *testing.T, cms storetypes.MultiStore) (sdk.Context, *evmke
820820
)
821821
evmKeeper := evmkeeper.NewKeeper(
822822
appCodec,
823-
runtime.NewKVStoreService(testStoreKeys[evmtypes.StoreKey]),
824823
testStoreKeys[evmtypes.StoreKey], testObjKeys[evmtypes.ObjectStoreKey], authtypes.NewModuleAddress(govtypes.ModuleName),
825824
accountKeeper, bankKeeper, nil, nil,
826825
"",

0 commit comments

Comments
 (0)