ante

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 49 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	// MaxAuthzNestingDepth limits nested authz.MsgExec unpacking before SetUpContext.
	MaxAuthzNestingDepth = 5

	// MaxExtractedMessages caps the flattened message list from a single tx,
	// including nested authz messages.
	MaxExtractedMessages = 32

	// EvmMsgTypeURL is the type URL for EVM messages
	EvmMsgTypeURL = "/cosmos.evm.vm.v1.MsgEthereumTx"
)

Variables

This section is empty.

Functions

func DisabledAuthzMsgTypeURLs added in v0.5.0

func DisabledAuthzMsgTypeURLs() []string

DisabledAuthzMsgTypeURLs is the set of message type URLs that cannot be granted or executed through authz.MsgGrant / MsgExec.

A message belongs here iff executing it requires the signer to *be* something the grantee is not: the owner of the assets being moved, the module authority, the client creator, or an allow-listed relayer. Delegating it hands over that identity.

Permissionless messages do NOT belong here. authz never rewrites the inner message's signer -- x/authz/keeper/keeper.go:110-130 reads the signer off the message itself, treats it as the granter, and requires a grant from it -- so a message with no signer check is equally executable by anyone: listing it removes no capability, only makes the list longer. IBC's entire relayer surface therefore stays grantable, MsgChannelCloseInit included (it never reads the signer, ibc-go modules/core/keeper/msg_server.go:374). ibc_authz_inventory_test.go asserts this classification, permissionless half included, against the protobuf descriptors -- extend the list there and the test names the family you missed.

gov v1 and v1beta1 are both listed because SDK 0.53 still registers the legacy vote/submit/deposit messages, and the limiter matches type URLs exactly.

Two entries were removed; neither is derivable from the rule and neither is an escalation:

  • MsgUpdateClient's relayer allow-list is real and always runs -- ibc-go's core keeper constructs ClientV2Keeper itself (modules/core/keeper/keeper.go:53), so the nil guard at msg_server.go:87-93 is always taken. It is inert because of the *configuration*: GetConfig returns an empty Config for any client that never called MsgUpdateClientConfig, and an empty list admits everyone (modules/core/02-client/v2/types/config.go:19). A client is permissionless to update until its creator opts in, and opting in is consenting.
  • MsgUpgradeClient has no signer check to find: its handler (msg_server.go:108-122) never reads msg.Signer, and the keeper it calls (modules/core/02-client/keeper/client.go:88) takes no signer argument. Its grant was a no-op that only appeared to restrict client upgrades.

app/ibc_v2_authz_guard_test.go pins the permissive default the MsgUpdateClient removal relies on, so an ibc-go bump that flips it fails a test instead of quietly making that entry necessary again -- MsgUpgradeClient's removal does not depend on that default, and ibc_authz_inventory_test.go pins both. Removing an entry is itself a state change (a previously rejected MsgExec now succeeds), so it is recorded in the CHANGELOG.

func HasWeb3ExtensionOption added in v0.5.0

func HasWeb3ExtensionOption(anyType *codectypes.Any) bool

HasWeb3ExtensionOption is the extension-option checker for the EIP-712 (Keplr) ante handler. It accepts exactly *eip712.ExtensionOptionsWeb3Tx, the extension verifyEip712Signature requires. Both the legacy ethermint and the current cosmos.evm type URLs unpack to this type (see app/upgrades/v041 RegisterCompatInterfaces). DynamicFee options belong to the Ethereum tx path and are rejected here.

func NewAnteHandler

func NewAnteHandler(options HandlerOptions) sdk.AnteHandler

NewAnteHandler returns the AnteHandler for the EVM

Types

type Eip712SigVerificationDecorator added in v0.5.0

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

Eip712SigVerificationDecorator verifies EIP-712 signatures produced by wallets (e.g. Keplr) that sign Cosmos txs against the legacy ethermint ExtensionOptionsWeb3Tx extension option.

CONTRACT: Pubkeys are set in context for all signers before this decorator runs.

func NewEip712SigVerificationDecorator added in v0.5.0

func NewEip712SigVerificationDecorator(
	ak anteinterfaces.AccountKeeper,
	cdc codec.BinaryCodec,
) Eip712SigVerificationDecorator

