Skip to content

Commit

Permalink
chore: gossipsub flood_publish and longer cache time to avoid loop
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed Dec 11, 2023
1 parent 2a9bad7 commit cc8b312
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions sn_networking/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,6 @@ impl NetworkBuilder {
let gossipsub = if self.enable_gossip {
// Gossipsub behaviour
let gossipsub_config = libp2p::gossipsub::ConfigBuilder::default()
// disable sending to ALL_PEERS subscribed to a topic, which is the default behaviour
.flood_publish(false)
// we don't currently require source peer id and/or signing
.validation_mode(libp2p::gossipsub::ValidationMode::Permissive)
// we use the hash of the msg content as the msg id to deduplicate them
Expand All @@ -467,6 +465,10 @@ impl NetworkBuilder {
})
// set the heartbeat interval to be higher than default 1sec
.heartbeat_interval(Duration::from_secs(5))
// default is 3sec, increase to 10sec to avoid false alert
.iwant_followup_time(Duration::from_secs(10))
// default is 10sec, increase to 60sec to reduce the risk of looping
.published_message_ids_cache_time(Duration::from_secs(60))
.build()
.map_err(|err| Error::GossipsubConfigError(err.to_string()))?;

Expand Down
5 changes: 3 additions & 2 deletions sn_node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ use tokio::{
/// serialised transfer info encrypted against the referenced public key.
pub const ROYALTY_TRANSFER_NOTIF_TOPIC: &str = "ROYALTY_TRANSFER_NOTIFICATION";

/// Defines the percentage (ie 1/FORWARDER_CHOOSING_FACTOR th of all nodes) of nodes which will act as royalty_transfer_notify forwarder.
const FORWARDER_CHOOSING_FACTOR: usize = 50;
/// Defines the percentage (ie 1/FORWARDER_CHOOSING_FACTOR th of all nodes) of nodes
/// which will act as royalty_transfer_notify forwarder.
const FORWARDER_CHOOSING_FACTOR: usize = 10;

/// Interval to trigger replication of all records to all peers.
/// This is the max time it should take. Minimum interval at any ndoe will be half this
Expand Down

0 comments on commit cc8b312

Please sign in to comment.