diff --git a/crates/verify/src/verify.rs b/crates/verify/src/verify.rs index de7779ac33a8..c2ac287703bd 100644 --- a/crates/verify/src/verify.rs +++ b/crates/verify/src/verify.rs @@ -20,6 +20,7 @@ use foundry_config::{figment, impl_figment_convert, impl_figment_convert_cast, C use itertools::Itertools; use reqwest::Url; use revm_primitives::HashSet; +use semver::BuildMetadata; use std::path::PathBuf; use crate::provider::VerificationContext; @@ -275,7 +276,7 @@ impl VerifyArgs { let cache = project.read_cache_file().ok(); - let version = if let Some(ref version) = self.compiler_version { + let mut version = if let Some(ref version) = self.compiler_version { version.trim_start_matches('v').parse()? } else if let Some(ref solc) = config.solc { match solc { @@ -321,7 +322,21 @@ impl VerifyArgs { let profiles = entry .artifacts .get(&contract.name) - .and_then(|artifacts| artifacts.get(&version)) + .and_then(|artifacts| { + let mut cached_artifacts = artifacts.get(&version); + // If we try to verify with specific build version and no cached artifacts + // found, then check if we have artifacts cached for same version but + // without any build metadata. + // This could happen when artifacts are built / cached + // with a version like `0.8.20` but verify is using a compiler-version arg + // as `0.8.20+commit.a1b79de6`. + // See . + if cached_artifacts.is_none() && version.build != BuildMetadata::EMPTY { + version.build = BuildMetadata::EMPTY; + cached_artifacts = artifacts.get(&version); + } + cached_artifacts + }) .map(|artifacts| artifacts.keys().collect::>()) .unwrap_or_default();