From 89c3a068502c6a119879b4fe11b627ac69ac74bc Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Tue, 5 Nov 2024 14:32:28 -0600 Subject: [PATCH 1/3] fix: removes avoid-contracts in favour of --skip --- crates/cli/src/opts/build/zksync.rs | 5 ----- crates/common/src/compile.rs | 8 +------- crates/config/README.md | 2 -- crates/config/src/zksync.rs | 13 ------------- crates/forge/bin/cmd/build.rs | 3 +-- crates/forge/bin/cmd/create.rs | 3 +-- crates/forge/bin/cmd/test/mod.rs | 3 +-- crates/forge/tests/cli/ext_integration.rs | 2 +- crates/script/src/build.rs | 5 +---- crates/verify/src/verify.rs | 2 +- crates/verify/src/zk_provider.rs | 4 ++-- 11 files changed, 9 insertions(+), 41 deletions(-) diff --git a/crates/cli/src/opts/build/zksync.rs b/crates/cli/src/opts/build/zksync.rs index acb4891a9..19426d07b 100644 --- a/crates/cli/src/opts/build/zksync.rs +++ b/crates/cli/src/opts/build/zksync.rs @@ -102,10 +102,6 @@ pub struct ZkSyncArgs { #[clap(long = "zk-optimizer")] pub optimizer: bool, - /// Contracts to avoid compiling on zkSync - #[clap(long = "zk-avoid-contracts", visible_alias = "avoid-contracts", value_delimiter = ',')] - pub avoid_contracts: Option>, - /// Paymaster address #[clap( long = "zk-paymaster-address", @@ -150,7 +146,6 @@ impl ZkSyncArgs { self.detect_missing_libraries.then_some(true), zksync.detect_missing_libraries ); - set_if_some!(self.avoid_contracts.clone(), zksync.avoid_contracts); set_if_some!(self.optimizer.then_some(true), zksync.optimizer); set_if_some!( diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 1495c445a..035c5081f 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -278,7 +278,6 @@ impl ProjectCompiler { pub fn zksync_compile( self, project: &Project, - maybe_avoid_contracts: Option>, ) -> Result { // TODO: Avoid process::exit if !project.paths.has_input_files() && self.files.is_empty() { @@ -301,12 +300,7 @@ impl ProjectCompiler { self.zksync_compile_with(&project.paths.root, || { let files_to_compile = if !files.is_empty() { files } else { project.paths.input_files() }; - let avoid_contracts = maybe_avoid_contracts.unwrap_or_default(); - let sources = Source::read_all( - files_to_compile - .into_iter() - .filter(|p| !avoid_contracts.iter().any(|c| c.is_match(p))), - )?; + let sources = Source::read_all(files_to_compile)?; foundry_compilers::zksync::compile::project::ProjectCompiler::with_sources( project, sources, )? diff --git a/crates/config/README.md b/crates/config/README.md index 4e04da2a5..182c49ac2 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -240,8 +240,6 @@ fallback_oz = false enable_eravm_extensions = false # Force compilation via EVMLA instead of Yul codegen pipeline force_evmla = false -# List of globs that match contracts to avoid compiling with zksolc -avoid_contracts = [] # Enable optimizer on zksolc (defaults to true) optimizer = true # zksolc optimizer mode (0 | 1 | 2 | 3 | s | z) diff --git a/crates/config/src/zksync.rs b/crates/config/src/zksync.rs index 8d86eaa41..8eea24c6b 100644 --- a/crates/config/src/zksync.rs +++ b/crates/config/src/zksync.rs @@ -50,9 +50,6 @@ pub struct ZkSyncConfig { /// Currently unused pub detect_missing_libraries: bool, - /// Source files to avoid compiling on zksolc - pub avoid_contracts: Option>, - /// Enable optimizer for zkSync pub optimizer: bool, @@ -76,7 +73,6 @@ impl Default for ZkSyncConfig { force_evmla: Default::default(), detect_missing_libraries: Default::default(), llvm_options: Default::default(), - avoid_contracts: Default::default(), optimizer: true, optimizer_mode: '3', optimizer_details: Default::default(), @@ -135,13 +131,4 @@ impl ZkSyncConfig { // `cli_settings` get set from `Project` values when building `ZkSolcVersionedInput` ZkSolcSettings { settings: zk_settings, cli_settings: CliSettings::default() } } - - pub fn avoid_contracts(&self) -> Option> { - self.avoid_contracts.clone().map(|patterns| { - patterns - .into_iter() - .map(|pat| globset::Glob::new(&pat).expect("invalid pattern").compile_matcher()) - .collect::>() - }) - } } diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index e4658a457..b0b91b525 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -120,8 +120,7 @@ impl BuildArgs { .quiet(self.format_json) .bail(!self.format_json); - let zk_output = - zk_compiler.zksync_compile(&zk_project, config.zksync.avoid_contracts())?; + let zk_output = zk_compiler.zksync_compile(&zk_project)?; if self.format_json { println!("{}", serde_json::to_string_pretty(&zk_output.output())?); } diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 9f0212ae7..a55e1c769 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -155,8 +155,7 @@ impl CreateArgs { let zk_compiler = ProjectCompiler::new() .quiet(self.json || self.opts.silent) .files([target_path.clone()]); - let mut zk_output = - zk_compiler.zksync_compile(&zk_project, config.zksync.avoid_contracts())?; + let mut zk_output = zk_compiler.zksync_compile(&zk_project)?; let artifact = remove_zk_contract(&mut zk_output, &target_path, &self.contract.name)?; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index db66a5fdb..530be44db 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -315,8 +315,7 @@ impl TestArgs { .quiet_if(self.json || self.opts.silent) .files(sources_to_compile); - let zk_output = - zk_compiler.zksync_compile(&zk_project, config.zksync.avoid_contracts())?; + let zk_output = zk_compiler.zksync_compile(&zk_project)?; let dual_compiled_contracts = DualCompiledContracts::new(&output, &zk_output, &project.paths, &zk_project.paths); diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index c04b21125..9a4c85f14 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -149,6 +149,6 @@ fn convex_shutdown_simulation() { #[test] fn test_zk_aave_di() { ExtTester::new("Moonsong-Labs", "aave-delivery-infrastructure", "ci") - .args(["--zksync", "--avoid-contracts", "\"*/PayloadScripts.t.sol\""]) + .args(["--zksync", "--skip", "\"*/PayloadScripts.t.sol\""]) .run() } diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 67d95cfab..7025034c8 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -247,10 +247,7 @@ impl PreprocessedState { let zk_compiler = ProjectCompiler::new().quiet_if(args.opts.silent).files(sources_to_compile); - zk_output = Some( - zk_compiler - .zksync_compile(&zk_project, script_config.config.zksync.avoid_contracts())?, - ); + zk_output = Some(zk_compiler.zksync_compile(&zk_project)?); Some(DualCompiledContracts::new( &output, &zk_output.clone().unwrap(), diff --git a/crates/verify/src/verify.rs b/crates/verify/src/verify.rs index 3bd159b12..e3724a7f2 100644 --- a/crates/verify/src/verify.rs +++ b/crates/verify/src/verify.rs @@ -368,7 +368,7 @@ impl VerifyArgs { let provider = utils::get_provider(&config)?; let code = provider.get_code_at(self.address).await?; - let output = ProjectCompiler::new().zksync_compile(&project, None)?; + let output = ProjectCompiler::new().zksync_compile(&project)?; let contracts = ContractsByArtifact::new( output.artifact_ids().map(|(id, artifact)| (id, artifact.clone().into())), ); diff --git a/crates/verify/src/zk_provider.rs b/crates/verify/src/zk_provider.rs index 5fc1bb3f0..d439daa2d 100644 --- a/crates/verify/src/zk_provider.rs +++ b/crates/verify/src/zk_provider.rs @@ -81,7 +81,7 @@ impl ZkVerificationContext { let output = ProjectCompiler::new() .quiet(true) .files([self.target_path.clone()]) - .zksync_compile(&project, None)?; + .zksync_compile(&project)?; let artifact = output .find(&self.target_path, &self.target_name) @@ -100,7 +100,7 @@ impl ZkVerificationContext { let output = ProjectCompiler::new() .quiet(true) .files([self.target_path.clone()]) - .zksync_compile(&project, None)?; + .zksync_compile(&project)?; let artifact = output .find(&self.target_path, &self.target_name) From 0fac8e82ef97adf781e5f2639303ca47dbca9dd6 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Tue, 5 Nov 2024 14:40:21 -0600 Subject: [PATCH 2/3] chore: run clippy --- Cargo.lock | 1 - crates/common/Cargo.toml | 7 +------ crates/forge/tests/it/test_helpers.rs | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8563f8af6..72234e93e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5063,7 +5063,6 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-zksync-compiler", - "globset", "num-format", "reqwest 0.12.8", "semver 1.0.23", diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 5bb6a2024..b2d809e16 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -13,9 +13,7 @@ repository.workspace = true workspace = true [dependencies] -foundry-block-explorers = { workspace = true, features = [ - "foundry-compilers", -] } +foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } foundry-zksync-compiler.workspace = true foundry-common-fmt.workspace = true foundry-compilers.workspace = true @@ -65,9 +63,6 @@ url.workspace = true walkdir.workspace = true yansi.workspace = true -# zksync -globset = "0.4" - [dev-dependencies] similar-asserts.workspace = true tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index ebce7b3f1..e5fdd132a 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -483,7 +483,7 @@ pub fn get_zk_compiled(zk_project: &ZkProject) -> ZkProjectCompileOutput { write = Some(lock.write().unwrap()); } - out = zk_compiler.zksync_compile(zk_project, None); + out = zk_compiler.zksync_compile(zk_project); if let Some(ref mut write) = write { write.write_all(b"1").unwrap(); From 86d414d266b228fda7a9e9ffb7a22401d90cf0f8 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 6 Nov 2024 07:45:09 -0600 Subject: [PATCH 3/3] chore: resolve conflicts --- crates/forge/bin/cmd/build.rs | 2 +- crates/forge/bin/cmd/create.rs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 410608f8d..0b10d1416 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -131,7 +131,7 @@ impl BuildArgs { .bail(!format_json); let zk_output = zk_compiler.zksync_compile(&zk_project)?; - if self.format_json { + if format_json { println!("{}", serde_json::to_string_pretty(&zk_output.output())?); } diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 15ae790a4..9a6cc9e6b 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -150,9 +150,7 @@ impl CreateArgs { let config = self.opts.try_load_config_emit_warnings()?; let zk_project = foundry_zksync_compiler::config_create_project(&config, config.cache, false)?; - let zk_compiler = ProjectCompiler::new() - .quiet(self.json || self.opts.silent) - .files([target_path.clone()]); + let zk_compiler = ProjectCompiler::new().files([target_path.clone()]); let mut zk_output = zk_compiler.zksync_compile(&zk_project)?; let artifact = remove_zk_contract(&mut zk_output, &target_path, &self.contract.name)?;