Skip to content

feat(verify): preflight check verifier credentials before broadcasting#14777

Open
mablr wants to merge 19 commits into
masterfrom
mablr/preflight_check_verifier_credentials
Open

feat(verify): preflight check verifier credentials before broadcasting#14777
mablr wants to merge 19 commits into
masterfrom
mablr/preflight_check_verifier_credentials

Conversation

@mablr
Copy link
Copy Markdown
Collaborator

@mablr mablr commented May 15, 2026

Motivation

Validate verifier credentials before deployment so users get an early, actionable error instead of deploying and then having verification fail.

Two layers of validation are now applied in forge script and forge create before any transaction is broadcasted:

  1. Presence check (VerificationProviderType::client): fails immediately if required credentials are obviously absent.
  2. Connectivity check (VerifierArgs::check_credentials): makes a lightweight network call to confirm credentials are actually accepted.

Staked on top of #14765 (merge the current one after)

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

zerosnacks
zerosnacks previously approved these changes May 19, 2026
Copy link
Copy Markdown
Contributor

@zerosnacks zerosnacks left a comment

Choose a reason for hiding this comment

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

Nice! Simple fix but saves a lot of hassle

@zerosnacks zerosnacks dismissed their stale review May 19, 2026 10:23

Oops - stale, found some things worth addressing

Copy link
Copy Markdown
Contributor

@zerosnacks zerosnacks left a comment

Choose a reason for hiding this comment

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

A few preflight-correctness concerns worth addressing before merge — focused on cases where this check could itself become the deploy-blocker it’s meant to prevent.

Comment thread crates/verify/src/verify.rs Outdated
Comment thread crates/script/src/broadcast.rs Outdated
Comment thread crates/verify/src/verify.rs
Comment thread crates/verify/src/verify.rs
Comment thread crates/forge/src/cmd/create.rs Outdated
Comment thread crates/forge/tests/cli/verify.rs
@mablr mablr requested a review from zerosnacks May 20, 2026 14:01
Comment thread crates/verify/src/verify.rs Outdated
Comment thread crates/verify/src/verify.rs Outdated
mablr added 4 commits May 27, 2026 16:10
Validate verifier credentials before deployment so users get an early,
actionable error instead of deploying and then having verification fail.

Two layers of validation are now applied in `forge script` and `forge
create` before any transaction is broadcasted:
1. Presence check (`VerificationProviderType::client`): fails
   immediately if required credentials are obviously absent.
2. Connectivity check (`VerifierArgs::check_credentials`): makes a
   lightweight network call to confirm credentials are actually
   accepted.
@mablr mablr force-pushed the mablr/preflight_check_verifier_credentials branch from 7a7182e to c3b4ce5 Compare May 27, 2026 15:24
Base automatically changed from mablr/fallback_etherscan_unsupported_chain to master May 28, 2026 12:45
mablr added 4 commits May 28, 2026 18:37
- Demote BlockedByCloudflare, CloudFlareSecurityChallenge,
  RateLimitExceeded,
  and InvalidApiVersion from hard-fail to warn-and-proceed; transient
  CDN
  challenges and version mismatches must not block deploys
- Split Custom verifier into its own branch using a raw HTTP probe with
  401/403 detection, fixing the catch-all bypass for
  non-Etherscan-shaped
  auth error responses (figtracer)
- Add HTTP status check to Sourcify custom-URL probe (warn on
  non-2xx/non-404)
- Restore etherscan_api_key global config fallback in broadcast
  preflight,
  fixing regression for users with a top-level key in foundry.toml
- Fix effective_type() -> resolve() in broadcast presence check so
  implicit
  Etherscan selection (key from env/config, no --verifier flag) is
  validated
- Remove duplicate create_fails_early_on_bad_verifier_credentials test
- Strengthen script preflight test to assert no broadcast occurred
Custom verifiers that return HTTP 200 with {"result":"Invalid API Key"}
were not caught by the credential check, which only inspected HTTP
status codes (401/403). Now also inspect the response body for the
invalid-API-key string so the preflight check correctly blocks
deployment.

Fixes create_preflight_fails_on_invalid_api_key and
script_fails_early_on_bad_verifier_credentials tests.
Comment thread crates/verify/src/verify.rs Outdated
Comment thread crates/verify/src/verify.rs Outdated
Comment thread crates/forge/tests/cli/verify.rs
@mablr mablr requested review from figtracer and stevencartavia May 30, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants