diff --git a/evm/src/cpu/memio.rs b/evm/src/cpu/memio.rs index 3fcdfc96..6ea82089 100644 --- a/evm/src/cpu/memio.rs +++ b/evm/src/cpu/memio.rs @@ -43,6 +43,15 @@ fn eval_packed_load( yield_constr.constraint(filter * (load_channel.addr_segment - addr_segment)); yield_constr.constraint(filter * (load_channel.addr_virtual - addr_virtual)); + // Constrain the new top of the stack. + for (&limb_loaded, &limb_new_top) in load_channel + .value + .iter() + .zip(nv.mem_channels[0].value.iter()) + { + yield_constr.constraint(filter * (limb_loaded - limb_new_top)); + } + // Disable remaining memory channels, if any. for &channel in &lv.mem_channels[4..NUM_GP_CHANNELS] { yield_constr.constraint(filter * channel.used); @@ -95,6 +104,17 @@ fn eval_ext_circuit_load, const D: usize>( yield_constr.constraint(builder, constr); } + // Constrain the new top of the stack. + for (&limb_loaded, &limb_new_top) in load_channel + .value + .iter() + .zip(nv.mem_channels[0].value.iter()) + { + let diff = builder.sub_extension(limb_loaded, limb_new_top); + let constr = builder.mul_extension(filter, diff); + yield_constr.constraint(builder, constr); + } + // Disable remaining memory channels, if any. for &channel in &lv.mem_channels[4..] { let constr = builder.mul_extension(filter, channel.used);