From 149ef4f59d66171d20f6e237f0dd9dd3b0693f94 Mon Sep 17 00:00:00 2001 From: Nisheeth Barthwal Date: Wed, 6 Nov 2024 13:36:19 +0100 Subject: [PATCH] feat: integrate compiler suppressed warnings/errors feature for upstream merge 57bb12e (#704) * integrate compilers suppressed warnings/errors functionality --- Cargo.lock | 12 +++++------ crates/cli/src/opts/build/zksync.rs | 31 ++++++++++++++++++++++++++++- crates/config/src/zksync.rs | 9 +++------ 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0b8fdec7..b95f61895 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5116,7 +5116,7 @@ dependencies = [ [[package]] name = "foundry-compilers" version = "0.11.6" -source = "git+https://github.com/Moonsong-Labs/compilers?branch=zksync-v0.11.6#7bb66e6871a47c323873a0d0d93487756f87e762" +source = "git+https://github.com/Moonsong-Labs/compilers?branch=zksync-v0.11.6#7c69695e5c75451f158dd2456bf8c94a7492ea0b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -5156,7 +5156,7 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" version = "0.11.6" -source = "git+https://github.com/Moonsong-Labs/compilers?branch=zksync-v0.11.6#7bb66e6871a47c323873a0d0d93487756f87e762" +source = "git+https://github.com/Moonsong-Labs/compilers?branch=zksync-v0.11.6#7c69695e5c75451f158dd2456bf8c94a7492ea0b" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -5166,7 +5166,7 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" version = "0.11.6" -source = "git+https://github.com/Moonsong-Labs/compilers?branch=zksync-v0.11.6#7bb66e6871a47c323873a0d0d93487756f87e762" +source = "git+https://github.com/Moonsong-Labs/compilers?branch=zksync-v0.11.6#7c69695e5c75451f158dd2456bf8c94a7492ea0b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -5189,7 +5189,7 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" version = "0.11.6" -source = "git+https://github.com/Moonsong-Labs/compilers?branch=zksync-v0.11.6#7bb66e6871a47c323873a0d0d93487756f87e762" +source = "git+https://github.com/Moonsong-Labs/compilers?branch=zksync-v0.11.6#7c69695e5c75451f158dd2456bf8c94a7492ea0b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -5203,7 +5203,7 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-zksolc" version = "0.11.6" -source = "git+https://github.com/Moonsong-Labs/compilers?branch=zksync-v0.11.6#7bb66e6871a47c323873a0d0d93487756f87e762" +source = "git+https://github.com/Moonsong-Labs/compilers?branch=zksync-v0.11.6#7c69695e5c75451f158dd2456bf8c94a7492ea0b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -5224,7 +5224,7 @@ dependencies = [ [[package]] name = "foundry-compilers-core" version = "0.11.6" -source = "git+https://github.com/Moonsong-Labs/compilers?branch=zksync-v0.11.6#7bb66e6871a47c323873a0d0d93487756f87e762" +source = "git+https://github.com/Moonsong-Labs/compilers?branch=zksync-v0.11.6#7c69695e5c75451f158dd2456bf8c94a7492ea0b" dependencies = [ "alloy-primitives", "cfg-if 1.0.0", diff --git a/crates/cli/src/opts/build/zksync.rs b/crates/cli/src/opts/build/zksync.rs index acb4891a9..6ea6da550 100644 --- a/crates/cli/src/opts/build/zksync.rs +++ b/crates/cli/src/opts/build/zksync.rs @@ -1,6 +1,7 @@ -use std::path::PathBuf; +use std::{collections::HashSet, path::PathBuf}; use clap::Parser; +use foundry_compilers::zksolc::settings::{ZkSolcError, ZkSolcWarning}; use foundry_config::ZkSyncConfig; use serde::Serialize; use zksync_web3_rs::types::{Address, Bytes}; @@ -121,6 +122,26 @@ pub struct ZkSyncArgs { visible_alias = "paymaster-input" )] pub paymaster_input: Option, + + /// Set the warnings to suppress for zksolc. + #[clap( + long = "zk-suppressed-warnings", + visible_alias = "suppressed-warnings", + value_delimiter = ',', + help = "Set the warnings to suppress for zksolc, possible values: [txorigin]" + )] + #[serde(skip_serializing_if = "Option::is_none")] + pub suppressed_warnings: Option>, + + /// Set the errors to suppress for zksolc. + #[clap( + long = "zk-suppressed-errors", + visible_alias = "suppressed-errors", + value_delimiter = ',', + help = "Set the errors to suppress for zksolc, possible values: [sendtransfer]" + )] + #[serde(skip_serializing_if = "Option::is_none")] + pub suppressed_errors: Option>, } impl ZkSyncArgs { @@ -157,6 +178,14 @@ impl ZkSyncArgs { self.optimizer_mode.as_ref().and_then(|mode| mode.parse::().ok()), zksync.optimizer_mode ); + let suppressed_warnings = self + .suppressed_warnings + .clone() + .map(|values| values.into_iter().collect::>()); + set_if_some!(suppressed_warnings, zksync.suppressed_warnings); + let suppressed_errors = + self.suppressed_errors.clone().map(|values| values.into_iter().collect::>()); + set_if_some!(suppressed_errors, zksync.suppressed_errors); zksync } diff --git a/crates/config/src/zksync.rs b/crates/config/src/zksync.rs index 951367b48..95370e5a9 100644 --- a/crates/config/src/zksync.rs +++ b/crates/config/src/zksync.rs @@ -13,9 +13,8 @@ use foundry_compilers::{ }, }; -use revm_primitives::HashSet; use serde::{Deserialize, Serialize}; -use std::path::PathBuf; +use std::{collections::HashSet, path::PathBuf}; use crate::SolcReq; @@ -140,10 +139,8 @@ impl ZkSyncConfig { }, }, codegen: if self.force_evmla { Codegen::EVMLA } else { Codegen::Yul }, - suppressed_warnings: Default::default(), /* TODO(zk): take from self when `FromStr` - * impl is provided */ - suppressed_errors: Default::default(), /* TODO(zk): take from self when `FromStr` - * impl is provided */ + suppressed_warnings: self.suppressed_warnings.clone(), + suppressed_errors: self.suppressed_errors.clone(), }; // `cli_settings` get set from `Project` values when building `ZkSolcVersionedInput`