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 / state-execution

State execution and block processing

State execution turns a proposed block into the next trusted chain state. The node checks the block against its current state, sends it to the ABCI application, commits the application result, and then records the new state for later validation and recovery.

Authoritative state

The authoritative state is the node's trusted summary of the latest committed block and the rules for accepting the next one. It links consensus data to application data through the application hash and the transaction-results hash.

State record

The state record keeps the chain identity, height context, latest block identity, validator sets, consensus parameters, application hash, and prior transaction-results hash. It is not the full application database. It is the compact record used to check the next block.

The state starts from genesis. Each committed block creates a new state. Validator sets and consensus parameters can change through application results. The application hash is filled only after the application commit succeeds.

References: state/state.go• L39-81 state/state.go• L371-411 state/execution.go• L720-799

Header commitments

A block header commits to the state values that must match across nodes. Validation compares the block's application hash, results hash, validator hashes, consensus-parameter hash, prior block identity, height, and chain identity with local state.

These commitments keep large data outside the header while making state divergence visible. An application-hash mismatch is a serious state error. The node logs the operator runbook before the validation error returns.

References: spec/…/state.md• L7-18 state/validation.go• L42-105 state/execution.go• L257-295

Block processing

Block processing moves one block through proposal handling, validation, application execution, commit, state save, and notification. The block executor coordinates the application, state store, block store, mempool, evidence pool, and event bus so these parts advance in one controlled sequence.

Proposal handling

Proposal handling lets the application select and order transactions for a candidate block. The node gives the application the available data space, evidence, commit information, and block context. The application response must still fit the state-derived block data limit.

Process proposal checks a received candidate before committed execution. Rejection does not change authoritative state. An accepted proposal still goes through normal block validation and final application processing.

References: state/execution.go• L124-225 state/execution.go• L227-255

Processing sequence

The normal path follows this sequence:

  1. Validate the block against the current state and check its evidence.
  2. Send the block to the ABCI application for final processing.
  3. Save transaction information and the application response needed for recovery.
  4. Build the next consensus state from the block and application response.
  5. Commit the application while the mempool is locked.
  6. Refresh the mempool against the committed state.
  7. Set the new application hash and save the state.
  8. Update evidence tracking and publish block and transaction events.

The application response supplies transaction results and may change validators, consensus parameters, or timeout values. Validator changes apply after the protocol delay. Consensus-parameter changes apply to the next block.

This diagram shows how a proposed block becomes a committed state and how side effects follow the commit boundary.

flowchart LR
    A[Proposed block] --> B[Validate against state]
    B -->|valid| C[ABCI FinalizeBlock]
    B -->|invalid| X[Reject block]
    C --> D[Save results and build next state]
    D --> E[ABCI Commit]
    E --> F[Refresh mempool]
    F --> G[Save state]
    G --> H[Update evidence and publish events]

References: state/execution.go• L317-450

Block validation

Validation checks that the block is well formed and follows the local state. It checks header commitments, the prior commit, proposer identity, block time, and evidence. For a non-genesis block, the prior validator set must verify the commit for the prior block.

Block time must be later than the prior block time and must match the weighted median of timestamps in the prior commit. A block that is too far in the future is rejected. Evidence is checked against the evidence pool after structural checks pass.

Validation does not change state. A caller can skip the prior-commit check only when another trusted path already checked it. That option does not skip the other checks.

The validation path is exercised with malformed commits, header and data mutations, and altered evidence. Valid input must pass both normal validation and the block-sync variant before execution can advance the chain.

References: state/validation.go• L16-32 state/validation.go• L37-182 state/execution.go• L257-329 state/execution_fuzz_test.go• L260-520

Application execution

The ABCI application is the chain-specific state machine. The node sends it the block, execution context, evidence, and prior commit through FinalizeBlock. Before this call, the node removes supported BlobTx wrappers according to the block's application version.

