From 60cdd69b0589ba4c148d7d091847a84ad228292f Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Fri, 20 Nov 2020 23:36:02 +0800 Subject: [PATCH] Update Gossipsub Parameters (#7869) * add param and flag * change back --- beacon-chain/p2p/parameter_test.go | 4 ++-- beacon-chain/p2p/pubsub.go | 12 +++++++++++- shared/featureconfig/config.go | 5 +++++ shared/featureconfig/flags.go | 6 ++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/beacon-chain/p2p/parameter_test.go b/beacon-chain/p2p/parameter_test.go index b10537c55..d64d202d9 100644 --- a/beacon-chain/p2p/parameter_test.go +++ b/beacon-chain/p2p/parameter_test.go @@ -10,8 +10,8 @@ import ( const ( // overlay parameters - gossipSubD = 6 // topic stable mesh target count - gossipSubDlo = 5 // topic stable mesh low watermark + gossipSubD = 8 // topic stable mesh target count + gossipSubDlo = 6 // topic stable mesh low watermark gossipSubDhi = 12 // topic stable mesh high watermark // gossip parameters diff --git a/beacon-chain/p2p/pubsub.go b/beacon-chain/p2p/pubsub.go index 56014f487..1fad374c6 100644 --- a/beacon-chain/p2p/pubsub.go +++ b/beacon-chain/p2p/pubsub.go @@ -116,9 +116,19 @@ func msgIDFunction(pmsg *pubsub_pb.Message) string { func setPubSubParameters() { heartBeatInterval := 700 * time.Millisecond - pubsub.GossipSubDlo = 5 + pubsub.GossipSubDlo = 6 + pubsub.GossipSubD = 8 pubsub.GossipSubHeartbeatInterval = heartBeatInterval pubsub.GossipSubHistoryLength = 6 pubsub.GossipSubHistoryGossip = 3 pubsub.TimeCacheDuration = 550 * heartBeatInterval + + // Set a larger gossip history to ensure that slower + // messages have a longer time to be propagated. This + // comes with the tradeoff of larger memory usage and + // size of the seen message cache. + if featureconfig.Get().EnableLargerGossipHistory { + pubsub.GossipSubHistoryLength = 12 + pubsub.GossipSubHistoryLength = 5 + } } diff --git a/shared/featureconfig/config.go b/shared/featureconfig/config.go index ef341099f..a7707848f 100644 --- a/shared/featureconfig/config.go +++ b/shared/featureconfig/config.go @@ -47,6 +47,7 @@ type Flags struct { EnablePeerScorer bool // EnablePeerScorer enables experimental peer scoring in p2p. EnablePruningDepositProofs bool // EnablePruningDepositProofs enables pruning deposit proofs which significantly reduces the size of a deposit EnableSyncBacktracking bool // EnableSyncBacktracking enables backtracking algorithm when searching for alternative forks during initial sync. + EnableLargerGossipHistory bool // EnableLargerGossipHistory increases the gossip history we store in our caches. // Logging related toggles. DisableGRPCConnectionLogs bool // Disables logging when a new grpc client has connected. @@ -174,6 +175,10 @@ func ConfigureBeaconChain(ctx *cli.Context) { log.Warn("Enabling init-sync backtracking algorithm") cfg.EnableSyncBacktracking = true } + if ctx.Bool(enableLargerGossipHistory.Name) { + log.Warn("Using a larger gossip history for the node") + cfg.EnableLargerGossipHistory = true + } Init(cfg) } diff --git a/shared/featureconfig/flags.go b/shared/featureconfig/flags.go index bc0efb26b..7c0cacef8 100644 --- a/shared/featureconfig/flags.go +++ b/shared/featureconfig/flags.go @@ -80,11 +80,16 @@ var ( Name: "enable-sync-backtracking", Usage: "Enable experimental fork exploration backtracking algorithm", } + enableLargerGossipHistory = &cli.BoolFlag{ + Name: "enable-larger-gossip-history", + Usage: "Enables the node to store a larger amount of gossip messages in its cache.", + } ) // devModeFlags holds list of flags that are set when development mode is on. var devModeFlags = []cli.Flag{ enableSyncBacktracking, + enableLargerGossipHistory, } // ValidatorFlags contains a list of all the feature flags that apply to the validator client. @@ -121,6 +126,7 @@ var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{ disableBlst, disableEth1DataMajorityVote, enablePeerScorer, + enableLargerGossipHistory, checkPtInfoCache, disablePruningDepositProofs, enableSyncBacktracking,