From 1c450bbc44563c7790e1f1b95756e5da6d094cc3 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Fri, 14 Jan 2022 19:47:59 +0000 Subject: [PATCH] [p2p] tuning libp2p parameters to reduce flooding Signed-off-by: Leo Chen --- p2p/host.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/p2p/host.go b/p2p/host.go index c74ea78e1..6b88a0d6b 100644 --- a/p2p/host.go +++ b/p2p/host.go @@ -9,6 +9,7 @@ import ( "runtime" "strings" "sync" + "time" "github.com/libp2p/go-libp2p" libp2p_crypto "github.com/libp2p/go-libp2p-core/crypto" @@ -153,6 +154,18 @@ func NewHost(cfg HostConfig) (Host, error) { } } + libp2p_pubsub.GossipSubDlazy = 4 + libp2p_pubsub.GossipSubGossipFactor = 0.15 + libp2p_pubsub.GossipSubD = 5 + libp2p_pubsub.GossipSubDlo = 4 + libp2p_pubsub.GossipSubDhi = 8 + libp2p_pubsub.GossipSubHistoryLength = 2 + libp2p_pubsub.GossipSubHistoryGossip = 2 + libp2p_pubsub.GossipSubGossipRetransmission = 2 + libp2p_pubsub.GossipSubFanoutTTL = 10 * time.Second + libp2p_pubsub.GossipSubMaxPendingConnections = 32 + libp2p_pubsub.GossipSubMaxIHaveLength = 1000 + pubsub, err := libp2p_pubsub.NewGossipSub(ctx, p2pHost, options...) if err != nil { return nil, errors.Wrapf(err, "cannot initialize libp2p pub-sub")