Skip to content

Commit

Permalink
gossipd: load and store node_announcements correctly
Browse files Browse the repository at this point in the history
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
  • Loading branch information
endothermicdev committed Mar 1, 2023
1 parent d5246e4 commit d1402e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gossipd/gossip_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions gossipd/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d1402e0

Please sign in to comment.