Skip to content

Release tx_signatures after async monitor update completes#4472

Open
wpaulino wants to merge 1 commit intolightningdevkit:mainfrom
wpaulino:release-tx-signatures-after-async-monitor-update-completion
Open

Release tx_signatures after async monitor update completes#4472
wpaulino wants to merge 1 commit intolightningdevkit:mainfrom
wpaulino:release-tx-signatures-after-async-monitor-update-completion

Conversation

@wpaulino
Copy link
Contributor

@wpaulino wpaulino commented Mar 9, 2026

In 83b2d3e, we reworked ChannelManager::funding_transaction_signed such that it would also for a user to cancel a splice up until they send commitment_signed. Previously, we would would only emit Event::FundingTransactionReadyForSigning when both nodes exchanged commitment_signed and the corresponding monitor update completed. With the event now being generated immediately after the nodes exchange tx_complete, we now need to handle the monitor update not having completed by the time we are ready to send tx_signatures. Unfortunately, we also did not have test coverage, allowing this to go unnoticed until being caught by the fuzzer due to a debug assertion. Doing so avoids a potential funds-loss scenario if the funding transaction confirms without the counterparty's signature for our commitment being durably persisted.

@wpaulino wpaulino added this to the 0.3 milestone Mar 9, 2026
@wpaulino wpaulino requested a review from TheBlueMatt March 9, 2026 18:04
@wpaulino wpaulino self-assigned this Mar 9, 2026
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Mar 9, 2026

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

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 86.42857% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.00%. Comparing base (36d04c3) to head (c8c5dc0).
⚠️ Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/channel.rs 82.29% 16 Missing and 1 partial ⚠️
lightning/src/ln/channelmanager.rs 95.12% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4472      +/-   ##
==========================================
- Coverage   86.08%   86.00%   -0.08%     
==========================================
  Files         159      159              
  Lines      105186   105489     +303     
  Branches   105186   105489     +303     
==========================================
+ Hits        90546    90727     +181     
- Misses      12131    12249     +118     
- Partials     2509     2513       +4     
Flag Coverage Δ
tests 86.00% <86.42%> (-0.08%) ⬇️

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

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

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

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

@ldk-claude-review-bot
Copy link
Collaborator

ldk-claude-review-bot commented Mar 14, 2026

Automated Review (Updated)

After extensive re-analysis of all code paths (monitor_updating_restored, tx_signatures_received, signer_maybe_unblocked, channel_reestablish, funding_transaction_signed, and handle_channel_resumption), my three prior concerns have been re-evaluated and found to be incorrect:

  1. "Stale monitor_pending_tx_signatures flag" — The flag is correctly cleared unconditionally at line 9129, outside any conditional block. No stale flag issue exists.

  2. "State mutation discarded on disconnect" — The funding_tx_signed IS returned through MonitorRestoreUpdates even when is_peer_disconnected() is true (line 9229). handle_channel_resumption correctly broadcasts the splice tx and emits SplicePending outside the is_connected() guard, while properly withholding messages for retransmission via channel_reestablish.

  3. "Missing monitor-update guard for holder-sends-first" — The early return at line 8903 checks self.is_awaiting_monitor_update() unconditionally, before any reference to holder_tx_signatures. All cases are guarded.

No new issues found. The logic correctly handles all examined scenarios including async signer + async monitor update combinations, disconnection during pending monitor updates, and reconnection with tx_signatures retransmission.

🤖 Generated with Claude Code

@ldk-reviews-bot
Copy link

🔔 3rd 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.

@ldk-reviews-bot
Copy link

✅ Added second reviewer: @tankyleo

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Aside from what claude noted I didn't see any issues.

@wpaulino wpaulino force-pushed the release-tx-signatures-after-async-monitor-update-completion branch from c8c5dc0 to 86fa38c Compare March 16, 2026 18:07
@wpaulino wpaulino requested review from jkczyz and removed request for tankyleo March 16, 2026 18:07
In 83b2d3e, we reworked `ChannelManager::funding_transaction_signed`
such that it would also for a user to cancel a splice up until they send
`commitment_signed`. Previously, we would would only emit
`Event::FundingTransactionReadyForSigning` when both nodes exchanged
`commitment_signed` and the corresponding monitor update completed. With
the event now being generated immediately after the nodes exchange
`tx_complete`, we now need to handle the monitor update not having
completed by the time we are ready to send `tx_signatures`.
Unfortunately, we also did not have test coverage, allowing this to go
unnoticed until being caught by the fuzzer due to a debug assertion.
Doing so avoids a potential funds-loss scenario if the funding
transaction confirms without the counterparty's signature for our
commitment being durably persisted.
@wpaulino wpaulino force-pushed the release-tx-signatures-after-async-monitor-update-completion branch from 86fa38c to ec60d8e Compare March 16, 2026 18:39
@TheBlueMatt
Copy link
Collaborator

Needs rebase now.

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.

4 participants