Skip to content

Channel Establishment for V3 Channels #3792

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 20 commits into
base: main
Choose a base branch
from

Conversation

carlaKC
Copy link
Contributor

@carlaKC carlaKC commented May 22, 2025

This PR updates the channel establishment flow to allow and validate V3 channels (behind test flag).

Useful for the commits that follow where we add more downgrade tests.
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented May 22, 2025

👋 Thanks for assigning @tankyleo 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.

@carlaKC carlaKC requested a review from TheBlueMatt May 22, 2025 15:43
@carlaKC carlaKC mentioned this pull request May 22, 2025
36 tasks
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.

Cool, basically all LGTM.

@@ -16153,22 +16154,28 @@ mod tests {
}

#[test]
fn test_anchors_zero_fee_htlc_tx_fallback() {
fn test_anchors_zero_fee_htlc_tx_downgrade() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Congrats, you touched it, now you get to move it out of channelmanager into some other test-specific file that isn't 15000 lines of code 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done this in a follow up in #3797 so that move + format can be reviewed separately.

Comment on lines 209 to 212
/// back to a `anchors_zero_fee_htlc` (if [`Self::negotiate_anchors_zero_fee_htlc_tx`]
/// is set) or `static_remote_key` channel.
///
/// *Implies [`Self::negotiate_anchors_zero_fee_htlc_tx`].*
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are in conflict - one says we'll fall back if its set, the other says that its implied (ie always set) if we set this flag.

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

@ldk-reviews-bot
Copy link

✅ Added second reviewer: @valentinewallace

@wpaulino wpaulino requested review from wpaulino and removed request for valentinewallace May 22, 2025 18:17
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.

LGTM after Matt's comments are addressed

@carlaKC
Copy link
Contributor Author

carlaKC commented May 23, 2025

Removed conflicting docs statement + opened followup for test separation (felt wrong to do move+format in the same PR, happy to include if we want it in here).

@carlaKC carlaKC requested review from wpaulino and TheBlueMatt May 23, 2025 20:54
@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @TheBlueMatt @wpaulino! 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.

1 similar comment
@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @TheBlueMatt @wpaulino! 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.

Sorry for the delay, here's a first pass :)

@ldk-reviews-bot
Copy link

🔔 2nd Reminder

Hey @TheBlueMatt @wpaulino! 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.

1 similar comment
@ldk-reviews-bot
Copy link

🔔 2nd Reminder

Hey @TheBlueMatt @wpaulino! 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.

Another pass :)

carlaKC added 4 commits May 28, 2025 09:16
Rather than duplicating our channel type preference ordering in
downgrade logic, make a modified version of the remote peer's supported
features and remove our current channel type from it to get the next
preferred channel type.
@carlaKC carlaKC force-pushed the 3789-channelestablishment branch from b9ec89c to 892d87a Compare May 29, 2025 15:50
@carlaKC
Copy link
Contributor Author

carlaKC commented May 29, 2025

Major change in push is using get_initial_channel_type in channel type downgrades to DRY up the code a bit.
Otherwise addressed nits + added some tests in fixups (full diff).

@carlaKC carlaKC requested a review from tankyleo May 29, 2025 15:53
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.

Thank you for the downgrade tests ! Just three nits at this point :)

Comment on lines 16244 to 16249
initiator_cfg .channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
initiator_cfg .channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;

let mut receiver_cfg = test_default_channel_config();
receiver_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
receiver_cfg.manually_accept_inbound_channels = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we also want to run a version of this test where local does not support zero fee htlc (instead of remote) ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I might have been unclear, I meant a diff similar to this one ? Or do you think it's not necessary ?

Thank you thank you :)

                let start_type = ChannelTypeFeatures::anchors_zero_fee_commitments();
                let end_type = ChannelTypeFeatures::only_static_remote_key();
                do_test_channel_type_downgrade(initiator_cfg, receiver_cfg, start_type, vec![end_type]);
+
+               let mut initiator_cfg = test_default_channel_config();
+               initiator_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
+
+               let mut receiver_cfg = test_default_channel_config();
+               receiver_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
+               receiver_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
+               receiver_cfg.manually_accept_inbound_channels = true;
+
+               let start_type = ChannelTypeFeatures::anchors_zero_fee_commitments();
+               let end_type = ChannelTypeFeatures::only_static_remote_key();
+               do_test_channel_type_downgrade(initiator_cfg, receiver_cfg, start_type, vec![end_type]);
        }

carlaKC and others added 15 commits May 30, 2025 15:43
To allow testing along the way in this PR, turn on negotiation of
zero fee channels.

Co-authored-by: Matt Corallo <git@bluematt.me>
Sender: MUST set `feerate_per_kw` to zero
Receiver: MUST fail the channel if `feerate_per_kw` != 0

Co-authored-by: Matt Corallo <git@bluematt.me>
Like anchor channels, these channels require that the user reserves a
UTXO to bump the channel. If we automatically accept this channel type
and the user does not have such reserve available, they are at risk of
losing funds because they cannot fee bump the channel.
@carlaKC carlaKC force-pushed the 3789-channelestablishment branch from 892d87a to e56e32a Compare May 30, 2025 20:23
@carlaKC
Copy link
Contributor Author

carlaKC commented May 30, 2025

@ldk-reviews-bot
Copy link

🔔 3rd Reminder

Hey @TheBlueMatt @wpaulino! 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.

1 similar comment
@ldk-reviews-bot
Copy link

🔔 3rd Reminder

Hey @TheBlueMatt @wpaulino! 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.

@ldk-reviews-bot
Copy link

🔔 4th Reminder

Hey @TheBlueMatt @wpaulino! 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.

1 similar comment
@ldk-reviews-bot
Copy link

🔔 4th Reminder

Hey @TheBlueMatt @wpaulino! 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.

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.

5 participants