Skip to content

Allow counterparty pending monitor update within quiescence handshake #3806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

wpaulino
Copy link
Contributor

Previously, if we were negotiating quiescence, and we had already sent our stfu, we'd disconnect upon receiving the counterparty's stfu if we had a pending monitor update. This could result from processing a counterparty's final revoke_and_ack to an update, and immediately processing their stfu (which is valid from their point of view) without complete the monitor update. This was unintended, as we are able to track the quiescent and pending monitor update flags at the same time. Note that this commit still considers whether our signer owes any messages, as these are indicative of a channel update still pending.

Fixes #3805.

Previously, if we were negotiating quiescence, and we had already sent
our `stfu`, we'd disconnect upon receiving the counterparty's `stfu` if
we had a pending monitor update. This could result from processing a
counterparty's final `revoke_and_ack` to an update, and immediately
processing their `stfu` (which is valid from their point of view)
without complete the monitor update. This was unintended, as we are able
to track the quiescent and pending monitor update flags at the same
time. Note that this commit still considers whether our signer owes any
messages, as these are indicative of a channel update still pending.
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented May 28, 2025

👋 Thanks for assigning @TheBlueMatt as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

Copy link

codecov bot commented May 28, 2025

Codecov Report

Attention: Patch coverage is 96.07843% with 2 lines in your changes missing coverage. Please review.

Project coverage is 89.73%. Comparing base (5688166) to head (a5b3bd2).
Report is 37 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/quiescence_tests.rs 95.91% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3806      +/-   ##
==========================================
- Coverage   89.77%   89.73%   -0.04%     
==========================================
  Files         159      159              
  Lines      128828   128878      +50     
  Branches   128828   128878      +50     
==========================================
+ Hits       115650   115653       +3     
- Misses      10500    10537      +37     
- Partials     2678     2688      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wpaulino wpaulino requested review from jkczyz and removed request for joostjager May 28, 2025 18:10
@ldk-reviews-bot
Copy link

👋 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.

@wpaulino wpaulino requested a review from TheBlueMatt May 30, 2025 20:20
@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed this also fixes the issue for seed

export HEX="06000000001b000000000000020000000000000000200000be0000000000
000000000000ff0e0000a3a3a3a3a3a3a3a3a30015ffffffffffefff0000
000000ff"

which we just hit once more in #3804.

@ldk-reviews-bot
Copy link

🔔 2nd Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@@ -9675,10 +9675,14 @@ impl<SP: Deref> FundedChannel<SP> where
self.mark_response_received();

if self.context.is_waiting_on_peer_pending_channel_update()
|| self.context.is_monitor_or_signer_pending_channel_update()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if we receive a commitment_signed, causing us to go monitor_update_in_progress and prep to send an RAA in response? I guess in theory they're not supposed to send their stfu after they sent their CS because they're waiting on a response from us, but also probably we want to reject that because trying to handle splicing when we have two pending commitments seems annoying?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess in theory they're not supposed to send their stfu after they sent their CS because they're waiting on a response from us

This is allowed as long as the commitment_signed is not sent as a result of a local update. In any case, our implementation will accept an inbound stfu at any point, but it will hold back sending its own as a response until both is_waiting_on_peer_pending_channel_update and is_monitor_or_signer_pending_channel_update are false.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking in the context of where we'd already sent our stfu. AFAIU if we send a stfu, then they send a CS followed by an stfu (for a local update, because if it was in response to our update we shouldn't have sent our stfu). They may violate the protocol, but we really should be rejecting it explicitly because otherwise we're gonna respond with an RAA+CS and mark ourselves quiescent even though there are two valid commitment transactions pending (and have to deal with that when splicing, which we shouldn't have to).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this case is already covered. We can receive commitment_signed if:

  1. a local update was made, and we now owe them a final revoke_and_ack or
  2. a remote update was made, and we now owe them a revoke_and_ack + commitment_signed, and they owe us a final revoke_and_ack

In case 1, we cannot send stfu until the local update is no longer pending, so receiving stfu here doesn't change anything.
In case 2, we'll disconnect them if they send stfu immediately after commitment_signed because we're awaiting_remote_revoke (covered by is_waiting_on_peer_pending_channel_update).

@TheBlueMatt TheBlueMatt merged commit 6133a6c into lightningdevkit:main Jun 4, 2025
27 of 28 checks passed
@wpaulino wpaulino deleted the quiescence-final-raa-pending branch June 4, 2025 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fuzz Failure: Received counterparty stfu while having pending counterparty updates
5 participants