Send payments to blinded routes#2482
Merged
Merged
Conversation
8860349 to
560cb25
Compare
Contributor
thomash-acinq
left a comment
There was a problem hiding this comment.
Can you add some tests to check that it actually works?
560cb25 to
55f6960
Compare
Member
Author
I added more tests in 55f6960, let me know if there are specific test cases that would be useful that I missed. I didn't add yet an e2e test because it would require the code from #2471 I also had to add utility test functions to generate blinded routes / bolt12 invoices, those should be cleaned up when we have #2471 |
0564362 to
f81512e
Compare
f81512e to
04019f9
Compare
Contributor
thomash-acinq
left a comment
There was a problem hiding this comment.
You should add the tests too now that #2499 has been merged, especially the zero-hop test which would not pass currently.
04019f9 to
2f65ed0
Compare
c8b9a38 to
426c4d6
Compare
426c4d6 to
39a4e5d
Compare
Since blinded routes have to be used from start to end and are somewhat similar to Bolt 11 routing hints, we model them as an abstract single hop during path-finding. This makes it trivial to reuse existing algorithms without any modifications. We then add support for paying blinded routes. We introduce a new type of recipient for those payments, that uses blinded hops and creates onion payloads accordingly. There is a subtlety in the case where we're the introduction of the blinded route: when that happens we need to decrypt the first payload to figure out where to send the payment. When we receive a failure from a blinded route, we simply ignore it in retries: we don't know what caused the issue so we assume it's permanent, which makes sense in most cases since we cannot change the relaying parameters (fees and expiry delta are chosen by the recipient).
db15525 to
002a741
Compare
thomash-acinq
previously approved these changes
Dec 16, 2022
thomash-acinq
approved these changes
Dec 16, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since blinded routes have to be used from start to end and are somewhat similar to Bolt 11 routing hints, we model them as an abstract single hop during path-finding. This makes it trivial to reuse existing algorithms without any modifications.
We then add support for paying blinded routes. We introduce a new type of recipient for those payments, that uses blinded hops and creates onion payloads accordingly. There is a subtlety in the case where we're the introduction of the blinded route: when that happens we need to decrypt the first payload to figure out where to send the payment.
When we receive a failure from a blinded route, we simply ignore it in retries: we don't know what caused the issue so we assume it's permanent, which makes sense in most cases since we cannot change the relaying parameters (fees and expiry delta are chosen by the recipient).
By building on top of #2480, the change is quite easy to review and doesn't impact the payment state machines much. I've added a lot of e2e tests #2490, where the error handling has (finally) been correctly implemented.
This is an alternative to #2467: what I didn't like in that PR were:
Partialpayment onion class, which is a clear layering violation and requires reviewers to look at the whole flow of code to verify that this object contains the right data (it's quite foot-gunny because a tlv stream isn't strongly typed, it may records you don't expect...)PaymentPacket.scala, which became very hard to readShortChannelIdin blinded hops, which was hiding subtle issuesI tried to build on top of #2467 at first, but when I realized that it was important to add the new abstraction proposed in #2480, it was impossible to do. I did pick a lot of the code from that PR though, most of the actual business logic is the same, it's just the abstractions that are different.