Skip to content

Commit f6547b3

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 f6547b3

File tree

6 files changed

+40
-3
lines changed

6 files changed

+40
-3
lines changed

Diff for: config.go

+2
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

Diff for: discovery/gossiper.go

+13-2
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

Diff for: docs/release-notes/release-notes-0.19.0.md

+5
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@
170170
range TLVs provided with the existing set of records on the HTLC,
171171
overwriting any conflicting values with those supplied by the API.
172172

173+
* [Make](https://github.com/lightningnetwork/lnd/pull/9405) the param
174+
`ProofMatureDelta` used in gossip to be configurable via
175+
`--gossip.announcement-conf`, with a default value of 6.
176+
173177
## lncli Updates
174178

175179
## Code Health
@@ -214,6 +218,7 @@ config option](https://github.com/lightningnetwork/lnd/pull/9182) and introduce
214218
a new option `channel-max-fee-exposure` which is unambiguous in its description.
215219
The underlying functionality between those two options remain the same.
216220

221+
217222
## Breaking Changes
218223
## Performance Improvements
219224

Diff for: lncfg/gossip.go

+17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package lncfg
22

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

67
"github.com/lightningnetwork/lnd/discovery"
@@ -18,6 +19,8 @@ type Gossip struct {
1819
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."`
1920

2021
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."`
22+
23+
AnnouncementConf uint32 `long:"announcement-conf" description:"The number of confirmations required before processing channel announcements."`
2124
}
2225

2326
// Parse the pubkeys for the pinned syncers.
@@ -35,3 +38,17 @@ func (g *Gossip) Parse() error {
3538

3639
return nil
3740
}
41+
42+
// Validate checks the Gossip configuration to ensure that the input values are
43+
// sane.
44+
func (g *Gossip) Validate() error {
45+
if g.AnnouncementConf <= 3 {
46+
return fmt.Errorf("announcement-conf=%v must be no less than 3",
47+
g.AnnouncementConf)
48+
}
49+
50+
return nil
51+
}
52+
53+
// Compile-time constraint to ensure Gossip implements the Validator interface.
54+
var _ Validator = (*Gossip)(nil)

Diff for: sample-lnd.conf

+2
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

Diff for: server.go

+1-1
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)