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

Routing to blinded payment paths #2120

Merged

Conversation

valentinewallace
Copy link
Contributor

@valentinewallace valentinewallace commented Mar 22, 2023

Support finding a route to a recipient who is behind blinded payment paths, which are provided in BOLT12 invoices.

  • finish tests

Based on #2258, #2305.

@valentinewallace valentinewallace force-pushed the 2023-03-blinded-pathfinding branch 2 times, most recently from 6841e43 to 6e6f76e Compare March 22, 2023 00:48
@jkczyz jkczyz self-requested a review March 22, 2023 19:18
@valentinewallace valentinewallace force-pushed the 2023-03-blinded-pathfinding branch 3 times, most recently from c0c4a84 to d5c978c Compare March 22, 2023 21:43
@codecov-commenter
Copy link

codecov-commenter commented Mar 22, 2023

Codecov Report

Patch coverage: 94.61% and project coverage change: +0.81 🎉

Comparison is base (d78dd48) 90.48% compared to head (6c3ca55) 91.30%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2120      +/-   ##
==========================================
+ Coverage   90.48%   91.30%   +0.81%     
==========================================
  Files         104      106       +2     
  Lines       53920    63000    +9080     
  Branches    53920    63000    +9080     
==========================================
+ Hits        48792    57525    +8733     
- Misses       5128     5475     +347     
Impacted Files Coverage Δ
lightning/src/offers/invoice_request.rs 93.38% <ø> (ø)
lightning/src/offers/refund.rs 94.39% <ø> (ø)
lightning/src/offers/invoice.rs 90.18% <94.11%> (ø)
lightning/src/routing/router.rs 93.55% <94.61%> (+0.34%) ⬆️
lightning/src/offers/test_utils.rs 96.72% <100.00%> (ø)

... and 17 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@valentinewallace valentinewallace marked this pull request as ready for review March 23, 2023 17:10
@TheBlueMatt TheBlueMatt added this to the 0.0.115 milestone Mar 25, 2023
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

We should definitely land at least the new serialization backwards-incompatible hints tlvs for the next release.

