fix(trie): intermediate trie node hashes (#11826)

This commit is contained in:
Roman Krasiuk
2024-10-17 10:07:45 +02:00
committed by GitHub
parent e3e83b7e71
commit 63a75fdd95

View File

@ -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
}
};