From d9266ca2e4d54b17ceabdca4ed2861d32b8b739a Mon Sep 17 00:00:00 2001 From: Wataxi Date: Sun, 26 Apr 2026 05:13:42 +0800 Subject: [PATCH] fix(trie): account for heap-allocated blinded hashes in `SparseNode::memory_size` `Branch` was only counting `size_of::()`, missing the 512 bytes held behind `Box<[B256; 16]>`. Before: a branch reports ~80 B; after: ~592 B, matching actual allocation and keeping `ParallelSparseTrie::memory_size` from undercounting by ~5 MB per 10k branches. --- crates/trie/sparse/src/trie.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/trie/sparse/src/trie.rs b/crates/trie/sparse/src/trie.rs index 0fa1fd9c66e..2a65d62dec9 100644 --- a/crates/trie/sparse/src/trie.rs +++ b/crates/trie/sparse/src/trie.rs @@ -437,7 +437,10 @@ impl SparseNode { /// Returns the memory size of this node in bytes. pub const fn memory_size(&self) -> usize { match self { - Self::Empty | Self::Branch { .. } => core::mem::size_of::(), + Self::Empty => core::mem::size_of::(), + Self::Branch { .. } => { + core::mem::size_of::() + core::mem::size_of::<[B256; 16]>() + } Self::Leaf { key, .. } | Self::Extension { key, .. } => { core::mem::size_of::() + key.len() }