Transaction Lifecycle
The transaction lifecycle involves a dual-phase process through CometBFT consensus:CheckTx Phase
- Transaction routing: Ante handler identifies transaction type (
ante/ante.go:18-71) - EVM validation: MonoDecorator consolidates validation using go-ethereum’s
txpool.ValidateTransaction()(ante/evm/mono_decorator.go:99+) - Transaction filtering: Uses
PendingFilterwith configurableMinTip, base fee, and transaction type filters (mempool/mempool.go:455-461) - Nonce gap handling: Transactions with future nonces queued locally via
InsertInvalidNonce()(mempool/check_tx.go:21-23) - Mempool addition: Valid transactions added to CometBFT mempool for P2P broadcast
DeliverTx Phase
- Message unwrapping:
msg.AsTransaction()extracts Ethereum transaction fromMsgEthereumTx(x/vm/keeper/msg_server.go:32) - State transition:
ApplyTransaction()executes EVM logic with gas isolation (x/vm/keeper/state_transition.go:165-199) - Cache contexts: Isolated execution with rollback capability
- State commitment: Successful transactions committed to Cosmos SDK store
For detailed transaction flow and mempool behavior, see Mempool documentation and Cosmos SDK lifecycle.
Transaction Types
Cosmos EVM supports two transaction types:1. Cosmos Transactions
Transactions comprised of metadata held in contexts andsdk.Msgs that trigger state changes through Protobuf Msg services.
Cosmos transactions can have multiple sdk.Msgs and include:
Msgs: Array of messagesGasLimit: Gas calculation optionFeeAmount: Maximum fee willing to payTimeoutHeight: Block height validitySignatures: Array of signer signaturesMemo: Note or comment
2. Ethereum Transactions
Actions initiated by EOAs (externally-owned accounts) that transform EVM state. Must be broadcasted to the entire network. Ethereum transaction categories:- Regular transactions: Account to account
- Contract deployment: No
toaddress, contract code indatafield - Contract execution: Interact with deployed smart contract
recipient,signature,nonce,valuedata: Arbitrary data for contract deployment/callsgasLimit,maxPriorityFeePerGas,maxFeePerGas
Supported Ethereum Transaction Types
Cosmos EVM supports types defined inAcceptedTxType (ante/evm/mono_decorator.go:23-27):
- Legacy Transactions (EIP-155): Chain ID protection
- Access List Transactions (EIP-2930): Pre-declared storage access
- Dynamic Fee Transactions (EIP-1559): Base fee + priority fee model
- Set Code Transactions (EIP-7702): Account code assignment with authorization list
Note: Unprotected legacy transactions are not supported by default.
MsgEthereumTx Wrapper
Cosmos EVM wraps Ethereum transactions inMsgEthereumTx (x/vm/types/tx.pb.go:36-43):
From: Ethereum signer address bytes for signature verificationRaw: Complete Ethereum transaction data
sdk.Msg and sdk.Tx interfaces, enabling:
- Direct go-ethereum integration: Uses
txpool.ValidateTransaction()instead of SDK ante handlers - Gas isolation: EVM execution uses infinite gas meter, bypassing SDK gas consumption (
x/vm/keeper/state_transition.go:153-164) - Economic validation:
CheckSenderBalance()compares account balance with transaction cost (x/vm/keeper/fees.go:24-39) - Single message constraint: Only one EVM message per transaction (
ante/evm/mono_decorator.go:88-91)
EVM Execution Integration
Cosmos EVM creates an execution environment bridging Ethereum and Cosmos SDK state management: Block Context Mapping (x/vm/keeper/state_transition.go:46-57):
- CometBFT block proposer → EVM coinbase address
- Block height → EVM block number
- Block timestamp → EVM timestamp opcode
- Historical block access via EIP-2935 contract
x/vm/keeper/state_transition.go:67-78):
- Restrict contract creation and execution via EVM opcode interceptors
- Policy-based permissions for
CREATE,CREATE2, andCALLoperations
x/vm/keeper/state_transition.go:125):
- Ethereum-compatible bloom filters for log filtering
- Dual transaction hash emission for cross-ecosystem compatibility
- Contract address generation via
crypto.CreateAddress()
Transaction Ordering and Prioritization
Transactions are ordered by effective tips:- Ethereum:
gas_tip_capormin(gas_tip_cap, gas_fee_cap - base_fee) - Cosmos:
(fee_amount / gas_limit) - base_fee
- Ethereum transactions: Support nonce gaps with local queuing and automatic promotion
- Cosmos transactions: Require sequential nonces
For detailed mempool behavior, see Mempool Architecture.
Transaction Receipts
Cosmos EVM generates Ethereum-compatible receipts with Cosmos SDK event integration (x/vm/keeper/state_transition.go:125-146):
- Bloom Filter Computation: Creates transaction and block-level bloom filters
- Gas Reconciliation: Reconciles EVM gas usage with SDK gas meter state
- Dual Event Emission: Contains both Ethereum transaction hash and CometBFT transaction hash (
x/vm/keeper/msg_server.go:77-80)
transactionHash,transactionIndex,blockHash,blockNumberfrom,to,cumulativeGasUsed,effectiveGasPrice,gasUsedcontractAddress,logs,logsBloomtype,status
IBC Integration
Cosmos EVM enables cross-chain functionality through IBC accessible from EVM smart contracts:- ICS20 Precompile: Direct interface for cross-chain token transfers
- Cosmos SDK Module Access: Smart contracts interact with bank, staking, distribution, and governance modules through precompiled contracts
Related Documentation
- Mempool - Transaction flow and mempool architecture
- Gas and Fees - Fee calculation and gas metering
- Accounts - Account structure and addressing
- x/vm Module - EVM implementation details