diff --git a/halo2-base/src/gates/circuit/builder.rs b/halo2-base/src/gates/circuit/builder.rs index f882426e..980abee9 100644 --- a/halo2-base/src/gates/circuit/builder.rs +++ b/halo2-base/src/gates/circuit/builder.rs @@ -343,6 +343,11 @@ impl BaseCircuitBuilder { let cell = advice[0].cell.as_ref().unwrap(); let copy_manager = self.core.copy_manager.lock().unwrap(); let acell = copy_manager.assigned_advices[cell]; + assert_eq!( + acell.column, + config.gate.basic_gates[phase][0].value.into(), + "lookup column does not match" + ); q_lookup.enable(region, acell.row_offset).unwrap(); } } diff --git a/halo2-base/src/gates/range/mod.rs b/halo2-base/src/gates/range/mod.rs index 3e5b5dfe..79cdf155 100644 --- a/halo2-base/src/gates/range/mod.rs +++ b/halo2-base/src/gates/range/mod.rs @@ -78,8 +78,9 @@ impl RangeConfig { for (phase, &num_columns) in num_lookup_advice.iter().enumerate() { let num_advice = *gate_params.num_advice_per_phase.get(phase).unwrap_or(&0); let mut columns = Vec::new(); - // if num_columns is set to 0, then we assume you do not want to perform any lookups in that phase - if num_advice == 1 && num_columns != 0 { + // If num_columns is set to 0, then we assume you do not want to perform any lookups in that phase. + // Disable this optimization in phase > 0 because you might set selectors based a cell from other columns. + if phase == 0 && num_advice == 1 && num_columns != 0 { q_lookup.push(Some(meta.complex_selector())); } else { q_lookup.push(None);