Improve error handling
This commit is contained in:
parent
8e57eef0ed
commit
f7eb89ddd9
@ -1070,7 +1070,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
let expected_kzg_commitments =
|
let expected_kzg_commitments =
|
||||||
match block.message().body().blob_kzg_commitments() {
|
match block.message().body().blob_kzg_commitments() {
|
||||||
Ok(kzg_commitments) => kzg_commitments,
|
Ok(kzg_commitments) => kzg_commitments,
|
||||||
Err(_) => return Err(Error::BlobsUnavailable),
|
Err(_) => return Err(Error::NoKzgCommitmentsFieldOnBlock),
|
||||||
};
|
};
|
||||||
if expected_kzg_commitments.is_empty() {
|
if expected_kzg_commitments.is_empty() {
|
||||||
Ok(Some(BlobsSidecar::empty_from_parts(
|
Ok(Some(BlobsSidecar::empty_from_parts(
|
||||||
@ -1079,12 +1079,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
)))
|
)))
|
||||||
} else {
|
} else {
|
||||||
if let Some(boundary) = self.data_availability_boundary() {
|
if let Some(boundary) = self.data_availability_boundary() {
|
||||||
// We should have blobs for all blocks after the boundary.
|
// We should have blobs for all blocks younger than the boundary.
|
||||||
if boundary <= block.epoch() {
|
if boundary <= block.epoch() {
|
||||||
return Err(Error::BlobsUnavailable);
|
return Err(Error::BlobsUnavailable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(None)
|
Err(Error::BlobsOlderThanDataAvailabilityBoundary)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.transpose()
|
.transpose()
|
||||||
|
@ -210,6 +210,8 @@ pub enum BeaconChainError {
|
|||||||
InconsistentFork(InconsistentFork),
|
InconsistentFork(InconsistentFork),
|
||||||
ProposerHeadForkChoiceError(fork_choice::Error<proto_array::Error>),
|
ProposerHeadForkChoiceError(fork_choice::Error<proto_array::Error>),
|
||||||
BlobsUnavailable,
|
BlobsUnavailable,
|
||||||
|
NoKzgCommitmentsFieldOnBlock,
|
||||||
|
BlobsOlderThanDataAvailabilityBoundary,
|
||||||
}
|
}
|
||||||
|
|
||||||
easy_from_to!(SlotProcessingError, BeaconChainError);
|
easy_from_to!(SlotProcessingError, BeaconChainError);
|
||||||
|
@ -251,7 +251,7 @@ impl<T: BeaconChainTypes> Worker<T> {
|
|||||||
let block_epoch = block.epoch();
|
let block_epoch = block.epoch();
|
||||||
|
|
||||||
if Some(block_epoch) >= finalized_data_availability_boundary {
|
if Some(block_epoch) >= finalized_data_availability_boundary {
|
||||||
debug!(
|
error!(
|
||||||
self.log,
|
self.log,
|
||||||
"Peer requested block and blob that should be available, but no blob found";
|
"Peer requested block and blob that should be available, but no blob found";
|
||||||
"peer" => %peer_id,
|
"peer" => %peer_id,
|
||||||
@ -270,7 +270,7 @@ impl<T: BeaconChainTypes> Worker<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok((None, Some(_))) => {
|
Ok((None, Some(_))) => {
|
||||||
debug!(
|
error!(
|
||||||
self.log,
|
self.log,
|
||||||
"Peer requested block and blob, but no block found";
|
"Peer requested block and blob, but no block found";
|
||||||
"peer" => %peer_id,
|
"peer" => %peer_id,
|
||||||
@ -754,17 +754,47 @@ impl<T: BeaconChainTypes> Worker<T> {
|
|||||||
send_response = false;
|
send_response = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Err(BeaconChainError::NoKzgCommitmentsFieldOnBlock) => {
|
||||||
|
error!(
|
||||||
|
self.log,
|
||||||
|
"No kzg_commitments field in block";
|
||||||
|
"block_root" => ?root,
|
||||||
|
);
|
||||||
|
self.send_error_response(
|
||||||
|
peer_id,
|
||||||
|
RPCResponseErrorCode::ResourceUnavailable,
|
||||||
|
"Failed reading field kzg_commitments from block".into(),
|
||||||
|
request_id,
|
||||||
|
);
|
||||||
|
send_response = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Err(BeaconChainError::BlobsOlderThanDataAvailabilityBoundary) => {
|
||||||
|
error!(
|
||||||
|
self.log,
|
||||||
|
"Failed loading blobs older than data availability boundary";
|
||||||
|
"block_root" => ?root,
|
||||||
|
);
|
||||||
|
self.send_error_response(
|
||||||
|
peer_id,
|
||||||
|
RPCResponseErrorCode::ResourceUnavailable,
|
||||||
|
"Blobs older than data availability boundary".into(),
|
||||||
|
request_id,
|
||||||
|
);
|
||||||
|
send_response = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!(
|
error!(
|
||||||
self.log,
|
self.log,
|
||||||
"Error fetching blob for peer";
|
"Error fetching blinded block for block root";
|
||||||
"block_root" => ?root,
|
"block_root" => ?root,
|
||||||
"error" => ?e
|
"error" => ?e
|
||||||
);
|
);
|
||||||
self.send_error_response(
|
self.send_error_response(
|
||||||
peer_id,
|
peer_id,
|
||||||
RPCResponseErrorCode::ServerError,
|
RPCResponseErrorCode::ServerError,
|
||||||
"Failed fetching blobs".into(),
|
"No blobs and failed fetching corresponding block".into(),
|
||||||
request_id,
|
request_id,
|
||||||
);
|
);
|
||||||
send_response = false;
|
send_response = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user