discovery: ensure we prioritize sending out our own local announcements

In this commit, we modify our gossip broadcast logic to ensure that we
always will send out our own gossip messages regardless of the
filtering/feature policies of the peer.

Before this commit, it was possible that when we went to broadcast an
announcement, none of our peers actually had us as a syncer peer (lnd
terminology). In this case, the FilterGossipMsg function wouldn't do
anything, as they don't have an active timestamp filter set. When we go
to them merge the syncer map, we'd add all these peers we didn't send
to, meaning we would skip them when it came to broadcast time.

In this commit, we now split things into two phases: we'll broadcast
_our_ own announcements to all our peers, but then do the normal
filtering and chunking for the announcements we got from a remote peer.

Fixes https://github.com/lightningnetwork/lnd/issues/6531
Fixes https://github.com/lightningnetwork/lnd/issues/7223
Fixes https://github.com/lightningnetwork/lnd/issues/7073
This commit is contained in:
Olaoluwa Osuntokun committed 2022-12-15 11:56:41 -08:00
1 parent 9a4701d709
commit 52451b37af
2 files changed
+114 -57

No files matched your search

+15 -9
View File
@@ -1910,31 +1910,37 @@ func TestDeDuplicatedAnnouncements(t *testing.T) {
// Ensure that announcement batch delivers channel announcements,
// channel updates, and node announcements in proper order.
batch := announcements.Emit()
if len(batch) != 4 {
if batch.length() != 4 {
t.Fatal("announcement batch incorrect length")
}
if !reflect.DeepEqual(batch[0].msg, ca2) {
if !reflect.DeepEqual(batch.localMsgs[0].msg, ca2) {
t.Fatalf("channel announcement not first in batch: got %v, "+
"expected %v", spew.Sdump(batch[0].msg), spew.Sdump(ca2))
"expected %v", spew.Sdump(batch.localMsgs[0].msg),
spew.Sdump(ca2))
}
if !reflect.DeepEqual(batch[1].msg, ua3) {
if !reflect.DeepEqual(batch.localMsgs[1].msg, ua3) {
t.Fatalf("channel update not next in batch: got %v, "+
"expected %v", spew.Sdump(batch[1].msg), spew.Sdump(ua2))
"expected %v", spew.Sdump(batch.localMsgs[1].msg),
spew.Sdump(ua2))
}
// We'll ensure that both node announcements are present. We check both
// indexes as due to the randomized order of map iteration they may be
// in either place.
if !reflect.DeepEqual(batch[2].msg, na) && !reflect.DeepEqual(batch[3].msg, na) {
if !reflect.DeepEqual(batch.localMsgs[2].msg, na) &&
!reflect.DeepEqual(batch.localMsgs[3].msg, na) {
t.Fatalf("first node announcement not in last part of batch: "+
"got %v, expected %v", batch[2].msg,
"got %v, expected %v", batch.localMsgs[2].msg,
na)
}
if !reflect.DeepEqual(batch[2].msg, na5) && !reflect.DeepEqual(batch[3].msg, na5) {
if !reflect.DeepEqual(batch.localMsgs[2].msg, na5) &&
!reflect.DeepEqual(batch.localMsgs[3].msg, na5) {
t.Fatalf("second node announcement not in last part of batch: "+
"got %v, expected %v", batch[3].msg,
"got %v, expected %v", batch.localMsgs[3].msg,
na5)
}