From 63a75fdd95ea71028d9d65c277a514f7e518676e Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Thu, 17 Oct 2024 10:07:45 +0200 Subject: [PATCH] fix(trie): intermediate trie node hashes (#11826) --- crates/trie/sparse/src/trie.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/crates/trie/sparse/src/trie.rs b/crates/trie/sparse/src/trie.rs index d8f4280e87..e83522ca89 100644 --- a/crates/trie/sparse/src/trie.rs +++ b/crates/trie/sparse/src/trie.rs @@ -345,9 +345,7 @@ impl RevealedSparseTrie { } else { let value = self.values.get(&path).unwrap(); let rlp_node = LeafNodeRef { key, value }.rlp(&mut self.rlp_buf); - if let Some(node_hash) = rlp_node.as_hash() { - *hash = Some(node_hash); - } + *hash = rlp_node.as_hash(); rlp_node } } @@ -360,9 +358,7 @@ impl RevealedSparseTrie { let (_, child) = rlp_node_stack.pop().unwrap(); self.rlp_buf.clear(); let rlp_node = ExtensionNodeRef::new(key, &child).rlp(&mut self.rlp_buf); - if let Some(node_hash) = rlp_node.as_hash() { - *hash = Some(node_hash); - } + *hash = rlp_node.as_hash(); rlp_node } else { path_stack.extend([path, child_path]); // need to get rlp node for child first @@ -400,9 +396,7 @@ impl RevealedSparseTrie { self.rlp_buf.clear(); let rlp_node = BranchNodeRef::new(&branch_value_stack_buf, *state_mask) .rlp(&mut self.rlp_buf); - if let Some(node_hash) = rlp_node.as_hash() { - *hash = Some(node_hash); - } + *hash = rlp_node.as_hash(); rlp_node } };