From 37b5978bf0b77ed53a1e257fa479752b2f3450cd Mon Sep 17 00:00:00 2001 From: Jose Storopoli Date: Tue, 15 Apr 2025 15:33:16 -0400 Subject: [PATCH] fix(gossipsub): tweak configs to reduce duplicated msgs --- crates/p2p/src/swarm/behavior.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/p2p/src/swarm/behavior.rs b/crates/p2p/src/swarm/behavior.rs index b265d2a8..e582d778 100644 --- a/crates/p2p/src/swarm/behavior.rs +++ b/crates/p2p/src/swarm/behavior.rs @@ -1,6 +1,6 @@ //! Request-Response [`Behaviour`] and [`NetworkBehaviour`] for the P2P protocol. -use std::collections::HashSet; +use std::{collections::HashSet, time::Duration}; use libp2p::{ allow_block_list::{AllowedPeers, Behaviour as AllowListBehaviour}, @@ -68,7 +68,15 @@ impl Behaviour { .validate_messages() .max_transmit_size(MAX_TRANSMIT_SIZE) // Avoids spamming the network and nodes with messages - .idontwant_on_publish(true) + .duplicate_cache_time(Duration::from_secs(60 * 5)) // default is 1 min + .published_message_ids_cache_time(Duration::from_secs(60)) // default is 10 + .max_ihave_messages(100) // default is 10 + .gossip_retransimission(1) // default is 3 + .iwant_followup_time(Duration::from_secs(2)) // default is 3 + .gossip_lazy(2) // default is 6 + .gossip_factor(0.1) // default is 0.25 + .history_gossip(1) // default is 3 + .history_length(3) // default is 5 .build() .expect("gossipsub config at this stage must be valid"), None,