From d595a9acf5bd72bf16f96950f7d780ca6eaaec0a Mon Sep 17 00:00:00 2001 From: mkzung <103102868+mkzung@users.noreply.github.com> Date: Tue, 18 Aug 2026 21:54:49 +0500 Subject: [PATCH] refactor(verify): drop the unreachable unknown optimizer runs branch --- .changelog/verify-optimizer-runs-mismatch-message.md | 5 +++++ crates/verify/src/utils.rs | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 .changelog/verify-optimizer-runs-mismatch-message.md diff --git a/.changelog/verify-optimizer-runs-mismatch-message.md b/.changelog/verify-optimizer-runs-mismatch-message.md new file mode 100644 index 0000000000000..277c97636ecb1 --- /dev/null +++ b/.changelog/verify-optimizer-runs-mismatch-message.md @@ -0,0 +1,5 @@ +--- +forge-verify: patch +--- + +Reported the local optimizer runs in the `forge verify-bytecode` settings mismatch instead of the string `unknown`, which the only caller could not reach. diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index 088aa51514dc9..91ec0a649820f 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -226,12 +226,13 @@ fn find_mismatch_in_settings( ); mismatches.push(str); } - if local_settings.optimizer_runs.is_some_and(|runs| etherscan_settings.runs != runs as u64) - || (local_settings.optimizer_runs.is_none() && etherscan_settings.runs > 0) + // The only caller reaches this with a `Config` from `load_config`, which has run + // `normalize_optimizer_settings`, so `optimizer_runs` is always set by now. + if let Some(local_runs) = local_settings.optimizer_runs + && etherscan_settings.runs != local_runs as u64 { let str = format!( - "Optimizer runs mismatch: local={}, onchain={}", - local_settings.optimizer_runs.map_or("unknown".to_string(), |runs| runs.to_string()), + "Optimizer runs mismatch: local={local_runs}, onchain={}", etherscan_settings.runs ); mismatches.push(str);