nucypher / nucypher-monitor

NuCypher network intelligence crawler and web dashboard
7 stars 15 forks source link

Check for events causes Connection Error with web3 provider #104

Closed derekpierre closed 2 years ago

derekpierre commented 2 years ago

Receive the following exception with our web3 provider.

    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

This error does not occur with other providers.

derekpierre commented 2 years ago

Seems like the issue occurs for all events, and may be related to how far in the past the query begins (i.e. the fromBlock value).

May be related to why Infura went this route - https://blog.infura.io/faster-logs-and-events-e43e2fa13773/

derekpierre commented 2 years ago

The failure seems periodic (sometimes works, sometimes fails) and irrespective of event being collected. There may be some association with load on the geth node. Sometimes I run a simple nucypher status events command for the current period using our web3 provider and it works fine.

Full stack trace of error:

File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/contract.py", line 1337, in getLogs
    logs = self.web3.eth.getLogs(event_filter_params)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/module.py", line 44, in caller
    result = w3.manager.request_blocking(method_str, params, error_formatters)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/manager.py", line 154, in request_blocking
    response = self._make_request(method, params)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/manager.py", line 133, in _make_request
    return request_func(method, params)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/middleware/cache.py", line 134, in middleware
    return make_request(method, params)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/middleware/cache.py", line 247, in middleware
    return make_request(method, params)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/src/nucypher/nucypher/blockchain/middleware/retry.py", line 90, in __call__
    raise result
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/src/nucypher/nucypher/blockchain/middleware/retry.py", line 67, in __call__
    response = self.make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
    return self.func(*args, **kwargs)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/middleware/formatting.py", line 74, in apply_formatters
    response = make_request(method, formatted_params)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/middleware/gas_price_strategy.py", line 34, in middleware
    return make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
    return self.func(*args, **kwargs)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/middleware/formatting.py", line 74, in apply_formatters
    response = make_request(method, formatted_params)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/middleware/attrdict.py", line 33, in middleware
    response = make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
    return self.func(*args, **kwargs)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/middleware/formatting.py", line 74, in apply_formatters
    response = make_request(method, formatted_params)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/middleware/normalize_errors.py", line 25, in middleware
    result = make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
    return self.func(*args, **kwargs)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/middleware/formatting.py", line 76, in apply_formatters
    response = make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
    return self.func(*args, **kwargs)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/middleware/formatting.py", line 74, in apply_formatters
    response = make_request(method, formatted_params)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/middleware/exception_retry_request.py", line 105, in middleware
    return make_request(method, params)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/providers/rpc.py", line 95, in make_request
    **self.get_request_kwargs()
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/web3/_utils/request.py", line 39, in make_post_request
    response = session.post(endpoint_uri, data=data, *args, **kwargs)  # type: ignore
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/requests/sessions.py", line 590, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/Users/derek/.local/share/virtualenvs/nucypher-monitor-YP7TeZrY/lib/python3.7/site-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

We only attempt to collect events for Slashed (StakingEscrow) and IncorrectCFragVerdict (Adjudicator). @KPrasch, perhaps it may be best to either remove the events tab or use the nucypher subgraph. Although it looks like the subgraph only provides information about the Slashed event and not IncorrectCFragVerdict.

I'm learning towards just removing checking for events. Perhaps slashing will be a bigger deal when the Threshold Network gets launched.