1#![doc = include_str!("../README.md")]
2#![doc(
3 html_logo_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/alloy.jpg",
4 html_favicon_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/favicon.ico"
5)]
6#![warn(
7 missing_copy_implementations,
8 missing_debug_implementations,
9 missing_docs,
10 unreachable_pub,
11 rustdoc::all
12)]
13#![cfg_attr(not(test), warn(unused_crate_dependencies))]
14#![deny(unused_must_use, rust_2018_idioms)]
15#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
16#![cfg_attr(not(feature = "std"), no_std)]
17
18#[macro_use]
19#[allow(unused_imports)]
20extern crate alloc;
21
22pub mod nodes;
23pub use nodes::BranchNodeCompact;
24
25pub mod hash_builder;
26pub use hash_builder::HashBuilder;
27
28pub mod proof;
29
30#[cfg(feature = "ethereum")]
31mod account;
32#[cfg(feature = "ethereum")]
33pub use account::TrieAccount;
34
35mod mask;
36pub use mask::TrieMask;
37
38#[allow(missing_docs)]
39pub mod root;
40
41#[doc(hidden)]
42pub use alloy_primitives::map::HashMap;
43
44#[doc(no_inline)]
45pub use nybbles::{self, Nibbles};
46
47use alloy_primitives::{b256, B256};
48
49pub const EMPTY_ROOT_HASH: B256 =
51 b256!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421");
52
53pub const KECCAK_EMPTY: B256 =
55 b256!("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
56
57#[cfg(test)]
58pub(crate) fn triehash_trie_root<I, K, V>(iter: I) -> B256
59where
60 I: IntoIterator<Item = (K, V)>,
61 K: AsRef<[u8]> + Ord,
62 V: AsRef<[u8]>,
63{
64 struct Keccak256Hasher;
65 impl hash_db::Hasher for Keccak256Hasher {
66 type Out = B256;
67 type StdHasher = plain_hasher::PlainHasher;
68
69 const LENGTH: usize = 32;
70
71 fn hash(x: &[u8]) -> Self::Out {
72 alloy_primitives::keccak256(x)
73 }
74 }
75
76 triehash::trie_root::<Keccak256Hasher, _, _, _>(iter)
81}