Merge pull request #4810 from Roasbeef/gossip-throttle-config

multi: add new config option to toggle gossip rate limiting
This commit is contained in:
Johan T. Halseth 2020-12-01 13:32:52 +01:00 committed by GitHub
commit 8ec4697fe3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 2 deletions

@ -228,6 +228,11 @@ type Config struct {
// This prevents ranges with old start times from causing us to dump the
// graph on connect.
IgnoreHistoricalFilters bool
// GossipUpdateThrottle if true, then the gossiper will throttle
// gossip updates to once per RebroadcastInterval for any keep-alive
// updates, and once per block for other types of updates.
GossipUpdateThrottle bool
}
// AuthenticatedGossiper is a subsystem which is responsible for receiving
@ -1965,8 +1970,9 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
// If we have a previous version of the edge being updated,
// we'll want to rate limit its updates to prevent spam
// throughout the network.
if nMsg.isRemote && edgeToUpdate != nil {
// throughout the network if we're currently throttling such
// updates.
if d.cfg.GossipUpdateThrottle && nMsg.isRemote && edgeToUpdate != nil {
// If it's a keep-alive update, we'll only propagate one
// if it's been a day since the previous. This follows
// our own heuristic of sending keep-alive updates after

@ -3957,6 +3957,7 @@ func TestRateLimitChannelUpdates(t *testing.T) {
}
defer cleanup()
ctx.gossiper.cfg.RebroadcastInterval = time.Hour
ctx.gossiper.cfg.GossipUpdateThrottle = true
// The graph should start empty.
require.Empty(t, ctx.router.infos)

@ -20,3 +20,8 @@ func (l *LegacyProtocol) LegacyOnion() bool {
func (l *LegacyProtocol) NoStaticRemoteKey() bool {
return false
}
// NoGossipThrottle returns true if gossip updates shouldn't be throttled.
func (l *LegacyProtocol) NoGossipThrottle() bool {
return false
}

@ -16,6 +16,12 @@ type LegacyProtocol struct {
// remote party's output in the commitment. If set to true, then we
// won't signal StaticRemoteKeyOptional.
CommitmentTweak bool `long:"committweak" description:"force node to not advertise the new commitment format"`
// NoGossipUpdateThrottle if true, then gossip updates won't be
// throttled using the current set of heuristics. This should mainly be
// used for integration tests where we want nearly instant propagation
// of gossip updates.
NoGossipUpdateThrottle bool `long:"no-gossip-throttle" description:"if true, then gossip updates will not be throttled to once per rebroadcast interval for non keep-alive updates"`
}
// LegacyOnion returns true if the old legacy onion format should be used when
@ -30,3 +36,8 @@ func (l *LegacyProtocol) LegacyOnion() bool {
func (l *LegacyProtocol) NoStaticRemoteKey() bool {
return l.CommitmentTweak
}
// NoGossipThrottle returns true if gossip updates shouldn't be throttled.
func (l *LegacyProtocol) NoGossipThrottle() bool {
return l.NoGossipUpdateThrottle
}

@ -255,6 +255,7 @@ func (cfg NodeConfig) genArgs() []string {
args = append(args, fmt.Sprintf("--invoicemacaroonpath=%v", cfg.InvoiceMacPath))
args = append(args, fmt.Sprintf("--trickledelay=%v", trickleDelay))
args = append(args, fmt.Sprintf("--profile=%d", cfg.ProfilePort))
args = append(args, fmt.Sprintf("--protocol.legacy.no-gossip-throttle"))
if !cfg.HasSeed {
args = append(args, "--noseedbackup")

@ -807,6 +807,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
MinimumBatchSize: 10,
SubBatchDelay: time.Second * 5,
IgnoreHistoricalFilters: cfg.IgnoreHistoricalGossipFilters,
GossipUpdateThrottle: !cfg.ProtocolOptions.NoGossipThrottle(),
},
s.identityECDH.PubKey(),
)