Skip to content

refactor: unify parent_hash representation as binary (#128)#134

Merged
mw2000 merged 1 commit intomainfrom
refactor/parent-hash-binary
May 2, 2026
Merged

refactor: unify parent_hash representation as binary (#128)#134
mw2000 merged 1 commit intomainfrom
refactor/parent-hash-binary

Conversation

@mw2000
Copy link
Copy Markdown
Owner

@mw2000 mw2000 commented May 1, 2026

Summary

  • Block.Header.parent_hash was already canonicalised as a 32-byte binary(), but BlockHashes.commit/3 took a non_neg_integer() — forcing a parent_hash_to_int shim in BlockchainTestRunner that handled nil / binary / integer.
  • Switch commit/3 to accept the 32-byte binary directly (the calldata was already encoded as 32 bytes), pass header.parent_hash through unchanged, and delete the shim.
  • Net -8 LOC. Closes Refactor: unify parent_hash representation (binary vs integer) #128.

Test plan

  • mix compile clean
  • mix credo --strict clean
  • mix test — 4 doctests, 613 tests, 0 failures
  • mix test test/system_contracts/block_hashes_test.exs — 11 tests, 0 failures
  • mix test test/blockchain_test_test.exs — 2 tests, 0 failures

🤖 Generated with Claude Code

Block headers already canonicalised parent_hash as a 32-byte binary, but
BlockHashes.commit/3 took a non_neg_integer, forcing a parent_hash_to_int
shim in BlockchainTestRunner that handled nil / binary / integer.

Switch commit/3 to accept a 32-byte binary directly (the calldata is
already encoded as 32 bytes), pass header.parent_hash through unchanged,
and delete the shim.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@mw2000 mw2000 merged commit 5fce5e3 into main May 2, 2026
3 checks passed
@mw2000 mw2000 deleted the refactor/parent-hash-binary branch May 2, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: unify parent_hash representation (binary vs integer)

1 participant