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

blindedpath: Minor bug fixes and feature addition. #9026

Merged

Conversation

ziggie1984
Copy link
Collaborator

@ziggie1984 ziggie1984 commented Aug 22, 2024

Fixes 2 bugs:

  1. We don't need to strictly correlate the invoice expiry with the min_cltv_delta value.
  2. Moreover we should respect the minHTLC constraint when creating the blinded route and moreover when adding a buffer to the channel policy when we try to blur the real policy values.

Planning to also add the SendToBlindedPath feature when when the sending node is the introduction point.

Copy link
Contributor

coderabbitai bot commented Aug 22, 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 as 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.

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

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.

@ziggie1984 ziggie1984 force-pushed the bugfix-minHTLC-blindedpath branch from 0290e64 to f7dc1c4 Compare August 22, 2024 14:37
@ziggie1984 ziggie1984 changed the title blindedpath: fix minHTLC constraint. blindedpath: Minor bug fixes and feature addition. Aug 22, 2024
@ellemouton ellemouton self-requested a review August 22, 2024 14:47
Copy link
Collaborator

@ellemouton ellemouton 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 the quick fixes.

Comment on lines -108 to -113
if cfg.MinFinalCLTVExpiryDelta >= cfg.BlocksUntilExpiry {
return nil, fmt.Errorf("blinded path CLTV expiry delta (%d) "+
"must be greater than the minimum final CLTV expiry "+
"delta (%d)", cfg.BlocksUntilExpiry,
cfg.MinFinalCLTVExpiryDelta)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we put this in it's own commit pls 🙏

Copy link
Collaborator

Choose a reason for hiding this comment

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

one thing, one commit :)

@@ -148,7 +150,7 @@ func BuildBlindedPaymentPaths(cfg *BuildBlindedPathCfg) (
continue
} else if err != nil {
log.Errorf("Not using route (%s) as a blinded path: %v",
err)
route, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

🙏 thanks

Comment on lines 440 to 444
if policy.MinHTLCMsat > cfg.ValueMsat {
return nil, 0, 0, fmt.Errorf("minHTLC of hop policy "+
"larger than payment amt: sentAmt(%v), "+
"minHTLC(%v)", cfg.ValueMsat,
policy.MinHTLCMsat)
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@ziggie1984 ziggie1984 marked this pull request as ready for review August 22, 2024 15:37
@saubyk saubyk added this to the v0.18.3 milestone Aug 22, 2024
Removes a check where we would NOT allow to create a blinded invoice
with an expiry (invoice expiry in seconds considered as block time)
lower than the min_final_ctlv_delta.
@ziggie1984 ziggie1984 force-pushed the bugfix-minHTLC-blindedpath branch from f7dc1c4 to 12bbf81 Compare August 22, 2024 15:53
// hops cannot have a higher cltv delta otherwise it will get rejected
// by the forwarding nodes or the final node.
//
// This number should at least be greater than the invoice expiry time
Copy link
Member

Choose a reason for hiding this comment

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

Q: can this value be equal to the invoice's final cltv delta?

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 this value is not related to the final_cltv value, the final_cltv_value is added on top of this expiry when calculating the payment constraint for each blinded hop.

@@ -435,11 +437,27 @@ func collectRelayInfo(cfg *BuildBlindedPathCfg, path *candidatePath) (
}
}

policy, err = cfg.AddPolicyBuffer(policy)
if policy.MinHTLCMsat > cfg.ValueMsat {
return nil, 0, 0, fmt.Errorf("minHTLC of hop policy "+
Copy link
Member

Choose a reason for hiding this comment

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

I think this should wrap an errInvalidBlindedPath, like how we handle if minHTLC > maxHTLC { below.

// NOTE: We don't check this for maxHTLC, because the payment
// amount can always be splitted using MPP.
if bufferPolicy.MinHTLCMsat <= cfg.ValueMsat {
policy = bufferPolicy
Copy link
Member

Choose a reason for hiding this comment

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

IIUC we should not choose this hop if the buffered policy cannot meet our requirement? I think we can do a single check on this if bufferPolicy.MinHTLCMsat > cfg.ValueMsat { and return a wrapped errInvalidBlindedPath here if bufferPolicy.MinHTLCMsat is at least policy.MinHTLCMsat

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought about this as well, but I changed my mind because based on how we figured out this behaviour. Sometimes you just want to test quickly and select 1 sat as an amount, in this case we would fail creating this invoice so I decided for this rare case to just not use the policy wdyt, at the end I think this behaviour is very unlikely in general but more likely when testing ?

Copy link
Member

Choose a reason for hiding this comment

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

yeah no strong opinion here (since i don't know it well😂), more like a question so feel free to ignore it.

We will not add a buffer to the chan policy for blinded paths in case
the sender amount violates the minHTLC restriction in the first place.

Moreover we disgard a route fast if the payment amount is smaller than
the minHTLC along the route.
@ziggie1984 ziggie1984 force-pushed the bugfix-minHTLC-blindedpath branch from 12bbf81 to 816b25e Compare August 22, 2024 17:45
Copy link
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

LGTM🙏

@guggero guggero merged commit d0d3975 into lightningnetwork:master Aug 23, 2024
21 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants