From 3bdd69549901456b69c3d52a0f4f0aa80b264082 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Sat, 24 May 2025 21:35:27 +0100 Subject: [PATCH 1/3] refine API --- crates/benchmark-runner/src/lib.rs | 41 ++++++++++++++++++++++-------- crates/ere-hosts/src/main.rs | 22 +++++++++------- 2 files changed, 44 insertions(+), 19 deletions(-) diff --git a/crates/benchmark-runner/src/lib.rs b/crates/benchmark-runner/src/lib.rs index 78f7cb8f..7a4d0d2b 100644 --- a/crates/benchmark-runner/src/lib.rs +++ b/crates/benchmark-runner/src/lib.rs @@ -39,7 +39,13 @@ where }); } -pub fn run_benchmark_ere(host_name: &str, zkvm_instance: V) -> Result<()> +/// Action specifies whether we should prove or execute +pub enum Action { + Prove, + Execute, +} + +pub fn run_benchmark_ere(host_name: &str, zkvm_instance: V, action: Action) -> Result<()> where // C: Compiler + Send + Sync, // C::Error: std::error::Error + Send + Sync + 'static, @@ -65,15 +71,30 @@ where stdin.write(ci); stdin.write(bw.network); - let report = zkvm_ref.execute(&stdin)?; - let region_cycles: HashMap<_, _> = report.region_cycles.into_iter().collect(); - - reports.push(WorkloadMetrics { - name: format!("{}-{}", bw.name, block_number), - total_num_cycles: report.total_num_cycles, - region_cycles, - proving_time_ms: 0, - }); + let workload_metrics = match action { + Action::Execute => { + let report = zkvm_ref.execute(&stdin)?; + let region_cycles: HashMap<_, _> = report.region_cycles.into_iter().collect(); + WorkloadMetrics { + name: format!("{}-{}", bw.name, block_number), + total_num_cycles: report.total_num_cycles, + region_cycles, + proving_time_ms: 0, + } + } + Action::Prove => { + let (proof, report) = zkvm_ref.prove(&stdin)?; + + WorkloadMetrics { + name: format!("{}-{}", bw.name, block_number), + total_num_cycles: 0, + region_cycles: Default::default(), + proving_time_ms: report.proving_time, + } + } + }; + + reports.push(workload_metrics); } let out_path = format!( diff --git a/crates/ere-hosts/src/main.rs b/crates/ere-hosts/src/main.rs index 0ea12b08..b9a4bee6 100644 --- a/crates/ere-hosts/src/main.rs +++ b/crates/ere-hosts/src/main.rs @@ -2,31 +2,35 @@ use std::path::PathBuf; -use benchmark_runner::run_benchmark_ere; +use benchmark_runner::{Action, run_benchmark_ere}; use ere_risczero::{EreRisc0, RV32_IM_RISCZERO_ZKVM_ELF}; use ere_sp1::{EreSP1, RV32_IM_SUCCINCT_ZKVM_ELF}; use zkvm_interface::{Compiler, ProverResourceType}; /// Main entry point for the host benchmarker fn main() -> Result<(), Box> { - let sp1_zkvm = new_sp1_zkvm()?; - run_benchmark_ere("sp1", sp1_zkvm)?; + let resource = ProverResourceType::Cpu; + let sp1_zkvm = new_sp1_zkvm(resource)?; + let action = Action::Execute; + run_benchmark_ere("sp1", sp1_zkvm, action)?; - let risc0_zkvm = new_risczero_zkvm()?; - run_benchmark_ere("risc0", risc0_zkvm)?; + let resource = ProverResourceType::Cpu; + let risc0_zkvm = new_risczero_zkvm(resource)?; + let action = Action::Execute; + run_benchmark_ere("risc0", risc0_zkvm, action)?; // TODO: Add more backends Ok(()) } -fn new_sp1_zkvm() -> Result> { - let prover_resource = ProverResourceType::Cpu; +fn new_sp1_zkvm(prover_resource: ProverResourceType) -> Result> { let guest_dir = concat!(env!("CARGO_WORKSPACE_DIR"), "ere-guests/sp1"); let program = RV32_IM_SUCCINCT_ZKVM_ELF::compile(&PathBuf::from(guest_dir))?; Ok(EreSP1::new(program, prover_resource)) } -fn new_risczero_zkvm() -> Result> { - let prover_resource = ProverResourceType::Cpu; +fn new_risczero_zkvm( + prover_resource: ProverResourceType, +) -> Result> { let guest_dir = concat!(env!("CARGO_WORKSPACE_DIR"), "ere-guests/risc0"); let program = RV32_IM_RISCZERO_ZKVM_ELF::compile(&PathBuf::from(guest_dir))?; Ok(EreRisc0::new(program, prover_resource)) From 27e87dd1cb63678f49e7d9cc266eb6d84878b63b Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Sat, 24 May 2025 21:37:53 +0100 Subject: [PATCH 2/3] .as_millis --- crates/benchmark-runner/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/benchmark-runner/src/lib.rs b/crates/benchmark-runner/src/lib.rs index 7a4d0d2b..9635ac47 100644 --- a/crates/benchmark-runner/src/lib.rs +++ b/crates/benchmark-runner/src/lib.rs @@ -89,7 +89,7 @@ where name: format!("{}-{}", bw.name, block_number), total_num_cycles: 0, region_cycles: Default::default(), - proving_time_ms: report.proving_time, + proving_time_ms: report.proving_time.as_millis(), } } }; From cb1da669332a8e8f42a375c05c56144c17e704b4 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Sat, 24 May 2025 21:40:15 +0100 Subject: [PATCH 3/3] use u128 --- crates/metrics/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/metrics/src/lib.rs b/crates/metrics/src/lib.rs index 806515d1..7db78a02 100644 --- a/crates/metrics/src/lib.rs +++ b/crates/metrics/src/lib.rs @@ -16,7 +16,7 @@ pub struct WorkloadMetrics { /// Region-specific cycles, mapping region names (e.g., "setup", "compute") to their cycle counts. pub region_cycles: HashMap, /// Proving time in milliseconds - pub proving_time_ms: u64, + pub proving_time_ms: u128, } /// Errors that can occur during metrics processing.