NewEip712SigVerificationDecorator creates a new Eip712SigVerificationDecorator. The codec is injected explicitly (the app's fully-populated ProtoCodec) so message unpacking for typed-data construction works for every registered interface — a package-level init() codec would only know the eip712 types and silently break for any message type it does not register.

func (Eip712SigVerificationDecorator) AnteHandle added in v0.5.0

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

AnteHandle validates and verifies EIP-712 signed Cosmos transactions. It is not executed on ReCheckTx.

type EvmKeeper

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

EvmKeeper defines the expected keeper interface used on the AnteHandler

type HandlerOptions

type HandlerOptions struct {
	AccountKeeper         anteinterfaces.AccountKeeper
	BankKeeper            anteinterfaces.BankKeeper
	IBCKeeper             *ibckeeper.Keeper
	FeeMarketKeeper       anteinterfaces.FeeMarketKeeper
	EvmKeeper             anteinterfaces.EVMKeeper
	FeegrantKeeper        ante.FeegrantKeeper
	SignModeHandler       *txsigning.HandlerMap
	SigGasConsumer        func(meter storetypes.GasMeter, sig signing.SignatureV2, params authtypes.Params) error
	Cdc                   codec.BinaryCodec
	MaxTxGasWanted        uint64
	TxFeeChecker          ante.TxFeeChecker
	DisabledAuthzMsgs     []string
	WasmKeeper            *wasmkeeper.Keeper
	WasmNodeConfig        *wasmtypes.NodeConfig
	TXCounterStoreService corestoretypes.KVStoreService
}

HandlerOptions defines the module keepers required to run the Uptick AnteHandler decorators: cosmos/evm's HandlerOptions plus Uptick-specific fields.

func (HandlerOptions) Validate

func (options HandlerOptions) Validate() error

Validate checks if the keepers are defined.

This is the only startup gate for the ante wire-up: cosmos/evm's own NewAnteHandler does not validate its options (see ante/ante.go:74), so a missing keeper is not caught until the first transaction reaches the decorator that dereferences it. Every field checked below is one that cosmosAnteDecorators passes to a decorator unconditionally — IBCKeeper to NewRedundantRelayDecorator and SigGasConsumer to NewSigGasConsumeDecorator — so nil there is a guaranteed panic on the first tx rather than a degraded feature. The required set matches cosmos/evm@v0.6.2's own ante.HandlerOptions.Validate except for PendingTxListener, which this package pins to nil in toEvmHandlerOptions.

Deliberately NOT required:

  • FeegrantKeeper: cosmos-sdk's DeductFeeDecorator reads nil as "feegrant disabled", a supported configuration (upstream's Validate omits it too), so rejecting nil here would turn a supported wire-up into a startup failure.
  • WasmKeeper / WasmNodeConfig / TXCounterStoreService: each guards an optional decorator inside cosmosAnteDecorators, and TestWasmDecoratorsOmittedWhenKeepersNil pins the nil form as supported input. Requiring them would break that contract.

type MessageSecurityDecorator added in v0.5.0

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

MessageSecurityDecorator validates every message in a transaction before it reaches the keeper layer, including messages hidden inside nested authz MsgExec wrappers:

  • CosmWasm messages are checked for basic validity and payload size, and cannot be used to bypass AnteHandler gas accounting via DispatchMsg;
  • Ethereum transactions are checked for a sane, bounded gas limit;
  • the flattened message list is capped in count and nesting depth.

func NewMessageSecurityDecorator added in v0.5.0

func NewMessageSecurityDecorator(cdc codec.BinaryCodec, maxTxGasWanted uint64) MessageSecurityDecorator

NewMessageSecurityDecorator creates a new MessageSecurityDecorator

func (MessageSecurityDecorator) AnteHandle added in v0.5.0

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

AnteHandle inspects all messages in the transaction to ensure AnteHandler checks are not bypassed

func (MessageSecurityDecorator) ExtractMessagesFromTx added in v0.5.0

func (msd MessageSecurityDecorator) ExtractMessagesFromTx(ctx sdk.Context, tx sdk.Tx) ([]sdk.Msg, error)

ExtractMessagesFromTx extracts all messages from a transaction, including nested messages from authz.MsgExec to prevent ante handler bypass attacks. BFS traversal deduplicates revisits of the same in-memory message via a pointer-based key; messages with equal content but distinct pointers are intentionally validated independently. The result-size cap is checked after dedup so a single duplicated message cannot trip the limit.

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.

Jump to

Keyboard shortcuts

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