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

fix: removes avoid-contracts in favour of --skip #702

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion Cargo.lock

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

5 changes: 0 additions & 5 deletions crates/cli/src/opts/build/zksync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,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<Vec<String>>,

/// Paymaster address
#[clap(
long = "zk-paymaster-address",
Expand Down Expand Up @@ -171,7 +167,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!(
Expand Down
7 changes: 1 addition & 6 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -69,9 +67,6 @@ anstream.workspace = true
anstyle.workspace = true
terminal_size.workspace = true

# zksync
globset = "0.4"

[dev-dependencies]
similar-asserts.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
8 changes: 1 addition & 7 deletions crates/common/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ impl ProjectCompiler {
pub fn zksync_compile(
self,
project: &Project<ZkSolcCompiler, ZkArtifactOutput>,
maybe_avoid_contracts: Option<Vec<globset::GlobMatcher>>,
) -> Result<ZkProjectCompileOutput> {
// TODO: Avoid process::exit
if !project.paths.has_input_files() && self.files.is_empty() {
Expand All @@ -311,12 +310,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,
)?
Expand Down
2 changes: 0 additions & 2 deletions crates/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 0 additions & 13 deletions crates/config/src/zksync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ pub struct ZkSyncConfig {
/// Currently unused
pub detect_missing_libraries: bool,

/// Source files to avoid compiling on zksolc
pub avoid_contracts: Option<Vec<String>>,

/// Enable optimizer for zkSync
pub optimizer: bool,

Expand Down Expand Up @@ -83,7 +80,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(),
Expand Down Expand Up @@ -146,13 +142,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<Vec<globset::GlobMatcher>> {
self.avoid_contracts.clone().map(|patterns| {
patterns
.into_iter()
.map(|pat| globset::Glob::new(&pat).expect("invalid pattern").compile_matcher())
.collect::<Vec<_>>()
})
}
}
3 changes: 1 addition & 2 deletions crates/forge/bin/cmd/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ impl BuildArgs {
.quiet(format_json)
.bail(!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 format_json {
println!("{}", serde_json::to_string_pretty(&zk_output.output())?);
}
Expand Down
3 changes: 1 addition & 2 deletions crates/forge/bin/cmd/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ impl CreateArgs {
let zk_project =
foundry_zksync_compiler::config_create_project(&config, config.cache, false)?;
let zk_compiler = ProjectCompiler::new().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)?;

Expand Down
3 changes: 1 addition & 2 deletions crates/forge/bin/cmd/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,7 @@ impl TestArgs {
let sources_to_compile = self.get_sources_to_compile(&config, &filter)?;
let zk_compiler = ProjectCompiler::new().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);

Expand Down
2 changes: 1 addition & 1 deletion crates/forge/tests/cli/ext_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
2 changes: 1 addition & 1 deletion crates/forge/tests/it/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,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();
Expand Down
5 changes: 1 addition & 4 deletions crates/script/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,7 @@ impl PreprocessedState {

let zk_compiler = ProjectCompiler::new().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(),
Expand Down
2 changes: 1 addition & 1 deletion crates/verify/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())),
);
Expand Down
4 changes: 2 additions & 2 deletions crates/verify/src/zk_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Loading