Skip to content

Commit 9ac474e

Browse files
stephenh-axiom-xyzjonathanpwang
authored andcommitted
test: add e2e deferral test (#2481)
1 parent 5ed031e commit 9ac474e

File tree

13 files changed

+837
-151
lines changed

13 files changed

+837
-151
lines changed

Cargo.lock

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

crates/continuations-v2/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ openvm-cuda-backend = { workspace = true, optional = true }
3232
[dev-dependencies]
3333
openvm-rv32im-circuit = { workspace = true, features = ["test-utils"] }
3434
openvm-rv32im-transpiler = { workspace = true }
35+
openvm-deferral-circuit = { workspace = true }
36+
openvm-deferral-transpiler = { workspace = true }
37+
openvm-instructions = { workspace = true }
3538
openvm-toolchain-tests = { workspace = true }
3639
openvm-transpiler = { workspace = true }
3740
test-case = { workspace = true }

crates/continuations-v2/programs/Cargo.lock

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

crates/continuations-v2/programs/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
[workspace]
22
[package]
3-
name = "openvm-continautions-test-programs"
3+
name = "openvm-continuations-test-programs"
44
version = "0.0.0"
55
edition = "2021"
66

77
[dependencies]
8-
openvm = { git = "https://github.com/openvm-org/openvm.git", branch = "develop-v2", default-features = false }
8+
openvm = { path = "../../toolchain/openvm", default-features = false }
9+
openvm-platform = { path = "../../toolchain/platform", default-features = false }
10+
openvm-custom-insn = { path = "../../toolchain/custom_insn", default-features = false }
11+
openvm-deferral-guest = { path = "../../../extensions/deferral/guest", default-features = false }
912

1013
[features]
1114
default = []
15+
std = ["openvm/std"]
1216

1317
[profile.release]
1418
panic = "abort"

crates/continuations-v2/programs/examples/fibonacci.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#![no_main]
2-
#![no_std]
1+
#![cfg_attr(target_os = "zkvm", no_main)]
2+
#![cfg_attr(target_os = "zkvm", no_std)]
33

44
use openvm::io::{read, reveal_u32};
55

25.7 KB
Binary file not shown.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#![cfg_attr(target_os = "zkvm", no_main)]
2+
#![cfg_attr(target_os = "zkvm", no_std)]
3+
4+
use openvm_deferral_guest::{deferred_compute, get_deferred_output, Commit};
5+
6+
openvm::entry!(main);
7+
8+
const INPUT_COMMIT_0: Commit = [0x11; 32];
9+
const INPUT_COMMIT_1: Commit = [0x22; 32];
10+
const INPUT_COMMIT_2: Commit = [0x33; 32];
11+
const EXPECTED_OUTPUT_0_IDX1: [u8; 8] = [2, 4, 7, 11, 16, 22, 29, 37];
12+
const EXPECTED_OUTPUT_1_IDX1: [u8; 8] = [9, 16, 22, 27, 31, 34, 36, 37];
13+
const EXPECTED_OUTPUT_2_IDX1: [u8; 8] = [10, 19, 28, 37, 46, 55, 64, 73];
14+
const EXPECTED_OUTPUT_0_IDX2: [u8; 8] = [3, 5, 8, 12, 17, 23, 30, 38];
15+
16+
pub fn main() {
17+
let output_key_0 = deferred_compute::<1>(&INPUT_COMMIT_0);
18+
let mut output_0 = [0u8; EXPECTED_OUTPUT_0_IDX1.len()];
19+
get_deferred_output::<1>(&mut output_0, &output_key_0);
20+
assert_eq!(output_0, EXPECTED_OUTPUT_0_IDX1);
21+
22+
let output_key_1 = deferred_compute::<1>(&INPUT_COMMIT_1);
23+
let mut output_1 = [0u8; EXPECTED_OUTPUT_1_IDX1.len()];
24+
get_deferred_output::<1>(&mut output_1, &output_key_1);
25+
assert_eq!(output_1, EXPECTED_OUTPUT_1_IDX1);
26+
27+
let output_key_2 = deferred_compute::<1>(&INPUT_COMMIT_2);
28+
let mut output_2 = [0u8; EXPECTED_OUTPUT_2_IDX1.len()];
29+
get_deferred_output::<1>(&mut output_2, &output_key_2);
30+
assert_eq!(output_2, EXPECTED_OUTPUT_2_IDX1);
31+
32+
let output_key_3 = deferred_compute::<2>(&INPUT_COMMIT_0);
33+
let mut output_3 = [0u8; EXPECTED_OUTPUT_0_IDX2.len()];
34+
get_deferred_output::<2>(&mut output_3, &output_key_3);
35+
assert_eq!(output_3, EXPECTED_OUTPUT_0_IDX2);
36+
}

crates/continuations-v2/src/circuit/inner/def_pvs/trace.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ pub fn generate_proving_ctx(
3030
AirProvingContext<CpuBackend<BabyBearPoseidon2Config>>,
3131
Vec<[F; POSEIDON2_WIDTH]>,
3232
) {
33-
assert_eq!(
34-
absent_trace_pvs.is_some(),
35-
matches!(proofs_type, ProofsType::Deferral) && proofs.len() == 1
33+
assert!(
34+
absent_trace_pvs.is_none()
35+
|| (matches!(proofs_type, ProofsType::Deferral) && proofs.len() == 1),
36+
"absent_trace_pvs is only valid for single-proof deferral aggregation"
3637
);
3738
let mut proof_idxs = vec![];
3839
let (num_rows, def_flag) = match proofs_type {

0 commit comments

Comments
 (0)