From fca1cd8181c38ddd3b63744ed9c9cc5dec1fa31e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 10 Oct 2024 18:54:06 +0200 Subject: [PATCH] fix: don't unwrap missing requests (#11646) --- crates/storage/codecs/src/alloy/header.rs | 10 ++++++++++ .../provider/src/providers/database/provider.rs | 12 ++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/crates/storage/codecs/src/alloy/header.rs b/crates/storage/codecs/src/alloy/header.rs index 526bc69b13..3a17ed1fdc 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 1afd4da3fa..767f92db98 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) @@ -3483,10 +3481,8 @@ impl(block_number, requests)?; - durations_recorder.record_relative(metrics::Action::InsertBlockRequests); - } + self.tx.put::(block_number, requests)?; + durations_recorder.record_relative(metrics::Action::InsertBlockRequests); } let block_indices = StoredBlockBodyIndices { first_tx_num, tx_count };