lightningd: send announcement_signatures once channel is ready, don't wait until 6 deep.

The spec used to say you had to wait for channel to be ready, *and* 6
depth before exchanging signatures.  Now the 6 depth requirement is only
on the actual announcing of the channel: you can send sigs any time.

This means our state machine goes from:

  NOT_USABLE -> NOT_DEEP_ENOUGH -> NEED_PEER_SIGS -> ANNOUNCED

to:

  NOT_USABLE -> NEED_PEER_SIGS -> NOT_DEEP_ENOUGH -> ANNOUNCED

However, this revealed that our state machine is insufficient, so
rework it to be more general and understandable.  In particular,
check for unexpected state transitions, and thus document them.

Note that cg->sent_sigs replaces channel->replied_to_announcement_sigs,
too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Protocol: We now exchange `announcement_signatures` as soon as we're ready, rather than waiting for 6 blocks (as per recent BOLT update)
This commit is contained in:
Rusty Russell
2025-05-15 15:17:49 +09:30
parent 167767d683
commit 01a8d2b01a
5 changed files with 568 additions and 271 deletions

View File

@@ -322,7 +322,6 @@ struct channel *new_unsaved_channel(struct peer *peer,
/* Nothing happened yet */
memset(&channel->stats, 0, sizeof(channel->stats));
channel->state_changes = tal_arr(channel, struct channel_state_change *, 0);
channel->replied_to_announcement_sigs = false;
/* No shachain yet */
channel->their_shachain.id = 0;
@@ -633,7 +632,6 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
channel->num_onchain_spent_calls = 0;
channel->stats = *stats;
channel->state_changes = tal_steal(channel, state_changes);
channel->replied_to_announcement_sigs = false;
/* Populate channel->channel_gossip */
channel_gossip_init(channel, take(peer_update));

View File

@@ -353,9 +353,6 @@ struct channel {
/* Our change history. */
struct channel_state_change **state_changes;
/* Have we replied to announcement_signatures once? */
bool replied_to_announcement_sigs;
};
/* Is channel owned (and should be talking to peer) */

File diff suppressed because it is too large Load Diff