Skip to content

Commit

Permalink
feat: add zk toolbox ci
Browse files Browse the repository at this point in the history
  • Loading branch information
aon committed May 20, 2024
1 parent a8458b2 commit 642d6c2
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 12 deletions.
52 changes: 50 additions & 2 deletions .github/workflows/ci-core-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,44 @@ jobs:
lint:
name: lint
uses: ./.github/workflows/ci-core-lint-reusable.yml

build-zk-toolbox:
name: Build zk_toolbox
runs-on: [matterlabs-ci-runner]

steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
with:
submodules: "recursive"
fetch-depth: 0

- name: Setup environment
run: |
echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
echo $(pwd)/bin >> $GITHUB_PATH
echo IN_DOCKER=1 >> .env
- name: Start services
run: |
ci_localnet_up
- name: Build zk_toolbox
run: |
ci_run bash -c "cd zk_toolbox && cargo build --release"
# Compress with tar to avoid permission loss
# https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss
- name: Tar zk_toolbox binaries
run: |
tar -C ./zk_toolbox/target/release -cvf zk_toolbox.tar zk_inception zk_supervisor
- name: Upload zk_toolbox binaries
uses: actions/upload-artifact@v4
with:
name: zk_toolbox
path: zk_toolbox.tar
compression-level: 0

unit-tests:
runs-on: [matterlabs-ci-runner]

Expand Down Expand Up @@ -66,13 +104,24 @@ jobs:

loadtest:
runs-on: [matterlabs-ci-runner]
needs: [build-zk-toolbox]

steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
with:
submodules: "recursive"
fetch-depth: 0

- name: Download zk_toolbox binaries
uses: actions/download-artifact@v4
with:
name: zk_toolbox
path: .

- name: Extract zk_toolbox binaries
run: |
tar -xvf zk_toolbox.tar -C ./bin
- name: Setup environment
run: |
echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
Expand All @@ -99,7 +148,7 @@ jobs:
ci_run git config --global --add safe.directory /usr/src/zksync/contracts
ci_run zk
ci_run zk init --local-legacy-bridge-testing
ci_run zk_inception ecosystem init --deploy-paymaster --deploy-erc20 --deploy-ecosystem --use-default --ignore-prerequisites
# `sleep 60` because we need to wait until server added all the tokens
- name: Run server
Expand Down Expand Up @@ -233,7 +282,6 @@ jobs:
ci_run sleep 2
ENABLE_CONSENSUS=${{ matrix.consensus }} DEPLOYMENT_MODE=${{ matrix.deployment_mode }} PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE" ci_run zk test i revert
# This test should be the last one as soon as it
# finished bootloader will be different
- name: Run upgrade test
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
- '.github/workflows/ci-core-lint-reusable.yml'
- 'Cargo.toml'
- 'Cargo.lock'
- 'zk_toolbox/**'
- '!**/*.md'
- '!**/*.MD'
- 'docker-compose.yml'
Expand Down
2 changes: 1 addition & 1 deletion contracts
4 changes: 4 additions & 0 deletions docker/zk-environment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ RUN wget -c https://sourceware.org/pub/valgrind/valgrind-3.20.0.tar.bz2 && \
cd valgrind-3.20.0 && ./configure && make && make install && \
cd ../ && rm -rf valgrind-3.20.0.tar.bz2 && rm -rf valgrind-3.20.0

# Install foundry
RUN cargo install --git https://github.com/foundry-rs/foundry \
--profile local --locked forge cast

# Setup the environment
ENV ZKSYNC_HOME=/usr/src/zksync
ENV PATH="${ZKSYNC_HOME}/bin:${PATH}"
Expand Down
1 change: 1 addition & 0 deletions zk_toolbox/crates/common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ pub fn global_config() -> &'static GlobalConfig {
pub struct GlobalConfig {
pub verbose: bool,
pub hyperchain_name: Option<String>,
pub ignore_prerequisites: bool,
}
9 changes: 2 additions & 7 deletions zk_toolbox/crates/zk_inception/src/accept_ownership.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use common::{
forge::{Forge, ForgeScript, ForgeScriptArgs},
spinner::Spinner,
};
use common::forge::{Forge, ForgeScript, ForgeScriptArgs};
use ethers::{abi::Address, types::H256};
use xshell::Shell;

Expand Down Expand Up @@ -81,9 +78,7 @@ fn accept_ownership(
)?;

forge = fill_forge_private_key(forge, governor)?;

let spinner = Spinner::new("Accepting governance");
forge.run(shell)?;
spinner.finish();

Ok(())
}
10 changes: 8 additions & 2 deletions zk_toolbox/crates/zk_inception/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clap::{command, Parser, Subcommand};
use common::{
check_prerequisites,
config::{init_global_config, GlobalConfig},
config::{global_config, init_global_config, GlobalConfig},
init_prompt_theme, logger,
};
use xshell::Shell;
Expand Down Expand Up @@ -53,6 +53,9 @@ struct InceptionGlobalArgs {
/// Hyperchain to use
#[clap(long, global = true)]
hyperchain: Option<String>,
/// Ignores prerequisites checks
#[clap(long, global = true)]
ignore_prerequisites: bool,
}

#[tokio::main]
Expand All @@ -69,7 +72,9 @@ async fn main() -> anyhow::Result<()> {

init_global_config_inner(&shell, &inception_args.global)?;

check_prerequisites(&shell);
if !global_config().ignore_prerequisites {
check_prerequisites(&shell);
}

match run_subcommand(inception_args, &shell).await {
Ok(_) => {}
Expand Down Expand Up @@ -124,6 +129,7 @@ fn init_global_config_inner(
init_global_config(GlobalConfig {
verbose: inception_args.verbose,
hyperchain_name: inception_args.hyperchain.clone(),
ignore_prerequisites: inception_args.ignore_prerequisites,
});
Ok(())
}

0 comments on commit 642d6c2

Please sign in to comment.