From dbb26e9f5a657ca526d7f4aae9c2c0b05fbc44f2 Mon Sep 17 00:00:00 2001 From: Nisheeth Barthwal Date: Thu, 27 Jun 2024 13:41:43 +0200 Subject: [PATCH] merge dev --- crates/cli/src/opts/build/core.rs | 7 +++++-- crates/config/src/lib.rs | 9 +-------- crates/config/src/zksync.rs | 11 ++++++----- crates/forge/bin/cmd/build.rs | 2 +- crates/forge/bin/cmd/coverage.rs | 8 -------- crates/forge/bin/cmd/create.rs | 4 ---- crates/forge/bin/cmd/test/mod.rs | 20 +++++++++----------- crates/script/src/lib.rs | 4 ++-- crates/script/src/simulate.rs | 2 +- 9 files changed, 25 insertions(+), 42 deletions(-) diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index 1497ff837..41aecb841 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -177,9 +177,12 @@ impl<'a> From<&'a CoreBuildArgs> for Figment { .extend(figment.extract_inner::>("remappings").unwrap_or_default()); // override only set values from the CLI for zksync let zksync = - args.compiler.zk.apply_overrides(figment.extract_inner("zksync").unwrap_or_default()); + args.compiler.zk.apply_overrides(figment.extract_inner("zksync").unwrap_or_default()); - figment = figment.merge(("remappings", remappings.into_inner())).merge(args).merge(("zksync", zksync)); + figment = figment + .merge(("remappings", remappings.into_inner())) + .merge(args) + .merge(("zksync", zksync)); if let Some(skip) = &args.skip { let mut skip = skip.iter().map(|s| s.file_pattern().to_string()).collect::>(); diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index d22e7d01e..39a1b182a 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -29,14 +29,7 @@ use foundry_compilers::{ multi::{MultiCompiler, MultiCompilerSettings}, solc::{Solc, SolcCompiler}, vyper::{Vyper, VyperSettings}, - zksolc::{ - settings::{ - BytecodeHash as ZkSolcBytecodeHash, Optimizer as ZkSolcOptimizer, - OptimizerDetails as ZkSolcOptimizerDetails, - SettingsMetadata as ZkSolcSettingsMetadata, - }, - ZkSolc, - }, + zksolc::ZkSolc, Compiler, }, error::SolcError, diff --git a/crates/config/src/zksync.rs b/crates/config/src/zksync.rs index b8265418e..af49928c0 100644 --- a/crates/config/src/zksync.rs +++ b/crates/config/src/zksync.rs @@ -1,7 +1,8 @@ use foundry_compilers::{ - artifacts::Libraries, - zksync::artifacts::{BytecodeHash, Optimizer, OptimizerDetails, Settings, SettingsMetadata}, - EvmVersion, + artifacts::{EvmVersion, Libraries}, + zksolc::settings::{ + BytecodeHash, Optimizer, OptimizerDetails, SettingsMetadata, ZkSolcSettings, + }, }; use serde::{Deserialize, Serialize}; @@ -91,7 +92,7 @@ impl ZkSyncConfig { libraries: Libraries, evm_version: EvmVersion, via_ir: bool, - ) -> Settings { + ) -> ZkSolcSettings { let optimizer = Optimizer { enabled: Some(self.optimizer), mode: Some(self.optimizer_mode), @@ -101,7 +102,7 @@ impl ZkSyncConfig { jump_table_density_threshold: None, }; - Settings { + ZkSolcSettings { libraries, optimizer, evm_version: Some(evm_version), diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 2b5efaf79..198e602df 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -98,7 +98,7 @@ impl BuildArgs { } } - let mut compiler = ProjectCompiler::new() + let compiler = ProjectCompiler::new() .print_names(self.names) .print_sizes(self.sizes) .quiet(self.format_json) diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 85a37478d..c8606054f 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -238,14 +238,6 @@ impl CoverageArgs { .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) - // XTODO - // .with_cheats_config(CheatsConfig::new( - // &config, - // evm_opts.clone(), - // None, - // Default::default(), - // false, - // )) .with_test_options(TestOptions { fuzz: config.fuzz.clone(), invariant: config.invariant.clone(), diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 97b36574a..62740cce9 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -84,10 +84,6 @@ pub struct CreateArgs { impl CreateArgs { /// Executes the command to create a contract pub async fn run(mut self) -> Result<()> { - let mut config = self.eth.try_load_config_emit_warnings()?; - let project_root = config.project_paths().root; - let zksync = self.opts.compiler.zk.enabled(); - // Find Project & Compile let project = self.opts.project()?; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 03eaebc4f..0b59d884a 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -274,8 +274,7 @@ impl TestArgs { let output = compiler.compile(&project)?; - let zk_compiler = ProjectCompiler::new().quiet_if(self.json || self.opts.silent); - let zk_output = zk_compiler.zksync_compile(&project)?; + let zk_output = foundry_zksync_compiler::compile_project(&project)?; let dual_compiled_contracts = DualCompiledContracts::new(&output, &zk_output, &project.paths); @@ -312,16 +311,16 @@ impl TestArgs { .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) - .with_cheats_config(CheatsConfig::new( - &config, - evm_opts.clone(), - None, - dual_compiled_contracts, - config.zksync, - )) .with_test_options(test_options.clone()) .enable_isolation(evm_opts.isolate) - .build(project_root, output, env, evm_opts, dual_compiled_contracts, config.zksync)?; + .build( + project_root, + output, + env, + evm_opts, + dual_compiled_contracts, + config.zksync.run_in_zk_mode(), + )?; if let Some(debug_test_pattern) = &self.debug { let test_pattern = &mut filter.args_mut().test_pattern; @@ -333,7 +332,6 @@ impl TestArgs { } *test_pattern = Some(debug_test_pattern.clone()); } - runner.use_zk = config.zksync; let libraries = runner.libraries.clone(); let outcome = self.run_tests(runner, config, verbosity, &filter).await?; diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index ab5377802..e19b2a66a 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -605,7 +605,7 @@ impl ScriptConfig { Some(script_wallets), Some(target.version), dual_compiled_contracts, - self.config.zksync, + self.config.zksync.run_in_zk_mode(), ) .into(), ) @@ -614,7 +614,7 @@ impl ScriptConfig { } let mut executor = builder.build(env, db); - executor.use_zk = self.config.zksync; + executor.use_zk = self.config.zksync.run_in_zk_mode(); Ok(ScriptRunner::new(executor, self.evm_opts.clone())) } } diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index f9b1ad1fc..163f8095e 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -108,7 +108,7 @@ impl PreSimulationState { to, tx.input.clone().into_input(), tx.value, - (self.script_config.config.zksync, zk.clone()), + (self.script_config.config.zksync.run_in_zk_mode(), zk.clone()), ) .wrap_err("Internal EVM error during simulation")?;