From 0b78c43fa3b4d1bb4537385b7b61379ea1187dfb Mon Sep 17 00:00:00 2001 From: Robin Salen Date: Fri, 18 Aug 2023 15:53:13 -0400 Subject: [PATCH] Remove filtering in membus --- evm/src/cpu/membus.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/evm/src/cpu/membus.rs b/evm/src/cpu/membus.rs index 8a703f0d..3ee75a65 100644 --- a/evm/src/cpu/membus.rs +++ b/evm/src/cpu/membus.rs @@ -49,11 +49,11 @@ pub fn eval_packed( lv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, ) { - let is_cpu_cycle: P = COL_MAP.op.iter().map(|&col_i| lv[col_i]).sum(); - // Validate `lv.code_context`. It should be 0 if in kernel mode and `lv.context` if in user - // mode. - yield_constr - .constraint(is_cpu_cycle * (lv.code_context - (P::ONES - lv.is_kernel_mode) * lv.context)); + // Validate `lv.code_context`. + // It should be 0 if in kernel mode and `lv.context` if in user mode. + // Note: This doesn't need to be filtered to CPU cycles, as this should also be satisfied + // during Kernel bootstrapping. + yield_constr.constraint(lv.code_context - (P::ONES - lv.is_kernel_mode) * lv.context); // Validate `channel.used`. It should be binary. for channel in lv.mem_channels { @@ -66,13 +66,13 @@ pub fn eval_ext_circuit, const D: usize>( lv: &CpuColumnsView>, yield_constr: &mut RecursiveConstraintConsumer, ) { - // Validate `lv.code_context`. It should be 0 if in kernel mode and `lv.context` if in user - // mode. + // Validate `lv.code_context`. + // It should be 0 if in kernel mode and `lv.context` if in user mode. + // Note: This doesn't need to be filtered to CPU cycles, as this should also be satisfied + // during Kernel bootstrapping. let diff = builder.sub_extension(lv.context, lv.code_context); let constr = builder.mul_sub_extension(lv.is_kernel_mode, lv.context, diff); - let is_cpu_cycle = builder.add_many_extension(COL_MAP.op.iter().map(|&col_i| lv[col_i])); - let filtered_constr = builder.mul_extension(is_cpu_cycle, constr); - yield_constr.constraint(builder, filtered_constr); + yield_constr.constraint(builder, constr); // Validate `channel.used`. It should be binary. for channel in lv.mem_channels {