Skip to content

feat(l2): bench job #2663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4398902
add job
xqft May 2, 2025
659f9ae
post benchmark to gh pages
xqft May 2, 2025
bfb6d58
WIP test
xqft May 2, 2025
0ac8409
WIP comment out report status
xqft May 2, 2025
867b1f4
add permissions, remove lfs
xqft May 2, 2025
1e4178b
dummy commit
xqft May 2, 2025
c1da217
Revert "dummy commit"
xqft May 2, 2025
918c4f6
fix json format
xqft May 2, 2025
8ddb9d2
WIP execute instead of prove
xqft May 2, 2025
4b70117
add more info
xqft May 2, 2025
167efd7
Revert "WIP test"
xqft May 2, 2025
0f72db3
Revert "WIP comment out report status"
xqft May 2, 2025
3b5a007
Revert "WIP execute instead of prove"
xqft May 2, 2025
ab44f18
cache block
xqft May 5, 2025
3defdc8
TEMP run in pr
xqft May 5, 2025
5fccc3b
add dummy value to rpc_url
xqft May 5, 2025
0cebefc
Merge branch 'main' into l2/bench_job
xqft May 5, 2025
f3dd283
TEMP turn off alerts
xqft May 5, 2025
173e05f
make down after integration test is done
xqft May 5, 2025
3f7fb8b
sigint to kill ethrex_prover
xqft May 5, 2025
5798ee2
add comment
xqft May 5, 2025
9b6f67f
Revert "TEMP turn off alerts"
xqft May 5, 2025
b5df22c
change block
xqft May 6, 2025
6cb177c
Revert "Revert "TEMP turn off alerts""
xqft May 6, 2025
85ee5c0
Revert "Revert "Revert "TEMP turn off alerts"""
xqft May 6, 2025
7a4ff7e
Revert "TEMP run in pr"
xqft May 6, 2025
12d2f8e
Merge branch 'main' into l2/bench_job
xqft May 6, 2025
4414d8d
add machine info
xqft May 6, 2025
4307835
Revert "Revert "TEMP run in pr""
xqft May 6, 2025
2f4d203
Revert "Revert "Revert "TEMP run in pr"""
xqft May 6, 2025
3750368
Merge branch 'main' into l2/bench_job
xqft May 6, 2025
355e96c
remove make down
xqft May 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/main_prover_l1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: RPC Prover (SP1 Backend)
on:
push:
branches: ["main"]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
CI_ETHREX_WORKDIR: /usr/local/bin
PROVER: sp1

permissions:
# deployments permission to deploy GitHub pages website
deployments: write
# contents permission to update benchmark contents in gh-pages branch
contents: write

jobs:
test:
name: L1 block proving test
runs-on: gpu
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Rustup toolchain install
uses: dtolnay/rust-toolchain@stable

- name: Set up Rust cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"

- name: RISC-V SP1 toolchain install
run: |
. "$HOME/.cargo/env"
curl -L https://sp1.succinct.xyz | bash
~/.sp1/bin/sp1up --version 4.1.7

- name: Build
run: |
cd crates/l2/prover/bench
cargo b -r --features "sp1,gpu"

- name: Run
env:
# TODO(): use RPC
# RPC_URL: $${{ secrets.ETHREX_L2_RPC_URL }}
RPC_URL: "dummy"
run: |
cp test_data/rpc_prover/cache_22240087.json crates/l2/prover/bench
cd crates/l2/prover/bench
make prove-sp1-gpu BLOCK_NUMBER=22240087

- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: "L1 block proving benchmark"
tool: "customBiggerIsBetter"
output-file-path: crates/l2/prover/bench/bench_latest.json
benchmark-data-dir-path: "."
# Access token to deploy GitHub Pages branch
github-token: ${{ secrets.GITHUB_TOKEN }}
# Push and deploy GitHub pages branch automatically
auto-push: true
comment-on-alert: true

- name: Ensure admin permissions in _work
if: always()
run: sudo chown admin:admin -R /home/admin/actions-runner/_work/

