Introducing a new way to review your PRs.

Read the announcement

celestiaorg / celestia-core

A fork of CometBFT

View on GitHub

20 documents · Updated Nov 23, 2026

docs / transaction-admission

Transaction admission and indexing

Transaction admission turns a submitted transaction into a checked, peer-shared, block-ready item. The same path keeps short-lived status data, publishes committed transaction events, and builds indexes for later lookup. Byzantine-validator evidence follows a separate block path described in Evidence and accountability. Client submission is described in RPC and API, while block commit and event production are part of State execution.

Admission lifecycle

Transaction intake and application checks

The mempool is the node's holding area for transactions that may enter a future block. It accepts transactions from local broadcast requests and peers, then asks the application to check each transaction before it becomes available for proposal.

The admission path applies checks in a fixed order:

  1. The node rejects a transaction that exceeds the configured transaction size.
  2. A pre-check can reject the transaction before the application call.
  3. The application receives an ABCI CheckTx request and returns its validity result.
  4. A post-check can apply node-level limits to the application's result.
  5. A valid transaction enters the mempool when capacity and the eviction policy allow it.

The application response supplies the values used for later block selection, such as gas need, priority, sender, and sequence. A transaction can pass application checks and still be rejected when the pool cannot make room for it. The pool also exposes the highest pending sequence for a signer, so sequence-aware application checks can inspect pending work without waiting on the pool-wide commit path.

References: mempool/…/pool.go• L216-220 mempool/…/pool.go• L238-264 mempool/…/pool.go• L308-409 mempool/…/pool_test.go• L731-748 mempool/…/pool_test.go• L1067-1171 mempool/mempool.go• L32-37 mempool/mempool.go• L134-142

Mempool ordering and selection

The pool presents transactions to consensus without removing them. Consensus reaps a bounded set for a proposed block, while the pool keeps the selected transactions until block processing confirms which transactions were included.

The store groups transactions by signer. It keeps each signer group in sequence order and orders groups by their gas-weighted priority. A group with no gas demand keeps zero aggregate priority. Transactions without a signer form separate groups. Equal-priority groups use arrival time as their tie-breaker.

Selection applies byte, gas, or transaction-count limits to the ordered groups. It takes a sequence-ordered prefix from each signer group. If the next transaction in a group does not fit, that group stops at that point, so the result can contain fewer transactions than the requested limit.

When space is scarce, the pool can remove lower-priority transactions from other signer groups to admit a higher-priority transaction. It removes higher sequence numbers first within a selected group so that the remaining prefix keeps its sequence order. It never evicts transactions from the incoming transaction's signer to make room for that transaction. This eviction is different from successful block inclusion because the removed transaction was not committed.

References: mempool/…/pool.go• L449-505 mempool/…/pool.go• L592-695 mempool/…/store.go• L34-70 mempool/…/store.go• L197-217 mempool/…/store.go• L267-305 mempool/…/store.go• L327-347 mempool/…/pool_test.go• L529-665 mempool/…/pool_test.go• L690-729 mempool/…/pool_test.go• L419-501 mempool/…/store_test.go• L477-639

Transaction retention and reaping

The pool retains transaction data and the admission facts needed for ordering, expiry, and status reporting. A transaction key provides lookup in the live pool. Bounded records for recent evictions and rejections let an API caller distinguish some outcomes from an unknown transaction.

Peer transactions that arrive before their signer sequence is ready use two related forms of short-lived state. The seen tracker records which peers can provide a transaction and, when needed, queues each peer's signer-and-sequence claim for gap filling. The received buffer holds requested transaction bytes that are ahead of the application's expected sequence. The claim from one peer does not override a different claim from another peer, and a delivery is judged by metadata that its own peer announced. Neither the claim nor the buffered bytes have passed CheckTx until the sequence gap closes.

The main retention rules are:

State or actionResult
ReapReturns candidates without removing them
Block inclusionRemoves the transaction after block processing
Recheck failureRemoves a transaction that is no longer valid
Capacity evictionRemoves lower-priority data and records an eviction
TTL expiryRemoves expired signer groups at a block-height update and records their transactions as expired or evicted
Peer receive bufferingHolds an out-of-order transaction before CheckTx, subject to byte, signer, peer, and time limits
FlushClears the pool and its status caches

