Skip to content

Broadcast holder commitment for currently confirmed funding #3939

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

@wpaulino wpaulino commented Jul 17, 2025

A splice's FundingScope can only be promoted once a ChannelMonitorUpdateStep::RenegotiatedFundingLocked is applied, or if the monitor is no longer accepting updates, once the splice transaction is no longer under reorg risk. Because of this, our current FundingScope may not reflect the latest confirmed state in the chain. Before making a holder commitment broadcast, we must check which FundingScope is currently confirmed to ensure that it can propagate throughout the network.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jul 17, 2025

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

@wpaulino wpaulino removed the request for review from joostjager July 17, 2025 21:00
@wpaulino wpaulino force-pushed the splice-funding-commitment-broadcast branch from a783444 to a8ae4b7 Compare July 18, 2025 22:23
@wpaulino wpaulino requested a review from TheBlueMatt July 18, 2025 22:23
Copy link

codecov bot commented Jul 18, 2025

Codecov Report

❌ Patch coverage is 47.00000% with 106 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.76%. Comparing base (ecce268) to head (89ce01d).
⚠️ Report is 49 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/chain/channelmonitor.rs 43.24% 92 Missing and 13 partials ⚠️
lightning/src/chain/onchaintx.rs 93.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3939      +/-   ##
==========================================
- Coverage   88.93%   88.76%   -0.18%     
==========================================
  Files         174      173       -1     
  Lines      123842   124326     +484     
  Branches   123842   124326     +484     
==========================================
+ Hits       110142   110357     +215     
- Misses      11254    11553     +299     
+ Partials     2446     2416      -30     
Flag Coverage Δ
fuzzing ?
tests 88.76% <47.00%> (-0.01%) ⬇️

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

👋 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 force-pushed the splice-funding-commitment-broadcast branch from a8ae4b7 to 86b53fa Compare July 22, 2025 16:39
@wpaulino wpaulino requested a review from TheBlueMatt July 22, 2025 16:40
@wpaulino wpaulino force-pushed the splice-funding-commitment-broadcast branch from 86b53fa to 48629c7 Compare July 22, 2025 23:15
@jkczyz jkczyz self-requested a review July 23, 2025 18:18
@wpaulino wpaulino force-pushed the splice-funding-commitment-broadcast branch from 48629c7 to 60d97d0 Compare July 24, 2025 00:10
@wpaulino wpaulino requested a review from TheBlueMatt July 24, 2025 00:11
@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @jkczyz! 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 @jkczyz! 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.

@wpaulino wpaulino requested a review from TheBlueMatt July 29, 2025 01:09
@wpaulino wpaulino force-pushed the splice-funding-commitment-broadcast branch 3 times, most recently from 582ad71 to 511fdc8 Compare July 29, 2025 19:39
@ldk-reviews-bot
Copy link

🔔 3rd Reminder

Hey @jkczyz! 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.

debug_assert!(self.alternative_funding_confirmed.is_none());
self
.pending_funding
.drain(..)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like it needs to handle multiple incomplete 0conf fundings too, though - we can accept one 0conf splice then another before either confirm, or accept another after the first only has 1 conf. We'd need to handle that here by only dropping some fundings...

I kinda feel like we should just drop the last commit and do it later, rather than trying to support it right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah right, the key aspect here is that the zero conf splices chain upon one another, unlike RBFs.

@ldk-reviews-bot
Copy link

🔔 4th Reminder

Hey @TheBlueMatt @jkczyz! 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

🔔 1st Reminder

Hey @TheBlueMatt @jkczyz! 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

🔔 5th Reminder

Hey @TheBlueMatt @jkczyz! 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 @jkczyz! 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.

@wpaulino wpaulino requested a review from jkczyz August 4, 2025 21:40
@wpaulino wpaulino force-pushed the splice-funding-commitment-broadcast branch from 919b1d8 to 88b2c22 Compare August 4, 2025 21:40
debug_assert!(self.no_further_updates_allowed());
debug_assert_ne!(self.funding.funding_txid(), entry.txid);
if let Err(_) = self.promote_funding(entry.txid) {
log_error!(logger, "Missing scope for alternative funding confirmation with txid {}", entry.txid);
Copy link
Contributor

@jkczyz jkczyz Aug 5, 2025

Choose a reason for hiding this comment

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

When would this happen in practice? I assume it's some corner case, but is there any danger in this happening? What would a user do if it happened?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shouldn't happen at all. It would mean that the scope was somehow removed, and the only way to do that currently is via promote_funding. The monitor is already not accepting updates so that's good, but it could lead to not being able to claim funds from a closed channel.

Whether it's a splice, or a dual-funded RBF, we need to know which
funding transaction out of all of the negotiated ones is currently
confirmed in case we need to broadcast the holder commitment.
A `FundingScope` can only be promoted once a
`ChannelMonitorUpdateStep::RenegotiatedFundingLocked` is applied, or if
the monitor is no longer accepting updates, once the renegotiated
funding transaction is no longer under reorg risk. Because of this, our
current `FundingScope` may not reflect the latest confirmed state in the
chain. Before making a holder commitment broadcast, we must check which
`FundingScope` is currently confirmed to ensure that it can propogate
throughout the network.
@wpaulino wpaulino force-pushed the splice-funding-commitment-broadcast branch from 88b2c22 to 89ce01d Compare August 5, 2025 23:10
@wpaulino wpaulino requested a review from jkczyz August 5, 2025 23:11
Copy link
Contributor

@jkczyz jkczyz left a comment

Choose a reason for hiding this comment

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

LGTM, but should let @TheBlueMatt take a final pass as I'm not intimately familiar with this 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.

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.

A few assertion nits and one real question that IMO should be addressed, but doesn't have to be in this PR. Gonna land to unblock progress.

@TheBlueMatt TheBlueMatt merged commit de2005a into lightningdevkit:main Aug 6, 2025
23 of 25 checks passed
@wpaulino wpaulino deleted the splice-funding-commitment-broadcast branch August 6, 2025 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants