Skip to content

Commit fd9d635

Browse files
committed
fix:progress channel announcement state when remote_sigs already in db
Fixes #8552 Changelog-Fixed: Channel announcements now work after restart even if peer doesn't resend announcement_signatures
1 parent 788ab8e commit fd9d635

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

lightningd/channel_gossip.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,14 @@ void channel_gossip_channel_reestablished(struct channel *channel)
12211221
* `announcement_signatures` for the funding transaction:
12221222
* - MUST send its own `announcement_signatures` message.
12231223
*/
1224+
1225+
1226+
if (channel->channel_gossip->state == CGOSSIP_WAITING_FOR_MATCHING_PEER_SIGS
1227+
&& channel->channel_gossip->remote_sigs) {
1228+
log_debug(channel->log, "channel_gossip: already have remote sigs, checking if we can progress");
1229+
update_gossip_state(channel);
1230+
}
1231+
12241232
/* We also always send a private channel_update, even if redundant
12251233
* (they might have lost it) */
12261234
switch (channel->channel_gossip->state) {

tests/test_gossip_announcement.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
from fixtures import * # noqa: F401,F403
2+
from pyln.testing.utils import wait_for
3+
import time
4+
import pytest
5+
6+
7+
def test_channel_announcement_after_restart_with_saved_sigs(node_factory, bitcoind):
8+
9+
l1, l2 = node_factory.line_graph(
10+
2,
11+
fundchannel=True,
12+
announce_channels=True,
13+
wait_for_announce=False,
14+
opts={'may_reconnect': True}
15+
)
16+
17+
bitcoind.generate_block(6)
18+
19+
wait_for(lambda: l1.rpc.listpeerchannels(l2.info['id'])['channels'][0]['state'] == 'CHANNELD_NORMAL')
20+
wait_for(lambda: l2.rpc.listpeerchannels(l1.info['id'])['channels'][0]['state'] == 'CHANNELD_NORMAL')
21+
22+
time.sleep(2)
23+
24+
channels_before = l1.rpc.listchannels()['channels']
25+
scid = l1.rpc.listpeerchannels(l2.info['id'])['channels'][0]['short_channel_id']
26+
27+
print(f"Channel SCID: {scid}")
28+
print(f"Channels before restart: {len(channels_before)}")
29+
30+
l1.rpc.disconnect(l2.info['id'], force=True)
31+
l1.restart()
32+
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
33+
34+
wait_for(lambda: l1.rpc.listpeerchannels(l2.info['id'])['channels'][0]['state'] == 'CHANNELD_NORMAL')
35+
36+
bitcoind.generate_block(6)
37+
38+
def channel_announced():
39+
channels = l1.rpc.listchannels(scid)['channels']
40+
return len(channels) == 2
41+
42+
wait_for(channel_announced, timeout=30)
43+
44+
channels = l1.rpc.listchannels(scid)['channels']
45+
assert len(channels) == 2
46+
print(f"SUCCESS: Both channel directions announced after restart!")
47+
48+
49+
def test_channel_announcement_reconnect_without_restart(node_factory, bitcoind):
50+
l1, l2 = node_factory.line_graph(
51+
2,
52+
fundchannel=True,
53+
announce_channels=True,
54+
wait_for_announce=True,
55+
opts={'may_reconnect': True}
56+
)
57+
58+
scid = l1.rpc.listpeerchannels(l2.info['id'])['channels'][0]['short_channel_id']
59+
60+
channels = l1.rpc.listchannels(scid)['channels']
61+
assert len(channels) == 2
62+
63+
l1.rpc.disconnect(l2.info['id'], force=True)
64+
time.sleep(1)
65+
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
66+
67+
wait_for(lambda: l1.rpc.listpeerchannels(l2.info['id'])['channels'][0]['state'] == 'CHANNELD_NORMAL')
68+
69+
channels = l1.rpc.listchannels(scid)['channels']
70+
assert len(channels) == 2
71+
print(f"SUCCESS: Channel still announced after reconnect!")

0 commit comments

Comments
 (0)