diff --git a/beacon_node/network/src/sync/backfill_sync/mod.rs b/beacon_node/network/src/sync/backfill_sync/mod.rs index a3d2c826429..4220f85fc3e 100644 --- a/beacon_node/network/src/sync/backfill_sync/mod.rs +++ b/beacon_node/network/src/sync/backfill_sync/mod.rs @@ -422,24 +422,8 @@ impl BackFillSync { self.request_batches(network)?; self.process_completed_batches(network) } - Err(result) => { - let (expected_boundary, received_boundary, outcome) = match result { - Err(e) => { - self.fail_sync(BackFillError::BatchInvalidState(batch_id, e.0))?; - return Ok(ProcessResult::Successful); - } - Ok(v) => v, - }; - warn!(self.log, "Batch received out of range blocks"; "expected_boundary" => expected_boundary, "received_boundary" => received_boundary, - "peer_id" => %peer_id, batch); - - if let BatchOperationOutcome::Failed { blacklist: _ } = outcome { - error!(self.log, "Backfill failed"; "epoch" => batch_id, "received_boundary" => received_boundary, "expected_boundary" => expected_boundary); - self.fail_sync(BackFillError::BatchDownloadFailed(batch_id))?; - return Ok(ProcessResult::Successful); - } - // this batch can't be used, so we need to request it again. - self.retry_batch_download(network, batch_id)?; + Err(e) => { + self.fail_sync(BackFillError::BatchInvalidState(batch_id, e.0))?; Ok(ProcessResult::Successful) } } diff --git a/beacon_node/network/src/sync/range_sync/batch.rs b/beacon_node/network/src/sync/range_sync/batch.rs index 818fde07b83..912287a8a4c 100644 --- a/beacon_node/network/src/sync/range_sync/batch.rs +++ b/beacon_node/network/src/sync/range_sync/batch.rs @@ -271,10 +271,7 @@ impl BatchInfo { pub fn download_completed( &mut self, blocks: Vec>, - ) -> Result< - usize, /* Received blocks */ - Result<(Slot, Slot, BatchOperationOutcome), WrongState>, - > { + ) -> Result { match self.state.poison() { BatchState::Downloading(peer, _request_id) => { let received = blocks.len(); @@ -284,10 +281,10 @@ impl BatchInfo { BatchState::Poisoned => unreachable!("Poisoned batch"), other => { self.state = other; - Err(Err(WrongState(format!( + Err(WrongState(format!( "Download completed for batch in wrong state {:?}", self.state - )))) + ))) } } } diff --git a/beacon_node/network/src/sync/range_sync/chain.rs b/beacon_node/network/src/sync/range_sync/chain.rs index 4eb73f54839..f02262e4b5d 100644 --- a/beacon_node/network/src/sync/range_sync/chain.rs +++ b/beacon_node/network/src/sync/range_sync/chain.rs @@ -265,40 +265,21 @@ impl SyncingChain { } }; - { - // A stream termination has been sent. This batch has ended. Process a completed batch. - // Remove the request from the peer's active batches - self.peers - .get_mut(peer_id) - .map(|active_requests| active_requests.remove(&batch_id)); - - match batch.download_completed(blocks) { - Ok(received) => { - let awaiting_batches = batch_id - .saturating_sub(self.optimistic_start.unwrap_or(self.processing_target)) - / EPOCHS_PER_BATCH; - debug!(self.log, "Batch downloaded"; "epoch" => batch_id, "blocks" => received, "batch_state" => self.visualize_batch_state(), "awaiting_batches" => awaiting_batches); - - // pre-emptively request more blocks from peers whilst we process current blocks, - self.request_batches(network)?; - self.process_completed_batches(network) - } - Err(result) => { - let (expected_boundary, received_boundary, outcome) = result?; - warn!(self.log, "Batch received out of range blocks"; "expected_boundary" => expected_boundary, "received_boundary" => received_boundary, - "peer_id" => %peer_id, batch); - - if let BatchOperationOutcome::Failed { blacklist } = outcome { - return Err(RemoveChain::ChainFailed { - blacklist, - failing_batch: batch_id, - }); - } - // this batch can't be used, so we need to request it again. - self.retry_batch_download(network, batch_id) - } - } - } + // A stream termination has been sent. This batch has ended. Process a completed batch. + // Remove the request from the peer's active batches + self.peers + .get_mut(peer_id) + .map(|active_requests| active_requests.remove(&batch_id)); + + let received = batch.download_completed(blocks)?; + let awaiting_batches = batch_id + .saturating_sub(self.optimistic_start.unwrap_or(self.processing_target)) + / EPOCHS_PER_BATCH; + debug!(self.log, "Batch downloaded"; "epoch" => batch_id, "blocks" => received, "batch_state" => self.visualize_batch_state(), "awaiting_batches" => awaiting_batches); + + // pre-emptively request more blocks from peers whilst we process current blocks, + self.request_batches(network)?; + self.process_completed_batches(network) } /// Processes the batch with the given id.