Expiry is evaluated during the block update path. When a signer group crosses the configured height or age limit, the store removes the group and its remaining transactions together. Rejected and evicted records are limited caches. Their expiry means that an old transaction can later appear as UNKNOWN even when the node saw it before. Seen-peer and future-sequence records also age out, so a gap that does not close does not keep peer or signer state forever.

References: mempool/cache.go• L10-32 mempool/cache.go• L36-50 mempool/cache.go• L131-205 mempool/…/cache.go• L15-37 mempool/…/cache.go• L165-189 mempool/…/cache.go• L458-469 mempool/…/cache.go• L518-529 mempool/…/pool.go• L411-439 mempool/…/pool.go• L507-589 mempool/…/pool.go• L839-875 mempool/…/store.go• L220-255 mempool/…/store_test.go• L393-443 mempool/…/received_buffer.go• L27-65 mempool/…/received_buffer.go• L68-121 mempool/…/received_buffer.go• L142-167 mempool/…/received_buffer_test.go• L299-407 mempool/mempool.go• L97-131

Peer propagation

Broadcast paths

Local RPC submission and peer receipt share the same admission path, but only locally broadcast transactions carry the marker used for user latency measures. The RPC layer offers three waiting levels: return after submission, return after CheckTx, or return after both CheckTx and block inclusion.

After a valid local transaction enters the pool, the mempool places it on a broadcast queue when broadcast is enabled. The peer reactor announces the transaction key first. It sends the announcement to a bounded, signer-stable peer set and can add configured persistent peers without replacing that set. It skips peers that already have the transaction or are too far behind. A receiving peer requests the full transaction only when it does not already have it, which limits duplicate data transfer.

Listen-only mode keeps admission active but stops transaction broadcasts. This allows a node to accept local transactions without gossiping them to its peers.

References: rpc/…/mempool.go• L19-61 rpc/…/mempool.go• L70-143 mempool/…/pool.go• L238-307 mempool/…/reactor.go• L188-210 mempool/…/reactor.go• L535-609

Peer exchange and sequence handling

Peer propagation uses a pull exchange. A SeenTx message identifies a transaction and includes the sender and sequence needed to request transactions in order. A WantTx message asks for the full transaction.

The reactor accepts transaction bytes only when they answer an active request. It drops unsolicited bytes but records the sender as a known source. It tracks which peers have each transaction and retries from another peer when a request times out or a peer disconnects.

Each transaction has at most one active request, and each peer has a bounded number of outstanding requests. A timed-out request keeps a short-lived record for a late response while a new peer can serve the retry. This prevents a late response or an old cleanup callback from clearing the newer request.

Future-sequence announcements wait in a bounded per-signer queue. Each distinct signer-and-sequence claim is kept with the peers that announced it. A later announcement replaces only that peer's earlier claim, so a false claim cannot hide a valid claim from another peer. When the application's expected sequence advances, the reactor requests consecutive announced transactions within a bounded window. A transaction that arrives ahead of the expected sequence waits in a bounded receive buffer until its sequence becomes valid. Stale sequences are discarded without an application check because the application has already consumed them.

This ordering rule links network gossip to application state. The node does not need to process an announced future transaction at once. It must retain enough peer information to fill the gap later. The queue and receive buffer limit memory and request growth when peers send far-ahead sequences. The message boundary rejects malformed or over-limit envelopes before transaction handling.

When a peer delivers a transaction that the application rejects, the reactor removes claims that the check disproved. It keeps other future claims when they still show that the same bytes may become valid after a sequence gap closes. The transaction enters the rejection cache only when no such claim remains, which prevents a temporary sequence error from blocking a later valid delivery.

