fix(forge): allow verify-bytecode to run without a block explorer#15142
Open
PrazwalR wants to merge 4 commits into
Open
fix(forge): allow verify-bytecode to run without a block explorer#15142PrazwalR wants to merge 4 commits into
PrazwalR wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates verify-bytecode to proceed when a block explorer client or explorer data is unavailable, falling back to local project configuration and runtime-bytecode-only verification to address #13479.
Changes:
- Make explorer integration optional (client creation, creation data, source code/metadata) and continue verification with local data when missing.
- Add fallback logic to verify runtime bytecode when creation data can’t be fetched.
- Add a CLI integration test ensuring verification works on anvil without any explorer.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| crates/verify/src/utils.rs | Makes mismatch reporting conditional on available explorer metadata. |
| crates/verify/src/bytecode.rs | Makes explorer client/data optional; adds runtime-only verification fallback and EVM version selection fallback. |
| crates/forge/tests/cli/verify_bytecode.rs | Adds an integration test for verification without a block explorer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
figtracer
reviewed
Jun 11, 2026
figtracer
reviewed
Jun 11, 2026
verify-bytecode unconditionally required the target contract to be verified on a block explorer: it bailed when the explorer client could not be created (unsupported chain), when creation data could not be fetched (missing API key), or when the source was not verified. Degrade gracefully instead, so bytecode can be verified against a local build with only an RPC endpoint: - an unavailable explorer client or failed source/creation-data fetch now warns instead of failing; - without explorer metadata, the EVM version falls back to the local project configuration and constructor args must be user-provided; - without creation data, the creation code check is skipped and the runtime bytecode is verified by deploying the local creation code at the target block (generalizing the existing predeploy path); - compiler-settings mismatch hints are only printed when explorer metadata is available. Supersedes the stale foundry-rs#14583 and adds the regression test requested in its review: deploys a contract on a local Anvil node and verifies it without any explorer. Closes foundry-rs#13479 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2eea384 to
d42a448
Compare
Contributor
|
This pull request is stale because it has been open for 14 days with no activity. It will be closed in 7 days if there is no further activity. |
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.
Motivation
forge verify-bytecodefails unconditionally when no block explorer is configured — three separate failure points: client construction dies on unknown chains, creation-data fetch errors withInvalidApiKey, source-code fetch errors with "Contract source code not verified". Private chains, custom L2s, and local anvil nodes are entirely excluded.This supersedes #14583 (closed as stale — @figtracer asked for a regression test that was never added; approach is the same, credit to @ParthSinghPS).
Closes #13479.
Changes
crates/verify/src/bytecode.rsOption<Client>— unknown chains getNone, no hard errorNonewhen explorer unavailablefoundry.tomlconfig when no explorer metadataBytes::new()when no source code availableif creation_data.is_none()branch unified: covers both predeploy (genesis) and no-explorer cases — does runtime-only verification at--block/latest, emitting a warning instead of erroringcrates/verify/src/utils.rsprint_resulttakesOption<&Metadata>— mismatch hints only printed when explorer metadata presentcrates/forge/tests/cli/verify_bytecode.rscan_verify_bytecode_without_explorer: spawns local anvil, deploys Counter, runsverify-bytecodewith no explorer args, asserts "Runtime code matched" in stdout and "Creation data is unavailable" in stderr — this is the regression test missing from fix(forge): allow verify-bytecode to run without external explorer dependencies #14583Testing
cargo test -p forge --test cli -- verify_bytecode::can_verify_bytecode_without_explorer