From bd19352decc1a610b4ff4c2a6cec75c12335876f Mon Sep 17 00:00:00 2001 From: Lev Gorodetskiy Date: Mon, 5 Feb 2024 12:57:56 -0300 Subject: [PATCH] Make `withdrawals_root` field optional, fix empty HTTP urls before request (#932) --- CHANGELOG.md | 2 ++ src/dipdup/http.py | 2 +- src/dipdup/models/evm_node.py | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1350181d1..0fa108de4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic - cli: Do not consider config as oneshot if `tezos.tzkt.head` index is present. - codegen: Allow dots to be used in typenames indicating nested packages. +- evm.node: Make `withdrawals_root` field optional in `EvmNodeHeadData` model. +- http: Fixed crash on some datasource URLs. ### Performance diff --git a/src/dipdup/http.py b/src/dipdup/http.py index 57b47cfc5..360464987 100644 --- a/src/dipdup/http.py +++ b/src/dipdup/http.py @@ -217,7 +217,7 @@ async def _request( """Wrapped aiohttp call with preconfigured headers and ratelimiting""" metrics.inc(f'{self._alias}:requests_total', 1.0) if not url: - url = self._path + url = self._path or '/' elif url.startswith('http'): url = url.replace(self._url, '').rstrip('/') else: diff --git a/src/dipdup/models/evm_node.py b/src/dipdup/models/evm_node.py index ade43d364..621dd142e 100644 --- a/src/dipdup/models/evm_node.py +++ b/src/dipdup/models/evm_node.py @@ -54,7 +54,7 @@ class EvmNodeHeadData: gas_used: int timestamp: int base_fee_per_gas: int - withdrawals_root: str + withdrawals_root: str | None nonce: str mix_hash: str @@ -76,7 +76,7 @@ def from_json(cls, block_json: dict[str, Any]) -> 'EvmNodeHeadData': gas_used=int(block_json['gasUsed'], 16), timestamp=int(block_json['timestamp'], 16), base_fee_per_gas=int(block_json['baseFeePerGas'], 16), - withdrawals_root=block_json['withdrawalsRoot'], + withdrawals_root=block_json.get('withdrawalsRoot', None), nonce=block_json['nonce'], mix_hash=block_json['mixHash'], )