Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["crates/*"]
resolver = "2"

[workspace.package]
version = "0.17.2"
version = "0.18.0"
edition = "2024"
rust-version = "1.88"
authors = ["init4"]
Expand Down Expand Up @@ -34,34 +34,34 @@ debug = false
incremental = false

[workspace.dependencies]
signet-blobber = { version = "0.17.2", path = "crates/blobber" }
signet-block-processor = { version = "0.17.2", path = "crates/block-processor" }
signet-genesis = { version = "0.17.2", path = "crates/genesis" }
signet-host-reth = { version = "0.17.2", path = "crates/host-reth" }
signet-host-rpc = { version = "0.17.2", path = "crates/host-rpc" }
signet-node = { version = "0.17.2", path = "crates/node" }
signet-node-config = { version = "0.17.2", path = "crates/node-config" }
signet-node-tests = { version = "0.17.2", path = "crates/node-tests" }
signet-node-types = { version = "0.17.2", path = "crates/node-types" }
signet-rpc = { version = "0.17.2", path = "crates/rpc" }

init4-bin-base = { version = "0.19.1", features = ["alloy"] }

signet-bundle = "0.16.0"
signet-constants = "0.16.0"
signet-evm = "0.16.0"
signet-extract = "0.16.0"
signet-test-utils = "0.16.0"
signet-tx-cache = "0.16.0"
signet-types = "0.16.0"
signet-zenith = "0.16.0"
signet-journal = "0.16.0"
signet-storage = "0.7"
signet-cold = "0.7"
signet-hot = "0.7"
signet-hot-mdbx = "0.7"
signet-cold-mdbx = "0.7"
signet-storage-types = "0.7"
signet-blobber = { version = "0.18.0", path = "crates/blobber" }
signet-block-processor = { version = "0.18.0", path = "crates/block-processor" }
signet-genesis = { version = "0.18.0", path = "crates/genesis" }
signet-host-reth = { version = "0.18.0", path = "crates/host-reth" }
signet-host-rpc = { version = "0.18.0", path = "crates/host-rpc" }
signet-node = { version = "0.18.0", path = "crates/node" }
signet-node-config = { version = "0.18.0", path = "crates/node-config" }
signet-node-tests = { version = "0.18.0", path = "crates/node-tests" }
signet-node-types = { version = "0.18.0", path = "crates/node-types" }
signet-rpc = { version = "0.18.0", path = "crates/rpc" }

init4-bin-base = { version = "0.20.0", features = ["alloy"] }

signet-bundle = "0.17"
signet-constants = "0.17"
signet-evm = "0.17"
signet-extract = "0.17"
signet-test-utils = "0.17"
signet-tx-cache = "0.17"
signet-types = "0.17"
signet-zenith = "0.17"
signet-journal = "0.17"
signet-storage = "0.8"
signet-cold = "0.8"
signet-hot = "0.8"
signet-hot-mdbx = "0.8"
signet-cold-mdbx = "0.8"
signet-storage-types = "0.8"

# ajj
ajj = "0.7.0"
Expand Down
5 changes: 3 additions & 2 deletions crates/block-processor/src/v1/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use signet_hot::{
model::{HotKv, HotKvRead, RevmRead},
};
use signet_storage_types::{DbSignetEvent, DbZenithHeader, ExecutedBlock, ExecutedBlockBuilder};
use signet_types::primitives::SignetHeaderV1;
use std::collections::VecDeque;
use tracing::{error, instrument};
use trevm::revm::{
Expand Down Expand Up @@ -195,7 +196,7 @@ where
block_extracts,
to_alias,
txns,
parent_header,
SignetHeaderV1::new_unchecked(parent_header.unseal()),
self.constants.clone(),
);

Expand Down Expand Up @@ -255,7 +256,7 @@ where
let zenith_header = block_extracts.ru_header().map(DbZenithHeader::from);

