-
Notifications
You must be signed in to change notification settings - Fork 906
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
Store failcode of local forward failure into DB (completed) #2524
Merged
Conversation
This file contains 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
trueptolemy
changed the title
DB: Store failcode of local forward into DB
DB: Store failcode of local forward failure into DB
Apr 2, 2019
trueptolemy
force-pushed
the
issue-2435
branch
6 times, most recently
from
April 3, 2019 15:23
f2b4585
to
c25c7f2
Compare
trueptolemy
changed the title
DB: Store failcode of local forward failure into DB
WIP: Store failcode of local forward failure into DB
Apr 4, 2019
trueptolemy
force-pushed
the
issue-2435
branch
7 times, most recently
from
April 30, 2019 14:47
03f2fb5
to
8f1771b
Compare
trueptolemy
changed the title
WIP: Store failcode of local forward failure into DB
Store failcode of local forward failure into DB (completed)
Apr 30, 2019
Hi! @cdecker I've done. What do you think about? Thank you! |
Removed the WIP tag, will review asap |
trueptolemy
force-pushed
the
issue-2435
branch
2 times, most recently
from
May 1, 2019 12:32
3bbaec5
to
b070dd5
Compare
cdecker
requested changes
May 2, 2019
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.
Just two minor cleanups:
- Reordering the
sqlite3_bind_*
calls would simplify theif-else
-statements - Reordering commits would fix bisectability
In addition I'd like to fix the JSON-output to be machine readable.
In FORWARD_LOCAL_FAILED case, we can get the failcode and can't get the resolve time, that is different with FORWARD_FAILED case.
It's a optional field. We only set failcode for FORWARD_LOCAL_FAILED case, and set this field with 0 in other case.
Here I add the test for this 5 local_failed case in this commit. There 5 cases for FORWARD_LOCAL_FAILED status: 1. When Msater resolves the reply about the next peer infor(sent by Gossipd), and need handle unknown next peer failure in channel_resolve_reply(); 2. When Master handle the forward process with the htlc_in and the id of next hop, it tries to drive a new htlc_out but fails in forward_htlc(); 3. When we send htlc_out, Master asks Channeld to add a new htlc into the outgoing channel but Channeld fails. Master need handle and store this failure in rcvd_htlc_reply(); 4. When Channeld receives a new revoke message, if the state of corresponding htlc is RCVD_ADD_ACK_REVOCATION, Master will tries to resolve onionpacket and handle the failure before resolving the next hop in peer_got_revoke(); 5. When Onchaind finds the htlc time out or missing htlc, Master need handle these failure as FORWARD_LOCAL_FAILED in if it's forward payment case.
ACK 88a28d5 |
cdecker
approved these changes
May 3, 2019
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.
Store failcode of local forward into DB, and thus listforwards will show the failcode for local failed forwarding payment.(issue #2435 )
Add a new status for forward payment: FORWARD_LOCAL_FAILED.
It means we meet failure locally, and we can fetch and store the failcode.
Add failcode field in
forwarded_payments
table;Add failcode arugument in function
wallet_forwarded_payment_add()
;Store local failure in forward process by calling
wallet_forwarded_payment_add()
;Here are 5 case I think we should handle as
local_failed
:Case 1. When Msater resolves the reply about the next peer infor(sent by Gossipd), and need handle unknown next peer failure in
channel_resolve_reply()
.Test for this case: I ask l1 pay to l3 through l2 but close the channel between l2 and l3 after
getroute()
, the payment will fail in l2 because ofWIRE_UNKNOWN_NEXT_PEER
;Case 2. When Master handle the forward process with the
htlc_in
and the id of next hop, it tries to drive a newhtlc_out
but fails inforward_htlc()
.Test for this case: I ask l1 pay to 14 through with no fee, so the payment will fail in l2 becase of
WIRE_FEE_INSUFFICIENT
;Case 3. When we send
htlc_out
, Master asks Channeld to add a new htlc into the outgoing channel but Channeld fails. Master need handle and store this failure inrcvd_htlc_reply()
.Test for this case: I ask l1 pay to l5 with 10^8 sat through the channel (l2-->l5) with the max capacity of 10^4 msat , the payment will fail in l2 because of
CHANNEL_ERR_MAX_HTLC_VALUE_EXCEEDED
;Case 4. When Channeld receives a new revoke message, if the state of corresponding htlc is RCVD_ADD_ACK_REVOCATION, Master will tries to resolve onionpacket and handle the failure before resolving the next hop in
peer_got_revoke()
.Test for this case: I ask l6 pay to l4 through l1 and l2, but we replace the second node_id in
[route]
with the wrong one, so the payment will fail in l2 because of WIRE_INVALID_ONION_KEY;Case 5. When Onchaind finds the htlc time out or missing htlc, Master need handle these failure as
FORWARD_LOCAL_FAILED
in if it's forward payment case.Test for this case: I ask l1 pay to l4 through l2 with the amount less than the invoice(the payment must fail in l4), and we also ask l5 disconnected before sending update_fail_htlc, so the htlc will be holding until l2 meets timeout and handle it as local_fail.
EDIT: The last commit in Heisei era.