From 65e66832959954ef77ca580f2268ee2e0d445a6f Mon Sep 17 00:00:00 2001 From: joshieDo <93316087+joshieDo@users.noreply.github.com> Date: Tue, 8 Oct 2024 21:54:47 +0900 Subject: [PATCH] fix(provider): fix sub overflow on `tx_range` queries for empty blocks (#11568) --- crates/storage/provider/src/providers/blockchain_provider.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/storage/provider/src/providers/blockchain_provider.rs b/crates/storage/provider/src/providers/blockchain_provider.rs index 9d07501539..c52d2d58b1 100644 --- a/crates/storage/provider/src/providers/blockchain_provider.rs +++ b/crates/storage/provider/src/providers/blockchain_provider.rs @@ -463,8 +463,9 @@ impl BlockchainProvider2 { let block_tx_count = block_state.block_ref().block().body.transactions.len(); let remaining = (tx_range.end() - tx_range.start() + 1) as usize; - // If the transaction range start is higher than this block last transaction, advance - if *tx_range.start() > in_memory_tx_num + block_tx_count as u64 - 1 { + // If the transaction range start is equal or higher than the next block first + // transaction, advance + if *tx_range.start() >= in_memory_tx_num + block_tx_count as u64 { in_memory_tx_num += block_tx_count as u64; continue }