build: strip CBOR metadata footer for deterministic bytecode#106
Merged
Conversation
Set `bytecode_hash = "none"` in foundry.toml so emitted bytecode no longer contains the appended CBOR metadata block (IPFS source hash + solc version marker). The IPFS hash covers source paths and dependency layout, so the same source produced different bytes across clones — this churn polluted genesis.json regenerations without changing any runtime behavior. The `solc = "0.8.30"` pin above is what actually fixes the compiler version; the in-bytecode version marker was redundant artifact. 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.
Summary
bytecode_hash = "none"infoundry.tomlso emitted bytecode no longer carries the appended CBOR metadata block (IPFS source hash + solc version marker).solc = "0.8.30"pin above is what actually fixes the compiler version; the in-bytecode version marker is just an artifact.Why
The IPFS hash in the CBOR footer is computed over a metadata JSON that includes source-file paths, dependency layout, and remapping serialization. The same source produced different bytes across clones /
node_moduleslayouts / machines, which polluted downstream consumers (most visibly:gravity_chain_core_contracts→gravity-mainnet-gitops/genesis.jsonregenerations would diff by hundreds of lines without any runtime behavior changing — see PR #110 on the gitops side for the empirical diagnosis).This change makes builds deterministic across clones, dependency layouts, OSes, and absolute-path differences.
What this changes
foundry.toml(solc = "0.8.30") is now the sole record of which solc was used.What this trades away
Test plan
forge clean && forge buildsucceeds.out/**/*.jsonartifact and confirmdeployedBytecode.objectno longer ends with thea26469706673...64736f6c63...0033CBOR footer.gravity-sdk/cluster/genesis.shagainst this ref twice from scratch and confirmgenesis.jsonis byte-identical both times.🤖 Generated with Claude Code