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

Implement RootCircuit for SuperCircuit aggregation#1000

Merged
han0110 merged 4 commits into
privacy-ethereum:mainfrom
han0110:feature/root-circuit
Feb 9, 2023
Merged

Implement RootCircuit for SuperCircuit aggregation#1000
han0110 merged 4 commits into
privacy-ethereum:mainfrom
han0110:feature/root-circuit

Conversation

@han0110

@han0110 han0110 commented Dec 22, 2022

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Collaborator

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

@smtmfft

smtmfft commented Dec 27, 2022

Copy link
Copy Markdown
Contributor

@CPerezz CPerezz left a comment

Copy link
Copy Markdown
Contributor

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!

Comment thread zkevm-circuits/src/root_circuit/aggregation.rs
Comment thread zkevm-circuits/src/root_circuit/aggregation.rs
Comment thread zkevm-circuits/src/root_circuit/aggregation.rs
Comment thread zkevm-circuits/src/root_circuit/aggregation.rs
use itertools::Itertools;
use rand::rngs::OsRng;

#[ignore = "Due to high memory requirement"]

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor 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.

Comment thread zkevm-circuits/src/root_circuit/aggregation.rs
Comment thread zkevm-circuits/src/root_circuit/aggregation.rs
@CPerezz CPerezz requested a review from kilic December 27, 2022 11:01
@han0110

han0110 commented Dec 27, 2022

Copy link
Copy Markdown
Contributor Author

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

smtmfft commented Dec 28, 2022

Copy link
Copy Markdown
Contributor

@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

han0110 commented Dec 28, 2022

Copy link
Copy Markdown
Contributor Author

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.

@andyguzmaneth

Copy link
Copy Markdown
Collaborator

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

@andyguzmaneth

andyguzmaneth commented Jan 12, 2023

Copy link
Copy Markdown
Collaborator

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

@andyguzmaneth

Copy link
Copy Markdown
Collaborator

@CPerezz @kilic this is now ready to be reviewed

@CPerezz CPerezz left a comment

Copy link
Copy Markdown
Contributor

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! 👏

@han0110 han0110 force-pushed the feature/root-circuit branch from b0fd687 to 1435a30 Compare February 3, 2023 14:56
@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
Comment thread zkevm-circuits/src/root_circuit.rs Outdated

@ChihChengLiang ChihChengLiang left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
Contributor 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 force-pushed the feature/root-circuit branch from c0ba028 to 54935c5 Compare February 9, 2023 04:14
@han0110 han0110 merged commit 76ba1f0 into privacy-ethereum: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-ethereum#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