diff --git a/crates/compilers/src/artifact_output/mod.rs b/crates/compilers/src/artifact_output/mod.rs index ec2a7d037..ccd079abc 100644 --- a/crates/compilers/src/artifact_output/mod.rs +++ b/crates/compilers/src/artifact_output/mod.rs @@ -625,10 +625,8 @@ pub trait ArtifactOutput { ) -> Result> { let mut artifacts = self.output_to_artifacts(contracts, sources, ctx, layout, primary_profiles); - fs::create_dir_all(&layout.artifacts).map_err(|err| { - error!(dir=?layout.artifacts, "Failed to create artifacts folder"); - SolcIoError::new(err, &layout.artifacts) - })?; + fs::create_dir_all(&layout.artifacts) + .map_err(|err| SolcIoError::new(err, &layout.artifacts))?; artifacts.join_all(&layout.artifacts); artifacts.write_all()?; @@ -1140,16 +1138,17 @@ impl ArtifactOutput for MinimalCombinedArtifactsHardhatFallback { } fn read_cached_artifact(path: &Path) -> Result { - let content = fs::read_to_string(path).map_err(|err| SolcError::io(err, path))?; - if let Ok(a) = serde_json::from_str(&content) { - Ok(a) - } else { - error!("Failed to deserialize compact artifact"); - trace!("Fallback to hardhat artifact deserialization"); - let artifact = serde_json::from_str::(&content)?; - trace!("successfully deserialized hardhat artifact"); - Ok(artifact.into_contract_bytecode()) + #[derive(Deserialize)] + #[serde(untagged)] + enum Artifact { + Compact(CompactContractBytecode), + Hardhat(HardhatArtifact), } + + Ok(match utils::read_json_file::(path)? { + Artifact::Compact(c) => c, + Artifact::Hardhat(h) => h.into_contract_bytecode(), + }) } fn contract_to_artifact( diff --git a/crates/compilers/src/compilers/solc/compiler.rs b/crates/compilers/src/compilers/solc/compiler.rs index 194b37f85..cd4d7559f 100644 --- a/crates/compilers/src/compilers/solc/compiler.rs +++ b/crates/compilers/src/compilers/solc/compiler.rs @@ -54,7 +54,7 @@ pub static RELEASES: std::sync::LazyLock<(svm::Releases, Vec, bool)> = (releases, sorted_versions, true) } Err(err) => { - error!("{:?}", err); + error!("failed to deserialize SVM static RELEASES JSON: {err}"); Default::default() } } diff --git a/crates/compilers/src/resolver/mod.rs b/crates/compilers/src/resolver/mod.rs index 4b0c722c4..d91592e72 100644 --- a/crates/compilers/src/resolver/mod.rs +++ b/crates/compilers/src/resolver/mod.rs @@ -917,8 +917,9 @@ impl> Graph { .collect(), ); } else { - error!("failed to resolve versions"); - return Err(SolcError::msg(errors.join("\n"))); + let s = errors.join("\n"); + debug!("failed to resolve versions: {s}"); + return Err(SolcError::msg(s)); } } @@ -960,8 +961,9 @@ impl> Graph { if errors.is_empty() { Ok(resulted_sources) } else { - error!("failed to resolve settings"); - Err(SolcError::msg(errors.join("\n"))) + let s = errors.join("\n"); + debug!("failed to resolve settings: {s}"); + Err(SolcError::msg(s)) } }