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
20/// Lazy initialization wrapper for trie data.
21mod trie_data;
22pub use trie_data::{LazyTrieData, SortedTrieData};
23
24/// In-memory hashed state.
25mod hashed_state;
26pub use hashed_state::*;
27
28/// Input for trie computation.
29mod input;
30pub use input::{TrieInput, TrieInputSorted};
31
32/// The implementation of hash builder.
33pub mod hash_builder;
34
35/// Constants related to the trie computation.
36mod constants;
37pub use constants::*;
38
39mod account;
40pub use account::TrieAccount;
41
42/// V2 proof targets and chunking.
43pub mod target_v2;
44pub use target_v2::{
45    ChunkedMultiProofTargetsV2, MultiProofTargetsV2, ProofV2Target, ProofV2TargetParent,
46};
47
48mod key;
49pub use key::{KeccakKeyHasher, KeyHasher};
50
51mod nibbles;
52pub use nibbles::{
53    depth_first_cmp, Nibbles, PackedStoredNibbles, PackedStoredNibblesSubKey, StoredNibbles,
54    StoredNibblesSubKey,
55};
56
57mod storage;
58pub use storage::{PackedStorageTrieEntry, StorageTrieEntry};
59
60mod subnode;
61pub use subnode::StoredSubNode;
62
63mod trie;
64pub use trie::{BranchNodeMasks, BranchNodeMasksMap, ProofTrieNode};
65
66mod trie_node_v2;
67pub use trie_node_v2::*;
68
69/// Merkle Patricia trie range-proof verification.
70pub mod range_proof;
71
72/// The implementation of a container for storing intermediate changes to a trie.
73/// The container indicates when the trie has been modified.
74pub mod prefix_set;
75
76mod proofs;
77#[cfg(any(test, feature = "test-utils"))]
78pub use proofs::triehash;
79pub use proofs::*;
80
81pub mod root;
82
83/// Incremental ordered trie root computation.
84pub mod ordered_root;
85
86/// Buffer for trie updates.
87pub mod updates;
88
89/// Utilities used by other modules in this crate.
90mod utils;
91
92/// Bincode-compatible serde implementations for trie types.
93///
94/// `bincode` crate allows for more efficient serialization of trie types, because it allows
95/// non-string map keys.
96///
97/// Read more: <https://github.com/paradigmxyz/reth/issues/11370>
98#[cfg(all(feature = "serde", feature = "serde-bincode-compat"))]
99pub mod serde_bincode_compat {
100    pub use super::{
101        hashed_state::serde_bincode_compat as hashed_state,
102        updates::serde_bincode_compat as updates,
103    };
104}
105
106/// Re-export
107pub use alloy_trie::{
108    nodes::*, proof, BranchNodeCompact, HashBuilder, TrieMask, TrieMaskIter, EMPTY_ROOT_HASH,
109};