diff --git a/recursion/core/src/fri_fold/mod.rs b/recursion/core/src/fri_fold/mod.rs index d59668d1e9..5c345d0469 100644 --- a/recursion/core/src/fri_fold/mod.rs +++ b/recursion/core/src/fri_fold/mod.rs @@ -25,6 +25,7 @@ pub const NUM_FRI_FOLD_COLS: usize = core::mem::size_of::>(); #[derive(Default)] pub struct FriFoldChip { pub fixed_log2_rows: Option, + pub pad: bool, } #[derive(Debug, Clone)] @@ -143,11 +144,13 @@ impl MachineAir for FriFoldChip .collect_vec(); // Pad the trace to a power of two. - pad_rows_fixed( - &mut rows, - || [F::zero(); NUM_FRI_FOLD_COLS], - self.fixed_log2_rows, - ); + if self.pad { + pad_rows_fixed( + &mut rows, + || [F::zero(); NUM_FRI_FOLD_COLS], + self.fixed_log2_rows, + ); + } // Convert the trace to a row major matrix. let trace = RowMajorMatrix::new(rows.into_iter().flatten().collect(), NUM_FRI_FOLD_COLS); diff --git a/recursion/core/src/multi/mod.rs b/recursion/core/src/multi/mod.rs index 10a9c3db0d..0b93f52aa2 100644 --- a/recursion/core/src/multi/mod.rs +++ b/recursion/core/src/multi/mod.rs @@ -66,8 +66,14 @@ impl MachineAir for MultiChip { input: &ExecutionRecord, output: &mut ExecutionRecord, ) -> RowMajorMatrix { - let fri_fold_chip = FriFoldChip::<3>::default(); - let poseidon2 = Poseidon2Chip::default(); + let fri_fold_chip = FriFoldChip::<3> { + fixed_log2_rows: None, + pad: false, + }; + let poseidon2 = Poseidon2Chip { + fixed_log2_rows: None, + pad: false, + }; let fri_fold_trace = fri_fold_chip.generate_trace(input, output); let mut poseidon2_trace = poseidon2.generate_trace(input, output); @@ -145,14 +151,12 @@ where // all the fri fold rows are first, then the posiedon2 rows, and finally any padded (non-real) rows. // First verify that all real rows are contiguous. - builder.when_first_row().assert_one(local_is_real.clone()); builder .when_transition() .when_not(local_is_real.clone()) .assert_zero(next_is_real.clone()); // Next, verify that all fri fold rows are before the poseidon2 rows within the real rows section. - builder.when_first_row().assert_one(local.is_fri_fold); builder .when_transition() .when(next_is_real) diff --git a/recursion/core/src/poseidon2/external.rs b/recursion/core/src/poseidon2/external.rs index d340ba2b41..21f56edb0b 100644 --- a/recursion/core/src/poseidon2/external.rs +++ b/recursion/core/src/poseidon2/external.rs @@ -24,6 +24,7 @@ pub const WIDTH: usize = 16; #[derive(Default)] pub struct Poseidon2Chip { pub fixed_log2_rows: Option, + pub pad: bool, } impl BaseAir for Poseidon2Chip { @@ -449,6 +450,7 @@ mod tests { fn generate_trace() { let chip = Poseidon2Chip { fixed_log2_rows: None, + pad: true, }; let rng = &mut rand::thread_rng(); @@ -498,6 +500,7 @@ mod tests { let chip = Poseidon2Chip { fixed_log2_rows: None, + pad: true, }; let trace: RowMajorMatrix = chip.generate_trace(&input_exec, &mut ExecutionRecord::::default()); diff --git a/recursion/core/src/poseidon2/trace.rs b/recursion/core/src/poseidon2/trace.rs index 2d5639edd2..567c09fc7d 100644 --- a/recursion/core/src/poseidon2/trace.rs +++ b/recursion/core/src/poseidon2/trace.rs @@ -174,11 +174,13 @@ impl MachineAir for Poseidon2Chip { let num_real_rows = rows.len(); // Pad the trace to a power of two. - pad_rows_fixed( - &mut rows, - || [F::zero(); NUM_POSEIDON2_COLS], - self.fixed_log2_rows, - ); + if self.pad { + pad_rows_fixed( + &mut rows, + || [F::zero(); NUM_POSEIDON2_COLS], + self.fixed_log2_rows, + ); + } let mut round_num = 0; for row in rows[num_real_rows..].iter_mut() { diff --git a/recursion/core/src/stark/mod.rs b/recursion/core/src/stark/mod.rs index 540dcb613b..7753c73f83 100644 --- a/recursion/core/src/stark/mod.rs +++ b/recursion/core/src/stark/mod.rs @@ -78,6 +78,7 @@ impl, const DEGREE: usize> RecursionAi }))) .chain(once(RecursionAir::FriFold(FriFoldChip:: { fixed_log2_rows: None, + pad: true, }))) .chain(once(RecursionAir::RangeCheck(RangeCheckChip::default()))) .collect() @@ -109,7 +110,7 @@ impl, const DEGREE: usize> RecursionAi fixed_log2_rows: Some(19), }))) .chain(once(RecursionAir::Multi(MultiChip { - fixed_log2_rows: Some(20), + fixed_log2_rows: Some(19), }))) .chain(once(RecursionAir::RangeCheck(RangeCheckChip::default()))) .collect() diff --git a/recursion/program/Cargo.toml b/recursion/program/Cargo.toml index 47dd52380c..7bfb8a3792 100644 --- a/recursion/program/Cargo.toml +++ b/recursion/program/Cargo.toml @@ -24,3 +24,6 @@ itertools = "0.12.1" serde = { version = "1.0.201", features = ["derive"] } rand = "0.8.5" tracing = "0.1.40" + +[features] +debug = ["sp1-core/debug"] \ No newline at end of file