From b55ff34f93bc3dbee68df7774f82c47ac8d85490 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 22 Sep 2019 10:59:01 +0930 Subject: [PATCH] gossipd: fix corner case where gossip msg too old after pending delay. Happened under Travis with --dev-fast-gossip (90 second prune time), but can happen anyway if gossip is almost 2 weeks old when we receive it: 2019-09-20T19:16:51.367Z DEBUG lightning_gossipd(20972): Received node_announcement for node 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59 2019-09-20T19:16:51.376Z DEBUG lightning_gossipd(20972): Ignoring node_announcement timestamp 1569006918 for 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59 2019-09-20T19:16:51.669Z **BROKEN** lightning_gossipd(20972): pending node_announcement 01013094af771d60f4de69bb39ce045e4edf4a06fe6c80078dfa4fab58ab5617d6ad4fa34b6d3437380db0a8293cea348bbc77f714ef71fcd8515bfc82336667441f00005d852546022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59022d2253494c454e544152544953542d633961313734610000000000000000000000000000 malformed? (version c9a174a) Signed-off-by: Rusty Russell --- gossipd/routing.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gossipd/routing.c b/gossipd/routing.c index 70a1b6c51..d44bc4635 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -1454,13 +1454,12 @@ static void process_pending_node_announcement(struct routing_state *rstate, "Processing deferred node_announcement for node %s", type_to_string(pna, struct node_id, nodeid)); - /* Should not error, since we processed it before */ + /* Can fail it timestamp is now too old */ if (!routing_add_node_announcement(rstate, pna->node_announcement, pna->index)) - status_failed(STATUS_FAIL_INTERNAL_ERROR, - "pending node_announcement %s malformed?", - tal_hex(tmpctx, pna->node_announcement)); + status_unusual("pending node_announcement %s too old?", + tal_hex(tmpctx, pna->node_announcement)); /* Never send this again. */ pna->node_announcement = tal_free(pna->node_announcement); } @@ -1836,13 +1835,15 @@ bool handle_pending_cannouncement(struct routing_state *rstate, pending_cannouncement_map_del(&rstate->pending_cannouncements, pending); tal_del_destructor2(pending, destroy_pending_cannouncement, rstate); + /* Can fail if channel_announcement too old */ if (!routing_add_channel_announcement(rstate, pending->announce, sat, 0)) - status_failed(STATUS_FAIL_INTERNAL_ERROR, - "Could not add channel_announcement"); - - /* Did we have an update waiting? If so, apply now. */ - process_pending_channel_update(rstate, scid, pending->updates[0]); - process_pending_channel_update(rstate, scid, pending->updates[1]); + status_unusual("Could not add channel_announcement %s: too old?", + tal_hex(tmpctx, pending->announce)); + else { + /* Did we have an update waiting? If so, apply now. */ + process_pending_channel_update(rstate, scid, pending->updates[0]); + process_pending_channel_update(rstate, scid, pending->updates[1]); + } tal_free(pending); return true;