Skip to main content

Crate signet_storage

Crate signet_storage 

Source
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: Propagates signet-hot/test-utils and signet-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§

CancellationToken
A token which can be used to signal a cancellation request to one or more tasks.
ColdStorage
Unified handle for interacting with a cold storage backend.
DatabaseArguments
Arguments for database initialization.
DatabaseEnv
MDBX database environment. Wraps the low-level Environment, and implements the HotKv trait.
DrainedBlock
Block data drained during a reorg unwind.
ErasedBackend
Type-erased cold storage backend, shareable across tasks.
ExecutedBlock
Complete execution output for a block.
ExecutedBlockBuilder
Builder for ExecutedBlock.
MdbxColdBackend
MDBX-based cold storage backend.
MdbxConnector
Connector for MDBX storage (both hot and cold).
RevmRead
Read-only Database and DatabaseRef adapter.
RevmWrite
Read-write REVM database adapter. This adapter allows committing changes. Despite the naming of TryDatabaseCommit::try_commit, the changes are only persisted when Self::persist is called. This is because of a mismatch in semantics between the two systems.
SqlColdBackendpostgres or sqlite
SQL-based cold storage backend.
SqlConnectorpostgres or sqlite
Connector for SQL cold storage (PostgreSQL or SQLite).
UnifiedStorage
Unified storage combining hot and cold backends.

Enums§

ColdStorageError
Error type for cold storage operations.
HistoryError
Error type for history operations.
StorageError
Error type for unified storage operations.

Traits§

ColdConnect
Connector trait for cold storage backends.
ColdStorageBackend
Combined read and write cold storage backend trait.
ColdStorageRead
Read-only cold storage backend trait.
ColdStorageWrite
Write-only cold storage backend trait.
DynColdStorageBackend
Object-safe mirror of ColdStorageBackend. Auto-implemented by a blanket impl over every B: ColdStorageBackend; do not implement directly.
HistoryRead
Trait for history read operations.
HistoryWrite
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.
HotKvRead
Trait for hot storage read transactions.

Type Aliases§

StorageResult
Result type alias for unified storage operations.