From d6855396718d15e69185c920b66c862a56785823 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 11 Feb 2026 15:05:16 -0500 Subject: [PATCH] chore: publish readiness fixes and version bump to 0.1.0 Prepare workspace for crates.io publishing: - Fix non-workspace path deps in signet-cold and signet-cold-mdbx - Remove ghost signet-mdbx-hot workspace dependency - Add [package.metadata.docs.rs] to all 6 crates - Bump version from 0.0.1 to 0.1.0 - Add feature flag documentation to all crate lib.rs files - Add rust-toolchain.toml pinning channel 1.92 - Add CHANGELOG.md with initial 0.1.0 entry - Add conformance integration test for signet-cold in-memory backend - Add unified storage integration tests for signet-storage - Remove eprintln! debug output from signet-hot-mdbx test utilities Co-Authored-By: Claude Opus 4.6 --- CHANGELOG.md | 14 ++++++ Cargo.toml | 15 +++--- crates/cold-mdbx/Cargo.toml | 6 ++- crates/cold-mdbx/src/lib.rs | 5 ++ crates/cold/Cargo.toml | 10 +++- crates/cold/src/lib.rs | 7 +++ crates/cold/tests/conformance.rs | 9 ++++ crates/hot-mdbx/Cargo.toml | 4 ++ crates/hot-mdbx/src/lib.rs | 7 +++ crates/hot-mdbx/src/test_utils.rs | 14 ------ crates/hot/Cargo.toml | 4 ++ crates/hot/src/lib.rs | 7 +++ crates/storage/Cargo.toml | 10 ++++ crates/storage/src/lib.rs | 6 +++ crates/storage/tests/unified.rs | 76 +++++++++++++++++++++++++++++++ crates/types/Cargo.toml | 4 ++ rust-toolchain.toml | 3 ++ 17 files changed, 177 insertions(+), 24 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 crates/cold/tests/conformance.rs create mode 100644 crates/storage/tests/unified.rs create mode 100644 rust-toolchain.toml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d304391 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog + +## 0.1.0 + +Initial release of the Signet storage workspace. + +### Crates + +- **signet-storage-types**: Shared primitive types adapted from Reth +- **signet-hot**: Trait-based hot storage abstractions +- **signet-hot-mdbx**: MDBX implementation of hot storage +- **signet-cold**: Append-only cold storage for historical data +- **signet-cold-mdbx**: MDBX table definitions for cold storage +- **signet-storage**: Unified storage interface combining hot and cold backends diff --git a/Cargo.toml b/Cargo.toml index 5dd9fa9..f0ddfe5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["crates/*"] resolver = "2" [workspace.package] -version = "0.0.1" +version = "0.1.0" edition = "2024" rust-version = "1.92" authors = ["init4"] @@ -35,13 +35,12 @@ incremental = false [workspace.dependencies] # internal -signet-hot = { version = "0.0.1", path = "./crates/hot" } -signet-hot-mdbx = { version = "0.0.1", path = "./crates/hot-mdbx" } -signet-mdbx-hot = { version = "0.0.1", path = "./crates/mdbx-hot" } -signet-cold = { version = "0.0.1", path = "./crates/cold" } -signet-cold-mdbx = { version = "0.0.1", path = "./crates/cold-mdbx" } -signet-storage = { version = "0.0.1", path = "./crates/storage" } -signet-storage-types = { version = "0.0.1", path = "./crates/types" } +signet-hot = { version = "0.1.0", path = "./crates/hot" } +signet-hot-mdbx = { version = "0.1.0", path = "./crates/hot-mdbx" } +signet-cold = { version = "0.1.0", path = "./crates/cold" } +signet-cold-mdbx = { version = "0.1.0", path = "./crates/cold-mdbx" } +signet-storage = { version = "0.1.0", path = "./crates/storage" } +signet-storage-types = { version = "0.1.0", path = "./crates/types" } # External, in-house signet-libmdbx = { version = "0.8.0" } diff --git a/crates/cold-mdbx/Cargo.toml b/crates/cold-mdbx/Cargo.toml index d947cb5..925697a 100644 --- a/crates/cold-mdbx/Cargo.toml +++ b/crates/cold-mdbx/Cargo.toml @@ -11,9 +11,13 @@ repository.workspace = true keywords = ["mdbx", "storage", "cold-storage", "blockchain"] categories = ["database-implementations"] +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [dependencies] alloy.workspace = true -signet-cold = { version = "0.0.1", path = "../cold" } +signet-cold.workspace = true signet-hot.workspace = true signet-hot-mdbx.workspace = true signet-storage-types.workspace = true diff --git a/crates/cold-mdbx/src/lib.rs b/crates/cold-mdbx/src/lib.rs index 0093203..96bdf76 100644 --- a/crates/cold-mdbx/src/lib.rs +++ b/crates/cold-mdbx/src/lib.rs @@ -19,6 +19,11 @@ //! ## Metadata Tables //! //! - [`ColdMetadata`]: Storage metadata (latest block, finalized, safe, earliest). +//! +//! # Feature Flags +//! +//! - **`test-utils`**: Propagates `signet-cold/test-utils` for conformance +//! testing against the MDBX backend. #![warn( missing_copy_implementations, diff --git a/crates/cold/Cargo.toml b/crates/cold/Cargo.toml index f60b999..146d5fb 100644 --- a/crates/cold/Cargo.toml +++ b/crates/cold/Cargo.toml @@ -11,15 +11,23 @@ repository.workspace = true keywords = ["blockchain", "storage", "cold-storage", "historical"] categories = ["database-implementations"] +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [dependencies] alloy.workspace = true lru.workspace = true -signet-storage-types = { version = "0.0.1", path = "../types" } +signet-storage-types.workspace = true thiserror.workspace = true tokio.workspace = true tokio-util.workspace = true tracing.workspace = true +[dev-dependencies] +signet-cold = { path = ".", features = ["test-utils"] } +tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } + [features] in-memory = [] test-utils = ["in-memory"] diff --git a/crates/cold/src/lib.rs b/crates/cold/src/lib.rs index 3c645bd..9570f11 100644 --- a/crates/cold/src/lib.rs +++ b/crates/cold/src/lib.rs @@ -122,6 +122,13 @@ //! ``` //! //! This is a design sketch; no implementation is provided yet. +//! +//! # Feature Flags +//! +//! - **`in-memory`**: Enables the [`mem`] module, providing an in-memory +//! [`ColdStorage`] backend for testing. +//! - **`test-utils`**: Enables the [`conformance`] module with backend +//! conformance tests. Implies `in-memory`. #![warn( missing_copy_implementations, diff --git a/crates/cold/tests/conformance.rs b/crates/cold/tests/conformance.rs new file mode 100644 index 0000000..7d38dd7 --- /dev/null +++ b/crates/cold/tests/conformance.rs @@ -0,0 +1,9 @@ +//! Conformance tests for the in-memory cold storage backend. + +use signet_cold::{conformance::conformance, mem::MemColdBackend}; + +#[tokio::test] +async fn mem_backend_conformance() { + let backend = MemColdBackend::new(); + conformance(&backend).await.unwrap(); +} diff --git a/crates/hot-mdbx/Cargo.toml b/crates/hot-mdbx/Cargo.toml index bf9fc89..1ba9f3c 100644 --- a/crates/hot-mdbx/Cargo.toml +++ b/crates/hot-mdbx/Cargo.toml @@ -11,6 +11,10 @@ repository.workspace = true keywords = ["mdbx", "storage", "key-value", "blockchain"] categories = ["database-implementations"] +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [dependencies] alloy.workspace = true bytes.workspace = true diff --git a/crates/hot-mdbx/src/lib.rs b/crates/hot-mdbx/src/lib.rs index b80957c..4e5e5b6 100644 --- a/crates/hot-mdbx/src/lib.rs +++ b/crates/hot-mdbx/src/lib.rs @@ -31,6 +31,13 @@ //! //! Overall, we do NOT recommend using this to open existing databases that //! were not created and managed by this implementation. +//! +//! # Feature Flags +//! +//! - **`test-utils`**: Enables the [`test_utils`] module with MDBX test +//! helpers and conformance tests. Adds a `tempfile` dependency. +//! - **`disable-lock`**: Disables the storage lock file, allowing multiple +//! processes to open the same database. Intended for testing scenarios. #![warn( missing_copy_implementations, diff --git a/crates/hot-mdbx/src/test_utils.rs b/crates/hot-mdbx/src/test_utils.rs index e706403..88777f2 100644 --- a/crates/hot-mdbx/src/test_utils.rs +++ b/crates/hot-mdbx/src/test_utils.rs @@ -1302,11 +1302,6 @@ mod tests { entries.push(next); } } - - eprintln!("\nStorageChangeSets entries ({} total):", entries.len()); - for ((bn, addr), slot, val) in &entries { - eprintln!(" block={}, addr={:?}, slot={}, old_value={}", bn, addr, slot, val); - } } // Count PlainStorageState entries before unwind @@ -1329,10 +1324,6 @@ mod tests { } } - eprintln!("\nPlainStorageState BEFORE unwind ({} total):", entries.len()); - for (addr, slot, val) in &entries { - eprintln!(" addr={:?}, slot={}, value={}", addr, slot, val); - } assert_eq!(entries.len(), 7, "Expected 7 storage entries before unwind"); } @@ -1363,11 +1354,6 @@ mod tests { } } - eprintln!("\nPlainStorageState AFTER unwind ({} total):", entries.len()); - for (addr, slot, val) in &entries { - eprintln!(" addr={:?}, slot={}, value={}", addr, slot, val); - } - // Expected: addr1.slot1=20, addr2.slot1=100 (2 entries) assert_eq!(entries.len(), 2, "Expected 2 storage entries after unwind"); diff --git a/crates/hot/Cargo.toml b/crates/hot/Cargo.toml index df5267b..546c27b 100644 --- a/crates/hot/Cargo.toml +++ b/crates/hot/Cargo.toml @@ -11,6 +11,10 @@ repository.workspace = true keywords = ["storage", "key-value", "blockchain", "database"] categories = ["database-implementations"] +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [dependencies] signet-storage-types.workspace = true signet-zenith.workspace = true diff --git a/crates/hot/src/lib.rs b/crates/hot/src/lib.rs index 980f773..8b844fb 100644 --- a/crates/hot/src/lib.rs +++ b/crates/hot/src/lib.rs @@ -78,6 +78,13 @@ //! [`HotKvRead`]: model::HotKvRead //! [`HotKvWrite`]: model::HotKvWrite //! [`HotKv`]: model::HotKv +//! # Feature Flags +//! +//! - **`in-memory`**: Enables the [`mem`] module, providing an in-memory +//! [`HotKv`] backend for testing. +//! - **`test-utils`**: Enables the [`conformance`] module with backend +//! conformance tests. Implies `in-memory`. +//! //! [`DualKey`]: tables::DualKey //! [`SingleKey`]: tables::SingleKey //! [`Table`]: tables::Table diff --git a/crates/storage/Cargo.toml b/crates/storage/Cargo.toml index 6646313..71293db 100644 --- a/crates/storage/Cargo.toml +++ b/crates/storage/Cargo.toml @@ -11,6 +11,10 @@ repository.workspace = true keywords = ["blockchain", "storage", "ethereum"] categories = ["data-structures"] +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [dependencies] signet-cold.workspace = true signet-hot.workspace = true @@ -20,6 +24,12 @@ alloy.workspace = true thiserror.workspace = true tokio-util.workspace = true +[dev-dependencies] +signet-storage = { path = ".", features = ["test-utils"] } +tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } +tokio-util.workspace = true +trevm.workspace = true + [features] default = [] test-utils = ["signet-hot/test-utils", "signet-cold/test-utils"] diff --git a/crates/storage/src/lib.rs b/crates/storage/src/lib.rs index 2f6cbaf..5fd5bb4 100644 --- a/crates/storage/src/lib.rs +++ b/crates/storage/src/lib.rs @@ -38,6 +38,12 @@ //! // 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. #![warn( missing_copy_implementations, diff --git a/crates/storage/tests/unified.rs b/crates/storage/tests/unified.rs new file mode 100644 index 0000000..34da081 --- /dev/null +++ b/crates/storage/tests/unified.rs @@ -0,0 +1,76 @@ +//! Integration tests for [`UnifiedStorage`]. + +use alloy::consensus::{Header, Sealable}; +use signet_cold::{ColdStorageTask, HeaderSpecifier, mem::MemColdBackend}; +use signet_hot::{HistoryRead, HotKv, mem::MemKv}; +use signet_storage::UnifiedStorage; +use signet_storage_types::{ExecutedBlock, ExecutedBlockBuilder, SealedHeader}; +use tokio_util::sync::CancellationToken; +use trevm::revm::database::BundleState; + +/// Build a chain of blocks with valid parent hash linkage. +fn make_chain(count: u64) -> Vec { + let mut blocks = Vec::with_capacity(count as usize); + let mut parent_hash = alloy::primitives::B256::ZERO; + + for number in 0..count { + let header = Header { number, parent_hash, ..Default::default() }; + let sealed: SealedHeader = header.seal_slow(); + parent_hash = sealed.hash(); + let block = ExecutedBlockBuilder::new() + .header(sealed) + .bundle(BundleState::default()) + .build() + .unwrap(); + blocks.push(block); + } + blocks +} + +#[tokio::test] +async fn append_and_read_back() { + let hot = MemKv::new(); + let cancel = CancellationToken::new(); + let cold_handle = ColdStorageTask::spawn(MemColdBackend::new(), cancel.clone()); + + let storage = UnifiedStorage::new(hot.clone(), cold_handle.clone()); + + // Append a block + let blocks = make_chain(1); + let expected_hash = blocks[0].header.hash(); + storage.append_blocks(blocks).unwrap(); + + // Verify hot storage has the block + let reader = hot.reader().unwrap(); + let tip = reader.get_chain_tip().unwrap(); + assert_eq!(tip, Some((0, expected_hash))); + + // Verify cold storage has the header + let header = cold_handle.get_header(HeaderSpecifier::Number(0)).await.unwrap(); + assert!(header.is_some()); + + cancel.cancel(); +} + +#[tokio::test] +async fn append_multiple_and_unwind() { + let hot = MemKv::new(); + let cancel = CancellationToken::new(); + let cold_handle = ColdStorageTask::spawn(MemColdBackend::new(), cancel.clone()); + + let storage = UnifiedStorage::new(hot.clone(), cold_handle.clone()); + + // Append blocks 0, 1, 2 + storage.append_blocks(make_chain(3)).unwrap(); + + // Verify tip is at block 2 + assert_eq!(hot.reader().unwrap().get_chain_tip().unwrap().unwrap().0, 2); + + // Unwind above block 0 + storage.unwind_above(0).unwrap(); + + // Hot tip should be block 0 + assert_eq!(hot.reader().unwrap().get_chain_tip().unwrap().unwrap().0, 0); + + cancel.cancel(); +} diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index 867ed4f..53e4da1 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -11,6 +11,10 @@ repository.workspace = true keywords = ["blockchain", "storage", "types", "ethereum"] categories = ["data-structures"] +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [dependencies] alloy.workspace = true bitflags = "2.10.0" diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..29d6aeb --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.92" +components = ["clippy", "rustfmt"]