Pass solc version into compiler rather than returning from compilation. Allows for better reporting

This commit is contained in:
James Wilson
2025-08-27 13:13:55 +01:00
parent 8229675ba8
commit 5c75228496
10 changed files with 174 additions and 171 deletions
-4
View File
@@ -1,4 +0,0 @@
use semver::Version;
/// This is the first version of solc that supports the `--via-ir` flag / "viaIR" input JSON.
pub const SOLC_VERSION_SUPPORTING_VIA_YUL_IR: Version = Version::new(0, 8, 13);
+8 -18
View File
@@ -3,7 +3,6 @@
//! - Polkadot revive resolc compiler
//! - Polkadot revive Wasm compiler
mod constants;
mod utils;
use std::{
@@ -15,7 +14,6 @@ use std::{
use alloy::json_abi::JsonAbi;
use alloy_primitives::Address;
use anyhow::Context;
use semver::{Version, VersionReq};
use serde::{Deserialize, Serialize};
use revive_common::EVMVersion;
@@ -25,6 +23,9 @@ use revive_dt_config::Arguments;
// Re-export this as it's a part of the compiler interface.
pub use revive_dt_common::types::{Mode, ModeOptimizerSetting, ModePipeline};
// Expose functionality for instantiating a SolcCompiler.
pub use utils::{SolcCompiler, solc_compiler};
pub mod revive_js;
pub mod revive_resolc;
pub mod solc;
@@ -53,7 +54,7 @@ pub trait SolidityCompiler {
pub struct CompilerInput {
pub pipeline: Option<ModePipeline>,
pub optimization: Option<ModeOptimizerSetting>,
pub solc_version: Option<VersionReq>,
pub solc: Option<SolcCompiler>,
pub evm_version: Option<EVMVersion>,
pub allow_paths: Vec<PathBuf>,
pub base_path: Option<PathBuf>,
@@ -63,24 +64,13 @@ pub struct CompilerInput {
}
/// The generic compilation output configuration.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct CompilerOutput {
/// Information about the `solc` compiler used to compile the contracts.
pub solc: SolcCompilerInformation,
/// The compiled contracts. The bytecode of the contract is kept as a string incase linking is
/// required and the compiled source has placeholders.
pub contracts: HashMap<PathBuf, HashMap<String, (String, JsonAbi)>>,
}
/// Information about the `solc` compiler.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SolcCompilerInformation {
/// Version of the compiler.
pub version: Version,
/// Path to the compiler executable.
pub path: PathBuf,
}
/// A generic builder style interface for configuring the supported compiler options.
pub struct Compiler<T: SolidityCompiler> {
input: CompilerInput,
@@ -102,7 +92,7 @@ where
input: CompilerInput {
pipeline: Default::default(),
optimization: Default::default(),
solc_version: Default::default(),
solc: Default::default(),
evm_version: Default::default(),
allow_paths: Default::default(),
base_path: Default::default(),
@@ -114,8 +104,8 @@ where
}
}
pub fn with_solc_version_req(mut self, value: impl Into<Option<VersionReq>>) -> Self {
self.input.solc_version = value.into();
pub fn with_solc(mut self, value: impl Into<Option<SolcCompiler>>) -> Self {
self.input.solc = value.into();
self
}
+8 -42
View File
@@ -1,9 +1,8 @@
//! Implements the [SolidityCompiler] trait with `resolc` for
//! compiling contracts to PolkaVM (PVM) bytecode.
use std::{collections::HashMap, path::PathBuf, process::Stdio};
use std::{path::PathBuf, process::Stdio};
use revive_dt_common::types::VersionOrRequirement;
use revive_dt_config::Arguments;
use revive_solc_json_interface::{
SolcStandardJsonInput, SolcStandardJsonInputLanguage, SolcStandardJsonInputSettings,
@@ -11,12 +10,7 @@ use revive_solc_json_interface::{
SolcStandardJsonOutput,
};
use super::constants::SOLC_VERSION_SUPPORTING_VIA_YUL_IR;
use super::utils;
use crate::{
CompilerInput, CompilerOutput, ModeOptimizerSetting, ModePipeline, SolcCompilerInformation,
SolidityCompiler,
};
use crate::{CompilerInput, CompilerOutput, ModeOptimizerSetting, ModePipeline, SolidityCompiler};
use alloy::json_abi::JsonAbi;
use anyhow::Context;
@@ -26,11 +20,6 @@ use tokio::{io::AsyncWriteExt, process::Command as AsyncCommand};
/// A wrapper around the `resolc` binary, emitting PVM-compatible bytecode.
#[derive(Debug)]
pub struct Resolc {
// Where to cache compiler executables.
compiler_executables_cache_directory: PathBuf,
// We'll use this version when no explicit version
// requirement is given in the test mode.
solc_version: Version,
/// Path to the `resolc` executable
resolc_path: PathBuf,
}
@@ -44,7 +33,7 @@ impl SolidityCompiler for Resolc {
CompilerInput {
pipeline,
optimization,
solc_version,
solc,
evm_version,
allow_paths,
base_path,
@@ -62,22 +51,7 @@ impl SolidityCompiler for Resolc {
);
}
let solc_version_req = solc_version
.unwrap_or_else(|| VersionOrRequirement::version_to_requirement(&self.solc_version));
let solc_path = revive_dt_solc_binaries::download_solc(
&self.compiler_executables_cache_directory,
solc_version_req,
false,
)
.await?;
let solc_version = utils::solc_version(&solc_path).await?;
if solc_version < SOLC_VERSION_SUPPORTING_VIA_YUL_IR {
anyhow::bail!(
"We are trying to run the test with solc version {solc_version}, but require {SOLC_VERSION_SUPPORTING_VIA_YUL_IR} or greater"
);
}
let solc = solc.ok_or_else(|| anyhow::anyhow!("solc compiler not provided to resolc."))?;
let input = SolcStandardJsonInput {
language: SolcStandardJsonInputLanguage::Solidity,
sources: sources
@@ -124,7 +98,7 @@ impl SolidityCompiler for Resolc {
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.arg("--solc")
.arg(&solc_path)
.arg(&solc.path)
.arg("--standard-json");
if let Some(ref base_path) = base_path {
@@ -203,14 +177,14 @@ impl SolidityCompiler for Resolc {
anyhow::bail!("Unexpected error - resolc output doesn't have a contracts section");
};
let mut compiled_contracts = HashMap::<PathBuf, HashMap<_, _>>::new();
let mut compiler_output = CompilerOutput::default();
for (source_path, contracts) in contracts.into_iter() {
let src_for_msg = source_path.clone();
let source_path = PathBuf::from(source_path)
.canonicalize()
.with_context(|| format!("Failed to canonicalize path {src_for_msg}"))?;
let map = compiled_contracts.entry(source_path).or_default();
let map = compiler_output.contracts.entry(source_path).or_default();
for (contract_name, contract_information) in contracts.into_iter() {
let bytecode = contract_information
.evm
@@ -255,19 +229,11 @@ impl SolidityCompiler for Resolc {
}
}
Ok(CompilerOutput {
solc: SolcCompilerInformation {
version: solc_version,
path: solc_path,
},
contracts: compiled_contracts,
})
Ok(compiler_output)
}
fn new(config: &Arguments) -> Self {
Resolc {
compiler_executables_cache_directory: config.directory().to_path_buf(),
solc_version: config.solc.clone(),
resolc_path: config.resolc.clone(),
}
}
+15 -44
View File
@@ -1,18 +1,8 @@
//! Implements the [SolidityCompiler] trait with solc for
//! compiling contracts to EVM bytecode.
use std::{collections::HashMap, path::PathBuf, process::Stdio};
use revive_dt_common::types::VersionOrRequirement;
use revive_dt_config::Arguments;
use super::constants::SOLC_VERSION_SUPPORTING_VIA_YUL_IR;
use super::utils;
use crate::{
CompilerInput, CompilerOutput, ModeOptimizerSetting, ModePipeline, SolcCompilerInformation,
SolidityCompiler,
};
use crate::{CompilerInput, CompilerOutput, ModeOptimizerSetting, ModePipeline, SolidityCompiler};
use anyhow::Context;
use foundry_compilers_artifacts::{
output_selection::{
@@ -21,17 +11,12 @@ use foundry_compilers_artifacts::{
solc::CompilerOutput as SolcOutput,
solc::*,
};
use semver::Version;
use revive_dt_config::Arguments;
use std::process::Stdio;
use tokio::{io::AsyncWriteExt, process::Command as AsyncCommand};
#[derive(Debug)]
pub struct Solc {
// Where to cache artifacts.
cache_directory: PathBuf,
// We'll use this version when no explicit version requirement
// is given in the test mode.
solc_version: Version,
}
pub struct Solc {}
impl SolidityCompiler for Solc {
type Options = ();
@@ -42,7 +27,7 @@ impl SolidityCompiler for Solc {
CompilerInput {
pipeline,
optimization,
solc_version,
solc,
evm_version,
allow_paths,
base_path,
@@ -52,15 +37,9 @@ impl SolidityCompiler for Solc {
}: CompilerInput,
_: Self::Options,
) -> anyhow::Result<CompilerOutput> {
let solc_version_req = solc_version
.unwrap_or_else(|| VersionOrRequirement::version_to_requirement(&self.solc_version));
let solc_path =
revive_dt_solc_binaries::download_solc(&self.cache_directory, solc_version_req, false)
.await?;
let solc_version = utils::solc_version(&solc_path).await?;
let solc = solc.ok_or_else(|| anyhow::anyhow!("solc compiler not provided to resolc."))?;
let compiler_supports_via_ir =
utils::solc_version(&solc_path).await? >= SOLC_VERSION_SUPPORTING_VIA_YUL_IR;
utils::solc_versions_supporting_yul_ir().matches(&solc.version);
// Be careful to entirely omit the viaIR field if the compiler does not support it,
// as it will error if you provide fields it does not know about. Because
@@ -126,7 +105,7 @@ impl SolidityCompiler for Solc {
},
};
let mut command = AsyncCommand::new(&solc_path);
let mut command = AsyncCommand::new(&solc.path);
command
.stdin(Stdio::piped())
.stdout(Stdio::piped())
@@ -147,7 +126,7 @@ impl SolidityCompiler for Solc {
}
let mut child = command
.spawn()
.with_context(|| format!("Failed to spawn solc at {}", solc_path.display()))?;
.with_context(|| format!("Failed to spawn solc at {}", solc.path.display()))?;
let stdin = child.stdin.as_mut().expect("should be piped");
let serialized_input = serde_json::to_vec(&input)
@@ -197,9 +176,10 @@ impl SolidityCompiler for Solc {
"Compiled successfully"
);
let mut compiled_contracts = HashMap::<PathBuf, HashMap<_, _>>::new();
let mut compiler_output = CompilerOutput::default();
for (contract_path, contracts) in parsed.contracts {
let map = compiled_contracts
let map = compiler_output
.contracts
.entry(contract_path.canonicalize().with_context(|| {
format!(
"Failed to canonicalize contract path {}",
@@ -223,20 +203,11 @@ impl SolidityCompiler for Solc {
}
}
Ok(CompilerOutput {
solc: SolcCompilerInformation {
version: solc_version,
path: solc_path,
},
contracts: compiled_contracts,
})
Ok(compiler_output)
}
fn new(config: &Arguments) -> Self {
Self {
cache_directory: config.directory().to_path_buf(),
solc_version: config.solc.clone(),
}
fn new(_config: &Arguments) -> Self {
Self {}
}
fn supports_mode(_optimize_setting: ModeOptimizerSetting, pipeline: ModePipeline) -> bool {
+68 -2
View File
@@ -1,3 +1,4 @@
use serde::{Deserialize, Serialize};
use std::{
path::{Path, PathBuf},
process::{Command, Stdio},
@@ -6,10 +7,61 @@ use std::{
use anyhow::Context;
use dashmap::DashMap;
use semver::Version;
use revive_dt_common::types::{ModePipeline, VersionOrRequirement};
use semver::{Version, VersionReq};
/// Return the path and version of a suitable `solc` compiler given the requirements provided.
///
/// This caches any compiler binaries/paths that are downloaded as a result of calling this.
pub async fn solc_compiler(
cache_directory: &Path,
fallback_version: &Version,
required_version: Option<&VersionReq>,
pipeline: ModePipeline,
) -> anyhow::Result<SolcCompiler> {
// Require Yul compatible solc, or any if we don't care about compiling via Yul.
let mut version_req = if pipeline == ModePipeline::ViaYulIR {
solc_versions_supporting_yul_ir()
} else {
VersionReq::STAR
};
// Take into account the version requirements passed in, too.
if let Some(other_version_req) = required_version {
version_req
.comparators
.extend(other_version_req.comparators.iter().cloned());
}
// If no requirements yet then fall back to the fallback version.
let version_req = if version_req == VersionReq::STAR {
VersionOrRequirement::version_to_requirement(fallback_version)
} else {
version_req
};
// Download (or pull from cache) a suitable solc compiler given this.
let solc_path =
revive_dt_solc_binaries::download_solc(cache_directory, version_req, false).await?;
let solc_version = solc_version(&solc_path).await?;
Ok(SolcCompiler {
version: solc_version,
path: solc_path,
})
}
/// A `solc` compiler, returned from [`solc_compiler`].
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SolcCompiler {
/// Version of the compiler.
pub version: Version,
/// Path to the compiler executable.
pub path: PathBuf,
}
/// Fetch the solc version given a path to the executable
pub async fn solc_version(solc_path: &Path) -> anyhow::Result<semver::Version> {
async fn solc_version(solc_path: &Path) -> anyhow::Result<semver::Version> {
/// This is a cache of the path of the compiler to the version number of the compiler. We
/// choose to cache the version in this way rather than through a field on the struct since
/// compiler objects are being created all the time from the path and the compiler object is
@@ -49,6 +101,20 @@ pub async fn solc_version(solc_path: &Path) -> anyhow::Result<semver::Version> {
}
}
/// This returns the solc versions which support Yul IR.
pub fn solc_versions_supporting_yul_ir() -> VersionReq {
use semver::{Comparator, Op, Prerelease, VersionReq};
VersionReq {
comparators: vec![Comparator {
op: Op::GreaterEq,
major: 0,
minor: Some(8),
patch: Some(13),
pre: Prerelease::EMPTY,
}],
}
}
#[cfg(test)]
mod test {
use super::*;
+10 -23
View File
@@ -9,10 +9,9 @@ use std::{
use futures::FutureExt;
use revive_dt_common::iterators::FilesWithExtensionIterator;
use revive_dt_compiler::{Compiler, CompilerInput, CompilerOutput, Mode, SolcCompilerInformation};
use revive_dt_compiler::{Compiler, CompilerInput, CompilerOutput, Mode, SolcCompiler};
use revive_dt_config::Arguments;
use revive_dt_format::metadata::{ContractIdent, ContractInstance, Metadata};
use revive_dt_solc_binaries::solc_version;
use alloy::{hex::ToHexExt, json_abi::JsonAbi, primitives::Address};
use anyhow::{Context as _, Error, Result};
@@ -54,26 +53,20 @@ impl CachedCompiler {
&self,
metadata: &Metadata,
metadata_file_path: impl AsRef<Path>,
solc: SolcCompiler,
mode: &Mode,
config: &Arguments,
deployed_libraries: Option<&HashMap<ContractInstance, (ContractIdent, Address, JsonAbi)>>,
compilation_success_report_callback: impl Fn(bool, Option<CompilerInput>, CompilerOutput)
+ Clone,
compilation_failure_report_callback: impl Fn(
Option<SolcCompilerInformation>,
Option<CompilerInput>,
String,
),
compilation_failure_report_callback: impl Fn(Option<CompilerInput>, String),
) -> Result<CompilerOutput> {
static CACHE_KEY_LOCK: Lazy<RwLock<HashMap<CacheKey, Arc<Mutex<()>>>>> =
Lazy::new(Default::default);
let solc_version_or_requirement = mode.compiler_version_to_use(config.solc.clone());
let solc_version = solc_version(solc_version_or_requirement, false).await?;
let cache_key = CacheKey {
platform_key: P::config_id().to_string(),
compiler_version: solc_version.clone(),
compiler_version: solc.version.clone(),
metadata_file_path: metadata_file_path.as_ref().to_path_buf(),
solc_mode: mode.clone(),
};
@@ -91,6 +84,7 @@ impl CachedCompiler {
.files_to_compile()
.context("Failed to enumerate files to compile from metadata")?,
config,
solc,
mode,
deployed_libraries,
compilation_success_report_callback,
@@ -170,14 +164,11 @@ async fn compile_contracts<P: Platform>(
metadata_directory: impl AsRef<Path>,
mut files_to_compile: impl Iterator<Item = PathBuf>,
config: &Arguments,
solc: SolcCompiler,
mode: &Mode,
deployed_libraries: Option<&HashMap<ContractInstance, (ContractIdent, Address, JsonAbi)>>,
compilation_success_report_callback: impl Fn(bool, Option<CompilerInput>, CompilerOutput),
compilation_failure_report_callback: impl Fn(
Option<SolcCompilerInformation>,
Option<CompilerInput>,
String,
),
compilation_failure_report_callback: impl Fn(Option<CompilerInput>, String),
) -> Result<CompilerOutput> {
let all_sources_in_dir = FilesWithExtensionIterator::new(metadata_directory.as_ref())
.with_allowed_extension("sol")
@@ -185,7 +176,7 @@ async fn compile_contracts<P: Platform>(
.collect::<Vec<_>>();
let compiler = Compiler::<P::Compiler>::new()
.with_solc_version_req(mode.version.clone())
.with_solc(solc)
.with_allow_path(metadata_directory)
// Handling the modes
.with_optimization(mode.optimize_setting)
@@ -194,7 +185,7 @@ async fn compile_contracts<P: Platform>(
.try_then(|compiler| {
files_to_compile.try_fold(compiler, |compiler, path| compiler.with_source(path))
})
.inspect_err(|err| compilation_failure_report_callback(None, None, format!("{err:#}")))?
.inspect_err(|err| compilation_failure_report_callback(None, format!("{err:#}")))?
// Adding the deployed libraries to the compiler.
.then(|compiler| {
deployed_libraries
@@ -216,11 +207,7 @@ async fn compile_contracts<P: Platform>(
.try_build(config)
.await
.inspect_err(|err| {
compilation_failure_report_callback(
None,
Some(compiler_input.clone()),
format!("{err:#}"),
)
compilation_failure_report_callback(Some(compiler_input.clone()), format!("{err:#}"))
})
.context("Failed to configure compiler with sources and options")?;
+53 -17
View File
@@ -604,6 +604,14 @@ where
L::Blockchain: revive_dt_node::Node + Send + Sync + 'static,
F::Blockchain: revive_dt_node::Node + Send + Sync + 'static,
{
let solc = revive_dt_compiler::solc_compiler(
config.directory(),
&config.solc,
test.mode.version.as_ref(),
test.mode.pipeline,
)
.await?;
let leader_reporter = test
.reporter
.execution_specific_reporter(leader_node.id(), NodeDesignation::Leader);
@@ -614,16 +622,15 @@ where
let (
CompilerOutput {
contracts: leader_pre_link_contracts,
..
},
CompilerOutput {
contracts: follower_pre_link_contracts,
..
},
) = try_join!(
cached_compiler.compile_contracts::<L>(
test.metadata,
test.metadata_file_path,
solc.clone(),
&test.mode,
config,
None,
@@ -631,15 +638,16 @@ where
leader_reporter
.report_pre_link_contracts_compilation_succeeded_event(
is_cached,
solc.clone(),
compiler_input,
compiler_output,
)
.expect("Can't fail")
},
|solc_info, compiler_input, failure_reason| {
|compiler_input, failure_reason| {
leader_reporter
.report_pre_link_contracts_compilation_failed_event(
solc_info,
solc.clone(),
compiler_input,
failure_reason,
)
@@ -649,6 +657,7 @@ where
cached_compiler.compile_contracts::<F>(
test.metadata,
test.metadata_file_path,
solc.clone(),
&test.mode,
config,
None,
@@ -656,15 +665,16 @@ where
follower_reporter
.report_pre_link_contracts_compilation_succeeded_event(
is_cached,
solc.clone(),
compiler_input,
compiler_output,
)
.expect("Can't fail")
},
|solc_info, compiler_input, failure_reason| {
|compiler_input, failure_reason| {
follower_reporter
.report_pre_link_contracts_compilation_failed_event(
solc_info,
solc.clone(),
compiler_input,
failure_reason,
)
@@ -802,17 +812,16 @@ where
let (
CompilerOutput {
solc: leader_solc_info,
contracts: leader_post_link_contracts,
},
CompilerOutput {
solc: follower_solc_info,
contracts: follower_post_link_contracts,
},
) = try_join!(
cached_compiler.compile_contracts::<L>(
test.metadata,
test.metadata_file_path,
solc.clone(),
&test.mode,
config,
leader_deployed_libraries.as_ref(),
@@ -820,15 +829,16 @@ where
leader_reporter
.report_post_link_contracts_compilation_succeeded_event(
is_cached,
solc.clone(),
compiler_input,
compiler_output,
)
.expect("Can't fail")
},
|solc_info, compiler_input, failure_reason| {
|compiler_input, failure_reason| {
leader_reporter
.report_post_link_contracts_compilation_failed_event(
solc_info,
solc.clone(),
compiler_input,
failure_reason,
)
@@ -838,6 +848,7 @@ where
cached_compiler.compile_contracts::<F>(
test.metadata,
test.metadata_file_path,
solc.clone(),
&test.mode,
config,
follower_deployed_libraries.as_ref(),
@@ -845,15 +856,16 @@ where
follower_reporter
.report_post_link_contracts_compilation_succeeded_event(
is_cached,
solc.clone(),
compiler_input,
compiler_output,
)
.expect("Can't fail")
},
|solc_info, compiler_input, failure_reason| {
|compiler_input, failure_reason| {
follower_reporter
.report_post_link_contracts_compilation_failed_event(
solc_info,
solc.clone(),
compiler_input,
failure_reason,
)
@@ -864,13 +876,13 @@ where
.context("Failed to compile post-link contracts for leader/follower in parallel")?;
let leader_state = CaseState::<L>::new(
leader_solc_info.version,
solc.version.clone(),
leader_post_link_contracts,
leader_deployed_libraries.unwrap_or_default(),
leader_reporter,
);
let follower_state = CaseState::<F>::new(
follower_solc_info.version,
solc.version.clone(),
follower_post_link_contracts,
follower_deployed_libraries.unwrap_or_default(),
follower_reporter,
@@ -913,7 +925,7 @@ async fn compile_corpus(
config: &Arguments,
tests: &[MetadataFile],
platform: &TestingPlatform,
_: Reporter,
reporter: Reporter,
report_aggregator_task: impl Future<Output = anyhow::Result<()>>,
) {
let tests = tests.iter().flat_map(|metadata| {
@@ -932,19 +944,42 @@ async fn compile_corpus(
let compilation_task =
futures::stream::iter(tests).for_each_concurrent(None, |(metadata, mode)| {
let cached_compiler = cached_compiler.clone();
let reporter = reporter.clone();
async move {
let solc = revive_dt_compiler::solc_compiler(
config.directory(),
&config.solc,
mode.version.as_ref(),
mode.pipeline,
)
.await;
let solc = match solc {
Ok(solc) => solc,
Err(err) => {
let test_specifier = TestSpecifier {
solc_mode: mode,
metadata_file_path: metadata.metadata_file_path.clone(),
case_idx: 0.into(),
};
let _ = reporter.report_test_failed_event(test_specifier, err.to_string());
return;
}
};
match platform {
TestingPlatform::Geth => {
let _ = cached_compiler
.compile_contracts::<Geth>(
metadata,
metadata.metadata_file_path.as_path(),
solc,
&mode,
config,
None,
|_, _, _| {},
|_, _, _| {},
|_, _| {},
)
.await;
}
@@ -953,11 +988,12 @@ async fn compile_corpus(
.compile_contracts::<Kitchensink>(
metadata,
metadata.metadata_file_path.as_path(),
solc,
&mode,
config,
None,
|_, _, _| {},
|_, _, _| {},
|_, _| {},
)
.await;
}
+5 -7
View File
@@ -10,7 +10,7 @@ use std::{
use alloy_primitives::Address;
use anyhow::{Context as _, Result};
use indexmap::IndexMap;
use revive_dt_compiler::{CompilerInput, CompilerOutput, Mode, SolcCompilerInformation};
use revive_dt_compiler::{CompilerInput, CompilerOutput, Mode, SolcCompiler};
use revive_dt_config::{Arguments, TestingPlatform};
use revive_dt_format::{case::CaseIdx, corpus::Corpus, metadata::ContractInstance};
use serde::Serialize;
@@ -290,7 +290,6 @@ impl ReportAggregator {
} else {
None
};
let solc_info = event.compiler_output.solc.clone();
let compiler_output = if include_output {
Some(event.compiler_output)
} else {
@@ -299,7 +298,7 @@ impl ReportAggregator {
execution_information.pre_link_compilation_status = Some(CompilationStatus::Success {
is_cached: event.is_cached,
solc_info,
solc_info: event.solc_info,
compiler_input,
compiler_output,
});
@@ -319,7 +318,6 @@ impl ReportAggregator {
} else {
None
};
let solc_info = event.compiler_output.solc.clone();
let compiler_output = if include_output {
Some(event.compiler_output)
} else {
@@ -328,7 +326,7 @@ impl ReportAggregator {
execution_information.post_link_compilation_status = Some(CompilationStatus::Success {
is_cached: event.is_cached,
solc_info,
solc_info: event.solc_info,
compiler_input,
compiler_output,
});
@@ -525,7 +523,7 @@ pub enum CompilationStatus {
/// A flag with information on whether the compilation artifacts were cached or not.
is_cached: bool,
/// The version and path of the solc compiler used to compile the contracts.
solc_info: SolcCompilerInformation,
solc_info: SolcCompiler,
/// The input provided to the compiler to compile the contracts. This is only included if
/// the appropriate flag is set in the CLI configuration and if the contracts were not
/// cached and the compiler was invoked.
@@ -541,7 +539,7 @@ pub enum CompilationStatus {
/// The failure reason.
reason: String,
/// The version and path of the solc compiler used to compile the contracts.
solc_info: Option<SolcCompilerInformation>,
solc_info: SolcCompiler,
/// The input provided to the compiler to compile the contracts. This is only included if
/// the appropriate flag is set in the CLI configuration and if the contracts were not
/// cached and the compiler was invoked.
+7 -3
View File
@@ -6,7 +6,7 @@ use std::{collections::BTreeMap, sync::Arc};
use alloy_primitives::Address;
use anyhow::Context as _;
use indexmap::IndexMap;
use revive_dt_compiler::{CompilerInput, CompilerOutput, SolcCompilerInformation};
use revive_dt_compiler::{CompilerInput, CompilerOutput, SolcCompiler};
use revive_dt_config::TestingPlatform;
use revive_dt_format::metadata::Metadata;
use revive_dt_format::{corpus::Corpus, metadata::ContractInstance};
@@ -549,6 +549,8 @@ define_event! {
/// A flag of whether the contract bytecode and ABI were cached or if they were compiled
/// anew.
is_cached: bool,
/// The version and path of the solc compiler used to compile the contracts.
solc_info: SolcCompiler,
/// The input provided to the compiler - this is optional and not provided if the
/// contracts were obtained from the cache.
compiler_input: Option<CompilerInput>,
@@ -563,6 +565,8 @@ define_event! {
/// A flag of whether the contract bytecode and ABI were cached or if they were compiled
/// anew.
is_cached: bool,
/// The version and path of the solc compiler used to compile the contracts.
solc_info: SolcCompiler,
/// The input provided to the compiler - this is optional and not provided if the
/// contracts were obtained from the cache.
compiler_input: Option<CompilerInput>,
@@ -575,7 +579,7 @@ define_event! {
/// A specifier for the execution that's taking place.
execution_specifier: Arc<ExecutionSpecifier>,
/// The version and path of the solc compiler used to compile the contracts.
solc_info: Option<SolcCompilerInformation>,
solc_info: SolcCompiler,
/// The input provided to the compiler - this is optional and not provided if the
/// contracts were obtained from the cache.
compiler_input: Option<CompilerInput>,
@@ -588,7 +592,7 @@ define_event! {
/// A specifier for the execution that's taking place.
execution_specifier: Arc<ExecutionSpecifier>,
/// The version and path of the solc compiler used to compile the contracts.
solc_info: Option<SolcCompilerInformation>,
solc_info: SolcCompiler,
/// The input provided to the compiler - this is optional and not provided if the
/// contracts were obtained from the cache.
compiler_input: Option<CompilerInput>,
-11
View File
@@ -5,7 +5,6 @@
use cache::get_or_download;
use download::SolcDownloader;
use semver::Version;
use std::path::{Path, PathBuf};
use revive_dt_common::types::VersionOrRequirement;
@@ -46,13 +45,3 @@ pub async fn download_solc(
let downloader = downloader(version, wasm).await?;
get_or_download(cache_directory, &downloader).await
}
/// Return the version of solc that will be downloaded via [`download_solc`]
/// given the version requirements and wasm flag.
pub async fn solc_version(
version: impl Into<VersionOrRequirement>,
wasm: bool,
) -> anyhow::Result<Version> {
let downloader = downloader(version, wasm).await?;
Ok(downloader.version.clone())
}