P2-9: fix swapped contracts init_code_hash / code_hash - #73
Merged
Conversation
process_contracts hashed the wrong inputs: init_code_hash held keccak256(result.code) -- the deployed runtime code -- and code_hash held keccak256(create.init) -- the deployment init code. The adjacent init_code/code and n_init_code_bytes/n_code_bytes columns map the inputs correctly, confirming the two hashes were transposed. Swap them so init_code_hash is the keccak256 of the init code and code_hash is the keccak256 of the deployed code. Added a regression test: a contract-creation trace with distinct init and deployed bytecode now produces each hash from its correct input. Cross-referenced candidate PR paradigmxyz#249. Closes #35. Co-Authored-By: AuburyEssentian <263089372+AuburyEssentian@users.noreply.github.com> Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
P2-9 —
contractsinit_code_hash/code_hashswappedProblem
In the
contractsdataset,process_contractshashed the wrong inputs:init_code_hashwas set tokeccak256(result.code)— the deployed runtime codecode_hashwas set tokeccak256(create.init)— the init (deployment) codeThe two
keccak256calls referenced each other's inputs. The adjacent columns map the inputs correctly —init_code←create.init,code←result.code,n_init_code_bytes←create.init,n_code_bytes←result.code— which confirms the two hashes were transposed.Fix
Swap the inputs so
init_code_hashis the keccak256 of the init code andcode_hashis the keccak256 of the deployed code.Validation
contracts.rs: a contract-creation trace with distinct init and deployed bytecode produces each hash from its correct input (and the test asserts the two differ, so a swap is caught).cargo build,clippy --all-targets -D warnings,cargo +nightly fmt --check,cargo test -p cryo_freezeall green locally.Credit
No upstream issue — cross-referenced candidate PR paradigmxyz#249 (@AuburyEssentian), credited via
Co-Authored-Byper ADR-0001.Closes #35.
🤖 Generated with Claude Code