Documentation ¶
Overview ¶
Package ante defines the SDK auth module's AnteHandler as well as an internal AnteHandler for an Ethereum transaction (i.e MsgEthereumTx).
During CheckTx, the transaction is passed through a series of pre-message execution validation checks such as signature and account verification in addition to minimum fees being checked. Otherwise, during DeliverTx, the transaction is simply passed to the EVM which will also perform the same series of checks. The distinction is made in CheckTx to prevent spam and DoS attacks.
Index ¶
- func DefaultSigVerificationGasConsumer(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error
- func NewAnteHandler(ak AccountKeeper, bankKeeper BankKeeper, evmKeeper EVMKeeper, ...) sdk.AnteHandler
- func Recover(logger tmlog.Logger, err *error)
- type AccessListDecorator
- type AccountKeeper
- type BankKeeper
- type CanTransferDecorator
- type EVMKeeper
- type EthAccountVerificationDecorator
- type EthGasConsumeDecorator
- type EthIncrementSenderSequenceDecorator
- type EthNonceVerificationDecorator
- type EthSetupContextDecorator
- type EthSigVerificationDecorator
- type EthValidateBasicDecorator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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( ak AccountKeeper, bankKeeper BankKeeper, evmKeeper EVMKeeper, feeGrantKeeper authante.FeegrantKeeper, channelKeeper channelkeeper.Keeper, signModeHandler authsigning.SignModeHandler, ) 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.
Types ¶
type AccessListDecorator ¶
type AccessListDecorator struct {
// contains filtered or unexported fields
}
AccessListDecorator prepare an access list for the sender if Yolov3/Berlin/EIPs 2929 and 2930 are applicable at the current block number.
func NewAccessListDecorator ¶
func NewAccessListDecorator(evmKeeper EVMKeeper) AccessListDecorator
NewAccessListDecorator creates a new AccessListDecorator.
func (AccessListDecorator) AnteHandle ¶
func (ald AccessListDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error)
AnteHandle handles the preparatory steps for executing an EVM state transition with regards to both EIP-2929 and EIP-2930:
- Add sender to access list (2929)
- Add destination to access list (2929)
- Add precompiles to access list (2929)
- Add the contents of the optional tx access list (2930)
The AnteHandler will only prepare the access list if Yolov3/Berlin/EIPs 2929 and 2930 are applicable at the current number.
type AccountKeeper ¶
type AccountKeeper interface { authante.AccountKeeper NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI GetSequence(sdk.Context, sdk.AccAddress) (uint64, error) }
AccountKeeper defines an expected keeper interface for the auth module's AccountKeeper
type BankKeeper ¶
type BankKeeper interface { authtypes.BankKeeper GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin }
BankKeeper defines an expected keeper interface for the bank module's Keeper
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 EVMKeeper ¶
type EVMKeeper interface { vm.StateDB ChainID() *big.Int GetParams(ctx sdk.Context) evmtypes.Params WithContext(ctx sdk.Context) ResetRefundTransient(ctx sdk.Context) GetCoinbaseAddress() (common.Address, error) NewEVM(msg core.Message, config *params.ChainConfig, params evmtypes.Params, coinbase common.Address, tracer vm.Tracer) *vm.EVM GetCodeHash(addr common.Address) common.Hash }
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 AccountKeeper, bankKeeper BankKeeper, 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(ak AccountKeeper, bankKeeper BankKeeper, ek EVMKeeper) 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 transaction contains more than one message - 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
type EthIncrementSenderSequenceDecorator ¶
type EthIncrementSenderSequenceDecorator struct {
// contains filtered or unexported fields
}
EthIncrementSenderSequenceDecorator increments the sequence of the signers.
func NewEthIncrementSenderSequenceDecorator ¶
func NewEthIncrementSenderSequenceDecorator(ak 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 EthNonceVerificationDecorator ¶
type EthNonceVerificationDecorator struct {
// contains filtered or unexported fields
}
EthNonceVerificationDecorator checks that the account nonce from the transaction matches the sender account sequence.
func NewEthNonceVerificationDecorator ¶
func NewEthNonceVerificationDecorator(ak AccountKeeper) EthNonceVerificationDecorator
NewEthNonceVerificationDecorator creates a new EthNonceVerificationDecorator
func (EthNonceVerificationDecorator) AnteHandle ¶
func (nvd EthNonceVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)
AnteHandle validates that the transaction nonces are valid and equivalent to the sender account’s current nonce.
type EthSetupContextDecorator ¶
type EthSetupContextDecorator struct{}
EthSetupContextDecorator is adapted from SetUpContextDecorator from cosmos-sdk, it ignores gas consumption by setting the gas meter to infinite
func NewEthSetUpContextDecorator ¶
func NewEthSetUpContextDecorator() EthSetupContextDecorator
func (EthSetupContextDecorator) AnteHandle ¶
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 EthValidateBasicDecorator ¶
type EthValidateBasicDecorator struct{}
EthValidateBasicDecorator is adapted from ValidateBasicDecorator from cosmos-sdk, it ignores ErrNoSignatures
func NewEthValidateBasicDecorator ¶
func NewEthValidateBasicDecorator() 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