From 71f05704add94577434dd3273f35fff335a38de0 Mon Sep 17 00:00:00 2001 From: Georg Wiese Date: Fri, 20 Dec 2024 18:58:49 +0100 Subject: [PATCH] Improve FixedEvaluator implementation --- executor/src/witgen/jit/block_machine_processor.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/executor/src/witgen/jit/block_machine_processor.rs b/executor/src/witgen/jit/block_machine_processor.rs index 5e696a1dc..541ca5de6 100644 --- a/executor/src/witgen/jit/block_machine_processor.rs +++ b/executor/src/witgen/jit/block_machine_processor.rs @@ -188,7 +188,14 @@ impl FixedEvaluator for &BlockMachineProcessor<'_, T> { fn evaluate(&self, var: &AlgebraicReference, row_offset: i32) -> Option { assert!(var.is_fixed()); let values = self.fixed_data.fixed_cols[&var.poly_id].values_max_size(); - let row = (row_offset + var.next as i32 + values.len() as i32) as usize % values.len(); + + // By assumption of the block machine, all fixed columns are cyclic with a period of . + // An exception might be the first and last row. + assert!(row_offset >= -1); + assert!(self.block_size >= 1); + // The current row is guaranteed to be at least 1. + let current_row = (2 * self.block_size as i32 + row_offset) as usize; + let row = current_row + var.next as usize; Some(values[row]) } }