mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-04 21:34:36 +00:00
Nest lookup type into request id SingleBlock and SingleBlob (#5562)
* Nest lookup type into block lookup RequestId
This commit is contained in:
@@ -493,10 +493,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
|||||||
) {
|
) {
|
||||||
let request_id = match request_id {
|
let request_id = match request_id {
|
||||||
RequestId::Sync(sync_id) => match sync_id {
|
RequestId::Sync(sync_id) => match sync_id {
|
||||||
SyncId::SingleBlock { .. }
|
SyncId::SingleBlock { .. } | SyncId::SingleBlob { .. } => {
|
||||||
| SyncId::SingleBlob { .. }
|
|
||||||
| SyncId::ParentLookup { .. }
|
|
||||||
| SyncId::ParentLookupBlob { .. } => {
|
|
||||||
crit!(self.log, "Block lookups do not request BBRange requests"; "peer_id" => %peer_id);
|
crit!(self.log, "Block lookups do not request BBRange requests"; "peer_id" => %peer_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -561,7 +558,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
|||||||
) {
|
) {
|
||||||
let request_id = match request_id {
|
let request_id = match request_id {
|
||||||
RequestId::Sync(sync_id) => match sync_id {
|
RequestId::Sync(sync_id) => match sync_id {
|
||||||
id @ (SyncId::SingleBlock { .. } | SyncId::ParentLookup { .. }) => id,
|
id @ SyncId::SingleBlock { .. } => id,
|
||||||
SyncId::BackFillBlocks { .. }
|
SyncId::BackFillBlocks { .. }
|
||||||
| SyncId::RangeBlocks { .. }
|
| SyncId::RangeBlocks { .. }
|
||||||
| SyncId::RangeBlockAndBlobs { .. }
|
| SyncId::RangeBlockAndBlobs { .. }
|
||||||
@@ -569,7 +566,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
|||||||
crit!(self.log, "Batch syncing do not request BBRoot requests"; "peer_id" => %peer_id);
|
crit!(self.log, "Batch syncing do not request BBRoot requests"; "peer_id" => %peer_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SyncId::SingleBlob { .. } | SyncId::ParentLookupBlob { .. } => {
|
SyncId::SingleBlob { .. } => {
|
||||||
crit!(self.log, "Blob response to block by roots request"; "peer_id" => %peer_id);
|
crit!(self.log, "Blob response to block by roots request"; "peer_id" => %peer_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -602,8 +599,8 @@ impl<T: BeaconChainTypes> Router<T> {
|
|||||||
) {
|
) {
|
||||||
let request_id = match request_id {
|
let request_id = match request_id {
|
||||||
RequestId::Sync(sync_id) => match sync_id {
|
RequestId::Sync(sync_id) => match sync_id {
|
||||||
id @ (SyncId::SingleBlob { .. } | SyncId::ParentLookupBlob { .. }) => id,
|
id @ SyncId::SingleBlob { .. } => id,
|
||||||
SyncId::SingleBlock { .. } | SyncId::ParentLookup { .. } => {
|
SyncId::SingleBlock { .. } => {
|
||||||
crit!(self.log, "Block response to blobs by roots request"; "peer_id" => %peer_id);
|
crit!(self.log, "Block response to blobs by roots request"; "peer_id" => %peer_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ pub enum ResponseType {
|
|||||||
Blob,
|
Blob,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum LookupType {
|
pub enum LookupType {
|
||||||
Current,
|
Current,
|
||||||
Parent,
|
Parent,
|
||||||
@@ -119,6 +119,7 @@ pub trait RequestState<L: Lookup, T: BeaconChainTypes> {
|
|||||||
let id = SingleLookupReqId {
|
let id = SingleLookupReqId {
|
||||||
id,
|
id,
|
||||||
req_counter: self.get_state().req_counter,
|
req_counter: self.get_state().req_counter,
|
||||||
|
lookup_type: L::lookup_type(),
|
||||||
};
|
};
|
||||||
Self::make_request(id, peer_id, request, cx)
|
Self::make_request(id, peer_id, request, cx)
|
||||||
}
|
}
|
||||||
@@ -265,7 +266,7 @@ impl<L: Lookup, T: BeaconChainTypes> RequestState<L, T> for BlockRequestState<L>
|
|||||||
request: Self::RequestType,
|
request: Self::RequestType,
|
||||||
cx: &SyncNetworkContext<T>,
|
cx: &SyncNetworkContext<T>,
|
||||||
) -> Result<(), LookupRequestError> {
|
) -> Result<(), LookupRequestError> {
|
||||||
cx.block_lookup_request(id, peer_id, request, L::lookup_type())
|
cx.block_lookup_request(id, peer_id, request)
|
||||||
.map_err(LookupRequestError::SendFailed)
|
.map_err(LookupRequestError::SendFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,7 +366,7 @@ impl<L: Lookup, T: BeaconChainTypes> RequestState<L, T> for BlobRequestState<L,
|
|||||||
request: Self::RequestType,
|
request: Self::RequestType,
|
||||||
cx: &SyncNetworkContext<T>,
|
cx: &SyncNetworkContext<T>,
|
||||||
) -> Result<(), LookupRequestError> {
|
) -> Result<(), LookupRequestError> {
|
||||||
cx.blob_lookup_request(id, peer_id, request, L::lookup_type())
|
cx.blob_lookup_request(id, peer_id, request)
|
||||||
.map_err(LookupRequestError::SendFailed)
|
.map_err(LookupRequestError::SendFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -691,7 +691,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
|||||||
pub fn parent_lookup_failed<R: RequestState<Parent, T>>(
|
pub fn parent_lookup_failed<R: RequestState<Parent, T>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
id: SingleLookupReqId,
|
id: SingleLookupReqId,
|
||||||
peer_id: PeerId,
|
peer_id: &PeerId,
|
||||||
cx: &SyncNetworkContext<T>,
|
cx: &SyncNetworkContext<T>,
|
||||||
error: RPCError,
|
error: RPCError,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ impl TestRig {
|
|||||||
beacon_block: Option<Arc<SignedBeaconBlock<E>>>,
|
beacon_block: Option<Arc<SignedBeaconBlock<E>>>,
|
||||||
) {
|
) {
|
||||||
self.send_sync_message(SyncMessage::RpcBlock {
|
self.send_sync_message(SyncMessage::RpcBlock {
|
||||||
request_id: SyncRequestId::ParentLookup { id },
|
request_id: SyncRequestId::SingleBlock { id },
|
||||||
peer_id,
|
peer_id,
|
||||||
beacon_block,
|
beacon_block,
|
||||||
seen_timestamp: D,
|
seen_timestamp: D,
|
||||||
@@ -324,7 +324,7 @@ impl TestRig {
|
|||||||
blob_sidecar: Option<Arc<BlobSidecar<E>>>,
|
blob_sidecar: Option<Arc<BlobSidecar<E>>>,
|
||||||
) {
|
) {
|
||||||
self.send_sync_message(SyncMessage::RpcBlob {
|
self.send_sync_message(SyncMessage::RpcBlob {
|
||||||
request_id: SyncRequestId::ParentLookupBlob { id },
|
request_id: SyncRequestId::SingleBlob { id },
|
||||||
peer_id,
|
peer_id,
|
||||||
blob_sidecar,
|
blob_sidecar,
|
||||||
seen_timestamp: D,
|
seen_timestamp: D,
|
||||||
@@ -348,7 +348,7 @@ impl TestRig {
|
|||||||
fn parent_lookup_failed(&mut self, id: SingleLookupReqId, peer_id: PeerId, error: RPCError) {
|
fn parent_lookup_failed(&mut self, id: SingleLookupReqId, peer_id: PeerId, error: RPCError) {
|
||||||
self.send_sync_message(SyncMessage::RpcError {
|
self.send_sync_message(SyncMessage::RpcError {
|
||||||
peer_id,
|
peer_id,
|
||||||
request_id: SyncRequestId::ParentLookup { id },
|
request_id: SyncRequestId::SingleBlock { id },
|
||||||
error,
|
error,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -409,7 +409,11 @@ impl TestRig {
|
|||||||
peer_id: _,
|
peer_id: _,
|
||||||
request: Request::BlocksByRoot(request),
|
request: Request::BlocksByRoot(request),
|
||||||
request_id: RequestId::Sync(SyncRequestId::SingleBlock { id }),
|
request_id: RequestId::Sync(SyncRequestId::SingleBlock { id }),
|
||||||
} if request.block_roots().to_vec().contains(&for_block) => Some(*id),
|
} if id.lookup_type == LookupType::Current
|
||||||
|
&& request.block_roots().to_vec().contains(&for_block) =>
|
||||||
|
{
|
||||||
|
Some(*id)
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|e| panic!("Expected block request for {for_block:?}: {e}"))
|
.unwrap_or_else(|e| panic!("Expected block request for {for_block:?}: {e}"))
|
||||||
@@ -422,7 +426,8 @@ impl TestRig {
|
|||||||
peer_id: _,
|
peer_id: _,
|
||||||
request: Request::BlobsByRoot(request),
|
request: Request::BlobsByRoot(request),
|
||||||
request_id: RequestId::Sync(SyncRequestId::SingleBlob { id }),
|
request_id: RequestId::Sync(SyncRequestId::SingleBlob { id }),
|
||||||
} if request
|
} if id.lookup_type == LookupType::Current
|
||||||
|
&& request
|
||||||
.blob_ids
|
.blob_ids
|
||||||
.to_vec()
|
.to_vec()
|
||||||
.iter()
|
.iter()
|
||||||
@@ -441,8 +446,12 @@ impl TestRig {
|
|||||||
NetworkMessage::SendRequest {
|
NetworkMessage::SendRequest {
|
||||||
peer_id: _,
|
peer_id: _,
|
||||||
request: Request::BlocksByRoot(request),
|
request: Request::BlocksByRoot(request),
|
||||||
request_id: RequestId::Sync(SyncRequestId::ParentLookup { id }),
|
request_id: RequestId::Sync(SyncRequestId::SingleBlock { id }),
|
||||||
} if request.block_roots().to_vec().contains(&for_block) => Some(*id),
|
} if id.lookup_type == LookupType::Parent
|
||||||
|
&& request.block_roots().to_vec().contains(&for_block) =>
|
||||||
|
{
|
||||||
|
Some(*id)
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|e| panic!("Expected block parent request for {for_block:?}: {e}"))
|
.unwrap_or_else(|e| panic!("Expected block parent request for {for_block:?}: {e}"))
|
||||||
@@ -454,8 +463,9 @@ impl TestRig {
|
|||||||
NetworkMessage::SendRequest {
|
NetworkMessage::SendRequest {
|
||||||
peer_id: _,
|
peer_id: _,
|
||||||
request: Request::BlobsByRoot(request),
|
request: Request::BlobsByRoot(request),
|
||||||
request_id: RequestId::Sync(SyncRequestId::ParentLookupBlob { id }),
|
request_id: RequestId::Sync(SyncRequestId::SingleBlob { id }),
|
||||||
} if request
|
} if id.lookup_type == LookupType::Parent
|
||||||
|
&& request
|
||||||
.blob_ids
|
.blob_ids
|
||||||
.to_vec()
|
.to_vec()
|
||||||
.iter()
|
.iter()
|
||||||
@@ -1974,7 +1984,7 @@ mod deneb_only {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let (block, blobs) = r.rand_block_and_blobs(NumBlobs::Number(2));
|
let (block, blobs) = r.rand_block_and_blobs(NumBlobs::Number(2));
|
||||||
let parent_root = block.parent_root();
|
let block_root = block.canonical_root();
|
||||||
let blob_0 = blobs[0].clone();
|
let blob_0 = blobs[0].clone();
|
||||||
let blob_1 = blobs[1].clone();
|
let blob_1 = blobs[1].clone();
|
||||||
let peer_a = r.new_connected_peer();
|
let peer_a = r.new_connected_peer();
|
||||||
@@ -1982,7 +1992,7 @@ mod deneb_only {
|
|||||||
// Send unknown parent block lookup
|
// Send unknown parent block lookup
|
||||||
r.trigger_unknown_parent_block(peer_a, block.into());
|
r.trigger_unknown_parent_block(peer_a, block.into());
|
||||||
// Expect network request for blobs
|
// Expect network request for blobs
|
||||||
let id = r.expect_blob_parent_request(parent_root);
|
let id = r.expect_blob_lookup_request(block_root);
|
||||||
// Peer responses with blob 0
|
// Peer responses with blob 0
|
||||||
r.single_lookup_blob_response(id, peer_a, Some(blob_0.into()));
|
r.single_lookup_blob_response(id, peer_a, Some(blob_0.into()));
|
||||||
// Blob 1 is received via gossip unknown parent blob from a different peer
|
// Blob 1 is received via gossip unknown parent blob from a different peer
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
//! search for the block and subsequently search for parents if needed.
|
//! search for the block and subsequently search for parents if needed.
|
||||||
|
|
||||||
use super::backfill_sync::{BackFillSync, ProcessResult, SyncStart};
|
use super::backfill_sync::{BackFillSync, ProcessResult, SyncStart};
|
||||||
|
use super::block_lookups::common::LookupType;
|
||||||
use super::block_lookups::BlockLookups;
|
use super::block_lookups::BlockLookups;
|
||||||
use super::network_context::{BlockOrBlob, SyncNetworkContext};
|
use super::network_context::{BlockOrBlob, SyncNetworkContext};
|
||||||
use super::peer_sync_info::{remote_sync_type, PeerSyncType};
|
use super::peer_sync_info::{remote_sync_type, PeerSyncType};
|
||||||
@@ -80,6 +81,7 @@ pub type Id = u32;
|
|||||||
pub struct SingleLookupReqId {
|
pub struct SingleLookupReqId {
|
||||||
pub id: Id,
|
pub id: Id,
|
||||||
pub req_counter: Id,
|
pub req_counter: Id,
|
||||||
|
pub lookup_type: LookupType,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Id of rpc requests sent by sync to the network.
|
/// Id of rpc requests sent by sync to the network.
|
||||||
@@ -89,12 +91,6 @@ pub enum RequestId {
|
|||||||
SingleBlock { id: SingleLookupReqId },
|
SingleBlock { id: SingleLookupReqId },
|
||||||
/// Request searching for a set of blobs given a hash.
|
/// Request searching for a set of blobs given a hash.
|
||||||
SingleBlob { id: SingleLookupReqId },
|
SingleBlob { id: SingleLookupReqId },
|
||||||
/// Request searching for a block's parent. The id is the chain, share with the corresponding
|
|
||||||
/// blob id.
|
|
||||||
ParentLookup { id: SingleLookupReqId },
|
|
||||||
/// Request searching for a block's parent blobs. The id is the chain, shared with the corresponding
|
|
||||||
/// block id.
|
|
||||||
ParentLookupBlob { id: SingleLookupReqId },
|
|
||||||
/// Request was from the backfill sync algorithm.
|
/// Request was from the backfill sync algorithm.
|
||||||
BackFillBlocks { id: Id },
|
BackFillBlocks { id: Id },
|
||||||
/// Backfill request that is composed by both a block range request and a blob range request.
|
/// Backfill request that is composed by both a block range request and a blob range request.
|
||||||
@@ -331,42 +327,42 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
|||||||
fn inject_error(&mut self, peer_id: PeerId, request_id: RequestId, error: RPCError) {
|
fn inject_error(&mut self, peer_id: PeerId, request_id: RequestId, error: RPCError) {
|
||||||
trace!(self.log, "Sync manager received a failed RPC");
|
trace!(self.log, "Sync manager received a failed RPC");
|
||||||
match request_id {
|
match request_id {
|
||||||
RequestId::SingleBlock { id } => {
|
RequestId::SingleBlock { id } => match id.lookup_type {
|
||||||
self.block_lookups
|
LookupType::Current => self
|
||||||
|
.block_lookups
|
||||||
.single_block_lookup_failed::<BlockRequestState<Current>>(
|
.single_block_lookup_failed::<BlockRequestState<Current>>(
|
||||||
id,
|
id,
|
||||||
&peer_id,
|
&peer_id,
|
||||||
&self.network,
|
&self.network,
|
||||||
error,
|
error,
|
||||||
);
|
),
|
||||||
}
|
LookupType::Parent => self
|
||||||
RequestId::SingleBlob { id } => {
|
.block_lookups
|
||||||
self.block_lookups
|
.parent_lookup_failed::<BlockRequestState<Parent>>(
|
||||||
|
id,
|
||||||
|
&peer_id,
|
||||||
|
&self.network,
|
||||||
|
error,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
RequestId::SingleBlob { id } => match id.lookup_type {
|
||||||
|
LookupType::Current => self
|
||||||
|
.block_lookups
|
||||||
.single_block_lookup_failed::<BlobRequestState<Current, T::EthSpec>>(
|
.single_block_lookup_failed::<BlobRequestState<Current, T::EthSpec>>(
|
||||||
id,
|
id,
|
||||||
&peer_id,
|
&peer_id,
|
||||||
&self.network,
|
&self.network,
|
||||||
error,
|
error,
|
||||||
);
|
),
|
||||||
}
|
LookupType::Parent => self
|
||||||
RequestId::ParentLookup { id } => {
|
.block_lookups
|
||||||
self.block_lookups
|
|
||||||
.parent_lookup_failed::<BlockRequestState<Parent>>(
|
|
||||||
id,
|
|
||||||
peer_id,
|
|
||||||
&self.network,
|
|
||||||
error,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
RequestId::ParentLookupBlob { id } => {
|
|
||||||
self.block_lookups
|
|
||||||
.parent_lookup_failed::<BlobRequestState<Parent, T::EthSpec>>(
|
.parent_lookup_failed::<BlobRequestState<Parent, T::EthSpec>>(
|
||||||
id,
|
id,
|
||||||
peer_id,
|
&peer_id,
|
||||||
&self.network,
|
&self.network,
|
||||||
error,
|
error,
|
||||||
);
|
),
|
||||||
}
|
},
|
||||||
RequestId::BackFillBlocks { id } => {
|
RequestId::BackFillBlocks { id } => {
|
||||||
if let Some(batch_id) = self
|
if let Some(batch_id) = self
|
||||||
.network
|
.network
|
||||||
@@ -882,7 +878,8 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
|||||||
seen_timestamp: Duration,
|
seen_timestamp: Duration,
|
||||||
) {
|
) {
|
||||||
match request_id {
|
match request_id {
|
||||||
RequestId::SingleBlock { id } => self
|
RequestId::SingleBlock { id } => match id.lookup_type {
|
||||||
|
LookupType::Current => self
|
||||||
.block_lookups
|
.block_lookups
|
||||||
.single_lookup_response::<BlockRequestState<Current>>(
|
.single_lookup_response::<BlockRequestState<Current>>(
|
||||||
id,
|
id,
|
||||||
@@ -891,10 +888,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
|||||||
seen_timestamp,
|
seen_timestamp,
|
||||||
&self.network,
|
&self.network,
|
||||||
),
|
),
|
||||||
RequestId::SingleBlob { .. } => {
|
LookupType::Parent => self
|
||||||
crit!(self.log, "Block received during blob request"; "peer_id" => %peer_id );
|
|
||||||
}
|
|
||||||
RequestId::ParentLookup { id } => self
|
|
||||||
.block_lookups
|
.block_lookups
|
||||||
.parent_lookup_response::<BlockRequestState<Parent>>(
|
.parent_lookup_response::<BlockRequestState<Parent>>(
|
||||||
id,
|
id,
|
||||||
@@ -903,8 +897,9 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
|||||||
seen_timestamp,
|
seen_timestamp,
|
||||||
&self.network,
|
&self.network,
|
||||||
),
|
),
|
||||||
RequestId::ParentLookupBlob { id: _ } => {
|
},
|
||||||
crit!(self.log, "Block received during parent blob request"; "peer_id" => %peer_id );
|
RequestId::SingleBlob { .. } => {
|
||||||
|
crit!(self.log, "Block received during blob request"; "peer_id" => %peer_id );
|
||||||
}
|
}
|
||||||
RequestId::BackFillBlocks { id } => {
|
RequestId::BackFillBlocks { id } => {
|
||||||
let is_stream_terminator = block.is_none();
|
let is_stream_terminator = block.is_none();
|
||||||
@@ -966,7 +961,8 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
|||||||
RequestId::SingleBlock { .. } => {
|
RequestId::SingleBlock { .. } => {
|
||||||
crit!(self.log, "Single blob received during block request"; "peer_id" => %peer_id );
|
crit!(self.log, "Single blob received during block request"; "peer_id" => %peer_id );
|
||||||
}
|
}
|
||||||
RequestId::SingleBlob { id } => self
|
RequestId::SingleBlob { id } => match id.lookup_type {
|
||||||
|
LookupType::Current => self
|
||||||
.block_lookups
|
.block_lookups
|
||||||
.single_lookup_response::<BlobRequestState<Current, T::EthSpec>>(
|
.single_lookup_response::<BlobRequestState<Current, T::EthSpec>>(
|
||||||
id,
|
id,
|
||||||
@@ -975,11 +971,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
|||||||
seen_timestamp,
|
seen_timestamp,
|
||||||
&self.network,
|
&self.network,
|
||||||
),
|
),
|
||||||
|
LookupType::Parent => self
|
||||||
RequestId::ParentLookup { id: _ } => {
|
|
||||||
crit!(self.log, "Single blob received during parent block request"; "peer_id" => %peer_id );
|
|
||||||
}
|
|
||||||
RequestId::ParentLookupBlob { id } => self
|
|
||||||
.block_lookups
|
.block_lookups
|
||||||
.parent_lookup_response::<BlobRequestState<Parent, T::EthSpec>>(
|
.parent_lookup_response::<BlobRequestState<Parent, T::EthSpec>>(
|
||||||
id,
|
id,
|
||||||
@@ -988,6 +980,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
|||||||
seen_timestamp,
|
seen_timestamp,
|
||||||
&self.network,
|
&self.network,
|
||||||
),
|
),
|
||||||
|
},
|
||||||
RequestId::BackFillBlocks { id: _ } => {
|
RequestId::BackFillBlocks { id: _ } => {
|
||||||
crit!(self.log, "Blob received during backfill block request"; "peer_id" => %peer_id );
|
crit!(self.log, "Blob received during backfill block request"; "peer_id" => %peer_id );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use super::range_sync::{BatchId, ByRangeRequestType, ChainId};
|
|||||||
use crate::network_beacon_processor::NetworkBeaconProcessor;
|
use crate::network_beacon_processor::NetworkBeaconProcessor;
|
||||||
use crate::service::{NetworkMessage, RequestId};
|
use crate::service::{NetworkMessage, RequestId};
|
||||||
use crate::status::ToStatusMessage;
|
use crate::status::ToStatusMessage;
|
||||||
use crate::sync::block_lookups::common::LookupType;
|
|
||||||
use crate::sync::manager::SingleLookupReqId;
|
use crate::sync::manager::SingleLookupReqId;
|
||||||
use beacon_chain::block_verification_types::RpcBlock;
|
use beacon_chain::block_verification_types::RpcBlock;
|
||||||
use beacon_chain::{BeaconChain, BeaconChainTypes, EngineState};
|
use beacon_chain::{BeaconChain, BeaconChainTypes, EngineState};
|
||||||
@@ -437,27 +436,20 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
|||||||
id: SingleLookupReqId,
|
id: SingleLookupReqId,
|
||||||
peer_id: PeerId,
|
peer_id: PeerId,
|
||||||
request: BlocksByRootRequest,
|
request: BlocksByRootRequest,
|
||||||
lookup_type: LookupType,
|
|
||||||
) -> Result<(), &'static str> {
|
) -> Result<(), &'static str> {
|
||||||
let sync_id = match lookup_type {
|
|
||||||
LookupType::Current => SyncRequestId::SingleBlock { id },
|
|
||||||
LookupType::Parent => SyncRequestId::ParentLookup { id },
|
|
||||||
};
|
|
||||||
let request_id = RequestId::Sync(sync_id);
|
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
self.log,
|
self.log,
|
||||||
"Sending BlocksByRoot Request";
|
"Sending BlocksByRoot Request";
|
||||||
"method" => "BlocksByRoot",
|
"method" => "BlocksByRoot",
|
||||||
"block_roots" => ?request.block_roots().to_vec(),
|
"block_roots" => ?request.block_roots().to_vec(),
|
||||||
"peer" => %peer_id,
|
"peer" => %peer_id,
|
||||||
"lookup_type" => ?lookup_type
|
"id" => ?id
|
||||||
);
|
);
|
||||||
|
|
||||||
self.send_network_msg(NetworkMessage::SendRequest {
|
self.send_network_msg(NetworkMessage::SendRequest {
|
||||||
peer_id,
|
peer_id,
|
||||||
request: Request::BlocksByRoot(request),
|
request: Request::BlocksByRoot(request),
|
||||||
request_id,
|
request_id: RequestId::Sync(SyncRequestId::SingleBlock { id }),
|
||||||
})?;
|
})?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -467,14 +459,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
|||||||
id: SingleLookupReqId,
|
id: SingleLookupReqId,
|
||||||
blob_peer_id: PeerId,
|
blob_peer_id: PeerId,
|
||||||
blob_request: BlobsByRootRequest,
|
blob_request: BlobsByRootRequest,
|
||||||
lookup_type: LookupType,
|
|
||||||
) -> Result<(), &'static str> {
|
) -> Result<(), &'static str> {
|
||||||
let sync_id = match lookup_type {
|
|
||||||
LookupType::Current => SyncRequestId::SingleBlob { id },
|
|
||||||
LookupType::Parent => SyncRequestId::ParentLookupBlob { id },
|
|
||||||
};
|
|
||||||
let request_id = RequestId::Sync(sync_id);
|
|
||||||
|
|
||||||
if let Some(block_root) = blob_request
|
if let Some(block_root) = blob_request
|
||||||
.blob_ids
|
.blob_ids
|
||||||
.as_slice()
|
.as_slice()
|
||||||
@@ -494,13 +479,13 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
|||||||
"block_root" => ?block_root,
|
"block_root" => ?block_root,
|
||||||
"blob_indices" => ?indices,
|
"blob_indices" => ?indices,
|
||||||
"peer" => %blob_peer_id,
|
"peer" => %blob_peer_id,
|
||||||
"lookup_type" => ?lookup_type
|
"id" => ?id
|
||||||
);
|
);
|
||||||
|
|
||||||
self.send_network_msg(NetworkMessage::SendRequest {
|
self.send_network_msg(NetworkMessage::SendRequest {
|
||||||
peer_id: blob_peer_id,
|
peer_id: blob_peer_id,
|
||||||
request: Request::BlobsByRoot(blob_request),
|
request: Request::BlobsByRoot(blob_request),
|
||||||
request_id,
|
request_id: RequestId::Sync(SyncRequestId::SingleBlob { id }),
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user