Skip to content

Commit

Permalink
query only if updates are enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Dec 9, 2024
1 parent c1487fe commit 522273f
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions crates/trie/sparse/src/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,15 +832,21 @@ where
let common = current.common_prefix_length(&path);
*key = current.slice(current.len() - key.len()..common);

// Check if the extension node child is a hash that needs to be revealed
if self.nodes.get(&current).unwrap().is_hash() {
if let Some(node) = self.provider.blinded_node(current.clone())? {
let decoded = TrieNode::decode(&mut &node[..])?;
trace!(target: "trie::sparse", ?current, ?decoded, "Revealing extension node child");
// We'll never have to update the revealed child node, only remove
// or do nothing, so we can safely ignore the hash mask here and
// pass `None`.
self.reveal_node(current.clone(), decoded, None)?;
// If branch node updates retention is enabled, we need to query the
// extension node child to later set the hash mask for a parent branch node
// correctly.
if self.updates.is_some() {
// Check if the extension node child is a hash that needs to be revealed
if self.nodes.get(&current).unwrap().is_hash() {
if let Some(node) = self.provider.blinded_node(current.clone())? {
let decoded = TrieNode::decode(&mut &node[..])?;
trace!(target: "trie::sparse", ?current, ?decoded, "Revealing extension node child");
// We'll never have to update the revealed child node, only
// remove or do nothing, so
// we can safely ignore the hash mask here and
// pass `None`.
self.reveal_node(current.clone(), decoded, None)?;
}
}
}

Expand Down

0 comments on commit 522273f

Please sign in to comment.