Uh oh!
There was an error while loading. Please reload this page.
Replace use of HolderSignedTx with HolderCommitment - #3664
Conversation
👋 Thanks for assigning @jkczyz as a reviewer! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| let holder_commitment = HolderCommitment::try_from(( | ||
| current_holder_commitment_tx, ¤t_holder_signed_tx, | ||
| )).map_err(|_| DecodeError::InvalidValue)?; | ||
| if HolderSignedTx::from(&holder_commitment) != current_holder_signed_tx { |
There was a problem hiding this comment.
What's gonna happen here? Are we just gonna keep writing the legacy versions and converting, or should we have some upgrade path?
There was a problem hiding this comment.
Was planning to address this in a follow-up PR that removes them from OnchainTxHandler such that we can no longer rely on getting them from there and instead store them as a new TLV in the monitor.
ldk-reviews-bot
commented
Mar 12, 2025
👋 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. |
TheBlueMatt
commented
Mar 12, 2025
This does seem like the kind of thing that might want an 👋 upgrade test 👋 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## main #3664 +/- ##
==========================================
- Coverage 89.25% 89.15% -0.11%
==========================================
Files 155 155 Lines 119959 121059 +1100 Branches 119959 121059 +1100 ==========================================
+ Hits 107069 107925 +856 - Misses 10276 10478 +202 - Partials 2614 2656 +42 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
wpaulino
commented
Mar 12, 2025
Will need to wait for #3584 first |
2884bad to
fdc1706Comparedunxen
commented
Mar 17, 2025
Needs rebase. |
fdc1706 to
73f82fbCompare
tankyleo
left a comment
There was a problem hiding this comment.
Didn't make it through everything, some initial comments.
I'm also unclear how this helps with custom commitment transactions in particular ? Thanks for clarifying here.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jkczyz
left a comment
There was a problem hiding this comment.
Made it through everything. Nothing out of the ordinary pops out aside from what other reviewers have raised.
I'm also unclear how this helps with custom commitment transactions in particular ? Thanks for clarifying here.
Will let @wpaulino confirm, but IIUC prior to this PR we were only storing parts of the commitment transaction, so anything additional in a custom one would be missing.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
73f82fb to
24dffdbComparewpaulino
commented
Mar 17, 2025
Correct. We were already tracking the actual commitment transaction at the |
Ok! From my side here's how I've been approaching custom transactions in channel monitor. Many details I haven't worked out yet but big picture:
Experimental API currently looks like this: /// Returns claims on a counterparty commitment transactionfngenerate_claims_from_counterparty_tx(&self,per_commitment_point:&PublicKey,channel_parameters:&ChannelTransactionParameters,tx:&Transaction,per_commitment_claimable_data:&Vec<(HTLCOutputInCommitment,Option<Box<HTLCSource>>)>,payment_preimages:&HashMap<PaymentHash,(PaymentPreimage,Vec<PaymentClaimDetails>)>,secp_ctx:&Secp256k1<secp256k1::All>,) -> (Vec<PackageTemplate>,CommitmentTxCounterpartyOutputInfo);/// Returns claims on a counterparty's revoked commitment transactionfngenerate_claims_from_revoked_tx(&self,per_commitment_key:&SecretKey,channel_parameters:&ChannelTransactionParameters,tx:&Transaction,per_commitment_claimable_data:&Vec<(HTLCOutputInCommitment,Option<Box<HTLCSource>>)>,height:u32,secp_ctx:&Secp256k1<secp256k1::All>,) -> (Vec<PackageTemplate>,CommitmentTxCounterpartyOutputInfo);/// Returns claims on a holder's commitment transactionfngenerate_claims_from_holder_tx(&self,holder_tx:&HolderSignedTx,conf_height:u32,channel_parameters:&ChannelTransactionParameters,payment_preimages:&HashMap<PaymentHash,(PaymentPreimage,Vec<PaymentClaimDetails>)>,secp_ctx:&Secp256k1<secp256k1::All>,) -> Vec<PackageTemplate>;What's missing:
Let me know if this syncs up with what you were thinking @wpaulino happy to chat here or elsewhere. This branch here contains this API together with an implementation that passes the test suite: |
jkczyz
left a comment
There was a problem hiding this comment.
LGTM aside from pending discussions. Please re-request a review once those are resolved.
wpaulino
commented
Mar 18, 2025
@tankyleo your proposal seems fine so far. The only change as a result of this PR would be to the function argument in |
tankyleo
commented
Mar 18, 2025
Yes agreed
Sounds good |
| Ok(LatestHolderCommitmentTXInfo { | ||
| commitment_tx: holder_commitment_tx, | ||
| htlc_outputs: htlcs_and_sigs, | ||
| htlc_outputs: dust_htlcs, |
There was a problem hiding this comment.
Can we rename this now that its something different?
There was a problem hiding this comment.
It might still have the old meaning when we read. Would you rather change it now anyway or wait until we know for sure we'll only ever find dust_htlcs?
There was a problem hiding this comment.
Maybe mostly_dust_htlcs? :). I mean we can certainly do it later, just seems easy for a bug to slip in because of a bad name.
There was a problem hiding this comment.
I'd rather defer it. I don't think a bug could happen where non-dust HTLCs are included because we still have code to support that, and the current name already assumed dust HTLCs must be included.
Uh oh!
There was an error while loading. Please reload this page.
24dffdb to
41d9463CompareCurrently, non-dust HTLCs are duplicated across the commitment transaction itself, and the full set of HTLCs (dust & non-dust) along with their `HTLCSource` considered in the commitment transaction. As of v0.0.15, we've had support for providing non-dust HTLC sources separately such that we no longer track duplicate non-dust HTLC data, but only enabled it under testing environments. This commit enables it such that it always happens. Note that we still need to support reading `ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo` updates that did not separate the non-dust HTLC sources in case they were written in an older version and they've yet to be processed.
41d9463 to
7f626c8Comparewpaulino
commented
Mar 25, 2025
Had to rebase due to a conflict with #3606 and implemented |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
7f626c8 to
a891a04CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
a891a04 to
e8ec314Comparee8ec314 to
80ac853CompareUh oh!
There was an error while loading. Please reload this page.
92df40e to
b8007c9Compare
TheBlueMatt
left a comment
There was a problem hiding this comment.
Would be nice to reduce the clones in a few places still, but we can also do it in a followup.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
b8007c9 to
d279b82CompareAs we move to a custom commitment transactions world, we'll no longer be able to rely on `HolderSignedTx` and should instead track the actual commitment transaction itself. This commit does so by introducing a new `HolderCommitment` struct, which we'll use as a replacement to `HolderSignedTx` to hold all relevant holder commitment data, including the `HolderCommitmentTransaction`, without data duplication. Luckily, this is a backwards and forwards compatible change due to the `OnchainTxHandler` tracking the latest `HolderCommitmentTransaction`s. In the future, we aim to remove them from the `OnchainTxHandler` entirely and begin storing them at the `ChannelMonitor` level. Aside from how the data is represented internally, there shouldn't be any functional changes within this patch.
d279b82 to
5d13fdcCompareldk-reviews-bot
commented
Mar 31, 2025
🔔 1st Reminder Hey @jkczyz! This PR has been waiting for your review. |
As we move to a custom commitment transactions world, we'll no longer be able to rely on
HolderSignedTxand should instead track the actual commitment transaction itself. This commit does so by introducing a newHolderCommitmentstruct, which we'll use as a replacement toHolderSignedTxto hold all relevant holder commitment data, including theHolderCommitmentTransaction, without data duplication.Luckily, this is a backwards and forwards compatible change due to the
OnchainTxHandlertracking the latestHolderCommitmentTransactions. In the future, we aim to remove them from theOnchainTxHandlerentirely and begin storing them at theChannelMonitorlevel.Aside from how the data is represented internally, there shouldn't be any functional changes within this patch.
Depends on #3663.