fix(solc): bundle new svm-solc feature (#1071)
* fix(solc): bundle new svm-solc feature * chore: update CHANGELOG * fix: enabled new feature in full
This commit is contained in:
parent
679ba09b92
commit
95a384b121
|
@ -73,6 +73,8 @@
|
||||||
|
|
||||||
### Unreleased
|
### Unreleased
|
||||||
|
|
||||||
|
- Bundle svm, svm-builds and sha2 dependencies in new `svm-solc` feature
|
||||||
|
[#1071](https://github.com/gakonst/ethers-rs/pull/1071)
|
||||||
- Wrap `ethabi::Contract` into new type `LosslessAbi` and `abi: Option<Abi>` with `abi: Option<LosslessAbi>` in `ConfigurableContractArtifact`
|
- Wrap `ethabi::Contract` into new type `LosslessAbi` and `abi: Option<Abi>` with `abi: Option<LosslessAbi>` in `ConfigurableContractArtifact`
|
||||||
[#952](https://github.com/gakonst/ethers-rs/pull/952)
|
[#952](https://github.com/gakonst/ethers-rs/pull/952)
|
||||||
- Let `Project` take ownership of `ArtifactOutput` and change trait interface
|
- Let `Project` take ownership of `ArtifactOutput` and change trait interface
|
||||||
|
|
|
@ -70,17 +70,18 @@ harness = false
|
||||||
[[test]]
|
[[test]]
|
||||||
name = "project"
|
name = "project"
|
||||||
path = "tests/project.rs"
|
path = "tests/project.rs"
|
||||||
required-features = ["async", "svm", "svm-builds", "project-util"]
|
required-features = ["async", "solc-svm", "project-util"]
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
name = "mocked"
|
name = "mocked"
|
||||||
path = "tests/mocked.rs"
|
path = "tests/mocked.rs"
|
||||||
required-features = ["async", "svm", "svm-builds", "project-util"]
|
required-features = ["async", "solc-svm", "project-util"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["rustls"]
|
default = ["rustls"]
|
||||||
async = ["tokio", "futures-util"]
|
async = ["tokio", "futures-util"]
|
||||||
full = ["async", "svm", "svm/blocking", "svm-builds"]
|
full = ["async", "svm-solc"]
|
||||||
|
svm-solc = ["svm/blocking", "svm-builds", "sha2"]
|
||||||
# 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 = []
|
||||||
|
|
|
@ -64,7 +64,7 @@ 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 accessing the release list
|
/// The boolean value marks whether there was an error accessing the release list
|
||||||
#[cfg(all(feature = "svm", feature = "svm-builds"))]
|
#[cfg(all(feature = "svm-solc"))]
|
||||||
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(|| {
|
once_cell::sync::Lazy::new(|| {
|
||||||
match serde_json::from_str::<svm::Releases>(svm_builds::RELEASE_LIST_JSON) {
|
match serde_json::from_str::<svm::Releases>(svm_builds::RELEASE_LIST_JSON) {
|
||||||
|
@ -224,7 +224,7 @@ impl Solc {
|
||||||
|
|
||||||
/// Returns the list of all versions that are available to download and marking those which are
|
/// Returns the list of all versions that are available to download and marking those which are
|
||||||
/// already installed.
|
/// already installed.
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
pub fn all_versions() -> Vec<SolcVersion> {
|
pub fn all_versions() -> Vec<SolcVersion> {
|
||||||
let mut all_versions = Self::installed_versions();
|
let mut all_versions = Self::installed_versions();
|
||||||
let mut uniques = all_versions
|
let mut uniques = all_versions
|
||||||
|
@ -285,7 +285,7 @@ impl Solc {
|
||||||
/// to build it, and returns it.
|
/// to build it, and returns it.
|
||||||
///
|
///
|
||||||
/// If the required compiler version is not installed, it also proceeds to install it.
|
/// If the required compiler version is not installed, it also proceeds to install it.
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
pub fn detect_version(source: &Source) -> Result<Version> {
|
pub fn detect_version(source: &Source) -> Result<Version> {
|
||||||
// detects the required solc version
|
// detects the required solc version
|
||||||
let sol_version = Self::source_version_req(source)?;
|
let sol_version = Self::source_version_req(source)?;
|
||||||
|
@ -296,7 +296,7 @@ impl Solc {
|
||||||
/// used to build it, and returns it.
|
/// used to build it, and returns it.
|
||||||
///
|
///
|
||||||
/// If the required compiler version is not installed, it also proceeds to install it.
|
/// If the required compiler version is not installed, it also proceeds to install it.
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
pub fn ensure_installed(sol_version: &VersionReq) -> Result<Version> {
|
pub fn ensure_installed(sol_version: &VersionReq) -> Result<Version> {
|
||||||
#[cfg(any(test, feature = "tests"))]
|
#[cfg(any(test, feature = "tests"))]
|
||||||
let _lock = take_solc_installer_lock();
|
let _lock = take_solc_installer_lock();
|
||||||
|
@ -361,7 +361,7 @@ impl Solc {
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(feature = "svm")]
|
#[cfg(feature = "svm-solc")]
|
||||||
pub async fn install(version: &Version) -> std::result::Result<Self, svm::SolcVmError> {
|
pub async fn install(version: &Version) -> std::result::Result<Self, svm::SolcVmError> {
|
||||||
tracing::trace!("installing solc version \"{}\"", version);
|
tracing::trace!("installing solc version \"{}\"", version);
|
||||||
crate::report::solc_installation_start(version);
|
crate::report::solc_installation_start(version);
|
||||||
|
@ -371,7 +371,7 @@ impl Solc {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Blocking version of `Self::install`
|
/// Blocking version of `Self::install`
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
pub fn blocking_install(version: &Version) -> std::result::Result<Self, svm::SolcVmError> {
|
pub fn blocking_install(version: &Version) -> std::result::Result<Self, svm::SolcVmError> {
|
||||||
tracing::trace!("blocking installing solc version \"{}\"", version);
|
tracing::trace!("blocking installing solc version \"{}\"", version);
|
||||||
crate::report::solc_installation_start(version);
|
crate::report::solc_installation_start(version);
|
||||||
|
@ -389,7 +389,7 @@ impl Solc {
|
||||||
|
|
||||||
/// Verify that the checksum for this version of solc is correct. We check against the SHA256
|
/// Verify that the checksum for this version of solc is correct. We check against the SHA256
|
||||||
/// checksum from the build information published by binaries.soliditylang
|
/// checksum from the build information published by binaries.soliditylang
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
pub fn verify_checksum(&self) -> Result<()> {
|
pub fn verify_checksum(&self) -> Result<()> {
|
||||||
let version = self.version_short()?;
|
let version = self.version_short()?;
|
||||||
let mut version_path = svm::version_path(version.to_string().as_str());
|
let mut version_path = svm::version_path(version.to_string().as_str());
|
||||||
|
@ -731,7 +731,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
// This test might be a bit hard to maintain
|
// This test might be a bit hard to maintain
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
fn test_detect_version() {
|
fn test_detect_version() {
|
||||||
for (pragma, expected) in [
|
for (pragma, expected) in [
|
||||||
// pinned
|
// pinned
|
||||||
|
|
|
@ -140,7 +140,7 @@ impl<'a, T: ArtifactOutput> ProjectCompiler<'a, T> {
|
||||||
/// let project = Project::builder().build().unwrap();
|
/// let project = Project::builder().build().unwrap();
|
||||||
/// let output = project.compile().unwrap();
|
/// let output = project.compile().unwrap();
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
pub fn new(project: &'a Project<T>) -> Result<Self> {
|
pub fn new(project: &'a Project<T>) -> Result<Self> {
|
||||||
Self::with_sources(project, project.paths.read_input_files()?)
|
Self::with_sources(project, project.paths.read_input_files()?)
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ impl<'a, T: ArtifactOutput> ProjectCompiler<'a, T> {
|
||||||
///
|
///
|
||||||
/// Multiple (`Solc` -> `Sources`) pairs can be compiled in parallel if the `Project` allows
|
/// Multiple (`Solc` -> `Sources`) pairs can be compiled in parallel if the `Project` allows
|
||||||
/// multiple `jobs`, see [`crate::Project::set_solc_jobs()`].
|
/// multiple `jobs`, see [`crate::Project::set_solc_jobs()`].
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
pub fn with_sources(project: &'a Project<T>, sources: Sources) -> Result<Self> {
|
pub fn with_sources(project: &'a Project<T>, sources: Sources) -> Result<Self> {
|
||||||
let graph = Graph::resolve_sources(&project.paths, sources)?;
|
let graph = Graph::resolve_sources(&project.paths, sources)?;
|
||||||
let (versions, edges) = graph.into_sources_by_version(project.offline)?;
|
let (versions, edges) = graph.into_sources_by_version(project.offline)?;
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub enum SolcError {
|
||||||
/// Failed to resolve a file
|
/// Failed to resolve a file
|
||||||
#[error("Failed to resolve file: {0}.\n Check configured remappings.")]
|
#[error("Failed to resolve file: {0}.\n Check configured remappings.")]
|
||||||
Resolve(SolcIoError),
|
Resolve(SolcIoError),
|
||||||
#[cfg(feature = "svm")]
|
#[cfg(feature = "svm-solc")]
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
SvmError(#[from] svm::SolcVmError),
|
SvmError(#[from] svm::SolcVmError),
|
||||||
#[error("No contracts found at \"{0}\"")]
|
#[error("No contracts found at \"{0}\"")]
|
||||||
|
|
|
@ -209,7 +209,7 @@ impl<T: ArtifactOutput> Project<T> {
|
||||||
let sources = self.paths.read_input_files()?;
|
let sources = self.paths.read_input_files()?;
|
||||||
tracing::trace!("found {} sources to compile: {:?}", sources.len(), sources.keys());
|
tracing::trace!("found {} sources to compile: {:?}", sources.len(), sources.keys());
|
||||||
|
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
if self.auto_detect {
|
if self.auto_detect {
|
||||||
tracing::trace!("using solc auto detection to compile sources");
|
tracing::trace!("using solc auto detection to compile sources");
|
||||||
return self.svm_compile(sources)
|
return self.svm_compile(sources)
|
||||||
|
@ -243,7 +243,7 @@ impl<T: ArtifactOutput> Project<T> {
|
||||||
/// let output = project.svm_compile(sources).unwrap();
|
/// let output = project.svm_compile(sources).unwrap();
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
pub fn svm_compile(&self, sources: Sources) -> Result<ProjectCompileOutput<T>> {
|
pub fn svm_compile(&self, sources: Sources) -> Result<ProjectCompileOutput<T>> {
|
||||||
project::ProjectCompiler::with_sources(self, sources)?.compile()
|
project::ProjectCompiler::with_sources(self, sources)?.compile()
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ impl<T: ArtifactOutput> Project<T> {
|
||||||
/// let output = project.compile_file("example/Greeter.sol").unwrap();
|
/// let output = project.compile_file("example/Greeter.sol").unwrap();
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
pub fn compile_file(&self, file: impl Into<PathBuf>) -> Result<ProjectCompileOutput<T>> {
|
pub fn compile_file(&self, file: impl Into<PathBuf>) -> Result<ProjectCompileOutput<T>> {
|
||||||
let file = file.into();
|
let file = file.into();
|
||||||
let source = Source::read(&file)?;
|
let source = Source::read(&file)?;
|
||||||
|
@ -282,7 +282,7 @@ impl<T: ArtifactOutput> Project<T> {
|
||||||
/// ).unwrap();
|
/// ).unwrap();
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
pub fn compile_files<P, I>(&self, files: I) -> Result<ProjectCompileOutput<T>>
|
pub fn compile_files<P, I>(&self, files: I) -> Result<ProjectCompileOutput<T>>
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = P>,
|
I: IntoIterator<Item = P>,
|
||||||
|
@ -321,7 +321,7 @@ impl<T: ArtifactOutput> Project<T> {
|
||||||
/// ).unwrap();
|
/// ).unwrap();
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
pub fn compile_sparse<F: FileFilter + 'static>(
|
pub fn compile_sparse<F: FileFilter + 'static>(
|
||||||
&self,
|
&self,
|
||||||
filter: F,
|
filter: F,
|
||||||
|
@ -748,7 +748,7 @@ impl<T: ArtifactOutput> ArtifactOutput for Project<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::remappings::Remapping;
|
use crate::remappings::Remapping;
|
||||||
|
|
||||||
|
|
|
@ -327,7 +327,7 @@ impl Graph {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
impl Graph {
|
impl Graph {
|
||||||
/// Consumes the nodes of the graph and returns all input files together with their appropriate
|
/// Consumes the nodes of the graph and returns all input files together with their appropriate
|
||||||
/// version and the edges of the graph
|
/// version and the edges of the graph
|
||||||
|
@ -632,14 +632,14 @@ impl<'a> Iterator for NodesIter<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Container type for solc versions and their compatible sources
|
/// Container type for solc versions and their compatible sources
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct VersionedSources {
|
pub struct VersionedSources {
|
||||||
inner: HashMap<crate::SolcVersion, Sources>,
|
inner: HashMap<crate::SolcVersion, Sources>,
|
||||||
offline: bool,
|
offline: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "svm", feature = "async"))]
|
#[cfg(all(feature = "svm-solc", feature = "async"))]
|
||||||
impl VersionedSources {
|
impl VersionedSources {
|
||||||
/// Resolves or installs the corresponding `Solc` installation.
|
/// Resolves or installs the corresponding `Solc` installation.
|
||||||
pub fn get(
|
pub fn get(
|
||||||
|
|
Loading…
Reference in New Issue