References: mempool/…/cache.go• L24-55 mempool/…/cache.go• L165-234 mempool/…/cache.go• L283-319 mempool/…/cache.go• L625-675 mempool/…/reactor.go• L289-369 mempool/…/reactor.go• L372-527 mempool/…/reactor.go• L611-713 mempool/…/reactor.go• L716-900 mempool/…/reactor.go• L922-971 mempool/…/requests.go• L56-115 mempool/…/requests.go• L144-221 mempool/…/received_buffer.go• L27-65 mempool/…/received_buffer.go• L68-121 mempool/…/received_buffer.go• L142-212 mempool/…/reactor_seen_metadata_test.go• L57-287 mempool/…/reactor_seen_metadata_test.go• L371-499 mempool/…/reactor_fuzz_test.go• L50-106 mempool/…/reactor_fuzz_test.go• L515-654 mempool/…/reactor_sequence_test.go• L29-35 mempool/…/reactor_sequence_test.go• L403-526

Block handoff and event publication

Block commit handoff

Consensus owns the boundary between a proposed block and the next mempool view. After the application commits a block, the node updates the pool with the included transactions and their execution results, advances the pool height, and installs the checks for the next block.

The update removes included transactions whether their execution succeeded or failed. If transactions remain, the node either asks the application to check them again or signals that transactions are available, depending on the recheck setting. This prevents the pool from treating pre-block validity as permanent when committed state has changed.

The update also expires old transactions at the new height and signals listeners that the mempool height advanced. This gives block processing one place to update transaction retention and availability state.

References: mempool/mempool.go• L41-109 mempool/…/pool.go• L507-589 mempool/…/pool.go• L717-818 mempool/…/pool.go• L839-875 mempool/…/pool_test.go• L222-326 mempool/…/reactor.go• L903-949

Event publication

The event bus is the node-wide stream for committed block and transaction events. Block processing publishes one transaction event for each transaction with its height, block position, raw transaction, execution result, and application events.

Transaction events carry reserved query fields for event type, transaction hash, and block height. Application event attributes are also exposed as query fields, which lets subscribers select transactions by application-defined data. Event publication can be repeated if the node crashes before commit, so consumers must treat events as a stream tied to block processing rather than as a one-time external notification.

Evidence events are published alongside transaction events but represent a different product concern. The Evidence and accountability page explains their detection, validation, pooling, and inclusion lifecycle.

References: types/events.go• L12-25 types/events.go• L87-100 types/events.go• L141-186 types/event_bus.go• L175-189 state/execution.go• L830-900

Mempool observability

Mempool metrics give operators a view of admission pressure and propagation health without changing the transaction state. They cover live pool size, byte use, transaction size, failed checks, capacity outcomes, rechecks, expiry, block inclusion, duplicate traffic, peer requests and retries, and latency for locally submitted transactions that reach a block.

The metric set separates application failure from resource pressure. It also distinguishes requests from re-requests, so an increase in retry activity can point to slow or unavailable peers rather than invalid transactions.

References: mempool/metrics.go• L15-80 mempool/metrics.gen.go• L11-133

Transaction indexing and query

Indexing pipeline

The transaction indexer consumes committed events instead of reading the mempool. It pairs the block event with the transaction events for that block, then stores a batch of transaction results together with the block index.

The indexing layer separates block-level and transaction-level query work. The block indexer records new-block event data and searches block heights. The transaction indexer accepts committed transaction results, stores them in batches, and supports lookup by hash or search query. These interfaces connect block execution to durable search without making pending mempool data appear committed.

The block indexer stores each committed block by height and stores only event attributes marked for indexing. Its queries can combine height limits with event conditions while keeping attributes from separate event instances distinct. It returns unique heights in order and can stop with a result-limit error instead of returning an unbounded result set.

The transaction index records each transaction by hash and height. It also records only application event attributes marked for indexing. The resulting data supports direct hash lookup and searches over block height or indexed event fields. A null indexer disables this query path.

The event bus therefore connects block execution to durable search: block processing emits the facts, the indexer groups them by block, and the storage backend makes them available to RPC callers.

References: state/…/indexer.go• L17-40 state/…/indexer_service.go• L17-25 state/…/indexer_service.go• L41-116 state/…/kv.go• L30-43 state/…/kv.go• L83-109 state/…/kv.go• L111-275 state/…/kv.go• L625-659 state/…/util.go• L46-66 state/…/util.go• L115-152 state/…/util.go• L155-215 state/…/kv.go• L88-156 state/…/kv.go• L159-208

