fix(contracts): swap init_code_hash and code_hash keccak256 inputs#249
Open
AuburyEssentian wants to merge 1 commit into
Open
fix(contracts): swap init_code_hash and code_hash keccak256 inputs#249AuburyEssentian wants to merge 1 commit into
AuburyEssentian wants to merge 1 commit into
Conversation
init_code_hash should hash create.init (the initialization bytecode), and code_hash should hash result.code (the deployed runtime bytecode). The two keccak256 calls were reversed, causing the columns to contain each other's values in the canonical_execution_contracts table. The n_init_code_bytes / n_code_bytes byte-count columns reference the correct inputs already — only the hash columns were affected. Fixes ethpandaops/xatu#688.
This was referenced May 15, 2026
trial123Zel
added a commit
to trial123Zel/cryo-ocd
that referenced
this pull request
May 17, 2026
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>
stiliyanaa
suggested changes
May 26, 2026
stiliyanaa
left a comment
There was a problem hiding this comment.
Join Holders! Your personalized invite is available at the link below. Before you start, make sure you have the latest version of the Tonhub app installed - https://tonhub.com/holders/invite/cmpm7bei61h1r933v07326shs
Author
|
The hash swap appears already implemented in the current code; init_code_hash hashes create.init and code_hash hashes result.code as described. Could you clarify the remaining concerns? |
Author
|
@maintainer Could you take a look at the hash swap changes? Let me know if any further tweaks are needed. |
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.
Problem
init_code_hashandcode_hashin thecontractsdataset are populated with each other's values. The twokeccak256calls on lines 101–102 ofcontracts.rsreference the wrong inputs:init_code_hashshould hashcreate.init— the initialization bytecode sent in the CREATE transactioncode_hashshould hashresult.code— the runtime bytecode stored at the contract addressThis was confirmed in ethpandaops/xatu#688 by comparing against
geth snapshot inspect-account: the value ininit_code_hashmatches geth'saccount.codehash(the deployed code hash), and distinct count ofcode_hash(~4.5M) far exceeds the known unique deployed code count (~1.7M).The
n_init_code_bytes/n_code_bytescolumns are unaffected — they already reference the correct sources.Fix
Swap the two
keccak256arguments so each column hashes the right input.