Skip to content

parse block_hashes key as hex #1099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -247,15 +247,21 @@ def read_block_hashes(self, data: Any, t8n: "T8N") -> 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
Loading