Skip to content

Commit 3409f90

Browse files
authored
fix: handle solc versions with +commit (#341)
- 8f1c61c introduced an issue with versions like `0.8.15+commit.e14f2714` format that can be seen in foundry CI failure https://github.com/foundry-rs/foundry/actions/runs/19511930077/job/55854689276?pr=12599#step:14:9999 - these versions should be normalized to e.g. `0.8.15` - only prereleases like `0.8.31-pre.1+commit.b59566f6` or `0.8.31-pre.1` should be preserved and looked up with original version - fix to preserve versions only if prereleases, foundry CI passes with patch: foundry-rs/foundry#12599 - should have created the foundry PR with patched versions to changes first, sorry for back and forth 🫠
1 parent 0eec4f0 commit 3409f90

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

crates/compilers/src/compilers/solc/compiler.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,17 @@ impl Solc {
215215
#[instrument(skip_all)]
216216
#[cfg(feature = "svm-solc")]
217217
pub fn find_svm_installed_version(version: &Version) -> Result<Option<Self>> {
218+
let version = if version.pre.is_empty() {
219+
Version::new(version.major, version.minor, version.patch)
220+
} else {
221+
// Preserve version if it is a prerelease.
222+
version.clone()
223+
};
218224
let solc = svm::version_binary(&version.to_string());
219225
if !solc.is_file() {
220226
return Ok(None);
221227
}
222-
Ok(Some(Self::new_with_version(&solc, version.clone())))
228+
Ok(Some(Self::new_with_version(&solc, version)))
223229
}
224230

225231
/// Returns the directory in which [svm](https://github.com/roynalnaruto/svm-rs) stores all versions
@@ -293,18 +299,25 @@ impl Solc {
293299
#[cfg(test)]
294300
crate::take_solc_installer_lock!(_lock);
295301

302+
let version = if version.pre.is_empty() {
303+
Version::new(version.major, version.minor, version.patch)
304+
} else {
305+
// Preserve version if it is a prerelease.
306+
version.clone()
307+
};
308+
296309
trace!("blocking installing solc version \"{}\"", version);
297-
crate::report::solc_installation_start(version);
310+
crate::report::solc_installation_start(&version);
298311
// The async version `svm::install` is used instead of `svm::blocking_install`
299312
// because the underlying `reqwest::blocking::Client` does not behave well
300313
// inside of a Tokio runtime. See: https://github.com/seanmonstar/reqwest/issues/1017
301-
match RuntimeOrHandle::new().block_on(svm::install(version)) {
314+
match RuntimeOrHandle::new().block_on(svm::install(&version)) {
302315
Ok(path) => {
303-
crate::report::solc_installation_success(version);
316+
crate::report::solc_installation_success(&version);
304317
Ok(Self::new_with_version(path, version.clone()))
305318
}
306319
Err(err) => {
307-
crate::report::solc_installation_error(version, &err.to_string());
320+
crate::report::solc_installation_error(&version, &err.to_string());
308321
Err(err)
309322
}
310323
}

0 commit comments

Comments
 (0)