From d1402e06f9a8c18244d854ccc159326f0bab749a Mon Sep 17 00:00:00 2001 From: Alex Myers Date: Wed, 1 Mar 2023 12:59:44 -0600 Subject: [PATCH] gossipd: load and store node_announcements correctly Loading the gossip_store would not create a pending node announcement when the node already had a zombie channel. This would cause the node announcement to attempt to be loaded, but fail because it had no broadcastable channels. Accepting a pending node announcement as when normally loading from the channel corrects this. `node_has_public_channels` taking into account zombie channels enables this behavior. Separately, node_announcements were still being flagged as zombies in the gossip store despite that feature being removed. Changelog-None --- gossipd/gossip_store.c | 2 +- gossipd/routing.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gossipd/gossip_store.c b/gossipd/gossip_store.c index 968c138f6..6db129f58 100644 --- a/gossipd/gossip_store.c +++ b/gossipd/gossip_store.c @@ -884,7 +884,7 @@ u32 gossip_store_load(struct routing_state *rstate, struct gossip_store *gs) case WIRE_NODE_ANNOUNCEMENT: /* In early v23.02 rcs we had zombie node announcements, * so throw them away here. */ - if (be16_to_cpu(hdr.flags) & GOSSIP_STORE_ZOMBIE_BIT) { + if (zombie) { status_unusual("gossip_store: removing zombie" " node_announcement from v23.02 rcs"); break; diff --git a/gossipd/routing.c b/gossipd/routing.c index 11e0c5cd7..ef7693f1a 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -381,6 +381,13 @@ static struct node *new_node(struct routing_state *rstate, return n; } +static bool is_chan_zombie(struct chan *chan) +{ + if (chan->half[0].zombie || chan->half[1].zombie) + return true; + return false; +} + /* We've received a channel_announce for a channel attached to this node: * otherwise it's in the map only because it's a peer, or us. */ static bool node_has_public_channels(struct node *node) @@ -389,19 +396,12 @@ static bool node_has_public_channels(struct node *node) struct chan *c; for (c = first_chan(node, &i); c; c = next_chan(node, &i)) { - if (is_chan_public(c)) + if (is_chan_public(c) && !is_chan_zombie(c)) return true; } return false; } -static bool is_chan_zombie(struct chan *chan) -{ - if (chan->half[0].zombie || chan->half[1].zombie) - return true; - return false; -} - static bool is_node_zombie(struct node* node) { struct chan_map_iter i; @@ -1907,7 +1907,7 @@ bool routing_add_node_announcement(struct routing_state *rstate, = gossip_store_add(rstate->gs, msg, timestamp, node_id_eq(&node_id, &rstate->local_id), - is_node_zombie(node), spam, NULL); + false, spam, NULL); if (node->bcast.timestamp > rstate->last_timestamp && node->bcast.timestamp < time_now().ts.tv_sec) rstate->last_timestamp = node->bcast.timestamp;