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: forge build, forge create, forge script and smoke tests #299

Merged
merged 16 commits into from
Apr 4, 2024
60 changes: 41 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: test
on:
push:
branches:
- foundry/main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: any reason why not both?

- dev
pull_request:
branches:
- foundry/main
- dev

concurrency:
cancel-in-progress: true
Expand Down Expand Up @@ -90,27 +90,49 @@ jobs:
- name: cargo hack
run: cargo hack check

zk-test:
name: zk-test
runs-on: ubuntu-22.04-github-hosted-16core
steps:
- uses: actions/checkout@v4
# TODO: This test currently hangs in the CI
# zk-test:
# name: zk-test
# runs-on: ubuntu-22.04-github-hosted-16core
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive
# ref: ${{ github.event.pull_request.head.sha }}

# - name: Install Rust
# uses: actions-rust-lang/setup-rust-toolchain@v1
# with:
# toolchain: nightly-2024-02-06


# - name: Get solc
# run: |
# mkdir /tmp/solc-bin
# wget https://github.com/ethereum/solidity/releases/download/v0.8.24/solc-static-linux -qO /tmp/solc-bin/solc
# chmod +x /tmp/solc-bin/solc
# echo "/tmp/solc-bin" >> $GITHUB_PATH

# - name: Test ZK VM
# run: RUST_LOG=1 cargo test --package forge --test it --jobs=1 -- zk

zk-smoke-test:
name: zk-smoke-test
runs-on: ubuntu-22.04-github-hosted-16core

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
ref: ${{ github.event.pull_request.head.sha }}

- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly-2024-02-06


- name: Get solc
run: |
mkdir /tmp/solc-bin
wget https://github.com/ethereum/solidity/releases/download/v0.8.24/solc-static-linux -qO /tmp/solc-bin/solc
chmod +x /tmp/solc-bin/solc
echo "/tmp/solc-bin" >> $GITHUB_PATH

- name: Test ZK VM
run: RUST_LOG=1 cargo test --package forge --test it --jobs=1 -- zk

- name: Run smoke-test
env:
RUST_BACKTRACE: full
run: cd zk-tests && ./test.sh
48 changes: 34 additions & 14 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ foundry-evm-traces = { path = "crates/evm/traces" }
foundry-macros = { path = "crates/macros" }
foundry-test-utils = { path = "crates/test-utils" }
foundry-wallets = { path = "crates/wallets" }
foundry-zksync = { path = "crates/zksync" }
foundry-zksync-core = { path = "crates/zksync/core" }
foundry-zksync-compiler = { path = "crates/zksync/compiler" }

# solc & compilation utilities
foundry-block-explorers = { version = "0.2.3", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion crates/cheatcodes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ foundry-compilers.workspace = true
foundry-config.workspace = true
foundry-evm-core.workspace = true
foundry-wallets.workspace = true
foundry-zksync.workspace = true
foundry-zksync-core.workspace = true
foundry-zksync-compiler.workspace = true

alloy-dyn-abi.workspace = true
alloy-json-abi.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion crates/cheatcodes/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use foundry_config::{
ResolvedRpcEndpoints,
};
use foundry_evm_core::opts::EvmOpts;
use foundry_zksync::DualCompiledContract;
use foundry_zksync_compiler::DualCompiledContract;
use std::{
collections::HashMap,
path::{Path, PathBuf},
Expand Down Expand Up @@ -210,6 +210,7 @@ mod tests {
Default::default(),
None,
Default::default(),
false,
)
}

Expand Down
16 changes: 8 additions & 8 deletions crates/cheatcodes/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl Cheatcode for getNonce_0Call {
let Self { account } = self;

if ccx.state.use_zk_vm {
let nonce = foundry_zksync::cheatcodes::get_nonce(
let nonce = foundry_zksync_core::cheatcodes::get_nonce(
*account,
ccx.data.db,
&mut ccx.data.journaled_state,
Expand Down Expand Up @@ -275,7 +275,7 @@ impl Cheatcode for rollCall {
fn apply_full<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
let Self { newHeight } = self;
if ccx.state.use_zk_vm {
foundry_zksync::cheatcodes::roll(
foundry_zksync_core::cheatcodes::roll(
*newHeight,
ccx.data.env,
ccx.data.db,
Expand Down Expand Up @@ -308,7 +308,7 @@ impl Cheatcode for warpCall {
fn apply_full<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
let Self { newTimestamp } = self;
if ccx.state.use_zk_vm {
foundry_zksync::cheatcodes::warp(
foundry_zksync_core::cheatcodes::warp(
*newTimestamp,
ccx.data.env,
ccx.data.db,
Expand All @@ -333,7 +333,7 @@ impl Cheatcode for dealCall {
fn apply_full<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
let Self { account: address, newBalance: new_balance } = *self;
let old_balance = if ccx.state.use_zk_vm {
foundry_zksync::cheatcodes::deal(
foundry_zksync_core::cheatcodes::deal(
address,
new_balance,
ccx.data.db,
Expand All @@ -354,7 +354,7 @@ impl Cheatcode for etchCall {
fn apply_full<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
let Self { target, newRuntimeBytecode } = self;
if ccx.state.use_zk_vm {
foundry_zksync::cheatcodes::etch(
foundry_zksync_core::cheatcodes::etch(
*target,
newRuntimeBytecode,
ccx.data.db,
Expand All @@ -376,7 +376,7 @@ impl Cheatcode for resetNonceCall {
fn apply_full<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
let Self { account } = self;
if ccx.state.use_zk_vm {
foundry_zksync::cheatcodes::set_nonce(
foundry_zksync_core::cheatcodes::set_nonce(
*account,
U256::ZERO,
ccx.data.db,
Expand All @@ -402,7 +402,7 @@ impl Cheatcode for setNonceCall {
let Self { account, newNonce } = *self;

if ccx.state.use_zk_vm {
foundry_zksync::cheatcodes::set_nonce(
foundry_zksync_core::cheatcodes::set_nonce(
account,
U256::from(newNonce),
ccx.data.db,
Expand All @@ -429,7 +429,7 @@ impl Cheatcode for setNonceUnsafeCall {
let Self { account, newNonce } = *self;

if ccx.state.use_zk_vm {
foundry_zksync::cheatcodes::set_nonce(
foundry_zksync_core::cheatcodes::set_nonce(
account,
U256::from(newNonce),
ccx.data.db,
Expand Down
9 changes: 5 additions & 4 deletions crates/cheatcodes/src/evm/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ impl Cheatcode for mockCall_0Call {
// check Solidity might perform.
let empty_bytecode = acc.info.code.as_ref().map_or(true, Bytecode::is_empty);
if empty_bytecode {
let code =
Bytecode::new_raw(Bytes::copy_from_slice(&foundry_zksync::cheatcodes::EMPTY_CODE))
.to_checked();
let code = Bytecode::new_raw(Bytes::copy_from_slice(
&foundry_zksync_core::cheatcodes::EMPTY_CODE,
))
.to_checked();
ccx.data.journaled_state.set_code(*callee, code.clone());

foundry_zksync::cheatcodes::set_mocked_account(
foundry_zksync_core::cheatcodes::set_mocked_account(
*callee,
ccx.data.db,
&mut ccx.data.journaled_state,
Expand Down
Loading
Loading