Skip to content

Commit 432fca6

Browse files
committed
feat: implement object stores
1 parent 2a9e687 commit 432fca6

35 files changed

+719
-1142
lines changed

ante/evm/01_setup_ctx.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,5 @@ func SetupContextAndResetTransientGas(ctx sdktypes.Context, tx sdktypes.Tx, evmK
5050
newCtx := evmante.BuildEvmExecutionCtx(ctx).
5151
WithGasMeter(storetypes.NewInfiniteGasMeter())
5252

53-
// Reset transient gas used to prepare the execution of current cosmos tx.
54-
// Transient gas-used is necessary to sum the gas-used of cosmos tx, when it contains multiple eth msgs.
55-
//
56-
// TODO: add more context here to explain why gas used is reset. Not clear
57-
// from docstring.
58-
evmKeeper.ResetTransientGasUsed(ctx)
59-
6053
return newCtx, nil
6154
}

ante/evm/10_gas_wanted.go

Lines changed: 0 additions & 82 deletions
This file was deleted.

ante/evm/11_emit_event.go

Lines changed: 0 additions & 64 deletions
This file was deleted.

ante/evm/fee_checker_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ func (m MockFeemarketKeeper) GetBaseFeeEnabled(_ sdk.Context) bool {
3939
return true
4040
}
4141

42-
func (m MockFeemarketKeeper) AddTransientGasWanted(_ sdk.Context, _ uint64) (uint64, error) {
43-
return 0, nil
44-
}
45-
4642
func (m MockFeemarketKeeper) GetParams(_ sdk.Context) (params feemarkettypes.Params) {
4743
return feemarkettypes.DefaultParams()
4844
}

ante/evm/mono_decorator.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,6 @@ func (md MonoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
255255
return ctx, err
256256
}
257257

258-
// 10. gas wanted
259-
if err := CheckGasWanted(ctx, md.feeMarketKeeper, tx, decUtils.Rules.IsLondon); err != nil {
260-
return ctx, err
261-
}
262-
263-
// 11. emit events
264-
txIdx := uint64(msgIndex) //nolint:gosec // G115
265-
EmitTxHashEvent(ctx, ethMsg, decUtils.BlockTxIndex, txIdx)
266-
267258
if err := CheckTxFee(txFeeInfo, decUtils.TxFee, decUtils.TxGasLimit); err != nil {
268259
return ctx, err
269260
}

ante/evm/mono_decorator_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@ func (k *ExtendedEVMKeeper) SpendableCoin(ctx sdk.Context, addr common.Address)
6262
return uint256.NewInt(0)
6363
}
6464

65-
func (k *ExtendedEVMKeeper) ResetTransientGasUsed(_ sdk.Context) {}
6665
func (k *ExtendedEVMKeeper) GetParams(_ sdk.Context) evmsdktypes.Params {
6766
return evmsdktypes.DefaultParams()
6867
}
6968
func (k *ExtendedEVMKeeper) GetBaseFee(_ sdk.Context) *big.Int { return big.NewInt(0) }
7069
func (k *ExtendedEVMKeeper) GetMinGasPrice(_ sdk.Context) math.LegacyDec { return math.LegacyZeroDec() }
71-
func (k *ExtendedEVMKeeper) GetTxIndexTransient(_ sdk.Context) uint64 { return 0 }
7270

7371
// only methods called by EVMMonoDecorator
7472
type MockFeeMarketKeeper struct{}
@@ -77,9 +75,6 @@ func (m MockFeeMarketKeeper) GetParams(_ sdk.Context) feemarkettypes.Params {
7775
return feemarkettypes.DefaultParams()
7876
}
7977

80-
func (m MockFeeMarketKeeper) AddTransientGasWanted(_ sdk.Context, _ uint64) (uint64, error) {
81-
return 0, nil
82-
}
8378
func (m MockFeeMarketKeeper) GetBaseFeeEnabled(_ sdk.Context) bool { return true }
8479
func (m MockFeeMarketKeeper) GetBaseFee(_ sdk.Context) math.LegacyDec { return math.LegacyZeroDec() }
8580

