Module zebra_state::service::finalized_state

source ·
Expand description

The primary implementation of the zebra_state::Service built upon rocksdb.

Zebra’s database is implemented in 4 layers:

  • FinalizedState: queues, validates, and commits blocks, using…
  • ZebraDb: reads and writes zebra_chain types to the state database, using…
  • DiskDb: reads and writes generic types to any column family in the database, using…
  • disk_format: converts types to raw database bytes.

These layers allow us to split zebra_chain types for efficient database storage. They reduce the risk of data corruption bugs, runtime inconsistencies, and panics.


crate::constants::state_database_format_version_in_code() must be incremented each time the database format (column, serialization, etc) changes.



  • arbitrary 🔒
    Arbitrary value generation and test harnesses for the finalized state.
  • Type-safe column family access.
  • disk_db 🔒
    Provides low-level access to RocksDB using some database-specific types.
  • Serialization formats for finalized data.
  • zebra_db 🔒
    Provides high-level access to the database using zebra_chain types.


  • The finalized part of the chain state, stored in the db.