From a00d1e795a44be8ead22921a00446e4cd93899b7 Mon Sep 17 00:00:00 2001 From: Povilas Liubauskas Date: Mon, 13 May 2024 14:23:57 +0300 Subject: [PATCH] Subscribe to all data column subnets for now --- p2p/src/block_sync_service.rs | 1 + p2p/src/messages.rs | 1 + p2p/src/network.rs | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/p2p/src/block_sync_service.rs b/p2p/src/block_sync_service.rs index 2215d465..86e7e105 100644 --- a/p2p/src/block_sync_service.rs +++ b/p2p/src/block_sync_service.rs @@ -659,6 +659,7 @@ impl BlockSyncService

{ if !was_forward_synced && is_forward_synced { SyncToP2p::SubscribeToCoreTopics.send(&self.sync_to_p2p_tx); + SyncToP2p::SubscribeToDataColumnTopics.send(&self.sync_to_p2p_tx); if self.back_sync.is_some() { SyncToP2p::PruneReceivedBlocks.send(&self.sync_to_p2p_tx); diff --git a/p2p/src/messages.rs b/p2p/src/messages.rs index 7aea6c31..be0d9a33 100644 --- a/p2p/src/messages.rs +++ b/p2p/src/messages.rs @@ -135,6 +135,7 @@ pub enum SyncToP2p { RequestBlockByRoot(RequestId, PeerId, H256), RequestPeerStatus(RequestId, PeerId), SubscribeToCoreTopics, + SubscribeToDataColumnTopics, } impl SyncToP2p { diff --git a/p2p/src/network.rs b/p2p/src/network.rs index ab4604ea..5999f15f 100644 --- a/p2p/src/network.rs +++ b/p2p/src/network.rs @@ -46,7 +46,7 @@ use types::{ capella::containers::SignedBlsToExecutionChange, combined::SignedBeaconBlock, deneb::containers::{BlobIdentifier, BlobSidecar}, - eip7594::DataColumnIdentifier, + eip7594::{DataColumnIdentifier, DATA_COLUMN_SIDECAR_SUBNET_COUNT}, nonstandard::{Phase, WithStatus}, phase0::{ consts::{FAR_FUTURE_EPOCH, GENESIS_EPOCH}, @@ -445,6 +445,9 @@ impl Network

{ SyncToP2p::SubscribeToCoreTopics => { self.subscribe_to_core_topics(); } + SyncToP2p::SubscribeToDataColumnTopics => { + self.subscribe_to_data_column_topics(); + } SyncToP2p::PruneReceivedBlocks => { self.received_block_roots = HashMap::new(); } @@ -2147,6 +2150,17 @@ impl Network

{ } } + fn subscribe_to_data_column_topics(&mut self) { + // TODO(das): for now, subscribe to all data column sidecar subnets + for subnet_id in 0..DATA_COLUMN_SIDECAR_SUBNET_COUNT { + let subnet = Subnet::DataColumn(subnet_id); + + if let Some(topic) = self.subnet_gossip_topic(subnet) { + ServiceInboundMessage::Subscribe(topic).send(&self.network_to_service_tx); + } + } + } + fn report_outcome(&self, gossip_id: GossipId, message_acceptance: MessageAcceptance) { ServiceInboundMessage::ReportMessageValidationResult(gossip_id, message_acceptance) .send(&self.network_to_service_tx);