gossipd: prune announced-but-not-updated channels eventually.

We currently give them a free pass.  The simplest fix is to give them
an old timestamp on initialization.

We still skip unannounced channels, on the assumption that they're
ours.  And we set the last_update_timestamp to -1 when we convert to
gossip_getchannels_entry to indicate no update.

This breaks the DEVELOPER=1 pruning test, since we hardcode the 1
week timeout.  That's fixed in the next patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-03-02 19:29:17 +10:30
committed by Christian Decker
parent b7ec2c8c9c
commit b7bf414ac4
3 changed files with 6 additions and 5 deletions

View File

@@ -1103,7 +1103,7 @@ static void append_half_channel(struct gossip_getchannels_entry **entries,
e->flags = c->flags; e->flags = c->flags;
e->public = (c->channel_update != NULL); e->public = (c->channel_update != NULL);
e->short_channel_id = c->short_channel_id; e->short_channel_id = c->short_channel_id;
e->last_update_timestamp = c->last_timestamp; e->last_update_timestamp = c->channel_update ? c->last_timestamp : -1;
if (e->last_update_timestamp >= 0) { if (e->last_update_timestamp >= 0) {
e->base_fee_msat = c->base_fee; e->base_fee_msat = c->base_fee;
e->fee_per_millionth = c->proportional_fee; e->fee_per_millionth = c->proportional_fee;
@@ -1385,8 +1385,7 @@ static void gossip_prune_network(struct daemon *daemon)
nc = connection_from(n, n->channels[i]); nc = connection_from(n, n->channels[i]);
/* FIXME: We still need to prune announced-but-not-updated channels after some time. */ if (!nc || !n->channels[i]->public) {
if (!nc || !nc->channel_update) {
/* Not even announced yet */ /* Not even announced yet */
continue; continue;
} }

View File

@@ -242,7 +242,9 @@ static struct node_connection *new_node_connection(struct routing_state *rstate,
c->unroutable_until = 0; c->unroutable_until = 0;
c->active = false; c->active = false;
c->flags = idx; c->flags = idx;
c->last_timestamp = -1; /* We haven't seen channel_update: give it an hour before we prune,
* which should be older than any update we'd see. */
c->last_timestamp = time_now().ts.tv_sec - (1209600 - 3600);
/* Hook it into in/out arrays. */ /* Hook it into in/out arrays. */
chan->connections[idx] = c; chan->connections[idx] = c;

View File

@@ -1854,7 +1854,7 @@ class LightningDTests(BaseLightningDTests):
assert [c['active'] for c in l2.rpc.listchannels()['channels']] == [True, True] assert [c['active'] for c in l2.rpc.listchannels()['channels']] == [True, True]
assert [c['public'] for c in l2.rpc.listchannels()['channels']] == [True, True] assert [c['public'] for c in l2.rpc.listchannels()['channels']] == [True, True]
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1 for --dev-broadcast-interval") @unittest.skip("Temporarily broken for short pruning times")
def test_gossip_pruning(self): def test_gossip_pruning(self):
""" Create channel and see it being updated in time before pruning """ Create channel and see it being updated in time before pruning
""" """