Skip to content

Commit

Permalink
multi: make ProofMatureDelta configurable
Browse files Browse the repository at this point in the history
We add a new config option to set the `ProofMatureDelta` so the users
can tune their graphs based on their own perference over the num of
confs found in the announcement signatures.
  • Loading branch information
yyforyongyu committed Jan 9, 2025
1 parent a388c1f commit 5a526b8
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ func DefaultConfig() Config {
MaxChannelUpdateBurst: discovery.DefaultMaxChannelUpdateBurst,
ChannelUpdateInterval: discovery.DefaultChannelUpdateInterval,
SubBatchDelay: discovery.DefaultSubBatchDelay,
AnnouncementConf: discovery.DefaultProofMatureDelta,
},
Invoices: &lncfg.Invoices{
HoldExpiryDelta: lncfg.DefaultHoldInvoiceExpiryDelta,
Expand Down Expand Up @@ -1754,6 +1755,7 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
cfg.Invoices,
cfg.Routing,
cfg.Pprof,
cfg.Gossip,
)
if err != nil {
return nil, err
Expand Down
13 changes: 10 additions & 3 deletions discovery/gossiper.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ const (
// we'll maintain. This is the global size across all peers. We'll
// allocate ~3 MB max to the cache.
maxRejectedUpdates = 10_000

// DefaultProofMatureDelta specifies the default value used for
// ProofMatureDelta, which is the number of confirmations needed before
// processing the announcement signatures.
DefaultProofMatureDelta = 6
)

var (
Expand Down Expand Up @@ -1984,10 +1989,12 @@ func (d *AuthenticatedGossiper) addNode(msg *lnwire.NodeAnnouncement,
// NOTE: must be used inside a lock.
func (d *AuthenticatedGossiper) isPremature(chanID lnwire.ShortChannelID,
delta uint32, msg *networkMsg) bool {
// TODO(roasbeef) make height delta 6
// * or configurable

msgHeight := chanID.BlockHeight + delta
// The channel is already confirmed at chanID.BlockHeight so we minus
// one block. For instance, if the required confirmation for this
// channel announcement is 6, we then only need to wait for 5 more
// blocks once the funding tx is confirmed.
msgHeight := chanID.BlockHeight + delta - 1

// The message height is smaller or equal to our best known height,
// thus the message is mature.
Expand Down
5 changes: 5 additions & 0 deletions docs/release-notes/release-notes-0.19.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@
range TLVs provided with the existing set of records on the HTLC,
overwriting any conflicting values with those supplied by the API.

* [Make](https://github.com/lightningnetwork/lnd/pull/9405) the param
`ProofMatureDelta` used in gossip to be configurable via
`--gossip.announcement-conf`, with a default value of 5.

## lncli Updates

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


## Breaking Changes
## Performance Improvements

Expand Down
17 changes: 17 additions & 0 deletions lncfg/gossip.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package lncfg

import (
"fmt"
"time"

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

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."`
}

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

return nil
}

// Validate checks the Gossip configuration to ensure that the input values are
// sane.
func (g *Gossip) Validate() error {
if g.AnnouncementConf <= 3 {
return fmt.Errorf("announcement-conf=%v must be no less than 3",
g.AnnouncementConf)
}

return nil
}

// Compile-time constraint to ensure Gossip implements the Validator interface.
var _ Validator = (*Gossip)(nil)
2 changes: 2 additions & 0 deletions sample-lnd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1729,6 +1729,8 @@
; be broadcast quickly.
; gossip.sub-batch-delay=5s

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

[invoices]

Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,

return s.genNodeAnnouncement(nil)
},
ProofMatureDelta: 0,
ProofMatureDelta: cfg.Gossip.AnnouncementConf,
TrickleDelay: time.Millisecond * time.Duration(cfg.TrickleDelay),
RetransmitTicker: ticker.New(time.Minute * 30),
RebroadcastInterval: time.Hour * 24,
Expand Down

0 comments on commit 5a526b8

Please sign in to comment.