mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-29 19:04:27 +00:00
Remove generic Id param from RequestId (#6032)
* rename RequestId's for better context, and move them to lighthouse_network crate. * remove unrequired generic AppReqId from RequestID
This commit is contained in:
@@ -7,9 +7,8 @@
|
||||
|
||||
use crate::error;
|
||||
use crate::network_beacon_processor::{InvalidBlockStorage, NetworkBeaconProcessor};
|
||||
use crate::service::{NetworkMessage, RequestId};
|
||||
use crate::service::NetworkMessage;
|
||||
use crate::status::status_message;
|
||||
use crate::sync::manager::RequestId as SyncId;
|
||||
use crate::sync::SyncMessage;
|
||||
use beacon_chain::{BeaconChain, BeaconChainTypes};
|
||||
use beacon_processor::{
|
||||
@@ -18,6 +17,7 @@ use beacon_processor::{
|
||||
use futures::prelude::*;
|
||||
use lighthouse_network::rpc::*;
|
||||
use lighthouse_network::{
|
||||
service::api_types::{AppRequestId, SyncRequestId},
|
||||
MessageId, NetworkGlobals, PeerId, PeerRequestId, PubsubMessage, Request, Response,
|
||||
};
|
||||
use logging::TimeLatch;
|
||||
@@ -61,13 +61,13 @@ pub enum RouterMessage<E: EthSpec> {
|
||||
/// An RPC response has been received.
|
||||
RPCResponseReceived {
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
response: Response<E>,
|
||||
},
|
||||
/// An RPC request failed
|
||||
RPCFailed {
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
error: RPCError,
|
||||
},
|
||||
/// A gossip message has been received. The fields are: message id, the peer that sent us this
|
||||
@@ -235,7 +235,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
fn handle_rpc_response(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
response: Response<T::EthSpec>,
|
||||
) {
|
||||
match response {
|
||||
@@ -448,9 +448,9 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
|
||||
/// An error occurred during an RPC request. The state is maintained by the sync manager, so
|
||||
/// this function notifies the sync manager of the error.
|
||||
pub fn on_rpc_error(&mut self, peer_id: PeerId, request_id: RequestId, error: RPCError) {
|
||||
pub fn on_rpc_error(&mut self, peer_id: PeerId, request_id: AppRequestId, error: RPCError) {
|
||||
// Check if the failed RPC belongs to sync
|
||||
if let RequestId::Sync(request_id) = request_id {
|
||||
if let AppRequestId::Sync(request_id) = request_id {
|
||||
self.send_to_sync(SyncMessage::RpcError {
|
||||
peer_id,
|
||||
request_id,
|
||||
@@ -488,18 +488,18 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
pub fn on_blocks_by_range_response(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
beacon_block: Option<Arc<SignedBeaconBlock<T::EthSpec>>>,
|
||||
) {
|
||||
let request_id = match request_id {
|
||||
RequestId::Sync(sync_id) => match sync_id {
|
||||
SyncId::SingleBlock { .. } | SyncId::SingleBlob { .. } => {
|
||||
AppRequestId::Sync(sync_id) => match sync_id {
|
||||
SyncRequestId::SingleBlock { .. } | SyncRequestId::SingleBlob { .. } => {
|
||||
crit!(self.log, "Block lookups do not request BBRange requests"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
id @ SyncId::RangeBlockAndBlobs { .. } => id,
|
||||
id @ SyncRequestId::RangeBlockAndBlobs { .. } => id,
|
||||
},
|
||||
RequestId::Router => {
|
||||
AppRequestId::Router => {
|
||||
crit!(self.log, "All BBRange requests belong to sync"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
@@ -522,7 +522,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
pub fn on_blobs_by_range_response(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
blob_sidecar: Option<Arc<BlobSidecar<T::EthSpec>>>,
|
||||
) {
|
||||
trace!(
|
||||
@@ -531,7 +531,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
"peer" => %peer_id,
|
||||
);
|
||||
|
||||
if let RequestId::Sync(id) = request_id {
|
||||
if let AppRequestId::Sync(id) = request_id {
|
||||
self.send_to_sync(SyncMessage::RpcBlob {
|
||||
peer_id,
|
||||
request_id: id,
|
||||
@@ -550,22 +550,22 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
pub fn on_blocks_by_root_response(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
beacon_block: Option<Arc<SignedBeaconBlock<T::EthSpec>>>,
|
||||
) {
|
||||
let request_id = match request_id {
|
||||
RequestId::Sync(sync_id) => match sync_id {
|
||||
id @ SyncId::SingleBlock { .. } => id,
|
||||
SyncId::RangeBlockAndBlobs { .. } => {
|
||||
AppRequestId::Sync(sync_id) => match sync_id {
|
||||
id @ SyncRequestId::SingleBlock { .. } => id,
|
||||
SyncRequestId::RangeBlockAndBlobs { .. } => {
|
||||
crit!(self.log, "Batch syncing do not request BBRoot requests"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
SyncId::SingleBlob { .. } => {
|
||||
SyncRequestId::SingleBlob { .. } => {
|
||||
crit!(self.log, "Blob response to block by roots request"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
},
|
||||
RequestId::Router => {
|
||||
AppRequestId::Router => {
|
||||
crit!(self.log, "All BBRoot requests belong to sync"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
@@ -588,22 +588,22 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
pub fn on_blobs_by_root_response(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
blob_sidecar: Option<Arc<BlobSidecar<T::EthSpec>>>,
|
||||
) {
|
||||
let request_id = match request_id {
|
||||
RequestId::Sync(sync_id) => match sync_id {
|
||||
id @ SyncId::SingleBlob { .. } => id,
|
||||
SyncId::SingleBlock { .. } => {
|
||||
AppRequestId::Sync(sync_id) => match sync_id {
|
||||
id @ SyncRequestId::SingleBlob { .. } => id,
|
||||
SyncRequestId::SingleBlock { .. } => {
|
||||
crit!(self.log, "Block response to blobs by roots request"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
SyncId::RangeBlockAndBlobs { .. } => {
|
||||
SyncRequestId::RangeBlockAndBlobs { .. } => {
|
||||
crit!(self.log, "Batch syncing does not request BBRoot requests"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
},
|
||||
RequestId::Router => {
|
||||
AppRequestId::Router => {
|
||||
crit!(self.log, "All BlobsByRoot requests belong to sync"; "peer_id" => %peer_id);
|
||||
return;
|
||||
}
|
||||
@@ -667,7 +667,7 @@ impl<E: EthSpec> HandlerNetworkContext<E> {
|
||||
pub fn send_processor_request(&mut self, peer_id: PeerId, request: Request) {
|
||||
self.inform_network(NetworkMessage::SendRequest {
|
||||
peer_id,
|
||||
request_id: RequestId::Router,
|
||||
request_id: AppRequestId::Router,
|
||||
request,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use super::sync::manager::RequestId as SyncId;
|
||||
use crate::nat;
|
||||
use crate::network_beacon_processor::InvalidBlockStorage;
|
||||
use crate::persisted_dht::{clear_dht, load_dht, persist_dht};
|
||||
@@ -23,6 +22,7 @@ use lighthouse_network::{
|
||||
Context, PeerAction, PeerRequestId, PubsubMessage, ReportSource, Request, Response, Subnet,
|
||||
};
|
||||
use lighthouse_network::{
|
||||
service::api_types::AppRequestId,
|
||||
types::{core_topics_to_subscribe, GossipEncoding, GossipTopic},
|
||||
MessageId, NetworkEvent, NetworkGlobals, PeerId,
|
||||
};
|
||||
@@ -51,13 +51,6 @@ const UNSUBSCRIBE_DELAY_EPOCHS: u64 = 2;
|
||||
/// able to run tens of thousands of validators on one BN.
|
||||
const VALIDATOR_SUBSCRIPTION_MESSAGE_QUEUE_SIZE: usize = 65_536;
|
||||
|
||||
/// Application level requests sent to the network.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum RequestId {
|
||||
Sync(SyncId),
|
||||
Router,
|
||||
}
|
||||
|
||||
/// Types of messages that the network service can receive.
|
||||
#[derive(Debug, IntoStaticStr)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
@@ -69,7 +62,7 @@ pub enum NetworkMessage<E: EthSpec> {
|
||||
SendRequest {
|
||||
peer_id: PeerId,
|
||||
request: Request,
|
||||
request_id: RequestId,
|
||||
request_id: AppRequestId,
|
||||
},
|
||||
/// Send a successful Response to the libp2p service.
|
||||
SendResponse {
|
||||
@@ -168,7 +161,7 @@ pub struct NetworkService<T: BeaconChainTypes> {
|
||||
/// A reference to the underlying beacon chain.
|
||||
beacon_chain: Arc<BeaconChain<T>>,
|
||||
/// The underlying libp2p service that drives all the network interactions.
|
||||
libp2p: Network<RequestId, T::EthSpec>,
|
||||
libp2p: Network<T::EthSpec>,
|
||||
/// An attestation and subnet manager service.
|
||||
attestation_service: AttestationService<T>,
|
||||
/// A sync committeee subnet manager service.
|
||||
@@ -499,7 +492,7 @@ impl<T: BeaconChainTypes> NetworkService<T> {
|
||||
/// Handle an event received from the network.
|
||||
async fn on_libp2p_event(
|
||||
&mut self,
|
||||
ev: NetworkEvent<RequestId, T::EthSpec>,
|
||||
ev: NetworkEvent<T::EthSpec>,
|
||||
shutdown_sender: &mut Sender<ShutdownReason>,
|
||||
) {
|
||||
match ev {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//! sync as failed, log an error and attempt to retry once a new peer joins the node.
|
||||
|
||||
use crate::network_beacon_processor::ChainSegmentProcessId;
|
||||
use crate::sync::manager::{BatchProcessResult, Id};
|
||||
use crate::sync::manager::BatchProcessResult;
|
||||
use crate::sync::network_context::RangeRequestId;
|
||||
use crate::sync::network_context::SyncNetworkContext;
|
||||
use crate::sync::range_sync::{
|
||||
@@ -17,6 +17,7 @@ use crate::sync::range_sync::{
|
||||
};
|
||||
use beacon_chain::block_verification_types::RpcBlock;
|
||||
use beacon_chain::{BeaconChain, BeaconChainTypes};
|
||||
use lighthouse_network::service::api_types::Id;
|
||||
use lighthouse_network::types::{BackFillState, NetworkGlobals};
|
||||
use lighthouse_network::{PeerAction, PeerId};
|
||||
use rand::seq::SliceRandom;
|
||||
|
||||
@@ -2,10 +2,10 @@ use crate::sync::block_lookups::single_block_lookup::{
|
||||
LookupRequestError, SingleBlockLookup, SingleLookupRequestState,
|
||||
};
|
||||
use crate::sync::block_lookups::{BlobRequestState, BlockRequestState, PeerId};
|
||||
use crate::sync::manager::Id;
|
||||
use crate::sync::network_context::{LookupRequestResult, SyncNetworkContext};
|
||||
use beacon_chain::block_verification_types::RpcBlock;
|
||||
use beacon_chain::BeaconChainTypes;
|
||||
use lighthouse_network::service::api_types::Id;
|
||||
use std::sync::Arc;
|
||||
use types::blob_sidecar::FixedBlobSidecarList;
|
||||
use types::SignedBeaconBlock;
|
||||
|
||||
@@ -28,12 +28,12 @@ use super::network_context::{RpcResponseResult, SyncNetworkContext};
|
||||
use crate::metrics;
|
||||
use crate::sync::block_lookups::common::ResponseType;
|
||||
use crate::sync::block_lookups::parent_chain::find_oldest_fork_ancestor;
|
||||
use crate::sync::manager::{Id, SingleLookupReqId};
|
||||
use beacon_chain::block_verification_types::AsBlock;
|
||||
use beacon_chain::data_availability_checker::AvailabilityCheckErrorCategory;
|
||||
use beacon_chain::{AvailabilityProcessingStatus, BeaconChainTypes, BlockError};
|
||||
pub use common::RequestState;
|
||||
use fnv::FnvHashMap;
|
||||
use lighthouse_network::service::api_types::SingleLookupReqId;
|
||||
use lighthouse_network::{PeerAction, PeerId};
|
||||
use lru_cache::LRUTimeCache;
|
||||
pub use single_block_lookup::{BlobRequestState, BlockRequestState};
|
||||
@@ -107,6 +107,9 @@ pub struct BlockLookups<T: BeaconChainTypes> {
|
||||
log: Logger,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
use lighthouse_network::service::api_types::Id;
|
||||
|
||||
#[cfg(test)]
|
||||
/// Tuple of `SingleLookupId`, requested block root, awaiting parent block root (if any),
|
||||
/// and list of peers that claim to have imported this set of block components.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use super::common::ResponseType;
|
||||
use super::{BlockComponent, PeerId, SINGLE_BLOCK_LOOKUP_MAX_ATTEMPTS};
|
||||
use crate::sync::block_lookups::common::RequestState;
|
||||
use crate::sync::block_lookups::Id;
|
||||
use crate::sync::network_context::{
|
||||
LookupRequestResult, ReqId, RpcRequestSendError, SendErrorProcessor, SyncNetworkContext,
|
||||
};
|
||||
use beacon_chain::BeaconChainTypes;
|
||||
use derivative::Derivative;
|
||||
use lighthouse_network::service::api_types::Id;
|
||||
use rand::seq::IteratorRandom;
|
||||
use std::collections::HashSet;
|
||||
use std::fmt::Debug;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
use crate::network_beacon_processor::NetworkBeaconProcessor;
|
||||
|
||||
use crate::service::RequestId;
|
||||
use crate::sync::manager::{
|
||||
BlockProcessType, RequestId as SyncRequestId, SingleLookupReqId, SyncManager,
|
||||
};
|
||||
use crate::sync::manager::{BlockProcessType, SyncManager};
|
||||
use crate::sync::SyncMessage;
|
||||
use crate::NetworkMessage;
|
||||
use std::sync::Arc;
|
||||
@@ -24,6 +21,7 @@ use beacon_chain::{
|
||||
};
|
||||
use beacon_processor::WorkEvent;
|
||||
use lighthouse_network::rpc::{RPCError, RPCResponseErrorCode};
|
||||
use lighthouse_network::service::api_types::{AppRequestId, Id, SingleLookupReqId, SyncRequestId};
|
||||
use lighthouse_network::types::SyncState;
|
||||
use lighthouse_network::{NetworkGlobals, Request};
|
||||
use slog::info;
|
||||
@@ -550,7 +548,7 @@ impl TestRig {
|
||||
while let Ok(request_id) = self.pop_received_network_event(|ev| match ev {
|
||||
NetworkMessage::SendRequest {
|
||||
peer_id,
|
||||
request_id: RequestId::Sync(id),
|
||||
request_id: AppRequestId::Sync(id),
|
||||
..
|
||||
} if *peer_id == disconnected_peer_id => Some(*id),
|
||||
_ => None,
|
||||
@@ -631,7 +629,7 @@ impl TestRig {
|
||||
NetworkMessage::SendRequest {
|
||||
peer_id: _,
|
||||
request: Request::BlocksByRoot(request),
|
||||
request_id: RequestId::Sync(SyncRequestId::SingleBlock { id }),
|
||||
request_id: AppRequestId::Sync(SyncRequestId::SingleBlock { id }),
|
||||
} if request.block_roots().to_vec().contains(&for_block) => Some(*id),
|
||||
_ => None,
|
||||
})
|
||||
@@ -651,7 +649,7 @@ impl TestRig {
|
||||
NetworkMessage::SendRequest {
|
||||
peer_id: _,
|
||||
request: Request::BlobsByRoot(request),
|
||||
request_id: RequestId::Sync(SyncRequestId::SingleBlob { id }),
|
||||
request_id: AppRequestId::Sync(SyncRequestId::SingleBlob { id }),
|
||||
} if request
|
||||
.blob_ids
|
||||
.to_vec()
|
||||
@@ -676,7 +674,7 @@ impl TestRig {
|
||||
NetworkMessage::SendRequest {
|
||||
peer_id: _,
|
||||
request: Request::BlocksByRoot(request),
|
||||
request_id: RequestId::Sync(SyncRequestId::SingleBlock { id }),
|
||||
request_id: AppRequestId::Sync(SyncRequestId::SingleBlock { id }),
|
||||
} if request.block_roots().to_vec().contains(&for_block) => Some(*id),
|
||||
_ => None,
|
||||
})
|
||||
@@ -698,7 +696,7 @@ impl TestRig {
|
||||
NetworkMessage::SendRequest {
|
||||
peer_id: _,
|
||||
request: Request::BlobsByRoot(request),
|
||||
request_id: RequestId::Sync(SyncRequestId::SingleBlob { id }),
|
||||
request_id: AppRequestId::Sync(SyncRequestId::SingleBlob { id }),
|
||||
} if request
|
||||
.blob_ids
|
||||
.to_vec()
|
||||
|
||||
@@ -53,6 +53,7 @@ use beacon_chain::{
|
||||
};
|
||||
use futures::StreamExt;
|
||||
use lighthouse_network::rpc::RPCError;
|
||||
use lighthouse_network::service::api_types::{Id, SingleLookupReqId, SyncRequestId};
|
||||
use lighthouse_network::types::{NetworkGlobals, SyncState};
|
||||
use lighthouse_network::SyncInfo;
|
||||
use lighthouse_network::{PeerAction, PeerId};
|
||||
@@ -78,25 +79,6 @@ pub const SLOT_IMPORT_TOLERANCE: usize = 32;
|
||||
/// arbitrary number that covers a full slot, but allows recovery if sync get stuck for a few slots.
|
||||
const NOTIFIED_UNKNOWN_ROOT_EXPIRY_SECONDS: u64 = 30;
|
||||
|
||||
pub type Id = u32;
|
||||
|
||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
||||
pub struct SingleLookupReqId {
|
||||
pub lookup_id: Id,
|
||||
pub req_id: Id,
|
||||
}
|
||||
|
||||
/// Id of rpc requests sent by sync to the network.
|
||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum RequestId {
|
||||
/// Request searching for a block given a hash.
|
||||
SingleBlock { id: SingleLookupReqId },
|
||||
/// Request searching for a set of blobs given a hash.
|
||||
SingleBlob { id: SingleLookupReqId },
|
||||
/// Range request that is composed by both a block range request and a blob range request.
|
||||
RangeBlockAndBlobs { id: Id },
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
/// A message that can be sent to the sync manager thread.
|
||||
pub enum SyncMessage<E: EthSpec> {
|
||||
@@ -105,7 +87,7 @@ pub enum SyncMessage<E: EthSpec> {
|
||||
|
||||
/// A block has been received from the RPC.
|
||||
RpcBlock {
|
||||
request_id: RequestId,
|
||||
request_id: SyncRequestId,
|
||||
peer_id: PeerId,
|
||||
beacon_block: Option<Arc<SignedBeaconBlock<E>>>,
|
||||
seen_timestamp: Duration,
|
||||
@@ -113,7 +95,7 @@ pub enum SyncMessage<E: EthSpec> {
|
||||
|
||||
/// A blob has been received from the RPC.
|
||||
RpcBlob {
|
||||
request_id: RequestId,
|
||||
request_id: SyncRequestId,
|
||||
peer_id: PeerId,
|
||||
blob_sidecar: Option<Arc<BlobSidecar<E>>>,
|
||||
seen_timestamp: Duration,
|
||||
@@ -135,7 +117,7 @@ pub enum SyncMessage<E: EthSpec> {
|
||||
/// An RPC Error has occurred on a request.
|
||||
RpcError {
|
||||
peer_id: PeerId,
|
||||
request_id: RequestId,
|
||||
request_id: SyncRequestId,
|
||||
error: RPCError,
|
||||
},
|
||||
|
||||
@@ -342,16 +324,16 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
}
|
||||
|
||||
/// Handles RPC errors related to requests that were emitted from the sync manager.
|
||||
fn inject_error(&mut self, peer_id: PeerId, request_id: RequestId, error: RPCError) {
|
||||
fn inject_error(&mut self, peer_id: PeerId, request_id: SyncRequestId, error: RPCError) {
|
||||
trace!(self.log, "Sync manager received a failed RPC");
|
||||
match request_id {
|
||||
RequestId::SingleBlock { id } => {
|
||||
SyncRequestId::SingleBlock { id } => {
|
||||
self.on_single_block_response(id, peer_id, RpcEvent::RPCError(error))
|
||||
}
|
||||
RequestId::SingleBlob { id } => {
|
||||
SyncRequestId::SingleBlob { id } => {
|
||||
self.on_single_blob_response(id, peer_id, RpcEvent::RPCError(error))
|
||||
}
|
||||
RequestId::RangeBlockAndBlobs { id } => {
|
||||
SyncRequestId::RangeBlockAndBlobs { id } => {
|
||||
if let Some(sender_id) = self.network.range_request_failed(id) {
|
||||
match sender_id {
|
||||
RangeRequestId::RangeSync { chain_id, batch_id } => {
|
||||
@@ -835,13 +817,13 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
|
||||
fn rpc_block_received(
|
||||
&mut self,
|
||||
request_id: RequestId,
|
||||
request_id: SyncRequestId,
|
||||
peer_id: PeerId,
|
||||
block: Option<Arc<SignedBeaconBlock<T::EthSpec>>>,
|
||||
seen_timestamp: Duration,
|
||||
) {
|
||||
match request_id {
|
||||
RequestId::SingleBlock { id } => self.on_single_block_response(
|
||||
SyncRequestId::SingleBlock { id } => self.on_single_block_response(
|
||||
id,
|
||||
peer_id,
|
||||
match block {
|
||||
@@ -849,10 +831,10 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
None => RpcEvent::StreamTermination,
|
||||
},
|
||||
),
|
||||
RequestId::SingleBlob { .. } => {
|
||||
SyncRequestId::SingleBlob { .. } => {
|
||||
crit!(self.log, "Block received during blob request"; "peer_id" => %peer_id );
|
||||
}
|
||||
RequestId::RangeBlockAndBlobs { id } => {
|
||||
SyncRequestId::RangeBlockAndBlobs { id } => {
|
||||
self.range_block_and_blobs_response(id, peer_id, block.into())
|
||||
}
|
||||
}
|
||||
@@ -877,16 +859,16 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
|
||||
fn rpc_blob_received(
|
||||
&mut self,
|
||||
request_id: RequestId,
|
||||
request_id: SyncRequestId,
|
||||
peer_id: PeerId,
|
||||
blob: Option<Arc<BlobSidecar<T::EthSpec>>>,
|
||||
seen_timestamp: Duration,
|
||||
) {
|
||||
match request_id {
|
||||
RequestId::SingleBlock { .. } => {
|
||||
SyncRequestId::SingleBlock { .. } => {
|
||||
crit!(self.log, "Single blob received during block request"; "peer_id" => %peer_id );
|
||||
}
|
||||
RequestId::SingleBlob { id } => self.on_single_blob_response(
|
||||
SyncRequestId::SingleBlob { id } => self.on_single_blob_response(
|
||||
id,
|
||||
peer_id,
|
||||
match blob {
|
||||
@@ -894,7 +876,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
None => RpcEvent::StreamTermination,
|
||||
},
|
||||
),
|
||||
RequestId::RangeBlockAndBlobs { id } => {
|
||||
SyncRequestId::RangeBlockAndBlobs { id } => {
|
||||
self.range_block_and_blobs_response(id, peer_id, blob.into())
|
||||
}
|
||||
}
|
||||
@@ -978,7 +960,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
"sender_id" => ?resp.sender_id,
|
||||
"error" => e.clone()
|
||||
);
|
||||
let id = RequestId::RangeBlockAndBlobs { id };
|
||||
let id = SyncRequestId::RangeBlockAndBlobs { id };
|
||||
self.network.report_peer(
|
||||
peer_id,
|
||||
PeerAction::MidToleranceError,
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
use self::requests::{ActiveBlobsByRootRequest, ActiveBlocksByRootRequest};
|
||||
pub use self::requests::{BlobsByRootSingleBlockRequest, BlocksByRootSingleRequest};
|
||||
use super::block_sidecar_coupling::BlocksAndBlobsRequestInfo;
|
||||
use super::manager::{Id, RequestId as SyncRequestId};
|
||||
use super::range_sync::{BatchId, ByRangeRequestType, ChainId};
|
||||
use crate::network_beacon_processor::NetworkBeaconProcessor;
|
||||
use crate::service::{NetworkMessage, RequestId};
|
||||
use crate::service::NetworkMessage;
|
||||
use crate::status::ToStatusMessage;
|
||||
use crate::sync::block_lookups::SingleLookupId;
|
||||
use crate::sync::manager::{BlockProcessType, SingleLookupReqId};
|
||||
use crate::sync::manager::BlockProcessType;
|
||||
use beacon_chain::block_verification_types::RpcBlock;
|
||||
use beacon_chain::{BeaconChain, BeaconChainTypes, BlockProcessStatus, EngineState};
|
||||
use fnv::FnvHashMap;
|
||||
use lighthouse_network::rpc::methods::BlobsByRangeRequest;
|
||||
use lighthouse_network::rpc::{BlocksByRangeRequest, GoodbyeReason, RPCError};
|
||||
use lighthouse_network::service::api_types::{AppRequestId, Id, SingleLookupReqId, SyncRequestId};
|
||||
use lighthouse_network::{Client, NetworkGlobals, PeerAction, PeerId, ReportSource, Request};
|
||||
pub use requests::LookupVerifyError;
|
||||
use slog::{debug, error, trace, warn};
|
||||
@@ -246,7 +246,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
);
|
||||
|
||||
let request = Request::Status(status_message.clone());
|
||||
let request_id = RequestId::Router;
|
||||
let request_id = AppRequestId::Router;
|
||||
let _ = self.send_network_msg(NetworkMessage::SendRequest {
|
||||
peer_id,
|
||||
request,
|
||||
@@ -274,7 +274,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
.send(NetworkMessage::SendRequest {
|
||||
peer_id,
|
||||
request: Request::BlocksByRange(request.clone()),
|
||||
request_id: RequestId::Sync(SyncRequestId::RangeBlockAndBlobs { id }),
|
||||
request_id: AppRequestId::Sync(SyncRequestId::RangeBlockAndBlobs { id }),
|
||||
})
|
||||
.map_err(|_| RpcRequestSendError::NetworkSendError)?;
|
||||
|
||||
@@ -295,7 +295,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
start_slot: *request.start_slot(),
|
||||
count: *request.count(),
|
||||
}),
|
||||
request_id: RequestId::Sync(SyncRequestId::RangeBlockAndBlobs { id }),
|
||||
request_id: AppRequestId::Sync(SyncRequestId::RangeBlockAndBlobs { id }),
|
||||
})
|
||||
.map_err(|_| RpcRequestSendError::NetworkSendError)?;
|
||||
}
|
||||
@@ -424,7 +424,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
.send(NetworkMessage::SendRequest {
|
||||
peer_id,
|
||||
request: Request::BlocksByRoot(request.into_request(&self.chain.spec)),
|
||||
request_id: RequestId::Sync(SyncRequestId::SingleBlock { id }),
|
||||
request_id: AppRequestId::Sync(SyncRequestId::SingleBlock { id }),
|
||||
})
|
||||
.map_err(|_| RpcRequestSendError::NetworkSendError)?;
|
||||
|
||||
@@ -510,7 +510,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
.send(NetworkMessage::SendRequest {
|
||||
peer_id,
|
||||
request: Request::BlobsByRoot(request.clone().into_request(&self.chain.spec)),
|
||||
request_id: RequestId::Sync(SyncRequestId::SingleBlob { id }),
|
||||
request_id: AppRequestId::Sync(SyncRequestId::SingleBlob { id }),
|
||||
})
|
||||
.map_err(|_| RpcRequestSendError::NetworkSendError)?;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::sync::manager::Id;
|
||||
use beacon_chain::block_verification_types::{AsBlock, RpcBlock};
|
||||
use lighthouse_network::rpc::methods::BlocksByRangeRequest;
|
||||
use lighthouse_network::service::api_types::Id;
|
||||
use lighthouse_network::PeerId;
|
||||
use std::collections::HashSet;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
use super::batch::{BatchInfo, BatchProcessingResult, BatchState};
|
||||
use crate::network_beacon_processor::ChainSegmentProcessId;
|
||||
use crate::sync::network_context::RangeRequestId;
|
||||
use crate::sync::{
|
||||
manager::Id, network_context::SyncNetworkContext, BatchOperationOutcome, BatchProcessResult,
|
||||
};
|
||||
use crate::sync::{network_context::SyncNetworkContext, BatchOperationOutcome, BatchProcessResult};
|
||||
use beacon_chain::block_verification_types::RpcBlock;
|
||||
use beacon_chain::BeaconChainTypes;
|
||||
use fnv::FnvHashMap;
|
||||
use lighthouse_network::service::api_types::Id;
|
||||
use lighthouse_network::{PeerAction, PeerId};
|
||||
use rand::seq::SliceRandom;
|
||||
use slog::{crit, debug, o, warn};
|
||||
|
||||
@@ -44,12 +44,12 @@ use super::chain::{BatchId, ChainId, RemoveChain, SyncingChain};
|
||||
use super::chain_collection::ChainCollection;
|
||||
use super::sync_type::RangeSyncType;
|
||||
use crate::status::ToStatusMessage;
|
||||
use crate::sync::manager::Id;
|
||||
use crate::sync::network_context::SyncNetworkContext;
|
||||
use crate::sync::BatchProcessResult;
|
||||
use beacon_chain::block_verification_types::RpcBlock;
|
||||
use beacon_chain::{BeaconChain, BeaconChainTypes};
|
||||
use lighthouse_network::rpc::GoodbyeReason;
|
||||
use lighthouse_network::service::api_types::Id;
|
||||
use lighthouse_network::PeerId;
|
||||
use lighthouse_network::SyncInfo;
|
||||
use lru_cache::LRUTimeCache;
|
||||
@@ -380,7 +380,6 @@ where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::network_beacon_processor::NetworkBeaconProcessor;
|
||||
use crate::service::RequestId;
|
||||
use crate::NetworkMessage;
|
||||
|
||||
use super::*;
|
||||
@@ -391,7 +390,10 @@ mod tests {
|
||||
use beacon_chain::test_utils::{BeaconChainHarness, EphemeralHarnessType};
|
||||
use beacon_chain::EngineState;
|
||||
use beacon_processor::WorkEvent as BeaconWorkEvent;
|
||||
use lighthouse_network::{rpc::StatusMessage, NetworkGlobals};
|
||||
use lighthouse_network::service::api_types::SyncRequestId;
|
||||
use lighthouse_network::{
|
||||
rpc::StatusMessage, service::api_types::AppRequestId, NetworkGlobals,
|
||||
};
|
||||
use slog::{o, Drain};
|
||||
use slot_clock::TestingSlotClock;
|
||||
use std::collections::HashSet;
|
||||
@@ -517,7 +519,7 @@ mod tests {
|
||||
&mut self,
|
||||
expected_peer: &PeerId,
|
||||
fork_name: ForkName,
|
||||
) -> (RequestId, Option<RequestId>) {
|
||||
) -> (AppRequestId, Option<AppRequestId>) {
|
||||
let block_req_id = if let Ok(NetworkMessage::SendRequest {
|
||||
peer_id,
|
||||
request: _,
|
||||
@@ -550,12 +552,12 @@ mod tests {
|
||||
|
||||
fn complete_range_block_and_blobs_response(
|
||||
&mut self,
|
||||
block_req: RequestId,
|
||||
blob_req_opt: Option<RequestId>,
|
||||
block_req: AppRequestId,
|
||||
blob_req_opt: Option<AppRequestId>,
|
||||
) -> (ChainId, BatchId, Id) {
|
||||
if blob_req_opt.is_some() {
|
||||
match block_req {
|
||||
RequestId::Sync(crate::sync::manager::RequestId::RangeBlockAndBlobs { id }) => {
|
||||
AppRequestId::Sync(SyncRequestId::RangeBlockAndBlobs { id }) => {
|
||||
let _ = self
|
||||
.cx
|
||||
.range_block_and_blob_response(id, BlockOrBlob::Block(None));
|
||||
@@ -571,7 +573,7 @@ mod tests {
|
||||
}
|
||||
} else {
|
||||
match block_req {
|
||||
RequestId::Sync(crate::sync::manager::RequestId::RangeBlockAndBlobs { id }) => {
|
||||
AppRequestId::Sync(SyncRequestId::RangeBlockAndBlobs { id }) => {
|
||||
let response = self
|
||||
.cx
|
||||
.range_block_and_blob_response(id, BlockOrBlob::Block(None))
|
||||
|
||||
Reference in New Issue
Block a user