diff --git a/Cargo.lock b/Cargo.lock index 18ff0e179a06..8208e2d1e79e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9381,6 +9381,7 @@ dependencies = [ "alloy-trie", "arbitrary", "bytes", + "criterion", "derive_more 1.0.0", "hash-db", "itertools 0.13.0", diff --git a/crates/trie/common/Cargo.toml b/crates/trie/common/Cargo.toml index 5b691d6e2033..fb8ca1642c5b 100644 --- a/crates/trie/common/Cargo.toml +++ b/crates/trie/common/Cargo.toml @@ -35,12 +35,14 @@ arbitrary = { workspace = true, features = ["derive"], optional = true } [dev-dependencies] alloy-primitives = { workspace = true, features = ["getrandom"] } -arbitrary = { workspace = true, features = ["derive"] } -proptest.workspace = true -proptest-arbitrary-interop.workspace = true +alloy-trie = { workspace = true, features = ["arbitrary"] } hash-db = "=0.15.2" plain_hasher = "0.2" serde_json.workspace = true +arbitrary = { workspace = true, features = ["derive"] } +proptest.workspace = true +proptest-arbitrary-interop.workspace = true +criterion.workspace = true [features] test-utils = [ @@ -60,3 +62,7 @@ arbitrary = [ "revm-primitives/arbitrary", "reth-codecs/arbitrary", ] + +[[bench]] +name = "prefix_set" +harness = false diff --git a/crates/trie/trie/benches/prefix_set.rs b/crates/trie/common/benches/prefix_set.rs similarity index 99% rename from crates/trie/trie/benches/prefix_set.rs rename to crates/trie/common/benches/prefix_set.rs index cae08d129f68..b61d58e02729 100644 --- a/crates/trie/trie/benches/prefix_set.rs +++ b/crates/trie/common/benches/prefix_set.rs @@ -7,7 +7,7 @@ use proptest::{ strategy::ValueTree, test_runner::{basic_result_cache, TestRunner}, }; -use reth_trie::{ +use reth_trie_common::{ prefix_set::{PrefixSet, PrefixSetMut}, Nibbles, }; diff --git a/crates/trie/common/src/lib.rs b/crates/trie/common/src/lib.rs index 7645ebd3a1cb..6f3cbf3eeae7 100644 --- a/crates/trie/common/src/lib.rs +++ b/crates/trie/common/src/lib.rs @@ -26,6 +26,10 @@ pub use storage::StorageTrieEntry; mod subnode; pub use subnode::StoredSubNode; +/// The implementation of a container for storing intermediate changes to a trie. +/// The container indicates when the trie has been modified. +pub mod prefix_set; + mod proofs; #[cfg(any(test, feature = "test-utils"))] pub use proofs::triehash; @@ -33,4 +37,5 @@ pub use proofs::*; pub mod root; +/// Re-export pub use alloy_trie::{nodes::*, proof, BranchNodeCompact, HashBuilder, TrieMask, EMPTY_ROOT_HASH}; diff --git a/crates/trie/trie/src/prefix_set.rs b/crates/trie/common/src/prefix_set.rs similarity index 98% rename from crates/trie/trie/src/prefix_set.rs rename to crates/trie/common/src/prefix_set.rs index d904ef38fdd5..1e3567f57d01 100644 --- a/crates/trie/trie/src/prefix_set.rs +++ b/crates/trie/common/src/prefix_set.rs @@ -73,7 +73,7 @@ pub struct TriePrefixSets { /// # Examples /// /// ``` -/// use reth_trie::{prefix_set::PrefixSetMut, Nibbles}; +/// use reth_trie_common::{prefix_set::PrefixSetMut, Nibbles}; /// /// let mut prefix_set_mut = PrefixSetMut::default(); /// prefix_set_mut.insert(Nibbles::from_nibbles_unchecked(&[0xa, 0xb])); @@ -211,8 +211,8 @@ impl PrefixSet { } impl<'a> IntoIterator for &'a PrefixSet { - type Item = &'a reth_trie_common::Nibbles; - type IntoIter = std::slice::Iter<'a, reth_trie_common::Nibbles>; + type Item = &'a Nibbles; + type IntoIter = std::slice::Iter<'a, Nibbles>; fn into_iter(self) -> Self::IntoIter { self.iter() } diff --git a/crates/trie/trie/Cargo.toml b/crates/trie/trie/Cargo.toml index 6136fa8e56bb..48f961c3071e 100644 --- a/crates/trie/trie/Cargo.toml +++ b/crates/trie/trie/Cargo.toml @@ -85,10 +85,6 @@ test-utils = [ "reth-stages-types/test-utils" ] -[[bench]] -name = "prefix_set" -harness = false - [[bench]] name = "hash_post_state" harness = false diff --git a/crates/trie/trie/src/lib.rs b/crates/trie/trie/src/lib.rs index 26bdc751124f..73a08d3fc442 100644 --- a/crates/trie/trie/src/lib.rs +++ b/crates/trie/trie/src/lib.rs @@ -17,10 +17,6 @@ mod constants; pub use constants::*; -/// The implementation of a container for storing intermediate changes to a trie. -/// The container indicates when the trie has been modified. -pub mod prefix_set; - /// The implementation of forward-only in-memory cursor. pub mod forward_cursor;