Skip to content

Commit 27a0569

Browse files
committed
multi: make ProofMatureDelta configurable
We add a new config option to set the `ProofMatureDelta` so the users can tune their graphs based on their own preference over the num of confs found in the announcement signatures.
1 parent e0a920a commit 27a0569

File tree

5 files changed

+46
-3
lines changed

5 files changed

+46
-3
lines changed

config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ func DefaultConfig() Config {
694694
MaxChannelUpdateBurst: discovery.DefaultMaxChannelUpdateBurst,
695695
ChannelUpdateInterval: discovery.DefaultChannelUpdateInterval,
696696
SubBatchDelay: discovery.DefaultSubBatchDelay,
697+
AnnouncementConf: discovery.DefaultProofMatureDelta,
697698
},
698699
Invoices: &lncfg.Invoices{
699700
HoldExpiryDelta: lncfg.DefaultHoldInvoiceExpiryDelta,
@@ -1754,6 +1755,7 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
17541755
cfg.Invoices,
17551756
cfg.Routing,
17561757
cfg.Pprof,
1758+
cfg.Gossip,
17571759
)
17581760
if err != nil {
17591761
return nil, err

discovery/gossiper.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ const (
6262
// we'll maintain. This is the global size across all peers. We'll
6363
// allocate ~3 MB max to the cache.
6464
maxRejectedUpdates = 10_000
65+
66+
// DefaultProofMatureDelta specifies the default value used for
67+
// ProofMatureDelta, which is the number of confirmations needed before
68+
// processing the announcement signatures.
69+
DefaultProofMatureDelta = 6
6570
)
6671

6772
var (
@@ -1984,8 +1989,14 @@ func (d *AuthenticatedGossiper) addNode(msg *lnwire.NodeAnnouncement,
19841989
// NOTE: must be used inside a lock.
19851990
func (d *AuthenticatedGossiper) isPremature(chanID lnwire.ShortChannelID,
19861991
delta uint32, msg *networkMsg) bool {
1987-
// TODO(roasbeef) make height delta 6
1988-
// * or configurable
1992+
1993+
// The channel is already confirmed at chanID.BlockHeight so we minus
1994+
// one block. For instance, if the required confirmation for this
1995+
// channel announcement is 6, we then only need to wait for 5 more
1996+
// blocks once the funding tx is confirmed.
1997+
if delta > 0 {
1998+
delta--
1999+
}
19892000

19902001
msgHeight := chanID.BlockHeight + delta
19912002

lncfg/gossip.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
package lncfg
22

33
import (
4+
"fmt"
45
"time"
56

67
"github.com/lightningnetwork/lnd/discovery"
78
"github.com/lightningnetwork/lnd/routing/route"
89
)
910

11+
// minAnnouncementConf defines the minimal num of confs needed for the config
12+
// AnnouncementConf. We choose 3 here as it's unlikely a reorg depth of 3 would
13+
// happen.
14+
//
15+
// NOTE: The specs recommends setting this value to 6, which is the default
16+
// value used for AnnouncementConf. However the receiver should be able to
17+
// decide which channels to be included in its local graph, more details can be
18+
// found:
19+
// - https://github.com/lightning/bolts/pull/1215#issuecomment-2557337202
20+
const minAnnouncementConf = 3
21+
1022
//nolint:ll
1123
type Gossip struct {
1224
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 a hex-encoded pubkey, the flag can be specified multiple times to add multiple peers. Connected peers matching this pubkey will remain active for the duration of the connection and not count towards the NumActiveSyncer count."`
@@ -18,6 +30,8 @@ type Gossip struct {
1830
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."`
1931

2032
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."`
33+
34+
AnnouncementConf uint32 `long:"announcement-conf" description:"The number of confirmations required before processing channel announcements."`
2135
}
2236

2337
// Parse the pubkeys for the pinned syncers.
@@ -35,3 +49,17 @@ func (g *Gossip) Parse() error {
3549

3650
return nil
3751
}
52+
53+
// Validate checks the Gossip configuration to ensure that the input values are
54+
// sane.
55+
func (g *Gossip) Validate() error {
56+
if g.AnnouncementConf < minAnnouncementConf {
57+
return fmt.Errorf("announcement-conf=%v must be no less than "+
58+
"%v", g.AnnouncementConf, minAnnouncementConf)
59+
}
60+
61+
return nil
62+
}
63+
64+
// Compile-time constraint to ensure Gossip implements the Validator interface.
65+
var _ Validator = (*Gossip)(nil)

sample-lnd.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,8 @@
17291729
; be broadcast quickly.
17301730
; gossip.sub-batch-delay=5s
17311731

1732+
; The number of confirmations required before processing channel announcements.
1733+
; gossip.announcement-conf=6
17321734

17331735
[invoices]
17341736

server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
11181118

11191119
return s.genNodeAnnouncement(nil)
11201120
},
1121-
ProofMatureDelta: 0,
1121+
ProofMatureDelta: cfg.Gossip.AnnouncementConf,
11221122
TrickleDelay: time.Millisecond * time.Duration(cfg.TrickleDelay),
11231123
RetransmitTicker: ticker.New(time.Minute * 30),
11241124
RebroadcastInterval: time.Hour * 24,

0 commit comments

Comments
 (0)