Skip to content
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

Re-add support for non-zero-fee-anchors to chan_utils #1828

Conversation

devrandom
Copy link
Member

@devrandom devrandom commented Nov 3, 2022

This would let VLS continue to use LDK past 0.0.111.

I tried to minimize the diff.

Fixes #1822

@@ -1193,6 +1195,7 @@ impl_writeable_tlv_based!(CommitmentTransaction, {
(10, built, required),
(12, htlcs, vec_type),
(14, opt_anchors, option),
(16, opt_non_zero_fee_anchors, option),
Copy link
Member Author

Choose a reason for hiding this comment

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

alternatively, I can create a const_false "TLV" directive for the macros, so that nothing is actually serialized for this field.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this either needs to be an odd type or an unwrap_or(false) such that we can read it on new versions that didn't previously serialize this field.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think so? I think it should be even because old versions should reject it - technically this means a non-forwards-compatible change on VLS' end, but I assume that's okay, it shouldn't matter for LDK users.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am doing self.opt_non_zero_fee_anchors.is_some() instead of self.opt_non_zero_fee_anchors.unwrap_or(false), but they are equivalent.

if it was serialized by an old version, the field won't exist, and that will be interpreted as None.

so this should work as written

@devrandom devrandom force-pushed the 2022-11-non-zero-fee-anchors branch 2 times, most recently from 1f98f65 to b67d958 Compare November 3, 2022 14:48
@codecov-commenter
Copy link

codecov-commenter commented Nov 3, 2022

Codecov Report

Base: 90.72% // Head: 92.37% // Increases project coverage by +1.65% 🎉

Coverage data is based on head (c4bb578) compared to base (8245128).
Patch coverage: 80.95% of modified lines in pull request are covered.

❗ Current head c4bb578 differs from pull request most recent head e6b9694. Consider uploading reports for the commit e6b9694 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1828      +/-   ##
==========================================
+ Coverage   90.72%   92.37%   +1.65%     
==========================================
  Files          91       91              
  Lines       47896    61923   +14027     
  Branches    47896    61923   +14027     
==========================================
+ Hits        43453    57204   +13751     
- Misses       4443     4719     +276     
Impacted Files Coverage Δ
lightning/src/ln/chan_utils.rs 93.63% <63.63%> (-0.36%) ⬇️
lightning/src/chain/channelmonitor.rs 92.92% <100.00%> (+2.19%) ⬆️
lightning/src/chain/keysinterface.rs 90.76% <100.00%> (+0.01%) ⬆️
lightning/src/ln/channel.rs 92.12% <100.00%> (+3.29%) ⬆️
lightning/src/util/enforcing_trait_impls.rs 86.17% <100.00%> (ø)
lightning/src/chain/mod.rs 66.66% <0.00%> (-1.52%) ⬇️
lightning-net-tokio/src/lib.rs 76.73% <0.00%> (-0.31%) ⬇️
lightning/src/ln/peer_channel_encryptor.rs 93.38% <0.00%> (-0.25%) ⬇️
lightning/src/lib.rs 100.00% <0.00%> (ø)
lightning/src/ln/reorg_tests.rs 100.00% <0.00%> (ø)
... and 30 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@TheBlueMatt
Copy link
Collaborator

Hmm, okay, so if I understand correctly, we're gonna have to keep code around to support this forever - CLN may well go to prod as greenlight with VLS and channels that are non-0-htlc-fee anchors, so future versions will always have to support those channels.

Do y'all use the signer directly? Can we avoid passing anything to the signer and just let the CommitmentTransaction track if we're 0-htlc-fee?

@devrandom
Copy link
Member Author

Do y'all use the signer directly? Can we avoid passing anything to the signer and just let the CommitmentTransaction track if we're 0-htlc-fee?

Ah, right, we do use InMemorySigner too.

@TheBlueMatt
Copy link
Collaborator

Ah, okay.

Separately, it looks like the changes to CommitmentTransaction are unused - the InMemorySigner just calls build_htlc_transaction, is there a reason to have the opt_non_zero_fee_anchors in CommitmentTransaction?

@devrandom
Copy link
Member Author

Apologies, missed this comment.

Separately, it looks like the changes to CommitmentTransaction are unused - the InMemorySigner just calls build_htlc_transaction, is there a reason to have the opt_non_zero_fee_anchors in CommitmentTransaction?

We use CommitmentTransaction, and we would like to use it with non-zero-fee anchors.

Copy link
Contributor

@wpaulino wpaulino left a comment

Choose a reason for hiding this comment

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

The logic for dust HTLCs also changed with the zero fee variant (see commit af2ff9b), do we need to bring that back as well?

@@ -519,6 +519,8 @@ pub struct InMemorySigner {
channel_value_satoshis: u64,
/// Key derivation parameters
channel_keys_id: [u8; 32],
/// Whether non-zero-fee anchors are enabled (used in conjuction with channel_parameters.opt_anchors)
use_non_zero_fee_anchors: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's include this within ChannelTransactionParameters instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would normally do that, but since there's no plan to support this in actual LDK channel operation, it seems it would just touch additional code for not much gain?

Copy link
Contributor

Choose a reason for hiding this comment

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

We want to keep signers derivable, except for the parameters that need to be provided through ready_channel, so I'd prefer all of them be under the channel_parameters option.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. done.

@@ -1193,6 +1195,7 @@ impl_writeable_tlv_based!(CommitmentTransaction, {
(10, built, required),
(12, htlcs, vec_type),
(14, opt_anchors, option),
(16, opt_non_zero_fee_anchors, option),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this either needs to be an odd type or an unwrap_or(false) such that we can read it on new versions that didn't previously serialize this field.

@TheBlueMatt
Copy link
Collaborator

The logic for dust HTLCs also changed with the zero fee variant (see commit af2ff9b), do we need to bring that back as well?

I don't think so - we don't care about supporting on the Channel end, just in the utils that VLS uses to support CLN channels.

@devrandom devrandom changed the title Draft: Re-add support for non-zero-fee-anchors to chan_utils Re-add support for non-zero-fee-anchors to chan_utils Nov 21, 2022
}
}

/// use non-zero fee anchors
pub fn with_non_zero_fee_anchors(mut self) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs: (C-not exported) since bindings don't support move semantics
cc @TheBlueMatt

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -519,6 +519,8 @@ pub struct InMemorySigner {
channel_value_satoshis: u64,
/// Key derivation parameters
channel_keys_id: [u8; 32],
/// Whether non-zero-fee anchors are enabled (used in conjuction with channel_parameters.opt_anchors)
use_non_zero_fee_anchors: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to keep signers derivable, except for the parameters that need to be provided through ready_channel, so I'd prefer all of them be under the channel_parameters option.

@devrandom devrandom force-pushed the 2022-11-non-zero-fee-anchors branch 2 times, most recently from c4bb578 to ef2914d Compare November 22, 2022 11:20
@TheBlueMatt TheBlueMatt added this to the 0.0.113 milestone Nov 22, 2022
@TheBlueMatt TheBlueMatt merged commit af7c292 into lightningdevkit:main Nov 22, 2022
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.

Non-zero-fee anchors support was removed
4 participants