[GH-ISSUE #2396] [Feature] Solidity: compare exact bytecode with separately explained compiler patch spans #806

Open
opened 2026-10-15 18:28:38 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @matbrgz on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/2396

Type: Feature Domain: Blockchain RE Status: Proposed Ecosystem: REA

Analyst question and current gap

Two Solidity builds can differ in metadata, library links or immutable patch values. A useful comparison must show those differences while preserving exact byte inequality and avoiding a false behavioral-equivalence claim.

Proposed outcome

  • Compare separately selected concrete bytecodes with original carrier and decoded identities, byte lengths and exact changed ranges.
  • Optionally consume explicitly bound compiler metadata/link/immutable ranges; report an additional comparison view with each explained span and original values.
  • Do not normalize arbitrary suffixes, guessed addresses or unexplained differences. Reject overlapping/out-of-range or incorrectly associated patch spans.
  • Preserve creation versus deployed selection and unknown association; compiler artifact facts are not proof of deployment.
  • Keep exact equality, equality under stated span exclusions and semantic equivalence as distinct conclusions. Metadata/data can be observable to executing code; excluded spans do not establish behavior equality.

Acceptance and verification

  • Pinned own fixtures cover metadata-only changes, linked libraries, constructor-patched immutables and actual executable differences.
  • Wrong reference ranges, overlapping masks and unbound artifacts never produce an explained equality result.
  • Raw versus differently formatted hex carriers retain distinct carrier identities and equal decoded bytes when appropriate.
  • CLI/MCP retain both complete byte identities, changed/excluded ranges, cancellation and bounded output.
  • Record one feature specification, one implementation plan and incremental tasks under docs/specs/solidity/bytecode-comparison/ before code.

Scope and relationships

Independently scoped follow-up to roadmap #972 and existing EVM interface PR #1051; parent TIOBE language tracker #2383. Initial analysis uses caller-selected local evidence and owned fixtures. New provider choices require the explicit CONTRIBUTING.md maintainer decision before substantial implementation for integration. Runtime acquisition, local execution and blockchain mutation are not implicit parts of this feature.

Primary references

Originally created by @matbrgz on GitHub (Oct 12, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/2396 [![Type: Feature](https://img.shields.io/badge/type-feature-blue.svg?style=flat-square)](https://github.com/morluto/rea) [![Domain: Blockchain RE](https://img.shields.io/badge/domain-blockchain_RE-orange.svg?style=flat-square)](https://github.com/morluto/rea) [![Status: Proposed](https://img.shields.io/badge/status-proposed-blue.svg?style=flat-square)](https://github.com/morluto/rea) [![Ecosystem: REA](https://img.shields.io/badge/ecosystem-morluto%2Frea-8A2BE2.svg?style=flat-square)](https://github.com/morluto/rea) ## Analyst question and current gap Two Solidity builds can differ in metadata, library links or immutable patch values. A useful comparison must show those differences while preserving exact byte inequality and avoiding a false behavioral-equivalence claim. ## Proposed outcome - Compare separately selected concrete bytecodes with original carrier and decoded identities, byte lengths and exact changed ranges. - Optionally consume explicitly bound compiler metadata/link/immutable ranges; report an additional comparison view with each explained span and original values. - Do not normalize arbitrary suffixes, guessed addresses or unexplained differences. Reject overlapping/out-of-range or incorrectly associated patch spans. - Preserve creation versus deployed selection and unknown association; compiler artifact facts are not proof of deployment. - Keep exact equality, equality under stated span exclusions and semantic equivalence as distinct conclusions. Metadata/data can be observable to executing code; excluded spans do not establish behavior equality. ## Acceptance and verification - [ ] Pinned own fixtures cover metadata-only changes, linked libraries, constructor-patched immutables and actual executable differences. - [ ] Wrong reference ranges, overlapping masks and unbound artifacts never produce an explained equality result. - [ ] Raw versus differently formatted hex carriers retain distinct carrier identities and equal decoded bytes when appropriate. - [ ] CLI/MCP retain both complete byte identities, changed/excluded ranges, cancellation and bounded output. - [ ] Record one feature specification, one implementation plan and incremental tasks under docs/specs/solidity/bytecode-comparison/ before code. ## Scope and relationships Independently scoped follow-up to roadmap #972 and existing EVM interface PR #1051; parent TIOBE language tracker #2383. Initial analysis uses caller-selected local evidence and owned fixtures. New provider choices require the explicit CONTRIBUTING.md maintainer decision before substantial implementation for integration. Runtime acquisition, local execution and blockchain mutation are not implicit parts of this feature. ## Primary references - [Compiler bytecode and patch-reference outputs](https://docs.soliditylang.org/en/latest/using-the-compiler.html) - [Solidity metadata bytecode effects](https://docs.soliditylang.org/en/latest/metadata.html)
Author
Owner

@matbrgz commented on GitHub (Oct 12, 2026):

Triage & Architectural Review Notes

Objective (ELI5):
Compare deployed on-chain bytecode against locally recompiled bytecode, isolating and explaining legitimate compiler variances (link references, immutable values, metadata hashes).

Diff Taxonomy:

  1. CBOR Metadata Suffix (#2388): Highlighted separately as non-executable provenance differences (compiler version, hash type).
  2. Linker Placeholders: Explaining 20-byte library address patch spans (__$30...$__).
  3. Immutable Slots: Recognizing constructor assignments replaced into deployed code as data slots rather than code logic alterations.
  4. If code outside these allowed patch spans differs, mark the comparison as mismatch.
<!-- gh-comment-id:6133872980 --> @matbrgz commented on GitHub (Oct 12, 2026): ### Triage & Architectural Review Notes **Objective (ELI5):** Compare deployed on-chain bytecode against locally recompiled bytecode, isolating and explaining legitimate compiler variances (link references, immutable values, metadata hashes). **Diff Taxonomy:** 1. **CBOR Metadata Suffix (#2388):** Highlighted separately as non-executable provenance differences (compiler version, hash type). 2. **Linker Placeholders:** Explaining 20-byte library address patch spans (`__$30...$__`). 3. **Immutable Slots:** Recognizing constructor assignments replaced into deployed code as data slots rather than code logic alterations. 4. If code outside these allowed patch spans differs, mark the comparison as `mismatch`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#806
No description provided.