Skip to content

Commit

Permalink
Merge branch 'main' into better-handling-of-failed-l1-transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
tomg10 authored Oct 16, 2024
2 parents 29d6898 + 899ffc0 commit 9389bfa
Show file tree
Hide file tree
Showing 63 changed files with 1,598 additions and 979 deletions.
127 changes: 127 additions & 0 deletions .github/workflows/ci-prover-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Workflow for testing prover component end-to-end
on:
workflow_call:

jobs:
e2e-test:
runs-on: [ matterlabs-ci-gpu-l4-runner-prover-tests ]
env:
RUNNER_COMPOSE_FILE: "docker-compose-gpu-runner-cuda-12-0.yml"

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
echo "SCCACHE_GCS_BUCKET=matterlabs-infra-sccache-storage" >> .env
echo "SCCACHE_GCS_SERVICE_ACCOUNT=gha-ci-runners@matterlabs-infra.iam.gserviceaccount.com" >> .env
echo "SCCACHE_GCS_RW_MODE=READ_WRITE" >> .env
echo "RUSTC_WRAPPER=sccache" >> .env
mkdir -p prover_logs
- name: Start services
run: |
run_retried docker-compose -f ${RUNNER_COMPOSE_FILE} pull
mkdir -p ./volumes/postgres ./volumes/reth/data
docker-compose -f ${RUNNER_COMPOSE_FILE} --profile runner up -d --wait
ci_run sccache --start-server
- name: Init
run: |
ci_run git config --global --add safe.directory "*"
ci_run chmod -R +x ./bin
ci_run ./zkstack_cli/zkstackup/install -g --path ./zkstack_cli/zkstackup/zkstackup || true
ci_run zkstackup -g --local
ci_run zkstack chain create \
--chain-name proving_chain \
--chain-id sequential \
--prover-mode gpu \
--wallet-creation localhost \
--l1-batch-commit-data-generator-mode rollup \
--base-token-address 0x0000000000000000000000000000000000000001 \
--base-token-price-nominator 1 \
--base-token-price-denominator 1 \
--set-as-default true \
--ignore-prerequisites
ci_run zkstack ecosystem init --dev --verbose
ci_run zkstack prover init --dev --verbose
echo "URL=$(grep "http_url" ./chains/proving_chain/configs/general.yaml | awk '{ print $2 }')" >> $GITHUB_ENV
- name: Build prover binaries
run: |
ci_run cargo build --release --workspace --manifest-path=prover/Cargo.toml
- name: Prepare prover subsystem
run: |
ci_run zkstack prover init-bellman-cuda --clone --verbose
ci_run zkstack prover setup-keys --mode=download --region=us --verbose
- name: Run server
run: |
ci_run zkstack server --uring --chain=proving_chain --components=api,tree,eth,state_keeper,commitment_generator,proof_data_handler,vm_runner_protective_reads,vm_runner_bwip &>prover_logs/server.log &
- name: Run Gateway
run: |
ci_run zkstack prover run --component=gateway --docker=false &>prover_logs/gateway.log &
- name: Run Prover Job Monitor
run: |
ci_run zkstack prover run --component=prover-job-monitor --docker=false &>prover_logs/prover-job-monitor.log &
- name: Wait for batch to be passed through gateway
env:
DATABASE_URL: postgres://postgres:notsecurepassword@localhost:5432/zksync_prover_localhost_proving_chain
BATCH_NUMBER: 1
INTERVAL: 30
TIMEOUT: 300
run: |
PASSED_ENV_VARS="DATABASE_URL,BATCH_NUMBER,INTERVAL,TIMEOUT" \
ci_run ./bin/prover_checkers/batch_availability_checker
- name: Run Witness Generator
run: |
ci_run zkstack prover run --component=witness-generator --round=all-rounds --docker=false &>prover_logs/witness-generator.log &
- name: Run Circuit Prover
run: |
ci_run zkstack prover run --component=circuit-prover --witness-vector-generator-count=10 --docker=false &>prover_logs/circuit_prover.log &
- name: Wait for prover jobs to finish
env:
DATABASE_URL: postgres://postgres:notsecurepassword@localhost:5432/zksync_prover_localhost_proving_chain
BATCH_NUMBER: 1
INTERVAL: 30
TIMEOUT: 1200
run: |
PASSED_ENV_VARS="DATABASE_URL,BATCH_NUMBER,INTERVAL,TIMEOUT" \
ci_run ./bin/prover_checkers/prover_jobs_status_checker
- name: Kill prover & start compressor
run: |
sudo ./bin/prover_checkers/kill_prover
ci_run zkstack prover run --component=compressor --docker=false &>prover_logs/compressor.log &
- name: Wait for batch to be executed on L1
env:
DATABASE_URL: postgres://postgres:notsecurepassword@localhost:5432/zksync_prover_localhost_proving_chain
BATCH_NUMBER: 1
INTERVAL: 30
TIMEOUT: 600
run: |
PASSED_ENV_VARS="BATCH_NUMBER,DATABASE_URL,URL,INTERVAL,TIMEOUT" \
ci_run ./bin/prover_checkers/batch_l1_status_checker
- name: Upload logs
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
if: always()
with:
name: prover_logs
path: prover_logs

