Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(verify): cached artifacts by version #9520

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions crates/verify/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 <https://github.com/foundry-rs/foundry/issues/9510>.
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::<HashSet<_>>())
.unwrap_or_default();

Expand Down
Loading