From 7409a93d17f50358877ca22b5d09171446e587df Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 20 Jul 2023 12:10:52 +0930 Subject: [PATCH] gossipd: when we dump our own gossip, include our node_announcement. @endothermicdev and I found this while investigating a "nobody sees my node_announcement" bug report. Signed-off-by: Rusty Russell Fixes: #6410 Reported-by: benjaminchodroff on discord Changelog-Fixed: Protocol: When we send our own gossip when a peer connects, send our node_announcement too (regression in v23.05) --- gossipd/gossipd.c | 4 ++++ tests/test_gossip.py | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index 524602221..94b7a196b 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -459,6 +459,10 @@ static void dump_our_gossip(struct daemon *daemon, struct peer *peer) if (is_halfchan_defined(&chan->half[dir])) queue_peer_from_store(peer, &chan->half[dir].bcast); } + + /* If we have one, we should send our own node_announcement */ + if (me->bcast.index) + queue_peer_from_store(peer, &me->bcast); } /*~ This is where connectd tells us about a new peer we might want to diff --git a/tests/test_gossip.py b/tests/test_gossip.py index 01157b5f0..c0afc9cc2 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -1383,9 +1383,10 @@ def test_gossipwith(node_factory): check=True, timeout=TIMEOUT, stdout=subprocess.PIPE).stdout - num_msgs = 0 + msgs = set() while len(out): l, t = struct.unpack('>HH', out[0:4]) + msg = out[2:2 + l] out = out[2 + l:] # Ignore pings, timestamp_filter @@ -1393,10 +1394,11 @@ def test_gossipwith(node_factory): continue # channel_announcement node_announcement or channel_update assert t == 256 or t == 257 or t == 258 - num_msgs += 1 + msgs.add(msg) # one channel announcement, two channel_updates, two node announcements. - assert num_msgs == 7 + # due to initial blast, we can have duplicates! + assert len(msgs) == 5 def test_gossip_notices_close(node_factory, bitcoind):