Skip to content

feat: add local_compilation mode for explorer-unverified contracts#192

Closed
arwer13 wants to merge 2 commits into
mainfrom
feat/unverified-sources-bytecode
Closed

feat: add local_compilation mode for explorer-unverified contracts#192
arwer13 wants to merge 2 commits into
mainfrom
feat/unverified-sources-bytecode

Conversation

@arwer13

@arwer13 arwer13 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Contracts without explorer-verified source can now be checked at the bytecode level: local_compilation.inputs maps an address to a local solc standard-JSON input (source manifest + compiler settings), and local_compilation.compiler pins the solc build. Source contents are still fetched from the pinned GitHub commit, and the source diff is skipped for these addresses since there is nothing explorer-side to diff against.

Relation to feat/local-compilation-mode

This PR implements the same feature as in feat/local-compilation-mode and keeps its config
schema verbatim
(local_compilation: {compiler, inputs}), so any config written
for either branch works with both. We propose landing this implementation because:

  1. Rebased on current main. The earlier branch forked ~82 commits back,
    before the allowed_diffs machinery and related process_config refactors,
    and no longer applies cleanly. This one is written against today's main and
    composes with allowlists, caching, and the summary/suggestion output.

  2. Local contracts reuse the explorer normalization path. The payload is built
    via the existing _build_contract_payload/_attach_contract_metadata helpers
    instead of by hand, so EVM-version normalization and library re-keying to the
    definition file (required for correct solc linking) apply to local inputs
    exactly as they do to explorer bundles.

  3. More guardrails. All-local configs need no explorer hostname/chain-id/token
    at all; unknown addresses in local_compilation.inputs are flagged; a config
    whose local contracts would get zero verification (bytecode comparison off)
    warns; the skipped source diff is logged per contract rather than silent;
    malformed/empty solc inputs are rejected with clear errors.

  4. Docs and tests included. README section (schema + why a full-bytecode match
    incl. the CBOR metadata tail is sound evidence for guessed settings), CLAUDE.md
    schema note, and tests covering error paths (malformed JSON, empty sources,
    absolute/relative input paths).

Contracts without explorer-verified source can now be checked at the
bytecode level: local_compilation.inputs maps an address to a local solc
standard-JSON input (source manifest + compiler settings), and
local_compilation.compiler pins the solc build. Source contents are
still fetched from the pinned GitHub commit, and the source diff is
skipped for these addresses since there is nothing explorer-side to
diff against.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@arwer13
arwer13 requested a review from a team as a code owner July 16, 2026 09:50
@arwer13
arwer13 requested a review from tamtamchik July 16, 2026 09:51
- load explorer token only when an in-scope (post-filter) contract needs it
- reject local_compilation.inputs addresses missing from contracts
- validate YAML unquoted hex keys under local_compilation.inputs
- record skipped source stats for local contracts and show them in summary
- warn when allowed_diffs.source rules are inert for local contracts
- handle null settings in local solc input gracefully

@tamtamchik tamtamchik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that if you have sources to create an identical bytecode, you can put it to etherscan / blockscout / sourcify as verified. So I don't think this PR is actually worth to be included.

@TheDZhon

Copy link
Copy Markdown
Contributor

Closing as the use case seems to be too exotic.

@TheDZhon TheDZhon closed this Jul 16, 2026
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.

3 participants