Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Rebase dynamic lookups #715

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft

Conversation

therealyingtong
Copy link
Collaborator

@therealyingtong therealyingtong commented Jan 2, 2023

Recommended: review commit-by-commit.

  • to run tests: cargo test --features unstable-dynamic-lookups dyn
  • to run example: cargo run --features unstable-dynamic-lookups --example dynamic-lookup

(This PR is a rebased version of #660.)

@therealyingtong therealyingtong mentioned this pull request Jan 2, 2023
2 tasks
@str4d str4d added the F-nightly Issue or PR about a nightly feature label Jan 20, 2023
halo2_proofs/src/circuit/layouter.rs Outdated Show resolved Hide resolved
halo2_proofs/src/circuit/layouter.rs Outdated Show resolved Hide resolved
halo2_proofs/src/circuit/layouter.rs Outdated Show resolved Hide resolved
halo2_proofs/src/circuit/layouter.rs Outdated Show resolved Hide resolved
halo2_proofs/src/circuit/layouter.rs Outdated Show resolved Hide resolved
halo2_proofs/src/plonk/keygen.rs Show resolved Hide resolved
halo2_proofs/src/plonk/keygen.rs Show resolved Hide resolved
halo2_proofs/src/plonk/prover.rs Outdated Show resolved Hide resolved
halo2_proofs/src/plonk/prover.rs Outdated Show resolved Hide resolved
halo2_proofs/src/plonk/verifier.rs Outdated Show resolved Hide resolved
@@ -476,7 +491,7 @@ impl<F: Field> Assignment<F> for MockProver<F> {
}
}

impl<F: Field + Ord> MockProver<F> {
impl<F: PrimeField + Ord> MockProver<F> {
Copy link
Contributor

@daira daira Feb 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logically this shouldn't need to be a prime field because, for example, we might want to support proving systems that are not group-based, such as FRI. (For a group-based proving system, a non-prime scalar field would be insecure because discrete log on the group could be broken by Pohlig–Hellman.)

Copy link
Contributor

@CPerezz CPerezz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1st pass! :)

halo2_proofs/src/dev.rs Outdated Show resolved Hide resolved
}
}

/// Just like dynamic_lookup, but breaks the table into single row regions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how we break the table into single row regions. Am I missing anything?

halo2_proofs/src/dev/failure.rs Outdated Show resolved Hide resolved
&|_| panic!("no instance columns in table expressions"),
&|_| panic!("no negations in table expressions"),
&|_, _| panic!("no sums in table expressions"),
&|_, _| panic!("no products in table expressions"),
&|a, b| format!("{} * {}", a, b),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are products now required? I presume because the Advice assigned into the DynamicLookupTable can come from any expression result.

If so, summ negation and scale should be supported too.

Comment on lines 158 to 162
&|virtual_col| {
iter::once(format!("V{}", virtual_col.0.index())).collect()
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not in this PR. But if we plan to support Instance cols too, we should change V for virtual_col.0.col_type()

@@ -82,7 +82,7 @@ impl CircuitLayout {
}

/// Renders the given circuit on the given drawing area.
pub fn render<F: Field, ConcreteCircuit: Circuit<F>, DB: DrawingBackend>(
pub fn render<F: PrimeField, ConcreteCircuit: Circuit<F>, DB: DrawingBackend>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw above. Nor sure neither. It doesn't seem that anything requires any function from the PrimeField trait specifically right?

halo2_proofs/src/plonk/circuit.rs Outdated Show resolved Hide resolved
halo2_proofs/src/plonk/circuit.rs Outdated Show resolved Hide resolved
halo2_proofs/src/plonk/circuit.rs Outdated Show resolved Hide resolved
@therealyingtong therealyingtong force-pushed the rebase-dynamic-lookups branch 4 times, most recently from dba5db0 to 0fb457e Compare February 23, 2023 04:22
@therealyingtong therealyingtong changed the title Rebase dynamic lookups [WIP] Rebase dynamic lookups Feb 23, 2023
@therealyingtong therealyingtong marked this pull request as draft February 23, 2023 10:32
@therealyingtong
Copy link
Collaborator Author

therealyingtong commented Apr 4, 2023

A book entry for the dynamic lookups feature has been added in 1de300f21ec84b119f82f04c3e7a2fabe4d40c82.

therealyingtong and others added 12 commits April 5, 2023 16:18
@therealyingtong
Copy link
Collaborator Author

This feature currently does not seem to work when input columns are reused to assign dynamic table columns; similarly, when inputs/tables across multiple arguments share the same columns. (see 9ce8858#diff-faaf1a95220be5b9b73f935e6659140eac1bd000fbbccb6e102589b4c3ec49c5R1869)

This seems like unexpected behaviour.

@therealyingtong therealyingtong marked this pull request as draft May 3, 2023 04:34
@therealyingtong therealyingtong changed the title Rebase dynamic lookups [WIP] Rebase dynamic lookups May 3, 2023
@therealyingtong
Copy link
Collaborator Author

As it stands now, this PR requires inputs and tables to be perfectly aligned by looking up these tuples:

(selector.clone() * input, selector.clone() * table_query)

https://github.com/Orbis-Tertius/halo2/blob/8bcc3f2349d926e4fddeee7cce09202913e10b8e/halo2_proofs/src/plonk/circuit.rs#L1226

Instead, we could either:

  • remove the selector.clone() from before table_query, which would require introducing a tag = 0, table_values = 0 in each table; or
  • introduce a table_selector complex selector, which would make the table tags redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-nightly Issue or PR about a nightly feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants