From 6fd1cfb3c1e7484cbaa99715d6de17ea4423375b Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 20 Aug 2020 16:25:22 +0930 Subject: [PATCH] gossipd: prune channels unless *both* peers have refreshed. See https://github.com/lightningnetwork/lightning-rfc/pull/767 Signed-off-by: Rusty Russell Changelog-Changed: Protocol: channels now pruned after two weeks unless both peers refresh it (see lightning-rfc#767) --- Makefile | 2 +- common/gossip_constants.h | 2 +- gossipd/gossipd.c | 2 +- gossipd/routing.c | 14 ++++++++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 439cca863141..dd28401e3623 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ CCANDIR := ccan # Where we keep the BOLT RFCs BOLTDIR := ../lightning-rfc/ -BOLTVERSION := b4132ff24025742ad8e175d52b68380520e9f0b7 +BOLTVERSION := 7e8c478aef0d23a445845b7d297b0e804583697c -include config.vars diff --git a/common/gossip_constants.h b/common/gossip_constants.h index 914dcd24f871..d23ac2d5f39a 100644 --- a/common/gossip_constants.h +++ b/common/gossip_constants.h @@ -58,7 +58,7 @@ /* BOLT #7: * * A node: - * - if a channel's latest `channel_update`s `timestamp` is older than two weeks + * - if a channel's oldest `channel_update`s `timestamp` is older than two weeks * (1209600 seconds): * - MAY prune the channel. * - MAY ignore the channel. diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index c838d4e33716..398dd7614cb4 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -725,7 +725,7 @@ static void gossip_send_keepalive_update(struct daemon *daemon, /* BOLT #7: * * A node: - * - if a channel's latest `channel_update`s `timestamp` is older than two weeks + * - if a channel's oldest `channel_update`s `timestamp` is older than two weeks * (1209600 seconds): * - MAY prune the channel. * - MAY ignore the channel. diff --git a/gossipd/routing.c b/gossipd/routing.c index 15704a43fb5a..26e8df2118bd 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -2777,10 +2777,16 @@ void route_prune(struct routing_state *rstate) if (!is_chan_public(chan)) continue; - if ((!is_halfchan_defined(&chan->half[0]) - || chan->half[0].bcast.timestamp < highwater) - && (!is_halfchan_defined(&chan->half[1]) - || chan->half[1].bcast.timestamp < highwater)) { + /* BOLT #7: + * - if a channel's oldest `channel_update`s `timestamp` is + * older than two weeks (1209600 seconds): + * - MAY prune the channel. + */ + /* This is a fancy way of saying "both ends must refresh!" */ + if (!is_halfchan_defined(&chan->half[0]) + || chan->half[0].bcast.timestamp < highwater + || !is_halfchan_defined(&chan->half[1]) + || chan->half[1].bcast.timestamp < highwater) { status_debug( "Pruning channel %s from network view (ages %"PRIu64" and %"PRIu64"s)", type_to_string(tmpctx, struct short_channel_id,