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] Integrate aggregation circuit #160

Closed
wants to merge 17 commits into from
Closed

Conversation

silathdiir
Copy link
Contributor

@silathdiir silathdiir commented Jul 7, 2023

Summary

  • Update aggregation APIs and tests.
  • Refactor and update compression and aggregation tests.
  • Update FFI.
  • Update FFI to zkevm.rs and aggregator.rs for each prover and verifier.
  • Move the current (aggregator) prover to a common folder, and add zkevm-prover and aggregator-prover use this common-prover.
  • Add MockProver for all circuits.
  • zhenfei is helping fix this issue [don't-merge] Try to enable test_aggregation_circuit zkevm-circuits#645.
  • Make aggregation-tests pass. the batch used in make test-agg-prove will contain one real chunk and one "dummy chunk". Discuss with lispc for more details here.
  • Replace zkevm-circuits branch integrate-dynamic-proof-agg (test aggregation) with develop after merging.
  • Clean code.
  • Replace halo2_proofs branch feat/disable_selector_compression (fix vk deserialization) with develop after merging.

TODO

  • Update bin (update in another PR after scroll-tests).
  • Add (back) inner snark verify.

@silathdiir silathdiir marked this pull request as draft July 7, 2023 01:18
@silathdiir silathdiir changed the title [WIP] add functions to generate aggregation snark [WIP] Integrate aggregation circuit Jul 11, 2023
ffi/src/prove.rs Outdated

/// # Safety
#[no_mangle]
pub unsafe extern "C" fn add_agg_chunk_trace(trace_char: *const c_char) {
Copy link
Member

Choose a reason for hiding this comment

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

we should not make a stateful API. You should just create a single API

fn create_agg_proof(chunk_trace: *const c_char) -> *const c_char;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. There is no this API for final FFI (have not finished updated FFI).

Will update as two FFI functions:

  • one chunk-trace -> one two-layer-compression proof (as chunk-proof)
  • Multiple two-layer-compression proofs -> one aggregation-proof (as batch-proof)

Is it right? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated (in-progress) functions gen_chunk_proof and gen_agg_proof in agg-funs/ffi-refactor branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update FFI prove to gen_chunk_proof and gen_agg_proof in commit fc94edf.

ffi/src/prove.rs Outdated
use std::cell::OnceCell;
use types::eth::BlockTrace;

static mut PROVER: OnceCell<zkevm::Prover> = OnceCell::new();
static mut CHUNK_PROVER: OnceCell<zkevm::Prover> = OnceCell::new();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static mut CHUNK_PROVER: OnceCell<zkevm::Prover> = OnceCell::new();
static mut ZKEVM_PROVER: OnceCell<zkevm::Prover> = OnceCell::new();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, should we also need zkevm-prover (suppose to delete it when update)?

Since both two-layer-compression proof (inner-snark -> compression-wide -> compression-thin) and aggregation-proof are generated by aggregator-prover.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or two-layer-compression proof should be generated by zkevm-prover?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update to ZKEVM_PROVER in commit fc94edf.

ffi/src/prove.rs Outdated
static mut PROVER: OnceCell<zkevm::Prover> = OnceCell::new();
static mut CHUNK_PROVER: OnceCell<zkevm::Prover> = OnceCell::new();
static mut AGG_PROVER: OnceCell<aggregator::Prover> = OnceCell::new();
static mut AGG_CHUNK_TRACES: OnceCell<Vec<Vec<BlockTrace>>> = OnceCell::new();
Copy link
Member

Choose a reason for hiding this comment

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

remove this line

Copy link
Contributor Author

@silathdiir silathdiir Jul 17, 2023

Choose a reason for hiding this comment

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

Delete it in commit fc94edf.

ffi/src/prove.rs Outdated
@@ -1,27 +1,44 @@
use crate::utils::{c_char_to_str, c_char_to_vec, vec_to_c_char};
Copy link
Member

Choose a reason for hiding this comment

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

I feel it's better to organize the files as zkevm.rs and aggregator.rs where each file contains both its prover and verifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re-organize FFI to zkevm.rs and aggregator.rs in commit d23c3e7.

@silathdiir silathdiir requested a review from lispc July 19, 2023 01:48
@chengwenxi
Copy link

Awesome work! I want to test it, what is the minimum memory requirement?

@silathdiir
Copy link
Contributor Author

Awesome work! I want to test it, what is the minimum memory requirement?

Sorry, this is WIP, tests cannot pass for now.

@chengwenxi
Copy link

chengwenxi commented Jul 21, 2023

Sorry, this is WIP, tests cannot pass for now.

@silathdiir Thanks for your response. I tested "test_agg_prove_verify" but it failed, I thought it was caused by low memory. Is it not finished yet?

@silathdiir
Copy link
Contributor Author

@silathdiir Thanks for your response. I tested "test_agg_prove_verify" but it failed, I thought it was caused by low memory. Is it not finished yet

It is not finished.

@silathdiir
Copy link
Contributor Author

Replaced by PR #179 and #180.

@silathdiir silathdiir closed this Jul 25, 2023
@silathdiir silathdiir deleted the add-agg-funs-to-prover branch July 25, 2023 07:08
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