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

[custom channels 2/5]: Extract PART2 from mega staging branch #9049

Merged
merged 28 commits into from
Sep 5, 2024

Conversation

guggero
Copy link
Collaborator

@guggero guggero commented Aug 29, 2024

Extracts part 2 from #8960.

Copy link
Contributor

coderabbitai bot commented Aug 29, 2024

Important

Review skipped

Auto reviews are limited to specific labels.

Labels to auto review (1)
  • llm-review

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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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
yyforyongyu
🥇
27
▀▀▀
17h 34m
104
▀▀
guggero
🥈
18
▀▀
11h 48m
35
Roasbeef
🥉
11
14d 7h 5m
▀▀▀
50
carlaKC
8
3d 20h 1m
36
bhandras
6
58m
2
ziggie1984
6
3d 8h 53m
19
ellemouton
5
20h 5m
37
bitromortac
5
5d 20h 45m
56
ProofOfKeags
4
16d 4h 25m
▀▀▀
71
▀▀
Crypt-iQ
4
14h 20m
9
hieblmi
2
1h 31m
2
morehouse
2
1h 14m
1
dstadulis
1
5d 7h 41m
1

@guggero
Copy link
Collaborator Author

guggero commented Aug 30, 2024

I addressed all TODOs, this is ready for full second round review.

@guggero guggero marked this pull request as ready for review August 30, 2024 13:58
Copy link
Collaborator

@ProofOfKeags ProofOfKeags left a comment

Choose a reason for hiding this comment

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

I'd like to avoid log analysis as a means of testing. I'd also like to not further cement the "trigger update" pattern we are currently using for getting the switch to stay in sync with the alias manager, but perhaps that is out of scope.

aliasmgr/aliasmgr.go Show resolved Hide resolved
aliasmgr/aliasmgr.go Show resolved Hide resolved
aliasmgr/aliasmgr.go Outdated Show resolved Hide resolved
lnrpc/marshall_utils.go Outdated Show resolved Hide resolved
lnwire/lnwire_test.go Show resolved Hide resolved
itest/lnd_forward_interceptor_test.go Outdated Show resolved Hide resolved
htlcswitch/packet.go Outdated Show resolved Hide resolved
lnwallet/channel.go Show resolved Hide resolved
@ProofOfKeags
Copy link
Collaborator

I did a first pass. I'll do another more detailed review next week.

Copy link
Collaborator

@ProofOfKeags ProofOfKeags left a comment

Choose a reason for hiding this comment

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

Left some more detailed comments this time around. I think we're close

Comment on lines 1617 to 1622
// But we only add it, if it's a valid alias, as defined
// by the BOLT spec.
if !aliasmgr.IsAlias(aliasScid) {
return nil, fmt.Errorf("SCID alias %v is not "+
"a valid alias", aliasScid)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like this check should be done first to prevent needing to query the alias manager for the existence of aliases that are fundamentally impossible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense, yes. Even though we just query the alias manager once for all the aliases and cache the result, from the flow of things this should come first.

lnrpc/routerrpc/router_server.go Show resolved Hide resolved
itest/lnd_routing_test.go Outdated Show resolved Hide resolved
itest/lnd_routing_test.go Show resolved Hide resolved
lnwire/custom_records.go Outdated Show resolved Hide resolved
lnwallet/channel.go Show resolved Hide resolved
routing/bandwidth.go Outdated Show resolved Hide resolved
routing/bandwidth.go Outdated Show resolved Hide resolved
routing/bandwidth.go Outdated Show resolved Hide resolved
routing/bandwidth.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

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

The commit structure is much nicer now, thank you 🙏, also great work with the persistence! I think it's almost ready. I have a suggestion to add the first hop custom records to the bandwidth manager, which may clean things up and hide them from pathfinding.

Comment on lines 184 to 185
to the channel peer via any message. Therefore, routing over such an alias
will only work if the peer also calls this same RPC on their end. If an
Copy link
Collaborator

Choose a reason for hiding this comment

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

The comment may need an update concerning that it's only possible to route if both add the alias (only the forwarding node needs to). Is there a strong reason to prepend this with X? I think we could drop it as I can see this to be an important LSP functionality.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are correct, for just the routing part it's enough if only one side sets this. But for the custom channel functionality (especially the RFQ part where the custom data within an HTLC might reference such an SCID alias) the alias needs to be known to both parties to fully work.

We added the X because of the requirement of both nodes needing to call this individually and it not being negotiated over a custom p2p message between the peers. I think it's still the goal to eventually (not this PR) make it possible to communicate this over the wire, that's when we're going to remove the X.

lnrpc/routerrpc/router_server.go Outdated Show resolved Hide resolved
}

err = s.cfg.AliasMgr.AddLocalAlias(
aliasScid, baseScid, false, true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure I fully understand the gossip flag it seems like it makes it possible to retrieve data about the channel via rpc?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That was pre-existing and I'm not 100% I understand it either.
The description reads:

The gossip boolean marks whether or not to create a mapping
that the gossiper will use.

So I assume it's only set to true if we'd ever expect gossip messages referencing such an alias? Not sure when that would be the case and when not.

lnrpc/routerrpc/router_server.go Outdated Show resolved Hide resolved
lnwire/extra_bytes.go Show resolved Hide resolved
routing/router.go Show resolved Hide resolved
routing/bandwidth.go Show resolved Hide resolved
routing/payment_lifecycle.go Show resolved Hide resolved
routing/bandwidth.go Outdated Show resolved Hide resolved
itest/lnd_forward_interceptor_test.go Show resolved Hide resolved
GeorgeTsagk and others added 8 commits September 5, 2024 08:44
With the new RPC calls that we are going to add in the next commits, it
will be possible for users to add (local only, non-gossipped) SCID
aliases for channels. Since those will be in the same range as the ones
given out by RequestAlias, we need to make sure that when we generate a
new one that it doesn't collide with an already existing one.
Because we restrict custom SCID aliases to be in a specific range, we
export the range start and end values so a user of the RPCs we're going
to add in the next commits can adjust their values to fit within the
range.
ffranr and others added 9 commits September 5, 2024 11:18
Introduce `ResumeModified` action to resume standard behavior of a p2p
message with optional modifications as specified by the client during
interception.
This commit extends the forward HTLC intercept response with fields that
can be used in conjunction with a `ResumeModified` action to modify the
intercepted HTLC p2p message.
Implement an integration test where an HTLC is intercepted and the
interception response modifies fields in the resultant p2p message.
With this commit we make sure the first hop custom records aren't lost
on restart/resume of a payment, so we persist it as part of the
PaymentCreationInfo struct.
routing/bandwidth.go Show resolved Hide resolved
Copy link
Collaborator

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

htlcswitch/mock.go Outdated Show resolved Hide resolved
@guggero guggero force-pushed the extract-part2-from-staging-branch branch from 74a559d to 427d41d Compare September 5, 2024 16:02
@guggero guggero merged commit 31a6f87 into master Sep 5, 2024
27 of 33 checks passed
@guggero guggero deleted the extract-part2-from-staging-branch branch September 5, 2024 18:08
@guggero guggero restored the extract-part2-from-staging-branch branch September 5, 2024 18:49
@guggero guggero deleted the extract-part2-from-staging-branch branch September 5, 2024 18:51
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.

7 participants