Documentation
¶
Index ¶
- Variables
- func NewCheckTxHandler(mempool *ExperimentalEVMMempool) types.CheckTxHandler
- func NewEVMMempoolIterator(evmIterator *miner.TransactionsByPriceAndNonce, ...) mempool.Iterator
- func ResetGlobalEVMMempool()
- func SetGlobalEVMMempool(mempool *ExperimentalEVMMempool) error
- type Blockchain
- func (b Blockchain) Config() *params.ChainConfig
- func (b Blockchain) CurrentBlock() *types.Header
- func (b Blockchain) GetBlock(_ common.Hash, _ uint64) *types.Block
- func (b Blockchain) GetLatestCtx() (sdk.Context, error)
- func (b *Blockchain) NotifyNewBlock()
- func (b Blockchain) StateAt(hash common.Hash) (vm.StateDB, error)
- func (b Blockchain) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
- type EVMMempoolConfig
- type EVMMempoolIterator
- type EthSignerExtractionAdapter
- type ExperimentalEVMMempool
- func (m *ExperimentalEVMMempool) CountTx() int
- func (m *ExperimentalEVMMempool) GetBlockchain() *Blockchain
- func (m *ExperimentalEVMMempool) GetTxPool() *txpool.TxPool
- func (m *ExperimentalEVMMempool) Insert(goCtx context.Context, tx sdk.Tx) error
- func (m *ExperimentalEVMMempool) InsertInvalidNonce(txBytes []byte) error
- func (m *ExperimentalEVMMempool) Remove(tx sdk.Tx) error
- func (m *ExperimentalEVMMempool) Select(goCtx context.Context, i [][]byte) sdkmempool.Iterator
- func (m *ExperimentalEVMMempool) SelectBy(goCtx context.Context, i [][]byte, f func(sdk.Tx) bool)
- type FeeMarketKeeperI
- type VMKeeperI
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoMessages = errors.New("transaction has no messages") ErrExpectedOneMessage = errors.New("expected 1 message") ErrExpectedOneError = errors.New("expected 1 error") ErrNotEVMTransaction = errors.New("transaction is not an EVM transaction") ErrNonceGap = errors.New("tx nonce is higher than account nonce") )
Functions ¶
func NewCheckTxHandler ¶
func NewCheckTxHandler(mempool *ExperimentalEVMMempool) types.CheckTxHandler
NewCheckTxHandler creates a CheckTx handler that integrates with the EVM mempool for transaction validation. It wraps the standard transaction execution flow to handle EVM-specific nonce gap errors by routing transactions with higher tx sequence numbers to the mempool for potential future execution. Returns a handler function that processes ABCI CheckTx requests and manages EVM transaction sequencing.
func NewEVMMempoolIterator ¶
func NewEVMMempoolIterator(evmIterator *miner.TransactionsByPriceAndNonce, cosmosIterator mempool.Iterator, logger log.Logger, txConfig client.TxConfig, bondDenom string, chainID *big.Int, blockchain *Blockchain) mempool.Iterator
NewEVMMempoolIterator creates a new unified iterator over EVM and Cosmos transactions. It combines iterators from both transaction pools and selects transactions based on fee priority. Returns nil if both iterators are empty or nil. The bondDenom parameter specifies the native token denomination for fee comparisons, and chainId is used for EVM transaction conversion.
func ResetGlobalEVMMempool ¶
func ResetGlobalEVMMempool()
ResetGlobalEVMMempool resets the global ExperimentalEVMMempool instance. This is intended for testing purposes only.
func SetGlobalEVMMempool ¶
func SetGlobalEVMMempool(mempool *ExperimentalEVMMempool) error
SetGlobalEVMMempool sets the global ExperimentalEVMMempool instance. This should only be called during application initialization. In production builds, it returns an error if already set.
Types ¶
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
Blockchain implements the BlockChain interface required by Ethereum transaction pools. It bridges Cosmos SDK blockchain state with Ethereum's transaction pool system by providing access to block headers, chain configuration, and state databases. This implementation is specifically designed for instant finality chains where reorgs never occur.
func (Blockchain) Config ¶
func (b Blockchain) Config() *params.ChainConfig
Config returns the Ethereum chain configuration. It should only be called after the chain is initialized. This provides the necessary parameters for EVM execution and transaction validation.
func (Blockchain) CurrentBlock ¶
func (b Blockchain) CurrentBlock() *types.Header
CurrentBlock returns the current block header for the app. It constructs an Ethereum-compatible header from the current Cosmos SDK context, including block height, timestamp, gas limits, and base fee (if London fork is active). Returns a zero header as placeholder if the context is not yet available.
func (Blockchain) GetBlock ¶
GetBlock retrieves a block by hash and number. Cosmos chains have instant finality, so this method should only be called for the genesis block (block 0) or block 1, as reorgs never occur. Any other call indicates a bug in the mempool logic. Panics if called for blocks beyond block 1, as this would indicate an attempted reorg.
func (Blockchain) GetLatestCtx ¶
func (b Blockchain) GetLatestCtx() (sdk.Context, error)
GetLatestCtx retrieves the most recent query context from the application. This provides access to the current blockchain state for transaction validation and execution.
func (*Blockchain) NotifyNewBlock ¶
func (b *Blockchain) NotifyNewBlock()
NotifyNewBlock sends a chain head event when a new block is finalized
func (Blockchain) StateAt ¶
StateAt returns the StateDB object for a given block hash. In practice, this always returns the most recent state since the mempool only needs current state for validation. Historical state access is not supported as it's never required by the txpool.
func (Blockchain) SubscribeChainHeadEvent ¶
func (b Blockchain) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
SubscribeChainHeadEvent allows subscribers to receive notifications when new blocks are finalized. Returns a subscription that will receive ChainHeadEvent notifications via the provided channel.
type EVMMempoolConfig ¶
type EVMMempoolConfig struct { TxPool *txpool.TxPool CosmosPool sdkmempool.ExtMempool AnteHandler sdk.AnteHandler BroadCastTxFn func(txs []*ethtypes.Transaction) error BlockGasLimit uint64 // Block gas limit from consensus parameters }
EVMMempoolConfig contains configuration options for creating an EVMsdkmempool. It allows customization of the underlying mempools, verification functions, and broadcasting functions used by the sdkmempool.
type EVMMempoolIterator ¶
type EVMMempoolIterator struct {
// contains filtered or unexported fields
}
EVMMempoolIterator provides a unified iterator over both EVM and Cosmos transactions in the mempool. It implements priority-based transaction selection, choosing between EVM and Cosmos transactions based on their fee values. The iterator maintains state to track transaction types and ensures proper sequencing during block building.
func (*EVMMempoolIterator) Next ¶
func (i *EVMMempoolIterator) Next() mempool.Iterator
Next advances the iterator to the next transaction and returns the updated iterator. It determines which iterator (EVM or Cosmos) provided the current transaction and advances that iterator accordingly. Returns nil when no more transactions are available.
func (*EVMMempoolIterator) Tx ¶
func (i *EVMMempoolIterator) Tx() sdk.Tx
Tx returns the current transaction from the iterator. It selects between EVM and Cosmos transactions based on fee priority and converts EVM transactions to SDK format.
type EthSignerExtractionAdapter ¶
type EthSignerExtractionAdapter struct {
// contains filtered or unexported fields
}
EthSignerExtractionAdapter is the default implementation of SignerExtractionAdapter. It extracts the signers from a cosmos-sdk tx via GetSignaturesV2.
func NewEthSignerExtractionAdapter ¶
func NewEthSignerExtractionAdapter(fallback mempool.SignerExtractionAdapter) EthSignerExtractionAdapter
NewEthSignerExtractionAdapter constructs a new EthSignerExtractionAdapter instance
func (EthSignerExtractionAdapter) GetSigners ¶
func (s EthSignerExtractionAdapter) GetSigners(tx sdk.Tx) ([]mempool.SignerData, error)
GetSigners implements the Adapter interface NOTE: only the first item is used by the mempool
type ExperimentalEVMMempool ¶
type ExperimentalEVMMempool struct {
// contains filtered or unexported fields
}
ExperimentalEVMMempool is a unified mempool that manages both EVM and Cosmos SDK transactions. It provides a single interface for transaction insertion, selection, and removal while maintaining separate pools for EVM and Cosmos transactions. The mempool handles fee-based transaction prioritization and manages nonce sequencing for EVM transactions.
func GetGlobalEVMMempool ¶
func GetGlobalEVMMempool() *ExperimentalEVMMempool
GetGlobalEVMMempool returns the global ExperimentalEVMMempool instance. Returns nil if not set.
func NewExperimentalEVMMempool ¶
func NewExperimentalEVMMempool(getCtxCallback func(height int64, prove bool) (sdk.Context, error), logger log.Logger, vmKeeper VMKeeperI, feeMarketKeeper FeeMarketKeeperI, txConfig client.TxConfig, clientCtx client.Context, config *EVMMempoolConfig) *ExperimentalEVMMempool
NewExperimentalEVMMempool creates a new unified mempool for EVM and Cosmos transactions. It initializes both EVM and Cosmos transaction pools, sets up blockchain interfaces, and configures fee-based prioritization. The config parameter allows customization of pools and verification functions, with sensible defaults created if not provided.
func (*ExperimentalEVMMempool) CountTx ¶
func (m *ExperimentalEVMMempool) CountTx() int
CountTx returns the total number of transactions in both EVM and Cosmos pools. This provides a combined count across all mempool types.
func (*ExperimentalEVMMempool) GetBlockchain ¶
func (m *ExperimentalEVMMempool) GetBlockchain() *Blockchain
GetBlockchain returns the blockchain interface used for chain head event notifications. This is primarily used to notify the mempool when new blocks are finalized.
func (*ExperimentalEVMMempool) GetTxPool ¶
func (m *ExperimentalEVMMempool) GetTxPool() *txpool.TxPool
GetTxPool returns the underlying EVM txpool. This provides direct access to the EVM-specific transaction management functionality.
func (*ExperimentalEVMMempool) Insert ¶
Insert adds a transaction to the appropriate mempool (EVM or Cosmos). EVM transactions are routed to the EVM transaction pool, while all other transactions are inserted into the Cosmos sdkmempool. The method assumes transactions have already passed CheckTx validation.
func (*ExperimentalEVMMempool) InsertInvalidNonce ¶
func (m *ExperimentalEVMMempool) InsertInvalidNonce(txBytes []byte) error
InsertInvalidNonce handles transactions that failed with nonce gap errors. It attempts to insert EVM transactions into the pool as non-local transactions, allowing them to be queued for future execution when the nonce gap is filled. Non-EVM transactions are discarded as regular Cosmos flows do not support nonce gaps.
func (*ExperimentalEVMMempool) Remove ¶
func (m *ExperimentalEVMMempool) Remove(tx sdk.Tx) error
Remove removes a transaction from the appropriate sdkmempool. For EVM transactions, removal is typically handled automatically by the pool based on nonce progression. Cosmos transactions are removed from the Cosmos pool.
func (*ExperimentalEVMMempool) Select ¶
func (m *ExperimentalEVMMempool) Select(goCtx context.Context, i [][]byte) sdkmempool.Iterator
Select returns a unified iterator over both EVM and Cosmos transactions. The iterator prioritizes transactions based on their fees and manages proper sequencing. The i parameter contains transaction hashes to exclude from selection.
type FeeMarketKeeperI ¶
type VMKeeperI ¶
type VMKeeperI interface { GetBaseFee(ctx sdk.Context) *big.Int GetParams(ctx sdk.Context) (params vmtypes.Params) GetAccount(ctx sdk.Context, addr common.Address) *statedb.Account GetState(ctx sdk.Context, addr common.Address, key common.Hash) common.Hash GetCode(ctx sdk.Context, codeHash common.Hash) []byte GetCodeHash(ctx sdk.Context, addr common.Address) common.Hash ForEachStorage(ctx sdk.Context, addr common.Address, cb func(key common.Hash, value common.Hash) bool) SetAccount(ctx sdk.Context, addr common.Address, account statedb.Account) error DeleteState(ctx sdk.Context, addr common.Address, key common.Hash) SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte) DeleteCode(ctx sdk.Context, codeHash []byte) SetCode(ctx sdk.Context, codeHash []byte, code []byte) DeleteAccount(ctx sdk.Context, addr common.Address) error KVStoreKeys() map[string]*storetypes.KVStoreKey SetEvmMempool(evmMempool *ExperimentalEVMMempool) }
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
legacypool
Package legacypool implements the normal EVM execution transaction pool.
|
Package legacypool implements the normal EVM execution transaction pool. |