Merge initial and retry stfu send paths#4432
Merge initial and retry stfu send paths#4432wpaulino wants to merge 2 commits intolightningdevkit:mainfrom
Conversation
In 15b04b5, we fixed a case in `FundedChannel::try_send_stfu` where we'd send `stfu` unnecessarily for a new splice while one is already pending. The same case also existed in `FundedChannel::send_stfu`, but was not fixed. There's no good reason for both of these methods to exist, so we merge them into one as `FundedChannel::try_send_stfu`. We also add a test that reproduces the `FundedChannel::send_stfu` issue to ensure it's fixed and does not regress.
With the introduction of `QuiescentAction`, the flag has essentially become duplicate state, so we opt to remove it in favor of just checking whether we have a pending `FundedChannel::quiescent_action`. Since the quiescent flags are never persisted, we can simply remove it and update the other flags, freeing up a bit for future use.
|
👋 Thanks for assigning @jkczyz as a reviewer! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4432 +/- ##
==========================================
- Coverage 85.87% 85.84% -0.03%
==========================================
Files 157 157
Lines 103769 103719 -50
Branches 103769 103719 -50
==========================================
- Hits 89115 89041 -74
- Misses 12158 12184 +26
+ Partials 2496 2494 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
lightning/src/ln/channel.rs
Outdated
| self.context.channel_state.clear_awaiting_quiescence(); | ||
| self.context.channel_state.clear_remote_stfu_sent(); | ||
| self.context.channel_state.set_quiescent(); | ||
| // We are sending an stfu in response to our couterparty's stfu, but had not yet sent |
| if self.context.channel_state.is_awaiting_quiescence() { | ||
| // We haven't been able to send `stfu` yet, and there's no point in attempting | ||
| // quiescence anymore since the counterparty wishes to close the channel. | ||
| self.context.channel_state.clear_awaiting_quiescence(); | ||
| } |
There was a problem hiding this comment.
If we have a QuiescenAction set, will we keep trying to send stfu?
| // TODO(splicing): If we didn't win quiescence, then we can contribute as an acceptor | ||
| // instead of waiting for the splice to lock. |
There was a problem hiding this comment.
Probably no need to worry since this is handled in #4416, but looks like this TODO wasn't moved.
lightning/src/ln/channel.rs
Outdated
| if self.context.channel_state.is_local_stfu_sent() | ||
| || self.context.channel_state.is_quiescent() | ||
| { | ||
| if self.quiescent_action.is_none() && !self.context.channel_state.is_remote_stfu_sent() { | ||
| return None; | ||
| } | ||
| if !self.context.channel_state.is_awaiting_quiescence() | ||
| && !self.context.channel_state.is_remote_stfu_sent() | ||
| if self.context.channel_state.is_local_stfu_sent() | ||
| || self.context.channel_state.is_quiescent() |
There was a problem hiding this comment.
nit: diff would be cleaner if the order of the if blocks wasn't flipped.
|
👋 The first review has been submitted! Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer. |
Fixes #4429.