-
Notifications
You must be signed in to change notification settings - Fork 378
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
Treat trying to deposit on a closed channel as recoverable error #4693
Conversation
Maybe fix raiden-network#4451 If a channel is not open, or is in a closing state (still open but waiting on the closing transaction result) the `set_total_deposit` function was throwing a `ValueError`. That is a valid and recoverable race condition so this commit introduces an appropriate error and handles it in all places where it can be thrown.
raiden/api/rest.py
Outdated
@@ -646,7 +647,7 @@ def open( | |||
return api_error(errors=str(e), status_code=HTTPStatus.PAYMENT_REQUIRED) | |||
except (NonexistingChannel, UnknownTokenAddress) as e: | |||
return api_error(errors=str(e), status_code=HTTPStatus.BAD_REQUEST) | |||
except (DepositOverLimit, DepositMismatch) as e: | |||
except (DepositOverLimit, DepositMismatch, ChannelNotOpenError) as e: |
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 am not sure about handling it here. Since this is right after opening in the same function I don't see how a race with the channel being closed can happen here.
But I opted to handle it here too just to be safe.
Codecov Report
@@ Coverage Diff @@
## develop #4693 +/- ##
===========================================
- Coverage 80.86% 80.83% -0.04%
===========================================
Files 118 118
Lines 14236 14226 -10
Branches 2197 2196 -1
===========================================
- Hits 11512 11499 -13
- Misses 2073 2089 +16
+ Partials 651 638 -13
Continue to review full report at Codecov.
|
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 am not confident this is the actual solution to the problem.
File "raiden/connection_manager.py", line 322, in _join_partner File "raiden/api/python.py", line 610, in set_total_channel_deposit ValueError: Channel is not in an open state.
are the relevant lines.
According to the stacktrace, the user was trying to "Join the network" by opening channel.
Looking at the code:
raiden/raiden/connection_manager.py
Line 307 in e8f0ac7
self.api.channel_open(self.registry_address, self.token_address, partner) |
The call here should actually wait until the channel is actually opened.
Lines 439 to 445 in e8f0ac7
waiting.wait_for_newchannel( | |
raiden=self.raiden, | |
token_network_registry_address=registry_address, | |
token_address=token_address, | |
partner_address=partner_address, | |
retry_timeout=retry_timeout, | |
) |
Then directly after that, the deposit starts.
raiden/raiden/connection_manager.py
Lines 317 to 323 in e8f0ac7
try: | |
self.api.set_total_channel_deposit( | |
registry_address=self.registry_address, | |
token_address=self.token_address, | |
partner_address=partner, | |
total_deposit=total_deposit, | |
) |
It is plausible that the partner closed the channel directly after it was created but i would say this is highly unlikely given the description in the issue and the verbal communication we got from @pirapira.
I would try to reproduce the issue before rushing into a solution. @pirapira can you help with that?
raiden/exceptions.py
Outdated
@@ -189,6 +189,10 @@ class DuplicatedChannelError(RaidenRecoverableError): | |||
"""Raised if someone tries to create a channel that already exists.""" | |||
|
|||
|
|||
class ChannelNotOpenError(RaidenRecoverableError): |
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.
Nitpick: I would generalize this to something like InvalidChannelState
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.
Hmmm perhaps unexpected channel state? Invalid would mean that it's something which we can't even parse.
I also think this is highly unlikely but under the circumstances and lack of logs this is all I can say about #4451 at this point. The potential race condition is there though and I think that replacing the ValueError with something better and handling this as a recoverable error just like it should be is a good move. |
If the issue depended on partner's behavior, maybe I need to reproduce the issue with the person on the other side of the channel. I try to find logs. How is a typical log file named? |
It looks like this: |
|
b242764
to
781ad64
Compare
I'm approving because a review from me was requested. I did not check the original issue to know if this PR fixes it, but the changes look fine to me. |
Augusto approved and as discussed the issue may be solved from this.
Maybe fix #4451
Description
If a channel is not open, or is in a closing state (still open but
waiting on the closing transaction result) the
set_total_deposit
function was throwing a
ValueError
.That is a valid and recoverable race condition so this commit
introduces an appropriate error and handles it in all places where it
can be thrown.
From the stack trace shown in #4451 this seems to have been the problem but without logs it's hard to say with 100% certainty.
PR review check list
Quality check list that cannot be automatically verified.