Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
temaniarpit27 committed Nov 12, 2024
1 parent 00ae12e commit a675a7c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 55 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
--- # Proof generation benchmarking workflow
---
# Proof generation benchmarking workflow

name: Benchmark proving

Expand Down
42 changes: 25 additions & 17 deletions .github/workflows/cron_jerigon_zero_testing.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
---
# Cron running every sunday at 12PM UTC which will run the integration and benchmarking tests for Jerigon Zero

name: Jerigon Zero Testing

on:
# Uncomment when ready to run on a schedule
# TODO - Change this before merge
# # Uncomment when ready to run on a schedule
# schedule:
# # Run every Sunday at 12:00 AM (UTC)
# - cron: "0 0 * * 0"
# # Run every Sunday at 12:00 PM (UTC)
# - cron: "0 12 * * SUN"
push:
branches: [develop]
pull_request:
Expand All @@ -21,7 +25,10 @@ env:
jobs:
jerigon_zero_testing:
name: Jerigon Zero Testing - Integration and Benchmarking
runs-on: zero-ci
runs-on: zero-reg
concurrency:
group: jerigon_zero_testing
cancel-in-progress: true
steps:
- name: Checkout zk_evm code
uses: actions/checkout@v4
Expand All @@ -34,9 +41,10 @@ jobs:
with:
cache-on-failure: true

# 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 -Copt-level=3' cargo build --release
RUSTFLAGS='-C target-cpu=native -Zlinker-features=-lld' cargo build --release
sudo sysctl kernel.perf_event_paranoid=0
- name: Set up QEMU
Expand All @@ -52,9 +60,10 @@ jobs:
- name: Run Erigon Network
run: |
cd ..
tar xf "$(pwd)/zk_evm/test_data/erigon-data.tar.gz" || {
echo "Failed to extract erigon-data.tar.gz"; exit 1;
}
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 \
Expand All @@ -73,30 +82,29 @@ jobs:
run: |
export ETH_RPC_URL="http://localhost:8545"
rm -rf proofs/* circuits/* ./proofs.json test.out verify.out leader.out
random_numbers=($(shuf -i 1-500 -n 5))
for number in "${random_numbers[@]}"; do
hex_number="0x$(echo "obase=16; $number" | bc)"
OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./scripts/prove_rpc.sh $hex_number $hex_number $ETH_RPC_URL jerigon true 3000 100
done
# TODO - Change block number and checkpoint before merge use 1000 to 1100
OUTPUT_TO_TERMINAL=true ./scripts/prove_rpc.sh 1 1 $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_benchmark
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.sh
./scripts/jerigon_zero_benchmark.bash
- name: Upload New Results
uses: actions/upload-artifact@v4
with:
name: jerigon_zero_benchmark
path: ./jerigon_zero_output.log
name: jerigon_zero_testing
path: |
./jerigon_zero_benchmark.log
./jerigon_zero_error.log
retention-days: 90
overwrite: true
13 changes: 7 additions & 6 deletions .github/workflows/yamllint.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/bin/bash
# ------------------------------------------------------------------------------
set -exo pipefail

# Args:
# 1 --> Output file (Not used in the current script)
#!/usr/bin/env bash
set -euxo pipefail

# Get the number of processors for parallelism
if [[ "$OSTYPE" == "darwin"* ]]; then
Expand All @@ -18,8 +14,9 @@ PROOF_OUTPUT_DIR="${REPO_ROOT}/proofs"
BLOCK_BATCH_SIZE="${BLOCK_BATCH_SIZE:-8}"

# Logging setup
OUTPUT_LOG="jerigon_zero_output.log"
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
Expand All @@ -33,55 +30,52 @@ export RUST_BACKTRACE=full
export RUST_LOG=info

# Log the current date and time
echo "$(date +"%Y-%m-%d %H:%M:%S")" &>> "$OUTPUT_LOG"

# Define the blocks to process
blocks=(100 200 300 400 500)
date +"%Y-%m-%d %H:%M:%S" &>> "$OUTPUT_LOG"

# Function to process each block
process_block() {
local block=$1

echo "Processing block: $block" &>> "$OUTPUT_LOG"
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" > "output_${block}.json"; then
echo "Failed to fetch block data for block: $block" &>> "$OUTPUT_LOG"
exit 1
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

local start_time=$(date +%s%N)
start_time=$(date +%s%N)

# Run performance stats
if ! perf stat -e cycles ./target/release/leader --runtime in-memory --load-strategy monolithic --block-batch-size "$BLOCK_BATCH_SIZE" --proof-output-dir "$PROOF_OUTPUT_DIR" stdio < "output_${block}.json" &> "$BLOCK_OUTPUT_LOG"; then
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" &>> "$OUTPUT_LOG"
exit 1
cat "$BLOCK_OUTPUT_LOG" &>> "$ERROR_LOG"
return
fi

local end_time=$(date +%s%N)
end_time=$(date +%s%N)

set +o pipefail
if ! cat "$BLOCK_OUTPUT_LOG" | grep "Successfully wrote to disk proof file " | awk '{print $NF}' | tee "$PROOFS_FILE_LIST"; then
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" &>> "$OUTPUT_LOG"
exit 1
cat "$BLOCK_OUTPUT_LOG" &>> "$ERROR_LOG"
return
fi

local duration_sec=$(echo "scale=3; ($end_time - $start_time) / 1000000000" | bc -l)
duration_sec=$(echo "scale=3; ($end_time - $start_time) / 1000000000" | bc -l)

# Extract performance timings
local PERF_TIME=$(grep "seconds time elapsed" "$BLOCK_OUTPUT_LOG" | tail -1 | awk '{ print ($1)}')
local PERF_USER_TIME=$(grep "seconds user" "$BLOCK_OUTPUT_LOG" | tail -1 | awk '{ print ($1)}')
local PERF_SYS_TIME=$(grep "seconds sys" "$BLOCK_OUTPUT_LOG" | tail -1 | awk '{ print ($1)}')
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 block in "${blocks[@]}"; do
process_block "$block"
# TODO - Change block numbers before merge use 700 to 1000
for i in $(seq 1 2); do
process_block "$i"
done

# Finalize logging
Expand Down
Binary file removed test_data/erigon-data.tar.gz
Binary file not shown.

0 comments on commit a675a7c

Please sign in to comment.