From 3a755b625ed7890c254675a35c3e1e190179bbdf Mon Sep 17 00:00:00 2001 From: Oleksandr Zarudnyi Date: Fri, 30 Aug 2024 13:09:07 +0800 Subject: [PATCH] fix: set solc toolchain for EVM by default --- .../src/compiler_tester/arguments.rs | 9 +++--- compiler_tester/src/compiler_tester/main.rs | 31 +++++++++++-------- compiler_tester/src/toolchain.rs | 8 ++--- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/compiler_tester/src/compiler_tester/arguments.rs b/compiler_tester/src/compiler_tester/arguments.rs index 697b71c..93c77eb 100644 --- a/compiler_tester/src/compiler_tester/arguments.rs +++ b/compiler_tester/src/compiler_tester/arguments.rs @@ -70,10 +70,11 @@ pub struct Arguments { pub zkvyper: Option, /// Specify the compiler toolchain. - /// Available arguments: `IR-LLVM`, `solc`, `solc-LLVM`. - /// The default is `EraVM`. - #[structopt(long = "toolchain", default_value = "IR-LLVM")] - pub toolchain: compiler_tester::Toolchain, + /// Available arguments: `ir-llvm`, `solc`, `solc-llvm`. + /// The default for `EraVM` target is `ir-llvm`. + /// The default for `EVM` target is `solc`. + #[structopt(long = "toolchain")] + pub toolchain: Option, /// Specify the target architecture. /// Available arguments: `eravm`, `evm`. diff --git a/compiler_tester/src/compiler_tester/main.rs b/compiler_tester/src/compiler_tester/main.rs index 62c915b..3a54088 100644 --- a/compiler_tester/src/compiler_tester/main.rs +++ b/compiler_tester/src/compiler_tester/main.rs @@ -100,9 +100,15 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> { arguments.workflow, )?; + let toolchain = match (arguments.target, arguments.toolchain) { + (era_compiler_common::Target::EraVM, Some(toolchain)) => toolchain, + (era_compiler_common::Target::EraVM, None) => compiler_tester::Toolchain::IrLLVM, + (era_compiler_common::Target::EVM, Some(toolchain)) => toolchain, + (era_compiler_common::Target::EVM, None) => compiler_tester::Toolchain::Solc, + }; let binary_download_config_paths = vec![ arguments.solc_bin_config_path.unwrap_or_else(|| { - PathBuf::from(match arguments.toolchain { + PathBuf::from(match toolchain { compiler_tester::Toolchain::IrLLVM => "./configs/solc-bin-default.json", compiler_tester::Toolchain::Solc => "./configs/solc-bin-upstream.json", compiler_tester::Toolchain::SolcLLVM => todo!(), @@ -112,14 +118,6 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> { .vyper_bin_config_path .unwrap_or_else(|| PathBuf::from("./configs/vyper-bin-default.json")), ]; - - let run_time_start = Instant::now(); - println!( - " {} tests with {} worker threads", - "Running".bright_green().bold(), - rayon::current_num_threads(), - ); - let environment = match (arguments.target, arguments.environment) { ( era_compiler_common::Target::EraVM, @@ -142,6 +140,14 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> { "Target `{target}` and environment `{environment}` combination is not supported" ), }; + + let run_time_start = Instant::now(); + println!( + " {} tests with {} worker threads", + "Running".bright_green().bold(), + rayon::current_num_threads(), + ); + match environment { compiler_tester::Environment::ZkEVM => { let system_contracts_debug_config = if arguments.dump_system { @@ -192,13 +198,12 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> { compiler_tester .run_evm_interpreter::( - vm, - arguments.toolchain, + vm, toolchain, ) } compiler_tester::Environment::REVM => { compiler_tester::EVM::download(binary_download_config_paths)?; - compiler_tester.run_revm(arguments.toolchain) + compiler_tester.run_revm(toolchain) } }?; @@ -249,7 +254,7 @@ mod tests { era_compiler_solidity::DEFAULT_EXECUTABLE_NAME, )), zkvyper: Some(PathBuf::from(era_compiler_vyper::DEFAULT_EXECUTABLE_NAME)), - toolchain: compiler_tester::Toolchain::IrLLVM, + toolchain: Some(compiler_tester::Toolchain::IrLLVM), target: era_compiler_common::Target::EraVM, environment: None, workflow: compiler_tester::Workflow::BuildAndRun, diff --git a/compiler_tester/src/toolchain.rs b/compiler_tester/src/toolchain.rs index 83c0cc1..c241821 100644 --- a/compiler_tester/src/toolchain.rs +++ b/compiler_tester/src/toolchain.rs @@ -20,9 +20,9 @@ impl std::str::FromStr for Toolchain { fn from_str(string: &str) -> Result { match string { - "IR-LLVM" => Ok(Self::IrLLVM), + "ir-llvm" => Ok(Self::IrLLVM), "solc" => Ok(Self::Solc), - "solc-LLVM" => Ok(Self::SolcLLVM), + "solc-llvm" => Ok(Self::SolcLLVM), string => anyhow::bail!( "Unknown target `{}`. Supported targets: {}", string, @@ -39,9 +39,9 @@ impl std::str::FromStr for Toolchain { impl std::fmt::Display for Toolchain { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::IrLLVM => write!(f, "IR-LLVM"), + Self::IrLLVM => write!(f, "ir-llvm"), Self::Solc => write!(f, "solc"), - Self::SolcLLVM => write!(f, "solc-LLVM"), + Self::SolcLLVM => write!(f, "solc-llvm"), } } }