Skip to content

Commit 193afc6

Browse files
committed
Recover test
1 parent 9e6aec0 commit 193afc6

File tree

5 files changed

+113
-73
lines changed

5 files changed

+113
-73
lines changed

Cargo.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
# openvm = { git = "https://github.com/scroll-tech/openvm.git", default-features = false }
8-
# openvm-circuit = { git = "https://github.com/scroll-tech/openvm.git", default-features = false, features = ["bench-metrics"] }
9-
# openvm-native-circuit = { git = "https://github.com/scroll-tech/openvm.git", default-features = false }
10-
# openvm-native-compiler = { git = "https://github.com/scroll-tech/openvm.git", default-features = false }
11-
# openvm-native-compiler-derive = { git = "https://github.com/scroll-tech/openvm.git", default-features = false }
12-
# openvm-native-recursion = { git = "https://github.com/scroll-tech/openvm.git", default-features = false }
7+
openvm = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/native_sumcheck_layer_eval", default-features = false }
8+
openvm-circuit = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/native_sumcheck_layer_eval", default-features = false, features = ["bench-metrics"] }
9+
openvm-native-circuit = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/native_sumcheck_layer_eval", default-features = false }
10+
openvm-native-compiler = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/native_sumcheck_layer_eval", default-features = false }
11+
openvm-native-compiler-derive = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/native_sumcheck_layer_eval", default-features = false }
12+
openvm-native-recursion = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/native_sumcheck_layer_eval", default-features = false }
1313

14-
openvm = { path = "../openvm-scroll-tech/crates/toolchain/openvm", default-features = false }
15-
openvm-circuit = { path = "../openvm-scroll-tech/crates/vm", default-features = false, features = ["bench-metrics"] }
16-
openvm-native-circuit = { path = "../openvm-scroll-tech/extensions/native/circuit", default-features = false }
17-
openvm-native-compiler = { path = "../openvm-scroll-tech/extensions/native/compiler", default-features = false }
18-
openvm-native-compiler-derive = { path = "../openvm-scroll-tech/extensions/native/compiler/derive", default-features = false }
19-
openvm-native-recursion = { path = "../openvm-scroll-tech/extensions/native/recursion", default-features = false }
14+
# openvm = { path = "../openvm-scroll-tech/crates/toolchain/openvm", default-features = false }
15+
# openvm-circuit = { path = "../openvm-scroll-tech/crates/vm", default-features = false, features = ["bench-metrics"] }
16+
# openvm-native-circuit = { path = "../openvm-scroll-tech/extensions/native/circuit", default-features = false }
17+
# openvm-native-compiler = { path = "../openvm-scroll-tech/extensions/native/compiler", default-features = false }
18+
# openvm-native-compiler-derive = { path = "../openvm-scroll-tech/extensions/native/compiler/derive", default-features = false }
19+
# openvm-native-recursion = { path = "../openvm-scroll-tech/extensions/native/recursion", default-features = false }
2020

2121
openvm-stark-backend = { git = "https://github.com/openvm-org/stark-backend.git", tag = "v1.1.1", default-features = false }
2222
openvm-stark-sdk = { git = "https://github.com/openvm-org/stark-backend.git", tag = "v1.1.1", default-features = false }

src/e2e/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ mod tests {
403403
println!("=> segment {:?} metrics: {:?}", i, seg.metrics);
404404
}
405405

406-
/* _debug: temp disable
407406
let poseidon2_max_constraint_degree = 3;
408407
let log_blowup = 1;
409408

@@ -430,7 +429,6 @@ mod tests {
430429
for proof in proofs {
431430
verify_single(&vm.engine, &pk.get_vk(), &proof).expect("Verification failed");
432431
}
433-
*/
434432
}
435433

436434
#[test]

src/tower_verifier/program.rs

Lines changed: 82 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,10 @@ pub fn verify_tower_proof<C: Config>(
319319
eval: initial_claim,
320320
};
321321

322-
let next_layer_evals_output_len: Usize<C::N> = builder.eval(Usize::from(1) + num_prod_spec.clone() + Usize::from(2) * num_logup_spec.clone());
323-
let next_layer_evals: Array<C, Ext<C::F, C::EF>> = builder.dyn_array(next_layer_evals_output_len);
322+
let next_layer_evals_output_len: Usize<C::N> = builder
323+
.eval(Usize::from(1) + num_prod_spec.clone() + Usize::from(2) * num_logup_spec.clone());
324+
let next_layer_evals: Array<C, Ext<C::F, C::EF>> =
325+
builder.dyn_array(next_layer_evals_output_len);
324326

