Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions discovery/gossiper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions discovery/gossiper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions lncfg/protocol_legacy_off.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
11 changes: 11 additions & 0 deletions lncfg/protocol_legacy_on.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
1 change: 1 addition & 0 deletions lntest/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
MinimumBatchSize: 10,
SubBatchDelay: time.Second * 5,
IgnoreHistoricalFilters: cfg.IgnoreHistoricalGossipFilters,
GossipUpdateThrottle: !cfg.ProtocolOptions.NoGossipThrottle(),
},
s.identityECDH.PubKey(),
)
Expand Down