Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Implement RootCircuit for SuperCircuit aggregation #1000

Merged

Conversation

han0110
Copy link
Collaborator

@han0110 han0110 commented Dec 22, 2022

This PR aims to implement RootCircuit for SuperCircuit aggregation, to replace current one in zkevm-chain repo.

It uses the latest snark-verifier (previously plonk-verifier) so it requires to upgrade the halo2 and halo2wrong tag, tho it doesn't require any change (it's just that we could use stable channel rust now but zkevm-circuits itself still requires nightly).

Resolves #664.

@github-actions github-actions bot added crate-bus-mapping Issues related to the bus-mapping workspace member crate-circuit-benchmarks Issues related to the circuit-benchmarks workspace member crate-eth-types Issues related to the eth-types workspace member crate-gadgets Issues related to the gadgets workspace member crate-integration-tests Issues related to the integration-tests workspace member crate-zkevm-circuits Issues related to the zkevm-circuits workspace member T-bench Type: benchmark improvements labels Dec 22, 2022
@aguzmant103
Copy link
Member

@lispc can you help us get another reviewer for this task. Thanks!

@smtmfft
Copy link
Contributor

smtmfft commented Dec 27, 2022

Does the evm-verifier-with-accumulator in that snark-verifier repo work for this root circuit??

https://github.com/privacy-scaling-explorations/snark-verifier/blob/dda742375cf87a268cba416b85a1d1b4e3383378/snark-verifier/examples/evm-verifier-with-accumulator.rs#L558-L563

Thanks!

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.

This work is awesome @han0110

It's quite clear what you're doing all the time. I really like it!
I left some questions and minor nits.

Also, are there any specs for the Root circuit somewhere? As I think we should have some. And also, to have them related to the code we see here.

Again, awesome work mate!

zkevm-circuits/src/root_circuit/aggregation.rs Outdated Show resolved Hide resolved
zkevm-circuits/src/root_circuit/aggregation.rs Outdated Show resolved Hide resolved
use itertools::Itertools;
use rand::rngs::OsRng;

#[ignore = "Due to high memory requirement"]
Copy link
Member

Choose a reason for hiding this comment

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

Would this be a candidate to run in the serial tests section of our testsuite? Or even with this the machine would OOM?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since it's trying to create a SuperCircuit proof with k >= 18, so I believe it requires a tons of memory to run, so I didn't bother to try enable this to test the CI machine.

@CPerezz CPerezz requested a review from kilic December 27, 2022 11:01
@han0110
Copy link
Collaborator Author

han0110 commented Dec 27, 2022

Does the evm-verifier-with-accumulator in that snark-verifier repo work for this root circuit??

https://github.com/privacy-scaling-explorations/snark-verifier/blob/dda742375cf87a268cba416b85a1d1b4e3383378/snark-verifier/examples/evm-verifier-with-accumulator.rs#L558-L563

Thanks!

@smtmfft Yes I think so.

@smtmfft
Copy link
Contributor

smtmfft commented Dec 28, 2022

@smtmfft Yes I think so.

Thanks @han0110 , I am reading that evm-verifier-with-accumulator, but not quite understand, do you have any doc (Or related materials if you think necessary) for how it works?

@han0110
Copy link
Collaborator Author

han0110 commented Dec 28, 2022

Thanks @han0110 , I am reading that evm-verifier-with-accumulator, but not quite understand, do you have any doc (Or related materials if you think necessary) for how it works?

@smtmfft Sorry that I haven't added too much document yet, but I'm planning to do that soon, the paper I followed is this one https://eprint.iacr.org/2020/499. Simply speaking it's trying to verify it without doing pairing, and defer the final pairing input to the evm verifier.

@aguzmant103
Copy link
Member

Note: Han is working on documentation tasks first that will help to review this one.

@aguzmant103
Copy link
Member

aguzmant103 commented Jan 12, 2023

Note: after the document is finished, this review can continue. privacy-scaling-explorations/snark-verifier#22

@aguzmant103
Copy link
Member

@CPerezz @kilic this is now ready to be reviewed

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.

Sorry for the delay on the review @han0110 .

Awesome job. I'll anyway dive deeper into the paper implementation inside snark-verifier once I get a bit more time.

Thanks for this awesome work! 👏

@github-actions github-actions bot removed crate-integration-tests Issues related to the integration-tests workspace member crate-gadgets Issues related to the gadgets workspace member crate-bus-mapping Issues related to the bus-mapping workspace member crate-eth-types Issues related to the eth-types workspace member crate-circuit-benchmarks Issues related to the circuit-benchmarks workspace member T-bench Type: benchmark improvements labels Feb 3, 2023
Copy link
Collaborator

@ChihChengLiang ChihChengLiang left a comment

Choose a reason for hiding this comment

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

Amazing work! LGTM. I added a comment.

Comment on lines +602 to +625
let a = region.assign_advice(|| "", w_l, 0, || Value::known(self.0))?;
region.assign_fixed(|| "", q_l, 0, || Value::known(-F::one()))?;
a.copy_advice(|| "", &mut region, w_r, 1)?;
a.copy_advice(|| "", &mut region, w_o, 2)?;
region.assign_advice(|| "", w_l, 3, || Value::known(-F::from(5)))?;
for (column, idx) in [q_l, q_r, q_o, q_m, q_c].iter().zip(1..) {
region.assign_fixed(|| "", *column, 3, || Value::known(F::from(idx)))?;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't follow the cell assignments here. Can we add a comment on why we are assigning this way?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's because currently there is some problem for halo2wrong if there is identity point in preprocessed or proof (kind of forget to investigate for a long time), so here it's trying to make sure the fixed columns are not identity by assigning some random values.

I have added some comments and error handling in 54935c5, and will try to dig into that issue.

@han0110 han0110 merged commit 76ba1f0 into privacy-scaling-explorations:main Feb 9, 2023
@han0110 han0110 deleted the feature/root-circuit branch February 9, 2023 06:21
@han0110 han0110 restored the feature/root-circuit branch February 9, 2023 06:21
noel2004 pushed a commit to noel2004/zkevm-circuits that referenced this pull request Nov 29, 2023
* create_op: fix memory size (privacy-scaling-explorations#990)

* create: refactor lifetime

* fmt

* add more tests

* update access list in create

* refactor create

* build

* fix

* try

* ci
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crate-zkevm-circuits Issues related to the zkevm-circuits workspace member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Define and implement the Root Circuit
6 participants