The application returns one result for each transaction and may return validator or consensus-rule changes. The node requires the result count to match the transaction count. It then builds the next consensus state with the new height, block identity, time, validator history, consensus parameters, timeout values, and transaction-results hash.

The same normalized transaction bytes go to transaction events and crash replay. This keeps normal execution and replay consistent across application versions. The execution path also confirms that a committed block changes the application hash, persists matching state, indexes transaction results, and allows the next block to proceed. For the application boundary and request lifecycle, see ABCI application integration.

References: state/execution.go• L335-445 state/execution.go• L720-799 state/execution.go• L881-942 state/execution_fuzz_test.go• L522-569

Vote extension verification

Vote extension verification is a consensus-time application check for data attached to a validator vote. The node first checks the vote and its extension signature, then sends the block identity, validator identity, height, and extension to the ABCI application. The application can accept or reject the extension without changing the authoritative state.

References: state/execution_fuzz_test.go• L591-685

Commit boundary

The commit boundary joins the application database to the node's state record. The node first flushes pending mempool requests, then calls the application's Commit while holding the mempool lock. The application must persist its state before that call returns.

After commit, the node uses the returned retain height for pruning and rechecks remaining mempool transactions against the committed state. It then stores the returned application hash and publishes events only after the state save step.

References: state/execution.go• L506-555 state/execution.go• L428-450

Recovery behavior

Recovery protects the link between application state, the state record, and block metadata when a node stops during processing. The stored application response lets the node determine whether an application commit completed before the state record was saved.

Crash recovery

The node saves the block's application response before it calls Commit. It keeps the latest response for recovery. It can also retain responses by height when historical transaction-result queries are needed.

Crash replay sends the same application-version-aware transaction bytes as normal execution. This allows the replayed application hash to match the original execution.

References: state/execution.go• L375-388 state/execution.go• L881-942 state/store.go• L477-603

Rollback scope

Rollback replaces CometBFT state with an earlier state and can remove blocks from the block store. It does not change the ABCI application's database. It repairs node metadata and stored blocks rather than reversing application execution.

Checked rollback confirms that the target is retained and that the needed block, validator, and consensus-parameter history exists. It also checks that state and block-store heights differ by no more than one pending block. A hard rollback removes at most one stored height. The operation can resume after a crash and verifies the target application hash before success.

When the block store is one height ahead, the extra block is saved but not executed. Rollback can keep or remove it without changing state. An application-state mismatch remains an application and operator recovery problem.

References: state/rollback.go• L13-17 state/rollback.go• L27-127 state/rollback.go• L130-264

Transaction filtering

Transaction filtering keeps mempool transactions within the limits of blocks that the node can carry and process. The filters use current consensus parameters and run at different points in the transaction life cycle.

Admission limits

The pre-check rejects a transaction that is too large for the block's remaining transaction space. That space is smaller than the full block limit because the block also needs room for its header, commit, and possible evidence. The post-check rejects a transaction whose requested gas exceeds the block gas limit.

These checks do not decide whether the application accepts a transaction. The application remains responsible for transaction validity. Proposal output uses the same data-space contract, so an oversized PrepareProposal response fails block creation.

References: state/tx_filter.go• L8-26 state/execution.go• L138-167 state/execution.go• L205-224 spec/…/state.md• L101-114

Sequence-aware admission

The sequence-aware gossip path uses signer sequence data to control when ordered transactions reach application checks. A signer sequence is the application-defined counter for the next transaction from a signer.

The path holds nearby future sequences until a gap closes and drops sequences that the application has already passed. It does not replace CheckTx. It keeps out-of-order data bounded by signer, peer, byte, and age limits.

After a block commit or another observed sequence change, the path removes stale buffered transactions and processes the next available sequence. This keeps transaction flow aligned with the application state without making gossip queues authoritative.

References: mempool/…/reactor.go• L289-365 mempool/…/reactor.go• L672-797 mempool/…/reactor.go• L832-895 mempool/…/received_buffer.go• L21-39 mempool/…/received_buffer.go• L51-100

Mempool refresh

