Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support suppressed warnings/errors for zksolc #691

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

15 changes: 14 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};

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 @@ -102,6 +103,14 @@
#[clap(long = "zk-optimizer")]
pub optimizer: bool,

/// zksolc suppressed warnings

Check failure on line 106 in crates/cli/src/opts/build/zksync.rs

View workflow job for this annotation

GitHub Actions / zk-cargo-test

the method `value_parser` exists for reference `&&&&&&_infer_ValueParser_for<ZkSolcWarning>`, but its trait bounds were not satisfied

Check failure on line 106 in crates/cli/src/opts/build/zksync.rs

View workflow job for this annotation

GitHub Actions / zk-cargo-test

the method `value_parser` exists for reference `&&&&&&_infer_ValueParser_for<ZkSolcWarning>`, but its trait bounds were not satisfied
#[clap(long = "zk-suppressed-warnings")]
pub suppressed_warnings: Option<Vec<ZkSolcWarning>>,

/// zksolc suppressed errors

Check failure on line 110 in crates/cli/src/opts/build/zksync.rs

View workflow job for this annotation

GitHub Actions / zk-cargo-test

the method `value_parser` exists for reference `&&&&&&_infer_ValueParser_for<ZkSolcError>`, but its trait bounds were not satisfied

Check failure on line 110 in crates/cli/src/opts/build/zksync.rs

View workflow job for this annotation

GitHub Actions / zk-cargo-test

the method `value_parser` exists for reference `&&&&&&_infer_ValueParser_for<ZkSolcError>`, but its trait bounds were not satisfied
#[clap(long = "zk-suppressed-errors")]
pub suppressed_errors: Option<Vec<ZkSolcError>>,

/// Contracts to avoid compiling on zkSync
#[clap(long = "zk-avoid-contracts", visible_alias = "avoid-contracts", value_delimiter = ',')]
pub avoid_contracts: Option<Vec<String>>,
Expand Down Expand Up @@ -153,6 +162,10 @@
set_if_some!(self.avoid_contracts.clone(), zksync.avoid_contracts);

set_if_some!(self.optimizer.then_some(true), zksync.optimizer);
let maybe_suppressed_warnings = self.suppressed_warnings.clone().map(HashSet::from_iter);
set_if_some!(maybe_suppressed_warnings, zksync.suppressed_warnings);
let maybe_suppressed_errors = self.suppressed_errors.clone().map(HashSet::from_iter);
set_if_some!(maybe_suppressed_errors, zksync.suppressed_errors);
set_if_some!(
self.optimizer_mode.as_ref().and_then(|mode| mode.parse::<char>().ok()),
zksync.optimizer_mode
Expand Down
17 changes: 14 additions & 3 deletions crates/config/src/zksync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ use foundry_compilers::{
solc::CliSettings,
zksolc::{
settings::{
BytecodeHash, Codegen, Optimizer, OptimizerDetails, SettingsMetadata, ZkSolcSettings,
BytecodeHash, Codegen, Optimizer, OptimizerDetails, SettingsMetadata, ZkSolcError,
ZkSolcSettings, ZkSolcWarning,
},
ZkSettings,
},
};

use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use std::{collections::HashSet, path::PathBuf};

use crate::SolcReq;

Expand Down Expand Up @@ -59,8 +60,14 @@ pub struct ZkSyncConfig {
/// The optimization mode string for zkSync
pub optimizer_mode: char,

/// zkSolc optimizer details
/// zksolc optimizer details
pub optimizer_details: Option<OptimizerDetails>,

/// zksolc suppressed errors
pub suppressed_warnings: HashSet<ZkSolcWarning>,

/// zksolc suppressed warnings
pub suppressed_errors: HashSet<ZkSolcError>,
}

impl Default for ZkSyncConfig {
Expand All @@ -80,6 +87,8 @@ impl Default for ZkSyncConfig {
optimizer: true,
optimizer_mode: '3',
optimizer_details: Default::default(),
suppressed_warnings: Default::default(),
suppressed_errors: Default::default(),
}
}
}
Expand Down Expand Up @@ -130,6 +139,8 @@ impl ZkSyncConfig {
},
},
codegen: if self.force_evmla { Codegen::EVMLA } else { Codegen::Yul },
suppressed_warnings: self.suppressed_warnings.clone(),
suppressed_errors: self.suppressed_errors.clone(),
};

// `cli_settings` get set from `Project` values when building `ZkSolcVersionedInput`
Expand Down
Loading