@valentinewallace valentinewallace force-pushed the 2023-03-blinded-pathfinding branch 3 times, most recently from ad8ccbf to 559ec3b Compare May 9, 2023 19:25
if blinded_path.blinded_hops.len() == 0 {
return Err(LightningError{err: "0-hop blinded path provided".to_owned(), action: ErrorAction::IgnoreError});
} else if &blinded_path.introduction_node_id == our_node_pubkey {
log_info!(logger, "Got blinded path with ourselves as the introduction node, ignoring");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this get some kind of TODO? Or should we just always use this path directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't use these paths atm because get_route doesn't have the ability to "advance" the blinded path to the next hop (and we can't pathfind to ourselves, ofc). Previously discussed here: #2146 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I misunderstood that comment, so I think there's another way to handle this - let get_route return early with a 0-hop unblinded path portion and the blinded tail as-is. Then the paying code would handle it by detecting this case and doing the advancing itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I don't see how that would work if the max_htlc of the 1 blinded hint isn't sufficient for the entire payment?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Mmm right, I suppose we could pre-select it as a path and then run the router to select more paths if needed? That seems like it would work pretty easy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that sounds good! We might want to have another prefactor, though, because there's still assumptions that path.hops.len() > 0 scattered around. Will look into that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI, two more notes on this approach:

  1. We may end up double-booking our own channel liquidity, since we don't know which of our channels is being used inside the blinded path (double-booking liquidity is a general problem for blinded pathfinding anyway, though)
  2. ISTM we'll always want to go through the process of selecting additional paths, because the blinded path where we are the intro node may be the most expensive option

For (1), we could decrement each of our available channel balances by the amount used on the path. Not sure it's if worth the additional complexity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm gonna address this in a follow-up since this PR is growing. IMO our offers code should still advance blinded paths before pathfinding to them, though adding the behavior you describe is good for keeping find_route general-purpose

@jkczyz jkczyz mentioned this pull request May 10, 2023
60 tasks
@valentinewallace valentinewallace added this to the 0.0.116 milestone May 15, 2023
@valentinewallace valentinewallace force-pushed the 2023-03-blinded-pathfinding branch 2 times, most recently from b181025 to c90a259 Compare May 16, 2023 21:35
@valentinewallace
Copy link
Contributor Author

Rebased to fix CI, also squashed.

@valentinewallace valentinewallace force-pushed the 2023-03-blinded-pathfinding branch from c90a259 to 8012de1 Compare May 16, 2023 21:39
Comment on lines 1506 to 1508
fees: RoutingFees {
base_msat: blinded_payinfo.fee_base_msat,
proportional_millionths: blinded_payinfo.fee_proportional_millionths,
Copy link
Contributor

Choose a reason for hiding this comment

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

More of a comprehension question - if a recipient includes a dummy hop, we'll send extra sats for this dummy hop's fees that will go to the recipient right? Is there anything stopping a recipient from always making a sender slightly overpay as long as there's a route with enough liquidity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dummy hops don't cost extra fees, since agregated fees for use of the entire blinded path are calculated by the recipient per https://github.com/lightning/bolts/blob/master/proposals/route-blinding.md#blinded-payments, based on the non-dummy hops' feerates. I think the recipient could make the sender overpay, though, if they just added extra fees on top of the aggregated fees?

Copy link
Contributor

Choose a reason for hiding this comment

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

Dummy hops don't cost extra fees, since agregated fees for use of the entire blinded path are calculated by the recipient per https://github.com/lightning/bolts/blob/master/proposals/route-blinding.md#blinded-payments

Oh I see, thanks

I think the recipient could make the sender overpay, though, if they just added extra fees on top of the aggregated fees?

I realize reading more of the proposal that recipients are even encouraged to in order to avoid probing, although I also saw this section where the recipient pays the blinded fees which was interesting. But yea, seems like nothing's really stopping a recipient from getting the sender to overpay as long as its not outrageous...🤷

@valentinewallace valentinewallace force-pushed the 2023-03-blinded-pathfinding branch 2 times, most recently from 3329fe3 to 776bd7d Compare June 14, 2023 23:22
@valentinewallace valentinewallace force-pushed the 2023-03-blinded-pathfinding branch 2 times, most recently from b59cf53 to c2cc256 Compare June 15, 2023 21:06
@valentinewallace
Copy link
Contributor Author

Squashed.

Copy link
Contributor

@jkczyz jkczyz left a comment

Choose a reason for hiding this comment

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

Largely looks good though I need to do a more detailed pass at the last commit still.

@valentinewallace valentinewallace force-pushed the 2023-03-blinded-pathfinding branch from c2cc256 to 8d4b6da Compare June 16, 2023 14:09
@valentinewallace valentinewallace force-pushed the 2023-03-blinded-pathfinding branch from 8d4b6da to a02a157 Compare June 16, 2023 15:17
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

LGTM, I think, feel free to squash fixups.

@valentinewallace valentinewallace force-pushed the 2023-03-blinded-pathfinding branch from a02a157 to ddf497d Compare June 16, 2023 17:33
jkczyz
jkczyz previously approved these changes Jun 16, 2023
TheBlueMatt
TheBlueMatt previously approved these changes Jun 17, 2023
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

One small thing worth fixing in a followup, though I'm not even sure the code is actually reachable.

It's unclear what values 1-hop blinded paths should set their BlindedPayInfos
to, because those values are meant to refer to the fees/cltv delta on the path
*between* the intro node and the destination. We zero out these values in the
new variant's methods so they don't mess with path finding/construction.
We don't need to collect a vec of Results anymore.
Sending to them is still disallowed, for now.
@TheBlueMatt TheBlueMatt merged commit ba342de into lightningdevkit:main Jun 20, 2023
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.

6 participants