diff --git a/crates/trie/sparse/src/state.rs b/crates/trie/sparse/src/state.rs index cf0bc20ab..58bb484e7 100644 --- a/crates/trie/sparse/src/state.rs +++ b/crates/trie/sparse/src/state.rs @@ -3,6 +3,7 @@ use crate::{ RevealedSparseTrie, SparseStateTrieError, SparseStateTrieResult, SparseTrie, SparseTrieError, }; use alloy_primitives::{ + hex, map::{HashMap, HashSet}, Bytes, B256, }; @@ -13,10 +14,9 @@ use reth_trie_common::{ updates::{StorageTrieUpdates, TrieUpdates}, MultiProof, Nibbles, TrieAccount, TrieNode, EMPTY_ROOT_HASH, TRIE_ACCOUNT_RLP_MAX_SIZE, }; -use std::iter::Peekable; +use std::{fmt, iter::Peekable}; /// Sparse state trie representing lazy-loaded Ethereum state trie. -#[derive(Debug)] pub struct SparseStateTrie { /// Blinded node provider factory. provider_factory: F, @@ -45,6 +45,18 @@ impl Default for SparseStateTrie { } } +impl fmt::Debug for SparseStateTrie { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("SparseStateTrie") + .field("state", &self.state) + .field("storages", &self.storages) + .field("revealed", &self.revealed) + .field("retain_updates", &self.retain_updates) + .field("account_rlp_buf", &hex::encode(&self.account_rlp_buf)) + .finish_non_exhaustive() + } +} + impl SparseStateTrie { /// Create state trie from state trie. pub fn from_state(state: SparseTrie) -> Self { diff --git a/crates/trie/sparse/src/trie.rs b/crates/trie/sparse/src/trie.rs index dd609a77c..cc6f110e0 100644 --- a/crates/trie/sparse/src/trie.rs +++ b/crates/trie/sparse/src/trie.rs @@ -19,7 +19,7 @@ use std::{borrow::Cow, fmt}; /// Inner representation of the sparse trie. /// Sparse trie is blind by default until nodes are revealed. -#[derive(PartialEq, Eq, Debug)] +#[derive(PartialEq, Eq)] pub enum SparseTrie

{ /// None of the trie nodes are known. Blind, @@ -27,6 +27,15 @@ pub enum SparseTrie

{ Revealed(Box>), } +impl

fmt::Debug for SparseTrie

{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Blind => write!(f, "Blind"), + Self::Revealed(revealed) => write!(f, "Revealed({revealed:?})"), + } + } +} + impl

Default for SparseTrie

{ fn default() -> Self { Self::Blind @@ -164,7 +173,7 @@ impl

fmt::Debug for RevealedSparseTrie

{ .field("prefix_set", &self.prefix_set) .field("updates", &self.updates) .field("rlp_buf", &hex::encode(&self.rlp_buf)) - .finish() + .finish_non_exhaustive() } }