Skip to content

Commit

Permalink
parse block_hashes key as hex
Browse files Browse the repository at this point in the history
  • Loading branch information
gurukamath committed Jan 27, 2025
1 parent d9febcb commit 7c7f148
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/ethereum_spec_tools/evm_tools/t8n/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,21 @@ def read_block_hashes(self, data: Any) -> None:
"""
# Read the block hashes
block_hashes: List[Any] = []

# The hex key strings provided might not have standard formatting
clean_block_hashes: Dict[int, Hash32] = {}
if "blockHashes" in data:
for key, value in data["blockHashes"].items():
int_key = int(key, 16)
clean_block_hashes[int_key] = Hash32(hex_to_bytes(value))

# Store a maximum of 256 block hashes.
max_blockhash_count = min(Uint(256), self.block_number)
for number in range(
self.block_number - max_blockhash_count, self.block_number
):
if "blockHashes" in data and str(number) in data["blockHashes"]:
block_hashes.append(
Hash32(hex_to_bytes(data["blockHashes"][str(number)]))
)
if number in clean_block_hashes.keys():
block_hashes.append(clean_block_hashes[number])
else:
block_hashes.append(None)

Expand Down

0 comments on commit 7c7f148

Please sign in to comment.