multi: add new config options to tune gossip msg allocated bandwidth

We go with the defaults of if no values are set.
This commit is contained in:
Olaoluwa Osuntokun
2025-03-20 14:54:26 -07:00
parent 05702d48b2
commit c7ed5d65c6
5 changed files with 45 additions and 10 deletions

View File

@@ -707,6 +707,8 @@ func DefaultConfig() Config {
ChannelUpdateInterval: discovery.DefaultChannelUpdateInterval, ChannelUpdateInterval: discovery.DefaultChannelUpdateInterval,
SubBatchDelay: discovery.DefaultSubBatchDelay, SubBatchDelay: discovery.DefaultSubBatchDelay,
AnnouncementConf: discovery.DefaultProofMatureDelta, AnnouncementConf: discovery.DefaultProofMatureDelta,
MsgRateBytes: discovery.DefaultMsgBytesPerSecond,
MsgBurstBytes: discovery.DefaultMsgBytesBurst,
}, },
Invoices: &lncfg.Invoices{ Invoices: &lncfg.Invoices{
HoldExpiryDelta: lncfg.DefaultHoldInvoiceExpiryDelta, HoldExpiryDelta: lncfg.DefaultHoldInvoiceExpiryDelta,

View File

@@ -390,6 +390,14 @@ type Config struct {
// spent-ness of channel outpoints. For neutrino, this saves long // spent-ness of channel outpoints. For neutrino, this saves long
// rescans from blocking initial usage of the daemon. // rescans from blocking initial usage of the daemon.
AssumeChannelValid bool AssumeChannelValid bool
// MsgRateBytes is the rate limit for the number of bytes per second
// that we'll allocate to outbound gossip messages.
MsgRateBytes uint64
// MsgBurstBytes is the allotted burst amount in bytes. This is the
// number of starting tokens in our token bucket algorithm.
MsgBurstBytes uint64
} }
// processedNetworkMsg is a wrapper around networkMsg and a boolean. It is // processedNetworkMsg is a wrapper around networkMsg and a boolean. It is
@@ -574,16 +582,18 @@ func New(cfg Config, selfKeyDesc *keychain.KeyDescriptor) *AuthenticatedGossiper
gossiper.vb = NewValidationBarrier(1000, gossiper.quit) gossiper.vb = NewValidationBarrier(1000, gossiper.quit)
gossiper.syncMgr = newSyncManager(&SyncManagerCfg{ gossiper.syncMgr = newSyncManager(&SyncManagerCfg{
ChainHash: cfg.ChainHash, ChainHash: cfg.ChainHash,
ChanSeries: cfg.ChanSeries, ChanSeries: cfg.ChanSeries,
RotateTicker: cfg.RotateTicker, RotateTicker: cfg.RotateTicker,
HistoricalSyncTicker: cfg.HistoricalSyncTicker, HistoricalSyncTicker: cfg.HistoricalSyncTicker,
NumActiveSyncers: cfg.NumActiveSyncers, NumActiveSyncers: cfg.NumActiveSyncers,
NoTimestampQueries: cfg.NoTimestampQueries, NoTimestampQueries: cfg.NoTimestampQueries,
IgnoreHistoricalFilters: cfg.IgnoreHistoricalFilters, IgnoreHistoricalFilters: cfg.IgnoreHistoricalFilters,
BestHeight: gossiper.latestHeight, BestHeight: gossiper.latestHeight,
PinnedSyncers: cfg.PinnedSyncers, PinnedSyncers: cfg.PinnedSyncers,
IsStillZombieChannel: cfg.IsStillZombieChannel, IsStillZombieChannel: cfg.IsStillZombieChannel,
AllotedMsgBytesPerSecond: cfg.MsgRateBytes,
AllotedMsgBytesBurst: cfg.MsgBurstBytes,
}) })
gossiper.reliableSender = newReliableSender(&reliableSenderCfg{ gossiper.reliableSender = newReliableSender(&reliableSenderCfg{

View File

@@ -5,6 +5,7 @@ import (
"time" "time"
"github.com/lightningnetwork/lnd/discovery" "github.com/lightningnetwork/lnd/discovery"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route" "github.com/lightningnetwork/lnd/routing/route"
) )
@@ -32,6 +33,10 @@ type Gossip struct {
SubBatchDelay time.Duration `long:"sub-batch-delay" description:"The duration to wait before sending the next announcement batch if there are multiple. Use a small value if there are a lot announcements and they need to be broadcast quickly."` SubBatchDelay time.Duration `long:"sub-batch-delay" description:"The duration to wait before sending the next announcement batch if there are multiple. Use a small value if there are a lot announcements and they need to be broadcast quickly."`
AnnouncementConf uint32 `long:"announcement-conf" description:"The number of confirmations required before processing channel announcements."` AnnouncementConf uint32 `long:"announcement-conf" description:"The number of confirmations required before processing channel announcements."`
MsgRateBytes uint64 `long:"msg-rate-bytes" description:"The maximum number of bytes of gossip messages that will be sent per second. This is a global limit that applies to all peers."`
MsgBurstBytes uint64 `long:"msg-burst-bytes" description:"The maximum number of bytes of gossip messages that will be sent in a burst. This is a global limit that applies to all peers. This value should be set to something greater than 130 KB"`
} }
// Parse the pubkeys for the pinned syncers. // Parse the pubkeys for the pinned syncers.
@@ -58,6 +63,11 @@ func (g *Gossip) Validate() error {
"%v", g.AnnouncementConf, minAnnouncementConf) "%v", g.AnnouncementConf, minAnnouncementConf)
} }
if g.MsgBurstBytes < lnwire.MaxSliceLength {
return fmt.Errorf("msg-burst-bytes=%v must be at least %v",
g.MsgBurstBytes, lnwire.MaxSliceLength)
}
return nil return nil
} }

View File

@@ -1746,6 +1746,17 @@
; The number of confirmations required before processing channel announcements. ; The number of confirmations required before processing channel announcements.
; gossip.announcement-conf=6 ; gossip.announcement-conf=6
; The allotted bandwidth rate expressed in bytes/second that will be allocated
; towards outbound gossip messages. Realized rates above this value will be
; throttled. This value is shared across all peers.
; gossip.msg-rate-bytes=102400
; The amount of bytes of gossip messages that can be sent at a given time. This
; is used as the amount of tokens in the token bucket algorithm. This value
; MUST be set to something about 65 KB, otherwise a single max sized message
; can never be sent.
; gossip.msg-burst-bytes=204800
[invoices] [invoices]
; If a hold invoice has accepted htlcs that reach their expiry height and are ; If a hold invoice has accepted htlcs that reach their expiry height and are

View File

@@ -1188,6 +1188,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
IsStillZombieChannel: s.graphBuilder.IsZombieChannel, IsStillZombieChannel: s.graphBuilder.IsZombieChannel,
ScidCloser: scidCloserMan, ScidCloser: scidCloserMan,
AssumeChannelValid: cfg.Routing.AssumeChannelValid, AssumeChannelValid: cfg.Routing.AssumeChannelValid,
MsgRateBytes: cfg.Gossip.MsgRateBytes,
MsgBurstBytes: cfg.Gossip.MsgBurstBytes,
}, nodeKeyDesc) }, nodeKeyDesc)
accessCfg := &accessManConfig{ accessCfg := &accessManConfig{