From c25206b176c363c1652c8b12a5a8b76b687866cf Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 10 Oct 2024 18:22:37 +0200 Subject: [PATCH] fix: don't unwrap missing requests --- crates/storage/codecs/src/alloy/header.rs | 10 ++++++++++ .../provider/src/providers/database/provider.rs | 6 ++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/storage/codecs/src/alloy/header.rs b/crates/storage/codecs/src/alloy/header.rs index 526bc69b13696..3a17ed1fdcd2c 100644 --- a/crates/storage/codecs/src/alloy/header.rs +++ b/crates/storage/codecs/src/alloy/header.rs @@ -181,4 +181,14 @@ mod tests { let len = header.to_compact(&mut encoded_header); assert_eq!(header, Header::from_compact(&encoded_header, len).0); } + + #[test] + fn test_extra_fields_missing() { + let mut header = HOLESKY_BLOCK; + header.extra_fields = None; + + let mut encoded_header = vec![]; + let len = header.to_compact(&mut encoded_header); + assert_eq!(header, Header::from_compact(&encoded_header, len).0); + } } diff --git a/crates/storage/provider/src/providers/database/provider.rs b/crates/storage/provider/src/providers/database/provider.rs index 1afd4da3fa8cc..15c13637f389f 100644 --- a/crates/storage/provider/src/providers/database/provider.rs +++ b/crates/storage/provider/src/providers/database/provider.rs @@ -2151,10 +2151,8 @@ impl RequestsProvider ) -> ProviderResult> { if self.chain_spec.is_prague_active_at_timestamp(timestamp) { if let Some(number) = self.convert_hash_or_number(id)? { - // If we are past Prague, then all blocks should have a requests list, even if - // empty - let requests = self.tx.get::(number)?.unwrap_or_default(); - return Ok(Some(requests)) + let requests = self.tx.get::(number)?; + return Ok(requests) } } Ok(None)