From 6ee2cd8ce37a5f5cef3632e696b277899a4e20bd Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 16 May 2019 09:04:16 +0930 Subject: [PATCH] openingd: fix hangup when gossipd compacts. My raspberry pi node hung up on my other node: lightning_openingd-... chan #1: Got bad message from gossipd: 0db1 This is because we didn't handle that message in one path. Signed-off-by: Rusty Russell --- openingd/openingd.c | 5 +++++ tests/test_gossip.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/openingd/openingd.c b/openingd/openingd.c index fb50803f0..49e6de205 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -1348,6 +1348,11 @@ static void handle_gossip_in(struct state *state) status_failed(STATUS_FAIL_GOSSIP_IO, "Reading gossip: %s", strerror(errno)); + if (fromwire_gossipd_new_store_fd(msg)) { + tal_free(msg); + new_gossip_store(GOSSIP_STORE_FD, fdpass_recv(GOSSIP_FD)); + return; + } handle_gossip_msg(PEER_FD, GOSSIP_STORE_FD, &state->cs, take(msg)); } diff --git a/tests/test_gossip.py b/tests/test_gossip.py index a06b157e1..acab91776 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -1080,3 +1080,18 @@ def test_gossip_store_private_channels(node_factory, bitcoind): # We should still see local channels! chans = l1.rpc.listchannels()['channels'] assert len(chans) == 2 + + +@unittest.skipIf(not DEVELOPER, "need dev-compact-gossip-store") +def test_gossip_store_compact(node_factory, bitcoind): + l1, l2, l3 = node_factory.line_graph(3, fundchannel=False) + + # Create channel. + l2.fund_channel(l3, 10**6) + + # Now compact store. + l2.rpc.call('dev-compact-gossip-store') + + # Should still be connected. + time.sleep(1) + assert len(l2.rpc.listpeers()['peers']) == 2