- name: Show sccache logs
if: always()
run: |
ci_run sccache --show-stats || true
ci_run cat /tmp/sccache_log.txt || true
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
- '!prover/extract-setup-data-keys.sh'
- 'docker/prover*/**'
- '.github/workflows/build-prover-template.yml'
- '.github/workflows/new-build-prover-template.yml'
- '.github/workflows/build-witness-generator-template.yml'
- '.github/workflows/new-build-witness-generator-template.yml'
- '.github/workflows/ci-prover-reusable.yml'
- 'docker-compose-runner-nightly.yml'
- '!**/*.md'
Expand All @@ -53,7 +56,9 @@ jobs:
- 'docker/external-node/**'
- 'docker/server/**'
- '.github/workflows/build-core-template.yml'
- '.github/workflows/new-build-core-template.yml'
- '.github/workflows/build-contract-verifier-template.yml'
- '.github/workflows/new-build-contract-verifier-template.yml'
- '.github/workflows/ci-core-reusable.yml'
- '.github/workflows/ci-core-lint-reusable.yml'
- 'Cargo.toml'
Expand Down Expand Up @@ -94,6 +99,12 @@ jobs:
name: CI for Prover Components
uses: ./.github/workflows/ci-prover-reusable.yml

e2e-for-prover:
name: E2E Test for Prover Components
needs: changed_files
if: ${{(needs.changed_files.outputs.prover == 'true' || needs.changed_files.outputs.all == 'true') && !contains(github.ref_name, 'release-please--branches') }}
uses: ./.github/workflows/ci-prover-e2e.yml

ci-for-docs:
needs: changed_files
if: needs.changed_files.outputs.docs == 'true'
Expand Down
25 changes: 8 additions & 17 deletions .github/workflows/new-build-contract-verifier-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,36 +74,30 @@ jobs:
tar -C ./contracts -zxf system-contracts.tar.gz
- name: Install Apt dependencies
if: env.BUILD_CONTRACTS == 'true'
shell: bash
run: |
sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config
- name: Install Node
if: env.BUILD_CONTRACTS == 'true'
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 20
cache: 'npm'

- name: Install Yarn
if: env.BUILD_CONTRACTS == 'true'
run: npm install -g yarn

- name: Setup rust
if: env.BUILD_CONTRACTS == 'true'
uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0
with:
toolchain: nightly-2024-08-01

- name: Install cargo-nextest from crates.io
uses: baptiste0928/cargo-install@904927dbe77864e0f2281519fe9d5bd097a220b3 # v3.1.1
with:
crate: cargo-nextest

- name: Install sqlx-cli from crates.io
uses: baptiste0928/cargo-install@904927dbe77864e0f2281519fe9d5bd097a220b3 # v3.1.1
with:
crate: sqlx-cli
tag: 0.8.1

- name: Install foundry-zksync
if: env.BUILD_CONTRACTS == 'true'
run: |
mkdir ./foundry-zksync
curl -LO https://github.com/matter-labs/foundry-zksync/releases/download/nightly-15bec2f861b3b4c71e58f85e2b2c9dd722585aa8/foundry_nightly_linux_amd64.tar.gz
Expand All @@ -112,6 +106,7 @@ jobs:
echo "$PWD/foundry-zksync" >> $GITHUB_PATH
- name: Pre-download compilers
if: env.BUILD_CONTRACTS == 'true'
shell: bash
run: |
# Download needed versions of vyper compiler
Expand All @@ -129,18 +124,14 @@ jobs:
chmod +x "./hardhat-nodejs/compilers-v2/$compiler/${compiler}-v${version}"
done
- name: init
shell: bash
run: |
mkdir -p ./volumes/postgres
docker compose up -d postgres
- name: Install zkstack
if: env.BUILD_CONTRACTS == 'true'
run: |
./zkstack_cli/zkstackup/install --path ./zkstack_cli/zkstackup/zkstackup
zkstackup --local || true
- name: build contracts
if: env.BUILD_CONTRACTS == 'true'
shell: bash
run: |
cp etc/tokens/{test,localhost}.json
Expand Down
25 changes: 8 additions & 17 deletions .github/workflows/new-build-core-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,36 +79,30 @@ jobs:
tar -C ./contracts -zxf system-contracts.tar.gz
- name: Install Apt dependencies
if: env.BUILD_CONTRACTS == 'true'
shell: bash
run: |
sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config
- name: Install Node
if: env.BUILD_CONTRACTS == 'true'
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 20
cache: 'npm'

