-
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
htlcswitch/hop: use InvalidOnionVersion for replayed packets #7937
Conversation
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.
Seems like this should be followed up with defining a spec error code, but something with BADONION
is def a better choice than temporary channel failure 👍
Why isn't Specifically: Lines 221 to 222 in 13568fd
|
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.
Why isn't testSphinxReplayPersistence failing before this PR?
@morehouse This is because when relaying HTLCs, the relaying node will convert the TemporaryChannelFailure
to FailInvalidOnionKey
. Looking at the test,
First, Dave sends a update_malformed_htlc
based on the check here, his logs,
2023-09-01 17:39:14.703 [ERR] HSWC: unable to process onion packet: sphinx packet replay attempted
2023-09-01 17:39:14.703 [ERR] HSWC: ChannelLink([ChanPoint: Carol=>Dave]): unable to decode onion hop iterator: TemporaryChannelFailure
...
2023-09-01 17:39:14.703 [DBG] PEER: Peer([Carol]): Sending UpdateFailMalformedHTLC(chan_id=902748dd38578ed72c6eba0307e5a004716a807f664b5d41eb483b0ae8faa39e, id=1, fail_code=TemporaryChannelFailure) to [Carol]@127.0.0.1:54338
Carol will check the failure code and send FailInvalidOnionKey
because of the check here, her logs,
2023-09-01 17:39:14.703 [DBG] PEER: Peer([Dave]): Received UpdateFailMalformedHTLC(chan_id=902748dd38578ed72c6eba0307e5a004716a807f664b5d41eb483b0ae8faa39e, id=1, fail_code=TemporaryChannelFailure) from [Dave]@127.0.0.1:5569
...
2023-09-01 17:39:14.703 [WRN] HSWC: ChannelLink([ChanPoint: Carol=>Dave]): unexpected failure code received in UpdateFailMailformedHTLC: TemporaryChannelFailure
...
2023-09-01 17:39:15.394 [INF] HSWC: Converting malformed HTLC error for circuit for Circuit(a8d2fa107cd88a5acf214564027a72e525968b1e85a2af19e69b74aa08a1c3be: (449:1:0, 0) <-> (442:1:0, 1))
Fred would receive the InvalidOnionKey
error as shown in his logs,
2023-09-01 17:39:16.143 [WRN] CRTR: Attempt 1 for payment a8d2fa107cd88a5acf214564027a72e525968b1e85a2af19e69b74aa08a1c3be failed: InvalidOnionKey(onion_sha=fbd635e56867841888333edf3c7e450a11f9d075a44211607d50eb7e9401e383)@1
After this change, Dave would now send InvalidOnionKey
,
2023-09-01 18:19:41.208 [DBG] PEER: Peer([Carol]): Sending UpdateFailMalformedHTLC(chan_id=a545313560caeed68ce9a4003af01904154b1e9621fd891a99a0155449371102, id=1, fail_code=InvalidOnionKey) to [Carol]@127.0.0.1:55071
The current test sends the payment using fred -> carol -> dave
. If we wanna test it, we can also send a payment using carol -> dave
and assert the expected failure code is returned.
@yyforyongyu thanks for the thorough explanation!
We should definitely test the new behavior. Extending |
7a34cac
to
e895b48
Compare
@Crypt-iQ, remember to re-request review from reviewers when ready |
40aca58
to
cf375e9
Compare
The unsafe-replay option only works if there's a multi-hop so testing carol -> dave won't work. I just modified the code to use InvalidOnionVersion and changed the itest so it now passes. In the future we might be able to use a specific failure code |
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.
Needs a rebase.
2343402
to
cb8b0bc
Compare
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
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.
Pending release notes, otherwise LGTM🙏
c9adc75
to
c34bfaa
Compare
added release notes |
Tagged it for 17.1. Need to update the release notes to 17.1 |
@Crypt-iQ release notes need to be updated for 0.17.1, then this can land. |
Updated the 0.17.1 release notes, but this is still based on 0-18-staging, what branch should this be based on instead? |
Since the merge window is open again, this can be based on |
Updated to be based on |
weird the CI seems to be halted |
The link will send an update_fail_malformed_htlc, so we need to set the BADONION bit. Since there isn't a replay-specific error, we set the failure code to InvalidOnionVersion which has the BADONION bit.
The link will send an update_fail_malformed_htlc, so we need to set the BADONION bit. Since there isn't a replay-specific error, we set the failure code to InvalidOnionVersion which has the BADONION bit.
It would be nice if there was a replay-specific failure code in the spec
Fixes #7851, #5792, #5443