mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-10 19:49:35 +00:00
remove ForceBlockLookup
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
use super::RootBlockTuple;
|
||||
use crate::sync::{
|
||||
manager::{Id, SLOT_IMPORT_TOLERANCE},
|
||||
network_context::SyncNetworkContext,
|
||||
};
|
||||
use beacon_chain::blob_verification::AsBlock;
|
||||
use beacon_chain::blob_verification::BlockWrapper;
|
||||
use beacon_chain::BeaconChainTypes;
|
||||
@@ -6,12 +10,6 @@ use lighthouse_network::PeerId;
|
||||
use store::Hash256;
|
||||
use strum::IntoStaticStr;
|
||||
|
||||
use crate::sync::block_lookups::ForceBlockRequest;
|
||||
use crate::sync::{
|
||||
manager::{Id, SLOT_IMPORT_TOLERANCE},
|
||||
network_context::SyncNetworkContext,
|
||||
};
|
||||
|
||||
use super::single_block_lookup::{self, SingleBlockRequest};
|
||||
|
||||
/// How many attempts we try to find a parent of a block before we give up trying.
|
||||
@@ -73,18 +71,14 @@ impl<T: BeaconChainTypes> ParentLookup<T> {
|
||||
}
|
||||
|
||||
/// Attempts to request the next unknown parent. If the request fails, it should be removed.
|
||||
pub fn request_parent(
|
||||
&mut self,
|
||||
cx: &mut SyncNetworkContext<T>,
|
||||
force_block_request: ForceBlockRequest,
|
||||
) -> Result<(), RequestError> {
|
||||
pub fn request_parent(&mut self, cx: &mut SyncNetworkContext<T>) -> Result<(), RequestError> {
|
||||
// check to make sure this request hasn't failed
|
||||
if self.downloaded_blocks.len() >= PARENT_DEPTH_TOLERANCE {
|
||||
return Err(RequestError::ChainTooLong);
|
||||
}
|
||||
|
||||
let (peer_id, request) = self.current_parent_request.request_block()?;
|
||||
match cx.parent_lookup_request(peer_id, request, force_block_request) {
|
||||
match cx.parent_lookup_request(peer_id, request) {
|
||||
Ok(request_id) => {
|
||||
self.current_parent_request_id = Some(request_id);
|
||||
Ok(())
|
||||
|
||||
@@ -7,7 +7,6 @@ use super::range_sync::{BatchId, ByRangeRequestType, ChainId};
|
||||
use crate::beacon_processor::WorkEvent;
|
||||
use crate::service::{NetworkMessage, RequestId};
|
||||
use crate::status::ToStatusMessage;
|
||||
use crate::sync::block_lookups::ForceBlockRequest;
|
||||
use beacon_chain::blob_verification::BlockWrapper;
|
||||
use beacon_chain::{BeaconChain, BeaconChainTypes, EngineState};
|
||||
use fnv::FnvHashMap;
|
||||
@@ -453,13 +452,11 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
request: BlocksByRootRequest,
|
||||
force_block_request: ForceBlockRequest,
|
||||
) -> Result<Id, &'static str> {
|
||||
let request = if self
|
||||
.chain
|
||||
.is_data_availability_check_required()
|
||||
.map_err(|_| "Unable to read slot clock")?
|
||||
&& matches!(force_block_request, ForceBlockRequest::False)
|
||||
{
|
||||
trace!(
|
||||
self.log,
|
||||
|
||||
Reference in New Issue
Block a user