Expand description

State contextual verification and storage code for Zebra. 🦓


Await UTXO and block commit requests should be wrapped in a timeout, because:

  • await UTXO requests wait for a block containing that UTXO, and
  • contextual verification and state updates wait for all previous blocks.

Otherwise, verification of out-of-order and invalid blocks can hang indefinitely.


pub use constants::MAX_BLOCK_REORG_HEIGHT;


Definitions of constants.


A chain tip block, with precalculated block data.

A chain tip change monitor.

A sender for changes to the non-finalized and finalized chain tips.

A wrapper for type erased errors that is itself clonable and implements the Error trait

An error describing the reason a block could not be committed to the state.

Configuration for the state service.

A finalized block, ready to be committed directly to the finalized state with no checks.

Efficient access to the state’s current best chain tip.

A transparent output’s index in its transaction.

A transparent output’s location in the chain, by block height and transaction index.

A block which has undergone semantic validation and has been prepared for contextual validation.

A transaction’s location in the chain, by block height and transaction index.


Identify a block by hash or height.

A read-only query about the chain state, via the ReadStateService.

A response to a read-only ReadStateService’s ReadRequest.

A query about or modification to the chain state, via the StateService.

A response to a StateService Request.

Actions that we can take in response to a ChainTipChange.

An error describing why a block failed contextual validation.


Spawns a task that checks if there are old database folders, and deletes them from the filesystem.

Initialize a state service from the provided Config. Returns a boxed state service, a read-only state service, and receivers for state chain tip updates.

Returns a [StateService] with an ephemeral Config and a buffer with a single slot.

Initializes a state service with an ephemeral Config and a buffer with a single slot, then returns the read-write service, read-only service, and tip watch channels.

Initialize a state service with blocks, and return:

Type Definitions