diff --git a/benches/end2end.rs b/benches/end2end.rs index 078450bbe9..9f0b704f73 100644 --- a/benches/end2end.rs +++ b/benches/end2end.rs @@ -84,7 +84,7 @@ fn end2end_benchmark(c: &mut Criterion) { group.bench_with_input(benchmark_id, &size, |b, &s| { b.iter(|| { let ptr = go_base::(&store, state.clone(), s.0, s.1); - let (frames, _) = evaluate::>(None, ptr, &store, limit).unwrap(); + let frames = evaluate::>(None, ptr, &store, limit).unwrap(); let _result = prover.prove(&pp, &frames, &store).unwrap(); }) }); @@ -251,7 +251,7 @@ fn prove_benchmark(c: &mut Criterion) { let ptr = go_base::(&store, state.clone(), s.0, s.1); let prover: NovaProver<'_, Fq, Coproc, MultiFrame<'_, Fq, Coproc>> = NovaProver::new(reduction_count, lang_pallas_rc.clone()); - let (frames, _) = evaluate::>(None, ptr, &store, limit).unwrap(); + let frames = evaluate::>(None, ptr, &store, limit).unwrap(); b.iter(|| { let result = prover.prove(&pp, &frames, &store).unwrap(); @@ -298,7 +298,7 @@ fn prove_compressed_benchmark(c: &mut Criterion) { group.bench_with_input(benchmark_id, &size, |b, &s| { let ptr = go_base::(&store, state.clone(), s.0, s.1); let prover = NovaProver::new(reduction_count, lang_pallas_rc.clone()); - let (frames, _) = evaluate::>(None, ptr, &store, limit).unwrap(); + let frames = evaluate::>(None, ptr, &store, limit).unwrap(); b.iter(|| { let (proof, _, _, _) = prover.prove(&pp, &frames, &store).unwrap(); @@ -344,7 +344,7 @@ fn verify_benchmark(c: &mut Criterion) { group.bench_with_input(benchmark_id, &size, |b, &s| { let ptr = go_base(&store, state.clone(), s.0, s.1); let prover = NovaProver::new(reduction_count, lang_pallas_rc.clone()); - let (frames, _) = evaluate::>(None, ptr, &store, limit).unwrap(); + let frames = evaluate::>(None, ptr, &store, limit).unwrap(); let (proof, z0, zi, num_steps) = prover.prove(&pp, &frames, &store).unwrap(); b.iter_batched( @@ -396,7 +396,7 @@ fn verify_compressed_benchmark(c: &mut Criterion) { group.bench_with_input(benchmark_id, &size, |b, &s| { let ptr = go_base(&store, state.clone(), s.0, s.1); let prover = NovaProver::new(reduction_count, lang_pallas_rc.clone()); - let (frames, _) = evaluate::>(None, ptr, &store, limit).unwrap(); + let frames = evaluate::>(None, ptr, &store, limit).unwrap(); let (proof, z0, zi, num_steps) = prover.prove(&pp, &frames, &store).unwrap(); let compressed_proof = proof.compress(&pp).unwrap(); diff --git a/benches/fibonacci.rs b/benches/fibonacci.rs index b803700017..35cdb0e6c8 100644 --- a/benches/fibonacci.rs +++ b/benches/fibonacci.rs @@ -142,8 +142,7 @@ fn fibonacci_prove( let frames = &evaluate::>(None, ptr, &store, limit) - .unwrap() - .0; + .unwrap(); b.iter_batched( || frames, diff --git a/benches/sha256.rs b/benches/sha256.rs index a9ad6b5b03..c09d7967f6 100644 --- a/benches/sha256.rs +++ b/benches/sha256.rs @@ -134,9 +134,7 @@ fn sha256_ivc_prove( let prover = NovaProver::new(prove_params.reduction_count, lang_rc.clone()); - let frames = &evaluate(Some((&lurk_step, &lang)), ptr, store, limit) - .unwrap() - .0; + let frames = &evaluate(Some((&lurk_step, &lang)), ptr, store, limit).unwrap(); b.iter_batched( || frames, @@ -217,9 +215,7 @@ fn sha256_ivc_prove_compressed( let prover = NovaProver::new(prove_params.reduction_count, lang_rc.clone()); - let frames = &evaluate(Some((&lurk_step, &lang)), ptr, store, limit) - .unwrap() - .0; + let frames = &evaluate(Some((&lurk_step, &lang)), ptr, store, limit).unwrap(); b.iter_batched( || frames, @@ -302,9 +298,7 @@ fn sha256_nivc_prove( let prover = SuperNovaProver::new(prove_params.reduction_count, lang_rc.clone()); - let frames = &evaluate(Some((&lurk_step, &lang)), ptr, store, limit) - .unwrap() - .0; + let frames = &evaluate(Some((&lurk_step, &lang)), ptr, store, limit).unwrap(); b.iter_batched( || frames, diff --git a/benches/synthesis.rs b/benches/synthesis.rs index cd1c6e6be0..da264cac8a 100644 --- a/benches/synthesis.rs +++ b/benches/synthesis.rs @@ -50,7 +50,7 @@ fn synthesize( let store = Store::default(); let fib_n = (reduction_count / 3) as u64; // Heuristic, since one fib is 35 iterations. let ptr = fib::(&store, state.clone(), black_box(fib_n)); - let (frames, _) = evaluate::>(None, ptr, &store, limit).unwrap(); + let frames = evaluate::>(None, ptr, &store, limit).unwrap(); let folding_config = Arc::new(FoldingConfig::new_ivc(lang_rc.clone(), *reduction_count)); diff --git a/examples/sha256_nivc.rs b/examples/sha256_nivc.rs index 446740c510..ffb256da74 100644 --- a/examples/sha256_nivc.rs +++ b/examples/sha256_nivc.rs @@ -77,7 +77,7 @@ fn main() { let lang_rc = Arc::new(lang.clone()); let lurk_step = make_eval_step_from_config(&EvalConfig::new_nivc(&lang)); - let (frames, _) = evaluate(Some((&lurk_step, &lang)), call, store, 1000).unwrap(); + let frames = evaluate(Some((&lurk_step, &lang)), call, store, 1000).unwrap(); let supernova_prover = SuperNovaProver::, MultiFrame<'_, _, _>>::new( REDUCTION_COUNT, diff --git a/src/cli/repl/meta_cmd.rs b/src/cli/repl/meta_cmd.rs index 409c3c8baf..b361a980a9 100644 --- a/src/cli/repl/meta_cmd.rs +++ b/src/cli/repl/meta_cmd.rs @@ -1047,7 +1047,7 @@ impl MetaCmd { Self::post_verify_check(repl, post_verify)?; - let (frames, iterations) = evaluate_with_env_and_cont::>( + let frames = evaluate_with_env_and_cont::>( None, cek_io[0], cek_io[1], @@ -1056,6 +1056,8 @@ impl MetaCmd { repl.limit, )?; + let iterations = frames.len(); + { // making sure the output matches expectation before proving let res = &frames.last().expect("frames can't be empty").output; diff --git a/src/cli/repl/mod.rs b/src/cli/repl/mod.rs index b64fbf187b..851962e04f 100644 --- a/src/cli/repl/mod.rs +++ b/src/cli/repl/mod.rs @@ -430,9 +430,10 @@ impl Repl { } fn eval_expr_and_memoize(&mut self, expr_ptr: Ptr) -> Result<(Vec, usize)> { - let (frames, iterations) = + let frames = evaluate_with_env::>(None, expr_ptr, self.env, &self.store, self.limit)?; - let output = frames[frames.len() - 1].output.clone(); + let iterations = frames.len(); + let output = frames[iterations - 1].output.clone(); self.evaluation = Some(Evaluation { frames, iterations }); Ok((output, iterations)) } diff --git a/src/lem/eval.rs b/src/lem/eval.rs index 869bee6b4e..ce64d6cd89 100644 --- a/src/lem/eval.rs +++ b/src/lem/eval.rs @@ -92,7 +92,7 @@ fn build_frames< limit: usize, lang: &Lang, log_fmt: LogFmt, -) -> Result<(Vec, usize)> { +) -> Result> { let mut pc = 0; let mut frames = vec![]; let mut iterations = 0; @@ -113,7 +113,7 @@ fn build_frames< } pc = get_pc(&expr, store, lang); } - Ok((frames, iterations)) + Ok(frames) } /// Faster version of `build_frames` that doesn't accumulate frames @@ -150,7 +150,7 @@ pub fn evaluate_with_env_and_cont>( cont: Ptr, store: &Store, limit: usize, -) -> Result<(Vec, usize)> { +) -> Result> { let state = initial_lurk_state(); let log_fmt = |i: usize, inp: &[Ptr], emit: &[Ptr], store: &Store| { let mut out = format!( @@ -186,7 +186,7 @@ pub fn evaluate_with_env>( env: Ptr, store: &Store, limit: usize, -) -> Result<(Vec, usize)> { +) -> Result> { evaluate_with_env_and_cont(func_lang, expr, env, store.cont_outermost(), store, limit) } @@ -196,7 +196,7 @@ pub fn evaluate>( expr: Ptr, store: &Store, limit: usize, -) -> Result<(Vec, usize)> { +) -> Result> { evaluate_with_env_and_cont( func_lang, expr, diff --git a/src/lem/multiframe.rs b/src/lem/multiframe.rs index 29cf57080d..f8c4e2640c 100644 --- a/src/lem/multiframe.rs +++ b/src/lem/multiframe.rs @@ -669,17 +669,8 @@ impl<'a, F: LurkField, C: Coprocessor + 'a> MultiFrameTrait<'a, F, C> for Mul ) -> Result, ProofError> { let cont = store.cont_outermost(); let lurk_step = make_eval_step_from_config(ec); - match evaluate_with_env_and_cont( - Some((&lurk_step, ec.lang())), - expr, - env, - cont, - store, - limit, - ) { - Ok((frames, _)) => Ok(frames), - Err(e) => Err(ProofError::Reduction(ReductionError::Misc(e.to_string()))), - } + evaluate_with_env_and_cont(Some((&lurk_step, ec.lang())), expr, env, cont, store, limit) + .map_err(|e| ProofError::Reduction(ReductionError::Misc(e.to_string()))) } fn significant_frame_count(frames: &[Self::EvalFrame]) -> usize { @@ -988,7 +979,7 @@ mod tests { let expr = store.read_with_default_state("(if t (+ 5 5) 6)").unwrap(); - let (frames, _) = evaluate::>(None, expr, &store, 10).unwrap(); + let frames = evaluate::>(None, expr, &store, 10).unwrap(); let sequential_slots_witnesses = generate_slots_witnesses(&store, &frames, num_slots_per_frame, false); @@ -1095,7 +1086,7 @@ mod tests { let expr = store.read_with_default_state("(+ 1 2)").unwrap(); let lang = Arc::new(Lang::>::new()); - let (mut frames, _) = evaluate::>(None, expr, &store, 1).unwrap(); + let mut frames = evaluate::>(None, expr, &store, 1).unwrap(); assert_eq!(frames.len(), 1); let mut frame = frames.pop().unwrap(); diff --git a/src/lem/tests/nivc_steps.rs b/src/lem/tests/nivc_steps.rs index 39eac8bd88..64b3e11ba4 100644 --- a/src/lem/tests/nivc_steps.rs +++ b/src/lem/tests/nivc_steps.rs @@ -31,7 +31,7 @@ fn test_nivc_steps() { // 9^2 + 8 = 89 let expr = store.read_with_default_state("(cproc-dumb 9 8)").unwrap(); - let (frames, _) = evaluate(Some((&lurk_step, &lang)), expr, &store, 10).unwrap(); + let frames = evaluate(Some((&lurk_step, &lang)), expr, &store, 10).unwrap(); // Iteration 1: evaluate first argument // Iteration 2: evaluate second argument