Skip to content

Commit 921d952

Browse files
authored
Remove un-used batch sync error condition (#6917)
- PR #6497 made obsolete some consistency checks inside the batch I forgot to remove the consumers of those errors Remove un-used batch sync error condition, which was a nested `Result<_, Result<_, E>>`
1 parent 7408719 commit 921d952

File tree

3 files changed

+20
-58
lines changed

3 files changed

+20
-58
lines changed

beacon_node/network/src/sync/backfill_sync/mod.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -422,24 +422,8 @@ impl<T: BeaconChainTypes> BackFillSync<T> {
422422
self.request_batches(network)?;
423423
self.process_completed_batches(network)
424424
}
425-
Err(result) => {
426-
let (expected_boundary, received_boundary, outcome) = match result {
427-
Err(e) => {
428-
self.fail_sync(BackFillError::BatchInvalidState(batch_id, e.0))?;
429-
return Ok(ProcessResult::Successful);
430-
}
431-
Ok(v) => v,
432-
};
433-
warn!(self.log, "Batch received out of range blocks"; "expected_boundary" => expected_boundary, "received_boundary" => received_boundary,
434-
"peer_id" => %peer_id, batch);
435-
436-
if let BatchOperationOutcome::Failed { blacklist: _ } = outcome {
437-
error!(self.log, "Backfill failed"; "epoch" => batch_id, "received_boundary" => received_boundary, "expected_boundary" => expected_boundary);
438-
self.fail_sync(BackFillError::BatchDownloadFailed(batch_id))?;
439-
return Ok(ProcessResult::Successful);
440-
}
441-
// this batch can't be used, so we need to request it again.
442-
self.retry_batch_download(network, batch_id)?;
425+
Err(e) => {
426+
self.fail_sync(BackFillError::BatchInvalidState(batch_id, e.0))?;
443427
Ok(ProcessResult::Successful)
444428
}
445429
}

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,7 @@ impl<E: EthSpec, B: BatchConfig> BatchInfo<E, B> {
271271
pub fn download_completed(
272272
&mut self,
273273
blocks: Vec<RpcBlock<E>>,
274-
) -> Result<
275-
usize, /* Received blocks */
276-
Result<(Slot, Slot, BatchOperationOutcome), WrongState>,
277-
> {
274+
) -> Result<usize /* Received blocks */, WrongState> {
278275
match self.state.poison() {
279276
BatchState::Downloading(peer, _request_id) => {
280277
let received = blocks.len();
@@ -284,10 +281,10 @@ impl<E: EthSpec, B: BatchConfig> BatchInfo<E, B> {
284281
BatchState::Poisoned => unreachable!("Poisoned batch"),
285282
other => {
286283
self.state = other;
287-
Err(Err(WrongState(format!(
284+
Err(WrongState(format!(
288285
"Download completed for batch in wrong state {:?}",
289286
self.state
290-
))))
287+
)))
291288
}
292289
}
293290
}

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

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -265,40 +265,21 @@ impl<T: BeaconChainTypes> SyncingChain<T> {
265265
}
266266
};
267267

268-
{
269-
// A stream termination has been sent. This batch has ended. Process a completed batch.
270-
// Remove the request from the peer's active batches
271-
self.peers
272-
.get_mut(peer_id)
273-
.map(|active_requests| active_requests.remove(&batch_id));
274-
275-
match batch.download_completed(blocks) {
276-
Ok(received) => {
277-
let awaiting_batches = batch_id
278-
.saturating_sub(self.optimistic_start.unwrap_or(self.processing_target))
279-
/ EPOCHS_PER_BATCH;
280-
debug!(self.log, "Batch downloaded"; "epoch" => batch_id, "blocks" => received, "batch_state" => self.visualize_batch_state(), "awaiting_batches" => awaiting_batches);
281-
282-
// pre-emptively request more blocks from peers whilst we process current blocks,
283-
self.request_batches(network)?;
284-
self.process_completed_batches(network)
285-
}
286-
Err(result) => {
287-
let (expected_boundary, received_boundary, outcome) = result?;
288-
warn!(self.log, "Batch received out of range blocks"; "expected_boundary" => expected_boundary, "received_boundary" => received_boundary,
289-
"peer_id" => %peer_id, batch);
290-
291-
if let BatchOperationOutcome::Failed { blacklist } = outcome {
292-
return Err(RemoveChain::ChainFailed {
293-
blacklist,
294-
failing_batch: batch_id,
295-
});
296-
}
297-
// this batch can't be used, so we need to request it again.
298-
self.retry_batch_download(network, batch_id)
299-
}
300-
}
301-
}
268+
// A stream termination has been sent. This batch has ended. Process a completed batch.
269+
// Remove the request from the peer's active batches
270+
self.peers
271+
.get_mut(peer_id)
272+
.map(|active_requests| active_requests.remove(&batch_id));
273+
274+
let received = batch.download_completed(blocks)?;
275+
let awaiting_batches = batch_id
276+
.saturating_sub(self.optimistic_start.unwrap_or(self.processing_target))
277+
/ EPOCHS_PER_BATCH;
278+
debug!(self.log, "Batch downloaded"; "epoch" => batch_id, "blocks" => received, "batch_state" => self.visualize_batch_state(), "awaiting_batches" => awaiting_batches);
279+
280+
// pre-emptively request more blocks from peers whilst we process current blocks,
281+
self.request_batches(network)?;
282+
self.process_completed_batches(network)
302283
}
303284

304285
/// Processes the batch with the given id.

0 commit comments

Comments
 (0)