ExecutedBlockBuilder::new()
.header(header)
.header(header.into_inner())
.bundle(bundle)
.transactions(transactions)
.receipts(receipts)
Expand Down
9 changes: 5 additions & 4 deletions crates/host-rpc/src/notifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use alloy::{
consensus::{BlockHeader, transaction::Recovered},
eips::{BlockId, BlockNumberOrTag},
network::BlockResponse,
primitives::{B256, Sealed},
primitives::B256,
providers::Provider,
pubsub::SubscriptionStream,
rpc::types::Header as RpcHeader,
};
use futures_util::{StreamExt, TryStreamExt, stream};
use signet_node_types::{HostNotification, HostNotificationKind, HostNotifier, RevertRange};
use signet_types::primitives::{RecoveredBlock, SealedBlock, TransactionSigned};
use signet_types::primitives::{RecoveredBlock, SealedBlock, SignetHeaderV1, TransactionSigned};
use std::{collections::VecDeque, sync::Arc, time::Instant};
use tracing::{debug, info, warn};

Expand Down Expand Up @@ -189,7 +189,6 @@ where
rpc_block: alloy::rpc::types::Block,
rpc_receipts: Option<Vec<alloy::rpc::types::TransactionReceipt>>,
) -> RpcBlock {
let hash = rpc_block.header.hash;
let block = rpc_block
.map_transactions(|tx| {
let recovered = tx.inner;
Expand All @@ -198,7 +197,9 @@ where
Recovered::new_unchecked(tx, signer)
})
.into_consensus();
let sealed_header = Sealed::new_unchecked(block.header, hash);
// SignetHeaderV1 reseals the header; the recomputed hash matches the
// RPC-supplied hash for any well-formed provider response.
let sealed_header = SignetHeaderV1::new_unchecked(block.header);
let block: RecoveredBlock = SealedBlock::new(sealed_header, block.body.transactions);
let receipts = rpc_receipts
.unwrap_or_default()
Expand Down
1 change: 1 addition & 0 deletions crates/node-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repository.workspace = true

[dependencies]
signet-blobber.workspace = true
signet-cold-mdbx.workspace = true
signet-storage.workspace = true
signet-types.workspace = true

Expand Down
8 changes: 7 additions & 1 deletion crates/node-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ pub use core::SignetNodeConfig;
// responsibility of the host adapter crate (e.g. `signet-host-reth`).

mod storage;
pub use storage::StorageConfig;
pub use storage::{NodeColdBackend, StorageConfig};

// `signet-cold-mdbx` is referenced via `NodeColdBackend` only when the SQL
// features are disabled. Keep the dependency satisfied for the SQL-enabled
// build so callers can still type-name the backend uniformly.
#[cfg(any(feature = "postgres", feature = "sqlite"))]
use signet_cold_mdbx as _;

/// Test configuration for Signet Nodes.
#[cfg(feature = "test_utils")]
Expand Down
36 changes: 28 additions & 8 deletions crates/node-config/src/storage.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
use init4_bin_base::utils::from_env::FromEnv;
use signet_storage::{DatabaseEnv, Either, MdbxConnector, UnifiedStorage, builder::StorageBuilder};
#[cfg(any(feature = "postgres", feature = "sqlite"))]
use signet_storage::SqlConnector;
use signet_storage::{DatabaseEnv, MdbxConnector, UnifiedStorage, builder::StorageBuilder};
use signet_storage::{SqlConnector, either::EitherCold};
use std::borrow::Cow;
#[cfg(any(feature = "postgres", feature = "sqlite"))]
use std::time::Duration;
use tokio_util::sync::CancellationToken;

/// Cold storage backend used by the unified node storage.
///
/// When SQL features are enabled, this is the [`EitherCold`] enum that can
/// hold either an MDBX or SQL cold backend (selected at runtime). When SQL
/// features are disabled, it falls back to MDBX only.
#[cfg(any(feature = "postgres", feature = "sqlite"))]
pub type NodeColdBackend = EitherCold;

/// Cold storage backend used by the unified node storage (no SQL feature).
#[cfg(not(any(feature = "postgres", feature = "sqlite")))]
pub type NodeColdBackend = signet_cold_mdbx::MdbxColdBackend;

/// Configuration for signet unified storage.
///
/// Reads hot and cold storage configuration from environment variables.
Expand All @@ -22,12 +34,10 @@ use tokio_util::sync::CancellationToken;
/// Exactly one of `SIGNET_COLD_PATH` or `SIGNET_COLD_SQL_URL` must be set.
///
/// When using SQL cold storage, connection pool tuning is configured via
/// [`SqlConnector`]'s own environment variables (e.g.
/// the `SqlConnector`'s own environment variables (e.g.
/// `SIGNET_COLD_SQL_MAX_CONNECTIONS`). See the `cold-sql` feature of
/// `init4-bin-base` for the full list.
///
/// [`SqlConnector`]: signet_storage::SqlConnector
///
/// # Example
///
/// ```rust,no_run
Expand Down Expand Up @@ -163,7 +173,7 @@ impl StorageConfig {
pub async fn build_storage(
&self,
cancel: CancellationToken,
) -> eyre::Result<UnifiedStorage<DatabaseEnv>> {
) -> eyre::Result<UnifiedStorage<DatabaseEnv, NodeColdBackend>> {
let hot = MdbxConnector::new(self.hot_path.as_ref());
let has_mdbx = !self.cold_path.is_empty();

Expand All @@ -172,10 +182,20 @@ impl StorageConfig {
#[cfg(not(any(feature = "postgres", feature = "sqlite")))]
let has_sql = std::env::var("SIGNET_COLD_SQL_URL").is_ok_and(|v| !v.is_empty());

// Helper to label the right-hand variant of `Either` for the
// current feature set, so both match arms produce the same
// `Either<MdbxConnector, _>` type.
#[cfg(any(feature = "postgres", feature = "sqlite"))]
type RightCold = SqlConnector;
#[cfg(not(any(feature = "postgres", feature = "sqlite")))]
type RightCold = ();

match (has_mdbx, has_sql) {
(true, false) => Ok(StorageBuilder::new()
.hot(hot)
.cold(MdbxConnector::new(self.cold_path.as_ref()))
.cold(Either::<MdbxConnector, RightCold>::left(MdbxConnector::new(
self.cold_path.as_ref(),
)))
.cancel_token(cancel)
.build()
.await?),
Expand All @@ -185,7 +205,7 @@ impl StorageConfig {
self.cold_sql.clone().expect("cold_sql must be Some when has_sql is true");
Ok(StorageBuilder::new()
.hot(hot)
.cold(connector)
.cold(Either::<MdbxConnector, RightCold>::right(connector))
.cancel_token(cancel)
.build()
.await?)
Expand Down
6 changes: 3 additions & 3 deletions crates/node-tests/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use alloy::{
rpc::types::eth::{TransactionReceipt, TransactionRequest},
};
use signet_blobber::MemoryBlobSource;
use signet_cold::{ColdStorageReadHandle, mem::MemColdBackend};
use signet_cold::{ColdStorage, mem::MemColdBackend};
use signet_hot::{
db::{HotDbRead, UnsafeDbWrite},
mem::MemKv,
Expand Down Expand Up @@ -103,7 +103,7 @@ pub struct SignetTestContext {
pub node_status: watch::Receiver<NodeStatus>,

/// Unified hot + cold storage for the rollup.
pub storage: Arc<UnifiedStorage<MemKv>>,
pub storage: Arc<UnifiedStorage<MemKv, MemColdBackend>>,

/// An alloy provider connected to the Signet Node RPC.
pub alloy_provider: CtxProvider,
Expand Down Expand Up @@ -288,7 +288,7 @@ impl SignetTestContext {
}

/// Get a cold storage read handle.
pub fn cold(&self) -> ColdStorageReadHandle {
pub fn cold(&self) -> ColdStorage<MemColdBackend> {
self.storage.cold_reader()
}

Expand Down
4 changes: 2 additions & 2 deletions crates/node-tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use alloy::{
signers::{SignerSync, local::PrivateKeySigner},
uint,
};
use signet_types::primitives::{RecoveredBlock, Transaction, TransactionSigned};
use signet_types::primitives::{RecoveredBlock, SignetHeaderV1, Transaction, TransactionSigned};
use signet_zenith::Zenith;
use std::{panic, sync::Once};
use tracing_subscriber::EnvFilter;
Expand All @@ -21,7 +21,7 @@ pub fn fake_block(number: u64) -> RecoveredBlock {
excess_blob_gas: Some(0),
..Default::default()
};
RecoveredBlock::blank_with_header(header)
RecoveredBlock::blank_with_header(SignetHeaderV1::new_unchecked(header))
}

/// Sign a transaction with a wallet.
Expand Down
19 changes: 10 additions & 9 deletions crates/node/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{NodeStatus, SignetNode};
use eyre::OptionExt;
use signet_blobber::CacheHandle;
use signet_block_processor::AliasOracleFactory;
use signet_cold::BlockData;
use signet_cold::{BlockData, ColdStorageBackend};
use signet_hot::db::{HotDbRead, UnsafeDbWrite};
use signet_node_config::SignetNodeConfig;
use signet_node_types::HostNotifier;
Expand All @@ -26,7 +26,7 @@ pub struct NotAStorage;
///
/// The builder requires the following components to be set before building:
/// - A [`HostNotifier`], via [`Self::with_notifier`].
/// - An [`Arc<UnifiedStorage<H>>`], via [`Self::with_storage`].
/// - An [`Arc<UnifiedStorage<H, B>>`], via [`Self::with_storage`].
/// - An [`AliasOracleFactory`], via [`Self::with_alias_oracle`].
/// - A [`CacheHandle`], via [`Self::with_blob_cacher`].
/// - A [`ServeConfig`], via [`Self::with_serve_config`].
Expand All @@ -38,10 +38,10 @@ pub struct NotAStorage;
///
/// ```no_run
/// # use signet_node::SignetNodeBuilder;
/// # fn example<H: signet_storage::HotKv>(
/// # fn example<H: signet_storage::HotKv, B: signet_cold::ColdStorageBackend>(
/// # config: signet_node_config::SignetNodeConfig,
/// # notifier: impl signet_node_types::HostNotifier,
/// # storage: std::sync::Arc<signet_storage::UnifiedStorage<H>>,
/// # storage: std::sync::Arc<signet_storage::UnifiedStorage<H, B>>,
/// # alias_oracle: impl signet_block_processor::AliasOracleFactory,
/// # blob_cacher: signet_blobber::CacheHandle,
/// # serve_config: signet_rpc::ServeConfig,
Expand Down Expand Up @@ -91,10 +91,10 @@ impl SignetNodeBuilder {

impl<Notifier, Storage, Aof> SignetNodeBuilder<Notifier, Storage, Aof> {
/// Set the [`UnifiedStorage`] backend for the signet node.
pub fn with_storage<H: HotKv>(
pub fn with_storage<H: HotKv, B: ColdStorageBackend>(
self,
storage: Arc<UnifiedStorage<H>>,
) -> SignetNodeBuilder<Notifier, Arc<UnifiedStorage<H>>, Aof> {
storage: Arc<UnifiedStorage<H, B>>,
) -> SignetNodeBuilder<Notifier, Arc<UnifiedStorage<H, B>>, Aof> {
SignetNodeBuilder {
config: self.config,
alias_oracle: self.alias_oracle,
Expand Down Expand Up @@ -163,10 +163,11 @@ impl<Notifier, Storage, Aof> SignetNodeBuilder<Notifier, Storage, Aof> {
}
}

impl<N, H, Aof> SignetNodeBuilder<N, Arc<UnifiedStorage<H>>, Aof>
impl<N, H, B, Aof> SignetNodeBuilder<N, Arc<UnifiedStorage<H, B>>, Aof>
where
N: HostNotifier,
H: HotKv + Clone + Send + Sync + 'static,
B: ColdStorageBackend,
<H::RoTx as HotKvRead>::Error: DBErrorMarker,
Aof: AliasOracleFactory,
{
Expand Down Expand Up @@ -214,7 +215,7 @@ where
/// - Inits storage from genesis if needed.
pub async fn build(
mut self,
) -> eyre::Result<(SignetNode<N, H, Aof>, tokio::sync::watch::Receiver<NodeStatus>)> {
) -> eyre::Result<(SignetNode<N, H, B, Aof>, tokio::sync::watch::Receiver<NodeStatus>)> {
self.prebuild().await?;
// NB: Notifier, Storage, and Aof are enforced by typestate generics.
// The remaining fields are set via `Option` and checked at runtime.
Expand Down
Loading