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

Internal server error when depositing to a channel #1916

Closed
kelsos opened this Issue Jul 22, 2018 · 2 comments

Comments

Projects
None yet
4 participants
@kelsos
Contributor

kelsos commented Jul 22, 2018

Problem Definition

While attempting to deposit in a channel I got a 500 internal server error.

curl 'http://localhost:5001/api/1/channels/0x0f114A1E9Db192502E7856309cc899952b3db1ED/0xFC57d325f23b9121a8488fFdE2E6b3ef1208a20b' -X PATCH -H 'Origin: http://localhost:5001' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36' -H 'Content-Type: application/json' -H 'Accept: application/json, text/plain, */*' -H 'Referer: http://localhost:5001/ui/channels' -H 'Cookie: io=1Zpb4VAIJd9pWdugAAAA' -H 'Connection: keep-alive' --data-binary '{"total_deposit":5}' --compressed
Traceback (most recent call last):
  File "/home/kelsos/development/github/raiden/env/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/kelsos/development/github/raiden/env/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/kelsos/development/github/raiden/env/lib/python3.6/site-packages/flask_restful/__init__.py", line 480, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/kelsos/development/github/raiden/env/lib/python3.6/site-packages/flask/views.py", line 88, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/kelsos/development/github/raiden/env/lib/python3.6/site-packages/flask_restful/__init__.py", line 595, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/kelsos/development/github/raiden/env/lib/python3.6/site-packages/webargs/core.py", line 441, in wrapper
    return func(*args, **kwargs)
  File "/home/kelsos/development/github/raiden/raiden/api/v1/resources.py", line 65, in patch
    **kwargs,
  File "/home/kelsos/development/github/raiden/raiden/api/rest.py", line 790, in patch_channel
    result = self._deposit(registry_address, channel_state, total_deposit)
  File "/home/kelsos/development/github/raiden/raiden/api/rest.py", line 693, in _deposit
    total_deposit,
  File "/home/kelsos/development/github/raiden/raiden/api/python.py", line 358, in set_total_channel_deposit
    channel_proxy.set_total_deposit(total_deposit)
  File "/home/kelsos/development/github/raiden/raiden/network/proxies/payment_channel.py", line 110, in set_total_deposit
    self.token_network.set_total_deposit(total_deposit, self.participant2)
  File "/home/kelsos/development/github/raiden/raiden/network/proxies/token_network.py", line 428, in set_total_deposit
    raise ValueError(f'deposit {amount_to_deposit} must be greater than 0.')
ValueError: deposit -5 must be greater than 0.

System Description

Linux thoth 4.17.8-1-ARCH #1 SMP PREEMPT Wed Jul 18 09:56:24 UTC 2018 x86_64 GNU/Linux
/usr/bin/solc
solc, the solidity compiler commandline interface
Version: 0.4.24+commit.e67f0147.Linux.g++
/usr/bin/geth
Geth
Version: 1.8.12-stable
Git Commit: 37685930d953bcbe023f9bc65b135a8d8b8f1488
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.10.3
Operating System: linux
GOPATH=
GOROOT=/usr/lib/go
/usr/bin/parity
Parity
  version Parity/v1.10.9-stable-23a9eefd64-20180707/x86_64-linux-gnu/rustc1.27.1
Copyright 2015, 2016, 2017, 2018 Parity Technologies (UK) Ltd
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

By Wood/Paronyan/Kotewicz/Drwięga/Volf
   Habermeier/Czaban/Greeff/Gotchac/Redmann

08c37279de96b26ffcc78559f861a4e7f555a7f7

@andrevmatos

This comment has been minimized.

Collaborator

andrevmatos commented Jul 22, 2018

From your curl, looks like you tried to do that from webUI, right? This is caused by the fact that Raiden only accepts a total_deposit (idempotent) value for the deposited amount in a given channel. To be able to set a desired amount, the client (in the case, webui) should fetch the current channel balance from Raiden API, and use it to calculate the new total_deposit. As I can see from the logs, looks like your previous balance was 10, and you tried setting total_deposit=5, which would cause an amount to be deposited of -5, which is invalid. The webUI fetches the current balance straight from the raiden API, so it may be caused by either a outdated value (there's still some issues with events not being correctly picked, or being doubly picked, like #1910, which causes some issues with internal state), or some pending previous operation, which wasn't picked yet by the node. We may improve that with some locks soon.

@kelsos

This comment has been minimized.

Contributor

kelsos commented Jul 22, 2018

Yes this was a webUI request on a new channel that should have a balance of 10 but instead, it reported a balance of 0. After I deposited a total of 15 everything worked as expected. and the webUI properly updated the deposit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment