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

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

* use correct features
This commit is contained in:
Matthias Seitz 2022-03-19 15:52:09 +01:00 committed by GitHub
parent b6b5b09f4a
commit 1788f05ab0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 16 deletions

25
Cargo.lock generated
View File

@ -330,6 +330,12 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "build_const"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7"
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.9.1" version = "3.9.1"
@ -1405,6 +1411,7 @@ dependencies = [
"sha2 0.9.9", "sha2 0.9.9",
"solang-parser", "solang-parser",
"svm-rs", "svm-rs",
"svm-rs-builds",
"tempfile", "tempfile",
"thiserror", "thiserror",
"tiny-keccak", "tiny-keccak",
@ -3312,9 +3319,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.78" version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d23c1ba4cf0efd44be32017709280b32d1cea5c3f1275c3b6d9e8bc54f758085" checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95"
dependencies = [ dependencies = [
"itoa 1.0.1", "itoa 1.0.1",
"ryu", "ryu",
@ -3576,7 +3583,7 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
[[package]] [[package]]
name = "svm-rs" name = "svm-rs"
version = "0.2.9" version = "0.2.9"
source = "git+https://github.com/roynalnaruto/svm-rs#37d0095eeac73546c507b706c51e8f901541a7c1" source = "git+https://github.com/roynalnaruto/svm-rs#496888fdcd9d2316a52020a09e281414755de3f8"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cfg-if 1.0.0", "cfg-if 1.0.0",
@ -3601,6 +3608,18 @@ dependencies = [
"url", "url",
] ]
[[package]]
name = "svm-rs-builds"
version = "0.1.0"
source = "git+https://github.com/roynalnaruto/svm-rs#496888fdcd9d2316a52020a09e281414755de3f8"
dependencies = [
"build_const",
"hex",
"semver",
"serde_json",
"svm-rs",
]
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.89" version = "1.0.89"

View File

@ -44,6 +44,7 @@ home = "0.5.3"
# SVM is not WASM compatible yet. # 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, 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 = { 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] [target.'cfg(target_arch = "wasm32")'.dependencies]
# NOTE: this enables wasm compatibility for getrandom indirectly # NOTE: this enables wasm compatibility for getrandom indirectly
@ -69,17 +70,17 @@ harness = false
[[test]] [[test]]
name = "project" name = "project"
path = "tests/project.rs" path = "tests/project.rs"
required-features = ["async", "svm", "project-util"] required-features = ["async", "svm", "svm-builds", "project-util"]
[[test]] [[test]]
name = "mocked" name = "mocked"
path = "tests/mocked.rs" path = "tests/mocked.rs"
required-features = ["async", "svm", "project-util"] required-features = ["async", "svm", "svm-builds", "project-util"]
[features] [features]
default = ["rustls"] default = ["rustls"]
async = ["tokio", "futures-util"] async = ["tokio", "futures-util"]
full = ["async", "svm", "svm/blocking"] full = ["async", "svm", "svm/blocking", "svm-builds"]
# Utilities for creating and testing project workspaces # Utilities for creating and testing project workspaces
project-util = ["tempfile", "fs_extra", "rand"] project-util = ["tempfile", "fs_extra", "rand"]
tests = [] tests = []

View File

@ -63,10 +63,11 @@ pub(crate) fn take_solc_installer_lock() -> std::sync::MutexGuard<'static, ()> {
/// A list of upstream Solc releases, used to check which version /// A list of upstream Solc releases, used to check which version
/// we should download. /// we should download.
/// The boolean value marks whether there was an error. /// The boolean value marks whether there was an error accessing the release list
#[cfg(all(feature = "svm"))] #[cfg(all(feature = "svm", feature = "svm-builds"))]
pub static RELEASES: once_cell::sync::Lazy<(svm::Releases, Vec<Version>, bool)> = pub static RELEASES: once_cell::sync::Lazy<(svm::Releases, Vec<Version>, bool)> =
once_cell::sync::Lazy::new(|| match svm::blocking_all_releases(svm::platform()) { once_cell::sync::Lazy::new(|| {
match serde_json::from_str::<svm::Releases>(svm_builds::RELEASE_LIST_JSON) {
Ok(releases) => { Ok(releases) => {
let sorted_versions = releases.clone().into_versions(); let sorted_versions = releases.clone().into_versions();
(releases, sorted_versions, true) (releases, sorted_versions, true)
@ -75,6 +76,7 @@ pub static RELEASES: once_cell::sync::Lazy<(svm::Releases, Vec<Version>, bool)>
tracing::error!("{:?}", err); tracing::error!("{:?}", err);
(svm::Releases::default(), Vec::new(), false) (svm::Releases::default(), Vec::new(), false)
} }
}
}); });
/// A `Solc` version is either installed (available locally) or can be downloaded, from the remote /// A `Solc` version is either installed (available locally) or can be downloaded, from the remote