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

Small updates to MockProver #256

Merged
merged 5 commits into from
Feb 5, 2024
Merged

Conversation

zemse
Copy link
Member

@zemse zemse commented Jan 30, 2024

  • expose InstanceValue::value() -> this is an helpful util to get the underlying value, though InstanceValue is public already
  • expose region data -> this is helpful to get the column annotations
  • add conversion for Selector -> Column -> this is helpful to cast selector as a fixed column

These changes allow something like this https://github.com/zemse/halo2-utils

@davidnevadoc davidnevadoc self-requested a review January 30, 2024 08:54
Copy link
Member

@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.

  • expose InstanceValue::value() -> this is an helpful util to get the underlying value, though InstanceValue is public already
    This looks good to me.
  • expose region data -> this is helpful to get the column annotations.
    I don't think access to the annotations in this way is needed. Annotations are there only for debugging purposes for the MockProver but nothing else. I don't see why you need access to them.
    Same for a lot of the other fields. I think giving access to the Region internals can be problematic.
  • add conversion for Selector -> Column -> this is helpful to cast selector as a fixed column:
    Due to selector-compression, not sure how efficient/secure this is.
  • record the last row assigned -> useful to estimate value of k:
    Already addressed in the comments of the PR.

halo2_proofs/src/dev.rs Outdated Show resolved Hide resolved
halo2_proofs/src/dev.rs Outdated Show resolved Hide resolved
halo2_proofs/src/dev.rs Outdated Show resolved Hide resolved
@@ -350,6 +350,15 @@ impl From<Column<Fixed>> for Column<Any> {
}
}

impl From<Selector> for Column<Any> {
Copy link
Member

Choose a reason for hiding this comment

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

Why would it be possible to cast this? How are you planning to create an Advice or Instance column from this?

If this stays here, it should only be valid to do:

Suggested change
impl From<Selector> for Column<Any> {
impl From<Selector> for Column<Fixed> {

And not only that, This cast is also bad in the sense that selector_compression will happen and I'm not sure how will affect this castings done here.
I'd remove this and not allow to do this type of cast just to be safe.

Tagging @ed255 @han0110

Copy link
Member Author

Choose a reason for hiding this comment

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

I want to use the name_column annotation util added in #109. However it only works for advice, fixed and instance. Currently it is not possible to annotate a selector column.

This is an example where it is currently failing https://github.com/zemse/halo2-utils/blob/d36fdf2036f4300bfc2559e754b7b68909f63044/src/example_circuit.rs#L70

Screenshot 2024-01-30 at 4 29 25 PM

Copy link
Member

Choose a reason for hiding this comment

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

That's correct. But there's an issue with that.
Notice that when we do keygen, we call the fn compress_selectors.
If you have compression enabled, the annotation could be erased. Otherwise, if we prevent compression, we're not matching the circuit we will end up with.

Hence why this is an issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it, I have removed this change by reverting the commit

Co-authored-by: Carlos Pérez <[email protected]>
@zemse
Copy link
Member Author

zemse commented Jan 30, 2024

Thanks for review

I don't think access to the annotations in this way is needed. Annotations are there only for debugging purposes for the MockProver but nothing else. I don't see why you need access to them.

If user is annotating the columns for debugging, that can be reused to print all column assignments (for a different debugging approach), while those columns can be labeled accordingly. Here is an example of how that would look.

@CPerezz CPerezz requested review from han0110 and ed255 February 2, 2024 14:59
Copy link

@han0110 han0110 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@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.

LGTM!

@CPerezz CPerezz merged commit bc30c46 into privacy-scaling-explorations:main Feb 5, 2024
12 checks passed
zemse added a commit to zemse/halo2 that referenced this pull request Apr 24, 2024
* expose InstanceValue::value

* expose region data

* add conversion for Selector -> Column<Any>

* Update halo2_proofs/src/dev.rs

Co-authored-by: Carlos Pérez <[email protected]>

* Revert "add conversion for Selector -> Column<Any>"

This reverts commit 8cd1376.

---------

Co-authored-by: Carlos Pérez <[email protected]>
zemse added a commit to zemse/halo2 that referenced this pull request Apr 24, 2024
* expose InstanceValue::value

* expose region data

* add conversion for Selector -> Column<Any>

* Update halo2_proofs/src/dev.rs

Co-authored-by: Carlos Pérez <[email protected]>

* Revert "add conversion for Selector -> Column<Any>"

This reverts commit 8cd1376.

---------

Co-authored-by: Carlos Pérez <[email protected]>
zemse added a commit to zemse/halo2 that referenced this pull request Apr 24, 2024
* expose InstanceValue::value

* expose region data

* add conversion for Selector -> Column<Any>

* Update halo2_proofs/src/dev.rs

Co-authored-by: Carlos Pérez <[email protected]>

* Revert "add conversion for Selector -> Column<Any>"

This reverts commit 8cd1376.

---------

Co-authored-by: Carlos Pérez <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants