Skip to content

Commit

Permalink
Merge branch 'main' into upstream-59f354c-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
elfedy committed Dec 12, 2024
2 parents ff8f1a2 + 082aff2 commit 4721908
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
run: cargo hack check

zk-cargo-test:
runs-on: ubuntu-22.04
runs-on: ubuntu-22.04-github-hosted-16core
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
17 changes: 0 additions & 17 deletions crates/cheatcodes/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1846,23 +1846,6 @@ where {
tx_req.authorization_list = None;
}

let mut tx_req = TransactionRequest {
from: Some(broadcast.new_origin),
to: Some(TxKind::from(Some(call.target_address))),
value: call.transfer_value(),
input: TransactionInput::new(call.input.clone()),
nonce: Some(account.info.nonce),
chain_id: Some(ecx.env.cfg.chain_id),
gas: if is_fixed_gas_limit { Some(call.gas_limit) } else { None },
..Default::default()
};

if let Some(auth_list) = self.active_delegation.take() {
tx_req.authorization_list = Some(vec![auth_list]);
} else {
tx_req.authorization_list = None;
}

self.broadcastable_transactions.push_back(BroadcastableTransaction {
rpc: ecx_inner.db.active_fork_url(),
transaction: tx_req.into(),
Expand Down
2 changes: 0 additions & 2 deletions crates/forge/bin/cmd/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ impl BuildArgs {
// solc output. This is safe currently as the output is simply dropped.
Ok(())
}
=======
>>>>>>> 59f354c179f4e7f6d7292acb3d068815c79286d1
}

/// Returns the `Project` for the current workspace
Expand Down
9 changes: 8 additions & 1 deletion crates/forge/bin/cmd/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,11 +757,14 @@ impl CreateArgs {
None
};
let verify = VerifyArgs {
<<<<<<< HEAD
=======
>>>>>>> 59f354c179f4e7f6d7292acb3d068815c79286d1
=======
>>>>>>> main
address,
contract: Some(self.contract),
compiler_version: Some(id.version.to_string()),
compiler_version: None,
constructor_args,
constructor_args_path: None,
num_of_optimizations,
Expand All @@ -779,8 +782,12 @@ impl CreateArgs {
evm_version: self.opts.compiler.evm_version,
show_standard_json_input: self.show_standard_json_input,
guess_constructor_args: false,
<<<<<<< HEAD
// compilation_profile: Some(id.profile.to_string()),
compilation_profile: None, // TODO(zk): provide comp profile
=======
compilation_profile: None, //TODO(zk): provide comp profile
>>>>>>> main
zksync: self.opts.compiler.zk.enabled(),
};
sh_println!("Waiting for {} to detect contract deployment...", verify.verifier.verifier)?;
Expand Down
16 changes: 15 additions & 1 deletion crates/forge/bin/cmd/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl InitArgs {
}
}

// install forge-zksync-std
// NOTE(zk): install forge-zksync-std
if zksync && !offline {
if root.join("lib/forge-zksync-std").exists() {
sh_println!("\"lib/forge-zksync-std\" already exists, skipping install....")?;
Expand All @@ -161,6 +161,20 @@ impl InitArgs {
let dep = "https://github.com/Moonsong-Labs/forge-zksync-std".parse()?;
self.opts.install(&mut config, vec![dep])?;
}

//Add zkout/ to .gitignore under compiler files if it doesn't exist
let gitignore_path = root.join(".gitignore");
if gitignore_path.exists() {
let mut content = fs::read_to_string(&gitignore_path)?;
if !content.contains("zkout/") {
// Find the compiler files section and add zkout/
if let Some(pos) = content.find("out/") {
let insert_pos = pos + "out/".len();
content.insert_str(insert_pos, "\nzkout/");
fs::write(&gitignore_path, content)?;
}
}
}
}

// init vscode settings
Expand Down
10 changes: 10 additions & 0 deletions crates/forge/src/gas_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ impl GasReport {
if is_create_call {
trace!(contract_name, "adding create gas info");
contract_info.gas = trace.gas_used;
<<<<<<< HEAD
=======
contract_info.size = trace.data.len();

if decoder.zk_contracts.contains(&node.trace.address) {
// Intercepted creates in zkvm mode will have the evm bytecode as input
// and the zkvm bytecode as output on the trace.
contract_info.size = trace.output.len();
}
>>>>>>> main
} else if let Some(DecodedCallData { signature, .. }) = decoded().await.call_data {
let name = signature.split('(').next().unwrap();
// ignore any test/setup functions
Expand Down
14 changes: 14 additions & 0 deletions crates/forge/tests/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ forgetest_init!(build_sizes_no_forge_std, |prj, cmd| {
"#]]
.is_json(),
);
<<<<<<< HEAD
=======
});

// tests build output is as expected in zksync mode
forgetest_init!(test_zk_build_sizes, |prj, cmd| {
cmd.args(["build", "--sizes", "--zksync", "--evm-version", "shanghai"]);
let stdout = cmd.assert_success().get_output().stdout_lossy();
let pattern =
Regex::new(r"\|\s*Counter\s*\|\s*800\s*\|\s*800\s*\|\s*450,199\s*\|\s*450,199\s*\|")
.unwrap();

assert!(pattern.is_match(&stdout), "Unexpected size output:\n{stdout}");
>>>>>>> main
});

// tests that skip key in config can be used to skip non-compilable contract
Expand Down
13 changes: 13 additions & 0 deletions crates/forge/tests/cli/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3415,3 +3415,16 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests)
.is_json(),
);
});

forgetest_init!(zk_can_init_with_zksync, |prj, cmd| {
cmd.args(["init", "--zksync", "--force"]).assert_success();

// Check that zkout/ is in .gitignore
let gitignore_path = prj.root().join(".gitignore");
assert!(gitignore_path.exists());
let gitignore_contents = std::fs::read_to_string(&gitignore_path).unwrap();
assert!(gitignore_contents.contains("zkout/"));

// Assert that forge-zksync-std is installed
assert!(prj.root().join("lib/forge-zksync-std").exists());
});
1 change: 0 additions & 1 deletion crates/script/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ impl VerifyBundle {
evm_version: None,
show_standard_json_input: false,
guess_constructor_args: false,
// compilation_profile: Some(artifact.profile.to_string()),
compilation_profile: None, //TODO(zk): get compilation profile
zksync: self.zksync,
};
Expand Down
6 changes: 4 additions & 2 deletions crates/verify/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,10 @@ impl VerifyArgs {
SolcReq::Version(version) => version.to_owned(),
SolcReq::Local(solc) => Solc::new(solc)?.version,
}
} else if let Some(entry) =
cache.as_ref().and_then(|cache| cache.files.get(&contract_path).cloned())
} else if let Some(entry) = project
.read_cache_file()
.ok()
.and_then(|mut cache| cache.files.remove(&contract_path))
{
let unique_versions = entry
.artifacts
Expand Down

0 comments on commit 4721908

Please sign in to comment.