Compare commits

..

1 Commits

Author SHA1 Message Date
0g-peterzhb
54c807c10a
Merge 9a11e969e6 into 37a601cef1 2024-12-04 09:12:28 +07:00
7 changed files with 10 additions and 25 deletions

View File

@ -133,9 +133,6 @@ pub struct Config {
/// Whether to disable network identity in ENR. /// Whether to disable network identity in ENR.
/// This is for test purpose only. /// This is for test purpose only.
pub disable_enr_network_id: bool, pub disable_enr_network_id: bool,
/// Whether to allow find chunks from peers.
pub find_chunks_enabled: bool,
} }
impl Default for Config { impl Default for Config {
@ -217,7 +214,6 @@ impl Default for Config {
peer_db: Default::default(), peer_db: Default::default(),
peer_manager: Default::default(), peer_manager: Default::default(),
disable_enr_network_id: false, disable_enr_network_id: false,
find_chunks_enabled: false,
} }
} }
} }

View File

@ -243,18 +243,7 @@ impl<AppReqId: ReqId> Service<AppReqId> {
// } // }
// } // }
let mut topics = vec![ for topic_kind in &crate::types::CORE_TOPICS {
GossipKind::NewFile,
GossipKind::FindFile,
GossipKind::AnnounceFile,
GossipKind::AnnounceShardConfig,
];
if config.find_chunks_enabled {
topics.push(GossipKind::FindChunks);
topics.push(GossipKind::AnnounceChunks);
}
for topic_kind in topics {
if swarm.behaviour_mut().subscribe_kind(topic_kind.clone()) { if swarm.behaviour_mut().subscribe_kind(topic_kind.clone()) {
subscribed_topics.push(topic_kind.clone()); subscribed_topics.push(topic_kind.clone());
} else { } else {

View File

@ -11,4 +11,4 @@ pub use pubsub::{
PubsubMessage, SignedAnnounceChunks, SignedAnnounceFile, SignedAnnounceShardConfig, PubsubMessage, SignedAnnounceChunks, SignedAnnounceFile, SignedAnnounceShardConfig,
SignedMessage, SnappyTransform, SignedMessage, SnappyTransform,
}; };
pub use topics::{GossipEncoding, GossipKind, GossipTopic}; pub use topics::{GossipEncoding, GossipKind, GossipTopic, CORE_TOPICS};

View File

@ -15,6 +15,14 @@ pub const ANNOUNCE_FILE_TOPIC: &str = "announce_file";
pub const ANNOUNCE_CHUNKS_TOPIC: &str = "announce_chunks"; pub const ANNOUNCE_CHUNKS_TOPIC: &str = "announce_chunks";
pub const ANNOUNCE_SHARD_CONFIG_TOPIC: &str = "announce_shard_config"; pub const ANNOUNCE_SHARD_CONFIG_TOPIC: &str = "announce_shard_config";
pub const CORE_TOPICS: [GossipKind; 5] = [
GossipKind::NewFile,
GossipKind::FindFile,
GossipKind::FindChunks,
GossipKind::AnnounceFile,
GossipKind::AnnounceChunks,
];
/// A gossipsub topic which encapsulates the type of messages that should be sent and received over /// A gossipsub topic which encapsulates the type of messages that should be sent and received over
/// the pubsub protocol and the way the messages should be encoded. /// the pubsub protocol and the way the messages should be encoded.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]

View File

@ -111,7 +111,6 @@ impl ZgsConfig {
network_config.peer_db = self.network_peer_db; network_config.peer_db = self.network_peer_db;
network_config.peer_manager = self.network_peer_manager.clone(); network_config.peer_manager = self.network_peer_manager.clone();
network_config.disable_enr_network_id = self.discv5_disable_enr_network_id; network_config.disable_enr_network_id = self.discv5_disable_enr_network_id;
network_config.find_chunks_enabled = self.network_find_chunks_enabled;
Ok(network_config) Ok(network_config)
} }

View File

@ -19,7 +19,6 @@ build_config! {
(network_libp2p_nodes, (Vec<String>), vec![]) (network_libp2p_nodes, (Vec<String>), vec![])
(network_private, (bool), false) (network_private, (bool), false)
(network_disable_discovery, (bool), false) (network_disable_discovery, (bool), false)
(network_find_chunks_enabled, (bool), false)
// discv5 // discv5
(discv5_request_timeout_secs, (u64), 5) (discv5_request_timeout_secs, (u64), 5)

View File

@ -14,12 +14,6 @@ class SyncTest(TestFramework):
def setup_params(self): def setup_params(self):
self.num_nodes = 2 self.num_nodes = 2
# enable find chunks topic
for i in range(self.num_nodes):
self.zgs_node_configs[i] = {
"network_find_chunks_enabled": True
}
def run_test(self): def run_test(self):
# By default, auto_sync_enabled and sync_file_on_announcement_enabled are both false, # By default, auto_sync_enabled and sync_file_on_announcement_enabled are both false,
# and file or chunks sync should be triggered by rpc. # and file or chunks sync should be triggered by rpc.