Skip to content

Commit 04f5ae2

Browse files
committed
align keys for snapshotKVStore
Revert "less" This reverts commit 21ef5c3.
1 parent 21ef5c3 commit 04f5ae2

File tree

16 files changed

+78
-60
lines changed

16 files changed

+78
-60
lines changed

evmd/app.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,9 @@ func NewExampleApp(
489489
// NOTE: it's required to set up the EVM keeper before the ERC-20 keeper, because it is used in its instantiation.
490490
app.EVMKeeper = evmkeeper.NewKeeper(
491491
// TODO: check why this is not adjusted to use the runtime module methods like SDK native keepers
492-
appCodec, keys[evmtypes.StoreKey], okeys[evmtypes.ObjectStoreKey], keys,
492+
appCodec,
493+
keys,
494+
okeys,
493495
authtypes.NewModuleAddress(govtypes.ModuleName),
494496
app.AccountKeeper,
495497
app.PreciseBankKeeper,

evmd/tests/ibc/ics20_precompile_transfer_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package ibc
77

88
import (
99
"math/big"
10+
"testing"
1011

1112
"github.com/ethereum/go-ethereum/common"
1213
"github.com/ethereum/go-ethereum/core/vm"
@@ -354,6 +355,6 @@ func (suite *ICS20TransferTestSuite) TestHandleMsgTransfer() {
354355
}
355356
}
356357

357-
// func TestICS20TransferTestSuite(t *testing.T) {
358-
// suite.Run(t, new(ICS20TransferTestSuite))
359-
// }
358+
func TestICS20TransferTestSuite(t *testing.T) {
359+
suite.Run(t, new(ICS20TransferTestSuite))
360+
}

evmd/tests/ibc/v2_ics20_precompile_transfer_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package ibc
77

88
import (
99
"math/big"
10+
"testing"
1011
"time"
1112

1213
"github.com/ethereum/go-ethereum/common"
@@ -358,6 +359,6 @@ func (suite *ICS20TransferV2TestSuite) TestHandleMsgTransfer() {
358359
}
359360
}
360361

361-
// func TestICS20TransferV2TestSuite(t *testing.T) {
362-
// suite.Run(t, new(ICS20TransferV2TestSuite))
363-
// }
362+
func TestICS20TransferV2TestSuite(t *testing.T) {
363+
suite.Run(t, new(ICS20TransferV2TestSuite))
364+
}

mempool/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type VMKeeperI interface {
2727
DeleteCode(ctx sdk.Context, codeHash []byte)
2828
SetCode(ctx sdk.Context, codeHash []byte, code []byte)
2929
DeleteAccount(ctx sdk.Context, addr common.Address) error
30-
KVStoreKeys() map[string]*storetypes.KVStoreKey
30+
KVStoreKeys() map[string]storetypes.StoreKey
3131
SetEvmMempool(evmMempool *ExperimentalEVMMempool)
3232
}
3333

x/feemarket/keeper/keeper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Keeper struct {
2323

2424
// NewKeeper generates new fee market module keeper
2525
func NewKeeper(
26-
cdc codec.BinaryCodec, authority sdk.AccAddress, storeKey, transientKey storetypes.StoreKey,
26+
cdc codec.BinaryCodec, authority sdk.AccAddress, storeKey, objectKey storetypes.StoreKey,
2727
) Keeper {
2828
// ensure authority account is correctly formatted
2929
if err := sdk.VerifyAddressFormat(authority); err != nil {
@@ -34,7 +34,7 @@ func NewKeeper(
3434
cdc: cdc,
3535
storeKey: storeKey,
3636
authority: authority,
37-
objectKey: transientKey,
37+
objectKey: objectKey,
3838
}
3939
}
4040

x/vm/keeper/keeper.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Keeper struct {
4343
objectKey storetypes.StoreKey
4444

4545
// KVStore Keys for modules wired to app
46-
storeKeys map[string]*storetypes.KVStoreKey
46+
storeKeys map[string]storetypes.StoreKey
4747

4848
// the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account.
4949
authority sdk.AccAddress
@@ -86,8 +86,8 @@ type Keeper struct {
8686
// NewKeeper generates new evm module keeper
8787
func NewKeeper(
8888
cdc codec.BinaryCodec,
89-
storeKey, objKey storetypes.StoreKey,
9089
keys map[string]*storetypes.KVStoreKey,
90+
okeys map[string]*storetypes.ObjectStoreKey,
9191
authority sdk.AccAddress,
9292
ak types.AccountKeeper,
9393
bankKeeper types.BankKeeper,
@@ -110,6 +110,13 @@ func NewKeeper(
110110
bankWrapper := wrappers.NewBankWrapper(bankKeeper)
111111
feeMarketWrapper := wrappers.NewFeeMarketWrapper(fmk)
112112

113+
storeKeys := make(map[string]storetypes.StoreKey)
114+
for k, v := range keys {
115+
storeKeys[k] = v
116+
}
117+
for k, v := range okeys {
118+
storeKeys[k] = v
119+
}
113120
// NOTE: we pass in the parameter space to the CommitStateDB in order to use custom denominations for the EVM operations
114121
return &Keeper{
115122
cdc: cdc,
@@ -118,12 +125,12 @@ func NewKeeper(
118125
bankWrapper: bankWrapper,
119126
stakingKeeper: sk,
120127
feeMarketWrapper: feeMarketWrapper,
121-
storeKey: storeKey,
122-
objectKey: objKey,
128+
storeKey: keys[types.StoreKey],
129+
objectKey: okeys[types.ObjectStoreKey],
123130
tracer: tracer,
124131
consensusKeeper: consensusKeeper,
125132
erc20Keeper: erc20Keeper,
126-
storeKeys: keys,
133+
storeKeys: storeKeys,
127134
}
128135
}
129136

@@ -359,7 +366,7 @@ func (k Keeper) AddTransientGasUsed(ctx sdk.Context, gasUsed uint64) (uint64, er
359366
}
360367

361368
// KVStoreKeys returns KVStore keys injected to keeper
362-
func (k Keeper) KVStoreKeys() map[string]*storetypes.KVStoreKey {
369+
func (k Keeper) KVStoreKeys() map[string]storetypes.StoreKey {
363370
return k.storeKeys
364371
}
365372

x/vm/keeper/keeper_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ func (suite *KeeperTestSuite) SetupTest() {
6666
// Cosmos EVM store keys
6767
vmtypes.StoreKey, feemarkettypes.StoreKey, erc20types.StoreKey, precisebanktypes.StoreKey,
6868
)
69-
okeys := storetypes.NewObjectStoreKeys(vmtypes.ObjectStoreKey)
70-
key := storetypes.NewKVStoreKey(vmtypes.StoreKey)
71-
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
69+
okeys := storetypes.NewObjectStoreKeys(banktypes.ObjectStoreKey)
70+
testCtx := testutil.DefaultContextWithDB(suite.T(), keys[vmtypes.StoreKey], storetypes.NewTransientStoreKey("transient_test"))
7271
ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: cmttime.Now()})
7372
encCfg := moduletestutil.MakeTestEncodingConfig()
7473

@@ -86,9 +85,8 @@ func (suite *KeeperTestSuite) SetupTest() {
8685
suite.accKeeper.On("GetModuleAddress", vmtypes.ModuleName).Return(sdk.AccAddress("evm"))
8786
suite.vmKeeper = vmkeeper.NewKeeper(
8887
encCfg.Codec,
89-
key,
90-
okeys[vmtypes.ObjectStoreKey],
9188
keys,
89+
okeys,
9290
authority,
9391
suite.accKeeper,
9492
suite.bankKeeper,

x/vm/statedb/interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ type Keeper interface {
3939

4040
// Getter for injected KVStore keys
4141
// It is used for StateDB.snapshotter creation
42-
KVStoreKeys() map[string]*storetypes.KVStoreKey
42+
KVStoreKeys() map[string]storetypes.StoreKey
4343
}

x/vm/statedb/mock_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@ func (k MockKeeper) Clone() *MockKeeper {
120120
return &MockKeeper{accounts, codes}
121121
}
122122

123-
func (k MockKeeper) KVStoreKeys() map[string]*storetypes.KVStoreKey {
124-
return make(map[string]*storetypes.KVStoreKey)
123+
func (k MockKeeper) KVStoreKeys() map[string]storetypes.StoreKey {
124+
return make(map[string]storetypes.StoreKey)
125125
}

x/vm/statedb/statedb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func (s *StateDB) cache() error {
199199
s.cacheCtx, _ = s.ctx.CacheContext()
200200

201201
// Get KVStores for modules wired to app
202-
cms := s.cacheCtx.MultiStore().(storetypes.CacheMultiStore)
202+
cms := s.cacheCtx.MultiStore()
203203
storeKeys := s.keeper.KVStoreKeys()
204204

205205
// Create and set snapshot store to stateDB

0 commit comments

Comments
 (0)