Skip to main content

reth_trie_common/
lib.rs

1//! Commonly used types for trie usage.
2
3#![doc(
4    html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
5    html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
6    issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
7)]
8#![cfg_attr(not(test), warn(unused_crate_dependencies))]
9#![cfg_attr(docsrs, feature(doc_cfg))]
10#![cfg_attr(not(feature = "std"), no_std)]
11
12extern crate alloc;
13
14// Used directly only by the `eip1186` feature and tests.
15use alloy_consensus as _;
16
17mod execution_witness;
18pub use execution_witness::ExecutionWitnessMode;
19
20mod lazy_hashed_state;
21pub use lazy_hashed_state::{HashedPostStateSortedProducer, LazyHashedPostStateSorted};
22
23mod block_trie_data;
24pub use block_trie_data::BlockTrieData;
25
26/// In-memory hashed state.
27mod hashed_state;
28pub use hashed_state::*;
29
30/// Input for trie computation.
31mod input;
32pub use input::{TrieInput, TrieInputSorted};
33
34/// The implementation of hash builder.
35pub mod hash_builder;
36
37/// Constants related to the trie computation.
38mod constants;
39pub use constants::*;
40
41mod account;
42pub use account::TrieAccount;
43
44/// V2 proof targets and chunking.
45pub mod target_v2;
46pub use target_v2::{
47    ChunkedMultiProofTargetsV2, MultiProofTargetsV2, ProofV2Target, ProofV2TargetParent,
48};
49
50mod key;
51pub use key::{KeccakKeyHasher, KeyHasher};
52
53mod nibbles;
54pub use nibbles::{
55    depth_first_cmp, Nibbles, PackedStoredNibbles, PackedStoredNibblesSubKey, StoredNibbles,
56    StoredNibblesSubKey,
57};
58
59mod storage;
60pub use storage::{PackedStorageTrieEntry, StorageTrieEntry};
61
62mod subnode;
63pub use subnode::StoredSubNode;
64
65mod trie;
66pub use trie::{BranchNodeMasks, BranchNodeMasksMap, ProofTrieNode};
67
68mod trie_node_v2;
69pub use trie_node_v2::*;
70
71/// Merkle Patricia trie range-proof verification.
72pub mod range_proof;
73
74/// The implementation of a container for storing intermediate changes to a trie.
75/// The container indicates when the trie has been modified.
76pub mod prefix_set;
77
78mod proofs;
79#[cfg(any(test, feature = "test-utils"))]
80pub use proofs::triehash;
81pub use proofs::*;
82
83pub mod root;
84
85/// Incremental ordered trie root computation.
86pub mod ordered_root;
87
88/// Buffer for trie updates.
89pub mod updates;
90
91/// Utilities used by other modules in this crate.
92mod utils;
93
94/// Bincode-compatible serde implementations for trie types.
95///
96/// `bincode` crate allows for more efficient serialization of trie types, because it allows
97/// non-string map keys.
98///
99/// Read more: <https://github.com/paradigmxyz/reth/issues/11370>
100#[cfg(all(feature = "serde", feature = "serde-bincode-compat"))]
101pub mod serde_bincode_compat {
102    pub use super::{
103        hashed_state::serde_bincode_compat as hashed_state,
104        updates::serde_bincode_compat as updates,
105    };
106}
107
108/// Re-export
109pub use alloy_trie::{
110    nodes::*, proof, BranchNodeCompact, HashBuilder, TrieMask, TrieMaskIter, EMPTY_ROOT_HASH,
111};