From ce1e401d217215dfdbe6c9de6b87efadf9f804e6 Mon Sep 17 00:00:00 2001 From: joshieDo <93316087+joshieDo@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:40:18 +0100 Subject: [PATCH] docs: add warning regarding `increment_block` necessity on `write_to_storage` (#7816) --- .../src/bundle_state/bundle_state_with_receipts.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/storage/provider/src/bundle_state/bundle_state_with_receipts.rs b/crates/storage/provider/src/bundle_state/bundle_state_with_receipts.rs index 5e595532c301..1153464f76fa 100644 --- a/crates/storage/provider/src/bundle_state/bundle_state_with_receipts.rs +++ b/crates/storage/provider/src/bundle_state/bundle_state_with_receipts.rs @@ -316,7 +316,12 @@ impl BundleStateWithReceipts { let mut bodies_cursor = tx.cursor_read::()?; let mut receipts_cursor = tx.cursor_write::()?; - for (idx, receipts) in self.receipts.into_iter().enumerate() { + // ATTENTION: Any potential future refactor or change to how this loop works should keep in + // mind that the static file producer must always call `increment_block` even if the block + // has no receipts. Keeping track of the exact block range of the segment is needed for + // consistency, querying and file range segmentation. + let blocks = self.receipts.into_iter().enumerate(); + for (idx, receipts) in blocks { let block_number = self.first_block + idx as u64; let first_tx_index = bodies_cursor .seek_exact(block_number)?