Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions ante/evm/01_setup_ctx.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package evm

import (
anteinterfaces "github.com/cosmos/evm/ante/interfaces"
evmante "github.com/cosmos/evm/x/vm/ante"

errorsmod "cosmossdk.io/errors"
Expand All @@ -16,18 +15,14 @@ var _ sdktypes.AnteDecorator = &EthSetupContextDecorator{}

// EthSetupContextDecorator is adapted from SetUpContextDecorator from cosmos-sdk, it ignores gas consumption
// by setting the gas meter to infinite
type EthSetupContextDecorator struct {
evmKeeper anteinterfaces.EVMKeeper
}
type EthSetupContextDecorator struct{}

func NewEthSetUpContextDecorator(evmKeeper anteinterfaces.EVMKeeper) EthSetupContextDecorator {
return EthSetupContextDecorator{
evmKeeper: evmKeeper,
}
func NewEthSetUpContextDecorator() EthSetupContextDecorator {
return EthSetupContextDecorator{}
}

func (esc EthSetupContextDecorator) AnteHandle(ctx sdktypes.Context, tx sdktypes.Tx, simulate bool, next sdktypes.AnteHandler) (newCtx sdktypes.Context, err error) {
newCtx, err = SetupContextAndResetTransientGas(ctx, tx, esc.evmKeeper)
newCtx, err = SetupContextAndResetTransientGas(ctx, tx)
if err != nil {
return ctx, err
}
Expand All @@ -37,7 +32,7 @@ func (esc EthSetupContextDecorator) AnteHandle(ctx sdktypes.Context, tx sdktypes
// SetupContextAndResetTransientGas modifies the context to be used in the
// execution of the ante handler associated with an EVM transaction. Previous
// gas consumed is reset in the transient store.
func SetupContextAndResetTransientGas(ctx sdktypes.Context, tx sdktypes.Tx, evmKeeper anteinterfaces.EVMKeeper) (sdktypes.Context, error) {
func SetupContextAndResetTransientGas(ctx sdktypes.Context, tx sdktypes.Tx) (sdktypes.Context, error) {
// all transactions must implement GasTx
_, ok := tx.(authante.GasTx)
if !ok {
Expand All @@ -50,12 +45,5 @@ func SetupContextAndResetTransientGas(ctx sdktypes.Context, tx sdktypes.Tx, evmK
newCtx := evmante.BuildEvmExecutionCtx(ctx).
WithGasMeter(storetypes.NewInfiniteGasMeter())

// Reset transient gas used to prepare the execution of current cosmos tx.
// Transient gas-used is necessary to sum the gas-used of cosmos tx, when it contains multiple eth msgs.
//
// TODO: add more context here to explain why gas used is reset. Not clear
// from docstring.
evmKeeper.ResetTransientGasUsed(ctx)

return newCtx, nil
}
82 changes: 0 additions & 82 deletions ante/evm/10_gas_wanted.go

This file was deleted.

64 changes: 0 additions & 64 deletions ante/evm/11_emit_event.go

This file was deleted.

4 changes: 0 additions & 4 deletions ante/evm/fee_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ func (m MockFeemarketKeeper) GetBaseFeeEnabled(_ sdk.Context) bool {
return true
}

func (m MockFeemarketKeeper) AddTransientGasWanted(_ sdk.Context, _ uint64) (uint64, error) {
return 0, nil
}

func (m MockFeemarketKeeper) GetParams(_ sdk.Context) (params feemarkettypes.Params) {
return feemarkettypes.DefaultParams()
}
Expand Down
11 changes: 1 addition & 10 deletions ante/evm/mono_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (md MonoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
evmDenom := evmtypes.GetEVMCoinDenom()

// 1. setup ctx
ctx, err = SetupContextAndResetTransientGas(ctx, tx, md.evmKeeper)
ctx, err = SetupContextAndResetTransientGas(ctx, tx)
if err != nil {
return ctx, err
}
Expand Down Expand Up @@ -255,15 +255,6 @@ func (md MonoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
return ctx, err
}

// 10. gas wanted
if err := CheckGasWanted(ctx, md.feeMarketKeeper, tx, decUtils.Rules.IsLondon); err != nil {
return ctx, err
}

// 11. emit events
txIdx := uint64(msgIndex) //nolint:gosec // G115
EmitTxHashEvent(ctx, ethMsg, decUtils.BlockTxIndex, txIdx)

if err := CheckTxFee(txFeeInfo, decUtils.TxFee, decUtils.TxGasLimit); err != nil {
return ctx, err
}
Expand Down
11 changes: 6 additions & 5 deletions ante/evm/mono_decorator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@ func (k *ExtendedEVMKeeper) SpendableCoin(ctx sdk.Context, addr common.Address)
return uint256.NewInt(0)
}

func (k *ExtendedEVMKeeper) ResetTransientGasUsed(_ sdk.Context) {}
func (k *ExtendedEVMKeeper) GetParams(_ sdk.Context) evmsdktypes.Params {
return evmsdktypes.DefaultParams()
}
func (k *ExtendedEVMKeeper) GetBaseFee(_ sdk.Context) *big.Int { return big.NewInt(0) }
func (k *ExtendedEVMKeeper) GetMinGasPrice(_ sdk.Context) math.LegacyDec { return math.LegacyZeroDec() }
func (k *ExtendedEVMKeeper) GetTxIndexTransient(_ sdk.Context) uint64 { return 0 }

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

func (m MockFeeMarketKeeper) AddTransientGasWanted(_ sdk.Context, _ uint64) (uint64, error) {
return 0, nil
}
func (m MockFeeMarketKeeper) GetBaseFeeEnabled(_ sdk.Context) bool { return true }
func (m MockFeeMarketKeeper) GetBaseFee(_ sdk.Context) math.LegacyDec { return math.LegacyZeroDec() }

Expand Down Expand Up @@ -202,6 +197,12 @@ func TestMonoDecorator(t *testing.T) {
monoDec := evm.NewEVMMonoDecorator(accountKeeper, MockFeeMarketKeeper{}, keeper, 0)
ctx := sdk.NewContext(nil, tmproto.Header{}, false, log.NewNopLogger())
ctx = ctx.WithBlockGasMeter(storetypes.NewGasMeter(1e19))
blockParams := tmproto.BlockParams{
MaxBytes: 200000,
MaxGas: 81500000, // default limit
}
consParams := tmproto.ConsensusParams{Block: &blockParams}
ctx = ctx.WithConsensusParams(consParams)

msgs := tc.buildMsgs(privKey)
tx, err := utiltx.PrepareEthTx(cfg.TxConfig, nil, toMsgSlice(msgs)...)
Expand Down
1 change: 0 additions & 1 deletion ante/evm/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func NewMonoDecoratorUtils(
BaseFee: baseFee,
MempoolMinGasPrice: mempoolMinGasPrice,
GlobalMinGasPrice: globalMinGasPrice,
BlockTxIndex: ek.GetTxIndexTransient(ctx),
GasWanted: 0,
MinPriority: int64(math.MaxInt64),
// TxGasLimit and TxFee are set to zero because they are updated
Expand Down
3 changes: 0 additions & 3 deletions ante/interfaces/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ type EVMKeeper interface {
stateDB vm.StateDB) *vm.EVM
DeductTxCostsFromUserBalance(ctx sdk.Context, fees sdk.Coins, from common.Address) error
SpendableCoin(ctx sdk.Context, addr common.Address) *uint256.Int
ResetTransientGasUsed(ctx sdk.Context)
GetTxIndexTransient(ctx sdk.Context) uint64
GetParams(ctx sdk.Context) evmtypes.Params
// GetBaseFee returns the BaseFee param from the fee market module
// adapted according to the evm denom decimals
Expand All @@ -41,7 +39,6 @@ type EVMKeeper interface {
// FeeMarketKeeper exposes the required feemarket keeper interface required for ante handlers
type FeeMarketKeeper interface {
GetParams(ctx sdk.Context) (params feemarkettypes.Params)
AddTransientGasWanted(ctx sdk.Context, gasWanted uint64) (uint64, error)
GetBaseFeeEnabled(ctx sdk.Context) bool
GetBaseFee(ctx sdk.Context) math.LegacyDec
}
Expand Down
2 changes: 0 additions & 2 deletions evmd/ante/cosmos_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ante
import (
baseevmante "github.com/cosmos/evm/ante"
cosmosante "github.com/cosmos/evm/ante/cosmos"
evmante "github.com/cosmos/evm/ante/evm"
evmtypes "github.com/cosmos/evm/x/vm/types"
ibcante "github.com/cosmos/ibc-go/v10/modules/core/ante"

Expand Down Expand Up @@ -35,6 +34,5 @@ func newCosmosAnteHandler(options baseevmante.HandlerOptions) sdk.AnteHandler {
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
evmante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper),
)
}
Loading
Loading