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 ¶
- Constants
- Variables
- func CalculateFee(cdc codec.BinaryCodec, msgs []sdk.Msg, txBytesLen int64, delPrice sdk.Dec, ...) (sdkmath.Int, error)
- func DeductFees(ctx sdk.Context, bankKeeper evmTypes.BankKeeper, ...) error
- func NewAnteHandler(options HandlerOptions) sdk.AnteHandler
- func NewCommissionGasMeter(limit sdk.Gas) sdk.GasMeter
- func SetGasMeter(simulate bool, ctx sdk.Context, gasLimit uint64) sdk.Context
- type BankKeeper
- type CountMsgDecorator
- type EthGasConsumeDecorator
- type EthMinGasPriceDecorator
- type FeeDecorator
- type GasTx
- type HandlerOptions
- type LegacyActualizerDecorator
- type PostCreateAccountDecorator
- type PreCreateAccountDecorator
- type SetUpContextDecorator
- type ValidatorCommissionDecorator
Constants ¶
const (
GasCommissionDesc = "commission"
)
Gas consumption descriptors.
Variables ¶
var ( FeePayerAddressDoesNotExist = errors.New(codespace, 1, "fee payer address does not exist") FeeLessThanCommission = errors.New(codespace, 2, "insufficient funds to pay for fees") FailedToSendCoins = errors.New(codespace, 3, "failed to send coins") InsufficientFundsToPayFee = errors.New(codespace, 4, "insufficient funds to pay for fee") InvalidFeeAmount = errors.New(codespace, 5, "invalid fee amount") UnknownTransaction = errors.New(codespace, 6, "unknown transaction type") CoinReserveInsufficient = errors.New(codespace, 7, "coin reserve balance is not sufficient for transaction") CoinReserveBecomeInsufficient = errors.New(codespace, 8, "coin reserve will become lower than minimal reserve.") NotFeeTxType = errors.New(codespace, 9, "x must be a FeeTx") CountOfMsgsMustBeOne = errors.New(codespace, 10, "count of messages must be 1") InvalidAddressOfCreatedAccount = errors.New(codespace, 11, "invalid address of created account") UnableToFindCreatedAccount = errors.New(codespace, 12, "unable to find created account") )
Functions ¶
func CalculateFee ¶
func DeductFees ¶
func DeductFees(ctx sdk.Context, bankKeeper evmTypes.BankKeeper, coinKeeper cointypes.CoinKeeper, feePayerAddress sdk.AccAddress, fee sdk.Coin, burningFactor sdk.Dec) error
DeductFees deducts fees from the given account.
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.
Types ¶
type BankKeeper ¶ added in v0.1.0
type CountMsgDecorator ¶ added in v0.0.8
type CountMsgDecorator struct { }
Out limits: only 1 message in transaction
func NewCountMsgDecorator ¶ added in v0.0.8
func NewCountMsgDecorator() CountMsgDecorator
func (CountMsgDecorator) AnteHandle ¶ added in v0.0.8
type EthGasConsumeDecorator ¶ added in v0.0.8
type EthGasConsumeDecorator struct {
// contains filtered or unexported fields
}
EthGasConsumeDecorator validates enough intrinsic gas for the transaction and gas consumption.
func NewEthGasConsumeDecorator ¶ added in v0.0.8
func NewEthGasConsumeDecorator( evmKeeper ethante.EVMKeeper, bankKeeper BankKeeper, feeKeeper feetypes.FeeKeeper, maxGasWanted uint64, ) EthGasConsumeDecorator
NewEthGasConsumeDecorator creates a new EthGasConsumeDecorator
func (EthGasConsumeDecorator) AnteHandle ¶ added in v0.0.8
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.
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 EthMinGasPriceDecorator ¶ added in v0.0.8
type EthMinGasPriceDecorator struct {
// contains filtered or unexported fields
}
EthMinGasPriceDecorator is the copy of evmos decorator, but with fixed error type 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
func NewEthMinGasPriceDecorator ¶ added in v0.0.8
func NewEthMinGasPriceDecorator(fk evmante.FeeMarketKeeper, ek evmante.EVMKeeper) EthMinGasPriceDecorator
func (EthMinGasPriceDecorator) AnteHandle ¶ added in v0.0.8
type FeeDecorator ¶
type FeeDecorator struct {
// contains filtered or unexported fields
}
func NewFeeDecorator ¶
func NewFeeDecorator(ck cointypes.CoinKeeper, bk evmTypes.BankKeeper, ak evmTypes.AccountKeeper, fk feetypes.FeeKeeper, cdc codec.BinaryCodec) FeeDecorator
NewFeeDecorator creates new FeeDecorator to deduct fee
func (FeeDecorator) AnteHandle ¶
func (fd FeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)
AnteHandle implements sdk.AnteHandler function.
type HandlerOptions ¶
type HandlerOptions struct { AccountKeeper evmtypes.AccountKeeper BankKeeper bankkeeper.Keeper IBCKeeper *ibckeeper.Keeper FeeMarketKeeper ethante.FeeMarketKeeper EvmKeeper ethante.EVMKeeper FeegrantKeeper authante.FeegrantKeeper CoinKeeper cointypes.CoinKeeper LegacyKeeper legacytypes.LegacyKeeper FeeKeeper feetypes.FeeKeeper SignModeHandler authsigning.SignModeHandler SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error Cdc codec.BinaryCodec MaxTxGasWanted uint64 ExtensionOptionChecker authante.ExtensionOptionChecker TxFeeChecker authante.TxFeeChecker }
HandlerOptions defines the list of module keepers required to run the Decimal AnteHandler decorators.
func (HandlerOptions) Validate ¶
func (options HandlerOptions) Validate() error
Validate checks if the keepers are defined
type LegacyActualizerDecorator ¶ added in v0.0.8
type LegacyActualizerDecorator struct {
// contains filtered or unexported fields
}
func NewLegacyActualizerDecorator ¶ added in v0.0.8
func NewLegacyActualizerDecorator(lk legacyTypes.LegacyKeeper) LegacyActualizerDecorator
NewFeeDecorator creates new FeeDecorator to deduct fee
func (LegacyActualizerDecorator) AnteHandle ¶ added in v0.0.8
func (lad LegacyActualizerDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)
AnteHandle implements sdk.AnteHandler function.
type PostCreateAccountDecorator ¶ added in v0.0.8
type PostCreateAccountDecorator struct {
// contains filtered or unexported fields
}
PostCreateAccountDecorator restores account number in case of check redeeming from account unknown for the blockchain.
func NewPostCreateAccountDecorator ¶ added in v0.0.8
func NewPostCreateAccountDecorator(ak evmtypes.AccountKeeper) PostCreateAccountDecorator
NewPostCreateAccountDecorator creates new PostCreateAccountDecorator.
func (PostCreateAccountDecorator) AnteHandle ¶ added in v0.0.8
func (cad PostCreateAccountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)
AnteHandle implements sdk.AnteHandler function.
type PreCreateAccountDecorator ¶ added in v0.0.8
type PreCreateAccountDecorator struct {
// contains filtered or unexported fields
}
func NewPreCreateAccountDecorator ¶ added in v0.0.8
func NewPreCreateAccountDecorator(ak evmtypes.AccountKeeper) PreCreateAccountDecorator
NewPreCreateAccountDecorator creates new PreCreateAccountDecorator.
func (PreCreateAccountDecorator) AnteHandle ¶ added in v0.0.8
func (cad PreCreateAccountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)
AnteHandle implements sdk.AnteHandler function.
type SetUpContextDecorator ¶
type SetUpContextDecorator struct{}
SetUpContextDecorator sets the GasMeter in the Context and wraps the next AnteHandler with a defer clause to recover from any downstream OutOfGas panics in the AnteHandler chain to return an error with information on gas provided and gas used. CONTRACT: Must be first decorator in the chain CONTRACT: Tx must implement GasTx interface
func NewSetUpContextDecorator ¶
func NewSetUpContextDecorator() SetUpContextDecorator
func (SetUpContextDecorator) AnteHandle ¶
type ValidatorCommissionDecorator ¶
type ValidatorCommissionDecorator struct {
// contains filtered or unexported fields
}
ValidatorCommissionDecorator validates that the validator commission is always greater or equal than the min commission rate
func NewValidatorCommissionDecorator ¶
func NewValidatorCommissionDecorator(cdc codec.BinaryCodec) ValidatorCommissionDecorator
NewValidatorCommissionDecorator creates a new NewValidatorCommissionDecorator
func (ValidatorCommissionDecorator) AnteHandle ¶
func (vcd ValidatorCommissionDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)
AnteHandle checks if the tx contains a staking create validator or edit validator. It errors if the the commission rate is below the min threshold.