Skip to content

Commit

Permalink
lightningd: don't force state if gossipd gives us an unexpected chann…
Browse files Browse the repository at this point in the history
…el_update.

This was triggered by the recover plugin tests (not yet merged!) and causes a crash
because we don't have signatures yet.  It can only happen if we lost our database,
but at least don't crash!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell authored and cdecker committed Feb 12, 2024
1 parent 1350194 commit 33af030
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions lightningd/channel_gossip.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@ enum channel_gossip_state {
CGOSSIP_ANNOUNCED,
};

static const char *channel_gossip_state_str(enum channel_gossip_state s)
{
switch (s) {
case CGOSSIP_PRIVATE:
return "CGOSSIP_PRIVATE";
case CGOSSIP_NOT_USABLE:
return "CGOSSIP_NOT_USABLE";
case CGOSSIP_NOT_DEEP_ENOUGH:
return "CGOSSIP_NOT_DEEP_ENOUGH";
case CGOSSIP_NEED_PEER_SIGS:
return "CGOSSIP_NEED_PEER_SIGS";
case CGOSSIP_ANNOUNCED:
return "CGOSSIP_ANNOUNCED";
}
return "***INVALID***";
}

struct remote_announce_sigs {
struct short_channel_id scid;
secp256k1_ecdsa_signature node_sig;
Expand Down Expand Up @@ -774,7 +791,7 @@ void channel_gossip_update_from_gossipd(struct channel *channel,
return;
}

/* If we didn't think it was announced already, it is now! */
/* We might still want signatures from peer (we lost state?) */
switch (channel->channel_gossip->state) {
case CGOSSIP_PRIVATE:
log_broken(channel->log,
Expand All @@ -784,8 +801,12 @@ void channel_gossip_update_from_gossipd(struct channel *channel,
case CGOSSIP_NOT_USABLE:
case CGOSSIP_NOT_DEEP_ENOUGH:
case CGOSSIP_NEED_PEER_SIGS:
set_gossip_state(channel, CGOSSIP_ANNOUNCED);
break;
if (taken(channel_update))
tal_free(channel_update);
log_broken(channel->log,
"gossipd gave us channel_update for channel in gossip_state %s",
channel_gossip_state_str(channel->channel_gossip->state));
return;
case CGOSSIP_ANNOUNCED:
break;
}
Expand Down

0 comments on commit 33af030

Please sign in to comment.