From 126ffdd82c3b460aa55801adc24bbc9e41eceb4d Mon Sep 17 00:00:00 2001 From: Constance Beguier Date: Thu, 26 Jun 2025 14:33:57 +0200 Subject: [PATCH 1/2] Add comment for range check lookup table --- .../src/utilities/lookup_range_check.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/halo2_gadgets/src/utilities/lookup_range_check.rs b/halo2_gadgets/src/utilities/lookup_range_check.rs index d756dd0aec..bdbec01c4c 100644 --- a/halo2_gadgets/src/utilities/lookup_range_check.rs +++ b/halo2_gadgets/src/utilities/lookup_range_check.rs @@ -665,6 +665,25 @@ impl LookupRangeCheck /// | 1 | X(S\[1\]) | Y(S\[1\]) | 5 | /// | ... | ... | ... | 5 | /// | 2^5-1 | X(S\[2^5-1\]) | Y(S\[2^5-1\]) | 5 | + /// + /// Rationale for the current lookup table format with duplicated rows: + /// + /// While it is possible to avoid duplicated rows by using tags and storing them in an advice + /// column, as done in the spread table of the SHA-256 gadget, applying this technique to the + /// range check lookup table would significantly increase complexity. + /// + /// Indeed, in the range check lookup tables, tags are currently computed on the fly and are not + /// stored in advice columns. Adopting the no duplicated rows approach would require modifying + /// the lookup chip to include an advice column for tags and updating the public API accordingly. + /// This tag column would need to be populated each time a range check lookup is performed. + /// Additionally, the current lookup range check implementation involves combinations of + /// multiple lookups, further complicating this approach. + /// + /// The performance benefit would be minimal: our current table has 1072 rows (2^10 + 2^4 + 2^5), + /// and switching to the no duplicated-rows method would reduce it only slightly to 1024 rows + /// (2^10), while adding more logic and infrastructure to manage the tags. + /// + /// Therefore, we retain the simpler duplicated-rows format for clarity and maintainability. fn load( &self, generator_table_config: &GeneratorTableConfig, From 434bd2b2404386a3aaaceaf6686a39bf323a22eb Mon Sep 17 00:00:00 2001 From: Constance Beguier Date: Thu, 26 Jun 2025 15:17:23 +0200 Subject: [PATCH 2/2] Take into account code review --- halo2_gadgets/src/utilities/lookup_range_check.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/halo2_gadgets/src/utilities/lookup_range_check.rs b/halo2_gadgets/src/utilities/lookup_range_check.rs index bdbec01c4c..0e9917fa07 100644 --- a/halo2_gadgets/src/utilities/lookup_range_check.rs +++ b/halo2_gadgets/src/utilities/lookup_range_check.rs @@ -666,7 +666,7 @@ impl LookupRangeCheck /// | ... | ... | ... | 5 | /// | 2^5-1 | X(S\[2^5-1\]) | Y(S\[2^5-1\]) | 5 | /// - /// Rationale for the current lookup table format with duplicated rows: + /// # Rationale /// /// While it is possible to avoid duplicated rows by using tags and storing them in an advice /// column, as done in the spread table of the SHA-256 gadget, applying this technique to the