From 721a58118060b70819e6fa620ae4003cf206f58d Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin <5773434+shekhirin@users.noreply.github.com> Date: Mon, 6 Jan 2025 20:20:50 +0000 Subject: [PATCH] fix(tree): do not reveal nodes twice in sparse trie (#13674) --- crates/trie/sparse/src/trie.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/trie/sparse/src/trie.rs b/crates/trie/sparse/src/trie.rs index 04f034e1c..8f54d9454 100644 --- a/crates/trie/sparse/src/trie.rs +++ b/crates/trie/sparse/src/trie.rs @@ -282,6 +282,11 @@ impl

RevealedSparseTrie

{ node: TrieNode, hash_mask: Option, ) -> SparseTrieResult<()> { + // If the node is already revealed and it's not a hash node, do nothing. + if self.nodes.get(&path).is_some_and(|node| !node.is_hash()) { + return Ok(()) + } + if let Some(hash_mask) = hash_mask { self.branch_node_hash_masks.insert(path.clone(), hash_mask); }