evm

package
v1.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDynamicFeeChecker added in v1.6.0

func NewDynamicFeeChecker(k DynamicFeeEVMKeeper) anteutils.TxFeeChecker

NewDynamicFeeChecker returns a `TxFeeChecker` that applies a dynamic fee to Cosmos txs using the EIP-1559 fee market logic. This can be called in both CheckTx and deliverTx modes. a) feeCap = tx.fees / tx.gas b) tipFeeCap = tx.MaxPriorityPrice (default) or MaxInt64 - when `ExtensionOptionDynamicFeeTx` is omitted, `tipFeeCap` defaults to `MaxInt64`. - when london hardfork is not enabled, it falls back to SDK default behavior (validator min-gas-prices). - Tx priority is set to `effectiveGasPrice / DefaultPriorityReduction`.

Types

type CanTransferDecorator added in v1.6.0

type CanTransferDecorator struct {
	// contains filtered or unexported fields
}

CanTransferDecorator checks if the sender is allowed to transfer funds according to the EVM block context rules.

func NewCanTransferDecorator added in v1.6.0

func NewCanTransferDecorator(evmKeeper EVMKeeper) CanTransferDecorator

NewCanTransferDecorator creates a new CanTransferDecorator instance.

func (CanTransferDecorator) AnteHandle added in v1.6.0

func (ctd CanTransferDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error)

AnteHandle creates an EVM from the message and calls the BlockContext CanTransfer function to see if the address can execute the transaction.

type DynamicFeeEVMKeeper added in v1.6.0

type DynamicFeeEVMKeeper interface {
	ChainID() *big.Int
	GetParams(ctx sdk.Context) evmtypes.Params
	GetBaseFee(ctx sdk.Context, ethCfg *params.ChainConfig) *big.Int
}

DynamicFeeEVMKeeper is a subset of EVMKeeper interface that supports dynamic fee checker

type EVMKeeper added in v1.6.0

type EVMKeeper interface {
	statedb.Keeper
	DynamicFeeEVMKeeper

	NewEVM(ctx sdk.Context, msg core.Message, cfg *statedb.EVMConfig, tracer vm.EVMLogger, stateDB vm.StateDB) *vm.EVM
	DeductTxCostsFromUserBalance(ctx sdk.Context, fees sdk.Coins, from common.Address) error
	GetBalance(ctx sdk.Context, addr common.Address) *big.Int
	ResetTransientGasUsed(ctx sdk.Context)
	GetTxIndexTransient(ctx sdk.Context) uint64
	GetParams(ctx sdk.Context) evmtypes.Params
}

EVMKeeper defines the expected keeper interface used on the AnteHandler

type EthAccountVerificationDecorator added in v1.6.0

type EthAccountVerificationDecorator struct {
	// contains filtered or unexported fields
}

EthAccountVerificationDecorator validates an account balance checks

func NewEthAccountVerificationDecorator added in v1.6.0

func NewEthAccountVerificationDecorator(ak evmtypes.AccountKeeper, ek EVMKeeper) EthAccountVerificationDecorator

NewEthAccountVerificationDecorator creates a new EthAccountVerificationDecorator

func (EthAccountVerificationDecorator) AnteHandle added in v1.6.0

func (avd EthAccountVerificationDecorator) AnteHandle(
	ctx sdk.Context,
	tx sdk.Tx,
	simulate bool,
	next sdk.AnteHandler,
) (newCtx sdk.Context, err error)

AnteHandle validates checks that the sender balance is greater than the total transaction cost. The account will be set to store if it doesn't exist, i.e. cannot be found on store. This AnteHandler decorator will fail if: - any of the msgs is not a MsgEthereumTx - from address is empty - account balance is lower than the transaction cost

type EthEmitEventDecorator added in v1.6.0

type EthEmitEventDecorator struct {
	// contains filtered or unexported fields
}

EthEmitEventDecorator emit events in ante handler in case of tx execution failed (out of block gas limit).

func NewEthEmitEventDecorator added in v1.6.0

func NewEthEmitEventDecorator(evmKeeper EVMKeeper) EthEmitEventDecorator

NewEthEmitEventDecorator creates a new EthEmitEventDecorator

func (EthEmitEventDecorator) AnteHandle added in v1.6.0

