diff --git a/.gitignore b/.gitignore index b79c463a..12dcfdf4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,28 @@ +# IDE +/.idea/ +/.vscode/ + +# MacOS +/**/.DS_Store + +# Backup files generated by rustfmt +/**/*.rs.bk + # Compiled files and executables /target*/ -# These are backup files generated by rustfmt -**/*.rs.bk +# Dependency locks +# /Cargo.lock +# /LLVM.lock -# The LLVM framework source +# LLVM framework source /llvm/ # External compilers -/solc-bin*/* -/vyper-bin/* +/solc-bin*/ +/vyper-bin*/ -# The debug, trace, benchmark artifacts +# Debug and benchmark artifacts /debug/ -/trace/ -/**/*.json -/**/*.txt - -# The dependency locks -# /Cargo.lock -# /LLVM.lock - -# IDE -/.idea/ -/.vscode/ - -# MacOS -/**/.DS_Store +/*.json +/*.txt \ No newline at end of file diff --git a/compiler_tester/src/compiler_tester/arguments.rs b/compiler_tester/src/compiler_tester/arguments.rs index 93c77ebd..13359500 100644 --- a/compiler_tester/src/compiler_tester/arguments.rs +++ b/compiler_tester/src/compiler_tester/arguments.rs @@ -59,12 +59,12 @@ pub struct Arguments { #[structopt(long = "disable-value-simulator")] pub disable_value_simulator: bool, - /// Path to the `zksolc` binary. + /// Path to the `zksolc` executable. /// Is set to `zksolc` by default. #[structopt(long = "zksolc")] pub zksolc: Option, - /// Path to the `zkvyper` binary. + /// Path to the `zkvyper` executable. /// Is set to `zkvyper` by default. #[structopt(long = "zkvyper")] pub zkvyper: Option, @@ -78,8 +78,7 @@ pub struct Arguments { /// Specify the target architecture. /// Available arguments: `eravm`, `evm`. - /// The default is `eravm`. - #[structopt(long = "target", default_value = "eravm")] + #[structopt(long = "target")] pub target: era_compiler_common::Target, /// Specify the environment to run tests on. @@ -93,11 +92,11 @@ pub struct Arguments { #[structopt(long = "workflow", default_value = "run")] pub workflow: compiler_tester::Workflow, - /// Path to the default `solc` binaries download configuration file. + /// Path to the default `solc` executables download configuration file. #[structopt(long = "solc-bin-config-path")] pub solc_bin_config_path: Option, - /// Path to the default `vyper` binaries download configuration file. + /// Path to the default `vyper` executables download configuration file. #[structopt(long = "vyper-bin-config-path")] pub vyper_bin_config_path: Option, diff --git a/compiler_tester/src/compiler_tester/main.rs b/compiler_tester/src/compiler_tester/main.rs index 3a540880..7770a510 100644 --- a/compiler_tester/src/compiler_tester/main.rs +++ b/compiler_tester/src/compiler_tester/main.rs @@ -1,5 +1,5 @@ //! -//! The compiler tester binary. +//! The compiler tester executable. //! pub(crate) mod arguments; @@ -106,12 +106,12 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> { (era_compiler_common::Target::EVM, Some(toolchain)) => toolchain, (era_compiler_common::Target::EVM, None) => compiler_tester::Toolchain::Solc, }; - let binary_download_config_paths = vec![ + let executable_download_config_paths = vec![ arguments.solc_bin_config_path.unwrap_or_else(|| { 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!(), + compiler_tester::Toolchain::SolcLLVM => "./configs/solc-bin-llvm.json", }) }), arguments @@ -156,7 +156,7 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> { None }; let vm = compiler_tester::EraVM::new( - binary_download_config_paths, + executable_download_config_paths, PathBuf::from("./configs/solc-bin-system-contracts.json"), system_contracts_debug_config, arguments.system_contracts_load_path, @@ -168,16 +168,16 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> { arguments.disable_deployer, arguments.disable_value_simulator, ) { - (true, true) => { - compiler_tester.run_eravm::(vm) - } - (true, false) => { - compiler_tester.run_eravm::(vm) - } + (true, true) => compiler_tester + .run_eravm::(vm, toolchain), + (true, false) => compiler_tester + .run_eravm::(vm, toolchain), (false, true) => compiler_tester - .run_eravm::(vm), + .run_eravm::( + vm, toolchain, + ), (false, false) => compiler_tester - .run_eravm::(vm), + .run_eravm::(vm, toolchain), } } compiler_tester::Environment::FastVM => todo!(), @@ -188,7 +188,7 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> { None }; let vm = compiler_tester::EraVM::new( - binary_download_config_paths, + executable_download_config_paths, PathBuf::from("./configs/solc-bin-system-contracts.json"), system_contract_debug_config, arguments.system_contracts_load_path, @@ -202,7 +202,7 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> { ) } compiler_tester::Environment::REVM => { - compiler_tester::EVM::download(binary_download_config_paths)?; + compiler_tester::EVM::download(executable_download_config_paths)?; compiler_tester.run_revm(toolchain) } }?; diff --git a/compiler_tester/src/compilers/solidity/mod.rs b/compiler_tester/src/compilers/solidity/mod.rs index 3fe13f15..f2fd25a8 100644 --- a/compiler_tester/src/compilers/solidity/mod.rs +++ b/compiler_tester/src/compilers/solidity/mod.rs @@ -81,7 +81,7 @@ impl Default for SolidityCompiler { } impl SolidityCompiler { - /// The compiler binaries directory. + /// The compiler executables directory. const DIRECTORY: &'static str = "solc-bin/"; /// The solc allow paths argument value. @@ -136,7 +136,7 @@ impl SolidityCompiler { })?; if !entry_type.is_file() { anyhow::bail!( - "Invalid `solc` binary file type: {}", + "Invalid `solc` executable file type: {}", path.to_string_lossy() ); } diff --git a/compiler_tester/src/compilers/solidity/upstream/mod.rs b/compiler_tester/src/compilers/solidity/upstream/mod.rs index b86c9c7d..b19832c1 100644 --- a/compiler_tester/src/compilers/solidity/upstream/mod.rs +++ b/compiler_tester/src/compilers/solidity/upstream/mod.rs @@ -14,6 +14,7 @@ use crate::compilers::mode::Mode; use crate::compilers::solidity::cache_key::CacheKey; use crate::compilers::yul::mode_upstream::Mode as YulUpstreamMode; use crate::compilers::Compiler; +use crate::toolchain::Toolchain; use crate::vm::eravm::input::Input as EraVMInput; use crate::vm::evm::input::build::Build as EVMBuild; use crate::vm::evm::input::Input as EVMInput; @@ -33,6 +34,9 @@ use self::solc::Compiler as SolcUpstreamCompiler; pub struct SolidityCompiler { /// The language the compiler will compile. language: SolcStandardJsonInputLanguage, + /// The toolchain identifier. + /// Only `solc` and `solc-llvm` are supported. + toolchain: Toolchain, /// The `solc` process output cache. cache: Cache, } @@ -54,7 +58,7 @@ lazy_static::lazy_static! { (era_compiler_solidity::SolcPipeline::Yul, true, true), ] { for version in SolidityCompiler::all_versions(pipeline, via_ir).expect("`solc` versions analysis error") { - modes.push(SolidityUpstreamMode::new(version, pipeline, via_ir, optimize).into()); + modes.push(SolidityUpstreamMode::new(version, pipeline, via_ir, false, optimize).into()); } } modes @@ -71,16 +75,37 @@ lazy_static::lazy_static! { false, true ] { for version in SolidityCompiler::all_versions(era_compiler_solidity::SolcPipeline::Yul, true).expect("`solc` versions analysis error") { - modes.push(YulUpstreamMode::new(version, optimize).into()); + modes.push(YulUpstreamMode::new(version, false, optimize).into()); } } modes }; + + /// + /// The supported Solidity modes for MLIR codegen. + /// + /// All compilers must be downloaded before initialization. + /// + static ref SOLIDITY_MLIR_MODES: Vec = { + vec![SolidityUpstreamMode::new(semver::Version::new(0, 8, 26), era_compiler_solidity::SolcPipeline::Yul, false, true, false).into()] + }; + + /// + /// The supported Yul modes for MLIR codegen. + /// + /// All compilers must be downloaded before initialization. + /// + static ref YUL_MLIR_MODES: Vec = { + vec![YulUpstreamMode::new(semver::Version::new(0, 8, 26), true, false).into()] + }; } impl SolidityCompiler { - /// The compiler binaries directory. - const DIRECTORY: &'static str = "solc-bin-upstream/"; + /// The upstream compiler executables directory. + const DIRECTORY_UPSTREAM: &'static str = "solc-bin-upstream/"; + + /// The LLVM-fork compiler executables directory. + const DIRECTORY_LLVM: &'static str = "solc-bin-llvm/"; /// The solc allow paths argument value. const SOLC_ALLOW_PATHS: &'static str = "tests"; @@ -88,9 +113,10 @@ impl SolidityCompiler { /// /// A shortcut constructor. /// - pub fn new(language: SolcStandardJsonInputLanguage) -> Self { + pub fn new(language: SolcStandardJsonInputLanguage, toolchain: Toolchain) -> Self { Self { language, + toolchain, cache: Cache::new(), } } @@ -98,8 +124,16 @@ impl SolidityCompiler { /// /// Returns the `solc` executable by its version. /// - pub fn executable(version: &semver::Version) -> anyhow::Result { - SolcUpstreamCompiler::new(format!("{}/solc-{}", Self::DIRECTORY, version)) + pub fn executable( + toolchain: Toolchain, + version: &semver::Version, + ) -> anyhow::Result { + let directory = match toolchain { + Toolchain::Solc => Self::DIRECTORY_UPSTREAM, + Toolchain::SolcLLVM => Self::DIRECTORY_LLVM, + toolchain => panic!("Unsupported toolchain: {toolchain}"), + }; + SolcUpstreamCompiler::new(format!("{}/solc-{}", directory, version)) } /// @@ -110,7 +144,7 @@ impl SolidityCompiler { via_ir: bool, ) -> anyhow::Result> { let mut versions = Vec::new(); - for entry in std::fs::read_dir(Self::DIRECTORY)? { + for entry in std::fs::read_dir(Self::DIRECTORY_UPSTREAM)? { let entry = entry?; let path = entry.path(); let entry_type = entry.file_type().map_err(|error| { @@ -122,7 +156,7 @@ impl SolidityCompiler { })?; if !entry_type.is_file() { anyhow::bail!( - "Invalid `solc` binary file type: {}", + "Invalid `solc` executable file type: {}", path.to_string_lossy() ); } @@ -158,6 +192,7 @@ impl SolidityCompiler { /// pub fn standard_json_output( language: SolcStandardJsonInputLanguage, + toolchain: Toolchain, sources: &[(String, String)], libraries: &BTreeMap>, mode: &Mode, @@ -168,7 +203,7 @@ impl SolidityCompiler { Mode::YulUpstream(mode) => &mode.solc_version, mode => anyhow::bail!("Unsupported mode: {mode}"), }; - let mut solc = Self::executable(solc_version)?; + let mut solc = Self::executable(toolchain, solc_version)?; let output_selection = SolcStandardJsonInputSettingsSelection::new_required(match mode { Mode::SolidityUpstream(mode) => mode.solc_pipeline, @@ -199,6 +234,12 @@ impl SolidityCompiler { mode => anyhow::bail!("Unsupported mode: {mode}"), }; + let via_mlir = match mode { + Mode::SolidityUpstream(mode) => mode.via_mlir, + Mode::YulUpstream(mode) => mode.via_mlir, + mode => anyhow::bail!("Unsupported mode: {mode}"), + }; + let debug = if solc_version >= &semver::Version::new(0, 6, 3) { test_params.map(|test_params| { SolcStandardJsonInputSettingsDebug::new(Some( @@ -217,6 +258,7 @@ impl SolidityCompiler { None, output_selection, via_ir, + via_mlir, optimizer, debug, ) @@ -263,7 +305,14 @@ impl SolidityCompiler { if !self.cache.contains(&cache_key) { self.cache.evaluate(cache_key.clone(), || { - Self::standard_json_output(language, sources, libraries, mode, test_params) + Self::standard_json_output( + language, + self.toolchain, + sources, + libraries, + mode, + test_params, + ) }); } @@ -374,14 +423,90 @@ impl SolidityCompiler { impl Compiler for SolidityCompiler { fn compile_for_eravm( &self, - _test_path: String, - _sources: Vec<(String, String)>, - _libraries: BTreeMap>, - _mode: &Mode, + test_path: String, + sources: Vec<(String, String)>, + libraries: BTreeMap>, + mode: &Mode, _llvm_options: Vec, _debug_config: Option, ) -> anyhow::Result { - anyhow::bail!("The upstream Solidity compiler cannot compile for EraVM"); + let solc_output = self.standard_json_output_cached( + test_path, + self.language, + &sources, + &libraries, + mode, + None, + )?; + + if let Some(errors) = solc_output.errors.as_deref() { + let mut has_errors = false; + let mut error_messages = Vec::with_capacity(errors.len()); + + for error in errors.iter() { + if error.severity.as_str() == "error" { + has_errors = true; + error_messages.push(error.formatted_message.to_owned()); + } + } + + if has_errors { + anyhow::bail!("`solc` errors found: {:?}", error_messages); + } + } + + let method_identifiers = match self.language { + SolcStandardJsonInputLanguage::Solidity => { + Some(Self::get_method_identifiers(&solc_output)?) + } + SolcStandardJsonInputLanguage::Yul => None, + }; + + let last_contract = Self::get_last_contract(self.language, &solc_output, &sources)?; + + let contracts = solc_output + .contracts + .ok_or_else(|| anyhow::anyhow!("Solidity contracts not found in the output"))?; + + let mut builds = HashMap::with_capacity(contracts.len()); + for (file, contracts) in contracts.into_iter() { + for (name, contract) in contracts.into_iter() { + let path = format!("{file}:{name}"); + let bytecode_string = contract + .evm + .as_ref() + .ok_or_else(|| { + anyhow::anyhow!("EraVM object of the contract `{path}` not found") + })? + .bytecode + .as_ref() + .ok_or_else(|| { + anyhow::anyhow!("EraVM bytecode of the contract `{path}` not found") + })? + .object + .as_str(); + let bytecode = hex::decode(bytecode_string).map_err(|error| { + anyhow::anyhow!("EraVM bytecode of the contract `{path}` is invalid: {error}") + })?; + let bytecode_words: Vec<[u8; era_compiler_common::BYTE_LENGTH_FIELD]> = bytecode + .as_slice() + .chunks(era_compiler_common::BYTE_LENGTH_FIELD) + .map(|word| word.try_into().expect("Always valid")) + .collect(); + let bytecode_hash = zkevm_opcode_defs::utils::bytecode_to_code_hash_for_mode::< + { era_compiler_common::BYTE_LENGTH_X64 }, + zkevm_opcode_defs::decoding::EncodingModeProduction, + >(bytecode_words.as_slice()) + .map_err(|_| { + anyhow::anyhow!("EraVM bytecode of the contract `{path}` hashing error") + })?; + let build = + era_compiler_llvm_context::EraVMBuild::new(bytecode, bytecode_hash, None, None); + builds.insert(path, build); + } + } + + Ok(EraVMInput::new(builds, method_identifiers, last_contract)) } fn compile_for_evm( @@ -468,9 +593,13 @@ impl Compiler for SolidityCompiler { } fn all_modes(&self) -> Vec { - match self.language { - SolcStandardJsonInputLanguage::Solidity => SOLIDITY_MODES.clone(), - SolcStandardJsonInputLanguage::Yul => YUL_MODES.clone(), + match (self.language, self.toolchain) { + (SolcStandardJsonInputLanguage::Solidity, Toolchain::SolcLLVM) => { + SOLIDITY_MLIR_MODES.clone() + } + (SolcStandardJsonInputLanguage::Solidity, _) => SOLIDITY_MODES.clone(), + (SolcStandardJsonInputLanguage::Yul, Toolchain::SolcLLVM) => YUL_MLIR_MODES.clone(), + (SolcStandardJsonInputLanguage::Yul, _) => YUL_MODES.clone(), } } diff --git a/compiler_tester/src/compilers/solidity/upstream/mode.rs b/compiler_tester/src/compilers/solidity/upstream/mode.rs index 16734c00..6c9157d6 100644 --- a/compiler_tester/src/compilers/solidity/upstream/mode.rs +++ b/compiler_tester/src/compilers/solidity/upstream/mode.rs @@ -17,6 +17,8 @@ pub struct Mode { pub solc_pipeline: era_compiler_solidity::SolcPipeline, /// Whether to enable the EVMLA codegen via Yul IR. pub via_ir: bool, + /// Whether to enable the MLIR codegen. + pub via_mlir: bool, /// Whether to run the Solidity compiler optimizer. pub solc_optimize: bool, } @@ -29,12 +31,14 @@ impl Mode { solc_version: semver::Version, solc_pipeline: era_compiler_solidity::SolcPipeline, via_ir: bool, + via_mlir: bool, solc_optimize: bool, ) -> Self { Self { solc_version, solc_pipeline, via_ir, + via_mlir, solc_optimize, } } @@ -111,6 +115,10 @@ impl Mode { impl std::fmt::Display for Mode { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if self.via_mlir { + return write!(f, "L {}", self.solc_version); + } + write!( f, "{}{} {}", diff --git a/compiler_tester/src/compilers/solidity/upstream/solc/mod.rs b/compiler_tester/src/compilers/solidity/upstream/solc/mod.rs index 7f4f0e23..1b4ab09f 100644 --- a/compiler_tester/src/compilers/solidity/upstream/solc/mod.rs +++ b/compiler_tester/src/compilers/solidity/upstream/solc/mod.rs @@ -13,7 +13,7 @@ use self::standard_json::output::Output as StandardJsonOutput; /// The Solidity compiler. /// pub struct Compiler { - /// The binary executable name. + /// The executable name. pub executable: String, } diff --git a/compiler_tester/src/compilers/solidity/upstream/solc/standard_json/input/mod.rs b/compiler_tester/src/compilers/solidity/upstream/solc/standard_json/input/mod.rs index 7a9c3533..993d26f7 100644 --- a/compiler_tester/src/compilers/solidity/upstream/solc/standard_json/input/mod.rs +++ b/compiler_tester/src/compilers/solidity/upstream/solc/standard_json/input/mod.rs @@ -49,6 +49,7 @@ impl Input { remappings: Option>, output_selection: SolcStandardJsonInputSettingsSelection, via_ir: bool, + via_mlir: bool, optimizer: SolcStandardJsonInputSettingsOptimizer, debug: Option, ) -> anyhow::Result { @@ -66,6 +67,7 @@ impl Input { remappings, output_selection, via_ir, + via_mlir, optimizer, debug, ), diff --git a/compiler_tester/src/compilers/solidity/upstream/solc/standard_json/input/settings/mod.rs b/compiler_tester/src/compilers/solidity/upstream/solc/standard_json/input/settings/mod.rs index e97c4c6b..16581b11 100644 --- a/compiler_tester/src/compilers/solidity/upstream/solc/standard_json/input/settings/mod.rs +++ b/compiler_tester/src/compilers/solidity/upstream/solc/standard_json/input/settings/mod.rs @@ -40,6 +40,13 @@ pub struct Settings { skip_deserializing )] pub via_ir: Option, + /// Whether to compile via MLIR. + #[serde( + rename = "viaMLIR", + skip_serializing_if = "Option::is_none", + skip_deserializing + )] + pub via_mlir: Option, /// The optimizer settings. pub optimizer: Optimizer, /// The debug settings. @@ -57,6 +64,7 @@ impl Settings { remappings: Option>, output_selection: Selection, via_ir: bool, + via_mlir: bool, optimizer: Optimizer, debug: Option, ) -> Self { @@ -66,6 +74,7 @@ impl Settings { remappings, output_selection: Some(output_selection), via_ir: if via_ir { Some(true) } else { None }, + via_mlir: if via_mlir { Some(true) } else { None }, optimizer, debug, } diff --git a/compiler_tester/src/compilers/vyper/mod.rs b/compiler_tester/src/compilers/vyper/mod.rs index 678d1565..bae7e2b6 100644 --- a/compiler_tester/src/compilers/vyper/mod.rs +++ b/compiler_tester/src/compilers/vyper/mod.rs @@ -55,7 +55,7 @@ impl Default for VyperCompiler { } impl VyperCompiler { - /// The compiler binaries directory. + /// The compiler executables directory. pub const DIRECTORY: &'static str = "vyper-bin/"; /// @@ -88,7 +88,7 @@ impl VyperCompiler { .file_type() .map_err(|error| anyhow::anyhow!("File {path:?} type getting error: {error}"))?; if !entry_type.is_file() { - anyhow::bail!("Invalid `vyper` binary file type: {path:?}"); + anyhow::bail!("Invalid `vyper` executable file type: {path:?}"); } let file_name = entry.file_name().to_string_lossy().to_string(); diff --git a/compiler_tester/src/compilers/yul/mod.rs b/compiler_tester/src/compilers/yul/mod.rs index 015553bb..2c635fee 100644 --- a/compiler_tester/src/compilers/yul/mod.rs +++ b/compiler_tester/src/compilers/yul/mod.rs @@ -26,7 +26,6 @@ use self::mode::Mode as YulMode; /// pub struct YulCompiler { /// The compiler toolchain to use. - #[allow(dead_code)] toolchain: Toolchain, } @@ -134,7 +133,7 @@ impl Compiler for YulCompiler { ) -> anyhow::Result { let language = SolcStandardJsonInputLanguage::Yul; - let solc_compiler = SolidityUpstreamCompiler::new(language); + let solc_compiler = SolidityUpstreamCompiler::new(language, self.toolchain); let solc_output = solc_compiler.standard_json_output_cached( test_path, diff --git a/compiler_tester/src/compilers/yul/mode_upstream.rs b/compiler_tester/src/compilers/yul/mode_upstream.rs index 46b58c01..0dcc3ae6 100644 --- a/compiler_tester/src/compilers/yul/mode_upstream.rs +++ b/compiler_tester/src/compilers/yul/mode_upstream.rs @@ -11,6 +11,8 @@ use crate::compilers::mode::Mode as ModeWrapper; pub struct Mode { /// The Solidity compiler version. pub solc_version: semver::Version, + /// Whether to enable the MLIR codegen. + pub via_mlir: bool, /// Whether to run the Solidity compiler optimizer. pub solc_optimize: bool, } @@ -19,9 +21,10 @@ impl Mode { /// /// A shortcut constructor. /// - pub fn new(solc_version: semver::Version, solc_optimize: bool) -> Self { + pub fn new(solc_version: semver::Version, via_mlir: bool, solc_optimize: bool) -> Self { Self { solc_version, + via_mlir, solc_optimize, } } @@ -43,6 +46,10 @@ impl Mode { impl std::fmt::Display for Mode { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if self.via_mlir { + return write!(f, "L {}", self.solc_version); + } + write!( f, "Y{} {}", diff --git a/compiler_tester/src/lib.rs b/compiler_tester/src/lib.rs index 4793eacc..ff5c2a57 100644 --- a/compiler_tester/src/lib.rs +++ b/compiler_tester/src/lib.rs @@ -123,11 +123,11 @@ impl CompilerTester { /// /// Runs all tests on EraVM. /// - pub fn run_eravm(self, vm: EraVM) -> anyhow::Result<()> + pub fn run_eravm(self, vm: EraVM, toolchain: Toolchain) -> anyhow::Result<()> where D: EraVMDeployer, { - let tests = self.all_tests(era_compiler_common::Target::EraVM, Toolchain::IrLLVM)?; + let tests = self.all_tests(era_compiler_common::Target::EraVM, toolchain)?; let vm = Arc::new(vm); let _: Vec<()> = tests @@ -266,12 +266,14 @@ impl CompilerTester { let solidity_compiler = Arc::new(SolidityCompiler::new()); let solidity_upstream_compiler = Arc::new(SolidityUpstreamCompiler::new( SolcStandardJsonInputLanguage::Solidity, + toolchain, )); let solidity_upstream_yul_compiler = Arc::new(SolidityUpstreamCompiler::new( SolcStandardJsonInputLanguage::Yul, + toolchain, )); - let vyper_compiler = Arc::new(VyperCompiler::new()); let yul_compiler = Arc::new(YulCompiler::new(toolchain)); + let vyper_compiler = Arc::new(VyperCompiler::new()); let llvm_compiler = Arc::new(LLVMCompiler); let eravm_compiler = Arc::new(EraVMCompiler); @@ -283,8 +285,7 @@ impl CompilerTester { era_compiler_common::EXTENSION_SOLIDITY, match toolchain { Toolchain::IrLLVM => solidity_compiler.clone(), - Toolchain::Solc => solidity_upstream_compiler.clone(), - Toolchain::SolcLLVM => todo!(), + Toolchain::Solc | Toolchain::SolcLLVM => solidity_upstream_compiler.clone(), }, )?); if let era_compiler_common::Target::EraVM = target { @@ -301,8 +302,7 @@ impl CompilerTester { era_compiler_common::EXTENSION_YUL, match toolchain { Toolchain::IrLLVM => yul_compiler.clone(), - Toolchain::Solc => solidity_upstream_yul_compiler.clone(), - Toolchain::SolcLLVM => todo!(), + Toolchain::Solc | Toolchain::SolcLLVM => solidity_upstream_yul_compiler.clone(), }, )?); tests.extend(self.directory::( @@ -324,8 +324,7 @@ impl CompilerTester { era_compiler_common::EXTENSION_JSON, match toolchain { Toolchain::IrLLVM => solidity_compiler.clone(), - Toolchain::Solc => solidity_upstream_compiler.clone(), - Toolchain::SolcLLVM => todo!(), + Toolchain::Solc | Toolchain::SolcLLVM => solidity_upstream_compiler.clone(), }, )?); if let era_compiler_common::Target::EraVM = target { @@ -346,8 +345,7 @@ impl CompilerTester { era_compiler_common::EXTENSION_SOLIDITY, match toolchain { Toolchain::IrLLVM => solidity_compiler.clone(), - Toolchain::Solc => solidity_upstream_compiler.clone(), - Toolchain::SolcLLVM => todo!(), + Toolchain::Solc | Toolchain::SolcLLVM => solidity_upstream_compiler.clone(), }, )?); if let era_compiler_common::Target::EraVM = target { diff --git a/compiler_tester/src/vm/eravm/mod.rs b/compiler_tester/src/vm/eravm/mod.rs index c7eabc06..a9b6c1f9 100644 --- a/compiler_tester/src/vm/eravm/mod.rs +++ b/compiler_tester/src/vm/eravm/mod.rs @@ -74,7 +74,7 @@ impl EraVM { /// Creates and initializes a new EraVM instance. /// pub fn new( - binary_download_config_paths: Vec, + executable_download_config_paths: Vec, system_contracts_solc_downloader_config_path: PathBuf, system_contracts_debug_config: Option, system_contracts_load_path: Option, @@ -88,16 +88,19 @@ impl EraVM { let http_client = http_client_builder.build()?; let download_time_start = Instant::now(); - println!(" {} compiler binaries", "Downloading".bright_green().bold()); + println!( + " {} compiler executables", + "Downloading".bright_green().bold() + ); let system_contracts_solc_downloader_config = era_compiler_downloader::Downloader::new(http_client.clone()) .download(system_contracts_solc_downloader_config_path.as_path())?; - for config_path in binary_download_config_paths.into_iter() { + for config_path in executable_download_config_paths.into_iter() { era_compiler_downloader::Downloader::new(http_client.clone()) .download(config_path.as_path())?; } println!( - " {} downloading compiler binaries in {}m{:02}s", + " {} downloading compiler executables in {}m{:02}s", "Finished".bright_green().bold(), download_time_start.elapsed().as_secs() / 60, download_time_start.elapsed().as_secs() % 60, diff --git a/compiler_tester/src/vm/evm/mod.rs b/compiler_tester/src/vm/evm/mod.rs index 248cd9b7..4f3d8085 100644 --- a/compiler_tester/src/vm/evm/mod.rs +++ b/compiler_tester/src/vm/evm/mod.rs @@ -49,9 +49,9 @@ impl<'evm> EVM<'evm> { } /// - /// Downloads the necessary compiler binaries. + /// Downloads the necessary compiler executables. /// - pub fn download(binary_download_config_paths: Vec) -> anyhow::Result<()> { + pub fn download(executable_download_config_paths: Vec) -> anyhow::Result<()> { let mut http_client_builder = reqwest::blocking::ClientBuilder::new(); http_client_builder = http_client_builder.connect_timeout(Duration::from_secs(60)); http_client_builder = http_client_builder.pool_idle_timeout(Duration::from_secs(60)); @@ -59,13 +59,16 @@ impl<'evm> EVM<'evm> { let http_client = http_client_builder.build()?; let download_time_start = Instant::now(); - println!(" {} compiler binaries", "Downloading".bright_green().bold()); - for config_path in binary_download_config_paths.into_iter() { + println!( + " {} compiler executables", + "Downloading".bright_green().bold() + ); + for config_path in executable_download_config_paths.into_iter() { era_compiler_downloader::Downloader::new(http_client.clone()) .download(config_path.as_path())?; } println!( - " {} downloading compiler binaries in {}m{:02}s", + " {} downloading compiler executables in {}m{:02}s", "Finished".bright_green().bold(), download_time_start.elapsed().as_secs() / 60, download_time_start.elapsed().as_secs() % 60, diff --git a/configs/solc-bin-llvm.json b/configs/solc-bin-llvm.json new file mode 100644 index 00000000..04646898 --- /dev/null +++ b/configs/solc-bin-llvm.json @@ -0,0 +1,16 @@ +{ + "binaries": { + "0.8.26": { + "is_enabled": true, + "protocol": "https", + "source": "https://github.com/matter-labs/era-solidity/releases/download/mlir-${VERSION}-tag/solc-${PLATFORM}-${VERSION}-mlir", + "destination": "./solc-bin-llvm/solc-${VERSION}" + } + }, + "platforms": { + "linux-amd64": "linux-amd64", + "linux-arm64": "linux-arm64", + "macos-amd64": "macosx-amd64", + "macos-arm64": "macosx-arm64" + } +}