From dcac5a87f4b8c18832d59fc61e6e2f28a749be18 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Wed, 3 Mar 2021 15:12:25 -0800 Subject: [PATCH] lncfg: expose channel update rate limiting options --- config.go | 5 ++++- lncfg/gossip.go | 6 ++++++ sample-lnd.conf | 5 +++++ server.go | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index 750d726d..2a124ccc 100644 --- a/config.go +++ b/config.go @@ -488,7 +488,10 @@ func DefaultConfig() Config { Backoff: defaultTLSBackoff, }, }, - Gossip: &lncfg.Gossip{}, + Gossip: &lncfg.Gossip{ + MaxChannelUpdateBurst: discovery.DefaultMaxChannelUpdateBurst, + ChannelUpdateInterval: discovery.DefaultChannelUpdateInterval, + }, MaxOutgoingCltvExpiry: htlcswitch.DefaultMaxOutgoingCltvExpiry, MaxChannelFeeAllocation: htlcswitch.DefaultMaxLinkFeeAllocation, MaxCommitFeeRateAnchors: lnwallet.DefaultAnchorsCommitMaxFeeRateSatPerVByte, diff --git a/lncfg/gossip.go b/lncfg/gossip.go index bf8473a7..de1fcae2 100644 --- a/lncfg/gossip.go +++ b/lncfg/gossip.go @@ -1,6 +1,8 @@ package lncfg import ( + "time" + "github.com/lightningnetwork/lnd/discovery" "github.com/lightningnetwork/lnd/routing/route" ) @@ -9,6 +11,10 @@ type Gossip struct { PinnedSyncersRaw []string `long:"pinned-syncers" description:"A set of peers that should always remain in an active sync state, which can be used to closely synchronize the routing tables of two nodes. The value should be comma separated list of hex-encoded pubkeys. Connected peers matching this pubkey will remain active for the duration of the connection and not count towards the NumActiveSyncer count."` PinnedSyncers discovery.PinnedSyncers + + MaxChannelUpdateBurst int `long:"max-channel-update-burst" description:"The maximum number of updates for a specific channel and direction that lnd will accept over the channel update interval."` + + ChannelUpdateInterval time.Duration `long:"channel-update-interval" description:"The interval used to determine how often lnd should allow a burst of new updates for a specific channel and direction."` } // Parse the pubkeys for the pinned syncers. diff --git a/sample-lnd.conf b/sample-lnd.conf index 5a94a3af..baa7f778 100644 --- a/sample-lnd.conf +++ b/sample-lnd.conf @@ -1043,3 +1043,8 @@ litecoin.node=ltcd ; peers can be specified by setting multiple flags/fields in the config. ; gossip.pinned-syncers=pubkey1 ; gossip.pinned-syncers=pubkey2 + +; The maximum number of updates for a specific channel and direction that lnd +; will accept over the channel update interval. +; gossip.max-channel-update-burst=10 +; gossip.channel-update-interval=1m diff --git a/server.go b/server.go index 5d7b21a9..7c6681b6 100644 --- a/server.go +++ b/server.go @@ -823,6 +823,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr, SubBatchDelay: time.Second * 5, IgnoreHistoricalFilters: cfg.IgnoreHistoricalGossipFilters, PinnedSyncers: cfg.Gossip.PinnedSyncers, + MaxChannelUpdateBurst: cfg.Gossip.MaxChannelUpdateBurst, + ChannelUpdateInterval: cfg.Gossip.ChannelUpdateInterval, }, nodeKeyECDH.PubKey(), )