Skip to content

Commit

Permalink
disable selector compression
Browse files Browse the repository at this point in the history
  • Loading branch information
lispc committed Jul 11, 2023
1 parent 103ce21 commit 031495f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
20 changes: 6 additions & 14 deletions halo2_proofs/src/plonk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ where
/// WITHOUT performing the expensive Montgomery reduction.
pub fn write<W: io::Write>(&self, writer: &mut W, format: SerdeFormat) -> io::Result<()> {
writer.write_all(&self.domain.k().to_be_bytes())?;
// the `fixed_commitments` here includes selectors
writer.write_all(&(self.fixed_commitments.len() as u32).to_be_bytes())?;
for commitment in &self.fixed_commitments {
commitment.write(writer, format)?;
Expand Down Expand Up @@ -119,21 +120,12 @@ where

let permutation = permutation::VerifyingKey::read(reader, &cs.permutation, format)?;

/*
// read selectors
let selectors: Vec<Vec<bool>> = vec![vec![false; 1 << k]; cs.num_selectors]
.into_iter()
.map(|mut selector| {
let mut selector_bytes = vec![0u8; (selector.len() + 7) / 8];
reader.read_exact(&mut selector_bytes)?;
for (bits, byte) in selector.chunks_mut(8).into_iter().zip(selector_bytes) {
crate::helpers::unpack(byte, bits);
}
Ok(selector)
})
.collect::<io::Result<_>>()?;
// We already disable compressing selectors inside `compress_selectors::process`.
// So `selectors` values is not relevant here actually.
// The selector commitments are already in fixed_commitments.
let selectors: Vec<Vec<bool>> = vec![vec![false; 1 << k]; cs.num_selectors];
let (cs, _) = cs.compress_selectors(selectors.clone());

Check warning on line 127 in halo2_proofs/src/plonk.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

redundant clone

warning: redundant clone --> halo2_proofs/src/plonk.rs:127:54 | 127 | let (cs, _) = cs.compress_selectors(selectors.clone()); | ^^^^^^^^ help: remove this | = note: `-W clippy::redundant-clone` implied by `-W clippy::all` note: this value is dropped without further use --> halo2_proofs/src/plonk.rs:127:45 | 127 | let (cs, _) = cs.compress_selectors(selectors.clone()); | ^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone

Check warning on line 127 in halo2_proofs/src/plonk.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

redundant clone

warning: redundant clone --> halo2_proofs/src/plonk.rs:127:54 | 127 | let (cs, _) = cs.compress_selectors(selectors.clone()); | ^^^^^^^^ help: remove this | = note: `-W clippy::redundant-clone` implied by `-W clippy::all` note: this value is dropped without further use --> halo2_proofs/src/plonk.rs:127:45 | 127 | let (cs, _) = cs.compress_selectors(selectors.clone()); | ^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone

Check failure on line 127 in halo2_proofs/src/plonk.rs

View workflow job for this annotation

GitHub Actions / Clippy (1.56.1)

redundant clone

error: redundant clone --> halo2_proofs/src/plonk.rs:127:54 | 127 | let (cs, _) = cs.compress_selectors(selectors.clone()); | ^^^^^^^^ help: remove this | = note: `-D clippy::redundant-clone` implied by `-D warnings` note: this value is dropped without further use --> halo2_proofs/src/plonk.rs:127:45 | 127 | let (cs, _) = cs.compress_selectors(selectors.clone()); | ^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone

Check failure on line 127 in halo2_proofs/src/plonk.rs

View workflow job for this annotation

GitHub Actions / Clippy (1.56.1)

redundant clone

error: redundant clone --> halo2_proofs/src/plonk.rs:127:54 | 127 | let (cs, _) = cs.compress_selectors(selectors.clone()); | ^^^^^^^^ help: remove this | = note: `-D clippy::redundant-clone` implied by `-D warnings` note: this value is dropped without further use --> halo2_proofs/src/plonk.rs:127:45 | 127 | let (cs, _) = cs.compress_selectors(selectors.clone()); | ^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
*/

Ok(Self::from_parts(
domain,
fixed_commitments,
Expand Down
3 changes: 2 additions & 1 deletion halo2_proofs/src/plonk/circuit/compress_selectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ where
// All provided selectors of degree 0 are assumed to be either concrete
// selectors or do not appear in a gate. Let's address these first.
selectors.retain(|selector| {
if selector.max_degree == 0 {
// here we disable any compression. Each selector will become a fixed column.
if true || selector.max_degree == 0 {

Check warning on line 75 in halo2_proofs/src/plonk/circuit/compress_selectors.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

this boolean expression contains a logic bug

warning: this boolean expression contains a logic bug --> halo2_proofs/src/plonk/circuit/compress_selectors.rs:75:12 | 75 | if true || selector.max_degree == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: it would look like the following: `true` | = note: `-W clippy::logic-bug` implied by `-W clippy::all` help: this expression can be optimized out by applying boolean operations to the outer expression --> halo2_proofs/src/plonk/circuit/compress_selectors.rs:75:20 | 75 | if true || selector.max_degree == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#logic_bug

Check warning on line 75 in halo2_proofs/src/plonk/circuit/compress_selectors.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

this boolean expression contains a logic bug

warning: this boolean expression contains a logic bug --> halo2_proofs/src/plonk/circuit/compress_selectors.rs:75:12 | 75 | if true || selector.max_degree == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: it would look like the following: `true` | = note: `-W clippy::logic-bug` implied by `-W clippy::all` help: this expression can be optimized out by applying boolean operations to the outer expression --> halo2_proofs/src/plonk/circuit/compress_selectors.rs:75:20 | 75 | if true || selector.max_degree == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#logic_bug

Check failure on line 75 in halo2_proofs/src/plonk/circuit/compress_selectors.rs

View workflow job for this annotation

GitHub Actions / Clippy (1.56.1)

this boolean expression contains a logic bug

error: this boolean expression contains a logic bug --> halo2_proofs/src/plonk/circuit/compress_selectors.rs:75:12 | 75 | if true || selector.max_degree == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: it would look like the following: `true` | = note: `#[deny(clippy::logic_bug)]` on by default help: this expression can be optimized out by applying boolean operations to the outer expression --> halo2_proofs/src/plonk/circuit/compress_selectors.rs:75:20 | 75 | if true || selector.max_degree == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#logic_bug

Check failure on line 75 in halo2_proofs/src/plonk/circuit/compress_selectors.rs

View workflow job for this annotation

GitHub Actions / Clippy (1.56.1)

this boolean expression contains a logic bug

error: this boolean expression contains a logic bug --> halo2_proofs/src/plonk/circuit/compress_selectors.rs:75:12 | 75 | if true || selector.max_degree == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: it would look like the following: `true` | = note: `#[deny(clippy::logic_bug)]` on by default help: this expression can be optimized out by applying boolean operations to the outer expression --> halo2_proofs/src/plonk/circuit/compress_selectors.rs:75:20 | 75 | if true || selector.max_degree == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#logic_bug
// This is a complex selector, or a selector that does not appear in any
// gate constraint.
let expression = allocate_fixed_column();
Expand Down

0 comments on commit 031495f

Please sign in to comment.