Skip to content
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

Inputting an address for an ethereum RPC node can throw 500 if an http exception is raised #927

Closed
LefterisJP opened this issue Apr 25, 2020 · 0 comments · Fixed by #954
Closed
Assignees
Milestone

Comments

@LefterisJP
Copy link
Member

Problem Definition

A user tried to input a quicknode URL as the ethereum rpc endpoint for Rotki. In one case it worked and in the other it did not with Rotki throwing a 500 error.

Relevant logs:

25/04/2020 13:11:04 EDT -- INFO:rotkehlchen.api.server.pywsgi:127.0.0.1 - - [2020-04-25 13:11:04] "OPTIONS /api/1/settings HTTP/1.1" 200 319 0.001073
25/04/2020 13:11:04 EDT -- DEBUG:web3.providers.HTTPProvider:Making request HTTP. URI: https://<edited>, Method: web3_clientVersion
25/04/2020 13:11:04 EDT -- DEBUG:rotkehlchen.api.rest:Request successful response={"result": {"warnings": [], "errors": []}, "message": ""}, status_code=200
25/04/2020 13:11:04 EDT -- INFO:rotkehlchen.api.server.pywsgi:127.0.0.1 - - [2020-04-25 13:11:04] "GET /api/1/messages/ HTTP/1.1" 200 245 0.000892
25/04/2020 13:11:04 EDT -- DEBUG:rotkehlchen.api.rest:Request successful response={"result": {"last_balance_save": 1587833627, "eth_node_connection": false, "history_process_start_ts": -1, "history_process_current_ts": -1}, "message": ""}, status_code=200
25/04/2020 13:11:04 EDT -- INFO:rotkehlchen.api.server.pywsgi:127.0.0.1 - - [2020-04-25 13:11:04] "GET /api/1/periodic/ HTTP/1.1" 200 345 0.000973
25/04/2020 13:11:04 EDT -- DEBUG:web3.providers.HTTPProvider:Getting response HTTP. URI: https://<edited>, Method: web3_clientVersion, Response: {'jsonrpc': '2.0', 'result': 'Parity-Ethereum//v2.5.13-stable-253ff3f-20191231/x86_64-linux-gnu/rustc1.40.0', 'id': 0}
25/04/2020 13:11:04 EDT -- DEBUG:web3.RequestManager:Making request. Method: eth_chainId
25/04/2020 13:11:04 EDT -- DEBUG:web3.providers.HTTPProvider:Making request HTTP. URI: https://<edited>, Method: eth_chainId
25/04/2020 13:11:04 EDT -- DEBUG:web3.providers.HTTPProvider:Getting response HTTP. URI: https://<edited>, Method: eth_chainId, Response: {'jsonrpc': '2.0', 'result': '0x1', 'id': 1}
25/04/2020 13:11:04 EDT -- DEBUG:web3.RequestManager:Making request. Method: eth_syncing
25/04/2020 13:11:04 EDT -- DEBUG:web3.providers.HTTPProvider:Making request HTTP. URI: https://<edited>, Method: eth_syncing
25/04/2020 13:11:04 EDT -- DEBUG:web3.providers.HTTPProvider:Making request HTTP. URI: https://<edited>, Method: eth_syncing
25/04/2020 13:11:05 EDT -- DEBUG:web3.providers.HTTPProvider:Making request HTTP. URI: https://<edited>, Method: eth_syncing
25/04/2020 13:11:05 EDT -- DEBUG:web3.providers.HTTPProvider:Making request HTTP. URI: https://<edited>, Method: eth_syncing
25/04/2020 13:11:05 EDT -- DEBUG:web3.providers.HTTPProvider:Making request HTTP. URI: https://<edited>, Method: eth_syncing
25/04/2020 13:11:05 EDT -- ERROR:rotkehlchen.api.server:Exception on /api/1/settings [PUT]
Traceback (most recent call last):
  File "flask/app.py", line 1949, in full_dispatch_request
  File "flask/app.py", line 1935, in dispatch_request
  File "flask_restful/__init__.py", line 458, in wrapper
  File "flask/views.py", line 89, in view
  File "flask_restful/__init__.py", line 573, in dispatch_request
  File "webargs/core.py", line 366, in wrapper
  File "rotkehlchen/api/v1/resources.py", line 175, in put
  File "rotkehlchen/api/rest.py", line 109, in wrapper
  File "rotkehlchen/api/rest.py", line 247, in set_settings
  File "rotkehlchen/rotkehlchen.py", line 601, in set_settings
  File "rotkehlchen/chain/manager.py", line 182, in set_eth_rpc_endpoint
  File "rotkehlchen/chain/ethereum/manager.py", line 161, in set_rpc_endpoint
  File "rotkehlchen/chain/ethereum/manager.py", line 103, in attempt_connect
  File "web3/eth.py", line 78, in syncing
  File "web3/manager.py", line 109, in request_blocking
  File "web3/manager.py", line 96, in _make_request
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "web3/middleware/formatting.py", line 50, in apply_formatters
  File "web3/middleware/gas_price_strategy.py", line 18, in middleware
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "web3/middleware/formatting.py", line 50, in apply_formatters
  File "web3/middleware/attrdict.py", line 18, in middleware
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "web3/middleware/formatting.py", line 50, in apply_formatters
  File "web3/middleware/normalize_errors.py", line 9, in middleware
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "web3/middleware/formatting.py", line 50, in apply_formatters
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "web3/middleware/formatting.py", line 50, in apply_formatters
  File "web3/middleware/exception_retry_request.py", line 83, in middleware
  File "web3/providers/rpc.py", line 68, in make_request
  File "web3/_utils/request.py", line 27, in make_post_request
  File "requests/models.py", line 940, in raise_for_status
requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: https://<edited>

It's due to Rotki not handling http requests to an own node like other http requests and not catching failures properly.

Task

Handle http errors and if it's a 429 retry again after backing off for a few seconds.

@LefterisJP LefterisJP added this to the v1.5.0 milestone Apr 25, 2020
@LefterisJP LefterisJP added this to To do in Next minor release via automation Apr 25, 2020
@LefterisJP LefterisJP modified the milestones: v1.5.0, v1.4.2 Apr 26, 2020
@LefterisJP LefterisJP added this to To do in Next patch release via automation Apr 26, 2020
@LefterisJP LefterisJP removed this from To do in Next minor release Apr 26, 2020
@LefterisJP LefterisJP self-assigned this Apr 28, 2020
@LefterisJP LefterisJP moved this from To do to In progress in Next patch release Apr 28, 2020
LefterisJP added a commit to LefterisJP/rotkehlchen that referenced this issue Apr 28, 2020
This should fix rotki#927 and all similar cases where a web3 request would
fail with a retriable HTTP Request exception.
Next patch release automation moved this from In progress to Done Apr 29, 2020
LefterisJP added a commit that referenced this issue Apr 29, 2020
This should fix #927 and all similar cases where a web3 request would
fail with a retriable HTTP Request exception.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

1 participant