mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-17 02:38:34 +00:00
Penalize based on the right error type
This commit is contained in:
@@ -176,6 +176,27 @@ impl std::fmt::Display for EnvelopeError {
|
||||
}
|
||||
}
|
||||
|
||||
impl EnvelopeError {
|
||||
pub fn penalize_peer(&self) -> bool {
|
||||
match self {
|
||||
EnvelopeError::BadSignature
|
||||
| EnvelopeError::BuilderIndexMismatch { .. }
|
||||
| EnvelopeError::SlotMismatch { .. }
|
||||
| EnvelopeError::BlockHashMismatch { .. }
|
||||
| EnvelopeError::UnknownValidator { .. }
|
||||
| EnvelopeError::IncorrectBlockProposer { .. }
|
||||
| EnvelopeError::EnvelopeProcessingError(_) => true,
|
||||
EnvelopeError::ExecutionPayloadError(e) => e.penalize_peer(),
|
||||
EnvelopeError::ImportError(BlockError::ExecutionPayloadError(e)) => e.penalize_peer(),
|
||||
EnvelopeError::BlockRootUnknown { .. }
|
||||
| EnvelopeError::PriorToFinalization { .. }
|
||||
| EnvelopeError::BeaconChainError(_)
|
||||
| EnvelopeError::BeaconStateError(_)
|
||||
| EnvelopeError::ImportError(_) => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BeaconChainError> for EnvelopeError {
|
||||
fn from(e: BeaconChainError) -> Self {
|
||||
EnvelopeError::BeaconChainError(Arc::new(e))
|
||||
|
||||
@@ -1008,6 +1008,31 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
peer_action: None,
|
||||
})
|
||||
}
|
||||
ref err @ BlockError::EnvelopeError(ref envelope_error) => {
|
||||
if envelope_error.penalize_peer() {
|
||||
debug!(error = ?err, "Invalid execution payload envelope");
|
||||
Err(ChainSegmentFailed {
|
||||
message: format!(
|
||||
"Peer sent an invalid execution payload envelope. Reason: {:?}",
|
||||
err
|
||||
),
|
||||
peer_action: Some(PeerAction::LowToleranceError),
|
||||
})
|
||||
} else {
|
||||
debug!(
|
||||
outcome = "not penalizing peer",
|
||||
?err,
|
||||
"Execution payload envelope processing failed"
|
||||
);
|
||||
Err(ChainSegmentFailed {
|
||||
message: format!(
|
||||
"Execution payload envelope processing failed. Reason: {:?}",
|
||||
err
|
||||
),
|
||||
peer_action: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
ref err @ BlockError::ExecutionPayloadError(ref epe) => {
|
||||
if !epe.penalize_peer() {
|
||||
// These errors indicate an issue with the EL and not the `ChainSegment`.
|
||||
|
||||
Reference in New Issue
Block a user