Skip to content

Commit ee1b0ae

Browse files
authored
Allow for sync state where batch is unknown (#7391)
1 parent 522bd9e commit ee1b0ae

File tree

1 file changed

+12
-7
lines changed
  • beacon_node/network/src/sync/range_sync

1 file changed

+12
-7
lines changed

beacon_node/network/src/sync/range_sync/chain.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ impl<T: BeaconChainTypes> SyncingChain<T> {
363363
BatchState::Poisoned => unreachable!("Poisoned batch"),
364364
BatchState::Failed | BatchState::AwaitingDownload | BatchState::Processing(_) => {
365365
// these are all inconsistent states:
366-
// - Failed -> non recoverable batch. Chain should have beee removed
366+
// - Failed -> non recoverable batch. Chain should have been removed
367367
// - AwaitingDownload -> A recoverable failed batch should have been
368368
// re-requested.
369369
// - Processing -> `self.current_processing_batch` is None
@@ -395,11 +395,15 @@ impl<T: BeaconChainTypes> SyncingChain<T> {
395395
// return an error.
396396
return Ok(KeepChain);
397397
} else {
398-
return Err(RemoveChain::WrongChainState(format!(
399-
"Batch not found for current processing target {}",
400-
self.processing_target
401-
)));
398+
// NOTE: It is possible that the batch doesn't exist for the processing id. This can happen
399+
// when we complete a batch and attempt to download a new batch but there are:
400+
// 1. No idle peers to download from
401+
// 2. No good peers on sampling subnets
402+
//
403+
// In these cases, a batch will not yet exist.
404+
debug!(batch = %self.processing_target, "The processing batch has not been scheduled for download yet. Awaiting progress");
402405
}
406+
403407
Ok(KeepChain)
404408
}
405409

@@ -511,7 +515,7 @@ impl<T: BeaconChainTypes> SyncingChain<T> {
511515
imported_blocks,
512516
penalty,
513517
} => {
514-
// Penalize the peer appropiately.
518+
// Penalize the peer appropriately.
515519
network.report_peer(peer, *penalty, "faulty_batch");
516520

517521
// Check if this batch is allowed to continue
@@ -553,7 +557,8 @@ impl<T: BeaconChainTypes> SyncingChain<T> {
553557
}
554558
BatchProcessResult::NonFaultyFailure => {
555559
batch.processing_completed(BatchProcessingResult::NonFaultyFailure)?;
556-
// Simply redownload the batch.
560+
561+
// Simply re-download the batch.
557562
self.send_batch(network, batch_id)
558563
}
559564
}

0 commit comments

Comments
 (0)