From 0644709830fc252f65c31c94856ad70ccebf9488 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Thu, 2 May 2024 17:32:40 +1000 Subject: [PATCH] Add data columns by root to currently supported protocol list (#5678) * Add data columns by root to currently supported protocol list. * Add missing data column by roots handling. --- .../lighthouse_network/src/rpc/protocol.rs | 2 ++ beacon_node/network/src/router.rs | 32 ++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/beacon_node/lighthouse_network/src/rpc/protocol.rs b/beacon_node/lighthouse_network/src/rpc/protocol.rs index 6df0b4702f..946db6459e 100644 --- a/beacon_node/lighthouse_network/src/rpc/protocol.rs +++ b/beacon_node/lighthouse_network/src/rpc/protocol.rs @@ -373,6 +373,8 @@ impl SupportedProtocol { supported.extend_from_slice(&[ ProtocolId::new(SupportedProtocol::BlobsByRootV1, Encoding::SSZSnappy), ProtocolId::new(SupportedProtocol::BlobsByRangeV1, Encoding::SSZSnappy), + // TODO(das): add to PeerDAS fork + ProtocolId::new(SupportedProtocol::DataColumnsByRootV1, Encoding::SSZSnappy), ]); } supported diff --git a/beacon_node/network/src/router.rs b/beacon_node/network/src/router.rs index caa9c38af3..170ea59594 100644 --- a/beacon_node/network/src/router.rs +++ b/beacon_node/network/src/router.rs @@ -638,11 +638,35 @@ impl Router { /// Handle a `DataColumnsByRoot` response from the peer. pub fn on_data_columns_by_root_response( &mut self, - _peer_id: PeerId, - _request_id: RequestId, - _data_column_sidecar: Option>>, + peer_id: PeerId, + request_id: RequestId, + data_column: Option>>, ) { - // TODO(das) implement `DataColumnsByRoot` response handling + let request_id = match request_id { + RequestId::Sync(sync_id) => match sync_id { + id @ SyncId::DataColumnsByRoot { .. } => id, + other => { + crit!(self.log, "DataColumnsByRoot response on incorrect request"; "request" => ?other); + return; + } + }, + RequestId::Router => { + crit!(self.log, "All DataColumnsByRoot requests belong to sync"; "peer_id" => %peer_id); + return; + } + }; + + trace!( + self.log, + "Received DataColumnsByRoot Response"; + "peer" => %peer_id, + ); + self.send_to_sync(SyncMessage::RpcDataColumn { + request_id, + peer_id, + data_column, + seen_timestamp: timestamp_now(), + }); } fn handle_beacon_processor_send_result(