Skip to content

Commit

Permalink
Fix penalties in sync methods (#3384)
Browse files Browse the repository at this point in the history
## Issue Addressed

N/A

## Proposed Changes

Uses the `penalize_peer` function added in #3350 in sync methods as well. The existing code in sync methods missed the `ExecutionPayloadError::UnverifiedNonOptimisticCandidate` case.
  • Loading branch information
pawanjay176 committed Jul 30, 2022
1 parent 034260b commit b3ce8d0
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions beacon_node/network/src/beacon_processor/worker/sync_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use crate::beacon_processor::DuplicateCache;
use crate::metrics;
use crate::sync::manager::{BlockProcessType, SyncMessage};
use crate::sync::{BatchProcessResult, ChainId};
use beacon_chain::CountUnrealized;
use beacon_chain::{
BeaconChainError, BeaconChainTypes, BlockError, ChainSegmentResult, HistoricalBlockError,
};
use beacon_chain::{CountUnrealized, ExecutionPayloadError};
use lighthouse_network::PeerAction;
use slog::{debug, error, info, warn};
use std::sync::Arc;
Expand Down Expand Up @@ -467,24 +467,22 @@ impl<T: BeaconChainTypes> Worker<T> {
mode: FailureMode::ConsensusLayer,
})
}
BlockError::ExecutionPayloadError(e) => match &e {
ExecutionPayloadError::NoExecutionConnection { .. }
| ExecutionPayloadError::RequestFailed { .. } => {
ref err @ BlockError::ExecutionPayloadError(ref epe) => {
if !epe.penalize_peer() {
// These errors indicate an issue with the EL and not the `ChainSegment`.
// Pause the syncing while the EL recovers
debug!(self.log,
"Execution layer verification failed";
"outcome" => "pausing sync",
"err" => ?e
"err" => ?err
);
Err(ChainSegmentFailed {
message: format!("Execution layer offline. Reason: {:?}", e),
message: format!("Execution layer offline. Reason: {:?}", err),
// Do not penalize peers for internal errors.
peer_action: None,
mode: FailureMode::ExecutionLayer { pause_sync: true },
})
}
err => {
} else {
debug!(self.log,
"Invalid execution payload";
"error" => ?err
Expand All @@ -498,7 +496,7 @@ impl<T: BeaconChainTypes> Worker<T> {
mode: FailureMode::ExecutionLayer { pause_sync: false },
})
}
},
}
other => {
debug!(
self.log, "Invalid block received";
Expand Down

0 comments on commit b3ce8d0

Please sign in to comment.