Return solc_version in CompilerOutput

This commit is contained in:
James Wilson
2025-08-27 10:45:22 +01:00
parent 4af9f6695d
commit dd94b12b34
8 changed files with 131 additions and 178 deletions
+13 -2
View File
@@ -14,8 +14,8 @@ use std::{
use alloy::json_abi::JsonAbi; use alloy::json_abi::JsonAbi;
use alloy_primitives::Address; use alloy_primitives::Address;
use semver::VersionReq;
use anyhow::Context; use anyhow::Context;
use semver::{Version, VersionReq};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use revive_common::EVMVersion; use revive_common::EVMVersion;
@@ -63,13 +63,24 @@ pub struct CompilerInput {
} }
/// The generic compilation output configuration. /// The generic compilation output configuration.
#[derive(Debug, Clone, Default, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CompilerOutput { 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 /// The compiled contracts. The bytecode of the contract is kept as a string incase linking is
/// required and the compiled source has placeholders. /// required and the compiled source has placeholders.
pub contracts: HashMap<PathBuf, HashMap<String, (String, JsonAbi)>>, 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. /// A generic builder style interface for configuring the supported compiler options.
pub struct Compiler<T: SolidityCompiler> { pub struct Compiler<T: SolidityCompiler> {
input: CompilerInput, input: CompilerInput,
+19 -13
View File
@@ -1,7 +1,7 @@
//! Implements the [SolidityCompiler] trait with `resolc` for //! Implements the [SolidityCompiler] trait with `resolc` for
//! compiling contracts to PolkaVM (PVM) bytecode. //! compiling contracts to PolkaVM (PVM) bytecode.
use std::{path::PathBuf, process::Stdio}; use std::{collections::HashMap, path::PathBuf, process::Stdio};
use revive_dt_common::types::VersionOrRequirement; use revive_dt_common::types::VersionOrRequirement;
use revive_dt_config::Arguments; use revive_dt_config::Arguments;
@@ -13,7 +13,10 @@ use revive_solc_json_interface::{
use super::constants::SOLC_VERSION_SUPPORTING_VIA_YUL_IR; use super::constants::SOLC_VERSION_SUPPORTING_VIA_YUL_IR;
use super::utils; use super::utils;
use crate::{CompilerInput, CompilerOutput, ModeOptimizerSetting, ModePipeline, SolidityCompiler}; use crate::{
CompilerInput, CompilerOutput, ModeOptimizerSetting, ModePipeline, SolcCompilerInformation,
SolidityCompiler,
};
use alloy::json_abi::JsonAbi; use alloy::json_abi::JsonAbi;
use anyhow::Context; use anyhow::Context;
@@ -23,10 +26,8 @@ use tokio::{io::AsyncWriteExt, process::Command as AsyncCommand};
/// A wrapper around the `resolc` binary, emitting PVM-compatible bytecode. /// A wrapper around the `resolc` binary, emitting PVM-compatible bytecode.
#[derive(Debug)] #[derive(Debug)]
pub struct Resolc { pub struct Resolc {
// Enable wasm compilation. // Where to cache compiler executables.
wasm: bool, compiler_executables_cache_directory: PathBuf,
// Where to cache artifacts.
cache_directory: PathBuf,
// We'll use this version when no explicit version // We'll use this version when no explicit version
// requirement is given in the test mode. // requirement is given in the test mode.
solc_version: Version, solc_version: Version,
@@ -64,9 +65,9 @@ impl SolidityCompiler for Resolc {
let solc_version_req = solc_version let solc_version_req = solc_version
.unwrap_or_else(|| VersionOrRequirement::version_to_requirement(&self.solc_version)); .unwrap_or_else(|| VersionOrRequirement::version_to_requirement(&self.solc_version));
let solc_path = revive_dt_solc_binaries::download_solc( let solc_path = revive_dt_solc_binaries::download_solc(
&self.cache_directory, &self.compiler_executables_cache_directory,
solc_version_req, solc_version_req,
self.wasm, false,
) )
.await?; .await?;
let solc_version = utils::solc_version(&solc_path).await?; let solc_version = utils::solc_version(&solc_path).await?;
@@ -202,14 +203,14 @@ impl SolidityCompiler for Resolc {
anyhow::bail!("Unexpected error - resolc output doesn't have a contracts section"); anyhow::bail!("Unexpected error - resolc output doesn't have a contracts section");
}; };
let mut compiler_output = CompilerOutput::default(); let mut compiled_contracts = HashMap::<PathBuf, HashMap<_, _>>::new();
for (source_path, contracts) in contracts.into_iter() { for (source_path, contracts) in contracts.into_iter() {
let src_for_msg = source_path.clone(); let src_for_msg = source_path.clone();
let source_path = PathBuf::from(source_path) let source_path = PathBuf::from(source_path)
.canonicalize() .canonicalize()
.with_context(|| format!("Failed to canonicalize path {src_for_msg}"))?; .with_context(|| format!("Failed to canonicalize path {src_for_msg}"))?;
let map = compiler_output.contracts.entry(source_path).or_default(); let map = compiled_contracts.entry(source_path).or_default();
for (contract_name, contract_information) in contracts.into_iter() { for (contract_name, contract_information) in contracts.into_iter() {
let bytecode = contract_information let bytecode = contract_information
.evm .evm
@@ -254,13 +255,18 @@ impl SolidityCompiler for Resolc {
} }
} }
Ok(compiler_output) Ok(CompilerOutput {
solc: SolcCompilerInformation {
version: solc_version,
path: solc_path,
},
contracts: compiled_contracts,
})
} }
fn new(config: &Arguments) -> Self { fn new(config: &Arguments) -> Self {
Resolc { Resolc {
wasm: config.wasm, compiler_executables_cache_directory: config.directory().to_path_buf(),
cache_directory: config.directory().to_path_buf(),
solc_version: config.solc.clone(), solc_version: config.solc.clone(),
resolc_path: config.resolc.clone(), resolc_path: config.resolc.clone(),
} }
+18 -11
View File
@@ -1,14 +1,17 @@
//! Implements the [SolidityCompiler] trait with solc for //! Implements the [SolidityCompiler] trait with solc for
//! compiling contracts to EVM bytecode. //! compiling contracts to EVM bytecode.
use std::{path::PathBuf, process::Stdio}; use std::{collections::HashMap, path::PathBuf, process::Stdio};
use revive_dt_common::types::VersionOrRequirement; use revive_dt_common::types::VersionOrRequirement;
use revive_dt_config::Arguments; use revive_dt_config::Arguments;
use super::constants::SOLC_VERSION_SUPPORTING_VIA_YUL_IR; use super::constants::SOLC_VERSION_SUPPORTING_VIA_YUL_IR;
use super::utils; use super::utils;
use crate::{CompilerInput, CompilerOutput, ModeOptimizerSetting, ModePipeline, SolidityCompiler}; use crate::{
CompilerInput, CompilerOutput, ModeOptimizerSetting, ModePipeline, SolcCompilerInformation,
SolidityCompiler,
};
use anyhow::Context; use anyhow::Context;
use foundry_compilers_artifacts::{ use foundry_compilers_artifacts::{
@@ -23,8 +26,6 @@ use tokio::{io::AsyncWriteExt, process::Command as AsyncCommand};
#[derive(Debug)] #[derive(Debug)]
pub struct Solc { pub struct Solc {
// Enable wasm compilation.
wasm: bool,
// Where to cache artifacts. // Where to cache artifacts.
cache_directory: PathBuf, cache_directory: PathBuf,
// We'll use this version when no explicit version requirement // We'll use this version when no explicit version requirement
@@ -51,11 +52,13 @@ impl SolidityCompiler for Solc {
}: CompilerInput, }: CompilerInput,
_: Self::Options, _: Self::Options,
) -> anyhow::Result<CompilerOutput> { ) -> anyhow::Result<CompilerOutput> {
let solc_version = solc_version let solc_version_req = solc_version
.unwrap_or_else(|| VersionOrRequirement::version_to_requirement(&self.solc_version)); .unwrap_or_else(|| VersionOrRequirement::version_to_requirement(&self.solc_version));
let solc_path = let solc_path =
revive_dt_solc_binaries::download_solc(&self.cache_directory, solc_version, self.wasm) revive_dt_solc_binaries::download_solc(&self.cache_directory, solc_version_req, false)
.await?; .await?;
let solc_version = utils::solc_version(&solc_path).await?;
let compiler_supports_via_ir = let compiler_supports_via_ir =
utils::solc_version(&solc_path).await? >= SOLC_VERSION_SUPPORTING_VIA_YUL_IR; utils::solc_version(&solc_path).await? >= SOLC_VERSION_SUPPORTING_VIA_YUL_IR;
@@ -194,10 +197,9 @@ impl SolidityCompiler for Solc {
"Compiled successfully" "Compiled successfully"
); );
let mut compiler_output = CompilerOutput::default(); let mut compiled_contracts = HashMap::<PathBuf, HashMap<_, _>>::new();
for (contract_path, contracts) in parsed.contracts { for (contract_path, contracts) in parsed.contracts {
let map = compiler_output let map = compiled_contracts
.contracts
.entry(contract_path.canonicalize().with_context(|| { .entry(contract_path.canonicalize().with_context(|| {
format!( format!(
"Failed to canonicalize contract path {}", "Failed to canonicalize contract path {}",
@@ -221,12 +223,17 @@ impl SolidityCompiler for Solc {
} }
} }
Ok(compiler_output) Ok(CompilerOutput {
solc: SolcCompilerInformation {
version: solc_version,
path: solc_path,
},
contracts: compiled_contracts,
})
} }
fn new(config: &Arguments) -> Self { fn new(config: &Arguments) -> Self {
Self { Self {
wasm: config.wasm,
cache_directory: config.directory().to_path_buf(), cache_directory: config.directory().to_path_buf(),
solc_version: config.solc.clone(), solc_version: config.solc.clone(),
} }
+27 -55
View File
@@ -9,7 +9,7 @@ use std::{
use futures::FutureExt; use futures::FutureExt;
use revive_dt_common::iterators::FilesWithExtensionIterator; use revive_dt_common::iterators::FilesWithExtensionIterator;
use revive_dt_compiler::{Compiler, CompilerInput, CompilerOutput, Mode}; use revive_dt_compiler::{Compiler, CompilerInput, CompilerOutput, Mode, SolcCompilerInformation};
use revive_dt_config::Arguments; use revive_dt_config::Arguments;
use revive_dt_format::metadata::{ContractIdent, ContractInstance, Metadata}; use revive_dt_format::metadata::{ContractIdent, ContractInstance, Metadata};
use revive_dt_solc_binaries::solc_version; use revive_dt_solc_binaries::solc_version;
@@ -57,29 +57,23 @@ impl CachedCompiler {
mode: &Mode, mode: &Mode,
config: &Arguments, config: &Arguments,
deployed_libraries: Option<&HashMap<ContractInstance, (ContractIdent, Address, JsonAbi)>>, deployed_libraries: Option<&HashMap<ContractInstance, (ContractIdent, Address, JsonAbi)>>,
compilation_success_report_callback: impl Fn( compilation_success_report_callback: impl Fn(bool, Option<CompilerInput>, CompilerOutput)
Version, + Clone,
PathBuf,
bool,
Option<CompilerInput>,
CompilerOutput,
) + Clone,
compilation_failure_report_callback: impl Fn( compilation_failure_report_callback: impl Fn(
Option<Version>, Option<SolcCompilerInformation>,
Option<PathBuf>,
Option<CompilerInput>, Option<CompilerInput>,
String, String,
), ),
) -> Result<(CompilerOutput, Version)> { ) -> Result<CompilerOutput> {
static CACHE_KEY_LOCK: Lazy<RwLock<HashMap<CacheKey, Arc<Mutex<()>>>>> = static CACHE_KEY_LOCK: Lazy<RwLock<HashMap<CacheKey, Arc<Mutex<()>>>>> =
Lazy::new(Default::default); Lazy::new(Default::default);
let compiler_version_or_requirement = mode.compiler_version_to_use(config.solc.clone()); let solc_version_or_requirement = mode.compiler_version_to_use(config.solc.clone());
let compiler_version = solc_version(compiler_version_or_requirement, config.wasm).await?; let solc_version = solc_version(solc_version_or_requirement, false).await?;
let cache_key = CacheKey { let cache_key = CacheKey {
platform_key: P::config_id().to_string(), platform_key: P::config_id().to_string(),
compiler_version: compiler_version.clone(), compiler_version: solc_version.clone(),
metadata_file_path: metadata_file_path.as_ref().to_path_buf(), metadata_file_path: metadata_file_path.as_ref().to_path_buf(),
solc_mode: mode.clone(), solc_mode: mode.clone(),
}; };
@@ -146,13 +140,11 @@ impl CachedCompiler {
match self.0.get(&cache_key).await { match self.0.get(&cache_key).await {
Some(cache_value) => { Some(cache_value) => {
// compilation_success_report_callback( compilation_success_report_callback(
// compiler_version.clone(), true,
// compiler_path, None,
// true, cache_value.compiler_output.clone(),
// None, );
// cache_value.compiler_output.clone(),
// );
cache_value.compiler_output cache_value.compiler_output
} }
None => { None => {
@@ -165,7 +157,7 @@ impl CachedCompiler {
} }
}; };
Ok((compiled_contracts, compiler_version)) Ok(compiled_contracts)
} }
} }
@@ -176,16 +168,9 @@ async fn compile_contracts<P: Platform>(
config: &Arguments, config: &Arguments,
mode: &Mode, mode: &Mode,
deployed_libraries: Option<&HashMap<ContractInstance, (ContractIdent, Address, JsonAbi)>>, deployed_libraries: Option<&HashMap<ContractInstance, (ContractIdent, Address, JsonAbi)>>,
compilation_success_report_callback: impl Fn( compilation_success_report_callback: impl Fn(bool, Option<CompilerInput>, CompilerOutput),
Version,
PathBuf,
bool,
Option<CompilerInput>,
CompilerOutput,
),
compilation_failure_report_callback: impl Fn( compilation_failure_report_callback: impl Fn(
Option<Version>, Option<SolcCompilerInformation>,
Option<PathBuf>,
Option<CompilerInput>, Option<CompilerInput>,
String, String,
), ),
@@ -204,15 +189,8 @@ async fn compile_contracts<P: Platform>(
// Adding the contract sources to the compiler. // Adding the contract sources to the compiler.
.try_then(|compiler| { .try_then(|compiler| {
files_to_compile.try_fold(compiler, |compiler, path| compiler.with_source(path)) files_to_compile.try_fold(compiler, |compiler, path| compiler.with_source(path))
// }) })
// .inspect_err(|err| { .inspect_err(|err| compilation_failure_report_callback(None, None, format!("{err:#}")))?
// compilation_failure_report_callback(
// Some(compiler_version.clone()),
// Some(compiler_path.as_ref().to_path_buf()),
// None,
// format!("{err:#}"),
// )
})?
// Adding the deployed libraries to the compiler. // Adding the deployed libraries to the compiler.
.then(|compiler| { .then(|compiler| {
deployed_libraries deployed_libraries
@@ -233,22 +211,16 @@ async fn compile_contracts<P: Platform>(
let compiler_output = compiler let compiler_output = compiler
.try_build(config) .try_build(config)
.await .await
// .inspect_err(|err| { .inspect_err(|err| {
// compilation_failure_report_callback( compilation_failure_report_callback(
// Some(compiler_version.clone()), None,
// Some(compiler_path.as_ref().to_path_buf()), Some(compiler_input.clone()),
// Some(compiler_input.clone()), format!("{err:#}"),
// format!("{err:#}"), )
// ) })
// })
.context("Failed to configure compiler with sources and options")?; .context("Failed to configure compiler with sources and options")?;
// compilation_success_report_callback(
// compiler_version, compilation_success_report_callback(false, Some(compiler_input), compiler_output.clone());
// compiler_path.as_ref().to_path_buf(),
// false,
// Some(compiler_input),
// compiler_output.clone(),
// );
Ok(compiler_output) Ok(compiler_output)
} }
+36 -56
View File
@@ -18,12 +18,12 @@ use futures::StreamExt;
use futures::stream; use futures::stream;
use indexmap::IndexMap; use indexmap::IndexMap;
use revive_dt_node_interaction::EthereumNode; use revive_dt_node_interaction::EthereumNode;
use tempfile::TempDir;
use tokio::{join, try_join};
use revive_dt_report::{ use revive_dt_report::{
NodeDesignation, ReportAggregator, Reporter, ReporterEvent, TestCaseStatus, NodeDesignation, ReportAggregator, Reporter, ReporterEvent, TestCaseStatus,
TestSpecificReporter, TestSpecifier, TestSpecificReporter, TestSpecifier,
}; };
use tempfile::TempDir;
use tokio::{join, try_join};
use tracing::{debug, info, info_span, instrument}; use tracing::{debug, info, info_span, instrument};
use tracing_appender::non_blocking::WorkerGuard; use tracing_appender::non_blocking::WorkerGuard;
use tracing_subscriber::{EnvFilter, FmtSubscriber}; use tracing_subscriber::{EnvFilter, FmtSubscriber};
@@ -612,18 +612,14 @@ where
.execution_specific_reporter(follower_node.id(), NodeDesignation::Follower); .execution_specific_reporter(follower_node.id(), NodeDesignation::Follower);
let ( let (
( CompilerOutput {
CompilerOutput { contracts: leader_pre_link_contracts,
contracts: leader_pre_link_contracts, ..
}, },
_, CompilerOutput {
), contracts: follower_pre_link_contracts,
( ..
CompilerOutput { },
contracts: follower_pre_link_contracts,
},
_,
),
) = try_join!( ) = try_join!(
cached_compiler.compile_contracts::<L>( cached_compiler.compile_contracts::<L>(
test.metadata, test.metadata,
@@ -631,22 +627,19 @@ where
&test.mode, &test.mode,
config, config,
None, None,
|compiler_version, compiler_path, is_cached, compiler_input, compiler_output| { |is_cached, compiler_input, compiler_output| {
leader_reporter leader_reporter
.report_pre_link_contracts_compilation_succeeded_event( .report_pre_link_contracts_compilation_succeeded_event(
compiler_version,
compiler_path,
is_cached, is_cached,
compiler_input, compiler_input,
compiler_output, compiler_output,
) )
.expect("Can't fail") .expect("Can't fail")
}, },
|compiler_version, compiler_path, compiler_input, failure_reason| { |solc_info, compiler_input, failure_reason| {
leader_reporter leader_reporter
.report_pre_link_contracts_compilation_failed_event( .report_pre_link_contracts_compilation_failed_event(
compiler_version, solc_info,
compiler_path,
compiler_input, compiler_input,
failure_reason, failure_reason,
) )
@@ -659,22 +652,19 @@ where
&test.mode, &test.mode,
config, config,
None, None,
|compiler_version, compiler_path, is_cached, compiler_input, compiler_output| { |is_cached, compiler_input, compiler_output| {
follower_reporter follower_reporter
.report_pre_link_contracts_compilation_succeeded_event( .report_pre_link_contracts_compilation_succeeded_event(
compiler_version,
compiler_path,
is_cached, is_cached,
compiler_input, compiler_input,
compiler_output, compiler_output,
) )
.expect("Can't fail") .expect("Can't fail")
}, },
|compiler_version, compiler_path, compiler_input, failure_reason| { |solc_info, compiler_input, failure_reason| {
follower_reporter follower_reporter
.report_pre_link_contracts_compilation_failed_event( .report_pre_link_contracts_compilation_failed_event(
compiler_version, solc_info,
compiler_path,
compiler_input, compiler_input,
failure_reason, failure_reason,
) )
@@ -811,18 +801,14 @@ where
} }
let ( let (
( CompilerOutput {
CompilerOutput { solc: leader_solc_info,
contracts: leader_post_link_contracts, contracts: leader_post_link_contracts,
}, },
leader_compiler_version, CompilerOutput {
), solc: follower_solc_info,
( contracts: follower_post_link_contracts,
CompilerOutput { },
contracts: follower_post_link_contracts,
},
follower_compiler_version,
),
) = try_join!( ) = try_join!(
cached_compiler.compile_contracts::<L>( cached_compiler.compile_contracts::<L>(
test.metadata, test.metadata,
@@ -830,22 +816,19 @@ where
&test.mode, &test.mode,
config, config,
leader_deployed_libraries.as_ref(), leader_deployed_libraries.as_ref(),
|compiler_version, compiler_path, is_cached, compiler_input, compiler_output| { |is_cached, compiler_input, compiler_output| {
leader_reporter leader_reporter
.report_post_link_contracts_compilation_succeeded_event( .report_post_link_contracts_compilation_succeeded_event(
compiler_version,
compiler_path,
is_cached, is_cached,
compiler_input, compiler_input,
compiler_output, compiler_output,
) )
.expect("Can't fail") .expect("Can't fail")
}, },
|compiler_version, compiler_path, compiler_input, failure_reason| { |solc_info, compiler_input, failure_reason| {
leader_reporter leader_reporter
.report_post_link_contracts_compilation_failed_event( .report_post_link_contracts_compilation_failed_event(
compiler_version, solc_info,
compiler_path,
compiler_input, compiler_input,
failure_reason, failure_reason,
) )
@@ -858,22 +841,19 @@ where
&test.mode, &test.mode,
config, config,
follower_deployed_libraries.as_ref(), follower_deployed_libraries.as_ref(),
|compiler_version, compiler_path, is_cached, compiler_input, compiler_output| { |is_cached, compiler_input, compiler_output| {
follower_reporter follower_reporter
.report_post_link_contracts_compilation_succeeded_event( .report_post_link_contracts_compilation_succeeded_event(
compiler_version,
compiler_path,
is_cached, is_cached,
compiler_input, compiler_input,
compiler_output, compiler_output,
) )
.expect("Can't fail") .expect("Can't fail")
}, },
|compiler_version, compiler_path, compiler_input, failure_reason| { |solc_info, compiler_input, failure_reason| {
follower_reporter follower_reporter
.report_post_link_contracts_compilation_failed_event( .report_post_link_contracts_compilation_failed_event(
compiler_version, solc_info,
compiler_path,
compiler_input, compiler_input,
failure_reason, failure_reason,
) )
@@ -884,13 +864,13 @@ where
.context("Failed to compile post-link contracts for leader/follower in parallel")?; .context("Failed to compile post-link contracts for leader/follower in parallel")?;
let leader_state = CaseState::<L>::new( let leader_state = CaseState::<L>::new(
leader_compiler_version, leader_solc_info.version,
leader_post_link_contracts, leader_post_link_contracts,
leader_deployed_libraries.unwrap_or_default(), leader_deployed_libraries.unwrap_or_default(),
leader_reporter, leader_reporter,
); );
let follower_state = CaseState::<F>::new( let follower_state = CaseState::<F>::new(
follower_compiler_version, follower_solc_info.version,
follower_post_link_contracts, follower_post_link_contracts,
follower_deployed_libraries.unwrap_or_default(), follower_deployed_libraries.unwrap_or_default(),
follower_reporter, follower_reporter,
@@ -963,8 +943,8 @@ async fn compile_corpus(
&mode, &mode,
config, config,
None, None,
|_, _, _, _, _| {}, |_, _, _| {},
|_, _, _, _| {}, |_, _, _| {},
) )
.await; .await;
} }
@@ -976,8 +956,8 @@ async fn compile_corpus(
&mode, &mode,
config, config,
None, None,
|_, _, _, _, _| {}, |_, _, _| {},
|_, _, _, _| {}, |_, _, _| {},
) )
.await; .await;
} }
+11 -21
View File
@@ -4,17 +4,15 @@
use std::{ use std::{
collections::{BTreeMap, BTreeSet, HashMap, HashSet}, collections::{BTreeMap, BTreeSet, HashMap, HashSet},
fs::OpenOptions, fs::OpenOptions,
path::PathBuf,
time::{SystemTime, UNIX_EPOCH}, time::{SystemTime, UNIX_EPOCH},
}; };
use alloy_primitives::Address; use alloy_primitives::Address;
use anyhow::{Context as _, Result}; use anyhow::{Context as _, Result};
use indexmap::IndexMap; use indexmap::IndexMap;
use revive_dt_compiler::{CompilerInput, CompilerOutput, Mode}; use revive_dt_compiler::{CompilerInput, CompilerOutput, Mode, SolcCompilerInformation};
use revive_dt_config::{Arguments, TestingPlatform}; use revive_dt_config::{Arguments, TestingPlatform};
use revive_dt_format::{case::CaseIdx, corpus::Corpus, metadata::ContractInstance}; use revive_dt_format::{case::CaseIdx, corpus::Corpus, metadata::ContractInstance};
use semver::Version;
use serde::Serialize; use serde::Serialize;
use serde_with::{DisplayFromStr, serde_as}; use serde_with::{DisplayFromStr, serde_as};
use tokio::sync::{ use tokio::sync::{
@@ -292,6 +290,7 @@ impl ReportAggregator {
} else { } else {
None None
}; };
let solc_info = event.compiler_output.solc.clone();
let compiler_output = if include_output { let compiler_output = if include_output {
Some(event.compiler_output) Some(event.compiler_output)
} else { } else {
@@ -300,8 +299,7 @@ impl ReportAggregator {
execution_information.pre_link_compilation_status = Some(CompilationStatus::Success { execution_information.pre_link_compilation_status = Some(CompilationStatus::Success {
is_cached: event.is_cached, is_cached: event.is_cached,
compiler_version: event.compiler_version, solc_info,
compiler_path: event.compiler_path,
compiler_input, compiler_input,
compiler_output, compiler_output,
}); });
@@ -321,6 +319,7 @@ impl ReportAggregator {
} else { } else {
None None
}; };
let solc_info = event.compiler_output.solc.clone();
let compiler_output = if include_output { let compiler_output = if include_output {
Some(event.compiler_output) Some(event.compiler_output)
} else { } else {
@@ -329,8 +328,7 @@ impl ReportAggregator {
execution_information.post_link_compilation_status = Some(CompilationStatus::Success { execution_information.post_link_compilation_status = Some(CompilationStatus::Success {
is_cached: event.is_cached, is_cached: event.is_cached,
compiler_version: event.compiler_version, solc_info,
compiler_path: event.compiler_path,
compiler_input, compiler_input,
compiler_output, compiler_output,
}); });
@@ -352,8 +350,7 @@ impl ReportAggregator {
execution_information.pre_link_compilation_status = Some(CompilationStatus::Failure { execution_information.pre_link_compilation_status = Some(CompilationStatus::Failure {
reason: event.reason, reason: event.reason,
compiler_version: event.compiler_version, solc_info: event.solc_info,
compiler_path: event.compiler_path,
compiler_input, compiler_input,
}); });
} }
@@ -374,8 +371,7 @@ impl ReportAggregator {
execution_information.post_link_compilation_status = Some(CompilationStatus::Failure { execution_information.post_link_compilation_status = Some(CompilationStatus::Failure {
reason: event.reason, reason: event.reason,
compiler_version: event.compiler_version, solc_info: event.solc_info,
compiler_path: event.compiler_path,
compiler_input, compiler_input,
}); });
} }
@@ -528,10 +524,8 @@ pub enum CompilationStatus {
Success { Success {
/// A flag with information on whether the compilation artifacts were cached or not. /// A flag with information on whether the compilation artifacts were cached or not.
is_cached: bool, is_cached: bool,
/// The version of the compiler used to compile the contracts. /// The version and path of the solc compiler used to compile the contracts.
compiler_version: Version, solc_info: SolcCompilerInformation,
/// The path of the compiler used to compile the contracts.
compiler_path: PathBuf,
/// The input provided to the compiler to compile the contracts. This is only included if /// 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 /// the appropriate flag is set in the CLI configuration and if the contracts were not
/// cached and the compiler was invoked. /// cached and the compiler was invoked.
@@ -546,12 +540,8 @@ pub enum CompilationStatus {
Failure { Failure {
/// The failure reason. /// The failure reason.
reason: String, reason: String,
/// The version of the compiler used to compile the contracts. /// The version and path of the solc compiler used to compile the contracts.
#[serde(skip_serializing_if = "Option::is_none")] solc_info: Option<SolcCompilerInformation>,
compiler_version: Option<Version>,
/// The path of the compiler used to compile the contracts.
#[serde(skip_serializing_if = "Option::is_none")]
compiler_path: Option<PathBuf>,
/// The input provided to the compiler to compile the contracts. This is only included if /// 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 /// the appropriate flag is set in the CLI configuration and if the contracts were not
/// cached and the compiler was invoked. /// cached and the compiler was invoked.
+6 -19
View File
@@ -1,16 +1,15 @@
//! The types associated with the events sent by the runner to the reporter. //! The types associated with the events sent by the runner to the reporter.
#![allow(dead_code)] #![allow(dead_code)]
use std::{collections::BTreeMap, path::PathBuf, sync::Arc}; use std::{collections::BTreeMap, sync::Arc};
use alloy_primitives::Address; use alloy_primitives::Address;
use anyhow::Context as _; use anyhow::Context as _;
use indexmap::IndexMap; use indexmap::IndexMap;
use revive_dt_compiler::{CompilerInput, CompilerOutput}; use revive_dt_compiler::{CompilerInput, CompilerOutput, SolcCompilerInformation};
use revive_dt_config::TestingPlatform; use revive_dt_config::TestingPlatform;
use revive_dt_format::metadata::Metadata; use revive_dt_format::metadata::Metadata;
use revive_dt_format::{corpus::Corpus, metadata::ContractInstance}; use revive_dt_format::{corpus::Corpus, metadata::ContractInstance};
use semver::Version;
use tokio::sync::{broadcast, oneshot}; use tokio::sync::{broadcast, oneshot};
use crate::{ExecutionSpecifier, ReporterEvent, TestSpecifier, common::MetadataFilePath}; use crate::{ExecutionSpecifier, ReporterEvent, TestSpecifier, common::MetadataFilePath};
@@ -547,10 +546,6 @@ define_event! {
PreLinkContractsCompilationSucceeded { PreLinkContractsCompilationSucceeded {
/// A specifier for the execution that's taking place. /// A specifier for the execution that's taking place.
execution_specifier: Arc<ExecutionSpecifier>, execution_specifier: Arc<ExecutionSpecifier>,
/// The version of the compiler used to compile the contracts.
compiler_version: Version,
/// The path of the compiler used to compile the contracts.
compiler_path: PathBuf,
/// A flag of whether the contract bytecode and ABI were cached or if they were compiled /// A flag of whether the contract bytecode and ABI were cached or if they were compiled
/// anew. /// anew.
is_cached: bool, is_cached: bool,
@@ -565,10 +560,6 @@ define_event! {
PostLinkContractsCompilationSucceeded { PostLinkContractsCompilationSucceeded {
/// A specifier for the execution that's taking place. /// A specifier for the execution that's taking place.
execution_specifier: Arc<ExecutionSpecifier>, execution_specifier: Arc<ExecutionSpecifier>,
/// The version of the compiler used to compile the contracts.
compiler_version: Version,
/// The path of the compiler used to compile the contracts.
compiler_path: PathBuf,
/// A flag of whether the contract bytecode and ABI were cached or if they were compiled /// A flag of whether the contract bytecode and ABI were cached or if they were compiled
/// anew. /// anew.
is_cached: bool, is_cached: bool,
@@ -583,10 +574,8 @@ define_event! {
PreLinkContractsCompilationFailed { PreLinkContractsCompilationFailed {
/// A specifier for the execution that's taking place. /// A specifier for the execution that's taking place.
execution_specifier: Arc<ExecutionSpecifier>, execution_specifier: Arc<ExecutionSpecifier>,
/// The version of the compiler used to compile the contracts. /// The version and path of the solc compiler used to compile the contracts.
compiler_version: Option<Version>, solc_info: Option<SolcCompilerInformation>,
/// The path of the compiler used to compile the contracts.
compiler_path: Option<PathBuf>,
/// The input provided to the compiler - this is optional and not provided if the /// The input provided to the compiler - this is optional and not provided if the
/// contracts were obtained from the cache. /// contracts were obtained from the cache.
compiler_input: Option<CompilerInput>, compiler_input: Option<CompilerInput>,
@@ -598,10 +587,8 @@ define_event! {
PostLinkContractsCompilationFailed { PostLinkContractsCompilationFailed {
/// A specifier for the execution that's taking place. /// A specifier for the execution that's taking place.
execution_specifier: Arc<ExecutionSpecifier>, execution_specifier: Arc<ExecutionSpecifier>,
/// The version of the compiler used to compile the contracts. /// The version and path of the solc compiler used to compile the contracts.
compiler_version: Option<Version>, solc_info: Option<SolcCompilerInformation>,
/// The path of the compiler used to compile the contracts.
compiler_path: Option<PathBuf>,
/// The input provided to the compiler - this is optional and not provided if the /// The input provided to the compiler - this is optional and not provided if the
/// contracts were obtained from the cache. /// contracts were obtained from the cache.
compiler_input: Option<CompilerInput>, compiler_input: Option<CompilerInput>,
+1 -1
View File
@@ -3,10 +3,10 @@
//! //!
//! [0]: https://binaries.soliditylang.org //! [0]: https://binaries.soliditylang.org
use std::path::{Path, PathBuf};
use cache::get_or_download; use cache::get_or_download;
use download::SolcDownloader; use download::SolcDownloader;
use semver::Version; use semver::Version;
use std::path::{Path, PathBuf};
use revive_dt_common::types::VersionOrRequirement; use revive_dt_common::types::VersionOrRequirement;