diff --git a/Cargo.lock b/Cargo.lock index 3d47fd2c..8a0f6fb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,7 +63,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -197,12 +197,13 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" +checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" dependencies = [ "jobserver", "libc", + "once_cell", ] [[package]] @@ -482,7 +483,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -540,7 +541,7 @@ dependencies = [ [[package]] name = "era-compiler-solidity" version = "1.5.0" -source = "git+https://github.com/matter-labs/era-compiler-solidity?branch=v1.5.0#f708d9eaac702a5d5d0a8ac7532b754add9b4e15" +source = "git+https://github.com/matter-labs/era-compiler-solidity?branch=v1.5.0#e90f9210c10601265b9e81e43046aa78d45b3531" dependencies = [ "anyhow", "colored", @@ -569,7 +570,7 @@ dependencies = [ [[package]] name = "era-compiler-vyper" version = "1.5.0" -source = "git+https://github.com/matter-labs/era-compiler-vyper?branch=v1.5.0#74706990b4c0caa4c5e63e2ac824082ba56e08fe" +source = "git+https://github.com/matter-labs/era-compiler-vyper?branch=v1.5.0#1998d739136eb2a2c8a4ba606f45fe44c27987bb" dependencies = [ "anyhow", "colored", @@ -775,7 +776,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -1118,7 +1119,7 @@ source = "git+https://github.com/matter-labs-forks/inkwell?branch=llvm-17#c0821d dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -1144,9 +1145,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685a7d121ee3f65ae4fddd72b25a04bb36b6af81bc0828f7d5434c0fe60fa3a2" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" dependencies = [ "libc", ] @@ -1232,9 +1233,9 @@ dependencies = [ [[package]] name = "libmimalloc-sys" -version = "0.1.35" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3979b5c37ece694f1f5e51e7ecc871fdb0f517ed04ee45f88d15d6d553cb9664" +checksum = "81eb4061c0582dedea1cbc7aff2240300dd6982e0239d1c99e65c1dbf4a30ba7" dependencies = [ "cc", "libc", @@ -1289,9 +1290,9 @@ checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "mimalloc" -version = "0.1.39" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa01922b5ea280a911e323e4d2fd24b7fe5cc4042e0d2cda3c40775cdc4bdc9c" +checksum = "9f41a2280ded0da56c8cf898babb86e8f10651a34adcfff190ae9a1159c6908d" dependencies = [ "libmimalloc-sys", ] @@ -1431,7 +1432,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -1548,7 +1549,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -1930,9 +1931,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.32" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.5.0", "errno", @@ -1943,9 +1944,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.10" +version = "0.21.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" dependencies = [ "log", "ring", @@ -2077,7 +2078,7 @@ checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -2287,9 +2288,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.59" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -2349,22 +2350,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -2483,7 +2484,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -2590,7 +2591,7 @@ checksum = "2266fcb904c50fb17fda4c9a751a1715629ecf8b21f4c9d78b4890fb71525d71" [[package]] name = "vm2" version = "0.1.0" -source = "git+https://github.com/matter-labs/vm2#02e4b3113c560d2a2d2b23ec29b663f120ac6bab" +source = "git+https://github.com/matter-labs/vm2#f38b8f536168a24c5fb38b0d56f309b228cf3c58" dependencies = [ "enum_dispatch", "primitive-types", @@ -2634,7 +2635,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -2668,7 +2669,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2757,11 +2758,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "134306a13c5647ad6453e8deaec55d3a44d6021970129e6188735e74bf546697" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] [[package]] diff --git a/compiler_tester/src/compiler_tester/arguments.rs b/compiler_tester/src/compiler_tester/arguments.rs index 0282e878..42779a12 100644 --- a/compiler_tester/src/compiler_tester/arguments.rs +++ b/compiler_tester/src/compiler_tester/arguments.rs @@ -6,6 +6,8 @@ use std::path::PathBuf; use structopt::StructOpt; +use compiler_tester::Workflow; + /// /// The compiler tester arguments. /// @@ -107,6 +109,10 @@ pub struct Arguments { /// Sets the `debug logging` option in LLVM. #[structopt(long = "llvm-debug-logging")] pub llvm_debug_logging: bool, + + /// Choose between `build` to compile tests only without running them, and `run` to compile and run them. + #[structopt(long = "workflow", default_value = "run")] + pub workflow: Workflow, } impl Arguments { diff --git a/compiler_tester/src/compiler_tester/main.rs b/compiler_tester/src/compiler_tester/main.rs index 7a9bd68b..ed0efc90 100644 --- a/compiler_tester/src/compiler_tester/main.rs +++ b/compiler_tester/src/compiler_tester/main.rs @@ -95,8 +95,12 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> { let filters = compiler_tester::Filters::new(arguments.paths, arguments.modes, arguments.groups); - let compiler_tester = - compiler_tester::CompilerTester::new(summary.clone(), filters, debug_config.clone())?; + let compiler_tester = compiler_tester::CompilerTester::new( + summary.clone(), + filters, + debug_config.clone(), + arguments.workflow, + )?; let binary_download_config_paths = vec![ arguments.solc_bin_config_path.unwrap_or_else(|| { @@ -208,7 +212,7 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> { ); if let Some(path) = arguments.benchmark { - let benchmark = summary.benchmark(); + let benchmark = summary.benchmark()?; benchmark.write_to_file(path)?; } @@ -258,6 +262,7 @@ mod tests { system_contracts_save_path: None, llvm_verify_each: false, llvm_debug_logging: false, + workflow: compiler_tester::Workflow::BuildAndRun, }; crate::main_inner(arguments).expect("Manual testing failed"); diff --git a/compiler_tester/src/lib.rs b/compiler_tester/src/lib.rs index 1c4a99c2..16d9049e 100644 --- a/compiler_tester/src/lib.rs +++ b/compiler_tester/src/lib.rs @@ -14,6 +14,7 @@ pub(crate) mod target; pub(crate) mod test; pub(crate) mod utils; pub(crate) mod vm; +pub(crate) mod workflow; use std::path::Path; use std::sync::Arc; @@ -46,6 +47,7 @@ pub use crate::vm::eravm::deployers::system_contract_deployer::SystemContractDep pub use crate::vm::eravm::deployers::EraVMDeployer; pub use crate::vm::eravm::EraVM; pub use crate::vm::evm::EVM; +pub use crate::workflow::Workflow; /// The debug directory path. pub const DEBUG_DIRECTORY: &str = "./debug/"; @@ -68,6 +70,8 @@ pub struct CompilerTester { pub filters: Filters, /// The debug config. pub debug_config: Option, + /// Actions to perform. + pub workflow: Workflow, } impl CompilerTester { @@ -103,11 +107,13 @@ impl CompilerTester { summary: Arc>, filters: Filters, debug_config: Option, + workflow: Workflow, ) -> anyhow::Result { Ok(Self { summary, filters, debug_config, + workflow, }) } @@ -124,15 +130,22 @@ impl CompilerTester { let _: Vec<()> = tests .into_par_iter() .map(|(test, compiler, mode)| { + let mode_string = mode.to_string(); + let specialized_debug_config = self + .debug_config + .as_ref() + .and_then(|config| config.create_subdirectory(mode_string.as_str()).ok()); if let Some(test) = test.build_for_eravm( mode, compiler, Target::EraVM, self.summary.clone(), &self.filters, - self.debug_config.clone(), + specialized_debug_config, ) { - test.run_eravm::(self.summary.clone(), vm.clone()); + if let Workflow::BuildAndRun = self.workflow { + test.run_eravm::(self.summary.clone(), vm.clone()) + }; } }) .collect(); @@ -149,15 +162,22 @@ impl CompilerTester { let _: Vec<()> = tests .into_par_iter() .map(|(test, compiler, mode)| { + let mode_string = mode.to_string(); + let specialized_debug_config = self + .debug_config + .as_ref() + .and_then(|config| config.create_subdirectory(mode_string.as_str()).ok()); if let Some(test) = test.build_for_evm( mode, compiler, Target::EVM, self.summary.clone(), &self.filters, - self.debug_config.clone(), + specialized_debug_config, ) { - test.run_evm(self.summary.clone()); + if let Workflow::BuildAndRun = self.workflow { + test.run_evm(self.summary.clone()) + }; } }) .collect(); @@ -190,7 +210,9 @@ impl CompilerTester { &self.filters, self.debug_config.clone(), ) { - test.run_evm_interpreter::(self.summary.clone(), vm.clone()); + if let Workflow::BuildAndRun = self.workflow { + test.run_evm_interpreter::(self.summary.clone(), vm.clone()); + } } }) .collect(); diff --git a/compiler_tester/src/summary/mod.rs b/compiler_tester/src/summary/mod.rs index 4a8d4b89..0809621d 100644 --- a/compiler_tester/src/summary/mod.rs +++ b/compiler_tester/src/summary/mod.rs @@ -75,7 +75,7 @@ impl Summary { /// /// Returns the benchmark structure. /// - pub fn benchmark(&self) -> benchmark_analyzer::Benchmark { + pub fn benchmark(&self) -> anyhow::Result { let mut benchmark = benchmark_analyzer::Benchmark::default(); benchmark.groups.insert( format!( @@ -139,16 +139,17 @@ impl Summary { .insert(key.clone(), benchmark_element.clone()); } + let group_key = format!("{} {}", benchmark_analyzer::BENCHMARK_ALL_GROUP_NAME, mode); benchmark .groups .get_mut( - format!("{} {}", benchmark_analyzer::BENCHMARK_ALL_GROUP_NAME, mode).as_str(), + group_key.as_str(), ) - .expect("Always exists") + .ok_or_else(|| anyhow::anyhow!("Group `{group_key}` not found. Only M3 and Mz groups are allowed in benchmarking"))? .elements .insert(key, benchmark_element); } - benchmark + Ok(benchmark) } /// diff --git a/compiler_tester/src/workflow.rs b/compiler_tester/src/workflow.rs new file mode 100644 index 00000000..862a2c3b --- /dev/null +++ b/compiler_tester/src/workflow.rs @@ -0,0 +1,28 @@ +//! +//! The compiler tester workflows. +//! + +use std::str::FromStr; + +/// +/// Describes sets of actions that compiler tester is able to perform. +/// +#[derive(Debug)] +pub enum Workflow { + /// Only build tests but not execute them. + BuildOnly, + /// Build and execute tests. + BuildAndRun, +} + +impl FromStr for Workflow { + type Err = &'static str; + + fn from_str(day: &str) -> Result { + match day { + "build" => Ok(Workflow::BuildOnly), + "run" => Ok(Workflow::BuildAndRun), + _ => Err("Could not parse workflow. Supported workflows: build, run."), + } + } +} diff --git a/fuzzer/fuzz_targets/common.rs b/fuzzer/fuzz_targets/common.rs index e0a4a313..4c628065 100644 --- a/fuzzer/fuzz_targets/common.rs +++ b/fuzzer/fuzz_targets/common.rs @@ -1,4 +1,11 @@ -use compiler_tester::{Buildable, EthereumTest, Mode, SolidityCompiler, SolidityMode, Summary}; +use std::{ + path::{Path, PathBuf}, + sync::Arc, +}; + +use compiler_tester::{ + Buildable, EthereumTest, Mode, SolidityCompiler, SolidityMode, Summary, Workflow, +}; use era_compiler_solidity::SolcPipeline; pub use solidity_adapter::{ @@ -20,8 +27,6 @@ pub use solidity_adapter::{ EnabledTest, FunctionCall, }; -use std::{path::PathBuf, sync::Arc}; - /// /// Fuzzing case definition /// @@ -173,6 +178,7 @@ pub fn build_and_run(test: EthereumTest) -> anyhow::Result { compiler_tester::Summary::new(true, false).wrap(), compiler_tester::Filters::new(vec![], vec![], vec![]), None, + Workflow::BuildAndRun, )?; zkevm_tester::runners::compiler_tests::set_tracing_mode( zkevm_tester::runners::compiler_tests::VmTracingOptions::from_u64(0), diff --git a/rust-toolchain.toml b/rust-toolchain.toml index f2a6c9a9..7a231182 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] profile = "default" -channel = "1.77.2" \ No newline at end of file +channel = "1.77.2" diff --git a/solidity b/solidity index 37d45336..ebdce269 160000 --- a/solidity +++ b/solidity @@ -1 +1 @@ -Subproject commit 37d45336f795e1aa5b1d842a98bb29eb63a3c778 +Subproject commit ebdce269005e8f2a6652bad64a000725ff1624fe