Skip to content

Commit

Permalink
Improve logging for malformed RPC responses
Browse files Browse the repository at this point in the history
  • Loading branch information
SamWilsn committed Aug 13, 2024
1 parent 217ea17 commit c5a2735
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/ethereum_spec_tools/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,22 @@ def fetch_blocks_debug(

with request.urlopen(post) as response:
replies = json.load(response)
if not isinstance(replies, list):
self.log.error(
"got non-list JSON-RPC response. replies=%r", replies
)
raise ValueError

block_rlps: Dict[int, Union[RpcError, bytes]] = {}

for reply in replies:
reply_id = int(reply["id"], 0)
try:
reply_id = int(reply["id"], 0)
except Exception:
self.log.exception(
"unable to parse RPC id. reply=%r", reply
)
raise

if reply_id < first or reply_id >= first + count:
raise Exception("mismatched request id")
Expand Down

0 comments on commit c5a2735

Please sign in to comment.