ante

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeductFees added in v0.10.0

func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc types.AccountI, fees sdk.Coins) error

DeductFees deducts fees from the given account.

func DefaultSigVerificationGasConsumer

func DefaultSigVerificationGasConsumer(
	meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params,
) error

DefaultSigVerificationGasConsumer is the default implementation of SignatureVerificationGasConsumer. It consumes gas for signature verification based upon the public key type. The cost is fetched from the given params and is matched by the concrete type.

func NewAnteHandler

func NewAnteHandler(options HandlerOptions) sdk.AnteHandler

NewAnteHandler returns an ante handler responsible for attempting to route an Ethereum or SDK transaction to an internal ante handler for performing transaction-level processing (e.g. fee payment, signature verification) before being passed onto it's respective handler.

func Recover

func Recover(logger tmlog.Logger, err *error)

Types

type AccountKeeper added in v0.10.0

type AccountKeeper interface {
	GetParams(ctx sdk.Context) (params authtypes.Params)
	GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
	SetAccount(ctx sdk.Context, acc authtypes.AccountI)
	GetModuleAddress(moduleName string) sdk.AccAddress
}

AccountKeeper defines the contract needed for AccountKeeper related APIs. Interface provides support to use non-sdk AccountKeeper for AnteHandler's decorators.

type CanTransferDecorator

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

func NewCanTransferDecorator(evmKeeper EVMKeeper) CanTransferDecorator

NewCanTransferDecorator creates a new CanTransferDecorator instance.

func (CanTransferDecorator) AnteHandle

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 DeductFeeDecorator added in v0.10.0

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

DeductFeeDecorator deducts fees from the first signer of the tx If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error Call next AnteHandler if fees successfully deducted CONTRACT: Tx must implement FeeTx interface to use DeductFeeDecorator

func NewDeductFeeDecorator added in v0.10.0

func NewDeductFeeDecorator(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper) DeductFeeDecorator

func (DeductFeeDecorator) AnteHandle added in v0.10.0

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

type EVMKeeper

type EVMKeeper interface {
	statedb.Keeper

	GetParams(ctx sdk.Context) evmtypes.Params
	NewEVM(ctx sdk.Context, msg core.Message, cfg *evmtypes.EVMConfig, tracer vm.EVMLogger, stateDB vm.StateDB) *vm.EVM
	DeductTxCostsFromUserBalance(
		ctx sdk.Context, msgEthTx evmtypes.MsgEthereumTx, txData evmtypes.TxData, denom string, homestead, istanbul, london bool,
	) (sdk.Coins, error)
	GetBaseFee(ctx sdk.Context, ethCfg *params.ChainConfig) *big.Int
	GetBalance(ctx sdk.Context, addr common.Address) *big.Int
	ResetTransientGasUsed(ctx sdk.Context)
}

EVMKeeper defines the expected keeper interface used on the Eth AnteHandler

type EthAccountVerificationDecorator

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

EthAccountVerificationDecorator validates an account balance checks

func NewEthAccountVerificationDecorator

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

NewEthAccountVerificationDecorator creates a new EthAccountVerificationDecorator

func (EthAccountVerificationDecorator) AnteHandle

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 exis, 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 EthGasConsumeDecorator

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

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

func NewEthGasConsumeDecorator

func NewEthGasConsumeDecorator(
	evmKeeper EVMKeeper,
	maxGasWanted uint64,
) EthGasConsumeDecorator

NewEthGasConsumeDecorator creates a new EthGasConsumeDecorator

func (EthGasConsumeDecorator) AnteHandle

func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err 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.

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 inccured 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 doesn't have enough balance to deduct the transaction fees (gas_limit * gas_price) - transaction or block gas meter runs out of gas - sets the gas meter limit

type EthIncrementSenderSequenceDecorator

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

EthIncrementSenderSequenceDecorator increments the sequence of the signers.

func NewEthIncrementSenderSequenceDecorator

func NewEthIncrementSenderSequenceDecorator(ak evmtypes.AccountKeeper) EthIncrementSenderSequenceDecorator

NewEthIncrementSenderSequenceDecorator creates a new EthIncrementSenderSequenceDecorator.

func (EthIncrementSenderSequenceDecorator) AnteHandle

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

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

func NewEthMempoolFeeDecorator(ek EVMKeeper) EthMempoolFeeDecorator

func (EthMempoolFeeDecorator) AnteHandle

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, if this is a CheckTx. This is only for local mempool purposes, and thus is only ran on check tx. It only do the check if london hardfork not enabled or feemarket not enabled, because in that case feemarket will take over the task.

type EthSetupContextDecorator

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

func NewEthSetUpContextDecorator(evmKeeper EVMKeeper) EthSetupContextDecorator

func (EthSetupContextDecorator) AnteHandle

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

type EthSigVerificationDecorator

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

EthSigVerificationDecorator validates an ethereum signatures

func NewEthSigVerificationDecorator

func NewEthSigVerificationDecorator(ek EVMKeeper) EthSigVerificationDecorator

NewEthSigVerificationDecorator creates a new EthSigVerificationDecorator

func (EthSigVerificationDecorator) AnteHandle

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 EthTxPayloadVerificationDecorator added in v0.10.0

type EthTxPayloadVerificationDecorator struct {
}

EthTxPayloadVerificationDecorator validates base tx payload and check some limitations

func NewEthTxPayloadVerificationDecorator added in v0.10.0

func NewEthTxPayloadVerificationDecorator() EthTxPayloadVerificationDecorator

func (EthTxPayloadVerificationDecorator) AnteHandle added in v0.10.0

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

AnteHandle validates msgs count, some signature protection and applied limitations

type EthValidateBasicDecorator

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

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

func NewEthValidateBasicDecorator

func NewEthValidateBasicDecorator(ek EVMKeeper) EthValidateBasicDecorator

NewEthValidateBasicDecorator creates a new EthValidateBasicDecorator

func (EthValidateBasicDecorator) AnteHandle

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 FeegrantKeeper added in v0.10.0

type FeegrantKeeper interface {
	UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins, msgs []sdk.Msg) error
}

FeegrantKeeper defines the expected feegrant keeper.

type HandlerOptions

type HandlerOptions struct {
	AccountKeeper   evmtypes.AccountKeeper
	BankKeeper      evmtypes.BankKeeper
	IBCKeeper       *ibckeeper.Keeper
	EvmKeeper       EVMKeeper
	FeegrantKeeper  ante.FeegrantKeeper
	SignModeHandler authsigning.SignModeHandler
	SigGasConsumer  func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error
	MaxTxGasWanted  uint64
}

HandlerOptions extend the SDK's AnteHandler options by requiring the IBC channel keeper, EVM Keeper and Fee Market Keeper.

func (HandlerOptions) Validate

func (options HandlerOptions) Validate() error

type MempoolFeeDecorator added in v0.10.0

type MempoolFeeDecorator struct{}

MempoolFeeDecorator will check if the transaction's 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 NewMempoolFeeDecorator added in v0.10.0

func NewMempoolFeeDecorator() MempoolFeeDecorator

func (MempoolFeeDecorator) AnteHandle added in v0.10.0

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

type RejectMessagesDecorator

type RejectMessagesDecorator struct{}

RejectMessagesDecorator prevents invalid msg types from being executed

func (RejectMessagesDecorator) AnteHandle

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

AnteHandle rejects messages that requires ethereum-specific authentication. For example `MsgEthereumTx` requires fee to be deducted in the antehandler in order to perform the refund.

Jump to

Keyboard shortcuts

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