From f4255216c78e78ae94ca8927f9f8f2afccb0d69c Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Wed, 21 Aug 2024 22:22:55 -0700 Subject: [PATCH] fix(trie): filter out removed nodes on extend (#10433) --- crates/trie/trie/src/updates.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/trie/trie/src/updates.rs b/crates/trie/trie/src/updates.rs index 2b53ddfd7b..3f9bc73d3d 100644 --- a/crates/trie/trie/src/updates.rs +++ b/crates/trie/trie/src/updates.rs @@ -36,6 +36,7 @@ impl TrieUpdates { /// Extends the trie updates. pub fn extend(&mut self, other: Self) { + self.account_nodes.retain(|nibbles, _| !other.removed_nodes.contains(nibbles)); self.account_nodes.extend(ExcludeEmptyFromPair::from_iter(other.account_nodes)); self.removed_nodes.extend(ExcludeEmpty::from_iter(other.removed_nodes)); for (hashed_address, storage_trie) in other.storage_tries { @@ -157,6 +158,7 @@ impl StorageTrieUpdates { self.removed_nodes.clear(); } self.is_deleted |= other.is_deleted; + self.storage_nodes.retain(|nibbles, _| !other.removed_nodes.contains(nibbles)); self.storage_nodes.extend(ExcludeEmptyFromPair::from_iter(other.storage_nodes)); self.removed_nodes.extend(ExcludeEmpty::from_iter(other.removed_nodes)); }