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

feat: FFLONK support for compressor #3359

Open
wants to merge 241 commits into
base: main
Choose a base branch
from
Open

feat: FFLONK support for compressor #3359

wants to merge 241 commits into from

Conversation

Artemka374
Copy link
Contributor

@Artemka374 Artemka374 commented Dec 4, 2024

What ❔

Enables support of FFLONK compression

  • Compressor now can be run with --flonk=true flag to run compressor in FFLONK mode(or by running zkstack prover run --component compressor --mode=fflonk), default mode is still PLONK
  • Final proof is now an enum: it can be either L1BatchProofForL1::Fflonk or L1BatchProofForL1::Plonk containing the proof inside
  • We are now making use out of compression_mode environment variable - FFLONK compressor can be run in 5 modes - 5th one is the most effective, so default value is 5.
  • VK setup data generator is updated to generate setup and verification keys for FFLONK as well.

Why ❔

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • Code has been formatted via zk fmt and zk lint.

Copy link
Contributor

@EmilLuta EmilLuta left a comment

Choose a reason for hiding this comment

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

Overall looks good.

My only concern -- this PR is massive as it is. It would've been better if we could have 2 PRs -- Igor's changes & then yours. I understand the context and won't push this PR for a split, but might be relevant for future follow-ups.

One concern I have, if anything's broken in either of the implementations, we'll have to revert both.

I'll wait for Crypto changes to VKs then do another review.

Thanks for the work!

Cargo.toml Outdated Show resolved Hide resolved
@@ -58,11 +58,15 @@ async fn run_init(args: InitArgs, shell: &Shell) -> anyhow::Result<()> {
let chain_config = config
.load_current_chain()
.context(MSG_CHAIN_NOT_FOUND_ERR)?;

if args.update_submodules.is_none() || args.update_submodules == Some(true) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What would happen if these changes were packed in a different PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this change is needed to be able to switch between different contracts commits, since when submodules are updated, they will be changed back to the current ones

}

#[derive(Debug)]
pub struct InsertVersionArgsFinal {
pub snark_wrapper: String,
pub fflonk_snark_wrapper: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do I understand correctly that we'll ask everyone to provide a snark wrapper & fflonk wrapper key always? If so, I wonder if this won't be harder for folks running our system. On the other hand, I don't see a clear technical alternative.

Maybe we should add some docs to explain how they work, why there's 2 and how they interact.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually it should work fine if the hash is not provided, I might've missed this option during implementation


use crate::messages::MSG_SETUP_COMPRESSOR_KEY_PATH_PROMPT;

#[derive(Debug, Clone, Parser, Default)]
pub struct CompressorKeysArgs {
#[clap(long)]
pub path: Option<String>,
#[clap(long, default_value = "plonk")]
Copy link
Contributor

Choose a reason for hiding this comment

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

For some reason, I understood that you can use both PLONK and FFLONK at the same time. If that's not the case, doesn't it make more sense to have the CLI accept one or another? (re: my other comment in insert_version.rs)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you can use them at the same time, I can add option all for this

CompressorType::Fflonk => {
let path = args.clone().path.context(MSG_SETUP_KEY_PATH_ERROR)?;

download_compressor_key(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need both keys here? How does the FFLONK part work? I was expecting just the expanded CRS.

prover/crates/lib/keystore/src/lib.rs Outdated Show resolved Hide resolved
@@ -120,6 +161,8 @@ mod tests {

use super::*;

// todo: test is ignored due to serialization issues for now
#[ignore]
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the plan to fix this test?

@@ -59,6 +59,7 @@ struct Opt {
/// This function recalculates the commitment in order to check the exact code that
/// will run, instead of loading `commitments.json` (which also may correct misaligned
/// information).
#[allow(dead_code)] // todo: remove after VK issue is resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

I reckon we'll get rid of this comment as well.

),
);

env::set_var("CRS_FILE", crs_path);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Early return here to get rid of else branch?

prover/crates/bin/proof_fri_compressor/src/compressor.rs Outdated Show resolved Hide resolved
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.

5 participants