-
Notifications
You must be signed in to change notification settings - Fork 43
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
fix(swaps): validate Raiden's resolve request #1172
Conversation
Please open an issue on raiden side for the crash @erkarl |
b18dcaa
to
bd57361
Compare
There already is: ExchangeUnion/raiden#1 |
I successfully tested this branch on native simnet, which since #1080 changed the behaviour of the XUD resolver when it gets an unfamiliar rHash and caused raiden to crash. With this branch, this is handled gracefully and raiden doesn't crash. |
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.
Looks nice, the 400/404/500 HTTP error codes here are much more sensible than returning plain error message strings in place of the preimage. Just a few questions/suggestions below.
lib/raidenclient/types.ts
Outdated
@@ -68,6 +68,7 @@ export type RaidenResolveRequest = { | |||
reveal_timeout: number; |
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.
Should we be removing reveal and settle timeout as part of this PR? Or are you planning to do this separately? I'm thinking if it's done together this can be marked as closing #1149.
If so, you can also remove the commented out "unused" fields below.
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.
Yes, absolutely - good idea.
lib/http/HttpServer.ts
Outdated
if (err.code === errorCodes.INVALID_ARGUMENT) { | ||
if ( | ||
err.code === errorCodes.INVALID_ARGUMENT || | ||
err.code === swapErrorCodes.INVALID_RESOLVE_REQUEST |
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.
I'm thinking I should've made this a switch
statement when I wrote this originally, but now I think it's even more clearly the nicer choice. Would you mind rewriting these if/elses as a switch?
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.
Rewrote this as switch - looks much better now, thanks.
bd57361
to
801a4dc
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.
Thanks, one last (or maybe two) change re: the new switch statement then this should be good to merge.
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.
Looks good! Do you think you could put the tslint rule in a separate commit tho?
c904006
to
e98de8f
Compare
@erkarl @sangaman could you please revisit this PR and merge it asap? The raiden in my local simnet instance is crashing a lot which causes some issues with the balancing of the initial deposit. |
In this commit we validate Raiden's resolve request to make sure the payment we're receiving has the previously agreed upon `deal.makerCltvDelta` as the minimum duration of the lock. In addition we change the error handling to return a status code 400 (Bad Request) to prevent Raiden from crashing. Previously we returned a status code of 200 with the response `{ secret: 'error message' }`.
85bf023
to
6d525a7
Compare
In this commit we validate Raiden's resolve request to make sure the
payment we're receiving has the previously agreed upon
deal.makerCltvDelta
as theminimum duration of the lock.
In addition we change the error handling to return a status code 400
(Bad Request) to prevent Raiden from crashing. Previously we returned a
status code of 200 with the response of
{ secret: 'error message' }
.Closes: #1149