reth_trie_db/
commitment.rs
1use crate::{
2 DatabaseHashedCursorFactory, DatabaseProof, DatabaseStateRoot, DatabaseStorageRoot,
3 DatabaseTrieCursorFactory, DatabaseTrieWitness,
4};
5use reth_db_api::transaction::DbTx;
6use reth_trie::{
7 proof::Proof, witness::TrieWitness, KeccakKeyHasher, KeyHasher, StateRoot, StorageRoot,
8};
9
10pub trait StateCommitment: std::fmt::Debug + Send + Sync + Unpin + 'static {
12 type StateRoot<'a, TX: DbTx + 'a>: DatabaseStateRoot<'a, TX>;
14 type StorageRoot<'a, TX: DbTx + 'a>: DatabaseStorageRoot<'a, TX>;
16 type StateProof<'a, TX: DbTx + 'a>: DatabaseProof<'a, TX>;
18 type StateWitness<'a, TX: DbTx + 'a>: DatabaseTrieWitness<'a, TX>;
20 type KeyHasher: KeyHasher;
22}
23
24#[derive(Debug)]
26#[non_exhaustive]
27pub struct MerklePatriciaTrie;
28
29impl StateCommitment for MerklePatriciaTrie {
30 type StateRoot<'a, TX: DbTx + 'a> =
31 StateRoot<DatabaseTrieCursorFactory<'a, TX>, DatabaseHashedCursorFactory<'a, TX>>;
32 type StorageRoot<'a, TX: DbTx + 'a> =
33 StorageRoot<DatabaseTrieCursorFactory<'a, TX>, DatabaseHashedCursorFactory<'a, TX>>;
34 type StateProof<'a, TX: DbTx + 'a> =
35 Proof<DatabaseTrieCursorFactory<'a, TX>, DatabaseHashedCursorFactory<'a, TX>>;
36 type StateWitness<'a, TX: DbTx + 'a> =
37 TrieWitness<DatabaseTrieCursorFactory<'a, TX>, DatabaseHashedCursorFactory<'a, TX>>;
38 type KeyHasher = KeccakKeyHasher;
39}