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