From ba8c8354e51a9b40f8320937c44a396ca73ecd39 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Tue, 27 Jan 2026 08:10:53 -0800 Subject: [PATCH] fix(reth-bench): retry up to 5 times on failed transaction fetches in big blocks generate (#21483) --- .../src/bench/generate_big_block.rs | 47 ++++++++++++------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/bin/reth-bench/src/bench/generate_big_block.rs b/bin/reth-bench/src/bench/generate_big_block.rs index 0352d0a39d..7869ee829c 100644 --- a/bin/reth-bench/src/bench/generate_big_block.rs +++ b/bin/reth-bench/src/bench/generate_big_block.rs @@ -401,25 +401,38 @@ impl Command { let mut current_block = start_block; for payload_idx in 0..count { - match collector.collect(current_block).await { - Ok((transactions, total_gas, next_block)) => { - info!( - payload = payload_idx + 1, - tx_count = transactions.len(), - total_gas, - blocks = format!("{}..{}", current_block, next_block), - "Fetched transactions" - ); - current_block = next_block; - - if tx_sender.send(transactions).await.is_err() { - break; + const MAX_RETRIES: u32 = 5; + let mut attempts = 0; + let result = loop { + attempts += 1; + match collector.collect(current_block).await { + Ok(res) => break Some(res), + Err(e) => { + if attempts >= MAX_RETRIES { + warn!(payload = payload_idx + 1, attempts, error = %e, "Failed to fetch transactions after max retries"); + break None; + } + warn!(payload = payload_idx + 1, attempts, error = %e, "Failed to fetch transactions, retrying..."); + tokio::time::sleep(std::time::Duration::from_secs(1)).await; } } - Err(e) => { - warn!(payload = payload_idx + 1, error = %e, "Failed to fetch transactions"); - break; - } + }; + + let Some((transactions, total_gas, next_block)) = result else { + break; + }; + + info!( + payload = payload_idx + 1, + tx_count = transactions.len(), + total_gas, + blocks = format!("{}..{}", current_block, next_block), + "Fetched transactions" + ); + current_block = next_block; + + if tx_sender.send(transactions).await.is_err() { + break; } } });