From e75848de667d9054b5b976e534db7f9ab38ca82b Mon Sep 17 00:00:00 2001 From: tbjump Date: Tue, 22 Aug 2023 17:05:02 +0000 Subject: [PATCH] node/p2p: Increase gossipParams.Dhi to 50 for testnet bootstrap node --- node/pkg/p2p/p2p.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/node/pkg/p2p/p2p.go b/node/pkg/p2p/p2p.go index d4f75e5bb..7a49eba96 100644 --- a/node/pkg/p2p/p2p.go +++ b/node/pkg/p2p/p2p.go @@ -278,9 +278,21 @@ func Run( topic := fmt.Sprintf("%s/%s", networkID, "broadcast") + bootstrappers, bootstrapNode := bootstrapAddrs(logger, bootstrapPeers, h.ID()) + gossipParams := pubsub.DefaultGossipSubParams() + + if bootstrapNode { + logger.Info("We are a bootstrap node.") + if networkID == "/wormhole/testnet/2/1" { + gossipParams.Dhi = 50 + logger.Info("We are a bootstrap node in Testnet. Setting gossipParams.Dhi.", zap.Int("gossipParams.Dhi", gossipParams.Dhi)) + } + } + logger.Info("Subscribing pubsub topic", zap.String("topic", topic)) ps, err := pubsub.NewGossipSub(ctx, h, pubsub.WithValidateQueueSize(P2P_VALIDATE_QUEUE_SIZE), + pubsub.WithGossipSubParams(gossipParams), ) if err != nil { panic(err) @@ -308,13 +320,8 @@ func Run( // Make sure we connect to at least 1 bootstrap node (this is particularly important in a local devnet and CI // as peer discovery can take a long time). - bootstrappers, bootstrapNode := bootstrapAddrs(logger, bootstrapPeers, h.ID()) successes := connectToPeers(ctx, logger, h, bootstrappers) - if bootstrapNode { - logger.Info("We are a bootstrap node.") - } - if successes == 0 && !bootstrapNode { // If we're a bootstrap node it's okay to not have any peers. // If we fail to connect to any bootstrap peer, kill the service // returning from this function will lead to rootCtxCancel() being called in the defer() above. The service will then be restarted by Tilt/kubernetes.