Skip to content

Commit 1c2ff4a

Browse files
authored
Merge pull request #10232 from ellemouton/g175MessageFollowup
lnwire: add missing Gossip 1.75 fields and message
2 parents e386e2b + b8ff9fb commit 1c2ff4a

32 files changed

+1435
-136
lines changed

discovery/gossiper.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ type Config struct {
244244
// FetchSelfAnnouncement retrieves our current node announcement, for
245245
// use when determining whether we should update our peers about our
246246
// presence in the network.
247-
FetchSelfAnnouncement func() lnwire.NodeAnnouncement
247+
FetchSelfAnnouncement func() lnwire.NodeAnnouncement1
248248

249249
// UpdateSelfAnnouncement produces a new announcement for our node with
250250
// an updated timestamp which can be broadcast to our peers.
251-
UpdateSelfAnnouncement func() (lnwire.NodeAnnouncement, error)
251+
UpdateSelfAnnouncement func() (lnwire.NodeAnnouncement1, error)
252252

253253
// ProofMatureDelta the number of confirmations which is needed before
254254
// exchange the channel announcement proofs.
@@ -1186,7 +1186,7 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) {
11861186

11871187
// Node announcements are identified by the Vertex field. Use the
11881188
// NodeID to create the corresponding Vertex.
1189-
case *lnwire.NodeAnnouncement:
1189+
case *lnwire.NodeAnnouncement1:
11901190
sender := route.NewVertex(message.source)
11911191
deDupKey := route.Vertex(msg.NodeID)
11921192

@@ -1195,7 +1195,8 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) {
11951195
oldTimestamp := uint32(0)
11961196
mws, ok := d.nodeAnnouncements[deDupKey]
11971197
if ok {
1198-
oldTimestamp = mws.msg.(*lnwire.NodeAnnouncement).Timestamp
1198+
ann, _ := mws.msg.(*lnwire.NodeAnnouncement1)
1199+
oldTimestamp = ann.Timestamp
11991200
}
12001201

12011202
// Discard the message if it's old.
@@ -1806,7 +1807,7 @@ func (d *AuthenticatedGossiper) retransmitStaleAnns(ctx context.Context,
18061807
return nil
18071808
}
18081809

1809-
// We'll also check that our NodeAnnouncement is not too old.
1810+
// We'll also check that our NodeAnnouncement1 is not too old.
18101811
currentNodeAnn := d.cfg.FetchSelfAnnouncement()
18111812
timestamp := time.Unix(int64(currentNodeAnn.Timestamp), 0)
18121813
timeElapsed := now.Sub(timestamp)
@@ -2062,7 +2063,7 @@ func (d *AuthenticatedGossiper) fetchPKScript(chanID lnwire.ShortChannelID) (
20622063
// addNode processes the given node announcement, and adds it to our channel
20632064
// graph.
20642065
func (d *AuthenticatedGossiper) addNode(ctx context.Context,
2065-
msg *lnwire.NodeAnnouncement, op ...batch.SchedulerOption) error {
2066+
msg *lnwire.NodeAnnouncement1, op ...batch.SchedulerOption) error {
20662067

20672068
if err := netann.ValidateNodeAnn(msg); err != nil {
20682069
return fmt.Errorf("unable to validate node announcement: %w",
@@ -2153,7 +2154,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(ctx context.Context,
21532154
// A new node announcement has arrived which either presents new
21542155
// information about a node in one of the channels we know about, or a
21552156
// updating previously advertised information.
2156-
case *lnwire.NodeAnnouncement:
2157+
case *lnwire.NodeAnnouncement1:
21572158
return d.handleNodeAnnouncement(ctx, nMsg, msg, schedulerOp)
21582159

21592160
// A new channel announcement has arrived, this indicates the
@@ -2248,7 +2249,7 @@ func (d *AuthenticatedGossiper) processZombieUpdate(_ context.Context,
22482249
// announcement fields and returns an error if they are invalid to prevent
22492250
// forwarding invalid node announcements to our peers.
22502251
func (d *AuthenticatedGossiper) fetchNodeAnn(ctx context.Context,
2251-
pubKey [33]byte) (*lnwire.NodeAnnouncement, error) {
2252+
pubKey [33]byte) (*lnwire.NodeAnnouncement1, error) {
22522253

22532254
node, err := d.cfg.Graph.FetchNode(ctx, pubKey)
22542255
if err != nil {
@@ -2478,12 +2479,12 @@ func (d *AuthenticatedGossiper) latestHeight() uint32 {
24782479

24792480
// handleNodeAnnouncement processes a new node announcement.
24802481
func (d *AuthenticatedGossiper) handleNodeAnnouncement(ctx context.Context,
2481-
nMsg *networkMsg, nodeAnn *lnwire.NodeAnnouncement,
2482+
nMsg *networkMsg, nodeAnn *lnwire.NodeAnnouncement1,
24822483
ops []batch.SchedulerOption) ([]networkMsg, bool) {
24832484

24842485
timestamp := time.Unix(int64(nodeAnn.Timestamp), 0)
24852486

2486-
log.Debugf("Processing NodeAnnouncement: peer=%v, timestamp=%v, "+
2487+
log.Debugf("Processing NodeAnnouncement1: peer=%v, timestamp=%v, "+
24872488
"node=%x, source=%x", nMsg.peer, timestamp, nodeAnn.NodeID,
24882489
nMsg.source.SerializeCompressed())
24892490

@@ -2542,7 +2543,7 @@ func (d *AuthenticatedGossiper) handleNodeAnnouncement(ctx context.Context,
25422543
nMsg.err <- nil
25432544
// TODO(roasbeef): get rid of the above
25442545

2545-
log.Debugf("Processed NodeAnnouncement: peer=%v, timestamp=%v, "+
2546+
log.Debugf("Processed NodeAnnouncement1: peer=%v, timestamp=%v, "+
25462547
"node=%x, source=%x", nMsg.peer, timestamp, nodeAnn.NodeID,
25472548
nMsg.source.SerializeCompressed())
25482549

discovery/gossiper_test.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,8 @@ func (m *mockNotifier) Stop() error {
493493
}
494494

495495
type annBatch struct {
496-
nodeAnn1 *lnwire.NodeAnnouncement
497-
nodeAnn2 *lnwire.NodeAnnouncement
496+
nodeAnn1 *lnwire.NodeAnnouncement1
497+
nodeAnn2 *lnwire.NodeAnnouncement1
498498

499499
chanAnn *lnwire.ChannelAnnouncement1
500500

@@ -577,8 +577,8 @@ func (ctx *testCtx) createAnnouncements(blockHeight uint32, key1,
577577

578578
}
579579

580-
func createNodeAnnouncement(priv *btcec.PrivateKey,
581-
timestamp uint32, extraBytes ...[]byte) (*lnwire.NodeAnnouncement, error) {
580+
func createNodeAnnouncement(priv *btcec.PrivateKey, timestamp uint32,
581+
extraBytes ...[]byte) (*lnwire.NodeAnnouncement1, error) {
582582

583583
var err error
584584
k := hex.EncodeToString(priv.Serialize())
@@ -587,7 +587,7 @@ func createNodeAnnouncement(priv *btcec.PrivateKey,
587587
return nil, err
588588
}
589589

590-
a := &lnwire.NodeAnnouncement{
590+
a := &lnwire.NodeAnnouncement1{
591591
Timestamp: timestamp,
592592
Addresses: testAddrs,
593593
Alias: alias,
@@ -966,15 +966,15 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
966966
c := make(chan struct{})
967967
return c
968968
},
969-
FetchSelfAnnouncement: func() lnwire.NodeAnnouncement {
970-
return lnwire.NodeAnnouncement{
969+
FetchSelfAnnouncement: func() lnwire.NodeAnnouncement1 {
970+
return lnwire.NodeAnnouncement1{
971971
Timestamp: testTimestamp,
972972
}
973973
},
974-
UpdateSelfAnnouncement: func() (lnwire.NodeAnnouncement,
974+
UpdateSelfAnnouncement: func() (lnwire.NodeAnnouncement1,
975975
error) {
976976

977-
return lnwire.NodeAnnouncement{
977+
return lnwire.NodeAnnouncement1{
978978
Timestamp: testTimestamp,
979979
}, nil
980980
},
@@ -2285,7 +2285,7 @@ func TestForwardPrivateNodeAnnouncement(t *testing.T) {
22852285
case <-time.After(2 * trickleDelay):
22862286
}
22872287

2288-
// Now, we'll attempt to forward the NodeAnnouncement for the same node
2288+
// Now, we'll attempt to forward the NodeAnnouncement1 for the same node
22892289
// by opening a public channel on the network. We'll create a
22902290
// ChannelAnnouncement and hand it off to the gossiper in order to
22912291
// process it.
@@ -2312,8 +2312,9 @@ func TestForwardPrivateNodeAnnouncement(t *testing.T) {
23122312
t.Fatal("gossiper should have broadcast the channel announcement")
23132313
}
23142314

2315-
// We'll recreate the NodeAnnouncement with an updated timestamp to
2316-
// prevent a stale update. The NodeAnnouncement should now be forwarded.
2315+
// We'll recreate the NodeAnnouncement1 with an updated timestamp to
2316+
// prevent a stale update. The NodeAnnouncement1 should now be
2317+
// forwarded.
23172318
nodeAnn, err = createNodeAnnouncement(remoteKeyPriv1, timestamp+1)
23182319
require.NoError(t, err, "unable to create node announcement")
23192320

@@ -2897,7 +2898,7 @@ func TestExtraDataChannelUpdateValidation(t *testing.T) {
28972898
}
28982899

28992900
// TestExtraDataNodeAnnouncementValidation tests that we're able to properly
2900-
// validate a NodeAnnouncement that includes opaque bytes that we don't
2901+
// validate a NodeAnnouncement1 that includes opaque bytes that we don't
29012902
// currently know of.
29022903
func TestExtraDataNodeAnnouncementValidation(t *testing.T) {
29032904
t.Parallel()
@@ -3044,7 +3045,7 @@ func TestRetransmit(t *testing.T) {
30443045
chanAnn++
30453046
case *lnwire.ChannelUpdate1:
30463047
chanUpd++
3047-
case *lnwire.NodeAnnouncement:
3048+
case *lnwire.NodeAnnouncement1:
30483049
nodeAnn++
30493050
}
30503051
}

discovery/syncer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,7 @@ func (g *GossipSyncer) FilterGossipMsgs(ctx context.Context,
16531653

16541654
// Similarly, we only send node announcements if the update
16551655
// timestamp ifs between our set gossip filter time range.
1656-
case *lnwire.NodeAnnouncement:
1656+
case *lnwire.NodeAnnouncement1:
16571657
if passesFilter(msg.Timestamp) {
16581658
msgsToSend = append(msgsToSend, msg)
16591659
}

discovery/syncer_test.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,14 @@ func TestGossipSyncerFilterGossipMsgsNoHorizon(t *testing.T) {
249249
// through the gossiper to the target peer.
250250
msgs := []msgWithSenders{
251251
{
252-
msg: &lnwire.NodeAnnouncement{Timestamp: uint32(time.Now().Unix())},
252+
msg: &lnwire.NodeAnnouncement1{
253+
Timestamp: uint32(time.Now().Unix()),
254+
},
253255
},
254256
{
255-
msg: &lnwire.NodeAnnouncement{Timestamp: uint32(time.Now().Unix())},
257+
msg: &lnwire.NodeAnnouncement1{
258+
Timestamp: uint32(time.Now().Unix()),
259+
},
256260
},
257261
}
258262

@@ -308,15 +312,21 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
308312
msgs := []msgWithSenders{
309313
{
310314
// Node ann above horizon.
311-
msg: &lnwire.NodeAnnouncement{Timestamp: unixStamp(25001)},
315+
msg: &lnwire.NodeAnnouncement1{
316+
Timestamp: unixStamp(25001),
317+
},
312318
},
313319
{
314320
// Node ann below horizon.
315-
msg: &lnwire.NodeAnnouncement{Timestamp: unixStamp(5)},
321+
msg: &lnwire.NodeAnnouncement1{
322+
Timestamp: unixStamp(5),
323+
},
316324
},
317325
{
318326
// Node ann above horizon.
319-
msg: &lnwire.NodeAnnouncement{Timestamp: unixStamp(999999)},
327+
msg: &lnwire.NodeAnnouncement1{
328+
Timestamp: unixStamp(999999),
329+
},
320330
},
321331
{
322332
// Ann tuple below horizon.
@@ -737,7 +747,7 @@ func TestGossipSyncerReplyShortChanIDs(t *testing.T) {
737747
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
738748
Timestamp: unixStamp(999999),
739749
},
740-
&lnwire.NodeAnnouncement{Timestamp: unixStamp(25001)},
750+
&lnwire.NodeAnnouncement1{Timestamp: unixStamp(25001)},
741751
}
742752

743753
// We'll then craft a reply to the upcoming query for all the matching

discovery/validation_barrier.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (v *ValidationBarrier) InitJobDependencies(job interface{}) (JobID,
188188
populateDependencies(msg.ShortChannelID.String(), childJobID)
189189

190190
return childJobID, nil
191-
case *lnwire.NodeAnnouncement:
191+
case *lnwire.NodeAnnouncement1:
192192
childJobID := JobID(v.idCtr.Add(1))
193193
populateDependencies(
194194
route.Vertex(msg.NodeID).String(), childJobID,
@@ -242,7 +242,7 @@ func (v *ValidationBarrier) WaitForParents(childJobID JobID,
242242
v.Lock()
243243

244244
switch msg := job.(type) {
245-
// Any ChannelUpdate or NodeAnnouncement jobs will need to wait on the
245+
// Any ChannelUpdate or NodeAnnouncement1 jobs will need to wait on the
246246
// completion of any active ChannelAnnouncement jobs related to them.
247247
case *lnwire.ChannelUpdate1:
248248
annID = msg.ShortChannelID.String()
@@ -258,7 +258,7 @@ func (v *ValidationBarrier) WaitForParents(childJobID JobID,
258258
jobDesc = fmt.Sprintf("job=lnwire.ChannelUpdate, scid=%v",
259259
msg.ShortChannelID.ToUint64())
260260

261-
case *lnwire.NodeAnnouncement:
261+
case *lnwire.NodeAnnouncement1:
262262
annID = route.Vertex(msg.NodeID).String()
263263

264264
parentJobIDs, ok = v.jobDependencies[childJobID]
@@ -269,7 +269,7 @@ func (v *ValidationBarrier) WaitForParents(childJobID JobID,
269269
return nil
270270
}
271271

272-
jobDesc = fmt.Sprintf("job=lnwire.NodeAnnouncement, pub=%s",
272+
jobDesc = fmt.Sprintf("job=lnwire.NodeAnnouncement1, pub=%s",
273273
route.Vertex(msg.NodeID))
274274

275275
// Other types of jobs can be executed immediately, so we'll just
@@ -446,7 +446,7 @@ func (v *ValidationBarrier) SignalDependents(job interface{}, id JobID) error {
446446

447447
return nil
448448

449-
case *lnwire.NodeAnnouncement:
449+
case *lnwire.NodeAnnouncement1:
450450
// Remove child job info.
451451
return removeJob(route.Vertex(msg.NodeID).String(), id, true)
452452

discovery/validation_barrier_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func TestValidationBarrierQuit(t *testing.T) {
186186
}
187187

188188
// TestValidationBarrierParentJobsClear tests that creating two parent jobs for
189-
// ChannelUpdate / NodeAnnouncement will pause child jobs until the set of
189+
// ChannelUpdate / NodeAnnouncement1 will pause child jobs until the set of
190190
// parent jobs has cleared.
191191
func TestValidationBarrierParentJobsClear(t *testing.T) {
192192
t.Parallel()
@@ -230,14 +230,14 @@ func TestValidationBarrierParentJobsClear(t *testing.T) {
230230
parentID3, err := barrier.InitJobDependencies(ann3)
231231
require.NoError(t, err)
232232

233-
// Create the ChannelUpdate & NodeAnnouncement messages.
233+
// Create the ChannelUpdate & NodeAnnouncement1 messages.
234234
upd1 := &lnwire.ChannelUpdate1{
235235
ShortChannelID: sharedScid,
236236
}
237237
childID1, err := barrier.InitJobDependencies(upd1)
238238
require.NoError(t, err)
239239

240-
node1 := &lnwire.NodeAnnouncement{
240+
node1 := &lnwire.NodeAnnouncement1{
241241
NodeID: sharedNodeID,
242242
}
243243
childID2, err := barrier.InitJobDependencies(node1)

funding/manager.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ type Config struct {
398398
// CurrentNodeAnnouncement should return the latest, fully signed node
399399
// announcement from the backing Lightning Network node with a fresh
400400
// timestamp.
401-
CurrentNodeAnnouncement func() (lnwire.NodeAnnouncement, error)
401+
CurrentNodeAnnouncement func() (lnwire.NodeAnnouncement1, error)
402402

403403
// SendAnnouncement is used by the FundingManager to send announcement
404404
// messages to the Gossiper to possibly broadcast to the greater
@@ -3757,8 +3757,8 @@ func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
37573757
shortChanID *lnwire.ShortChannelID) error {
37583758

37593759
// If this channel is not meant to be announced to the greater network,
3760-
// we'll only send our NodeAnnouncement to our counterparty to ensure we
3761-
// don't leak any of our information.
3760+
// we'll only send our NodeAnnouncement1 to our counterparty to ensure
3761+
// we don't leak any of our information.
37623762
announceChan := completeChan.ChannelFlags&lnwire.FFAnnounceChannel != 0
37633763
if !announceChan {
37643764
log.Debugf("Will not announce private channel %v.",
@@ -3779,7 +3779,7 @@ func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
37793779
completeChan.FundingOutpoint,
37803780
)
37813781
pubKey := peer.PubKey()
3782-
log.Debugf("Sending our NodeAnnouncement for "+
3782+
log.Debugf("Sending our NodeAnnouncement1 for "+
37833783
"ChannelID(%v) to %x", chanID, pubKey)
37843784

37853785
// TODO(halseth): make reliable. If the peer is not online this
@@ -4724,7 +4724,7 @@ func (f *Manager) announceChannel(localIDKey, remoteIDKey *btcec.PublicKey,
47244724
graph.ErrIgnored) {
47254725

47264726
log.Debugf("Graph rejected "+
4727-
"NodeAnnouncement: %v", err)
4727+
"NodeAnnouncement1: %v", err)
47284728
} else {
47294729
log.Errorf("Unable to send node "+
47304730
"announcement: %v", err)

0 commit comments

Comments
 (0)