config: expose gossip.pinned-syncers for conf

The pinned syncer set is exposed as a comma-separated list of pubkeys.
This commit is contained in:
Conner Fromknecht 2021-01-29 00:14:21 -08:00
parent 2371fc5a8e
commit fcd5cb625a
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
5 changed files with 59 additions and 0 deletions

View File

@ -309,6 +309,8 @@ type Config struct {
Routing *lncfg.Routing `group:"routing" namespace:"routing"`
Gossip *lncfg.Gossip `group:"gossip" namespace:"gossip"`
Workers *lncfg.Workers `group:"workers" namespace:"workers"`
Caches *lncfg.Caches `group:"caches" namespace:"caches"`
@ -477,6 +479,7 @@ func DefaultConfig() Config {
Backoff: defaultTLSBackoff,
},
},
Gossip: &lncfg.Gossip{},
MaxOutgoingCltvExpiry: htlcswitch.DefaultMaxOutgoingCltvExpiry,
MaxChannelFeeAllocation: htlcswitch.DefaultMaxLinkFeeAllocation,
MaxCommitFeeRateAnchors: lnwallet.DefaultAnchorsCommitMaxFeeRateSatPerVByte,
@ -1289,6 +1292,10 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
maxRemoteHtlcs)
}
if err := cfg.Gossip.Parse(); err != nil {
return nil, err
}
// Validate the subconfigs for workers, caches, and the tower client.
err = lncfg.Validate(
cfg.Workers,

View File

@ -237,6 +237,11 @@ type Config struct {
// gossip updates to once per RebroadcastInterval for any keep-alive
// updates, and once per block for other types of updates.
GossipUpdateThrottle bool
// PinnedSyncers is a set of peers that will always transition to
// ActiveSync upon connection. These peers will never transition to
// PassiveSync.
PinnedSyncers PinnedSyncers
}
// AuthenticatedGossiper is a subsystem which is responsible for receiving
@ -338,6 +343,7 @@ func New(cfg Config, selfKey *btcec.PublicKey) *AuthenticatedGossiper {
NumActiveSyncers: cfg.NumActiveSyncers,
IgnoreHistoricalFilters: cfg.IgnoreHistoricalFilters,
BestHeight: gossiper.latestHeight,
PinnedSyncers: cfg.PinnedSyncers,
})
gossiper.reliableSender = newReliableSender(&reliableSenderCfg{

28
lncfg/gossip.go Normal file
View File

@ -0,0 +1,28 @@
package lncfg
import (
"github.com/lightningnetwork/lnd/discovery"
"github.com/lightningnetwork/lnd/routing/route"
)
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
}
// Parse the pubkeys for the pinned syncers.
func (g *Gossip) Parse() error {
pinnedSyncers := make(discovery.PinnedSyncers)
for _, pubkeyStr := range g.PinnedSyncersRaw {
vertex, err := route.NewVertexFromStr(pubkeyStr)
if err != nil {
return err
}
pinnedSyncers[vertex] = struct{}{}
}
g.PinnedSyncers = pinnedSyncers
return nil
}

View File

@ -1019,3 +1019,20 @@ litecoin.node=ltcd
; Specify the timeout to be used when opening the database.
; db.bolt.dbtimeout=60s
[gossip]
; Specify a set of pinned gossip syncers, which will always be actively syncing
; whenever the corresponding peer is online. A pinned syncer does not count
; towards the configured `numgraphsyncpeers` since pinned syncers are not
; rotated. Configuring a pinned syncer does not ensure a persistent connection
; to the target peer, they will only be pinned if the connection remains active
; via some other mechanism, e.g. having an open channel.
;
; This feature is useful when trying to ensure that a node keeps its
; routing table tightly synchronized with a set of remote peers, e.g. multiple
; lightning nodes operated by the same service.
;
; Each value should be a hex-encoded pubkey of the pinned peer. Multiple pinned
; peers can be specified by setting multiple flags/fields in the config.
; gossip.pinned-syncers=pubkey1
; gossip.pinned-syncers=pubkey2

View File

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