func (eeed EthEmitEventDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

AnteHandle emits some basic events for the eth messages

type EthGasConsumeDecorator added in v1.6.0

type EthGasConsumeDecorator struct {
	// contains filtered or unexported fields
}

EthGasConsumeDecorator validates enough intrinsic gas for the transaction and gas consumption.

func NewEthGasConsumeDecorator added in v1.6.0

func NewEthGasConsumeDecorator(
	bankKeeper anteutils.BankKeeper,
	distributionKeeper anteutils.DistributionKeeper,
	evmKeeper EVMKeeper,
	stakingKeeper anteutils.StakingKeeper,
	maxGasWanted uint64,
) EthGasConsumeDecorator

NewEthGasConsumeDecorator creates a new EthGasConsumeDecorator

func (EthGasConsumeDecorator) AnteHandle added in v1.6.0

func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error)

AnteHandle validates that the Ethereum tx message has enough to cover intrinsic gas (during CheckTx only) and that the sender has enough balance to pay for the gas cost. If the balance is not sufficient, it will be attempted to withdraw enough staking rewards for the payment.

Intrinsic gas for a transaction is the amount of gas that the transaction uses before the transaction is executed. The gas is a constant value plus any cost incurred by additional bytes of data supplied with the transaction.

This AnteHandler decorator will fail if: - the message is not a MsgEthereumTx - sender account cannot be found - transaction's gas limit is lower than the intrinsic gas - user has neither enough balance nor staking rewards to deduct the transaction fees (gas_limit * gas_price) - transaction or block gas meter runs out of gas - sets the gas meter limit - gas limit is greater than the block gas meter limit

type EthIncrementSenderSequenceDecorator added in v1.6.0

type EthIncrementSenderSequenceDecorator struct {
	// contains filtered or unexported fields
}

EthIncrementSenderSequenceDecorator increments the sequence of the signers.

func NewEthIncrementSenderSequenceDecorator added in v1.6.0

func NewEthIncrementSenderSequenceDecorator(ak evmtypes.AccountKeeper) EthIncrementSenderSequenceDecorator

NewEthIncrementSenderSequenceDecorator creates a new EthIncrementSenderSequenceDecorator.

func (EthIncrementSenderSequenceDecorator) AnteHandle added in v1.6.0

func (issd EthIncrementSenderSequenceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error)

AnteHandle handles incrementing the sequence of the signer (i.e. sender). If the transaction is a contract creation, the nonce will be incremented during the transaction execution and not within this AnteHandler decorator.

type EthMempoolFeeDecorator added in v1.6.0

type EthMempoolFeeDecorator struct {
	// contains filtered or unexported fields
}

EthMempoolFeeDecorator will check if the transaction's effective fee is at least as large as the local validator's minimum gasFee (defined in validator config). If fee is too low, decorator returns error and tx is rejected from mempool. Note this only applies when ctx.CheckTx = true If fee is high enough or not CheckTx, then call next AnteHandler CONTRACT: Tx must implement FeeTx to use MempoolFeeDecorator

func NewEthMempoolFeeDecorator added in v1.6.0

func NewEthMempoolFeeDecorator(ek EVMKeeper) EthMempoolFeeDecorator

NewEthMempoolFeeDecorator creates a new NewEthMempoolFeeDecorator instance used only for Ethereum transactions.

func (EthMempoolFeeDecorator) AnteHandle added in v1.6.0

