Penalize based on the right error type

This commit is contained in:
Pawan Dhananjay
2026-05-28 14:28:18 -07:00
parent bbe325732f
commit df0886ee32
2 changed files with 46 additions and 0 deletions

View File

@@ -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))