feat(trie-debug): record SetRoot op in ParallelSparseTrie::set_root (#22324)

Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Brian Picciano
2026-02-18 15:03:42 +01:00
committed by GitHub
parent 8d97ab63c6
commit 302993b45a
3 changed files with 19 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
reth-trie-sparse: patch
---
Added recording of `SetRoot` operation in `ParallelSparseTrie::set_root` when the `trie-debug` feature is enabled.

View File

@@ -70,6 +70,11 @@ pub enum RecordedOp {
UpdateSubtrieHashes,
/// Records a `root()` call.
Root,
/// Records a `set_root` call with the root node that was set.
SetRoot {
/// The root trie node that was set.
node: ProofTrieNodeRecord,
},
}
/// A serializable record of a proof trie node.

View File

@@ -169,6 +169,15 @@ impl SparseTrie for ParallelSparseTrie {
masks: Option<BranchNodeMasks>,
retain_updates: bool,
) -> SparseTrieResult<()> {
#[cfg(feature = "trie-debug")]
self.debug_recorder.record(RecordedOp::SetRoot {
node: ProofTrieNodeRecord::from_proof_trie_node_v2(&ProofTrieNodeV2 {
path: Nibbles::default(),
node: root.clone(),
masks,
}),
});
// A fresh/cleared `ParallelSparseTrie` has a `SparseNode::Empty` at its root in the upper
// subtrie. Delete that so we can reveal the new root node.
let path = Nibbles::default();