Expand description
Unified storage interface for Signet.
This crate provides a unified interface for writing execution data to both hot storage (for fast state access) and cold storage (for historical archival).
§Overview
The UnifiedStorage struct wraps both a hot storage backend and a cold
storage handle, providing a single API for block writes:
- Hot storage receives headers and state changes for fast access
- Cold storage receives full block data (transactions, receipts, events)
§Write Semantics
- Hot writes are synchronous (database transactions)
- Cold writes are dispatched asynchronously (fire-and-forget)
- Hot errors are fatal; cold errors are logged but don’t block
§Example
ⓘ
use signet_storage::UnifiedStorage;
use signet_storage_types::ExecutedBlockBuilder;
// Create unified storage from hot and cold backends
let storage = UnifiedStorage::new(hot_db, cold_handle);
// Build an executed block
let block = ExecutedBlockBuilder::new()
.header(sealed_header)
.bundle(bundle_state)
.transactions(txs)
.receipts(receipts)
.build()
.unwrap();
// Write to both storages (takes ownership)
storage.append_blocks(vec![block])?;§Feature Flags
test-utils: Propagatessignet-hot/test-utilsandsignet-cold/test-utils, enabling in-memory backends and conformance tests for both storage layers.
Re-exports§
pub use either::Either;
Modules§
- builder
- Storage builder for programmatic and environment-based configuration.
- config
- Storage configuration types and environment parsing.
- either
- Either type for holding one of two connector types.
Structs§
- Cancellation
Token - A token which can be used to signal a cancellation request to one or more tasks.
- Cold
Storage - Unified handle for interacting with a cold storage backend.
- Database
Arguments - Arguments for database initialization.
- Database
Env - MDBX database environment. Wraps the low-level Environment, and
implements the
HotKvtrait. - Drained
Block - Block data drained during a reorg unwind.
- Erased
Backend - Type-erased cold storage backend, shareable across tasks.
- Executed
Block - Complete execution output for a block.
- Executed
Block Builder - Builder for
ExecutedBlock. - Mdbx
Cold Backend - MDBX-based cold storage backend.
- Mdbx
Connector - Connector for MDBX storage (both hot and cold).
- Revm
Read - Read-only
DatabaseandDatabaseRefadapter. - Revm
Write - Read-write REVM database adapter. This adapter allows committing changes.
Despite the naming of
TryDatabaseCommit::try_commit, the changes are only persisted whenSelf::persistis called. This is because of a mismatch in semantics between the two systems. - SqlCold
Backend postgresorsqlite - SQL-based cold storage backend.
- SqlConnector
postgresorsqlite - Connector for SQL cold storage (PostgreSQL or SQLite).
- Unified
Storage - Unified storage combining hot and cold backends.
Enums§
- Cold
Storage Error - Error type for cold storage operations.
- History
Error - Error type for history operations.
- Storage
Error - Error type for unified storage operations.
Traits§
- Cold
Connect - Connector trait for cold storage backends.
- Cold
Storage Backend - Combined read and write cold storage backend trait.
- Cold
Storage Read - Read-only cold storage backend trait.
- Cold
Storage Write - Write-only cold storage backend trait.
- DynCold
Storage Backend - Object-safe mirror of
ColdStorageBackend. Auto-implemented by a blanket impl over everyB: ColdStorageBackend; do not implement directly. - History
Read - Trait for history read operations.
- History
Write - Trait for database write operations on hot history tables. This trait maintains a consistent state of the database.
- HotConnect
- Connector trait for hot storage backends.
- HotKv
- Trait for hot storage. This is a KV store with read/write transactions.
- HotKv
Read - Trait for hot storage read transactions.
Type Aliases§
- Storage
Result - Result type alias for unified storage operations.