Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

feat(solc): use svm-builds instead of fetching http releases list #1063

Merged
merged 2 commits into from
Mar 19, 2022
Merged
Show file tree
Hide file tree
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
25 changes: 22 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions ethers-solc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ home = "0.5.3"
# SVM is not WASM compatible yet.
# svm = { package = "svm-rs", default-features = false, version = "0.2.7", optional = true }
svm = { package = "svm-rs", default-features = false, git = "https://github.com/roynalnaruto/svm-rs", optional = true, features = ["blocking"] }
svm-builds = { package = "svm-rs-builds", git = "https://github.com/roynalnaruto/svm-rs", optional = true}

[target.'cfg(target_arch = "wasm32")'.dependencies]
# NOTE: this enables wasm compatibility for getrandom indirectly
Expand All @@ -69,17 +70,17 @@ harness = false
[[test]]
name = "project"
path = "tests/project.rs"
required-features = ["async", "svm", "project-util"]
required-features = ["async", "svm", "svm-builds", "project-util"]

[[test]]
name = "mocked"
path = "tests/mocked.rs"
required-features = ["async", "svm", "project-util"]
required-features = ["async", "svm", "svm-builds", "project-util"]

[features]
default = ["rustls"]
async = ["tokio", "futures-util"]
full = ["async", "svm", "svm/blocking"]
full = ["async", "svm", "svm/blocking", "svm-builds"]
# Utilities for creating and testing project workspaces
project-util = ["tempfile", "fs_extra", "rand"]
tests = []
Expand Down
22 changes: 12 additions & 10 deletions ethers-solc/src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,19 @@ pub(crate) fn take_solc_installer_lock() -> std::sync::MutexGuard<'static, ()> {

/// A list of upstream Solc releases, used to check which version
/// we should download.
/// The boolean value marks whether there was an error.
#[cfg(all(feature = "svm"))]
/// The boolean value marks whether there was an error accessing the release list
#[cfg(all(feature = "svm", feature = "svm-builds"))]
pub static RELEASES: once_cell::sync::Lazy<(svm::Releases, Vec<Version>, bool)> =
once_cell::sync::Lazy::new(|| match svm::blocking_all_releases(svm::platform()) {
Ok(releases) => {
let sorted_versions = releases.clone().into_versions();
(releases, sorted_versions, true)
}
Err(err) => {
tracing::error!("{:?}", err);
(svm::Releases::default(), Vec::new(), false)
once_cell::sync::Lazy::new(|| {
match serde_json::from_str::<svm::Releases>(svm_builds::RELEASE_LIST_JSON) {
Ok(releases) => {
let sorted_versions = releases.clone().into_versions();
(releases, sorted_versions, true)
}
Err(err) => {
tracing::error!("{:?}", err);
(svm::Releases::default(), Vec::new(), false)
}
}
});

Expand Down