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 1 commit 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.

Depends on #3774.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jun 2, 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.

@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 27.77778% with 117 lines in your changes missing coverage. Please review.

Project coverage is 89.77%. Comparing base (0848e7a) to head (5f0709f).
Report is 28 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/chain/channelmonitor.rs 7.93% 116 Missing ⚠️
lightning/src/chain/chainmonitor.rs 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3822      +/-   ##
==========================================
- Coverage   89.88%   89.77%   -0.11%     
==========================================
  Files         160      162       +2     
  Lines      129654   130264     +610     
  Branches   129654   130264     +610     
==========================================
+ Hits       116534   116949     +415     
- Misses      10425    10609     +184     
- Partials     2695     2706      +11     

☔ 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

👋 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 renegotiated-funding-monitor-update branch from 6c78591 to ac8c8c5 Compare June 9, 2025 00:35
@wpaulino wpaulino requested a review from jkczyz June 9, 2025 00:35
@tankyleo tankyleo self-requested a review June 9, 2025 19:55
Copy link
Contributor

@tankyleo tankyleo left a comment

Choose a reason for hiding this comment

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

First pass in channel monitor

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.
@wpaulino wpaulino force-pushed the renegotiated-funding-monitor-update branch from ac8c8c5 to 5f0709f Compare June 10, 2025 18:58
@wpaulino wpaulino requested a review from TheBlueMatt June 10, 2025 18:58
@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.

Copy link
Contributor

@tankyleo tankyleo left a comment

Choose a reason for hiding this comment

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

stared at the code again today, picked up nits on the way.

fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
write_tlv_fields!(w, {
(1, self.channel_parameters, (required: ReadableArgs, None)),
(3, self.current_counterparty_commitment_txid, required),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Could we set this to option, and elide the field entirely if it is set to None ?

Comment on lines +1889 to +1890
let funding_outpoint = funding.channel_parameters.funding_outpoint
.as_ref().unwrap().into_bitcoin_outpoint();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: let funding_outpoint = funding.funding_outpoint().into_bitcoin_outpoint(); ?

debug_assert!(alternative_htlcs.len() <= current_counterparty_commitment_htlcs.len());
for (alternative_htlc, (htlc, _)) in alternative_htlcs.iter().zip(htlcs_with_sources.iter_mut()) {
debug_assert!(alternative_htlc.transaction_output_index.is_some());
debug_assert!(alternative_htlc.is_data_equal(htlc));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I would have also added debug_assert!(htlc.transaction_output_index.is_some()) here to make sure we are not turning a previously dust HTLC into a non-dust HTLC.

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