Crate zebra_state

Crate zebra_state 

Source
Expand description

State contextual verification and storage code for Zebra.

§Correctness

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.

Re-exports§

pub use config::check_and_delete_old_databases;
pub use config::check_and_delete_old_state_databases;
pub use config::database_format_version_on_disk;
pub use config::state_database_format_version_on_disk;
pub use config::Config;
pub use constants::state_database_format_version_in_code;
pub use constants::MAX_BLOCK_REORG_HEIGHT;

Modules§

check
Consensus critical contextual checks
config
Cached state configuration for Zebra.
constants
Constants that impact state behaviour.

Structs§

ChainTipBlock
A chain tip block, with precalculated block data.
ChainTipChange
A chain tip change monitor.
ChainTipSender
A sender for changes to the non-finalized and finalized chain tips.
CheckpointVerifiedBlock
A block ready to be committed directly to the finalized state with a small number of checks if compared with a ContextuallyVerifiedBlock.
CloneError
A wrapper for type erased errors that is itself clonable and implements the Error trait
CommitSemanticallyVerifiedBlockRequest
Performs contextual validation of the given semantically verified block, committing it to the state if successful.
ContextuallyVerifiedBlock
A contextually verified block, ready to be committed directly to the finalized state with no checks, if it becomes the root of the best non-finalized chain.
DiskWriteBatch
Wrapper struct to ensure low-level database writes go through the correct API.
FinalizedState
The finalized part of the chain state, stored in the db.
GetBlockTemplateChainInfo
A structure with the information needed from the state to build a getblocktemplate RPC response.
LatestChainTip
Efficient access to the state’s current best chain tip.
MinedTx
Information about a transaction in the best chain
NonFinalizedBlocksListener
A listener for changes in the non-finalized state.
NonFinalizedState
The state of the chains in memory, including queued blocks.
OutputLocation
A transparent output’s location in the chain, by block height and transaction index.
ReadStateService
A read-only service for accessing Zebra’s cached blockchain state.
SemanticallyVerifiedBlock
A block which has undergone semantic validation and has been prepared for contextual validation.
TransactionIndex
A transaction’s index in its block.
TransactionLocation
A transaction’s location in the chain, by block height and transaction index.
WatchReceiver
Efficient access to state data via a tokio watch::Receiver channel, while avoiding deadlocks.
ZebraDb
Wrapper struct to ensure high-level zebra-state database access goes through the correct API.

Enums§

AnyTx
Information about a transaction in any chain.
CommitSemanticallyVerifiedError
An error describing why a CommitSemanticallyVerified request failed.
HashOrHeight
Identify a block by hash or height.
KnownBlock
An enum of block stores in the state where a block hash could be found.
ReadRequest
A read-only query about the chain state, via the ReadStateService.
ReadResponse
A response to a read-only ReadStateService’s ReadRequest.
Request
A query about or modification to the chain state, via the StateService.
Response
A response to a StateService Request.
TipAction
Actions that we can take in response to a ChainTipChange.
ValidateContextError
An error describing why a block failed contextual validation.

Traits§

DuplicateNullifierError
Trait for creating the corresponding duplicate nullifier error from a nullifier.
FromDisk
Helper type for reading types from disk as raw bytes.
IntoDisk
Helper type for writing types to disk as raw bytes. Also used to convert key types to raw bytes for disk lookups.
MappedRequest
Helper trait for convenient access to expected response and error types.
ReadState
Trait alias for services handling read-only state requests.
State
Trait alias for services handling state-modifying requests.
WriteDisk
Helper trait for inserting serialized typed (Key, Value) pairs into rocksdb.

Functions§

init
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.
init_read_only
Initialize a read state service from the provided Config. Returns a read-only state service,
spawn_init_read_only
Calls init_read_only with the provided Config and Network from a blocking task. Returns a tokio::task::JoinHandle with a read state service and chain tip sender.

Type Aliases§

BoxError
A boxed std::error::Error.