Skip to content

Commit

Permalink
fix: set solc toolchain for EVM by default
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgar2017 committed Aug 30, 2024
1 parent 1e424af commit 3a755b6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
9 changes: 5 additions & 4 deletions compiler_tester/src/compiler_tester/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ pub struct Arguments {
pub zkvyper: Option<PathBuf>,

/// 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<compiler_tester::Toolchain>,

/// Specify the target architecture.
/// Available arguments: `eravm`, `evm`.
Expand Down
31 changes: 18 additions & 13 deletions compiler_tester/src/compiler_tester/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(),
Expand All @@ -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,
Expand All @@ -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 {
Expand Down Expand Up @@ -192,13 +198,12 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> {

compiler_tester
.run_evm_interpreter::<compiler_tester::EraVMSystemContractDeployer, true>(
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)
}
}?;

Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions compiler_tester/src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ impl std::str::FromStr for Toolchain {

fn from_str(string: &str) -> Result<Self, Self::Err> {
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,
Expand All @@ -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"),
}
}
}

0 comments on commit 3a755b6

Please sign in to comment.