diff --git a/CHANGELOG.md b/CHANGELOG.md index f34273d32d..c702a54eb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Pathfinder panics with "Block number Z is not in the range X..=Y" after starting up from an old Sepolia testnet database snapshot. - Pathfinder returns internal errors for some `starknet_getTransactionStatus` / `starknet_getTransactionReceipt` queries for transactions in the pre-confirmed block. +- L2 sync stalls for a while after logging an "L2 sync process terminated with: Fetch signature for BlockNumber(XXX) from sequencer" error. ## [0.20.3] - 2025-09-09 diff --git a/crates/pathfinder/src/state/sync/l2.rs b/crates/pathfinder/src/state/sync/l2.rs index 64ed07f9fb..cd31f96bed 100644 --- a/crates/pathfinder/src/state/sync/l2.rs +++ b/crates/pathfinder/src/state/sync/l2.rs @@ -261,11 +261,28 @@ where // There is a race condition here: if the query for the signature was made // _before_ the block was published -- but by the time we // actually queried for the block it was there. In this case - // we just retry the signature download. + // we just retry the signature download until we get it. let t_signature = std::time::Instant::now(); - let signature = sequencer.signature(next.into()).await.with_context(|| { - format!("Fetch signature for block {next:?} from sequencer") - })?; + let signature = loop { + match sequencer.signature(next.into()).await { + Ok(s) => { + break s; + } + Err(SequencerError::StarknetError(err)) + if err.code + == starknet_gateway_types::error::KnownStarknetErrorCode::BlockNotFound + .into() => + { + // Wait a bit and retry + tokio::time::sleep(Duration::from_millis(500)).await; + continue; + } + Err(err) => { + return Err(err) + .context(format!("Fetch signature for block {next:?} from sequencer")) + } + } + }; (signature, t_signature.elapsed()) } Err(err) => {