Skip to content

Produce a single monitor update per commitment number #3738

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tankyleo
Copy link
Contributor

    Produce a single monitor update per commitment number
    
    Such updates will contain a single HTLC-source table for that
    commitment number, together with a vector of commitment transactions
    created at that commitment number. This vector will grow with the number
    of pending splices for a channel.
    
    The HTLC-source table produced by channel will stop storing information
    on which HTLCs were assigned which output index. Instead, this
    information will be stored in each commitment transaction in the
    monitor update.
    
    This commit deduplicates the `HTLCSource` collection for each commitment
    number, but `HTLCOutputData` would store information already stored in
    each `CommitmentTransaction` in a monitor update.
    
    This is a partial rework of b8a03cd. That commit has not been shipped in
    a release yet.

@ldk-reviews-bot
Copy link

👋 Hi! I see this is a draft PR.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

@tankyleo tankyleo force-pushed the one-update-per-commitment-number branch from 2adce74 to 829402c Compare April 15, 2025 17:11
@tankyleo
Copy link
Contributor Author

@TheBlueMatt this is what we've been discussing with @wpaulino can we get your impression of this approach ? Thank you.

@tankyleo
Copy link
Contributor Author

A high level overview of how I am thinking these new monitor updates will get produced on channel / tx-builder side:

Channel ───────────► HTLC Outputs─────────────────────► HTLC Outputs                        
                         │                                                     
                         │                                                     
                         │                                                     
                         │                                                     
                         └►──────► TX Builder ─────────► Commitment Transcation

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.

Design makes sense to me.

@wpaulino
Copy link
Contributor

wpaulino commented Apr 15, 2025

@TheBlueMatt note that going with this design will mean undoing a good chunk of the work in #3664 to no longer keep the non-dust sources separate. Should be fine as long as we get it shipped in the same release.

(2, commitment_txs, required_vec),
(4, claimed_htlcs, required_vec),
},
(7, LatestCounterpartyCommitmentTXs) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be even, and the members below should be odd

Comment on lines 673 to 675
(0, htlc_data, required_vec),
(2, commitment_txs, required_vec),
(4, claimed_htlcs, required_vec),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be odd

Comment on lines 609 to 612
(0, offered, required),
(2, amount_msat, required),
(4, cltv_expiry, required),
(6, payment_hash, required),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be odd

@tankyleo tankyleo force-pushed the one-update-per-commitment-number branch 2 times, most recently from 8fd9765 to 0b93e43 Compare April 16, 2025 02:49
Copy link

codecov bot commented Apr 16, 2025

Codecov Report

Attention: Patch coverage is 40.42553% with 28 lines in your changes missing coverage. Please review.

Project coverage is 89.19%. Comparing base (83e9e80) to head (0b93e43).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/chain/channelmonitor.rs 6.89% 27 Missing ⚠️
lightning/src/ln/channel.rs 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3738      +/-   ##
==========================================
+ Coverage   89.12%   89.19%   +0.06%     
==========================================
  Files         156      156              
  Lines      123514   123984     +470     
  Branches   123514   123984     +470     
==========================================
+ Hits       110086   110582     +496     
+ Misses      10749    10734      -15     
+ Partials     2679     2668      -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.

Such updates will contain a single HTLC-source table for that
commitment number, together with a vector of commitment transactions
created at that commitment number. This vector will grow with the number
of pending splices for a channel.

The HTLC-source table produced by channel will stop storing information
on which HTLCs were assigned which output index. Instead, this
information will be stored in each commitment transaction in the
monitor update.

This commit deduplicates the `HTLCSource` collection for each commitment
number, but `HTLCOutputData` would store information already stored in
each `CommitmentTransaction` in a monitor update.

This is a partial rework of b8a03cd. That commit has not been shipped in
a release yet.
@tankyleo tankyleo force-pushed the one-update-per-commitment-number branch from 0b93e43 to 8ac0358 Compare April 16, 2025 03:06
@TheBlueMatt
Copy link
Collaborator

@TheBlueMatt note that going with this design will mean undoing a good chunk of the work in #3664 to no longer keep the non-dust sources separate. Should be fine as long as we get it shipped in the same release.

Why do we not want to keep them separate now?

@tankyleo
Copy link
Contributor Author

@TheBlueMatt note that going with this design will mean undoing a good chunk of the work in #3664 to no longer keep the non-dust sources separate. Should be fine as long as we get it shipped in the same release.

Why do we not want to keep them separate now?

The HTLC-source table now no longer holds "dust-vs-nondust" data; that information is now solely stored in each CommitmentTransaction.

So in the updates, we no longer have this concept of a "dust-vs-nondust source"; they are all part of a single vector that contains all the sources for this set of commitment transactions.

@TheBlueMatt
Copy link
Collaborator

Right, but why? I guess now because there's many commitment txn we will no longer rely on the HTLCs to be sorted in commitment-tx-order and so now it doesn't matter (and HTLCs could theoretically be dust in some commitments but not in others)?

@tankyleo
Copy link
Contributor Author

tankyleo commented Apr 16, 2025

Right, but why? I guess now because there's many commitment txn we will no longer rely on the HTLCs to be sorted in commitment-tx-order and so now it doesn't matter (and HTLCs could theoretically be dust in some commitments but not in others)?

The HTLCs could be sorted in the same commitment tx order across funding scopes, but the transaction output indices of the HTLCs might vary, as which index the non-HTLC outputs get assigned to might vary across funding scopes - because of the different channel_value_satoshis, to_remote and to_local will get different amounts.

Right now though I don't see a way for a HTLC to be dust in one scope, and non-dust in another scope... but looks like this will change with dynamic commitments if I recall.

Looking at BOLT PR 1117 yes - that is a proposal to vary the dust_limit_satoshis across funding scopes.

@TheBlueMatt
Copy link
Collaborator

Right, so basically there's no point in splitting by dust/non-dust because we're not longer going to be able to rely on the order of the HTLCSources in the update, and instead now have to scan them when we need them, so we just shove them all in the update in a big heap cause it doesn't matter. Makes sense to me.

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