Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Releases prior to 7.0 has been removed from this file to declutter search result
### Fixed

- database: Fix exception when creating connections with aiosqlite==0.22.0.
- evm.node: Retry JSON-RPC requests on "invalid block range params" error.

## [8.5.1] - 2025-11-03

Expand Down
27 changes: 27 additions & 0 deletions src/dipdup/datasources/evm_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,33 @@ async def _emitter_loop(self) -> None:

del self._level_data[head.hash]

async def _jsonrpc_request(
self,
method: str,
params: Any,
raw: bool = False,
ws: bool = False,
) -> Any:
attempt = 1
retry_sleep = self._http_config.retry_sleep
retry_count = self._http_config.retry_count
last_attempt = retry_count + 1

while True:
try:
return await super()._jsonrpc_request(method, params, raw=raw, ws=ws)
except DatasourceError as e:
# NOTE: Special case: node is out of sync, but we don't track
# `syncing` events, so just retry as a safe HTTP exception.
if 'invalid block range params' not in str(e) or attempt == last_attempt:
raise

self._logger.warning('JSON-RPC request `%s` failed, retrying: %s', method, e)
to_sleep = float(f'{retry_sleep:.1f}')
self._logger.info('Waiting %s seconds before retry', to_sleep)
await asyncio.sleep(to_sleep)
attempt += 1

@property
def ws_available(self) -> bool:
return self._config.ws_url is not None
Expand Down