retry on invalid block/blob

This commit is contained in:
realbigsean
2023-05-22 11:02:41 -04:00
parent c7aad773a8
commit c59a3fcf42
3 changed files with 24 additions and 14 deletions

View File

@@ -909,11 +909,12 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
PeerAction::MidToleranceError,
"single_block_failure",
);
if let Some(blob_id_ref) = blob_id_ref {
// Try it again if possible.
if !request_ref.awaiting_download(ResponseType::Blob) {
if matches!(response_type, ResponseType::Blob)
|| (!request_ref.blob_request_state.component_processed
&& !request_ref.downloading(ResponseType::Blob))
{
retry_request_after_failure(
blob_id_ref,
blob_id_ref.as_mut().unwrap(),
request_ref,
ResponseType::Blob,
peer_id.as_peer_id(),
@@ -921,20 +922,20 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
&self.log,
);
}
}
if let Some(block_id_ref) = block_id_ref {
if !request_ref.awaiting_download(ResponseType::Block) {
if matches!(response_type, ResponseType::Block)
|| (!request_ref.block_request_state.component_processed
&& !request_ref.downloading(ResponseType::Block))
{
// Try it again if possible.
retry_request_after_failure(
block_id_ref,
block_id_ref.as_mut().unwrap(),
request_ref,
ResponseType::Block,
peer_id.as_peer_id(),
cx,
&self.log,
);
}
}
ShouldRemoveLookup::False
}
@@ -1502,7 +1503,7 @@ fn should_remove_missing_components<T: BeaconChainTypes>(
}
request_ref.remove_peer_if_useless(blob_peer.as_peer_id(), ResponseType::Blob);
if let Some(blob_id_ref) = blob_id_ref {
if !request_ref.awaiting_download(ResponseType::Blob) {
if !request_ref.downloading(ResponseType::Blob) {
// Try it again if possible.
return retry_request_after_failure(
blob_id_ref,

View File

@@ -48,6 +48,15 @@ impl<const MAX_ATTEMPTS: u8, T: BeaconChainTypes> SingleBlockLookup<MAX_ATTEMPTS
}
}
pub(crate) fn downloading(&mut self, response_type: ResponseType) -> bool {
match response_type {
ResponseType::Block => {
matches!(self.block_request_state.state, State::Downloading {..})
}
ResponseType::Blob => matches!(self.blob_request_state.state, State::Downloading { .. }),
}
}
pub(crate) fn remove_peer_if_useless(&mut self, peer_id: &PeerId, response_type: ResponseType) {
match response_type {
ResponseType::Block => self.block_request_state.remove_peer_if_useless(peer_id),

View File

@@ -1704,8 +1704,8 @@ mod deneb_only {
.block_response_triggering_process()
.invalid_block_processed()
.expect_penalty()
.expect_blobs_request()
.expect_block_request()
.expect_no_blobs_request()
.blobs_response()
.missing_components_from_blob_request()
.expect_no_penalty()
@@ -1726,7 +1726,7 @@ mod deneb_only {
.invalid_blob_processed()
.expect_penalty()
.expect_blobs_request()
.expect_block_request();
.expect_no_block_request();
}
#[test]
@@ -1881,8 +1881,8 @@ mod deneb_only {
.block_response_triggering_process()
.invalid_block_processed()
.expect_penalty()
.expect_blobs_request()
.expect_block_request()
.expect_no_blobs_request()
.blobs_response()
.missing_components_from_blob_request()
.expect_no_penalty()
@@ -1903,7 +1903,7 @@ mod deneb_only {
.invalid_blob_processed()
.expect_penalty()
.expect_blobs_request()
.expect_block_request();
.expect_no_block_request();
}
#[test]