Skip to content

Commit

Permalink
integrate compilers suppressed warnings/errors functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaztec committed Nov 6, 2024
1 parent 55fa294 commit 73f8462
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 13 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 42 additions & 1 deletion crates/cli/src/opts/build/zksync.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -121,6 +122,24 @@ pub struct ZkSyncArgs {
visible_alias = "paymaster-input"
)]
pub paymaster_input: Option<Bytes>,

/// 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<Vec<String>>,

/// 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<Vec<String>>,
}

impl ZkSyncArgs {
Expand Down Expand Up @@ -157,6 +176,28 @@ impl ZkSyncArgs {
self.optimizer_mode.as_ref().and_then(|mode| mode.parse::<char>().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::<HashSet<ZkSolcWarning>>()
});
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::<HashSet<ZkSolcError>>()
});
set_if_some!(suppressed_errors, zksync.suppressed_errors);

zksync
}
Expand Down
9 changes: 3 additions & 6 deletions crates/config/src/zksync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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`
Expand Down

0 comments on commit 73f8462

Please sign in to comment.