Skip to content

Introduce RenegotiatedFunding monitor update variant #3822

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wpaulino
Copy link
Contributor

@wpaulino wpaulino commented Jun 2, 2025

This is a new ChannelMonitorUpdateStep variant intended to be used whenever a new funding transaction for the channel has been negotiated via the InteractiveTxConstructor. This commit primarily focuses on its use for splices, but future work will expand where needed to support RBFs (both for the initial dual funding transaction, and splice transactions).

To draw a parallel to channel open, we generally want to have the commitment transactions negotiated for the funding transaction and committed to the respective ChannelMonitor before attempting to sign the funding transaction itself. This monitor update fulfills this need for a newly negotiated splice; it includes both the new holder and counterparty commitment transactions, and the new set of applicable ChannelTransactionParameters. Once the monitor update has been applied to the monitor and persisted, we allow the release of our tx_signatures for the splice transaction to wait for its confirmation.

Note: This currently doesn't build without some of the work done in #3736.

Depends on #3774.

wpaulino added 2 commits June 2, 2025 15:34
We shouldn't track our `HTLCSource`s within our
`HolderCommitmentTransaction`s duplicatively for each `FundingScope`.
With splicing, we may have alternative holder commitment transactions,
but they must all have the same set of non-dust and dust HTLCs as the
pre-spliced commitment transaction. Different sets of HTLCs are only
possible with a change to the dust limit on commitment transactions,
which the splicing protocol does not currently support.

This commit moves the `nondust_htlc_sources` and `dust_htlcs` fields
out from each `FundingScope` into the `ChannelMonitor`, such that they
can be reused for each `FundingScope`. This remains as a backwards
compatible change, the underlying stored data is not changed, but where
it lives in memory is.
This is a new `ChannelMonitorUpdateStep` variant intended to be used
whenever a new funding transaction for the channel has been negotiated
via the `InteractiveTxConstructor`. This commit primarily focuses on its
use for splices, but future work will expand where needed to support
RBFs (both for the initial dual funding transaction, and splice
transactions).

To draw a parallel to channel open, we generally want to have the
commitment transactions negotiated for the funding transaction and
committed to the respective `ChannelMonitor` before attempting to sign
the funding transaction itself. This monitor update fulfills this need
for a newly negotiated splice; it includes both the new holder
and counterparty commitment transactions, and the new set of applicable
`ChannelTransactionParameters`. Once the monitor update has been applied
to the monitor and persisted, we allow the release of our
`tx_signatures` for the splice transaction to wait for its confirmation.
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jun 2, 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 requested a review from jkczyz June 2, 2025 23:53
Copy link

codecov bot commented Jun 3, 2025

Codecov Report

Attention: Patch coverage is 57.34463% with 151 lines in your changes missing coverage. Please review.

Project coverage is 89.67%. Comparing base (5e7930f) to head (6c78591).
Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/chain/channelmonitor.rs 54.62% 139 Missing and 8 partials ⚠️
lightning/src/chain/chainmonitor.rs 42.85% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3822      +/-   ##
==========================================
- Coverage   89.75%   89.67%   -0.08%     
==========================================
  Files         159      160       +1     
  Lines      128906   129281     +375     
  Branches   128906   129281     +375     
==========================================
+ Hits       115697   115932     +235     
- Misses      10512    10639     +127     
- Partials     2697     2710      +13     

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

}

fn funding_txid(&self) -> Txid {
self.channel_parameters.funding_outpoint.as_ref().unwrap().txid
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use expect here, too?

Comment on lines +6013 to +6015
if msg.batch.is_some() {
return Err(ChannelError::close("Peer sent splice initial commitment_signed with a batch".to_owned()));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

May as well drop this given #3793.

Comment on lines +1679 to +1680
.map(|session| session.has_received_commitment_signed())
.unwrap_or(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you help me understand the difference between the case where session.has_received_commitment_signed() is false and where we don't have an interactive_tx_signing_session?

Comment on lines +6048 to +6049
let tx_signatures = self.interactive_tx_signing_session.as_mut()
.and_then(|session| session.received_commitment_signed());
Copy link
Contributor

Choose a reason for hiding this comment

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

When would we not have an interactive_tx_signing_session here?

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

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.

3 participants