Skip to content

Commit

Permalink
update lookup_range_check
Browse files Browse the repository at this point in the history
  • Loading branch information
YaoGalteland committed Mar 21, 2024
1 parent 9ef46c3 commit dc93a71
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions halo2_gadgets/src/utilities/lookup_range_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,24 @@ impl<F: PrimeFieldBits, const K: usize> LookupRangeCheckConfig<F, K> {
* Expression::Constant(F::from(4_u64));

// Insert the second lookup expression.
v.insert(0, (
q_lookup.clone() * q_range_check.clone() * num_bits,
extended_lookup_inputs.table_range_check_tag,
),);
v.insert(
0,
(
q_lookup.clone() * q_range_check.clone() * num_bits,
extended_lookup_inputs.table_range_check_tag,
),
);
}
// Insert the first lookup expression.
v.insert(0, (
q_lookup
* ((one - q_range_check.clone()) * (running_sum_lookup + short_lookup)
+ q_range_check.clone() * z_cur),
config.table_idx,
),);
v.insert(
0,
(
q_lookup
* ((one - q_range_check.clone()) * (running_sum_lookup + short_lookup)
+ q_range_check.clone() * z_cur),
config.table_idx,
),
);
v
});

Expand Down Expand Up @@ -219,18 +225,23 @@ impl<F: PrimeFieldBits, const K: usize> LookupRangeCheckConfig<F, K> {
layouter.assign_table(
|| "generate lookup table",
|mut table| {
self.create_lookup_subtable(&mut table,0, K)?;
self.create_lookup_subtable(&mut table, 0, K)?;

self.create_lookup_subtable(&mut table,1 << K,4)?;
self.create_lookup_subtable(&mut table, 1 << K, 4)?;

self.create_lookup_subtable(&mut table,(1 << K) +(1 << 4) ,5)?;
self.create_lookup_subtable(&mut table, (1 << K) + (1 << 4), 5)?;
Ok(())
},
)
}

// create a lookup range check subtable for an 'index_size'-bit
fn create_lookup_subtable(&self, table: &mut Table<F>, index_start: usize, index_size: usize) -> Result<(), Error> {
fn create_lookup_subtable(

Check warning on line 239 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

method `create_lookup_subtable` is never used

warning: method `create_lookup_subtable` is never used --> halo2_gadgets/src/utilities/lookup_range_check.rs:239:8 | 79 | impl<F: PrimeFieldBits, const K: usize> LookupRangeCheckConfig<F, K> { | -------------------------------------------------------------------- method in this implementation ... 239 | fn create_lookup_subtable( | ^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default

Check warning on line 239 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

associated function is never used: `create_lookup_subtable`

Check warning on line 239 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-unknown-unknown

associated function is never used: `create_lookup_subtable`

Check warning on line 239 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

method `create_lookup_subtable` is never used

Check warning on line 239 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Book tests

associated function is never used: `create_lookup_subtable`

Check warning on line 239 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

associated function is never used: `create_lookup_subtable`

Check warning on line 239 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

associated function is never used: `create_lookup_subtable`

Check warning on line 239 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

associated function is never used: `create_lookup_subtable`

Check warning on line 239 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

associated function is never used: `create_lookup_subtable`

Check warning on line 239 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with beta features

associated function is never used: `create_lookup_subtable`

Check warning on line 239 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

associated function is never used: `create_lookup_subtable`

Check warning on line 239 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with nightly features

associated function is never used: `create_lookup_subtable`

Check warning on line 239 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

associated function is never used: `create_lookup_subtable`

Check warning on line 239 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

associated function is never used: `create_lookup_subtable`
&self,
table: &mut Table<F>,
index_start: usize,
index_size: usize,
) -> Result<(), Error> {
for index in 0..(1 << index_size) {
let new_index = index + index_start;
table.assign_cell(
Expand All @@ -239,7 +250,7 @@ impl<F: PrimeFieldBits, const K: usize> LookupRangeCheckConfig<F, K> {
new_index,
|| Value::known(F::from(index as u64)),
)?;
if let Some(extended_lookup_inputs) = self.extended_lookup_inputs {
if let Some(extended_lookup_inputs) = self.extended_lookup_inputs {
match index_size {
10 => {
table.assign_cell(
Expand Down

0 comments on commit dc93a71

Please sign in to comment.