diff options
| author | Kamen Mladenov <kamen@syndamia.com> | 2025-04-30 17:25:15 +0300 |
|---|---|---|
| committer | Kamen Mladenov <kamen@syndamia.com> | 2025-05-02 15:32:54 +0300 |
| commit | eefb57f2c035be1a398f630dd8cfed8b4ccbe348 (patch) | |
| tree | 598cc4a5d784addf59bad7323018260b977ed6c2 /zkvms | |
| parent | 400c41f4f408aee6002489633914cd74ca888ff4 (diff) | |
| download | zkVMs-benchmarks-eefb57f2c035be1a398f630dd8cfed8b4ccbe348.tar zkVMs-benchmarks-eefb57f2c035be1a398f630dd8cfed8b4ccbe348.tar.gz zkVMs-benchmarks-eefb57f2c035be1a398f630dd8cfed8b4ccbe348.zip | |
feat(zkvms_guest_io): Output proof size
In each zkVM we'll write the size to /tmp/proof_size and then guest_io
will read that value and place it inside our metrics output. This is not
the most elegant, and in certain zkVMs the file output is a part of the
benchmark timing, but it will have to do.
Diffstat (limited to 'zkvms')
| -rw-r--r-- | zkvms/jolt/host/src/main.rs | 9 | ||||
| -rw-r--r-- | zkvms/nexus/host/src/main.rs | 7 | ||||
| -rw-r--r-- | zkvms/risc0/host/src/main.rs | 6 | ||||
| -rw-r--r-- | zkvms/sp1/host/src/main.rs | 8 | ||||
| -rw-r--r-- | zkvms/zkm/host/src/main.rs | 3 | ||||
| -rw-r--r-- | zkvms/zkwasm/host/src/main.rs | 7 |
6 files changed, 37 insertions, 3 deletions
diff --git a/zkvms/jolt/host/src/main.rs b/zkvms/jolt/host/src/main.rs index aa6b898..8bb3c86 100644 --- a/zkvms/jolt/host/src/main.rs +++ b/zkvms/jolt/host/src/main.rs @@ -1,6 +1,7 @@ use zkvms_host_io::{ benchmarkable, read_args, RunType::{Execute, Prove, Verify}, + output_proof_size, }; pub fn main() { @@ -16,11 +17,17 @@ pub fn main() { match run_info.run_type { Execute => unreachable!(), Prove => benchmarkable! { - let (output, _) = prove_guest(run_info.input.clone().into()); + let (output, proof) = prove_guest(run_info.input.clone().into()); + + output_proof_size(&proof); + println!("Prove output: {:?}", output); }, Verify => benchmarkable! { let (_, proof) = prove_guest(run_info.input.clone().into()); + + output_proof_size(&proof); + let is_valid = verify_guest(proof); println!("Verify is valid: {:?}", is_valid); }, diff --git a/zkvms/nexus/host/src/main.rs b/zkvms/nexus/host/src/main.rs index 9693d02..68593fc 100644 --- a/zkvms/nexus/host/src/main.rs +++ b/zkvms/nexus/host/src/main.rs @@ -2,6 +2,7 @@ use nexus_sdk::{stwo::seq::Stwo, Local, Prover, Verifiable, Viewable}; use zkvms_host_io::{ benchmarkable, read_args, Input, Return, RunType::{Execute, Prove, Verify}, + output_proof_size, }; fn main() { @@ -20,10 +21,12 @@ fn main() { let prover: Stwo<Local> = Stwo::new_from_file(&elf_path).expect("failed to load guest program"); println!("Proving execution of vm..."); - let (view, _) = prover + let (view, proof) = prover .prove_with_input(&run_info.private_input, &run_info.public_input) .expect("failed to prove program"); + output_proof_size(&proof); + println!( " output is {:?}!", view @@ -44,6 +47,8 @@ fn main() { .prove_with_input(&run_info.private_input, &run_info.public_input) .expect("failed to prove program"); + output_proof_size(&proof); + println!( " output is {:?}!", view.public_output::<Return>() diff --git a/zkvms/risc0/host/src/main.rs b/zkvms/risc0/host/src/main.rs index e61692b..78fd164 100644 --- a/zkvms/risc0/host/src/main.rs +++ b/zkvms/risc0/host/src/main.rs @@ -4,6 +4,7 @@ use risc0_zkvm::{default_executor, default_prover, ExecutorEnv, Receipt}; use zkvms_host_io::{ benchmarkable, foreach_input_field, read_args, Input, Output, RunType::{Execute, Prove, Verify}, + output_proof_size, }; // https://github.com/risc0/risc0/blob/881e512732eca72849b2d0e263a1242aba3158af/risc0/build/src/lib.rs#L280-L284 @@ -54,6 +55,9 @@ fn main() { // ExecutorEnv does not derive Clone let env = build_env(&run_info.input); let receipt = prove(env); + + output_proof_size(&receipt); + println!("Output from journal: {:?}", journal(receipt)); }, Verify => benchmarkable! { @@ -64,6 +68,8 @@ fn main() { let env = build_env(&run_info.input); let receipt = prove(env); + output_proof_size(&receipt); + let receipt = receipt.clone(); receipt.verify(guest_id.clone()).unwrap(); println!("Output from verify: {:?}", journal(receipt)); diff --git a/zkvms/sp1/host/src/main.rs b/zkvms/sp1/host/src/main.rs index 6d19000..a395247 100644 --- a/zkvms/sp1/host/src/main.rs +++ b/zkvms/sp1/host/src/main.rs @@ -2,6 +2,7 @@ use sp1_sdk::{EnvProver, ProverClient, SP1ProofWithPublicValues, SP1Stdin, SP1Ve use zkvms_host_io::{ benchmarkable, foreach_input_field, read_args, Input, RunType::{Execute, Prove, Verify}, + output_proof_size, }; /// The ELF (executable and linkable format) file for the Succinct RISC-V zkVM. @@ -40,13 +41,18 @@ fn main() { println!("Number of cycles: {}", report.total_instruction_count()); }, Prove => benchmarkable! { - let _ = prove(&client, stdin.clone()); + let (proof, _) = prove(&client, stdin.clone()); + + output_proof_size(&proof); + println!("Successfully generated proof!"); }, Verify => { let (proof, vk) = prove(&client, stdin.clone()); println!("Successfully generated proof!"); + output_proof_size(&proof); + benchmarkable! { client.verify(&proof, &vk).expect("failed to verify proof"); println!("Successfully verified proof!"); diff --git a/zkvms/zkm/host/src/main.rs b/zkvms/zkm/host/src/main.rs index 3b8d068..1640b30 100644 --- a/zkvms/zkm/host/src/main.rs +++ b/zkvms/zkm/host/src/main.rs @@ -9,6 +9,7 @@ use zkm_sdk::{ use zkvms_host_io::{ benchmarkable, read_args, RunType::{Execute, Prove, Verify}, + output_proof_size, }; async fn get_proof( @@ -40,6 +41,8 @@ async fn prove( ) { let prover_result = get_proof(prover_client, prover_input).await; + output_proof_size(&prover_result); + prover_client .process_proof_results(&prover_result, &prover_input, &proof_results_path) .expect("process proof results error"); diff --git a/zkvms/zkwasm/host/src/main.rs b/zkvms/zkwasm/host/src/main.rs index 288c3a5..6a23504 100644 --- a/zkvms/zkwasm/host/src/main.rs +++ b/zkvms/zkwasm/host/src/main.rs @@ -5,6 +5,7 @@ use zkvms_host_io::{ PrivateInput, PublicInput, RunType::{Execute, Prove, Verify}, RunWith, + output_proof_size_raw, }; static PUBLIC_INPUT_PATH: &str = "public_input.bin"; @@ -94,6 +95,9 @@ fn main() { .arg("--public").arg(public_input.clone()) .arg("--private").arg(private_input.clone()) .arg("--output").arg(output.clone())); + + let proofSize = std::fs::metadata(output.clone() + "/prog.0.transcript.data").unwrap().len(); + output_proof_size_raw(proofSize as usize); }, Verify => { run(zkwasm_command("prove") @@ -104,6 +108,9 @@ fn main() { .arg("--output") .arg(output.clone())); + let proofSize = std::fs::metadata(output.clone() + "/prog.0.transcript.data").unwrap().len(); + output_proof_size_raw(proofSize as usize); + benchmarkable! { run(Command::new("zkwasm-cli") .arg("--params").arg(params.clone()) |
