Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(trie): move prefix sets to reth-trie-common #12860

Merged
merged 3 commits into from
Nov 26, 2024
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions crates/trie/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -60,3 +62,7 @@ arbitrary = [
"revm-primitives/arbitrary",
"reth-codecs/arbitrary",
]

[[bench]]
name = "prefix_set"
harness = false
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
5 changes: 5 additions & 0 deletions crates/trie/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ 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;
pub use proofs::*;

pub mod root;

/// Re-export
pub use alloy_trie::{nodes::*, proof, BranchNodeCompact, HashBuilder, TrieMask, EMPTY_ROOT_HASH};
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
Expand Down Expand Up @@ -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()
}
Expand Down
4 changes: 0 additions & 4 deletions crates/trie/trie/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ test-utils = [
"reth-stages-types/test-utils"
]

[[bench]]
name = "prefix_set"
harness = false

[[bench]]
name = "hash_post_state"
harness = false
Expand Down
4 changes: 0 additions & 4 deletions crates/trie/trie/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading