Skip to content

Commit 3712229

Browse files
gurukamathSamWilsn
authored andcommitted
parse block_hashes key as hex
1 parent ee73be5 commit 3712229

File tree

1 file changed

+10
-4
lines changed
  • src/ethereum_spec_tools/evm_tools/t8n

1 file changed

+10
-4
lines changed

src/ethereum_spec_tools/evm_tools/t8n/env.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,21 @@ def read_block_hashes(self, data: Any, t8n: "T8N") -> None:
247247

248248
# Read the block hashes
249249
block_hashes: List[Any] = []
250+
251+
# The hex key strings provided might not have standard formatting
252+
clean_block_hashes: Dict[int, Hash32] = {}
253+
if "blockHashes" in data:
254+
for key, value in data["blockHashes"].items():
255+
int_key = int(key, 16)
256+
clean_block_hashes[int_key] = Hash32(hex_to_bytes(value))
257+
250258
# Store a maximum of 256 block hashes.
251259
max_blockhash_count = min(Uint(256), self.block_number)
252260
for number in range(
253261
self.block_number - max_blockhash_count, self.block_number
254262
):
255-
if "blockHashes" in data and str(number) in data["blockHashes"]:
256-
block_hashes.append(
257-
Hash32(hex_to_bytes(data["blockHashes"][str(number)]))
258-
)
263+
if number in clean_block_hashes.keys():
264+
block_hashes.append(clean_block_hashes[number])
259265
else:
260266
block_hashes.append(None)
261267

0 commit comments

Comments
 (0)