func (mfd EthMempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

AnteHandle ensures that the provided fees meet a minimum threshold for the validator. This check only for local mempool purposes, and thus it is only run on (Re)CheckTx. The logic is also skipped if the London hard fork and EIP-1559 are enabled.

type EthMinGasPriceDecorator added in v1.6.0

type EthMinGasPriceDecorator struct {
	// contains filtered or unexported fields
}

EthMinGasPriceDecorator will check if the transaction's fee is at least as large as the MinGasPrices param. If fee is too low, decorator returns error and tx is rejected. This applies to both CheckTx and DeliverTx and regardless if London hard fork or fee market params (EIP-1559) are enabled. If fee is high enough, then call next AnteHandler

func NewEthMinGasPriceDecorator added in v1.6.0

func NewEthMinGasPriceDecorator(fk FeeMarketKeeper, ek EVMKeeper) EthMinGasPriceDecorator

NewEthMinGasPriceDecorator creates a new MinGasPriceDecorator instance used only for Ethereum transactions.

func (EthMinGasPriceDecorator) AnteHandle added in v1.6.0

func (empd EthMinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

AnteHandle ensures that the effective fee from the transaction is greater than the minimum global fee, which is defined by the MinGasPrice (parameter) * GasLimit (tx argument).

type EthSetupContextDecorator added in v1.6.0

type EthSetupContextDecorator struct {
	// contains filtered or unexported fields
}

EthSetupContextDecorator is adapted from SetUpContextDecorator from cosmos-sdk, it ignores gas consumption by setting the gas meter to infinite

func NewEthSetUpContextDecorator added in v1.6.0

func NewEthSetUpContextDecorator(evmKeeper EVMKeeper) EthSetupContextDecorator

func (EthSetupContextDecorator) AnteHandle added in v1.6.0

func (esc EthSetupContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

type EthSigVerificationDecorator added in v1.6.0

type EthSigVerificationDecorator struct {
	// contains filtered or unexported fields
}

EthSigVerificationDecorator validates an ethereum signatures

func NewEthSigVerificationDecorator added in v1.6.0

func NewEthSigVerificationDecorator(ek EVMKeeper) EthSigVerificationDecorator

NewEthSigVerificationDecorator creates a new EthSigVerificationDecorator

func (EthSigVerificationDecorator) AnteHandle added in v1.6.0

func (esvd EthSigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

AnteHandle validates checks that the registered chain id is the same as the one on the message, and that the signer address matches the one defined on the message. It's not skipped for RecheckTx, because it set `From` address which is critical from other ante handler to work. Failure in RecheckTx will prevent tx to be included into block, especially when CheckTx succeed, in which case user won't see the error message.

type EthValidateBasicDecorator added in v1.6.0

type EthValidateBasicDecorator struct {
	// contains filtered or unexported fields
}

EthValidateBasicDecorator is adapted from ValidateBasicDecorator from cosmos-sdk, it ignores ErrNoSignatures

func NewEthValidateBasicDecorator added in v1.6.0

func NewEthValidateBasicDecorator(ek EVMKeeper) EthValidateBasicDecorator

NewEthValidateBasicDecorator creates a new EthValidateBasicDecorator

func (EthValidateBasicDecorator) AnteHandle added in v1.6.0

func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error)

AnteHandle handles basic validation of tx

type EthVestingTransactionDecorator

type EthVestingTransactionDecorator struct {
	// contains filtered or unexported fields
}

EthVestingTransactionDecorator validates if clawback vesting accounts are permitted to perform Ethereum Tx.

func NewEthVestingTransactionDecorator

func NewEthVestingTransactionDecorator(ak evmtypes.AccountKeeper, bk evmtypes.BankKeeper, ek EVMKeeper) EthVestingTransactionDecorator

NewEthVestingTransactionDecorator returns a new EthVestingTransactionDecorator.

func (EthVestingTransactionDecorator) AnteHandle

func (vtd EthVestingTransactionDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

AnteHandle validates that a clawback vesting account has surpassed the vesting cliff and lockup period.

This AnteHandler decorator will fail if:

  • the message is not a MsgEthereumTx
  • sender account cannot be found
  • tx values are in excess of any account's spendable balances

type FeeMarketKeeper added in v1.6.0

type FeeMarketKeeper interface {
	GetParams(ctx sdk.Context) (params feemarkettypes.Params)
	AddTransientGasWanted(ctx sdk.Context, gasWanted uint64) (uint64, error)
	GetBaseFeeEnabled(ctx sdk.Context) bool
}

type GasWantedDecorator added in v1.6.0

type GasWantedDecorator struct {
	// contains filtered or unexported fields
}

GasWantedDecorator keeps track of the gasWanted amount on the current block in transient store for BaseFee calculation. NOTE: This decorator does not perform any validation

func NewGasWantedDecorator added in v1.6.0

func NewGasWantedDecorator(
	evmKeeper EVMKeeper,
	feeMarketKeeper FeeMarketKeeper,
) GasWantedDecorator

NewGasWantedDecorator creates a new NewGasWantedDecorator

func (GasWantedDecorator) AnteHandle added in v1.6.0

func (gwd GasWantedDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL