From 39fd143d82621b0fc6a6e3af4a75300449eb6521 Mon Sep 17 00:00:00 2001 From: clabby Date: Thu, 5 Sep 2024 09:32:45 -0400 Subject: [PATCH] fix(mpt): Empty list walker Co-Authored-By: Rami Khalil --- crates/mpt/src/list_walker.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/mpt/src/list_walker.rs b/crates/mpt/src/list_walker.rs index f98c82af4..97f93b105 100644 --- a/crates/mpt/src/list_walker.rs +++ b/crates/mpt/src/list_walker.rs @@ -117,6 +117,7 @@ where node => Ok(Self::fetch_leaves(node, fetcher)?), } } + TrieNode::Empty => Ok(VecDeque::new()), _ => anyhow::bail!("Invalid trie node type encountered"), } } @@ -161,6 +162,7 @@ mod test { get_live_derivable_receipts_list, get_live_derivable_transactions_list, TrieNodeProvider, }, + NoopTrieDBFetcher, }; use alloc::{collections::BTreeMap, string::String, vec::Vec}; use alloy_consensus::{ReceiptEnvelope, TxEnvelope}; @@ -221,4 +223,11 @@ mod test { VALUES ); } + + #[test] + fn test_empty_list_walker() { + assert!(OrderedListWalker::fetch_leaves(&TrieNode::Empty, &NoopTrieDBFetcher) + .expect("Failed to traverse empty trie") + .is_empty()); + } }