mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-15 09:48:20 +00:00
Improve error types for envelopes (#9414)
N/A Currently, we have `EnvelopeError` having a `ImportError` wrapping a `BlockError`. I feel this is extremely unintuitive because most of the envelope processing functions can simply return an `EnvelopeError` that makes sense in the function's context. It revealed further ugliness when implementing range sync in #9362 This PR does 2 main things: 1. Removes `ImportError(BlockError)` variant 2. Adds `EnvelopeError(EnvelopeError)` variant to a `BlockError`. I feel this is more natural as there can be envelope errors when we try importing a Block but envelope errors can be contained to just envelope related errors. The main blocker to doing this was `PayloadVerificationHandle` returning a `BlockError`. It uses a very small subset of `BlockError` which I extracted to its own error type which can be converted into both a BlockError and EnvelopeError. This allows us to keep most of the pure envelope processing functions to just return EnvelopeErrors while we convert it to a `BlockError` only in import paths where we need to return a consolidated `BlockError`. Co-Authored-By: Pawan Dhananjay <pawandhananjay@gmail.com>
This commit is contained in:
@@ -1654,9 +1654,14 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
crit!(error = %e, "Internal block gossip validation error. Availability check during gossip validation");
|
||||
return None;
|
||||
}
|
||||
Err(e @ BlockError::InternalError(_))
|
||||
| Err(e @ BlockError::EnvelopeBlockRootUnknown(_))
|
||||
| Err(e @ BlockError::OptimisticSyncNotSupported { .. }) => {
|
||||
// This error variant cannot be reached when doing gossip block validation: a block has
|
||||
// no envelope to verify, and `BlockError::EnvelopeError` is only ever produced by the
|
||||
// envelope import pipeline.
|
||||
Err(e @ BlockError::EnvelopeError(_)) => {
|
||||
crit!(error = %e, "Internal block gossip validation error. Envelope error during gossip validation");
|
||||
return None;
|
||||
}
|
||||
Err(e @ BlockError::InternalError(_)) => {
|
||||
error!(error = %e, "Internal block gossip validation error");
|
||||
return None;
|
||||
}
|
||||
@@ -3748,7 +3753,11 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
EnvelopeError::PriorToFinalization { .. }
|
||||
| EnvelopeError::BeaconChainError(_)
|
||||
| EnvelopeError::BeaconStateError(_)
|
||||
| EnvelopeError::ImportError(_) => {
|
||||
// The following variants are produced during envelope import, not gossip
|
||||
// verification, so they cannot be reached here. Ignore them to be safe.
|
||||
| EnvelopeError::OptimisticSyncNotSupported { .. }
|
||||
| EnvelopeError::BlockRootNotInForkChoice(_)
|
||||
| EnvelopeError::InternalError(_) => {
|
||||
self.propagate_validation_result(
|
||||
message_id,
|
||||
peer_id,
|
||||
|
||||
@@ -367,7 +367,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
)
|
||||
.await
|
||||
}
|
||||
Err(e) => Err(e),
|
||||
Err(e) => Err(e.into()),
|
||||
};
|
||||
|
||||
// TODO(gloas): structured penalty classification arrives with the envelope lookup state
|
||||
@@ -1025,6 +1025,10 @@ impl From<Result<AvailabilityProcessingStatus, BlockError>> for BlockProcessingR
|
||||
None
|
||||
}
|
||||
}
|
||||
BlockError::EnvelopeError(_) => {
|
||||
// TODO(gloas): penalize correctly in range sync PR
|
||||
None
|
||||
}
|
||||
// Remaining invalid blocks: penalize the block peer. Listed explicitly so a
|
||||
// new `BlockError` variant forces a compile error here.
|
||||
BlockError::FutureSlot { .. }
|
||||
@@ -1044,8 +1048,6 @@ impl From<Result<AvailabilityProcessingStatus, BlockError>> for BlockProcessingR
|
||||
| BlockError::ParentExecutionPayloadInvalid { .. }
|
||||
| BlockError::KnownInvalidExecutionPayload(_)
|
||||
| BlockError::Slashable
|
||||
| BlockError::EnvelopeBlockRootUnknown(_)
|
||||
| BlockError::OptimisticSyncNotSupported { .. }
|
||||
| BlockError::InvalidBlobCount { .. }
|
||||
| BlockError::BidParentRootMismatch { .. } => block_peer_penalty(&e),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user