rust-lightning icon indicating copy to clipboard operation
rust-lightning copied to clipboard

Implement V2 channel establishment

Open dunxen opened this issue 2 years ago • 18 comments

This PR aims to do the following:

  • [ ] Introduce V2 prefunded channel types with state specific to dual-funding.
  • [ ] Add functionality to ChannelManager to create and accept dual-funded channels.
    • [ ] Can set config contribute_to_dual_funded_channels if the user would like to contribute inputs to incoming dual-funded channels. In this case, these channels will need to be accepted manually, indicated by a new OpenChannelV2Request event so that inputs can be provided. If the above flag is false (default), then no inputs will be contributed and the channel is accepted on the user's behalf gated by all the commonly enforced rules. Other policies and functionality to automate funding of incoming channels may be introduced in the future.
  • [ ] Introduce dual-funded channel feature bits

dunxen avatar May 16 '23 10:05 dunxen

Codecov Report

Attention: Patch coverage is 73.02780% with 359 lines in your changes missing coverage. Please review.

Project coverage is 89.70%. Comparing base (07f3380) to head (365aac8).

Files Patch % Lines
lightning/src/ln/interactivetxs.rs 72.96% 205 Missing and 8 partials :warning:
lightning/src/ln/channelmanager.rs 76.58% 78 Missing and 7 partials :warning:
lightning/src/ln/channel.rs 78.91% 29 Missing and 2 partials :warning:
lightning/src/ln/functional_test_utils.rs 6.25% 30 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2302      +/-   ##
==========================================
- Coverage   89.90%   89.70%   -0.20%     
==========================================
  Files         121      121              
  Lines       99170   100033     +863     
  Branches    99170   100033     +863     
==========================================
+ Hits        89159    89735     +576     
- Misses       7408     7687     +279     
- Partials     2603     2611       +8     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar May 25 '23 17:05 codecov-commenter

This isn't blocked on anything anymore, right? Is there anything you want early feedback on here?

TheBlueMatt avatar Jul 08 '23 20:07 TheBlueMatt

This isn't blocked on anything anymore, right? Is there anything you want early feedback on here?

Technically blocked on interactive txs. But yeah, a few things I need to update before some conceptual/approach review here.

dunxen avatar Jul 08 '23 21:07 dunxen

Also now blocked on the 2077 fixups.

dunxen avatar Jul 10 '23 15:07 dunxen

Technically blocked on interactive txs. But yeah, a few things I need to update before some conceptual/approach review here.

If this is blocked on review interactive txs on the spec-side, I can do a round here. Though dunno which PRs it’s blocked on.

ariard avatar Jul 12 '23 00:07 ariard

If this is blocked on review interactive txs on the spec-side, I can do a round here. Though dunno which PRs it’s blocked on.

Oh sorry, I meant the interactive txs implementation. Jurvis had two sketches up in his fork and will be putting a PR together as per the first action item here: https://gist.github.com/jurvis/98215abd6fd392a3f2f0ded03c5c6fff. I'll mark this as blocked on that, but it will be at least ready for some conceptual review after I rebase the changes in #2382.

dunxen avatar Jul 12 '23 10:07 dunxen

Jurvis had two sketches up in his fork and will be putting a PR together as per the first action item here: https://gist.github.com/jurvis/98215abd6fd392a3f2f0ded03c5c6fff.

@jurvis If you have a branch available for early conceptual review, happy to have a look and see how it scores compared to the specification, the ongoing changes in the mempool and LDK current interfaces :)

ariard avatar Jul 15 '23 01:07 ariard

@ariard we just finalised an approach for the TX constructor we are happy with so I’m working to put together a proof of concept rn for review. Should be ready in the next couple of days!

jurvis avatar Jul 15 '23 23:07 jurvis

Should be ready in the next couple of days!

Many thanks, left a couple of review feedback on the new poc PR. If Duncan or you can maintain a dual-funding / splicing issue like Wilmer is doing for anchor output, this is very welcome to coordinate review and pin feedback backlog. I’ll have a look on the gist too, have to catchup with spec first.

ariard avatar Jul 19 '23 01:07 ariard

If Duncan or you can maintain a dual-funding / splicing issue like Wilmer is doing for anchor output, this is very welcome to coordinate review and pin feedback backlog.

@ariard see https://github.com/lightningdevkit/rust-lightning/issues/1621.

wpaulino avatar Jul 19 '23 16:07 wpaulino

@ariard see https://github.com/lightningdevkit/rust-lightning/issues/1621.

Just added this PR there and will continue to keep fleshing it out.

dunxen avatar Jul 19 '23 18:07 dunxen

It seems that interactive_tx_signing_session is not reset at the end of the process. In a test with a payment being done after a V2 establishment, a new commitment was mis-handled to commitment_signed_initial_v2(). I think interactive_tx_signing_session should be reset (e.g. at the end of tx_signatures()).

optout21 avatar Feb 09 '24 08:02 optout21

[!IMPORTANT]

Auto Review Skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

coderabbitai[bot] avatar Feb 20 '24 17:02 coderabbitai[bot]

Working through a rebase on #2981 at the moment, then will start addressing feedback above :pray:

dunxen avatar Apr 11 '24 09:04 dunxen

I see I've missed some error handling todo!()s. I'll push them up soon. As for checking the sighashes, I'm still working on figuring out the best way we're going to do that.

dunxen avatar May 02 '24 15:05 dunxen

Just resolved some conflicts and addressed a few comments. Still busy addressing Jeff's other initial review comments.

dunxen avatar May 15 '24 17:05 dunxen

Pushed some fixes for feedback. Working on remaining ones.

dunxen avatar Jun 07 '24 13:06 dunxen

Split out https://github.com/lightningdevkit/rust-lightning/pull/3137 which should be easier to review and lower risk since it involves no contribution of funds.

This PR will be rebased on that.

dunxen avatar Jun 20 '24 16:06 dunxen

Ok, rebasing will now be fun after #3137 merge.

dunxen avatar Nov 21 '24 08:11 dunxen