chore(trie): move prefix sets to reth_trie_common (#12860)

This commit is contained in:
Roman Krasiuk
2024-11-26 10:29:28 +01:00
committed by GitHub
parent 96d61dd44b
commit fae44bf74a
7 changed files with 19 additions and 15 deletions

1
Cargo.lock generated
View File

@ -9381,6 +9381,7 @@ dependencies = [
"alloy-trie", "alloy-trie",
"arbitrary", "arbitrary",
"bytes", "bytes",
"criterion",
"derive_more 1.0.0", "derive_more 1.0.0",
"hash-db", "hash-db",
"itertools 0.13.0", "itertools 0.13.0",

View File

@ -35,12 +35,14 @@ arbitrary = { workspace = true, features = ["derive"], optional = true }
[dev-dependencies] [dev-dependencies]
alloy-primitives = { workspace = true, features = ["getrandom"] } alloy-primitives = { workspace = true, features = ["getrandom"] }
arbitrary = { workspace = true, features = ["derive"] } alloy-trie = { workspace = true, features = ["arbitrary"] }
proptest.workspace = true
proptest-arbitrary-interop.workspace = true
hash-db = "=0.15.2" hash-db = "=0.15.2"
plain_hasher = "0.2" plain_hasher = "0.2"
serde_json.workspace = true serde_json.workspace = true
arbitrary = { workspace = true, features = ["derive"] }
proptest.workspace = true
proptest-arbitrary-interop.workspace = true
criterion.workspace = true
[features] [features]
test-utils = [ test-utils = [
@ -60,3 +62,7 @@ arbitrary = [
"revm-primitives/arbitrary", "revm-primitives/arbitrary",
"reth-codecs/arbitrary", "reth-codecs/arbitrary",
] ]
[[bench]]
name = "prefix_set"
harness = false

View File

@ -7,7 +7,7 @@ use proptest::{
strategy::ValueTree, strategy::ValueTree,
test_runner::{basic_result_cache, TestRunner}, test_runner::{basic_result_cache, TestRunner},
}; };
use reth_trie::{ use reth_trie_common::{
prefix_set::{PrefixSet, PrefixSetMut}, prefix_set::{PrefixSet, PrefixSetMut},
Nibbles, Nibbles,
}; };

View File

@ -26,6 +26,10 @@ pub use storage::StorageTrieEntry;
mod subnode; mod subnode;
pub use subnode::StoredSubNode; 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; mod proofs;
#[cfg(any(test, feature = "test-utils"))] #[cfg(any(test, feature = "test-utils"))]
pub use proofs::triehash; pub use proofs::triehash;
@ -33,4 +37,5 @@ pub use proofs::*;
pub mod root; pub mod root;
/// Re-export
pub use alloy_trie::{nodes::*, proof, BranchNodeCompact, HashBuilder, TrieMask, EMPTY_ROOT_HASH}; pub use alloy_trie::{nodes::*, proof, BranchNodeCompact, HashBuilder, TrieMask, EMPTY_ROOT_HASH};

View File

@ -73,7 +73,7 @@ pub struct TriePrefixSets {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// use reth_trie::{prefix_set::PrefixSetMut, Nibbles}; /// use reth_trie_common::{prefix_set::PrefixSetMut, Nibbles};
/// ///
/// let mut prefix_set_mut = PrefixSetMut::default(); /// let mut prefix_set_mut = PrefixSetMut::default();
/// prefix_set_mut.insert(Nibbles::from_nibbles_unchecked(&[0xa, 0xb])); /// prefix_set_mut.insert(Nibbles::from_nibbles_unchecked(&[0xa, 0xb]));
@ -211,8 +211,8 @@ impl PrefixSet {
} }
impl<'a> IntoIterator for &'a PrefixSet { impl<'a> IntoIterator for &'a PrefixSet {
type Item = &'a reth_trie_common::Nibbles; type Item = &'a Nibbles;
type IntoIter = std::slice::Iter<'a, reth_trie_common::Nibbles>; type IntoIter = std::slice::Iter<'a, Nibbles>;
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
self.iter() self.iter()
} }

View File

@ -85,10 +85,6 @@ test-utils = [
"reth-stages-types/test-utils" "reth-stages-types/test-utils"
] ]
[[bench]]
name = "prefix_set"
harness = false
[[bench]] [[bench]]
name = "hash_post_state" name = "hash_post_state"
harness = false harness = false

View File

@ -17,10 +17,6 @@
mod constants; mod constants;
pub use 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. /// The implementation of forward-only in-memory cursor.
pub mod forward_cursor; pub mod forward_cursor;