From a90ecd90577986428853c13163feb371bf121495 Mon Sep 17 00:00:00 2001 From: Dhruv Agarwal <91938348+Dhruv-2003@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:54:12 +0530 Subject: [PATCH] feat(cli): added header request retry in stages run command (#13816) --- crates/cli/commands/src/stage/run.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/cli/commands/src/stage/run.rs b/crates/cli/commands/src/stage/run.rs index 1fb2e2886ce9..254b5fe6483e 100644 --- a/crates/cli/commands/src/stage/run.rs +++ b/crates/cli/commands/src/stage/run.rs @@ -189,9 +189,15 @@ impl let fetch_client = Arc::new(network.fetch_client().await?); // Use `to` as the tip for the stage - let tip: P::BlockHeader = fetch_client - .get_header(BlockHashOrNumber::Number(self.to)) - .await? + let tip: P::BlockHeader = loop { + match fetch_client.get_header(BlockHashOrNumber::Number(self.to)).await { + Ok(header) => break header, + Err(error) if error.is_retryable() => { + warn!(target: "reth::cli", "Error requesting header: {error}. Retrying...") + } + Err(error) => return Err(error.into()), + } + } .into_data() .ok_or(StageError::MissingSyncGap)?; let (_, rx) = watch::channel(tip.hash_slow());