Skip to content

Commit

Permalink
Add shell wrappers for checking prover and rollup benchmark thresholds (
Browse files Browse the repository at this point in the history
#1296)

* rollup bench ci

* change env vars

* shell wrappers for benchmark checks

* fix tps threshold

* switch error codes. condition is correct

* fix comparison

* modify proof_block_jump
  • Loading branch information
dubbelosix authored Jan 11, 2024
1 parent a8a234c commit c9f56b4
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 2 deletions.
40 changes: 39 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ jobs:
BLOCKS: 1
TXNS_PER_BLOCK: 10
NUM_PUB_KEYS: 100
run: cargo bench --bench prover_bench --features bench
run: sh ci_prover_count_check.sh

bench_check:
name: bench_check
Expand Down Expand Up @@ -228,6 +228,44 @@ jobs:
NUM_PUB_KEYS: 100
run: cargo bench

rollup_bench_check:
name: rollup_bench_check
needs: check
runs-on: buildjet-8vcpu-ubuntu-2204
timeout-minutes: 120
steps:
- uses: actions/checkout@v3
- uses: rui314/setup-mold@v1
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust
run: rustup show && rustup install nightly && rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu
- name: Install cargo-risczero
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain
run: cargo risczero install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
shared-key: cargo-check-cache
save-if: ${{ github.ref == 'refs/heads/nightly' }}
workspaces: |
.
fuzz
- name: rollup bench check
env:
BLOCKS: 10
TXNS_PER_BLOCK: 10000
NUM_PUB_KEYS: 100
run: sh ci_rollup_count_check.sh

# Check that every combination of features is working properly.
hack:
name: features
Expand Down
29 changes: 29 additions & 0 deletions ci_prover_count_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
export BLOCKS=1
export TXNS_PER_BLOCK=10
export NUM_PUB_KEYS=100
export CYCLE_COUNT=1000000
cargo bench --bench prover_bench --features bench 2>&1 | tee output.log

output_file="output.log"

verify_line=$(grep -w "verify" $output_file)

if [ -z "$verify_line" ]; then
echo "The line containing 'verify' was not found."
exit 1
else
average_cycles=$(echo $verify_line | awk '{print $4}' | sed 's/,//g') # Remove commas if present

if [ -n "$average_cycles" ] && [ "$average_cycles" -lt $CYCLE_COUNT ]; then
echo "The value for 'verify' is less than $CYCLE_COUNT. Passing the check. Value: $average_cycles"
exit 0
elif [ -n "$average_cycles" ]; then
echo "The value for 'verify' is greater than $CYCLE_COUNT. Failing the check. Value: $average_cycles"
exit 0
else
echo "Unable to extract the 'Average Cycles' value."
exit 1
fi
fi
exit 1
25 changes: 25 additions & 0 deletions ci_rollup_count_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
export BLOCKS=10
export TXNS_PER_BLOCK=10000
export TPS=1000
(cd examples/demo-rollup/benches/node && make basic 2>&1) | tee output.log

output_file="output.log"

verify_line=$(grep -w "Transactions per sec (TPS)" $output_file)

if [ -z "$verify_line" ]; then
echo "The line containing 'verify' was not found."
exit 1
else
tps_count=$(echo $verify_line | awk -F '|' '{print $3}' | sed 's/,//g')
result=$(awk -v val="$tps_count" -v threshold="$TPS" 'BEGIN {print (val < threshold) ? "FAIL" : "PASS"}')
if [ "$result" = "FAIL" ]; then
echo "The value for TPS is less than $TPS. Failing the check. Value: $tps_count"
exit 1
else
echo "The value for TPS is greater than $TPS. Passing the check. Value: $tps_count"
exit 0
fi
fi
exit 1
2 changes: 1 addition & 1 deletion examples/demo-rollup/benches/node/rollup_coarse_measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async fn main() -> Result<(), anyhow::Error> {
>::new();

let demo_genesis_config = {
let integ_test_conf_dir: &Path = "../../test-data/genesis/integration-tests".as_ref();
let integ_test_conf_dir: &Path = "../test-data/genesis/integration-tests".as_ref();
let rt_params =
get_genesis_config::<DefaultContext, _>(&GenesisPaths::from_dir(integ_test_conf_dir))
.unwrap();
Expand Down
3 changes: 3 additions & 0 deletions examples/demo-rollup/benches/node/rollup_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ start_height = 1
# the host and port to bind the rpc server for
bind_host = "127.0.0.1"
bind_port = 12345

[prover_service]
aggregated_proof_block_jump = 1

0 comments on commit c9f56b4

Please sign in to comment.