From 1f929114d905c9df71342591dab7d210454bc35b Mon Sep 17 00:00:00 2001 From: Dusty Daemon Date: Sat, 12 Aug 2023 13:24:16 -0400 Subject: [PATCH] splice: STFU -> disable announce and commit timers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is a small chance these can fire during a splice or other STFU mode activity which shouldn’t be allowed to happen. Changelog-None --- channeld/channeld.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/channeld/channeld.c b/channeld/channeld.c index 5d3ae1dde..b0c7369ab 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -443,7 +443,11 @@ static void send_channel_update(struct peer *peer, int disable_flag) * they route through us */ static void send_channel_initial_update(struct peer *peer) { - send_channel_update(peer, 0); + /* If `stfu` is already active then the channel is being mutated quickly + * after creation. These mutations (ie. splice) must announce the + * channel when they finish anyway, so it is safe to skip it here */ + if (!is_stfu_active(peer)) + send_channel_update(peer, 0); } /** @@ -591,6 +595,12 @@ static void announce_channel(struct peer *peer) send_channel_update(peer, 0); } +static void announce_channel_if_not_stfu(struct peer *peer) +{ + if (!is_stfu_active(peer)) + announce_channel(peer); +} + /* Returns true if an announcement was sent */ static bool channel_announcement_negotiate(struct peer *peer) { @@ -665,7 +675,7 @@ static bool channel_announcement_negotiate(struct peer *peer) /* Give other nodes time to notice new block. */ notleak(new_reltimer(&peer->timers, peer, time_from_sec(GOSSIP_ANNOUNCE_DELAY(peer->dev_fast_gossip)), - announce_channel, peer)); + announce_channel_if_not_stfu, peer)); } return sent_announcement; @@ -1722,6 +1732,18 @@ static void send_commit(struct peer *peer) start_commit_timer(peer); } +static void send_commit_if_not_stfu(struct peer *peer) +{ + if (!is_stfu_active(peer)) { + send_commit(peer); + } + else { + /* Timer now considered expired, you can add a new one. */ + peer->commit_timer = NULL; + start_commit_timer(peer); + } +} + static void start_commit_timer(struct peer *peer) { /* Already armed? */ @@ -1730,7 +1752,7 @@ static void start_commit_timer(struct peer *peer) peer->commit_timer = new_reltimer(&peer->timers, peer, time_from_msec(peer->commit_msec), - send_commit, peer); + send_commit_if_not_stfu, peer); } /* If old_secret is NULL, we don't care, otherwise it is filled in. */