mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-18 05:13:36 +01:00
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.
This commit is contained in:
parent
e0a920af44
commit
27a05694cb
@ -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,
|
||||
@ -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
|
||||
|
@ -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 (
|
||||
@ -1984,8 +1989,14 @@ 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
|
||||
|
||||
// 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.
|
||||
if delta > 0 {
|
||||
delta--
|
||||
}
|
||||
|
||||
msgHeight := chanID.BlockHeight + delta
|
||||
|
||||
|
@ -1,12 +1,24 @@
|
||||
package lncfg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/lightningnetwork/lnd/discovery"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
)
|
||||
|
||||
// minAnnouncementConf defines the minimal num of confs needed for the config
|
||||
// AnnouncementConf. We choose 3 here as it's unlikely a reorg depth of 3 would
|
||||
// happen.
|
||||
//
|
||||
// NOTE: The specs recommends setting this value to 6, which is the default
|
||||
// value used for AnnouncementConf. However the receiver should be able to
|
||||
// decide which channels to be included in its local graph, more details can be
|
||||
// found:
|
||||
// - https://github.com/lightning/bolts/pull/1215#issuecomment-2557337202
|
||||
const minAnnouncementConf = 3
|
||||
|
||||
//nolint:ll
|
||||
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 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 {
|
||||
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.
|
||||
@ -35,3 +49,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 < minAnnouncementConf {
|
||||
return fmt.Errorf("announcement-conf=%v must be no less than "+
|
||||
"%v", g.AnnouncementConf, minAnnouncementConf)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Compile-time constraint to ensure Gossip implements the Validator interface.
|
||||
var _ Validator = (*Gossip)(nil)
|
||||
|
@ -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]
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user