remove ForceBlockLookup

This commit is contained in:
realbigsean
2023-03-29 09:53:37 -04:00
parent 8d80200bc4
commit 9642ec02fa
3 changed files with 13 additions and 41 deletions

View File

@@ -41,13 +41,6 @@ pub type RootBlockTuple<T> = (Hash256, BlockWrapper<T>);
const FAILED_CHAINS_CACHE_EXPIRY_SECONDS: u64 = 60;
const SINGLE_BLOCK_LOOKUP_MAX_ATTEMPTS: u8 = 3;
/// This is used to resolve the scenario where we request a parent from before the data availability
/// boundary and need to retry with a request for only the block.
pub enum ForceBlockRequest {
True,
False,
}
pub(crate) struct BlockLookups<T: BeaconChainTypes> {
/// Parent chain lookups being downloaded.
parent_lookups: SmallVec<[ParentLookup<T>; 3]>,
@@ -204,7 +197,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
}
let parent_lookup = ParentLookup::new(block_root, block, peer_id);
self.request_parent(parent_lookup, cx, ForceBlockRequest::False);
self.request_parent(parent_lookup, cx);
}
/* Lookup responses */
@@ -330,7 +323,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
cx.report_peer(peer_id, PeerAction::LowToleranceError, e);
// We try again if possible.
self.request_parent(parent_lookup, cx, ForceBlockRequest::False);
self.request_parent(parent_lookup, cx);
}
VerifyError::PreviousFailure { parent_root } => {
debug!(
@@ -406,7 +399,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
{
let parent_lookup = self.parent_lookups.remove(pos);
trace!(self.log, "Parent lookup's peer disconnected"; &parent_lookup);
self.request_parent(parent_lookup, cx, ForceBlockRequest::False);
self.request_parent(parent_lookup, cx);
}
}
@@ -427,18 +420,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
parent_lookup.download_failed();
trace!(self.log, "Parent lookup request failed"; &parent_lookup);
// `ResourceUnavailable` indicates we requested a parent block from prior to the 4844 fork epoch.
let force_block_request = if let RPCError::ErrorResponse(
RPCResponseErrorCode::ResourceUnavailable,
_,
) = error
{
debug!(self.log, "RPC parent lookup for block and blobs failed. Retrying the request for just a block"; "peer_id" => %peer_id);
ForceBlockRequest::True
} else {
ForceBlockRequest::False
};
self.request_parent(parent_lookup, cx, force_block_request);
self.request_parent(parent_lookup, cx);
} else {
return debug!(self.log, "RPC failure for a parent lookup request that was not found"; "peer_id" => %peer_id);
};
@@ -603,7 +585,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
// need to keep looking for parents
// add the block back to the queue and continue the search
parent_lookup.add_block(block);
self.request_parent(parent_lookup, cx, ForceBlockRequest::False);
self.request_parent(parent_lookup, cx);
}
BlockProcessResult::Ok
| BlockProcessResult::Err(BlockError::BlockIsAlreadyKnown { .. }) => {
@@ -665,7 +647,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
// Try again if possible
parent_lookup.processing_failed();
self.request_parent(parent_lookup, cx, ForceBlockRequest::False);
self.request_parent(parent_lookup, cx);
}
BlockProcessResult::Ignored => {
// Beacon processor signalled to ignore the block processing result.
@@ -758,9 +740,8 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
&mut self,
mut parent_lookup: ParentLookup<T>,
cx: &mut SyncNetworkContext<T>,
force_block_request: ForceBlockRequest,
) {
match parent_lookup.request_parent(cx, force_block_request) {
match parent_lookup.request_parent(cx) {
Err(e) => {
debug!(self.log, "Failed to request parent"; &parent_lookup, "error" => e.as_static());
match e {