ante/evm/utils.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ func NewMonoDecoratorUtils(
7171
BaseFee: baseFee,
7272
MempoolMinGasPrice: mempoolMinGasPrice,
7373
GlobalMinGasPrice: globalMinGasPrice,
74-
BlockTxIndex: ek.GetTxIndexTransient(ctx),
7574
GasWanted: 0,
7675
MinPriority: int64(math.MaxInt64),
7776
// TxGasLimit and TxFee are set to zero because they are updated

ante/interfaces/evm.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ type EVMKeeper interface {
2727
stateDB vm.StateDB) *vm.EVM
2828
DeductTxCostsFromUserBalance(ctx sdk.Context, fees sdk.Coins, from common.Address) error
2929
SpendableCoin(ctx sdk.Context, addr common.Address) *uint256.Int
30-
ResetTransientGasUsed(ctx sdk.Context)
31-
GetTxIndexTransient(ctx sdk.Context) uint64
3230
GetParams(ctx sdk.Context) evmtypes.Params
3331
// GetBaseFee returns the BaseFee param from the fee market module
3432
// adapted according to the evm denom decimals
@@ -41,7 +39,6 @@ type EVMKeeper interface {
4139
// FeeMarketKeeper exposes the required feemarket keeper interface required for ante handlers
4240
type FeeMarketKeeper interface {
4341
GetParams(ctx sdk.Context) (params feemarkettypes.Params)
44-
AddTransientGasWanted(ctx sdk.Context, gasWanted uint64) (uint64, error)
4542
GetBaseFeeEnabled(ctx sdk.Context) bool
4643
GetBaseFee(ctx sdk.Context) math.LegacyDec
4744
}

evmd/ante/cosmos_handler.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package ante
33
import (
44
baseevmante "github.com/cosmos/evm/ante"
55
cosmosante "github.com/cosmos/evm/ante/cosmos"
6-
evmante "github.com/cosmos/evm/ante/evm"
76
evmtypes "github.com/cosmos/evm/x/vm/types"
87
ibcante "github.com/cosmos/ibc-go/v10/modules/core/ante"
98

@@ -35,6 +34,5 @@ func newCosmosAnteHandler(options baseevmante.HandlerOptions) sdk.AnteHandler {
3534
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
3635
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
3736
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
38-
evmante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper),
3937
)
4038
}

evmd/app.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ type EVMD struct {
172172
keys map[string]*storetypes.KVStoreKey
173173
tkeys map[string]*storetypes.TransientStoreKey
174174
memKeys map[string]*storetypes.MemoryStoreKey
175+
okeys map[string]*storetypes.ObjectStoreKey
175176

176177
// keepers
177178
AccountKeeper authkeeper.AccountKeeper
@@ -267,6 +268,8 @@ func NewExampleApp(
267268
bApp.SetVersion(version.Version)
268269
bApp.SetInterfaceRegistry(interfaceRegistry)
269270
bApp.SetTxEncoder(txConfig.TxEncoder())
271+
bApp.SetTxExecutor(DefaultTxExecutor)
272+
bApp.SetDisableBlockGasMeter(true)
270273

271274
// initialize the Cosmos EVM application configuration
272275
if err := evmAppOptions(evmChainID); err != nil {
@@ -284,7 +287,8 @@ func NewExampleApp(
284287
evmtypes.StoreKey, feemarkettypes.StoreKey, erc20types.StoreKey, precisebanktypes.StoreKey,
285288
)
286289

287-
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey)
290+
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
291+
okeys := storetypes.NewObjectStoreKeys(banktypes.ObjectStoreKey, evmtypes.ObjectStoreKey, feemarkettypes.ObjectStoreKey)
288292

289293
// load state streaming if enabled
290294
if err := bApp.RegisterStreamingServices(appOpts, keys); err != nil {
@@ -305,6 +309,7 @@ func NewExampleApp(
305309
interfaceRegistry: interfaceRegistry,
306310
keys: keys,
307311
tkeys: tkeys,
312+
okeys: okeys,
308313
}
309314

310315
app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
@@ -332,6 +337,7 @@ func NewExampleApp(
332337

333338
app.BankKeeper = bankkeeper.NewBaseKeeper(
334339
appCodec,
340+
okeys[banktypes.ObjectStoreKey],
335341
runtime.NewKVStoreService(keys[banktypes.StoreKey]),
336342
app.AccountKeeper,
337343
evmdconfig.BlockedAddresses(),
@@ -464,7 +470,7 @@ func NewExampleApp(
464470
app.FeeMarketKeeper = feemarketkeeper.NewKeeper(
465471
appCodec, authtypes.NewModuleAddress(govtypes.ModuleName),
466472
keys[feemarkettypes.StoreKey],
467-
tkeys[feemarkettypes.TransientKey],
473+
okeys[feemarkettypes.ObjectStoreKey],
468474
)
469475

470476
// Set up PreciseBank keeper
@@ -483,7 +489,7 @@ func NewExampleApp(
483489
// NOTE: it's required to set up the EVM keeper before the ERC-20 keeper, because it is used in its instantiation.
484490
app.EVMKeeper = evmkeeper.NewKeeper(
485491
// TODO: check why this is not adjusted to use the runtime module methods like SDK native keepers
486-
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], keys,
492+
appCodec, keys[evmtypes.StoreKey], okeys[evmtypes.ObjectStoreKey], keys,
487493
authtypes.NewModuleAddress(govtypes.ModuleName),
488494
app.AccountKeeper,
489495
app.PreciseBankKeeper,
@@ -751,6 +757,7 @@ func NewExampleApp(
751757
// initialize stores
752758
app.MountKVStores(keys)
753759
app.MountTransientStores(tkeys)
760+
app.MountObjectStores(okeys)
754761

755762
maxGasWanted := cast.ToUint64(appOpts.Get(srvflags.EVMMaxTxGasWanted))
756763

0 commit comments

Comments
 (0)