Query and status view

Transaction lookup has two related views. Transaction search APIs read committed results from the index. Transaction status combines committed block information with the live mempool and its recent outcome caches.

Status checks follow this order:

  1. A committed transaction returns its block height, index, execution result, and gas data.
  2. A transaction still in the mempool returns PENDING.
  3. A recently evicted or rejected transaction returns its cached outcome.
  4. A transaction with no available record returns UNKNOWN.

This distinction matters for clients. PENDING means the node still holds the transaction. It does not mean that the transaction has reached a peer or will enter the next block. UNKNOWN can mean that the node never received it, propagation has not reached this node, or its short-lived record has expired.

References: rpc/…/tx.go• L278-329 rpc/…/tx.go• L332-355 rpc/…/tx.go• L76-119 rpc/…/mempool.go• L146-180 mempool/mempool.go• L117-131

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to admission metadata or application CheckTx results must preserve signer grouping, sequence order, priority aggregation, eviction, and recheck contracts used by the pool.
  • Changes to transaction or block event fields must stay aligned with event-bus query keys, indexer batch pairing, and RPC search behavior.
  • Changes to mempool wire messages must preserve allocation pre-checks, message-count limits, transaction-key validation, and protobuf round-trip behavior.
  • Changes to peer announcement fields must preserve the relationship between transaction keys, peer-specific signer sequences, future-sequence queues, bounded receive buffering, request retries, and the listen-only broadcast boundary.
  • Changes to solicited-transaction checks must preserve the pull-only rule so unsolicited bytes cannot reach application checks while valid request responses remain admissible.
  • Changes to peer lifecycle or timeout cleanup must preserve bounded request ownership, peer tracking, signer queues, and received-buffer accounting after disconnects and retries.
  • Changes to status precedence must keep committed storage ahead of mempool state and recent rejection or eviction caches.
  • Changes to transaction expiry or cache sizes must account for the point at which clients lose PENDING, EVICTED, or REJECTED evidence.
  • Changes to transaction-set priority or gas aggregation must preserve zero-gas handling and the incoming-signer eviction exclusion.
  • Changes to reaping limits must preserve the sequence-ordered prefix rule for each signer group when a byte or gas boundary falls inside that group.
  • Changes to pending-sequence access must preserve reads that do not wait on commit or recheck work.
  • Changes to block or transaction indexer interfaces must keep event consumers, batch creation, hash lookup, and search behavior aligned.
  • Changes to block-event query limits or key parsing must preserve deterministic range order, event-instance matching, height filtering, and compatibility with existing indexed records.
  • Changes to mempool metric names or help text must preserve the meaning of admission failures, capacity outcomes, retries, expiry, and user transaction latency for existing dashboards.

Important failure modes

TriggerConsequenceGuard
Application CheckTx rejects a transactionThe transaction does not enter the pool and its rejection may be cachedCheck the CheckTx result and log before reporting admission success
A transaction set has zero total gas wantedPriority aggregation can fail or leave the set with invalid ordering stateTreat zero-gas sets as having zero aggregate priority
A valid transaction cannot displace enough lower-priority dataThe transaction is marked evicted even though application checks passedKeep pool byte and count limits aligned with proposal limits
A full pool receives a transaction from a signer already in the poolThe incoming transaction is rejected instead of creating a sequence gap by evicting its signer groupExclude the incoming signer from eviction candidates
A future-sequence transaction arrives before its gapThe transaction waits or is dropped when it is too far ahead or when a byte, signer, or peer limit is fullUse the bounded gap queue and receive buffer with current application sequence state
A peer announces false or conflicting signer metadataA delivery can be held under the wrong sequence or cause a valid future claim to be lostAttribute claims to the announcing peer and keep distinct peer claims separate
An unsolicited transaction arrives from a peerThe bytes are dropped without an application CheckTx callRequire an active request before processing peer transaction bytes
A peer does not answer a transaction requestThe transaction is not admitted from that request pathRemove the peer source and retry another known source
A peer disconnects while requests or announcements remain trackedStale request ownership or peer state can block retries and consume bounded tracking spaceClear peer-owned requests and seen entries while preserving other claims and received-buffer accounting
A late response is treated as the current requestA newer request can be cleared or retried incorrectlyKeep the old peer's late-response slot separate from the active transaction owner
A malformed or oversized mempool envelope passes the message boundaryFull decoding or transaction handling can process invalid structure or excess inputValidate bytes before envelope decoding and fuzz each wire-message variant
Event publication or index batch processing failsCommitted data may be absent from event consumers or transaction searchMonitor event and indexer errors and apply the intended terminate-on-error policy
A block-event search exceeds its configured result capSearch returns ErrTooManyResults instead of a partial resultUse selective conditions or handle the bounded-search error
A query combines attributes from separate event instances as one matchSearch returns a false block matchPreserve event identity while intersecting event conditions
A transaction's recent cache entry expiresStatus changes from a known rejection or eviction to UNKNOWNTreat status as node-local and time-limited until commitment

