AnteHandler v7
The AnteHandler chains together several decorators to ensure the following criteria are met for app version 7:
- Panics are wrapped with the transaction string format for better error reporting.
- A gas meter is set up in the context before any gas consumption occurs.
- The tx does not contain any messages that are disabled by the circuit breaker (e.g.
MsgSoftwareUpgrade,MsgCancelUpgrade,MsgIBCSoftwareUpgrade). - The tx does not contain any extension options.
- [New in v7] If the tx contains a single
MsgPayProtocolFee, it is handled by theProtocolFeeTerminatorDecoratorwhich terminates the ante chain early after validating and deducting fees. - The tx passes
ValidateBasic(). - The tx's timeout_height has not been reached if one is specified.
- The tx's memo is <= the max memo characters where
MaxMemoCharacters = 256. - The tx's gas_limit is > the gas consumed based on the tx's size where
TxSizeCostPerByte = 10. - [New in v7] If the tx is a fee forward transaction:
- User-submitted fee forward transactions are rejected in
CheckTx,ReCheckTx, and simulation mode. Only protocol-injected transactions fromPrepareProposalare accepted. - The fee must be exactly one coin in utia with a positive amount.
- The fee is deducted from the fee address and sent to the fee collector.
- User-submitted fee forward transactions are rejected in
- The tx's feepayer has enough funds to pay fees for the tx. The tx's feepayer is the feegranter (if specified) or the tx's first signer. Note the feegrant module is enabled.
- The tx's gas price is >= the network minimum gas price where
NetworkMinGasPrice = 0.000001utia. - Public keys are set in the context for the fee-payer and all signers.
- The tx's count of signatures <= the max number of signatures. The max number of signatures is
TxSigLimit = 7. - The tx's gas_limit is > the gas consumed based on the tx's signatures.
- The tx's signatures are valid. For each signature, ensure that the signature's sequence number (a.k.a nonce) matches the account sequence number of the signer.
- The tx does not contain a
MsgExecwith a nestedMsgExecorMsgPayForBlobs. - [New in v7] The tx does not send non-utia tokens to the fee address. Only utia can be sent to the fee address via
MsgSend,MsgMultiSend, or nestedMsgExecmessages. - The tx's gas_limit is > the gas consumed based on the blob size(s). Since blobs are charged based on the number of shares they occupy, the gas consumed is calculated as follows:
gasToConsume = sharesNeeded(blob) * bytesPerShare * gasPerBlobByte. WherebytesPerShareis a global constant (an alias forShareSize = 512) from the go-square package andgasPerBlobByteis a versioned constant that can be modified through hard forks (theGasPerBlobByte = 8). - The tx's total blob share count is <= the max blob share count. The max blob share count is derived from the maximum valid square size. The max valid square size is the minimum of:
GovMaxSquareSizeandSquareSizeUpperBound. - The tx does not contain a message of type MsgSubmitProposal with zero proposal messages or with a proposal message that modifies a parameter that is not governance modifiable.
- The nonce of all tx signers is incremented by 1. [New in v7] Fee forward transactions are exempt from this since they have no signers.
- The tx is not an IBC packet or update message that has already been processed.
In addition to the above criteria, the AnteHandler also has a number of side-effects:
- Tx fees are deducted from the tx's feepayer and added to the fee collector module account. [New in v7] For fee forward transactions, fees are deducted from the fee address instead.
- Tx priority is calculated based on the smallest denomination of gas price in the tx and set in context.
- The nonce of all tx signers is incremented by 1.
Fee Forwarding (New in v7)
App version 7 introduces a fee address mechanism (see pkg/feeaddress) which enables forwarding tokens to delegators as staking rewards. The ante handler includes two decorators to support this:
-
ProtocolFeeTerminatorDecorator: Handles
MsgPayProtocolFeetransactions completely and terminates the ante chain early. This decorator:- Detects
MsgPayProtocolFeetransactions - Rejects user-submitted transactions (only protocol-injected transactions from block proposers are allowed)
- Validates the fee is exactly one utia coin with positive amount
- Deducts the fee from the fee address and sends it to the fee collector
- Returns without calling the rest of the ante chain (no signatures to verify, no sequence to increment)
- Detects
-
FeeAddressDecorator: Ensures only utia can be sent to the fee address via standard bank transfers. This prevents non-utia tokens from being permanently stuck at the fee address.