325327
builder
326328
.range(0, op_range.clone())
@@ -360,22 +362,46 @@ pub fn verify_tower_proof<C: Config>(
360362
builder.set(&input_ctx, 0, round_var);
361363
builder.set(&input_ctx, 1, num_prod_spec.clone());
362364
builder.set(&input_ctx, 2, num_logup_spec.clone());
363-
builder.set(&input_ctx, 3, Usize::from(proof.prod_specs_eval.inner_length));
364-
builder.set(&input_ctx, 4, Usize::from(proof.prod_specs_eval.inner_inner_length));
365-
builder.set(&input_ctx, 5, Usize::from(proof.logup_specs_eval.inner_length));
366-
builder.set(&input_ctx, 6, Usize::from(proof.logup_specs_eval.inner_inner_length));
365+
builder.set(
366+
&input_ctx,
367+
3,
368+
Usize::from(proof.prod_specs_eval.inner_length),
369+
);
370+
builder.set(
371+
&input_ctx,
372+
4,
373+
Usize::from(proof.prod_specs_eval.inner_inner_length),
374+
);
375+
builder.set(
376+
&input_ctx,
377+
5,
378+
Usize::from(proof.logup_specs_eval.inner_length),
379+
);
380+
builder.set(
381+
&input_ctx,
382+
6,
383+
Usize::from(proof.logup_specs_eval.inner_inner_length),
384+
);
367385
builder.set(&input_ctx, 7, Usize::from(1));
368386

369387
let input_ctx_variables_slice = input_ctx.slice(builder, 8, input_ctx.len());
370-
iter_zip!(builder, input_ctx_variables_slice, num_variables).for_each(|ptr_vec, builder| {
371-
let n_v = builder.iter_ptr_get(&num_variables, ptr_vec[1]);
372-
builder.iter_ptr_set(&input_ctx_variables_slice, ptr_vec[0], n_v);
373-
});
388+
iter_zip!(builder, input_ctx_variables_slice, num_variables).for_each(
389+
|ptr_vec, builder| {
390+
let n_v = builder.iter_ptr_get(&num_variables, ptr_vec[1]);
391+
builder.iter_ptr_set(&input_ctx_variables_slice, ptr_vec[0], n_v);
392+
},
393+
);
374394

375395
let challenges: Array<C, Ext<C::F, C::EF>> = builder.dyn_array(3);
376396
builder.set(&challenges, 0, alpha.clone());
377397

378-
builder.sumcheck_layer_eval(&input_ctx, &challenges, &proof.prod_specs_eval.data, &proof.logup_specs_eval.data, &next_layer_evals);
398+
builder.sumcheck_layer_eval(
399+
&input_ctx,
400+
&challenges,
401+
&proof.prod_specs_eval.data,
402+
&proof.logup_specs_eval.data,
403+
&next_layer_evals,
404+
);
379405
let expected_evaluation = builder.get(&next_layer_evals, 0);
380406

381407
builder.assign(&expected_evaluation, expected_evaluation * eq_e);
@@ -405,12 +431,18 @@ pub fn verify_tower_proof<C: Config>(
405431
builder.assign(&alpha, new_alpha);
406432

407433
// Use native opcode
408-
builder.set(&input_ctx, 7, Usize::from(0)); // Turn `in_round` off
434+
builder.set(&input_ctx, 7, Usize::from(0)); // Turn `in_round` off
409435
builder.set(&challenges, 0, new_alpha.clone());
410436
builder.set(&challenges, 1, c1.clone());
411437
builder.set(&challenges, 2, c2.clone());
412438

413-
builder.sumcheck_layer_eval(&input_ctx, &challenges, &proof.prod_specs_eval.data, &proof.logup_specs_eval.data, &next_layer_evals);
439+
builder.sumcheck_layer_eval(
440+
&input_ctx,
441+
&challenges,
442+
&proof.prod_specs_eval.data,
443+
&proof.logup_specs_eval.data,
444+
&next_layer_evals,
445+
);
414446

415447
let next_round = builder.eval_expr(round_var + RVar::from(1));
416448
builder
@@ -423,25 +455,19 @@ pub fn verify_tower_proof<C: Config>(
423455

424456
// now skip is 0 if and only if current round_var is smaller than round_limit.
425457
builder.if_eq(skip, var_zero.clone()).then(|builder| {
426-
builder.if_eq(next_round, round_limit).then(
427-
|builder| {
428-
let evals_idx: Usize<C::N> = builder.eval(spec_index + Usize::from(1));
429-
let evals = builder.get(&next_layer_evals, evals_idx);
430-
431-
let point_and_eval: PointAndEvalVariable<C> =
432-
builder.eval(PointAndEvalVariable {
433-
point: PointVariable {
434-
fs: rt_prime.clone(),
435-
},
436-
eval: evals,
437-
});
438-
builder.set_value(
439-
&prod_spec_point_n_eval,
440-
spec_index,
441-
point_and_eval,
442-
);
443-
}
444-
);
458+
builder.if_eq(next_round, round_limit).then(|builder| {
459+
let evals_idx: Usize<C::N> = builder.eval(spec_index + Usize::from(1));
460+
let evals = builder.get(&next_layer_evals, evals_idx);
461+
462+
let point_and_eval: PointAndEvalVariable<C> =
463+
builder.eval(PointAndEvalVariable {
464+
point: PointVariable {
465+
fs: rt_prime.clone(),
466+
},
467+
eval: evals,
468+
});
469+
builder.set_value(&prod_spec_point_n_eval, spec_index, point_and_eval);
470+
});
445471
});
446472
});
447473

@@ -460,31 +486,30 @@ pub fn verify_tower_proof<C: Config>(
460486

461487
// now skip is 0 if and only if current round_var is smaller than round_limit.
462488
builder.if_eq(skip, var_zero).then(|builder| {
463-
builder.if_eq(next_round, round_limit).then(
464-
|builder| {
465-
let p_idx: Usize<C::N> = builder.eval(idx + Usize::from(1));
466-
let q_idx: Usize<C::N> = builder.eval(idx + Usize::from(1) + num_logup_spec.clone());
467-
let p_eval = builder.get(&next_layer_evals, p_idx);
468-
let q_eval = builder.get(&next_layer_evals, q_idx);
469-
470-
let p_eval: PointAndEvalVariable<C> =
471-
builder.eval(PointAndEvalVariable {
472-
point: PointVariable {
473-
fs: rt_prime.clone(),
474-
},
475-
eval: p_eval,
476-
});
477-
let q_eval: PointAndEvalVariable<C> =
478-
builder.eval(PointAndEvalVariable {
479-
point: PointVariable {
480-
fs: rt_prime.clone(),
481-
},
482-
eval: q_eval,
483-
});
484-
builder.set_value(&logup_spec_p_point_n_eval, spec_index, p_eval);
485-
builder.set_value(&logup_spec_q_point_n_eval, spec_index, q_eval);
486-
}
487-
);
489+
builder.if_eq(next_round, round_limit).then(|builder| {
490+
let p_idx: Usize<C::N> = builder.eval(idx + Usize::from(1));
491+
let q_idx: Usize<C::N> =
492+
builder.eval(idx + Usize::from(1) + num_logup_spec.clone());
493+
let p_eval = builder.get(&next_layer_evals, p_idx);
494+
let q_eval = builder.get(&next_layer_evals, q_idx);
495+
496+
let p_eval: PointAndEvalVariable<C> =
497+
builder.eval(PointAndEvalVariable {
498+
point: PointVariable {
499+
fs: rt_prime.clone(),
500+
},
501+
eval: p_eval,
502+
});
503+
let q_eval: PointAndEvalVariable<C> =
504+
builder.eval(PointAndEvalVariable {
505+
point: PointVariable {
506+
fs: rt_prime.clone(),
507+
},
508+
eval: q_eval,
509+
});
510+
builder.set_value(&logup_spec_p_point_n_eval, spec_index, p_eval);
511+
builder.set_value(&logup_spec_q_point_n_eval, spec_index, q_eval);
512+
});
488513
});
489514
});
490515

src/zkvm_verifier/verifier.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ pub fn verify_zkvm_proof<C: Config<F = F>>(
219219
});
220220

221221
// _debug
222-
// for (i, (circuit_name, chip_vk)) in vk.circuit_vks.iter().enumerate() {
223-
for (i, (circuit_name, chip_vk)) in vk.circuit_vks.iter().take(100).enumerate() {
222+
for (i, (circuit_name, chip_vk)) in vk.circuit_vks.iter().enumerate() {
224223
// _debug
225224
println!("=> circuit_name: {:?}", circuit_name);
226225

0 commit comments

Comments
 (0)