- name: Install Yarn
if: env.BUILD_CONTRACTS == 'true'
run: npm install -g yarn

- name: Setup rust
if: env.BUILD_CONTRACTS == 'true'
uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0
with:
toolchain: nightly-2024-08-01

- name: Install cargo-nextest from crates.io
uses: baptiste0928/cargo-install@904927dbe77864e0f2281519fe9d5bd097a220b3 # v3.1.1
with:
crate: cargo-nextest

- name: Install sqlx-cli from crates.io
uses: baptiste0928/cargo-install@904927dbe77864e0f2281519fe9d5bd097a220b3 # v3.1.1
with:
crate: sqlx-cli
tag: 0.8.1

- name: Install foundry-zksync
if: env.BUILD_CONTRACTS == 'true'
run: |
mkdir ./foundry-zksync
curl -LO https://github.com/matter-labs/foundry-zksync/releases/download/nightly-15bec2f861b3b4c71e58f85e2b2c9dd722585aa8/foundry_nightly_linux_amd64.tar.gz
Expand All @@ -117,6 +111,7 @@ jobs:
echo "$PWD/foundry-zksync" >> $GITHUB_PATH
- name: Pre-download compilers
if: env.BUILD_CONTRACTS == 'true'
shell: bash
run: |
# Download needed versions of vyper compiler
Expand All @@ -134,18 +129,14 @@ jobs:
chmod +x "./hardhat-nodejs/compilers-v2/$compiler/${compiler}-v${version}"
done
- name: init
shell: bash
run: |
mkdir -p ./volumes/postgres
docker compose up -d postgres
- name: Install zkstack
if: env.BUILD_CONTRACTS == 'true'
run: |
./zkstack_cli/zkstackup/install --path ./zkstack_cli/zkstackup/zkstackup
zkstackup --local || true
- name: build contracts
if: env.BUILD_CONTRACTS == 'true'
shell: bash
run: |
cp etc/tokens/{test,localhost}.json
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/zk-environment-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ jobs:
- docker/zk-environment/Dockerfile
- .github/workflows/zk-environment-publish.yml
zk_env_cuda_11_8:
- docker/zk-environment/20.04_amd64_cuda_11_8.Dockerfile
- docker/zk-environment/22.04_amd64_cuda_11_8.Dockerfile
- .github/workflows/zk-environment-publish.yml
zk_env_cuda_12:
- docker/zk-environment/20.04_amd64_cuda_12_0.Dockerfile
- docker/zk-environment/22.04_amd64_cuda_12_0.Dockerfile
- .github/workflows/zk-environment-publish.yml
get_short_sha:
Expand Down Expand Up @@ -245,7 +245,7 @@ jobs:
if: ${{ (steps.condition.outputs.should_run == 'true') || (github.event_name == 'workflow_dispatch' && inputs.build_cuda) }}
uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445 # v6.5.0
with:
file: docker/zk-environment/20.04_amd64_cuda_${{ matrix.cuda_version }}.Dockerfile
file: docker/zk-environment/22.04_amd64_cuda_${{ matrix.cuda_version }}.Dockerfile
push: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) || (github.event_name == 'workflow_dispatch' && inputs.build_cuda) }}
tags: |
us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/zk-environment-cuda-${{ matrix.cuda_version }}:latest
Expand Down
40 changes: 40 additions & 0 deletions bin/prover_checkers/batch_availability_checker
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

set -o errexit
set -o pipefail

# Configuration
# DATABASE_URL - The URL of the prover database to connect to
# BATCH_NUMBER - The batch number to check availability for
# INTERVAL - Time interval for polling in seconds
# TIMEOUT - Timeout of script in seconds

# Start timer
START_TIME=$(date +%s)

# Loop to query periodically
while true; do
# Calculate the elapsed time
CURRENT_TIME=$(date +%s)
ELAPSED_TIME=$((CURRENT_TIME - START_TIME))

# Check if the timeout has been reached
if [ $ELAPSED_TIME -ge $TIMEOUT ]; then
echo "Timeout reached. Failing CI..."
exit 1 # Exit with non-zero status to fail CI
fi

# Run the SQL query and capture the result
RESULT=$(psql $DATABASE_URL -c "SELECT count(*) FROM witness_inputs_fri WHERE l1_batch_number = $BATCH_NUMBER;" -t -A)

# Check if the result is 1
if [ "$RESULT" -eq 1 ]; then
echo "Query result is 1. Success!"
exit 0 # Exit with zero status to succeed CI
else
echo "Batch is not available yet. Retrying in $INTERVAL seconds..."
fi

# Wait for the next interval
sleep $INTERVAL
done
Loading

0 comments on commit 9389bfa

Please sign in to comment.