diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index e3af33006..a61078547 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -1,4 +1,5 @@ ---- # Proof generation benchmarking workflow +--- +# Proof generation benchmarking workflow name: Benchmark proving diff --git a/.github/workflows/cron_jerigon_zero_testing.yml b/.github/workflows/cron_jerigon_zero_testing.yml new file mode 100644 index 000000000..25d843529 --- /dev/null +++ b/.github/workflows/cron_jerigon_zero_testing.yml @@ -0,0 +1,103 @@ +--- +# Cron running every sunday at 12PM UTC which will run the integration and benchmarking tests for Jerigon Zero + +name: Jerigon Zero Testing + +on: + # TODO @temaniarpit27 - Change this before merge + # # Uncomment when ready to run on a schedule + # schedule: + # # Run every Sunday at 12:00 PM (UTC) + # - cron: "0 12 * * SUN" + push: + branches: [develop] + # TODO @temaniarpit27 - Remove this before merge + pull_request: + branches: + - "**" + workflow_dispatch: + branches: + - "**" + +env: + CARGO_TERM_COLOR: always + REGISTRY: ghcr.io + +jobs: + jerigon_zero_testing: + name: Jerigon Zero Testing - Integration and Benchmarking + runs-on: zero-reg + timeout-minutes: 300 + concurrency: + group: jerigon_zero_testing + cancel-in-progress: true + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/rust + + # Build optimized for the native CPU with `lld` linker and allow detailed performance profiling. + - name: Build the project + run: | + RUSTFLAGS='-C target-cpu=native -Zlinker-features=-lld' cargo build --release + sudo sysctl kernel.perf_event_paranoid=0 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Run Erigon Network + run: | + cd .. + curl -o erigon-test-data.tar.gz \ + https://224d54070bdacdb423e0b7594ebdc231.ipfscdn.io/ipfs/bafybeigpm34mzhebd24uljuntmhulo6dpniqf75xtxcviztemb2fi5q74i \ + || { echo "Failed to download erigon.tar.gz"; exit 1; } + tar xf ./erigon-test-data.tar.gz + docker pull ghcr.io/0xpolygonzero/erigon:feat-zero + docker run -d --name erigon \ + -p 8545:8545 \ + -v $(pwd):/data \ + ghcr.io/0xpolygonzero/erigon:feat-zero \ + --datadir=/data/erigon/execution-data \ + --http.api=eth,erigon,engine,web3,net,debug,trace,txpool,admin \ + --http.vhosts=* --ws --http --http.addr=0.0.0.0 \ + --http.corsdomain=* --http.port=8545 \ + --metrics --metrics.addr=0.0.0.0 --metrics.port=9001 \ + --db.size.limit=3000MB || { + echo "Failed to start Erigon"; exit 1; + } + + - name: Regression Test with Zero Tracer in Real Mode + run: | + export ETH_RPC_URL="http://localhost:8545" + rm -rf proofs/* circuits/* ./proofs.json test.out verify.out leader.out + OUTPUT_TO_TERMINAL=true ./scripts/prove_rpc.sh 1000 1100 $ETH_RPC_URL jerigon 0 3000 100 test_only + + - name: Download Previous Results + uses: dawidd6/action-download-artifact@v6 + with: + workflow: cron_jerigon_zero_testing.yml + workflow_conclusion: success + name: jerigon_zero_testing + path: ./ + if_no_artifact_found: ignore + + - name: Run the Benchmark Script + run: | + export ETH_RPC_URL="http://localhost:8545" + ./scripts/jerigon_zero_benchmark.bash + + - name: Upload New Results + uses: actions/upload-artifact@v4 + with: + name: jerigon_zero_testing + path: | + ./jerigon_zero_benchmark.log + ./jerigon_zero_error.log + retention-days: 90 + overwrite: true diff --git a/.github/workflows/yamllint.yml b/.github/workflows/yamllint.yml index 0cfde4e60..71a116615 100644 --- a/.github/workflows/yamllint.yml +++ b/.github/workflows/yamllint.yml @@ -1,14 +1,15 @@ ---- # Run yamllint on all YAML files in the repository +--- +# Run yamllint on all YAML files in the repository name: Yamllint -'on': +"on": pull_request: paths: - - '**/*.yml' - - '.github/**' + - "**/*.yml" + - ".github/**" workflow_dispatch: branches: - - '**' + - "**" jobs: yamllint-check: @@ -22,5 +23,5 @@ jobs: run: > yamllint --format github - -d "{extends: default, rules: {line-length: {max: 120}, truthy: {check-keys: false}}}" + -d "{extends: default, rules: {line-length: {max: 130}, truthy: {check-keys: false}}}" .github scripts diff --git a/scripts/jerigon_zero_benchmark.bash b/scripts/jerigon_zero_benchmark.bash new file mode 100755 index 000000000..0b576f010 --- /dev/null +++ b/scripts/jerigon_zero_benchmark.bash @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +set -euxo pipefail + +# Get the number of processors for parallelism +if [[ "$OSTYPE" == "darwin"* ]]; then + num_procs=$(sysctl -n hw.physicalcpu) +else + num_procs=$(nproc) +fi + +# Force the working directory to always be the repository root. +REPO_ROOT=$(git rev-parse --show-toplevel) +PROOF_OUTPUT_DIR="${REPO_ROOT}/proofs" +BLOCK_BATCH_SIZE="${BLOCK_BATCH_SIZE:-8}" + +# Logging setup +OUTPUT_LOG="jerigon_zero_benchmark.log" +BLOCK_OUTPUT_LOG="jerigon_zero_block_output.log" +ERROR_LOG="jerigon_zero_error.log" +PROOFS_FILE_LIST="${PROOF_OUTPUT_DIR}/proof_files.json" + +# Ensure necessary directories exist +mkdir -p "$PROOF_OUTPUT_DIR" + +# Set environment variables for parallelism and logging +export RAYON_NUM_THREADS=$num_procs +export TOKIO_WORKER_THREADS=$num_procs +export RUST_MIN_STACK=33554432 +export RUST_BACKTRACE=full +export RUST_LOG=info + +# Log the current date and time +date +"%Y-%m-%d %H:%M:%S" &>> "$OUTPUT_LOG" +date +"%Y-%m-%d %H:%M:%S" &>> "$ERROR_LOG" + +# Function to process each block +process_block() { + local block start_time end_time duration_sec PERF_TIME PERF_USER_TIME PERF_SYS_TIME + block=$1 + + # Fetch block data + if ! ./target/release/rpc --rpc-url "$ETH_RPC_URL" fetch --start-block "$block" --end-block "$block" > "witness_${block}.json"; then + echo "Failed to fetch block data for block: $block" &>> "$ERROR_LOG" + return + fi + + start_time=$(date +%s%N) + + # Run performance stats + if ! perf stat -e cycles ./target/release/leader --runtime in-memory --use-test-config --load-strategy on-demand --block-batch-size "$BLOCK_BATCH_SIZE" --proof-output-dir "$PROOF_OUTPUT_DIR" stdio < "witness_${block}.json" &> "$BLOCK_OUTPUT_LOG"; then + echo "Performance command failed for block: $block" &>> "$OUTPUT_LOG" + cat "$BLOCK_OUTPUT_LOG" &>> "$ERROR_LOG" + return + fi + + end_time=$(date +%s%N) + + set +o pipefail + if ! grep "Successfully wrote to disk proof file " "$BLOCK_OUTPUT_LOG" | awk '{print $NF}' | tee "$PROOFS_FILE_LIST"; then + echo "Proof list not generated for block: $block. Check the log for details." &>> "$OUTPUT_LOG" + cat "$BLOCK_OUTPUT_LOG" &>> "$ERROR_LOG" + return + fi + + duration_sec=$(echo "scale=3; ($end_time - $start_time) / 1000000000" | bc -l) + + # Extract performance timings + PERF_TIME=$(grep "seconds time elapsed" "$BLOCK_OUTPUT_LOG" | tail -1 | awk '{ print ($1)}') + PERF_USER_TIME=$(grep "seconds user" "$BLOCK_OUTPUT_LOG" | tail -1 | awk '{ print ($1)}') + PERF_SYS_TIME=$(grep "seconds sys" "$BLOCK_OUTPUT_LOG" | tail -1 | awk '{ print ($1)}') + + echo "Success for block: $block!" + echo "Proving duration for block $block: $duration_sec seconds, performance time: $PERF_TIME, performance user time: $PERF_USER_TIME, performance system time: $PERF_SYS_TIME" &>> "$OUTPUT_LOG" +} + +# Process each block +for i in $(seq 701 1000); do + process_block "$i" +done + +# Finalize logging +echo "Processing completed at: $(date +"%Y-%m-%d %H:%M:%S")" &>> "$OUTPUT_LOG" +echo "" &>> "$OUTPUT_LOG" + +echo "Processing completed at: $(date +"%Y-%m-%d %H:%M:%S")" &>> "$ERROR_LOG" +echo "" &>> "$ERROR_LOG" \ No newline at end of file