mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-23 06:44:35 +00:00
Add data columns by root sync request (#6274)
* Add data columns by root sync request
This commit is contained in:
@@ -53,7 +53,9 @@ use beacon_chain::{
|
||||
};
|
||||
use futures::StreamExt;
|
||||
use lighthouse_network::rpc::RPCError;
|
||||
use lighthouse_network::service::api_types::{Id, SingleLookupReqId, SyncRequestId};
|
||||
use lighthouse_network::service::api_types::{
|
||||
DataColumnsByRootRequestId, Id, SingleLookupReqId, SyncRequestId,
|
||||
};
|
||||
use lighthouse_network::types::{NetworkGlobals, SyncState};
|
||||
use lighthouse_network::SyncInfo;
|
||||
use lighthouse_network::{PeerAction, PeerId};
|
||||
@@ -345,9 +347,13 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
SyncRequestId::SingleBlob { id } => {
|
||||
self.on_single_blob_response(id, peer_id, RpcEvent::RPCError(error))
|
||||
}
|
||||
SyncRequestId::DataColumnsByRoot { .. } => {
|
||||
// TODO(das)
|
||||
}
|
||||
SyncRequestId::DataColumnsByRoot(req_id, requester) => self
|
||||
.on_data_columns_by_root_response(
|
||||
req_id,
|
||||
requester,
|
||||
peer_id,
|
||||
RpcEvent::RPCError(error),
|
||||
),
|
||||
SyncRequestId::RangeBlockAndBlobs { id } => {
|
||||
if let Some(sender_id) = self.network.range_request_failed(id) {
|
||||
match sender_id {
|
||||
@@ -860,15 +866,12 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
None => RpcEvent::StreamTermination,
|
||||
},
|
||||
),
|
||||
SyncRequestId::SingleBlob { .. } => {
|
||||
crit!(self.log, "Block received during blob request"; "peer_id" => %peer_id );
|
||||
}
|
||||
SyncRequestId::DataColumnsByRoot { .. } => {
|
||||
// TODO(das)
|
||||
}
|
||||
SyncRequestId::RangeBlockAndBlobs { id } => {
|
||||
self.range_block_and_blobs_response(id, peer_id, block.into())
|
||||
}
|
||||
_ => {
|
||||
crit!(self.log, "bad request id for block"; "peer_id" => %peer_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -897,9 +900,6 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
seen_timestamp: Duration,
|
||||
) {
|
||||
match request_id {
|
||||
SyncRequestId::SingleBlock { .. } => {
|
||||
crit!(self.log, "Single blob received during block request"; "peer_id" => %peer_id );
|
||||
}
|
||||
SyncRequestId::SingleBlob { id } => self.on_single_blob_response(
|
||||
id,
|
||||
peer_id,
|
||||
@@ -908,23 +908,41 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
None => RpcEvent::StreamTermination,
|
||||
},
|
||||
),
|
||||
SyncRequestId::DataColumnsByRoot { .. } => {
|
||||
// TODO(das)
|
||||
}
|
||||
SyncRequestId::RangeBlockAndBlobs { id } => {
|
||||
self.range_block_and_blobs_response(id, peer_id, blob.into())
|
||||
}
|
||||
_ => {
|
||||
crit!(self.log, "bad request id for blob"; "peer_id" => %peer_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn rpc_data_column_received(
|
||||
&mut self,
|
||||
_request_id: SyncRequestId,
|
||||
_peer_id: PeerId,
|
||||
_data_column: Option<Arc<DataColumnSidecar<T::EthSpec>>>,
|
||||
_seen_timestamp: Duration,
|
||||
request_id: SyncRequestId,
|
||||
peer_id: PeerId,
|
||||
data_column: Option<Arc<DataColumnSidecar<T::EthSpec>>>,
|
||||
seen_timestamp: Duration,
|
||||
) {
|
||||
// TODO(das): implement handler
|
||||
match request_id {
|
||||
SyncRequestId::DataColumnsByRoot(req_id, requester) => {
|
||||
self.on_data_columns_by_root_response(
|
||||
req_id,
|
||||
requester,
|
||||
peer_id,
|
||||
match data_column {
|
||||
Some(data_column) => RpcEvent::Response(data_column, seen_timestamp),
|
||||
None => RpcEvent::StreamTermination,
|
||||
},
|
||||
);
|
||||
}
|
||||
SyncRequestId::RangeBlockAndBlobs { id: _ } => {
|
||||
// TODO(das): implement custody range sync
|
||||
}
|
||||
_ => {
|
||||
crit!(self.log, "bad request id for data_column"; "peer_id" => %peer_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn on_single_blob_response(
|
||||
@@ -944,6 +962,21 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_data_columns_by_root_response(
|
||||
&mut self,
|
||||
req_id: DataColumnsByRootRequestId,
|
||||
_requester: SingleLookupReqId,
|
||||
peer_id: PeerId,
|
||||
rpc_event: RpcEvent<Arc<DataColumnSidecar<T::EthSpec>>>,
|
||||
) {
|
||||
if let Some(_resp) = self
|
||||
.network
|
||||
.on_data_columns_by_root_response(req_id, peer_id, rpc_event)
|
||||
{
|
||||
// TODO(das): pass data_columns_by_root result to consumer
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles receiving a response for a range sync request that should have both blocks and
|
||||
/// blobs.
|
||||
fn range_block_and_blobs_response(
|
||||
|
||||
Reference in New Issue
Block a user