ante

package
v0.4.0-fix Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

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 (
	// MaxWasmDispatchMsgCount limits the maximum number of nested messages in a CosmWasm DispatchMsg
	// to prevent DoS attacks via excessive nested messages
	MaxWasmDispatchMsgCount = 10

	// 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 NewAnteHandler

func NewAnteHandler(options HandlerOptions) sdk.AnteHandler

NewAnteHandler returns the AnteHandler for the EVM

Types

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
	MaxWasmDispatchMsgCount uint64
	WasmKeeper              *wasmkeeper.Keeper
	WasmNodeConfig          *wasmtypes.NodeConfig
	TXCounterStoreService   corestoretypes.KVStoreService
}

HandlerOptions defines the list of module keepers required to run the Uptick AnteHandler decorators. It wraps cosmos/evm's HandlerOptions and adds Uptick-specific fields.

func (HandlerOptions) Validate

func (options HandlerOptions) Validate() error

Validate checks if the keepers are defined

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.

type WasmSecurityDecorator added in v0.3.1

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

WasmSecurityDecorator checks for security issues in CosmWasm messages and prevents bypassing AnteHandler gas checks via CosmWasm DispatchMsg

func NewWasmSecurityDecorator added in v0.3.1

func NewWasmSecurityDecorator(cdc codec.BinaryCodec, evmKeeper anteinterfaces.EVMKeeper, maxTxGasWanted, maxDispatch uint64) WasmSecurityDecorator

NewWasmSecurityDecorator creates a new WasmSecurityDecorator

func (WasmSecurityDecorator) AnteHandle added in v0.3.1

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

AnteHandle inspects CosmWasm messages in the tx to ensure AnteHandler checks are not bypassed

func (WasmSecurityDecorator) ExtractMessagesFromTx added in v0.3.1

func (wsd WasmSecurityDecorator) 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.

Jump to

Keyboard shortcuts

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