Skip to content

Commit

Permalink
Begin deprecation of Session::resolve (#1378) (#1379)
Browse files Browse the repository at this point in the history
* Drop `Session::resolve` convienence; this function doesn't scale
* Avoid using resolve to compute cycle counts and pre/post states
* Use docker feature flag for stark2snark test
  • Loading branch information
flaub committed Jan 26, 2024
1 parent f2e9dbe commit 75710b3
Show file tree
Hide file tree
Showing 40 changed files with 164 additions and 380 deletions.
7 changes: 0 additions & 7 deletions benchmarks/methods/guest/Cargo.lock

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

35 changes: 10 additions & 25 deletions benchmarks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::{
time::{Duration, Instant},
};

use risc0_zkvm::{sha::Digest, ExecutorEnv, ExecutorImpl, Receipt, Segment, Session};
use risc0_zkvm::{sha::Digest, ExecutorEnv, ExecutorImpl, Receipt, Session};
use serde::Serialize;
use tracing::info;

Expand All @@ -33,8 +33,8 @@ pub struct Metrics {
pub proof_duration: Duration,
pub total_duration: Duration,
pub verify_duration: Duration,
pub cycles: u32,
pub insn_cycles: u32,
pub cycles: u64,
pub insn_cycles: u64,
pub output_bytes: u32,
pub proof_bytes: u32,
}
Expand Down Expand Up @@ -118,7 +118,7 @@ impl Job {
self.input.len() as u32
}

fn exec_compute(&self) -> (Session, u32, u32, Duration) {
fn exec_compute(&self) -> (Session, Duration) {
let env = ExecutorEnv::builder()
.write_slice(&self.input)
.build()
Expand All @@ -127,9 +127,7 @@ impl Job {
let start = Instant::now();
let session = exec.run().unwrap();
let elapsed = start.elapsed();
let segments = session.resolve().unwrap();
let (exec_cycles, prove_cycles) = get_cycles(segments);
(session, prove_cycles as u32, exec_cycles as u32, elapsed)
(session, elapsed)
}

fn verify_proof(&self, receipt: &Receipt) -> bool {
Expand All @@ -145,10 +143,10 @@ impl Job {
fn run(&self) -> Metrics {
let mut metrics = Metrics::new(self.name.clone(), self.job_size());

let (session, cycles, insn_cycles, duration) = self.exec_compute();
let (session, duration) = self.exec_compute();

metrics.cycles = cycles;
metrics.insn_cycles = insn_cycles;
metrics.cycles = session.total_cycles;
metrics.insn_cycles = session.user_cycles;
metrics.exec_duration = duration;

let receipt = {
Expand Down Expand Up @@ -186,19 +184,6 @@ pub fn get_image(path: &str) -> Vec<u8> {
std::fs::read(path).unwrap()
}

pub fn get_cycles(segments: Vec<Segment>) -> (u32, u32) {
let (exec_cycles, prove_cycles) =
segments
.iter()
.fold((0, 0), |(exec_cycles, prove_cycles), segment| {
(
exec_cycles + segment.cycles,
prove_cycles + (1 << segment.po2),
)
});
(prove_cycles as u32, exec_cycles as u32)
}

pub fn init_logging() {
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::filter::EnvFilter::from_default_env())
Expand All @@ -214,8 +199,8 @@ struct CsvRow<'a> {
proof_duration: u128,
total_duration: u128,
verify_duration: u128,
insn_cycles: u32,
prove_cycles: u32,
insn_cycles: u64,
prove_cycles: u64,
proof_bytes: u32,
}

Expand Down
7 changes: 0 additions & 7 deletions bonsai/examples/governance/methods/guest/Cargo.lock

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

6 changes: 3 additions & 3 deletions compact_proof/seal_to_json/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ fn stark2snark() {
tracing::info!("execute");
let mut exec = ExecutorImpl::from_elf(env, MULTI_TEST_ELF).unwrap();
let session = exec.run().unwrap();
let segments = session.resolve().unwrap();
assert_eq!(segments.len(), 1);
assert_eq!(session.segments.len(), 1);
let segment = session.segments.first().unwrap().resolve().unwrap();

tracing::info!("prove");
let opts = ProverOpts::default();
let ctx = VerifierContext::default();
let prover = get_prover_server(&opts).unwrap();
let segment_receipt = prover.prove_segment(&ctx, &segments[0]).unwrap();
let segment_receipt = prover.prove_segment(&ctx, &segment).unwrap();

tracing::info!("lift");
let lift_receipt = lift(&segment_receipt).unwrap();
Expand Down
7 changes: 0 additions & 7 deletions examples/bevy/methods/guest/Cargo.lock

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

7 changes: 0 additions & 7 deletions examples/chess/methods/guest/Cargo.lock

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

7 changes: 0 additions & 7 deletions examples/composition/methods/guest/Cargo.lock

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

7 changes: 0 additions & 7 deletions examples/digital-signature/methods/guest/Cargo.lock

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

7 changes: 0 additions & 7 deletions examples/ecdsa/methods/guest/Cargo.lock

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

7 changes: 0 additions & 7 deletions examples/groth16-verifier/methods/guest/Cargo.lock

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

7 changes: 0 additions & 7 deletions examples/hello-world/methods/guest/Cargo.lock

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

7 changes: 0 additions & 7 deletions examples/json/methods/guest/Cargo.lock

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

7 changes: 0 additions & 7 deletions examples/jwt-validator/methods/guest/Cargo.lock

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

7 changes: 0 additions & 7 deletions examples/password-checker/methods/guest/Cargo.lock

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

7 changes: 0 additions & 7 deletions examples/profiling/methods/guest/Cargo.lock

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

7 changes: 0 additions & 7 deletions examples/prorata/methods/guest/Cargo.lock

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

0 comments on commit 75710b3

Please sign in to comment.