Skip to content

Commit

Permalink
Subscribe to all data column subnets for now
Browse files Browse the repository at this point in the history
  • Loading branch information
povi committed May 13, 2024
1 parent a24ede3 commit a00d1e7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions p2p/src/block_sync_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ impl<P: Preset> BlockSyncService<P> {

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);
Expand Down
1 change: 1 addition & 0 deletions p2p/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ pub enum SyncToP2p {
RequestBlockByRoot(RequestId, PeerId, H256),
RequestPeerStatus(RequestId, PeerId),
SubscribeToCoreTopics,
SubscribeToDataColumnTopics,
}

impl SyncToP2p {
Expand Down
16 changes: 15 additions & 1 deletion p2p/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -445,6 +445,9 @@ impl<P: Preset> Network<P> {
SyncToP2p::SubscribeToCoreTopics => {
self.subscribe_to_core_topics();
}
SyncToP2p::SubscribeToDataColumnTopics => {
self.subscribe_to_data_column_topics();
}
SyncToP2p::PruneReceivedBlocks => {
self.received_block_roots = HashMap::new();
}
Expand Down Expand Up @@ -2147,6 +2150,17 @@ impl<P: Preset> Network<P> {
}
}

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);
Expand Down

0 comments on commit a00d1e7

Please sign in to comment.