Skip to content

Commit

Permalink
Feature gate TrieAccount related code behind ethereum
Browse files Browse the repository at this point in the history
  • Loading branch information
moricho committed Dec 4, 2024
1 parent bfbeb22 commit 7f97f9c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ arbitrary = [
"alloy-primitives/arbitrary",
"nybbles/arbitrary",
]
ethereum = []

[[bench]]
name = "bench"
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ pub use hash_builder::HashBuilder;

pub mod proof;

#[cfg(feature = "ethereum")]
mod account;
#[cfg(feature = "ethereum")]
pub use account::TrieAccount;

mod mask;
Expand Down
4 changes: 4 additions & 0 deletions src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ where
/// Hashes and sorts account keys, then proceeds to calculating the root hash of the state
/// represented as MPT.
/// See [`state_root_unsorted`] for more info.
#[cfg(feature = "ethereum")]
pub fn state_root_ref_unhashed<'a, A: Into<TrieAccount> + Clone + 'a>(
state: impl IntoIterator<Item = (&'a Address, &'a A)>,
) -> B256 {
Expand All @@ -62,6 +63,7 @@ pub fn state_root_ref_unhashed<'a, A: Into<TrieAccount> + Clone + 'a>(
/// Hashes and sorts account keys, then proceeds to calculating the root hash of the state
/// represented as MPT.
/// See [`state_root_unsorted`] for more info.
#[cfg(feature = "ethereum")]
pub fn state_root_unhashed<A: Into<TrieAccount>>(
state: impl IntoIterator<Item = (Address, A)>,
) -> B256 {
Expand All @@ -70,6 +72,7 @@ pub fn state_root_unhashed<A: Into<TrieAccount>>(

/// Sorts the hashed account keys and calculates the root hash of the state represented as MPT.
/// See [`state_root`] for more info.
#[cfg(feature = "ethereum")]
pub fn state_root_unsorted<A: Into<TrieAccount>>(
state: impl IntoIterator<Item = (B256, A)>,
) -> B256 {
Expand All @@ -85,6 +88,7 @@ pub fn state_root_unsorted<A: Into<TrieAccount>>(
/// # Panics
///
/// If the items are not in sorted order.
#[cfg(feature = "ethereum")]
pub fn state_root<A: Into<TrieAccount>>(state: impl IntoIterator<Item = (B256, A)>) -> B256 {
let mut hb = HashBuilder::default();
for (hashed_key, account) in state {
Expand Down

0 comments on commit 7f97f9c

Please sign in to comment.