reth_trie/
progress.rs

1use crate::{hash_builder::HashBuilder, trie_cursor::CursorSubNode, updates::TrieUpdates};
2use alloy_primitives::B256;
3use reth_stages_types::MerkleCheckpoint;
4
5/// The progress of the state root computation.
6#[derive(Debug)]
7pub enum StateRootProgress {
8    /// The complete state root computation with updates and computed root.
9    Complete(B256, usize, TrieUpdates),
10    /// The intermediate progress of state root computation.
11    /// Contains the walker stack, the hash builder and the trie updates.
12    Progress(Box<IntermediateStateRootState>, usize, TrieUpdates),
13}
14
15/// The intermediate state of the state root computation.
16#[derive(Debug)]
17pub struct IntermediateStateRootState {
18    /// Previously constructed hash builder.
19    pub hash_builder: HashBuilder,
20    /// Previously recorded walker stack.
21    pub walker_stack: Vec<CursorSubNode>,
22    /// The last hashed account key processed.
23    pub last_account_key: B256,
24}
25
26impl From<MerkleCheckpoint> for IntermediateStateRootState {
27    fn from(value: MerkleCheckpoint) -> Self {
28        Self {
29            hash_builder: HashBuilder::from(value.state),
30            walker_stack: value.walker_stack.into_iter().map(CursorSubNode::from).collect(),
31            last_account_key: value.last_account_key,
32        }
33    }
34}