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

[3/5]: multi: add new AuxFundingController for custom external funding flows #8622

Open
wants to merge 15 commits into
base: 0-19-staging
Choose a base branch
from

Conversation

Roasbeef
Copy link
Member

@Roasbeef Roasbeef commented Apr 5, 2024

Depends on #8684.

In this commit, we add the AuxFundingController interface that can be used to implement a class of custom funding channels that only requires some additional data to be inserted into the tapscript leaves for the funding/HTLC/commitment outputs. This controller also implements the MsgEndpoint interface (see #8520) as well. This allows the controller to intercept certain custom messages related to the funding process (think extra sigs for a channel factory), and even the existing funding messages.

We then create a new top level config entry for this interface. This allows an external program to instantiate a AuxFundingController, make a MsgRouter, register that, then pass both into the lnd top level config.

We also pick up where the prior PR in this series left of by using the new abstraction to map a pending chan ID (kinda like the FundingStateStep RPC) to the aux funding data. This data is then used to populate all the new custom blobs that we'll store for these new channel types, which impacts the way we construct the funding output, and also the commitment/HTLC outputs+scripts.

Link to all PRs in the saga:

@Roasbeef Roasbeef added funding Related to the opening of new channels with funding transactions on the blockchain custom chans labels Apr 5, 2024
Copy link

coderabbitai bot commented Apr 5, 2024

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

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.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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 testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Apr 5, 2024

Pull reviewers stats

Stats of the last 30 days for lnd:

User Total reviews Time to review Total comments
guggero
🥇
25
▀▀▀
2d 21h 27m
57
▀▀▀
ellemouton
🥈
17
▀▀
4d 14h 51m
34
▀▀
bhandras
🥉
10
30m
0
Roasbeef
6
7h 40m
12
yyforyongyu
6
3h 18m
0
ProofOfKeags
4
7d 8h 54m
42
▀▀
GeorgeTsagk
4
2d 20h 31m
10
ziggie1984
4
3d 11h 1m
9
saubyk
3
3h 43m
0
Chinwendu20
3
18d 5h 35m
▀▀▀
10
hieblmi
2
21m
1
bitromortac
2
9h 44m
0
positiveblue
1
4d 21h 57m
0
Crypt-iQ
1
7d 14h 36m
4
dstadulis
1
1d 22h 10m
4
morehouse
1
2d 2h 39m
1
carlaKC
1
12h 2m
0
mohamedawnallah
1
1d 4h 44m
0

peer/msg_router.go Outdated Show resolved Hide resolved
peer/msg_router.go Outdated Show resolved Hide resolved
peer/msg_router.go Outdated Show resolved Hide resolved
peer/msg_router.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Did a first pass, looks good! Will probably have more questions once we start with the actual AuxFundingController implementation.

funding/aux_funding.go Outdated Show resolved Hide resolved
funding/manager.go Outdated Show resolved Hide resolved
@Roasbeef
Copy link
Member Author

Pushed a few new commits: we'll now include the taproot internal key in the PBST template we return for the PSBT funding flow.

@guggero guggero force-pushed the aux-leaf-fetcher branch 3 times, most recently from a8bfe36 to e04f50d Compare April 24, 2024 13:01
@guggero guggero changed the title multi: add new AuxFundingController for custom external funding flows [3/?]: multi: add new AuxFundingController for custom external funding flows Apr 24, 2024
@guggero guggero force-pushed the aux-leaf-fetcher branch 3 times, most recently from 3fb4bb6 to 72f7b80 Compare May 1, 2024 09:20
@guggero guggero changed the base branch from aux-leaf-fetcher to 0-19-staging May 1, 2024 13:52
@lightninglabs-deploy
Copy link

@Roasbeef, remember to re-request review from reviewers when ready

binary.LittleEndian.PutUint64(nonce[:], f.chanIDNonce)
f.chanIDNonce++
f.nonceMtx.Unlock()
nextNonce := f.chanIDNonce.Add(1)
Copy link
Collaborator

@guggero guggero May 16, 2024

Choose a reason for hiding this comment

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

As described in the commit message, we change the algorithm here. Do these values need to be in sync between node implementations/peers? Or is this value only ever used locally? Just trying to understand if this has any impact or not.

Roasbeef and others added 15 commits May 17, 2024 13:08
In this commit, we add a new abstract message router. Over time, the
goal is that this message router replaces the logic we currently have in
the readHandler (the giant switch for each message).

With this new abstraction, can reduce the responsibilities of the
readHandler to *just* reading messages off the wire and handing them off
to the msg router. The readHandler no longer needs to know *where* the
messages should go, or how they should be dispatched.

This will be used in tandem with the new `protofsm` module in an
upcoming PR implementing the new rbf-coop close.
Over time with this, we should be able to significantly reduce the size
of the peer.Brontide struct as we only need all those deps as the peer
needs to recognize and handle each incoming wire message itself.
With this commit, we allow the `MsgRouter` to be available in the `ImplementationCfg`. With this, programs outside of lnd itself are able to now hook into the message processing flow to direct handle custom messages, and even normal wire messages.
This'll be useful for new interface definitions that use the contents of the package.
This lets us get rid of the mutex usage there. We also shift the algo slightly to increment by 1, then use that as the next value, which plays nicer with the atomics.
This struct will house all the information we'll need to do a class of custom channels that relies primarily on adding additional items to the tapscript root of the HTLC/commitment/funding outputs.
With this commit, we'll now populate all the custom channel information within the OpenChannel and ChannelCommitment structs.
In this commit, we make a new `AuxFundingController` interface capable of processing messages off the wire. In addition, we can use it to abstract away details w.r.t how we obtain a `AuxFundingDesc` for a given channel.

We'll now use this whenever we get a channel funding request, to make sure we pass along the custom state that a channel may require.
If this is a taproot channel, then we'll return the internal key which'll be useful to callers.
We also add a new assertion to the itests to ensure the field is being properly set.
In this commit, we modify the aux funding work flow slightly. We won't
be able to generate the full AuxFundingDesc until both sides has
sent+received funding params. So we'll now only attempt to bind the
tapscript root as soon as we send+recv the open_channel message.

We'll now also make sure that we pass the tapscript root all the way
down into the musig2 session creation.
For the initiator, once we get the signal that the PSBT has been
finalized, we'll call into the aux funder to get the funding desc. For
the responder, once we receive the funding_created message, we'll do the
same.

We now also have local+remote aux leaves for the commitment transaction.
@guggero guggero changed the title [3/?]: multi: add new AuxFundingController for custom external funding flows [3/5]: multi: add new AuxFundingController for custom external funding flows May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
custom chans funding Related to the opening of new channels with funding transactions on the blockchain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants