Skip to content

Commit

Permalink
add storage tries diffs if existence doesn't match
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Jan 10, 2025
1 parent 8c3a28d commit 169b055
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions crates/engine/tree/src/tree/trie_updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,24 +145,21 @@ pub(super) fn compare_trie_updates(
let (task, regular) = (task.storage_tries.remove(&key), regular.storage_tries.remove(&key));
if task != regular {
let mut storage_trie_cursor = trie_cursor_factory.storage_trie_cursor(key)?;
if let Some((left, right)) = task.as_ref().zip(regular.as_ref()) {
let storage_diff =
compare_storage_trie_updates(&mut storage_trie_cursor, left, right)?;
if storage_diff.has_differences() {
diff.storage_tries.insert(key, StorageTrieDiffEntry::Value(storage_diff));
}
} else if compare_storage_trie_updates(
&mut storage_trie_cursor,
&task.clone().unwrap_or_default(),
&regular.clone().unwrap_or_default(),
)?
.has_differences()
{
if task.is_some() != regular.is_some() {
diff.storage_tries.insert(
key,
StorageTrieDiffEntry::Existence(task.is_some(), regular.is_some()),
);
}

let storage_diff = compare_storage_trie_updates(
&mut storage_trie_cursor,
&task.unwrap_or_default(),
&regular.unwrap_or_default(),
)?;
if storage_diff.has_differences() {
diff.storage_tries.insert(key, StorageTrieDiffEntry::Value(storage_diff));
}
}
}

Expand Down

0 comments on commit 169b055

Please sign in to comment.