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

[2/3]: Support Forwarding of Blinded Payments #8160

Merged
merged 16 commits into from Apr 3, 2024

Conversation

carlaKC
Copy link
Collaborator

@carlaKC carlaKC commented Nov 8, 2023

This PR is the second in a series to add the ability for LND to forward payments to blinded routes.

Reviewer Notes:

  • This PR does not signal the route blinding feature yet because it does not include error handling for blinded forwards, which is critical to receiver privacy so LND should not advertise the feature until it fully support it.
  • Itests can be squashed, they're broken into multiple commits to aid readability.

Replaces #7376
Fixes #7298

@carlaKC carlaKC self-assigned this Nov 8, 2023
@saubyk saubyk added this to the v0.18.0 milestone Nov 9, 2023
@Roasbeef
Copy link
Member

Will this be the last in the series to support forwarding?

@carlaKC
Copy link
Collaborator Author

carlaKC commented Jan 18, 2024

Will this be the last in the series to support forwarding?

One more (WIP) to add and test error handling - it's quite delicate so I want to separate it out.

Copy link

coderabbitai bot commented Jan 25, 2024

Important

Auto Review Skipped

Auto reviews are limited to the following labels: llm-review. Please add one of these labels to enable auto reviews.

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 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/coderabbit-overrides.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.

@carlaKC carlaKC force-pushed the 7298-2-forwardblindedroutes branch 3 times, most recently from 1892855 to 5fe3bb5 Compare February 17, 2024 22:54
@carlaKC carlaKC changed the title [2/n]: Support Forwarding of Blinded Payments [2/3]: Support Forwarding of Blinded Payments Feb 17, 2024
@carlaKC carlaKC force-pushed the 7298-2-forwardblindedroutes branch from eb4b8d8 to 8ddafed Compare March 22, 2024 17:47
@carlaKC
Copy link
Collaborator Author

carlaKC commented Mar 22, 2024

Added a469087 disable route blinding so that this can merge independently of #8485 (which will re-enable it + advertise feature).

@carlaKC carlaKC force-pushed the 7298-2-forwardblindedroutes branch from 8ddafed to a5c3bb4 Compare March 27, 2024 13:47
@carlaKC
Copy link
Collaborator Author

carlaKC commented Mar 27, 2024

Rebase! Also re-confirmed interop testing here.

@Roasbeef
Copy link
Member

Needs a rebase!

@carlaKC carlaKC force-pushed the 7298-2-forwardblindedroutes branch from a5c3bb4 to 9c2efac Compare March 28, 2024 22:20
htlcswitch/hop/iterator.go Outdated Show resolved Hide resolved
htlcswitch/hop/iterator.go Show resolved Hide resolved
htlcswitch/hop/iterator.go Outdated Show resolved Hide resolved
htlcswitch/hop/iterator.go Outdated Show resolved Hide resolved
// route forwarding. Payloads will simply be rejected as invalid if
// they contain blinding points, as our node does not want to forward
// them.
DisableBlindedFwd bool
Copy link
Member

Choose a reason for hiding this comment

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

Same comment about if we can lift this up to a higher layer. So we never even try to decrypt/decode something when we don't support it.

I think not yet in the scope of these PRs, but we should also have path finding logic to not attempt to include a node in our blinded path if they don't support it.

Copy link
Member

Choose a reason for hiding this comment

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

Eg: we don't even need to call MakeBlindingKit (just for it to reject the payload) if we don't support the feature.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

but we should also have path finding logic to not attempt to include a node in our blinded path if they don't support it.

Def, I imagine that would be for blinded path creation? Filter by feature bit and then make a path seems to be the norm.

htlcswitch/hop/payload.go Outdated Show resolved Hide resolved
htlcswitch/hop/payload.go Outdated Show resolved Hide resolved
itest/lnd_route_blinding_test.go Show resolved Hide resolved
itest/lnd_route_blinding_test.go Show resolved Hide resolved
itest/lnd_route_blinding_test.go Outdated Show resolved Hide resolved
@carlaKC carlaKC force-pushed the 7298-2-forwardblindedroutes branch from 9c2efac to 59d817f Compare April 2, 2024 20:17
@carlaKC
Copy link
Collaborator Author

carlaKC commented Apr 2, 2024

Thanks for the review @Roasbeef, the suggested interface makes things much cleaner 🧹

Addressed some of your post-merge review of #8159 here (where relevant to the existing changes) and will follow with the rest either in #8485 or an independent followup.

@carlaKC carlaKC requested a review from Roasbeef April 2, 2024 20:21
Add an option to disable route blinding, failing back any HTLC with
a blinding point set when we haven't got the feature enabled.

Note that this commit only handles the case where we're chosen as the
relaying node (where the blinding point is in update_add_htlc), we'll
add handling for the introduction node case once we get to handling of
blinded payloads).
This commit introduces a blinding kits which abstracts over the
operations required to decrypt, deserialize and reconstruct forwarding
data from an encrypted blob of data included for nodes in blinded
routes.
When we have a HTLC that is part of a blinded route, we need to include
the next ephemeral blinding point in UpdateAddHtlc for the next hop. The
way that we handle the addition of this key is the same for introduction
nodes and relaying nodes within the route.
To separate blinded route parsing from payload parsing, we need to
return the parsed types map so that we can properly validate blinded
data payloads against what we saw in the onion.
If we received a payload with a encrypted data point set, our forwarding
information should be set from the information in our encrypted blob.
This behavior is the same for introduction and relying nodes in a
blinded route.
Reject any HTLCs that use us as an introduction point in a blinded
route if we have disabled route blinding. We have to do this after
we've processed the payload, because we only know we're an introduction
point once we've processed the payload itself.
Note: the itest is broken up into multiple commits to make it
more readable, they can be squashed post-review.
We don't support receiving blinded in this PR - just intercept and
settle instead. The HTLC's arrival on the interceptor indicates that
it was successfully forwarded on a blinded hop.
This commit turns off route blinding for the daemon while we're waiting
on full handling for blinded errors. The feature remains on for itests
so that tests covering blinding can run as usual.
@carlaKC carlaKC force-pushed the 7298-2-forwardblindedroutes branch from 59d817f to 2188dd9 Compare April 3, 2024 14:54
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🥕

Thanks for considering those late-ish review comments, we're super close, let's keep this momentum going!

@Roasbeef Roasbeef merged commit 9bafcb2 into lightningnetwork:master Apr 3, 2024
25 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[feature]: Blinded Forwarding in LND
7 participants