Skip to content

Commit 16b1833

Browse files
jotabulaciosnicole-graus
authored andcommitted
Add MEMW_R register fast-path table (#477)
* save work * Fix MEMW_R routing predicate to allow timestamp delta = 2^16 * promote old_timestamp assert, add IS_HALF vs LT doc, and expand test coverage * fix comment * Add underflow guard and change assert to debug_assert --------- Co-authored-by: Nicole <nicole.graus@lambdaclass.com>
1 parent 1dd8680 commit 16b1833

7 files changed

Lines changed: 775 additions & 57 deletions

File tree

prover/src/lib.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ use crate::tables::types::BusId;
4141
use crate::test_utils::{
4242
E, F, VmAir, create_bitwise_air, create_branch_air, create_commit_air, create_cpu_air,
4343
create_decode_air, create_dvrm_air, create_halt_air, create_load_air, create_lt_air,
44-
create_memw_air, create_memw_aligned_air, create_mul_air, create_page_air, create_register_air,
45-
create_shift_air,
44+
create_memw_air, create_memw_aligned_air, create_memw_register_air, create_mul_air,
45+
create_page_air, create_register_air, create_shift_air,
4646
};
4747

4848
use stark::proof::options::{GoldilocksCubicProofOptions, ProofOptions};
@@ -73,6 +73,7 @@ pub struct TableCounts {
7373
pub dvrm: usize,
7474
pub shift: usize,
7575
pub branch: usize,
76+
pub memw_register: usize,
7677
}
7778

7879
impl TableCounts {
@@ -91,6 +92,7 @@ impl TableCounts {
9192
+ self.dvrm
9293
+ self.shift
9394
+ self.branch
95+
+ self.memw_register
9496
}
9597

9698
/// Validate that all required tables have at least one chunk.
@@ -108,6 +110,7 @@ impl TableCounts {
108110
("dvrm", self.dvrm),
109111
("shift", self.shift),
110112
("branch", self.branch),
113+
("memw_register", self.memw_register),
111114
];
112115
for (name, count) in checks {
113116
if count == 0 {
@@ -195,6 +198,7 @@ pub(crate) struct VmAirs {
195198
pub commit: VmAir,
196199
pub register: VmAir,
197200
pub pages: Vec<VmAir>,
201+
pub memw_registers: Vec<VmAir>,
198202
}
199203

200204
impl VmAirs {
@@ -242,6 +246,13 @@ impl VmAirs {
242246
for (air, trace) in self.pages.iter().zip(traces.pages.iter_mut()) {
243247
pairs.push((air, trace, &()));
244248
}
249+
for (air, trace) in self
250+
.memw_registers
251+
.iter()
252+
.zip(traces.memw_registers.iter_mut())
253+
{
254+
pairs.push((air, trace, &()));
255+
}
245256

246257
pairs
247258
}
@@ -286,6 +297,9 @@ impl VmAirs {
286297
for air in &self.pages {
287298
refs.push(air);
288299
}
300+
for air in &self.memw_registers {
301+
refs.push(air);
302+
}
289303

290304
refs
291305
}
@@ -358,6 +372,9 @@ impl VmAirs {
358372
)
359373
})
360374
.collect();
375+
let memw_registers: Vec<_> = (0..table_counts.memw_register)
376+
.map(|i| create_memw_register_air(proof_options).with_name(&format!("MEMW_R[{}]", i)))
377+
.collect();
361378

362379
#[cfg(feature = "debug-checks")]
363380
debug_report::print_bus_legend();
@@ -378,6 +395,7 @@ impl VmAirs {
378395
commit,
379396
register,
380397
pages,
398+
memw_registers,
381399
}
382400
}
383401
}

0 commit comments

Comments
 (0)