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

[5/5]: lnwallet: extensions to aux leaf store to integrate custom channels #8641

Open
wants to merge 8 commits into
base: aux-leaf-signing
Choose a base branch
from

Conversation

Copy link

coderabbitai bot commented Apr 11, 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

Pull reviewers stats

Stats of the last 30 days for lnd:

User Total reviews Time to review Total comments
guggero
🥇
24
▀▀▀
2d 13h 46m
52
▀▀▀
ellemouton
🥈
12
5d 14h 33m
21
bhandras
🥉
9
30m
0
Roasbeef
7
7d 8h 43m
20
yyforyongyu
6
3h 18m
0
ziggie1984
5
3d 1h 5m
14
ProofOfKeags
4
4d 6h 3m
42
▀▀
GeorgeTsagk
4
2d 20h 31m
10
bitromortac
2
13d 3h 49m
6
saubyk
2
5h 24m
0
Chinwendu20
2
18d 5h 38m
▀▀
9
positiveblue
1
4d 21h 57m
0
AndySchroder
1
17d 9h 5m
▀▀
4
ffranr
1
14h 10m
4
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

@@ -654,25 +654,29 @@ type AuxLeafStore interface {
// FetchLeavesFromView attempts to fetch the auxiliary leaves that
// correspond to the passed aux blob, and pending fully evaluated HTLC
// view.
FetchLeavesFromView(prevBlob tlv.Blob, view *HtlcView,
FetchLeavesFromView(chanState *channeldb.OpenChannel, prevBlob tlv.Blob,
Copy link
Member

Choose a reason for hiding this comment

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

Alternatively could just be that special funding blob (the one in the open channel struct), we could also use a type alias here. Unsure though if we do need all that other information or not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need the local/remote channel config, custom blob, thaw height, initiator and channel type. So it's easiest to just pass in the whole channel state. Not sure what a type alias would give us? Other than perhaps being a bit shorter.

// of the pkScript and CLTV timeout, and the value is the index the
// output should be placed at. The CLTV timeout is encoded as a big
// endian before hashing and is assumed to be 0 for non-HTLC outputs.
// sha256(pkScript || bigEndian(cltvDelta)) -> outputIndex
Copy link
Member

Choose a reason for hiding this comment

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

IIUC, this also incudes the value as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yes, good catch. Fixed.

// lets us skip sending the entire transaction over, instead we'll just
// send signatures.
if auxLeaves.IsSome() &&
auxLeaves.UnsafeFromSome().CustomOutputOrder != nil {
Copy link
Member

Choose a reason for hiding this comment

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

If we want to mask this a bit more, then we can have a functional option to pass in a new custom sorting interface/type. Default is the existing one, then we know to override it at the config level for these special channels.

Copy link
Collaborator Author

@guggero guggero Apr 12, 2024

Choose a reason for hiding this comment

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

Good point. I'm meeting you half way: Instead of passing in a function, we now require a sort function to be returned. But that way at least the sorting logic is not in the lnd code base anymore.

input/script_utils.go Show resolved Hide resolved
@@ -660,7 +660,8 @@ type AuxLeafStore interface {
// correspond to the passed aux blob, and pending original (unfiltered)
// HTLC view.
FetchLeavesFromView(chanState *channeldb.OpenChannel, prevBlob tlv.Blob,
unfilteredView *HtlcView,
unfilteredView *HtlcView, isOurCommit bool, ourBalance,
theirBalance lnwire.MilliSatoshi,
Copy link
Member

Choose a reason for hiding this comment

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

Balances needed for the new sorting algo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, for sorting, making sure we have non-dust BTC amounts for any asset amounts and for determining whether we need commitment anchor outputs (which we need to create exclusion proofs for).

@guggero guggero force-pushed the custom-channels-integration branch 5 times, most recently from d288b6a to f7f875b Compare April 16, 2024 11:23
@guggero guggero changed the base branch from aux-leaf-fetcher to aux-leaf-signing April 16, 2024 11:23
@guggero guggero force-pushed the custom-channels-integration branch 7 times, most recently from cb514a1 to f35aead Compare April 23, 2024 20:19
@guggero guggero changed the base branch from aux-leaf-signing to 0-19-staging April 23, 2024 20:21
@guggero guggero force-pushed the custom-channels-integration branch from f35aead to cf965f0 Compare April 24, 2024 15:04
@guggero guggero changed the base branch from 0-19-staging to aux-leaf-signing April 24, 2024 15:07
@guggero guggero changed the title lnwallet: extensions to aux leaf store to integrate custom channels [5/?]: lnwallet: extensions to aux leaf store to integrate custom channels Apr 24, 2024
@guggero guggero force-pushed the custom-channels-integration branch from cf965f0 to 0e6a9dd Compare April 25, 2024 17:06
@guggero guggero force-pushed the custom-channels-integration branch from ebfde14 to 0b991e2 Compare May 1, 2024 08:30
@guggero guggero force-pushed the custom-channels-integration branch from 0b991e2 to a5d1e43 Compare May 1, 2024 09:20
@guggero guggero force-pushed the aux-leaf-signing branch 2 times, most recently from 8ed50cf to cfd4314 Compare May 1, 2024 13:53
@guggero guggero force-pushed the custom-channels-integration branch from a5d1e43 to 15abb14 Compare May 1, 2024 13:53
@guggero guggero force-pushed the custom-channels-integration branch from 15abb14 to 09b34f1 Compare May 14, 2024 07:49
@guggero guggero force-pushed the custom-channels-integration branch from 09b34f1 to fedcac2 Compare May 17, 2024 12:34
@guggero guggero force-pushed the custom-channels-integration branch from fedcac2 to f9b366e Compare May 17, 2024 13:26
@guggero guggero changed the title [5/?]: lnwallet: extensions to aux leaf store to integrate custom channels [5/5]: lnwallet: extensions to aux leaf store to integrate custom channels May 17, 2024
@guggero guggero marked this pull request as ready for review May 17, 2024 13:26
@guggero
Copy link
Collaborator Author

guggero commented May 17, 2024

This PR should now contain everything from the PoC branch and is ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants