From 73f84623138da49faf5df9ab595f94e5018b12e1 Mon Sep 17 00:00:00 2001 From: Nisheeth Barthwal Date: Wed, 6 Nov 2024 12:55:15 +0100 Subject: [PATCH 1/2] integrate compilers suppressed warnings/errors functionality --- Cargo.lock | 12 ++++---- crates/cli/src/opts/build/zksync.rs | 43 ++++++++++++++++++++++++++++- crates/config/src/zksync.rs | 9 ++---- 3 files changed, 51 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..e25426a49 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, str::FromStr}; 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,24 @@ 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 = ',' + )] + #[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 = ',' + )] + #[serde(skip_serializing_if = "Option::is_none")] + pub suppressed_errors: Option>, } impl ZkSyncArgs { @@ -157,6 +176,28 @@ 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() + .map(|value| { + ZkSolcWarning::from_str(&value).unwrap_or_else(|s| { + panic!("failed parsing suppressed warning '{value}': {s}") + }) + }) + .collect::>() + }); + set_if_some!(suppressed_warnings, zksync.suppressed_warnings); + let suppressed_errors = self.suppressed_errors.clone().map(|values| { + values + .into_iter() + .map(|value| { + ZkSolcError::from_str(&value).unwrap_or_else(|s| { + panic!("failed parsing suppressed error '{value}': {s}") + }) + }) + .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` From 87f150c5447b1ea9a0f5dbaf2b1d5558c1f86e17 Mon Sep 17 00:00:00 2001 From: Nisheeth Barthwal Date: Wed, 6 Nov 2024 13:24:47 +0100 Subject: [PATCH 2/2] update help --- crates/cli/src/opts/build/zksync.rs | 38 ++++++++++------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/crates/cli/src/opts/build/zksync.rs b/crates/cli/src/opts/build/zksync.rs index e25426a49..6ea6da550 100644 --- a/crates/cli/src/opts/build/zksync.rs +++ b/crates/cli/src/opts/build/zksync.rs @@ -1,4 +1,4 @@ -use std::{collections::HashSet, path::PathBuf, str::FromStr}; +use std::{collections::HashSet, path::PathBuf}; use clap::Parser; use foundry_compilers::zksolc::settings::{ZkSolcError, ZkSolcWarning}; @@ -127,19 +127,21 @@ pub struct ZkSyncArgs { #[clap( long = "zk-suppressed-warnings", visible_alias = "suppressed-warnings", - value_delimiter = ',' + value_delimiter = ',', + help = "Set the warnings to suppress for zksolc, possible values: [txorigin]" )] #[serde(skip_serializing_if = "Option::is_none")] - pub suppressed_warnings: Option>, + pub suppressed_warnings: Option>, /// Set the errors to suppress for zksolc. #[clap( long = "zk-suppressed-errors", visible_alias = "suppressed-errors", - value_delimiter = ',' + value_delimiter = ',', + help = "Set the errors to suppress for zksolc, possible values: [sendtransfer]" )] #[serde(skip_serializing_if = "Option::is_none")] - pub suppressed_errors: Option>, + pub suppressed_errors: Option>, } impl ZkSyncArgs { @@ -176,27 +178,13 @@ 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() - .map(|value| { - ZkSolcWarning::from_str(&value).unwrap_or_else(|s| { - panic!("failed parsing suppressed warning '{value}': {s}") - }) - }) - .collect::>() - }); + 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() - .map(|value| { - ZkSolcError::from_str(&value).unwrap_or_else(|s| { - panic!("failed parsing suppressed error '{value}': {s}") - }) - }) - .collect::>() - }); + let suppressed_errors = + self.suppressed_errors.clone().map(|values| values.into_iter().collect::>()); set_if_some!(suppressed_errors, zksync.suppressed_errors); zksync