The mempool stays locked during application commit because commit can change application state. After commit, the node applies the block's transaction results and runs the size and gas checks again. This removes transactions that were valid against the old state but are no longer valid.

The sequence-aware gossip path also refreshes pending announcements after a height change. It drains transactions whose signer sequence is now ready and requests the next consecutive transactions.

References: state/execution.go• L506-555 mempool/…/reactor.go• L832-887

Storage relationships

State execution depends on durable records with different roles. The state store preserves the trusted execution summary and recovery data. The block store preserves blocks and commit data. Query indexes expose committed results without deciding whether a block is valid.

Persistent records

The state store loads the current state from the database or creates it from genesis. It also preserves validator history, consensus-parameter history, and application responses. The block store supplies block metadata and commit data for later validation and execution.

For persistence, loading, pruning, and compaction, see State and block storage. State execution creates and consumes these records. It does not define their storage layout.

References: state/store.go• L53-87 state/store.go• L209-248 state/services.go• L20-48

Query indexes

Query indexes are secondary views of committed results. They support transaction and block searches by height, hash, and indexed event attributes. A missing or stale index affects queries, not the authoritative state transition.

References: state/…/indexer.go• L19-57 state/…/kv.go• L26-56 state/…/kv.go• L35-77

Change checklist

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

  • Keep block-header commitments aligned with the state values checked during validation and used when blocks are built.
  • Preserve the distinction between proposal acceptance and committed execution when changing proposal handling.
  • Preserve the one-result-per-transaction contract and update timing for validator and consensus-parameter changes when changing FinalizeBlock result handling.
  • Keep normal execution and crash replay on the same transaction normalization path when application-version rules change.
  • Keep the mempool locked through commit and refresh when changing commit order.
  • Preserve the one-height pending-block boundary and target application-hash check when changing state or rollback handling.
  • Update both proposal limits and mempool checks when block size or gas rules change.
  • Preserve ordered requests, stale-entry removal, and bounded memory when signer sequence or CAT buffering changes.
  • Keep vote-extension signature checks and ABCI request fields aligned when vote-extension validation changes.

Important failure modes

TriggerConsequenceGuard
Header application hash differs from local stateThe node detects state divergence during validationStop and collect evidence using the operator runbook before recovery actions
Application result count differs from block transaction countThe execution cannot produce a trusted result setReject the result and keep the prior state
Normal execution and crash replay normalize a transaction differentlyReplay can produce a different application hashUse the same application-version-aware normalization
Application commit succeeds but state save does notApplication and node metadata can be at different commit stagesSave the application response before commit and use height-aware recovery
State and block-store heights differ by more than one pending blockRollback cannot identify a safe prior stateRepair the store relationship before rollback
Rollback target history or target application hash is unavailableRollback stops without proving a consistent targetRetain required block and state history and verify the target hash
Proposal data exceeds available block spaceBlock creation failsValidate application-selected transactions against the state-derived data limit
A future signer sequence remains buffered after its gap closesOrdered transactions can stall before CheckTxRefresh on height or sequence changes and remove stale entries
A vote extension signature no longer matches its voteThe extension must not reach the ABCI application as trusted dataVerify the vote and extension signature before the application check

Key files

FileWhy to read it
state/state.goDefines the state summary used by validation and state transitions
state/validation.goDefines the rules for accepting a block against current state
state/execution.goShows proposal handling and the path from validation through application execution, commit, and state save
state/execution_fuzz_test.goExercises block validation, application execution, transaction normalization, commit persistence, and vote-extension checks across malformed inputs
state/store.goDefines durable state and application-response records used by execution and recovery
state/rollback.goDefines checked rollback and handling for saved but unexecuted blocks
state/tx_filter.goDefines block size and gas filters around mempool processing
mempool/…/reactor.goShows sequence-aware transaction requests, buffering, application checks, and refresh
state/services.goDefines the boundary between execution and block storage services
state/…/kv.goShows the secondary query view for transaction results