Skip to content

Lower strictness of pending monitor update while awaiting tx_signatures#4748

Merged
wpaulino merged 2 commits into
lightningdevkit:mainfrom
wpaulino:tx-signatures-unrelated-pending-monitor-update
Jun 26, 2026
Merged

Lower strictness of pending monitor update while awaiting tx_signatures#4748
wpaulino merged 2 commits into
lightningdevkit:mainfrom
wpaulino:tx-signatures-unrelated-pending-monitor-update

Conversation

@wpaulino

Copy link
Copy Markdown
Contributor

We previously assumed that no monitor update should ever be pending when receiving tx_signatures while quiescent, with the exception of the RenegotiatedFunding variant. This was a bit too strict, as we did not consider that if an HTLC was sent via the same channel, its preimage could be received from upstream leading to a monitor update to durably persist it.

This commit ensures that if the recipient of a tx_signatures has not yet echoed theirs back, and it is awaiting a monitor update completion, then the pending monitor update must be of the RenegotiatedFunding variant. If the pending monitor update is of another variant, then we must remain quiescent with no pending updates available to send until after the tx_signatures exchange.

Fixes #4729.

@wpaulino wpaulino requested review from TheBlueMatt and jkczyz June 24, 2026 23:57
@wpaulino wpaulino self-assigned this Jun 24, 2026
@ldk-reviews-bot

ldk-reviews-bot commented Jun 24, 2026

Copy link
Copy Markdown

👋 Thanks for assigning @jkczyz 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.

@ldk-claude-review-bot

ldk-claude-review-bot commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

No issues found.

I re-reviewed all hunks in this PR (the loosened debug_asserts in on_tx_signatures_exchange at channel.rs:9533-9536, the gating change at channel.rs:9689, the removed reestablish-time expecting_peer_commitment_signed = true at channel.rs:10647, and the new test in splicing_tests.rs). The logic is internally consistent:

  • The hold-back guard now only triggers when both is_awaiting_monitor_update() and monitor_pending_tx_signatures hold, correctly allowing the tx_signatures exchange to proceed when only an unrelated monitor update (e.g. an HTLC preimage persist) is pending.
  • Both call sites of on_tx_signatures_exchange satisfy the loosened asserts (tx_signatures() only reaches it when the guard is false; monitor_updating_restored clears monitor_pending_tx_signatures at channel.rs:9923 before invoking it).

No new defects beyond my prior pass.

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.94%. Comparing base (6965bc9) to head (b8a76c1).
⚠️ Report is 3224 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4748      +/-   ##
==========================================
+ Coverage   84.55%   86.94%   +2.39%     
==========================================
  Files         137      161      +24     
  Lines       77617   111632   +34015     
  Branches    77617   111632   +34015     
==========================================
+ Hits        65627    97064   +31437     
- Misses       9948    12060    +2112     
- Partials     2042     2508     +466     
Flag Coverage Δ
fuzzing-fake-hashes 8.43% <0.00%> (?)
fuzzing-real-hashes 32.40% <80.00%> (?)
tests 86.27% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

Comment thread lightning/src/ln/channel.rs Outdated
splice_locked: None,
};
if self.is_awaiting_monitor_update() {
if self.is_awaiting_monitor_update() && holder_tx_signatures.is_some() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure I understand this, isn't it the case that we can get a pending monitor update from a preimage no matter the state, so shouldn't we be able to hit this even if we don't have a holder sigs to send? Shouldn't we instead move the monitor_pending_tx_signatures check into the if here?

)));
}

if !session.has_received_commitment_signed() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you explain this change? Maybe in the commit message?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

At least according to the docs on expecting_peer_commitment_signed, we were using it incorrectly as it's only meant for channel updates. If it was being used as a signal to disconnect if not sent in a timely manner, then it's unnecessary to track this as we're already quiescent within this path and can rely on that signal instead to disconnect.

Comment thread lightning/src/ln/channel.rs Outdated
splice_locked: None,
};
if self.is_awaiting_monitor_update() {
if self.is_awaiting_monitor_update() && holder_tx_signatures.is_some() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If holder_tx_signatures is None will we hit the debug_assert in the else clause below on line 9715?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think that's reachable because we can't process their tx_signatures without processing their initial commitment_signed first, and we only process that after the user has called back with funding_transaction_signed.

wpaulino added 2 commits June 25, 2026 15:59
The use of `expecting_peer_commitment_signed` was being used as a way to
signal that we must disconnect if the message is not sent in a timely
manner. This isn't necessary, as we're already quiescent within this
flow, and can disconnect via that signal instead.
We previously assumed that no monitor update should ever be pending when
receiving `tx_signatures` while quiescent, with the exception of the
`RenegotiatedFunding` variant. This was a bit too strict, as we did not
consider that if an HTLC was sent via the same channel, its preimage
could be received from upstream leading to a monitor update to durably
persist it.

This commit ensures that if the recipient of a `tx_signatures` has not
yet echoed theirs back, and it is awaiting a monitor update completion,
then the pending monitor update must be of the `RenegotiatedFunding`
variant. If the pending monitor update is of another variant, then we
must remain quiescent with no pending updates available to send until
after the `tx_signatures` exchange.
@wpaulino wpaulino force-pushed the tx-signatures-unrelated-pending-monitor-update branch from c583fa7 to b8a76c1 Compare June 25, 2026 22:59
@wpaulino wpaulino requested review from TheBlueMatt and jkczyz June 25, 2026 22:59

@jkczyz jkczyz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@wpaulino Will let you merge in case any of your other PRs conflict.

@wpaulino wpaulino merged commit 43ea836 into lightningdevkit:main Jun 26, 2026
24 checks passed
@wpaulino wpaulino deleted the tx-signatures-unrelated-pending-monitor-update branch June 26, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Splice tx_signatures assertion with unrelated monitor update pending

5 participants