- name: Report Status
if: always()
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ job.status }}
notify_when: 'failure'
env:
SLACK_WEBHOOK_URL: ${{ secrets.ETHREX_L2_SLACK_WEBHOOK }}
81 changes: 77 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/l2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ integration-test: rm-db-l2 rm-db-l1
CI_ETHREX_WORKDIR=${CI_ETHREX_WORKDIR} docker compose -f ${ethrex_L2_DOCKER_COMPOSE_PATH} down
CI_ETHREX_WORKDIR=${CI_ETHREX_WORKDIR} docker compose -f ${ethrex_L2_DOCKER_COMPOSE_PATH} up --detach --build
RUST_LOG=info,ethrex_prover_lib=debug make init-prover & cargo test l2 --release -- --nocapture --test-threads=1
killall ethrex_prover
killall ethrex_prover -s SIGINT

integration-test-gpu: rm-db-l2 rm-db-l1
# We create an empty .env file simply because if the file
Expand All @@ -216,7 +216,7 @@ integration-test-gpu: rm-db-l2 rm-db-l1
CI_ETHREX_WORKDIR=${CI_ETHREX_WORKDIR} docker compose -f ${ethrex_L2_DOCKER_COMPOSE_PATH} down
CI_ETHREX_WORKDIR=${CI_ETHREX_WORKDIR} docker compose -f ${ethrex_L2_DOCKER_COMPOSE_PATH} up --detach --build
RUST_LOG=info,ethrex_prover_lib=debug SP1_PROVER=cuda make init-prover & cargo test l2 --release -- --nocapture --test-threads=1
killall ethrex_prover
killall ethrex_prover -s SIGINT # if sent a SIGTERM, SP1 does not shuts down the sp1-gpu container

# State reconstruction tests
state-diff-test:
Expand Down
1 change: 1 addition & 0 deletions crates/l2/prover/bench/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
cache_*.json
bench_latest.json
1 change: 1 addition & 0 deletions crates/l2/prover/bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ tokio-utils = "0.1.2"
again = "0.1.2"
lazy_static = "1.5.0"
bincode = "1.3.3"
machine-info = "1.0.9"

[features]
pico = ["zkvm_interface/pico", "ethrex-prover/pico"]
Expand Down
48 changes: 45 additions & 3 deletions crates/l2/prover/bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use ethrex_prover_bench::{
rpc::{db::RpcDB, get_block, get_latest_block_number},
};
use ethrex_prover_lib::execute;
use machine_info::Machine;
use serde_json::json;
use zkvm_interface::io::ProgramInput;

#[cfg(not(any(feature = "sp1", feature = "risc0", feature = "pico")))]
Expand Down Expand Up @@ -81,6 +83,7 @@ async fn main() {
};

let now = std::time::Instant::now();
let gas_used = block.header.gas_used as f64;
if prove {
println!("proving");
ethrex_prover_lib::prove(ProgramInput {
Expand All @@ -100,10 +103,49 @@ async fn main() {
}
let elapsed = now.elapsed().as_secs();
println!(
"finished in {} minutes for block {}",
"finished in {} minutes for block {} with gas {}",
elapsed / 60,
block_number
block_number,
gas_used
);

// TODO: Print total gas from pre-execution (to_exec_db() call)
write_benchmark_file(gas_used, elapsed as f64);
}

fn write_benchmark_file(gas_used: f64, elapsed: f64) {
let rate = gas_used / 10e6 / elapsed;

let backend = if cfg!(feature = "sp1") {
"SP1"
} else if cfg!(feature = "risc0") {
"Risc0"
} else if cfg!(feature = "pico") {
"Pico"
} else {
unreachable!();
};

let mut machine = Machine::new();
let processing_unit = if cfg!(feature = "gpu") {
// assumes single GPU
format!(
"GPU: {}",
machine
.system_info()
.graphics
.first()
.expect("could not write bench file: no gpu info found")
.name
)
} else {
format!("CPU: {}", machine.system_info().processor.brand)
};

let benchmark_json = &json!([{
"name": format!("{backend}, {processing_unit}"),
"unit": "Mgas/s",
"value": rate
}]);
let file = File::create("bench_latest.json").expect("failed to create bench_latest.json");
serde_json::to_writer(file, benchmark_json).expect("failed to write to bench_latest.json");
}
1 change: 1 addition & 0 deletions test_data/rpc_prover/cache_22240087.json

Large diffs are not rendered by default.

Loading