Skip to content

Commit 94d973a

Browse files
committed
raising ForkedBlock exception also if chain of blocks from batch request is not consistent.
1 parent 0b250c4 commit 94d973a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

IceCreamSwapWeb3/EthAdvanced.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,14 @@ def get_logs(
221221
for i, block_number in enumerate(range(from_block, to_block + 1)):
222222
block = blocks[i]
223223
if i != 0:
224-
assert block["parentHash"] == blocks[i-1]["hash"], f"{blocks[i-1]['hash'].hex()=}, {block['parentHash'].hex()=}"
224+
if block["parentHash"] != blocks[i-1]["hash"]:
225+
raise ForkedBlock(f"expected={blocks[i-1]['hash'].to_0x_hex()}, actual={block['parentHash'].to_0x_hex()}")
225226
if from_block_body is not None and from_block_body["number"] == block_number:
226227
if block["hash"] != from_block_body["hash"]:
227-
raise ForkedBlock(f"expected={from_block_body['hash'].hex()}, actual={block['hash'].hex()}")
228+
raise ForkedBlock(f"expected={from_block_body['hash'].to_0x_hex()}, actual={block['hash'].to_0x_hex()}")
228229
if to_block_body is not None and to_block_body["number"] == block_number:
229230
if block["hash"] != to_block_body["hash"]:
230-
raise ForkedBlock(f"expected={to_block_body['hash'].hex()}, actual={block['hash'].hex()}")
231+
raise ForkedBlock(f"expected={to_block_body['hash'].to_0x_hex()}, actual={block['hash'].to_0x_hex()}")
231232

232233
single_hash_filter = filter_params.copy()
233234
del single_hash_filter["fromBlock"]

0 commit comments

Comments
 (0)