Key files

FileWhy to read it
mempool/mempool.goDefines the mempool contract for checks, reaping, updates, flushes, status caches, and pending sequence access.
mempool/…/tx.goDefines transaction groups and metadata that support signer order and pool selection.
mempool/…/pool.goShows the admission, priority, eviction, recheck, expiry, broadcast, and block-update lifecycle.
mempool/…/store.goShows how live transactions become signer groups and how those groups support ordering, reaping, eviction, and expiry.
mempool/…/pool_test.goDemonstrates the contracts for admission, capacity eviction, recheck, reaping, expiry, broadcast queue behavior, and cached rejection results.
mempool/…/store_test.goDemonstrates signer sequence order, weighted group priority, removal cleanup, concurrent access, and group expiry.
mempool/…/cache.goDefines peer knowledge and peer-specific signer-sequence claims used to fill future sequence gaps.
mempool/…/cache_test.goDemonstrates bounded peer tracking, distinct claims, cleanup, expiry, and safe state copies.
mempool/…/reactor.goShows how peers announce, request, retry, buffer, validate, and sequence transactions.
mempool/…/requests.goDefines one-request-per-transaction tracking, peer request limits, timeout retries, and late-response cleanup.
mempool/…/received_buffer.goDefines the bounded pre-CheckTx store for out-of-order peer transactions.
mempool/…/received_buffer_test.goDemonstrates signer, peer, total-byte, expiry, and cleanup limits for buffered transactions.
mempool/…/reactor_seen_metadata_test.goDemonstrates that peer-specific announcement metadata remains correct across retries, conflicting claims, buffering, and rejection.
mempool/…/reactor_sequence_test.goDemonstrates sorted future-sequence queues, bounded request progress, and buffered transaction cleanup.
mempool/…/msgs_fuzz_test.goShows the wire-message boundary for malformed and over-limit mempool envelopes.
mempool/…/reactor_fuzz_test.goExercises peer exchange, sequence gaps, request cleanup, bounded tracking, peer churn, and block updates as one stateful flow.
mempool/cache.goDefines the bounded records used to recognize recent transactions and outcomes.
mempool/metrics.goDefines the operational measures for pool state, admission outcomes, propagation, expiry, inclusion, and latency.
mempool/metrics.gen.goConnects those measures to Prometheus and no-op metric providers.
proxy/app_conn.goDefines the application boundary used for mempool checks and sequence queries.
rpc/…/mempool.goConnects client broadcast modes and unconfirmed-transaction queries to the mempool.
types/event_bus.goDefines transaction event publication and query fields.
state/execution.goShows when block and transaction events are emitted during block processing.
state/…/indexer_service.goConnects block and transaction events to durable indexing.
state/…/kv.goDefines block-height and indexed-event search over committed block events.
state/…/util.goDefines block-index keys and query metadata rules.
state/…/kv.goShows the durable hash, height, and indexed-event query model.
rpc/…/tx.goDefines committed, pending, evicted, rejected, and unknown transaction views.