From 642d6c28a9eb42eb177f7d2262f0a81b433db454 Mon Sep 17 00:00:00 2001 From: aon <21188659+aon@users.noreply.github.com> Date: Mon, 20 May 2024 17:05:24 -0300 Subject: [PATCH] feat: add zk toolbox ci --- .github/workflows/ci-core-reusable.yml | 52 ++++++++++++++++++- .github/workflows/ci.yml | 1 + contracts | 2 +- docker/zk-environment/Dockerfile | 4 ++ zk_toolbox/crates/common/src/config.rs | 1 + .../zk_inception/src/accept_ownership.rs | 9 +--- zk_toolbox/crates/zk_inception/src/main.rs | 10 +++- 7 files changed, 67 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci-core-reusable.yml b/.github/workflows/ci-core-reusable.yml index 39b389ef94ed..1b68f6b43ed3 100644 --- a/.github/workflows/ci-core-reusable.yml +++ b/.github/workflows/ci-core-reusable.yml @@ -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] @@ -66,6 +104,7 @@ jobs: loadtest: runs-on: [matterlabs-ci-runner] + needs: [build-zk-toolbox] steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 @@ -73,6 +112,16 @@ jobs: 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 @@ -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 @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21e3104a5dcd..6c616edc755e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,6 +57,7 @@ jobs: - '.github/workflows/ci-core-lint-reusable.yml' - 'Cargo.toml' - 'Cargo.lock' + - 'zk_toolbox/**' - '!**/*.md' - '!**/*.MD' - 'docker-compose.yml' diff --git a/contracts b/contracts index 8854ae8230b3..c64d4489b2da 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 8854ae8230b395680fabb74d758b1d00211d7ddc +Subproject commit c64d4489b2da5d5db095e54455afd371229122a3 diff --git a/docker/zk-environment/Dockerfile b/docker/zk-environment/Dockerfile index 6690d317d2a3..1ed60f4b95f1 100644 --- a/docker/zk-environment/Dockerfile +++ b/docker/zk-environment/Dockerfile @@ -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}" diff --git a/zk_toolbox/crates/common/src/config.rs b/zk_toolbox/crates/common/src/config.rs index 3911016c5a47..9db0c974c591 100644 --- a/zk_toolbox/crates/common/src/config.rs +++ b/zk_toolbox/crates/common/src/config.rs @@ -14,4 +14,5 @@ pub fn global_config() -> &'static GlobalConfig { pub struct GlobalConfig { pub verbose: bool, pub hyperchain_name: Option, + pub ignore_prerequisites: bool, } diff --git a/zk_toolbox/crates/zk_inception/src/accept_ownership.rs b/zk_toolbox/crates/zk_inception/src/accept_ownership.rs index 420c4efcaa88..6199f9929af5 100644 --- a/zk_toolbox/crates/zk_inception/src/accept_ownership.rs +++ b/zk_toolbox/crates/zk_inception/src/accept_ownership.rs @@ -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; @@ -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(()) } diff --git a/zk_toolbox/crates/zk_inception/src/main.rs b/zk_toolbox/crates/zk_inception/src/main.rs index 28a932de1eb4..84c8eb2da6ac 100644 --- a/zk_toolbox/crates/zk_inception/src/main.rs +++ b/zk_toolbox/crates/zk_inception/src/main.rs @@ -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; @@ -53,6 +53,9 @@ struct InceptionGlobalArgs { /// Hyperchain to use #[clap(long, global = true)] hyperchain: Option, + /// Ignores prerequisites checks + #[clap(long, global = true)] + ignore_prerequisites: bool, } #[tokio::main] @@ -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(_) => {} @@ -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(()) }