Skip to content

Commit

Permalink
discovery+lnd: remove unused param ProofMatureDelta
Browse files Browse the repository at this point in the history
This field is always set to 0 so we remove it.
  • Loading branch information
yyforyongyu committed Jan 7, 2025
1 parent a388c1f commit abeda3b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
21 changes: 6 additions & 15 deletions discovery/gossiper.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,6 @@ type Config struct {
// an updated timestamp which can be broadcast to our peers.
UpdateSelfAnnouncement func() (lnwire.NodeAnnouncement, error)

// ProofMatureDelta the number of confirmations which is needed before
// exchange the channel announcement proofs.
ProofMatureDelta uint32

// TrickleDelay the period of trickle timer which flushes to the
// network the pending batch of new announcements we've received since
// the last trickle tick.
Expand Down Expand Up @@ -1983,11 +1979,9 @@ 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
msg *networkMsg) bool {

msgHeight := chanID.BlockHeight + delta
msgHeight := chanID.BlockHeight

// The message height is smaller or equal to our best known height,
// thus the message is mature.
Expand Down Expand Up @@ -2483,7 +2477,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
// If the advertised inclusionary block is beyond our knowledge of the
// chain tip, then we'll ignore it for now.
d.Lock()
if nMsg.isRemote && d.isPremature(scid, 0, nMsg) {
if nMsg.isRemote && d.isPremature(scid, nMsg) {
log.Warnf("Announcement for chan_id=(%v), is premature: "+
"advertises height %v, only height %v is known",
scid.ToUint64(), scid.BlockHeight, d.bestHeight)
Expand Down Expand Up @@ -2861,7 +2855,7 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
// since aliases start at block height 16_000_000.
d.Lock()
if nMsg.isRemote && !d.cfg.IsAlias(upd.ShortChannelID) &&
d.isPremature(upd.ShortChannelID, 0, nMsg) {
d.isPremature(upd.ShortChannelID, nMsg) {

log.Warnf("Update announcement for short_chan_id(%v), is "+
"premature: advertises height %v, only height %v is "+
Expand Down Expand Up @@ -3234,8 +3228,7 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
func (d *AuthenticatedGossiper) handleAnnSig(nMsg *networkMsg,
ann *lnwire.AnnounceSignatures1) ([]networkMsg, bool) {

needBlockHeight := ann.ShortChannelID.BlockHeight +
d.cfg.ProofMatureDelta
needBlockHeight := ann.ShortChannelID.BlockHeight
shortChanID := ann.ShortChannelID.ToUint64()

prefix := "local"
Expand All @@ -3250,9 +3243,7 @@ func (d *AuthenticatedGossiper) handleAnnSig(nMsg *networkMsg,
// after some number of confirmations after channel was registered in
// bitcoin blockchain. Therefore, we check if the proof is mature.
d.Lock()
premature := d.isPremature(
ann.ShortChannelID, d.cfg.ProofMatureDelta, nMsg,
)
premature := d.isPremature(ann.ShortChannelID, nMsg)
if premature {
log.Warnf("Premature proof announcement, current block height"+
"lower than needed: %v < %v", d.bestHeight,
Expand Down
6 changes: 1 addition & 5 deletions discovery/gossiper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,6 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
TrickleDelay: trickleDelay,
RetransmitTicker: ticker.NewForce(retransmitDelay),
RebroadcastInterval: rebroadcastInterval,
ProofMatureDelta: proofMatureDelta,
WaitingProofStore: waitingProofStore,
MessageStore: newMockMessageStore(),
RotateTicker: ticker.NewForce(DefaultSyncerRotationInterval),
Expand Down Expand Up @@ -1473,7 +1472,6 @@ func TestSignatureAnnouncementRetryAtStartup(t *testing.T) {
TrickleDelay: trickleDelay,
RetransmitTicker: ticker.NewForce(retransmitDelay),
RebroadcastInterval: rebroadcastInterval,
ProofMatureDelta: proofMatureDelta,
WaitingProofStore: ctx.gossiper.cfg.WaitingProofStore,
MessageStore: ctx.gossiper.cfg.MessageStore,
RotateTicker: ticker.NewForce(DefaultSyncerRotationInterval),
Expand Down Expand Up @@ -3625,9 +3623,7 @@ func TestSplitAnnouncementsCorrectSubBatches(t *testing.T) {
lengthAnnouncementBatchSizes := len(announcementBatchSizes)
lengthExpectedNumberMiniBatches := len(expectedNumberMiniBatches)

batchSizeCalculator = func(totalDelay, subBatchDelay time.Duration,
minimumBatchSize, batchSize int) int {

batchSizeCalculator = func(_, _ time.Duration, _, _ int) int {
return subBatchSize
}

Expand Down
3 changes: 3 additions & 0 deletions docs/release-notes/release-notes-0.19.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ 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.

* [Remove](https://github.com/lightningnetwork/lnd/pull/9405) unused param
`ProofMatureDelta` used in gossip, which is always set to 0.

## Breaking Changes
## Performance Improvements

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

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

0 comments on commit abeda3b

Please sign in to comment.