-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[reliable payments] Move payment error deobfuscation to router #3063
[reliable payments] Move payment error deobfuscation to router #3063
Conversation
d1dc602
to
8575d62
Compare
ba14744
to
77ffe6c
Compare
d9ccc34
to
80c2dfc
Compare
PTAL @Roasbeef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@halseth completed an initial pass, most everything looks good though i think there's a potential race between GetPaymentResult
and removePendingPayment
.
f4a6cd4
to
a3fbc87
Compare
ebcfe7b
to
7e552a0
Compare
needs rebase as well :) |
The switch satisfies this interface, and makes it easy to mock the send method from the router.
This commit moves the responsibility of generating a unique payment ID from the switch to the router. This will make it easier for the router to keep track of which HTLCs were successfully forwarded onto the network, as it can query the switch for existing HTLCs as long as the paymentIDs are kept. The router is expected to maintain a map from paymentHash->paymentID, such that they can be replayed on restart. This also lets the router check the status of a sent payment after a restart, by querying the switch for the paymentID in question.
We will later persist the fields necessary to decrypt a received error.
With the following commits, it'll become important to not resuse paymentIDs, since there is no way to tell whether the HTLC in question has already been forwarded and settled/failed. We clarify this in the SendHTLC comments, and alter the tests to not attempt to resend an HTLC with a duplicate payment ID.
This lets us distinguish an critical error from a actual payment result (success or failure). This is important since we know that we can only attempt another payment when a final result from the previous payment attempt is received.
We extract the session key such that we can later store it across restarts.
In this commit we move handing the deobfuscator from the router to the switch from when the payment is initiated, to when the result is queried. We do this because only the router can recreate the deobfuscator after a restart, and we are preparing for being able to handle results across restarts. Since the deobfuscator cannot be nil anymore, we can also get rid of that special case.
7e552a0
to
cd02c22
Compare
Rebased :) PTAL @joostjager @cfromknecht |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another step closer to reliable payments! LGTM 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🌋
This PR consists of two important pieces of #2761:
Make
router
<->switch
interaction asyncWe define
PaymentResult
and the methodGetPaymentResult
exposed by the
switch
.This lets us distinguish an critical error from a actual payment result
(success or failure). This is important since we know that we can only
attempt another payment when a final result from the previous payment
attempt is received.
In order to achieve this we let the
router
handling generatingpaymentID
s,since they are used to later query the
switch
for the final result.Move payment error deobfuscation
In this commit we move handing the deobfuscator from the router to the
switch from when the payment is initiated, to when the result is
queried.
We do this because only the router can recreate the deobfuscator after a
restart, and we are preparing for being able to handle results across
restarts.
Since the deobfuscator cannot be nil anymore, we can also get rid of
that special case.
Split off from #2761