Skip to content

Commit e4096d8

Browse files
committed
gossipd: don't shortcut dying phase for local channels.
This means that we won't complain to peers which gossip about our channels, but it does mean that our channel graph (like other nodes on the network) will show two channels, not one, for the duration. For this reason, we need askrene to omit local dying channels. Signed-off-by: Rusty Russell <[email protected]>
1 parent 816e4ea commit e4096d8

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

gossipd/gossmap_manage.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,6 @@ void gossmap_manage_channel_spent(struct gossmap_manage *gm,
13171317
struct short_channel_id scid)
13181318
{
13191319
struct gossmap_chan *chan;
1320-
const struct gossmap_node *me;
13211320
const u8 *msg;
13221321
struct chan_dying cd;
13231322
struct gossmap *gossmap = gossmap_manage_get_gossmap(gm);
@@ -1326,14 +1325,6 @@ void gossmap_manage_channel_spent(struct gossmap_manage *gm,
13261325
if (!chan)
13271326
return;
13281327

1329-
me = gossmap_find_node(gossmap, &gm->daemon->id);
1330-
/* We delete our own channels immediately, since we have local knowledge */
1331-
if (gossmap_nth_node(gossmap, chan, 0) == me
1332-
|| gossmap_nth_node(gossmap, chan, 1) == me) {
1333-
kill_spent_channel(gm, gossmap, scid);
1334-
return;
1335-
}
1336-
13371328
/* Is it already dying? It's lightningd re-telling us */
13381329
if (channel_already_dying(gm->dying_channels, scid))
13391330
return;

plugins/askrene/askrene.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ static struct command_result *do_getroutes(struct command *cmd,
573573
struct route **routes;
574574
struct flow **flows;
575575
struct json_stream *response;
576+
const struct gossmap_node *me;
576577

577578
/* update the gossmap */
578579
if (gossmap_refresh(askrene->gossmap)) {
@@ -593,6 +594,30 @@ static struct command_result *do_getroutes(struct command *cmd,
593594
rq->additional_costs = info->additional_costs;
594595
rq->maxparts = info->maxparts;
595596

597+
/* We also eliminate any local channels we *know* are dying.
598+
* Most channels get 12 blocks grace in case it's a splice,
599+
* but if it's us, we know about the splice already. */
600+
me = gossmap_find_node(rq->gossmap, &askrene->my_id);
601+
if (me) {
602+
for (size_t i = 0; i < me->num_chans; i++) {
603+
struct short_channel_id_dir scidd;
604+
const struct gossmap_chan *c = gossmap_nth_chan(rq->gossmap,
605+
me, i, NULL);
606+
if (!gossmap_chan_is_dying(rq->gossmap, c))
607+
continue;
608+
609+
scidd.scid = gossmap_chan_scid(rq->gossmap, c);
610+
/* Disable both directions */
611+
for (scidd.dir = 0; scidd.dir < 2; scidd.dir++) {
612+
bool enabled = false;
613+
gossmap_local_updatechan(localmods,
614+
&scidd,
615+
&enabled,
616+
NULL, NULL, NULL, NULL, NULL);
617+
}
618+
}
619+
}
620+
596621
/* apply selected layers to the localmods */
597622
apply_layers(askrene, rq, &info->source, info->amount, localmods,
598623
info->layers, info->local_layer);

tests/test_closing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,8 +1851,8 @@ def test_onchaind_replay(node_factory, bitcoind):
18511851

18521852
# Wait for nodes to notice the failure, this seach needle is after the
18531853
# DB commit so we're sure the tx entries in onchaindtxs have been added
1854-
l1.daemon.wait_for_log("Deleting channel .* due to the funding outpoint being spent")
1855-
l2.daemon.wait_for_log("Deleting channel .* due to the funding outpoint being spent")
1854+
l1.daemon.wait_for_log("closing soon due to the funding outpoint being spent")
1855+
l2.daemon.wait_for_log("closing soon due to the funding outpoint being spent")
18561856

18571857
# We should at least have the init tx now
18581858
assert len(l1.db_query("SELECT * FROM channeltxs;")) > 0

tests/test_misc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,8 +1488,8 @@ def no_more_blocks(req):
14881488

14891489
l1.rpc.close(l2.info['id'])
14901490
bitcoind.generate_block(1, True)
1491-
l1.daemon.wait_for_log(r'Deleting channel')
1492-
l2.daemon.wait_for_log(r'Deleting channel')
1491+
l1.daemon.wait_for_log(r'closing soon due to the funding outpoint being spent')
1492+
l2.daemon.wait_for_log(r'closing soon due to the funding outpoint being spent')
14931493

14941494

14951495
@pytest.mark.openchannel('v1')

0 commit comments

Comments
 (0)