From 3b16ddbcd853e77e66a3beae8d3c20a47803e807 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:23:04 +0300 Subject: [PATCH 01/32] add gpu compressor --- Cargo.lock | 10 +- prover/Cargo.lock | 146 +++++++++++++++++- prover/Cargo.toml | 6 +- prover/proof_fri_compressor/Cargo.toml | 4 + prover/proof_fri_compressor/src/compressor.rs | 94 ++++++++--- 5 files changed, 221 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 85e0b8bbced8..6fd2393047bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2621,9 +2621,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.13.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +checksum = "33ff8ae62cd3a9102e5637afc8452c55acf3844001bd5374e0b0bd7b6616c038" dependencies = [ "ahash 0.8.7", ] @@ -3662,13 +3662,13 @@ dependencies = [ [[package]] name = "metrics-util" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "111cb375987443c3de8d503580b536f77dc8416d32db62d9456db5d93bd7ac47" +checksum = "4de2ed6e491ed114b40b732e4d1659a9d53992ebd87490c44a6ffe23739d973e" dependencies = [ "crossbeam-epoch 0.9.15", "crossbeam-utils 0.8.16", - "hashbrown 0.13.2", + "hashbrown 0.13.1", "metrics", "num_cpus", "quanta 0.11.1", diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 268dab9e5264..fcb9747e0682 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -424,6 +424,29 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.59.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +dependencies = [ + "bitflags 1.3.2", + "cexpr", + "clang-sys", + "clap 2.34.0", + "env_logger 0.9.3", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2 1.0.78", + "quote 1.0.35", + "regex", + "rustc-hash", + "shlex", + "which", +] + [[package]] name = "bindgen" version = "0.65.1" @@ -835,6 +858,20 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "circuit_definitions" +version = "0.1.0" +source = "git+https://github.com/matter-labs/era-zkevm_test_harness?branch=gpu-wrapper#ea0d54f6d5d7d3302a4a6594150a2ca809e6677b" +dependencies = [ + "crossbeam 0.8.4", + "derivative", + "seq-macro", + "serde", + "snark_wrapper", + "zk_evm 1.4.0", + "zkevm_circuits 1.4.0 (git+https://github.com/matter-labs/era-zkevm_circuits.git?branch=main)", +] + [[package]] name = "circuit_definitions" version = "0.1.0" @@ -858,7 +895,7 @@ dependencies = [ "derivative", "serde", "zk_evm 1.4.0", - "zkevm_circuits 1.4.0", + "zkevm_circuits 1.4.0 (git+https://github.com/matter-labs/era-zkevm_circuits.git?branch=v1.4.0)", ] [[package]] @@ -2185,6 +2222,17 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +[[package]] +name = "futures-locks" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45ec6fe3675af967e67c5536c0b9d44e34e6c52f86bedc4ea49c5317b8e94d06" +dependencies = [ + "futures-channel", + "futures-task", + "tokio", +] + [[package]] name = "futures-macro" version = "0.3.30" @@ -2340,6 +2388,35 @@ dependencies = [ "async-trait", ] +[[package]] +name = "gpu-ffi" +version = "0.1.0" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?branch=snark_wrapper#68943f30850ecd83fa9a28cc9416a83fce39ff9d" +dependencies = [ + "bindgen 0.59.2", + "crossbeam 0.7.3", + "derivative", + "futures 0.3.30", + "futures-locks", + "num_cpus", +] + +[[package]] +name = "gpu-prover" +version = "0.1.0" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?branch=snark_wrapper#68943f30850ecd83fa9a28cc9416a83fce39ff9d" +dependencies = [ + "bit-vec", + "cfg-if 1.0.0", + "crossbeam 0.7.3", + "franklin-crypto 0.0.5 (git+https://github.com/matter-labs/franklin-crypto?branch=snark_wrapper)", + "gpu-ffi", + "itertools 0.10.5", + "num_cpus", + "rand 0.4.6", + "serde", +] + [[package]] name = "group" version = "0.12.1" @@ -5393,7 +5470,7 @@ dependencies = [ "blake2 0.10.6 (registry+https://github.com/rust-lang/crates.io-index)", "boojum", "boojum-cuda", - "circuit_definitions", + "circuit_definitions 0.1.0 (git+https://github.com/matter-labs/era-zkevm_test_harness.git?branch=v1.4.2)", "cudart", "cudart-sys", "derivative", @@ -6693,7 +6770,7 @@ version = "0.1.0" dependencies = [ "anyhow", "bincode", - "circuit_definitions", + "circuit_definitions 0.1.0 (git+https://github.com/matter-labs/era-zkevm_test_harness.git?branch=v1.4.2)", "clap 4.4.6", "hex", "itertools 0.10.5", @@ -7118,6 +7195,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "wrapper-prover" +version = "0.1.0" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?branch=snark_wrapper#68943f30850ecd83fa9a28cc9416a83fce39ff9d" +dependencies = [ + "circuit_definitions 0.1.0 (git+https://github.com/matter-labs/era-zkevm_test_harness?branch=gpu-wrapper)", + "gpu-prover", + "zkevm_test_harness 1.4.0", +] + [[package]] name = "wyz" version = "0.5.1" @@ -7332,6 +7419,27 @@ dependencies = [ "zkevm_opcode_defs 1.4.1", ] +[[package]] +name = "zkevm_circuits" +version = "1.4.0" +source = "git+https://github.com/matter-labs/era-zkevm_circuits.git?branch=main#fb3e2574b5c890342518fc930c145443f039a105" +dependencies = [ + "arrayvec 0.7.4", + "bincode", + "boojum", + "cs_derive 0.1.0 (git+https://github.com/matter-labs/era-boojum?branch=main)", + "derivative", + "hex", + "itertools 0.10.5", + "rand 0.4.6", + "rand 0.8.5", + "seq-macro", + "serde", + "serde_json", + "smallvec", + "zkevm_opcode_defs 1.3.2", +] + [[package]] name = "zkevm_circuits" version = "1.4.0" @@ -7476,13 +7584,36 @@ dependencies = [ "zkevm-assembly 1.3.2", ] +[[package]] +name = "zkevm_test_harness" +version = "1.4.0" +source = "git+https://github.com/matter-labs/era-zkevm_test_harness?branch=gpu-wrapper#ea0d54f6d5d7d3302a4a6594150a2ca809e6677b" +dependencies = [ + "bincode", + "circuit_definitions 0.1.0 (git+https://github.com/matter-labs/era-zkevm_test_harness?branch=gpu-wrapper)", + "codegen", + "crossbeam 0.8.4", + "derivative", + "env_logger 0.9.3", + "hex", + "rand 0.4.6", + "rayon", + "serde", + "serde_json", + "smallvec", + "structopt", + "test-log", + "tracing", + "zkevm-assembly 1.3.2", +] + [[package]] name = "zkevm_test_harness" version = "1.4.2" source = "git+https://github.com/matter-labs/era-zkevm_test_harness.git?branch=v1.4.2#012dcc678990c695f97e5dd1f136dfa8fe376c16" dependencies = [ "bincode", - "circuit_definitions", + "circuit_definitions 0.1.0 (git+https://github.com/matter-labs/era-zkevm_test_harness.git?branch=v1.4.2)", "circuit_sequencer_api 0.1.42", "codegen", "crossbeam 0.8.4", @@ -7781,6 +7912,7 @@ dependencies = [ "vise", "vk_setup_data_generator_server_fri", "vlog", + "wrapper-prover", "zkevm_test_harness 1.3.3", "zkevm_test_harness 1.4.2", "zksync_config", @@ -7835,7 +7967,7 @@ version = "0.1.0" dependencies = [ "anyhow", "async-trait", - "circuit_definitions", + "circuit_definitions 0.1.0 (git+https://github.com/matter-labs/era-zkevm_test_harness.git?branch=v1.4.2)", "ctrlc", "futures 0.3.30", "local-ip-address", @@ -7890,7 +8022,7 @@ dependencies = [ name = "zksync_prover_fri_types" version = "0.1.0" dependencies = [ - "circuit_definitions", + "circuit_definitions 0.1.0 (git+https://github.com/matter-labs/era-zkevm_test_harness.git?branch=v1.4.2)", "serde", "zksync_object_store", "zksync_types", @@ -8047,7 +8179,7 @@ dependencies = [ "anyhow", "async-trait", "bincode", - "circuit_definitions", + "circuit_definitions 0.1.0 (git+https://github.com/matter-labs/era-zkevm_test_harness.git?branch=v1.4.2)", "const-decoder", "ctrlc", "futures 0.3.30", diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 11412ec5289d..5e5fd2c0d5fc 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -4,7 +4,6 @@ members = [ "prover_fri_utils", "prover_fri_types", "prover_dal", - # binaries "witness_generator", "vk_setup_data_generator_server_fri", @@ -31,7 +30,7 @@ categories = ["cryptography"] anyhow = "1.0" async-trait = "0.1" bincode = "1" -circuit_definitions = { git = "https://github.com/matter-labs/era-zkevm_test_harness.git", branch = "v1.4.2"} +circuit_definitions = { git = "https://github.com/matter-labs/era-zkevm_test_harness.git", branch = "v1.4.2" } circuit_sequencer_api = { package = "circuit_sequencer_api", git = "https://github.com/matter-labs/era-zkevm_test_harness.git", branch = "v1.4.2" } clap = "4.4.6" colored = "2.0" @@ -87,6 +86,9 @@ zksync_system_constants = { path = "../core/lib/constants" } zksync_types = { path = "../core/lib/types" } zksync_utils = { path = "../core/lib/utils" } +wrapper_prover = { package = "wrapper-prover", git = "https://github.com/matter-labs/era-heavy-ops-service.git", branch = "snark_wrapper" } + + # for `perf` profiling [profile.perf] inherits = "release" diff --git a/prover/proof_fri_compressor/Cargo.toml b/prover/proof_fri_compressor/Cargo.toml index a79fedb277e5..dd1aad902da3 100644 --- a/prover/proof_fri_compressor/Cargo.toml +++ b/prover/proof_fri_compressor/Cargo.toml @@ -39,4 +39,8 @@ bincode.workspace = true reqwest = { workspace = true, features = ["blocking"] } serde_json.workspace = true serde = { workspace = true, features = ["derive"] } +wrapper_prover = { workspace = true, optional = true } + +[features] +gpu = ["wrapper_prover"] diff --git a/prover/proof_fri_compressor/src/compressor.rs b/prover/proof_fri_compressor/src/compressor.rs index 7b1352b6a7c9..58b9dddc6c21 100644 --- a/prover/proof_fri_compressor/src/compressor.rs +++ b/prover/proof_fri_compressor/src/compressor.rs @@ -5,7 +5,12 @@ use async_trait::async_trait; use circuit_sequencer_api::proof::FinalProof; use prover_dal::{ConnectionPool, Prover, ProverDal}; use tokio::task::JoinHandle; -use zkevm_test_harness::proof_wrapper_utils::{wrap_proof, WrapperConfig}; +#[cfg(feature = "gpu")] +use wrapper_prover::{GPUWrapperConfigs, WrapperProver}; +#[allow(unused_imports)] +use zkevm_test_harness::proof_wrapper_utils::{ + get_trusted_setup, wrap_proof, WrapperConfig, DEFAULT_WRAPPER_CONFIG, +}; use zkevm_test_harness_1_3_3::{ abstract_zksync_circuit::concrete_circuits::{ ZkSyncCircuit, ZkSyncProof, ZkSyncVerificationKey, @@ -20,9 +25,14 @@ use zksync_object_store::ObjectStore; use zksync_prover_fri_types::{ circuit_definitions::{ boojum::field::goldilocks::GoldilocksField, - circuit_definitions::recursion_layer::{ - ZkSyncRecursionLayerProof, ZkSyncRecursionLayerStorageType, + circuit_definitions::{ + aux_layer::ZkSyncSnarkWrapperCircuit, + recursion_layer::{ + ZkSyncRecursionLayerProof, ZkSyncRecursionLayerStorageType, + ZkSyncRecursionLayerVerificationKey, + }, }, + snark_wrapper::franklin_crypto::bellman::plonk::better_better_cs::proof::Proof as SnarkProof, zkevm_circuits::scheduler::block_header::BlockAuxilaryOutputWitness, }, get_current_pod_name, AuxOutputWitnessWrapper, FriProofWrapper, @@ -59,6 +69,58 @@ impl ProofCompressor { } } + fn verify_proof(keystore: Keystore, serialized_proof: Vec) -> anyhow::Result<()> { + let proof: Proof>> = + bincode::deserialize(&serialized_proof) + .expect("Failed to deserialize proof with ZkSyncCircuit"); + // We're fetching the key as String and deserializing it here + // as we don't want to include the old version of prover in the main libraries. + let existing_vk_serialized = keystore + .load_snark_verification_key() + .context("get_snark_vk()")?; + let existing_vk = serde_json::from_str::< + SnarkVerificationKey>>, + >(&existing_vk_serialized)?; + + let vk = ZkSyncVerificationKey::from_verification_key_and_numeric_type(0, existing_vk); + let scheduler_proof = ZkSyncProof::from_proof_and_numeric_type(0, proof.clone()); + match vk.verify_proof(&scheduler_proof) { + true => tracing::info!("Compressed proof verified successfully"), + false => anyhow::bail!("Compressed proof verification failed "), + } + Ok(()) + } + + #[cfg(not(feature = "gpu"))] + fn get_wrapper_proof( + proof: ZkSyncRecursionLayerProof, + scheduler_vk: ZkSyncRecursionLayerVerificationKey, + compression_mode: u8, + ) -> SnarkProof { + let config = WrapperConfig::new(compression_mode); + + let (wrapper_proof, _) = wrap_proof(proof, scheduler_vk, config); + wrapper_proof.into_inner() + } + + #[cfg(feature = "gpu")] + fn get_wrapper_proof( + proof: ZkSyncRecursionLayerProof, + scheduler_vk: ZkSyncRecursionLayerVerificationKey, + _compression_mode: u8, + ) -> SnarkProof { + let crs = get_trusted_setup(); + let wrapper_config = DEFAULT_WRAPPER_CONFIG; + let mut prover = WrapperProver::::new(&crs, wrapper_config).unwrap(); + + prover + .generate_setup_data(scheduler_vk.into_inner()) + .unwrap(); + prover.generate_proofs(proof.into_inner()).unwrap(); + + prover.get_wrapper_proof().unwrap() + } + pub fn compress_proof( proof: ZkSyncRecursionLayerProof, compression_mode: u8, @@ -70,35 +132,17 @@ impl ProofCompressor { ZkSyncRecursionLayerStorageType::SchedulerCircuit as u8, ) .context("get_recursiver_layer_vk_for_circuit_type()")?; - let config = WrapperConfig::new(compression_mode); - let (wrapper_proof, _) = wrap_proof(proof, scheduler_vk, config); - let inner = wrapper_proof.into_inner(); + let wrapper_proof = Self::get_wrapper_proof(proof, scheduler_vk, compression_mode); + // (Re)serialization should always succeed. - let serialized = bincode::serialize(&inner) + let serialized = bincode::serialize(&wrapper_proof) .expect("Failed to serialize proof with ZkSyncSnarkWrapperCircuit"); if verify_wrapper_proof { // If we want to verify the proof, we have to deserialize it, with proper type. // So that we can pass it into `from_proof_and_numeric_type` method below. - let proof: Proof>> = - bincode::deserialize(&serialized) - .expect("Failed to deserialize proof with ZkSyncCircuit"); - // We're fetching the key as String and deserializing it here - // as we don't want to include the old version of prover in the main libraries. - let existing_vk_serialized = keystore - .load_snark_verification_key() - .context("get_snark_vk()")?; - let existing_vk = serde_json::from_str::< - SnarkVerificationKey>>, - >(&existing_vk_serialized)?; - - let vk = ZkSyncVerificationKey::from_verification_key_and_numeric_type(0, existing_vk); - let scheduler_proof = ZkSyncProof::from_proof_and_numeric_type(0, proof.clone()); - match vk.verify_proof(&scheduler_proof) { - true => tracing::info!("Compressed proof verified successfully"), - false => anyhow::bail!("Compressed proof verification failed "), - } + Self::verify_proof(keystore, serialized.clone())?; } // For sending to L1, we can use the `FinalProof` type, that has a generic circuit inside, that is not used for serialization. From 1afd5c09bc654a676496ea68f04ee0b3c532f7e5 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:34:54 +0300 Subject: [PATCH 02/32] merge fixes --- prover/Cargo.lock | 146 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 139 insertions(+), 7 deletions(-) diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 71722be14408..1f15446bc1d1 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -424,6 +424,29 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.59.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +dependencies = [ + "bitflags 1.3.2", + "cexpr", + "clang-sys", + "clap 2.34.0", + "env_logger 0.9.3", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2 1.0.78", + "quote 1.0.35", + "regex", + "rustc-hash", + "shlex", + "which", +] + [[package]] name = "bindgen" version = "0.65.1" @@ -835,6 +858,20 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "circuit_definitions" +version = "0.1.0" +source = "git+https://github.com/matter-labs/era-zkevm_test_harness?branch=gpu-wrapper#ea0d54f6d5d7d3302a4a6594150a2ca809e6677b" +dependencies = [ + "crossbeam 0.8.4", + "derivative", + "seq-macro", + "serde", + "snark_wrapper", + "zk_evm 1.4.0", + "zkevm_circuits 1.4.0 (git+https://github.com/matter-labs/era-zkevm_circuits.git?branch=main)", +] + [[package]] name = "circuit_definitions" version = "1.5.0" @@ -858,7 +895,7 @@ dependencies = [ "derivative", "serde", "zk_evm 1.4.0", - "zkevm_circuits 1.4.0", + "zkevm_circuits 1.4.0 (git+https://github.com/matter-labs/era-zkevm_circuits.git?branch=v1.4.0)", ] [[package]] @@ -2185,6 +2222,17 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +[[package]] +name = "futures-locks" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45ec6fe3675af967e67c5536c0b9d44e34e6c52f86bedc4ea49c5317b8e94d06" +dependencies = [ + "futures-channel", + "futures-task", + "tokio", +] + [[package]] name = "futures-macro" version = "0.3.30" @@ -2340,6 +2388,35 @@ dependencies = [ "async-trait", ] +[[package]] +name = "gpu-ffi" +version = "0.1.0" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?branch=snark_wrapper#68943f30850ecd83fa9a28cc9416a83fce39ff9d" +dependencies = [ + "bindgen 0.59.2", + "crossbeam 0.7.3", + "derivative", + "futures 0.3.30", + "futures-locks", + "num_cpus", +] + +[[package]] +name = "gpu-prover" +version = "0.1.0" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?branch=snark_wrapper#68943f30850ecd83fa9a28cc9416a83fce39ff9d" +dependencies = [ + "bit-vec", + "cfg-if 1.0.0", + "crossbeam 0.7.3", + "franklin-crypto 0.0.5 (git+https://github.com/matter-labs/franklin-crypto?branch=snark_wrapper)", + "gpu-ffi", + "itertools 0.10.5", + "num_cpus", + "rand 0.4.6", + "serde", +] + [[package]] name = "group" version = "0.12.1" @@ -5393,7 +5470,7 @@ dependencies = [ "blake2 0.10.6 (registry+https://github.com/rust-lang/crates.io-index)", "boojum", "boojum-cuda", - "circuit_definitions", + "circuit_definitions 1.5.0", "cudart", "cudart-sys", "derivative", @@ -6693,7 +6770,7 @@ version = "0.1.0" dependencies = [ "anyhow", "bincode", - "circuit_definitions", + "circuit_definitions 1.5.0", "clap 4.4.6", "hex", "itertools 0.10.5", @@ -7118,6 +7195,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "wrapper-prover" +version = "0.1.0" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?branch=snark_wrapper#68943f30850ecd83fa9a28cc9416a83fce39ff9d" +dependencies = [ + "circuit_definitions 0.1.0", + "gpu-prover", + "zkevm_test_harness 1.4.0", +] + [[package]] name = "wyz" version = "0.5.1" @@ -7332,6 +7419,27 @@ dependencies = [ "zkevm_opcode_defs 1.5.0", ] +[[package]] +name = "zkevm_circuits" +version = "1.4.0" +source = "git+https://github.com/matter-labs/era-zkevm_circuits.git?branch=main#fb3e2574b5c890342518fc930c145443f039a105" +dependencies = [ + "arrayvec 0.7.4", + "bincode", + "boojum", + "cs_derive 0.1.0 (git+https://github.com/matter-labs/era-boojum?branch=main)", + "derivative", + "hex", + "itertools 0.10.5", + "rand 0.4.6", + "rand 0.8.5", + "seq-macro", + "serde", + "serde_json", + "smallvec", + "zkevm_opcode_defs 1.3.2", +] + [[package]] name = "zkevm_circuits" version = "1.4.0" @@ -7476,13 +7584,36 @@ dependencies = [ "zkevm-assembly 1.3.2", ] +[[package]] +name = "zkevm_test_harness" +version = "1.4.0" +source = "git+https://github.com/matter-labs/era-zkevm_test_harness?branch=gpu-wrapper#ea0d54f6d5d7d3302a4a6594150a2ca809e6677b" +dependencies = [ + "bincode", + "circuit_definitions 0.1.0", + "codegen", + "crossbeam 0.8.4", + "derivative", + "env_logger 0.9.3", + "hex", + "rand 0.4.6", + "rayon", + "serde", + "serde_json", + "smallvec", + "structopt", + "test-log", + "tracing", + "zkevm-assembly 1.3.2", +] + [[package]] name = "zkevm_test_harness" version = "1.5.0" source = "git+https://github.com/matter-labs/era-zkevm_test_harness.git?branch=v1.5.0#ecb08797ced36fcc7d3696ffd2ec6a2d534b9395" dependencies = [ "bincode", - "circuit_definitions", + "circuit_definitions 1.5.0", "circuit_sequencer_api 0.1.50", "codegen", "crossbeam 0.8.4", @@ -7785,6 +7916,7 @@ dependencies = [ "vise", "vk_setup_data_generator_server_fri", "vlog", + "wrapper-prover", "zkevm_test_harness 1.3.3", "zkevm_test_harness 1.5.0", "zksync_config", @@ -7839,7 +7971,7 @@ version = "0.1.0" dependencies = [ "anyhow", "async-trait", - "circuit_definitions", + "circuit_definitions 1.5.0", "ctrlc", "futures 0.3.30", "local-ip-address", @@ -7894,7 +8026,7 @@ dependencies = [ name = "zksync_prover_fri_types" version = "0.1.0" dependencies = [ - "circuit_definitions", + "circuit_definitions 1.5.0", "serde", "zksync_object_store", "zksync_types", @@ -8051,7 +8183,7 @@ dependencies = [ "anyhow", "async-trait", "bincode", - "circuit_definitions", + "circuit_definitions 1.5.0", "const-decoder", "ctrlc", "futures 0.3.30", From d252467ccbbacf641c1e32dca308e24c3a212972 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Wed, 1 May 2024 16:54:25 +0300 Subject: [PATCH 03/32] add revision for heavy ops repo --- prover/Cargo.lock | 6 +++--- prover/Cargo.toml | 2 +- prover/proof_fri_compressor/src/compressor.rs | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 1f15446bc1d1..e5254a4534a5 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -2391,7 +2391,7 @@ dependencies = [ [[package]] name = "gpu-ffi" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?branch=snark_wrapper#68943f30850ecd83fa9a28cc9416a83fce39ff9d" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=ccfbd0c#ccfbd0ca15e9f087bd764a2926acb8d51f63c1bb" dependencies = [ "bindgen 0.59.2", "crossbeam 0.7.3", @@ -2404,7 +2404,7 @@ dependencies = [ [[package]] name = "gpu-prover" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?branch=snark_wrapper#68943f30850ecd83fa9a28cc9416a83fce39ff9d" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=ccfbd0c#ccfbd0ca15e9f087bd764a2926acb8d51f63c1bb" dependencies = [ "bit-vec", "cfg-if 1.0.0", @@ -7198,7 +7198,7 @@ dependencies = [ [[package]] name = "wrapper-prover" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?branch=snark_wrapper#68943f30850ecd83fa9a28cc9416a83fce39ff9d" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=ccfbd0c#ccfbd0ca15e9f087bd764a2926acb8d51f63c1bb" dependencies = [ "circuit_definitions 0.1.0", "gpu-prover", diff --git a/prover/Cargo.toml b/prover/Cargo.toml index c41366be6697..6f266c4c5920 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -86,7 +86,7 @@ zksync_system_constants = { path = "../core/lib/constants" } zksync_types = { path = "../core/lib/types" } zksync_utils = { path = "../core/lib/utils" } -wrapper_prover = { package = "wrapper-prover", git = "https://github.com/matter-labs/era-heavy-ops-service.git", branch = "snark_wrapper" } +wrapper_prover = { package = "wrapper-prover", git = "https://github.com/matter-labs/era-heavy-ops-service.git", rev = "ccfbd0c" } # for `perf` profiling diff --git a/prover/proof_fri_compressor/src/compressor.rs b/prover/proof_fri_compressor/src/compressor.rs index bbeab66d9978..5c1ea070fdc7 100644 --- a/prover/proof_fri_compressor/src/compressor.rs +++ b/prover/proof_fri_compressor/src/compressor.rs @@ -6,11 +6,11 @@ use circuit_sequencer_api::proof::FinalProof; use prover_dal::{ConnectionPool, Prover, ProverDal}; use tokio::task::JoinHandle; #[cfg(feature = "gpu")] -use wrapper_prover::{GPUWrapperConfigs, WrapperProver}; -#[allow(unused_imports)] -use zkevm_test_harness::proof_wrapper_utils::{ - get_trusted_setup, wrap_proof, WrapperConfig, DEFAULT_WRAPPER_CONFIG, +use wrapper_prover::{ + GPUWrapperConfigs, WrapperProver, ZkSyncCompressionWrapper, DEFAULT_WRAPPER_CONFIG, }; +#[allow(unused_imports)] +use zkevm_test_harness::proof_wrapper_utils::{get_trusted_setup, wrap_proof}; use zkevm_test_harness_1_3_3::{ abstract_zksync_circuit::concrete_circuits::{ ZkSyncCircuit, ZkSyncProof, ZkSyncVerificationKey, From feeca5f1ccee89d819f6b82d559cfea25516de60 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Wed, 1 May 2024 17:03:24 +0300 Subject: [PATCH 04/32] one more revision change, update imports --- prover/Cargo.lock | 6 +++--- prover/Cargo.toml | 2 +- prover/proof_fri_compressor/src/compressor.rs | 18 ++++++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/prover/Cargo.lock b/prover/Cargo.lock index e5254a4534a5..036b27d46e47 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -2391,7 +2391,7 @@ dependencies = [ [[package]] name = "gpu-ffi" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=ccfbd0c#ccfbd0ca15e9f087bd764a2926acb8d51f63c1bb" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=5464d5d#5464d5d43c49065e659221fa55fb6b8f17cff1a0" dependencies = [ "bindgen 0.59.2", "crossbeam 0.7.3", @@ -2404,7 +2404,7 @@ dependencies = [ [[package]] name = "gpu-prover" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=ccfbd0c#ccfbd0ca15e9f087bd764a2926acb8d51f63c1bb" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=5464d5d#5464d5d43c49065e659221fa55fb6b8f17cff1a0" dependencies = [ "bit-vec", "cfg-if 1.0.0", @@ -7198,7 +7198,7 @@ dependencies = [ [[package]] name = "wrapper-prover" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=ccfbd0c#ccfbd0ca15e9f087bd764a2926acb8d51f63c1bb" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=5464d5d#5464d5d43c49065e659221fa55fb6b8f17cff1a0" dependencies = [ "circuit_definitions 0.1.0", "gpu-prover", diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 6f266c4c5920..51c0071f144b 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -86,7 +86,7 @@ zksync_system_constants = { path = "../core/lib/constants" } zksync_types = { path = "../core/lib/types" } zksync_utils = { path = "../core/lib/utils" } -wrapper_prover = { package = "wrapper-prover", git = "https://github.com/matter-labs/era-heavy-ops-service.git", rev = "ccfbd0c" } +wrapper_prover = { package = "wrapper-prover", git = "https://github.com/matter-labs/era-heavy-ops-service.git", rev = "5464d5d" } # for `perf` profiling diff --git a/prover/proof_fri_compressor/src/compressor.rs b/prover/proof_fri_compressor/src/compressor.rs index 5c1ea070fdc7..b93bed237fd2 100644 --- a/prover/proof_fri_compressor/src/compressor.rs +++ b/prover/proof_fri_compressor/src/compressor.rs @@ -7,7 +7,8 @@ use prover_dal::{ConnectionPool, Prover, ProverDal}; use tokio::task::JoinHandle; #[cfg(feature = "gpu")] use wrapper_prover::{ - GPUWrapperConfigs, WrapperProver, ZkSyncCompressionWrapper, DEFAULT_WRAPPER_CONFIG, + GPUWrapperConfigs, Proof as SnarkProof, WrapperProver, ZkSyncSnarkWrapperCircuit, + DEFAULT_WRAPPER_CONFIG, }; #[allow(unused_imports)] use zkevm_test_harness::proof_wrapper_utils::{get_trusted_setup, wrap_proof}; @@ -22,17 +23,18 @@ use zkevm_test_harness_1_3_3::{ witness::oracle::VmWitnessOracle, }; use zksync_object_store::ObjectStore; +#[cfg(not(feature = "gpu"))] +use zksync_prover_fri_types::circuit_definitions::{ + circuit_definitions::aux_layer::ZkSyncSnarkWrapperCircuit, + snark_wrapper::franklin_crypto::bellman::plonk::better_better_cs::proof::Proof as SnarkProof, +}; use zksync_prover_fri_types::{ circuit_definitions::{ boojum::field::goldilocks::GoldilocksField, - circuit_definitions::{ - aux_layer::ZkSyncSnarkWrapperCircuit, - recursion_layer::{ - ZkSyncRecursionLayerProof, ZkSyncRecursionLayerStorageType, - ZkSyncRecursionLayerVerificationKey, - }, + circuit_definitions::recursion_layer::{ + ZkSyncRecursionLayerProof, ZkSyncRecursionLayerStorageType, + ZkSyncRecursionLayerVerificationKey, }, - snark_wrapper::franklin_crypto::bellman::plonk::better_better_cs::proof::Proof as SnarkProof, zkevm_circuits::scheduler::block_header::BlockAuxilaryOutputWitness, }, get_current_pod_name, AuxOutputWitnessWrapper, FriProofWrapper, From 1cf7bb3da9af7199e86da5903b69630cdcf692bf Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Wed, 1 May 2024 17:07:00 +0300 Subject: [PATCH 05/32] one more revision change, update imports --- prover/Cargo.lock | 6 +++--- prover/Cargo.toml | 2 +- prover/proof_fri_compressor/src/compressor.rs | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 036b27d46e47..67d7faa01897 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -2391,7 +2391,7 @@ dependencies = [ [[package]] name = "gpu-ffi" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=5464d5d#5464d5d43c49065e659221fa55fb6b8f17cff1a0" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=3d33e06#3d33e069d9d263f3a9626d235ac6dc6c49179965" dependencies = [ "bindgen 0.59.2", "crossbeam 0.7.3", @@ -2404,7 +2404,7 @@ dependencies = [ [[package]] name = "gpu-prover" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=5464d5d#5464d5d43c49065e659221fa55fb6b8f17cff1a0" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=3d33e06#3d33e069d9d263f3a9626d235ac6dc6c49179965" dependencies = [ "bit-vec", "cfg-if 1.0.0", @@ -7198,7 +7198,7 @@ dependencies = [ [[package]] name = "wrapper-prover" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=5464d5d#5464d5d43c49065e659221fa55fb6b8f17cff1a0" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=3d33e06#3d33e069d9d263f3a9626d235ac6dc6c49179965" dependencies = [ "circuit_definitions 0.1.0", "gpu-prover", diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 51c0071f144b..05d6d01964a2 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -86,7 +86,7 @@ zksync_system_constants = { path = "../core/lib/constants" } zksync_types = { path = "../core/lib/types" } zksync_utils = { path = "../core/lib/utils" } -wrapper_prover = { package = "wrapper-prover", git = "https://github.com/matter-labs/era-heavy-ops-service.git", rev = "5464d5d" } +wrapper_prover = { package = "wrapper-prover", git = "https://github.com/matter-labs/era-heavy-ops-service.git", rev = "3d33e06" } # for `perf` profiling diff --git a/prover/proof_fri_compressor/src/compressor.rs b/prover/proof_fri_compressor/src/compressor.rs index b93bed237fd2..5642f7fec160 100644 --- a/prover/proof_fri_compressor/src/compressor.rs +++ b/prover/proof_fri_compressor/src/compressor.rs @@ -7,18 +7,19 @@ use prover_dal::{ConnectionPool, Prover, ProverDal}; use tokio::task::JoinHandle; #[cfg(feature = "gpu")] use wrapper_prover::{ - GPUWrapperConfigs, Proof as SnarkProof, WrapperProver, ZkSyncSnarkWrapperCircuit, + Bn256, GPUWrapperConfigs, Proof as SnarkProof, WrapperProver, ZkSyncSnarkWrapperCircuit, DEFAULT_WRAPPER_CONFIG, }; #[allow(unused_imports)] use zkevm_test_harness::proof_wrapper_utils::{get_trusted_setup, wrap_proof}; +#[cfg(not(feature = "gpu"))] +use zkevm_test_harness_1_3_3::bellman::bn256::Bn256; use zkevm_test_harness_1_3_3::{ abstract_zksync_circuit::concrete_circuits::{ ZkSyncCircuit, ZkSyncProof, ZkSyncVerificationKey, }, - bellman::{ - bn256::Bn256, - plonk::better_better_cs::{proof::Proof, setup::VerificationKey as SnarkVerificationKey}, + bellman::plonk::better_better_cs::{ + proof::Proof, setup::VerificationKey as SnarkVerificationKey, }, witness::oracle::VmWitnessOracle, }; From a196bb89238bdb0bf0d8635e19c1d07f60bd359c Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Wed, 1 May 2024 17:11:24 +0300 Subject: [PATCH 06/32] move the gpu part out of the method --- prover/proof_fri_compressor/src/compressor.rs | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/prover/proof_fri_compressor/src/compressor.rs b/prover/proof_fri_compressor/src/compressor.rs index 5642f7fec160..47a1f2c13395 100644 --- a/prover/proof_fri_compressor/src/compressor.rs +++ b/prover/proof_fri_compressor/src/compressor.rs @@ -106,23 +106,13 @@ impl ProofCompressor { wrapper_proof.into_inner() } - #[cfg(feature = "gpu")] - fn get_wrapper_proof( - proof: ZkSyncRecursionLayerProof, - scheduler_vk: ZkSyncRecursionLayerVerificationKey, - _compression_mode: u8, - ) -> SnarkProof { - let crs = get_trusted_setup(); - let wrapper_config = DEFAULT_WRAPPER_CONFIG; - let mut prover = WrapperProver::::new(&crs, wrapper_config).unwrap(); - - prover - .generate_setup_data(scheduler_vk.into_inner()) - .unwrap(); - prover.generate_proofs(proof.into_inner()).unwrap(); - - prover.get_wrapper_proof().unwrap() - } + // #[cfg(feature = "gpu")] + // fn get_wrapper_proof( + // proof: ZkSyncRecursionLayerProof, + // scheduler_vk: ZkSyncRecursionLayerVerificationKey, + // _compression_mode: u8, + // ) -> SnarkProof { + // } pub fn compress_proof( proof: ZkSyncRecursionLayerProof, @@ -136,6 +126,20 @@ impl ProofCompressor { ) .context("get_recursiver_layer_vk_for_circuit_type()")?; + #[cfg(feature = "gpu")] + let wrapper_proof = { + let crs = get_trusted_setup(); + let wrapper_config = DEFAULT_WRAPPER_CONFIG; + let mut prover = WrapperProver::::new(&crs, wrapper_config).unwrap(); + + prover + .generate_setup_data(scheduler_vk.into_inner()) + .unwrap(); + prover.generate_proofs(proof.into_inner()).unwrap(); + + prover.get_wrapper_proof().unwrap() + }; + #[cfg(not(feature = "gpu"))] let wrapper_proof = Self::get_wrapper_proof(proof, scheduler_vk, compression_mode); // (Re)serialization should always succeed. From 026746a663220827ec01559d865344221bcb1a9a Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Wed, 1 May 2024 17:12:43 +0300 Subject: [PATCH 07/32] add generic const expr --- prover/proof_fri_compressor/src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/prover/proof_fri_compressor/src/main.rs b/prover/proof_fri_compressor/src/main.rs index 2ae19423d453..af00e368375d 100644 --- a/prover/proof_fri_compressor/src/main.rs +++ b/prover/proof_fri_compressor/src/main.rs @@ -1,3 +1,5 @@ +#![feature(generic_const_exprs)] + use std::{env, time::Duration}; use anyhow::Context as _; From 64781c438548e4e7e41d991aac81689331c27e7f Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Fri, 3 May 2024 14:27:18 +0300 Subject: [PATCH 08/32] add import for cpu --- prover/proof_fri_compressor/src/compressor.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/prover/proof_fri_compressor/src/compressor.rs b/prover/proof_fri_compressor/src/compressor.rs index 47a1f2c13395..5652252aa2e4 100644 --- a/prover/proof_fri_compressor/src/compressor.rs +++ b/prover/proof_fri_compressor/src/compressor.rs @@ -10,6 +10,8 @@ use wrapper_prover::{ Bn256, GPUWrapperConfigs, Proof as SnarkProof, WrapperProver, ZkSyncSnarkWrapperCircuit, DEFAULT_WRAPPER_CONFIG, }; +#[cfg(not(feature = "gpu"))] +use zkevm_test_harness::proof_wrapper_utils::WrapperConfig; #[allow(unused_imports)] use zkevm_test_harness::proof_wrapper_utils::{get_trusted_setup, wrap_proof}; #[cfg(not(feature = "gpu"))] From 7b5cfc89c69f1644382b9ba17b9209863e101367 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Fri, 3 May 2024 18:07:15 +0300 Subject: [PATCH 09/32] update rev for wrapper --- prover/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 05d6d01964a2..b0ea682e3b6b 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -86,7 +86,7 @@ zksync_system_constants = { path = "../core/lib/constants" } zksync_types = { path = "../core/lib/types" } zksync_utils = { path = "../core/lib/utils" } -wrapper_prover = { package = "wrapper-prover", git = "https://github.com/matter-labs/era-heavy-ops-service.git", rev = "3d33e06" } +wrapper_prover = { package = "wrapper-prover", git = "https://github.com/matter-labs/era-heavy-ops-service.git", rev = "6f77bf0" } # for `perf` profiling From 0f31e733c8a6c06e2794d0e54aa2ed129c5e6185 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Tue, 7 May 2024 17:40:20 +0300 Subject: [PATCH 10/32] reset changes --- prover/Cargo.lock | 6 ++-- prover/proof_fri_compressor/src/compressor.rs | 36 ++++--------------- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 67d7faa01897..6d39bf6febc3 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -2391,7 +2391,7 @@ dependencies = [ [[package]] name = "gpu-ffi" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=3d33e06#3d33e069d9d263f3a9626d235ac6dc6c49179965" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=6f77bf0#6f77bf042e429935fb88ef31c17df5bb76bf22e0" dependencies = [ "bindgen 0.59.2", "crossbeam 0.7.3", @@ -2404,7 +2404,7 @@ dependencies = [ [[package]] name = "gpu-prover" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=3d33e06#3d33e069d9d263f3a9626d235ac6dc6c49179965" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=6f77bf0#6f77bf042e429935fb88ef31c17df5bb76bf22e0" dependencies = [ "bit-vec", "cfg-if 1.0.0", @@ -7198,7 +7198,7 @@ dependencies = [ [[package]] name = "wrapper-prover" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=3d33e06#3d33e069d9d263f3a9626d235ac6dc6c49179965" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=6f77bf0#6f77bf042e429935fb88ef31c17df5bb76bf22e0" dependencies = [ "circuit_definitions 0.1.0", "gpu-prover", diff --git a/prover/proof_fri_compressor/src/compressor.rs b/prover/proof_fri_compressor/src/compressor.rs index 5652252aa2e4..4cd16b956333 100644 --- a/prover/proof_fri_compressor/src/compressor.rs +++ b/prover/proof_fri_compressor/src/compressor.rs @@ -26,17 +26,11 @@ use zkevm_test_harness_1_3_3::{ witness::oracle::VmWitnessOracle, }; use zksync_object_store::ObjectStore; -#[cfg(not(feature = "gpu"))] -use zksync_prover_fri_types::circuit_definitions::{ - circuit_definitions::aux_layer::ZkSyncSnarkWrapperCircuit, - snark_wrapper::franklin_crypto::bellman::plonk::better_better_cs::proof::Proof as SnarkProof, -}; use zksync_prover_fri_types::{ circuit_definitions::{ boojum::field::goldilocks::GoldilocksField, circuit_definitions::recursion_layer::{ ZkSyncRecursionLayerProof, ZkSyncRecursionLayerStorageType, - ZkSyncRecursionLayerVerificationKey, }, zkevm_circuits::scheduler::block_header::BlockAuxilaryOutputWitness, }, @@ -95,30 +89,9 @@ impl ProofCompressor { } Ok(()) } - - #[cfg(not(feature = "gpu"))] - fn get_wrapper_proof( - proof: ZkSyncRecursionLayerProof, - scheduler_vk: ZkSyncRecursionLayerVerificationKey, - compression_mode: u8, - ) -> SnarkProof { - let config = WrapperConfig::new(compression_mode); - - let (wrapper_proof, _) = wrap_proof(proof, scheduler_vk, config); - wrapper_proof.into_inner() - } - - // #[cfg(feature = "gpu")] - // fn get_wrapper_proof( - // proof: ZkSyncRecursionLayerProof, - // scheduler_vk: ZkSyncRecursionLayerVerificationKey, - // _compression_mode: u8, - // ) -> SnarkProof { - // } - pub fn compress_proof( proof: ZkSyncRecursionLayerProof, - compression_mode: u8, + _compression_mode: u8, verify_wrapper_proof: bool, ) -> anyhow::Result { let keystore = Keystore::default(); @@ -142,7 +115,12 @@ impl ProofCompressor { prover.get_wrapper_proof().unwrap() }; #[cfg(not(feature = "gpu"))] - let wrapper_proof = Self::get_wrapper_proof(proof, scheduler_vk, compression_mode); + let wrapper_proof = { + let config = WrapperConfig::new(_compression_mode); + + let (wrapper_proof, _) = wrap_proof(proof, scheduler_vk, config); + wrapper_proof.into_inner() + }; // (Re)serialization should always succeed. let serialized = bincode::serialize(&wrapper_proof) From 9e5fcb47feb7483fe90579b4a7e1aa5ad051fea4 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Tue, 7 May 2024 17:47:30 +0300 Subject: [PATCH 11/32] add info how to run the compressor --- prover/prover_fri/README.md | 47 +++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/prover/prover_fri/README.md b/prover/prover_fri/README.md index 9ec6cb870c75..f3a1e79d4374 100644 --- a/prover/prover_fri/README.md +++ b/prover/prover_fri/README.md @@ -16,9 +16,9 @@ will pull jobs from the database and do their part of the pipeline, loading inte ```mermaid flowchart LR - A["Operator"] --> |Produces block| F[Prover Gateway] - F --> |Inserts into DB| B["Postgres DB"] - B --> |Retrieves proven block \nafter compression| F + A["Operator"] -->|Produces block| F[Prover Gateway] + F -->|Inserts into DB| B["Postgres DB"] + B -->|Retrieves proven block \nafter compression| F B --> C["Witness"] C --- C1["Basic Circuits"] C --- C2["Leaf Aggregation"] @@ -27,9 +27,9 @@ flowchart LR C --- C5["Scheduler"] C --> B B --> D["Vector Generator/Prover"] - D --> |Proven Block| B + D -->|Proven Block| B B --> G["Compressor"] - G --> |Compressed block| B + G -->|Compressed block| B ``` ## Prerequisites @@ -167,6 +167,43 @@ Machine specs: zk f cargo run --release --bin zksync_proof_fri_compressor ``` +## Running GPU compressors + +There is an option to run compressors with the GPU, which will significantly improve the performance. + +1. The hardware setup should be the same as for GPU prover +2. Install and compile `era-bellman-cuda` library + +```shell +git clone https://github.com/matter-labs/bellman-cuda.git --branch dev bellman-cuda; fi +cmake -Bbellman-cuda/build -Sbellman-cuda/ -DCMAKE_BUILD_TYPE=Release +cmake --build bellman-cuda/build/ +``` + +3. Set path of library as environmental variable + +```shell +export BELLMAN_CUDA_DIR=$PWD/bellman-cuda +``` + +4. GPU compressor uses `setup_2^24.key`. Download it by using: + +```shell +wget https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^24.key +``` + +5. Set the env variable with it's path: + +```shell +export CRS_FILE=$PWD/setup_2^24.key +``` + +6. Run the compressor using: + +```shell +zk f cargo run ---features "gpu" --release --bin zksync_proof_fri_compressor +``` + ## Checking the status of the prover Once everything is running (either with the CPU or GPU prover), the server should have at least three blocks, and you From 56678c7a7e3708c105f55643951d660a3dd81f8d Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Tue, 7 May 2024 17:54:13 +0300 Subject: [PATCH 12/32] update imports --- prover/proof_fri_compressor/src/compressor.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/prover/proof_fri_compressor/src/compressor.rs b/prover/proof_fri_compressor/src/compressor.rs index 4cd16b956333..6523f4eef604 100644 --- a/prover/proof_fri_compressor/src/compressor.rs +++ b/prover/proof_fri_compressor/src/compressor.rs @@ -6,10 +6,7 @@ use circuit_sequencer_api::proof::FinalProof; use prover_dal::{ConnectionPool, Prover, ProverDal}; use tokio::task::JoinHandle; #[cfg(feature = "gpu")] -use wrapper_prover::{ - Bn256, GPUWrapperConfigs, Proof as SnarkProof, WrapperProver, ZkSyncSnarkWrapperCircuit, - DEFAULT_WRAPPER_CONFIG, -}; +use wrapper_prover::{Bn256, GPUWrapperConfigs, WrapperProver, DEFAULT_WRAPPER_CONFIG}; #[cfg(not(feature = "gpu"))] use zkevm_test_harness::proof_wrapper_utils::WrapperConfig; #[allow(unused_imports)] From 2c0a988eeb0312fb25a245a0c561fa77dbded056 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Tue, 7 May 2024 18:01:37 +0300 Subject: [PATCH 13/32] update revision --- prover/Cargo.lock | 6 +++--- prover/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 6d39bf6febc3..67d7faa01897 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -2391,7 +2391,7 @@ dependencies = [ [[package]] name = "gpu-ffi" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=6f77bf0#6f77bf042e429935fb88ef31c17df5bb76bf22e0" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=3d33e06#3d33e069d9d263f3a9626d235ac6dc6c49179965" dependencies = [ "bindgen 0.59.2", "crossbeam 0.7.3", @@ -2404,7 +2404,7 @@ dependencies = [ [[package]] name = "gpu-prover" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=6f77bf0#6f77bf042e429935fb88ef31c17df5bb76bf22e0" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=3d33e06#3d33e069d9d263f3a9626d235ac6dc6c49179965" dependencies = [ "bit-vec", "cfg-if 1.0.0", @@ -7198,7 +7198,7 @@ dependencies = [ [[package]] name = "wrapper-prover" version = "0.1.0" -source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=6f77bf0#6f77bf042e429935fb88ef31c17df5bb76bf22e0" +source = "git+https://github.com/matter-labs/era-heavy-ops-service.git?rev=3d33e06#3d33e069d9d263f3a9626d235ac6dc6c49179965" dependencies = [ "circuit_definitions 0.1.0", "gpu-prover", diff --git a/prover/Cargo.toml b/prover/Cargo.toml index b0ea682e3b6b..05d6d01964a2 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -86,7 +86,7 @@ zksync_system_constants = { path = "../core/lib/constants" } zksync_types = { path = "../core/lib/types" } zksync_utils = { path = "../core/lib/utils" } -wrapper_prover = { package = "wrapper-prover", git = "https://github.com/matter-labs/era-heavy-ops-service.git", rev = "6f77bf0" } +wrapper_prover = { package = "wrapper-prover", git = "https://github.com/matter-labs/era-heavy-ops-service.git", rev = "3d33e06" } # for `perf` profiling From 528d53323df3ea2f57197419f55b14e0119d85cc Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Tue, 7 May 2024 18:13:05 +0300 Subject: [PATCH 14/32] try satisfying lint --- prover/prover_fri/README.md | 39 ++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/prover/prover_fri/README.md b/prover/prover_fri/README.md index f3a1e79d4374..a31f883c51b6 100644 --- a/prover/prover_fri/README.md +++ b/prover/prover_fri/README.md @@ -173,36 +173,31 @@ There is an option to run compressors with the GPU, which will significantly imp 1. The hardware setup should be the same as for GPU prover 2. Install and compile `era-bellman-cuda` library - -```shell -git clone https://github.com/matter-labs/bellman-cuda.git --branch dev bellman-cuda; fi -cmake -Bbellman-cuda/build -Sbellman-cuda/ -DCMAKE_BUILD_TYPE=Release -cmake --build bellman-cuda/build/ -``` + ```console + git clone https://github.com/matter-labs/bellman-cuda.git --branch dev bellman-cuda; fi + cmake -Bbellman-cuda/build -Sbellman-cuda/ -DCMAKE_BUILD_TYPE=Release + cmake --build bellman-cuda/build/ + ``` 3. Set path of library as environmental variable - -```shell -export BELLMAN_CUDA_DIR=$PWD/bellman-cuda -``` + ```console + export BELLMAN_CUDA_DIR=$PWD/bellman-cuda + ``` 4. GPU compressor uses `setup_2^24.key`. Download it by using: - -```shell -wget https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^24.key -``` + ```console + wget https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^24.key + ``` 5. Set the env variable with it's path: - -```shell -export CRS_FILE=$PWD/setup_2^24.key -``` + ```console + export CRS_FILE=$PWD/setup_2^24.key + ``` 6. Run the compressor using: - -```shell -zk f cargo run ---features "gpu" --release --bin zksync_proof_fri_compressor -``` + ```console + zk f cargo run ---features "gpu" --release --bin zksync_proof_fri_compressor + ``` ## Checking the status of the prover From 32b51566e29d1e5e7be46339f5bfed9efef5500b Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Wed, 8 May 2024 13:38:19 +0300 Subject: [PATCH 15/32] update dockerfile --- .github/workflows/build-prover-template.yml | 6 ++- docker/proof-gpu-fri-compressor/Dockerfile | 47 +++++++++++++++++++++ etc/env/base/fri_proof_compressor.toml | 18 ++++---- prover/prover_fri/README.md | 2 +- 4 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 docker/proof-gpu-fri-compressor/Dockerfile diff --git a/.github/workflows/build-prover-template.yml b/.github/workflows/build-prover-template.yml index bd8ba742aed1..da27b7ff472a 100644 --- a/.github/workflows/build-prover-template.yml +++ b/.github/workflows/build-prover-template.yml @@ -41,7 +41,7 @@ jobs: RUNNER_COMPOSE_FILE: "docker-compose-runner-nightly.yml" ERA_BELLMAN_CUDA_RELEASE: ${{ inputs.ERA_BELLMAN_CUDA_RELEASE }} CUDA_ARCH: ${{ inputs.CUDA_ARCH }} - runs-on: [matterlabs-ci-runner] + runs-on: [ matterlabs-ci-runner ] strategy: matrix: component: @@ -51,6 +51,7 @@ jobs: - witness-vector-generator - prover-fri-gateway - proof-fri-compressor + - proof-gpu-fri-compressor steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 with: @@ -82,6 +83,7 @@ jobs: - name: download CRS if: matrix.component == 'proof-fri-compressor' run: | + ci_run curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^24.key ci_run curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key - name: login to Docker registries @@ -137,7 +139,7 @@ jobs: env: DOCKER_ACTION: ${{ inputs.action }} COMPONENT: ${{ matrix.component }} - run: | + run: | PASSED_ENV_VARS="ERA_BELLMAN_CUDA_RELEASE,CUDA_ARCH" \ ci_run zk docker $DOCKER_ACTION $COMPONENT diff --git a/docker/proof-gpu-fri-compressor/Dockerfile b/docker/proof-gpu-fri-compressor/Dockerfile new file mode 100644 index 000000000000..053cfda38a81 --- /dev/null +++ b/docker/proof-gpu-fri-compressor/Dockerfile @@ -0,0 +1,47 @@ +# Will work locally only after prior universal setup key download +FROM nvidia/cuda:12.2.0-devel-ubuntu22.04 as builder + +ARG DEBIAN_FRONTEND=noninteractive + +ARG CUDA_ARCH=89 +ENV CUDAARCHS=${CUDA_ARCH} + +RUN apt-get update && apt-get install -y curl clang openssl libssl-dev gcc g++ \ + pkg-config build-essential libclang-dev && \ + rm -rf /var/lib/apt/lists/* + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH + +RUN curl https://sh.rustup.rs -sSf | bash -s -- -y && \ + rustup install nightly-2023-08-21 && \ + rustup default nightly-2023-08-21 + +RUN curl -Lo cmake-3.24.2-linux-x86_64.sh https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2-linux-x86_64.sh && \ + chmod +x cmake-3.24.2-linux-x86_64.sh && \ + ./cmake-3.24.2-linux-x86_64.sh --skip-license --prefix=/usr/local + +WORKDIR /usr/src/zksync +COPY . . + +RUN cd prover && \ + git clone https://github.com/matter-labs/bellman-cuda.git --branch dev bellman-cuda && \ + cmake -Bbellman-cuda/build -Sbellman-cuda/ -DCMAKE_BUILD_TYPE=Release && \ + cmake --build bellman-cuda/build/ && \ + export BELLMAN_CUDA_DIR=$PWD/bellman-cuda +RUN cd prover && cargo build --features "gpu" --release --bin zksync_proof_fri_compressor + +FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04 + +RUN apt-get update && apt-get install -y curl libpq5 ca-certificates && rm -rf /var/lib/apt/lists/* + +# copy VK required for proof wrapping +COPY prover/vk_setup_data_generator_server_fri/data/ /prover/vk_setup_data_generator_server_fri/data/ + +# copy universal setup key required for proof compression +COPY setup_2\^24.key /setup_2\^24.key + +COPY --from=builder /usr/src/zksync/prover/target/release/zksync_proof_fri_compressor /usr/bin/ + +ENTRYPOINT ["zksync_proof_fri_compressor"] diff --git a/etc/env/base/fri_proof_compressor.toml b/etc/env/base/fri_proof_compressor.toml index bda943391f06..9d26fe876896 100644 --- a/etc/env/base/fri_proof_compressor.toml +++ b/etc/env/base/fri_proof_compressor.toml @@ -1,10 +1,10 @@ [fri_proof_compressor] -compression_mode=1 -prometheus_listener_port=3321 -prometheus_pushgateway_url="http://127.0.0.1:9091" -prometheus_push_interval_ms=100 -generation_timeout_in_secs=3600 -max_attempts=5 -universal_setup_path="../keys/setup/setup_2^26.key" -universal_setup_download_url="https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^26.key" -verify_wrapper_proof=true +compression_mode = 1 +prometheus_listener_port = 3321 +prometheus_pushgateway_url = "http://127.0.0.1:9091" +prometheus_push_interval_ms = 100 +generation_timeout_in_secs = 3600 +max_attempts = 5 +universal_setup_path = "../keys/setup/setup_2^24.key" +universal_setup_download_url = "https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^24.key" +verify_wrapper_proof = true diff --git a/prover/prover_fri/README.md b/prover/prover_fri/README.md index a31f883c51b6..d195ba5e79f5 100644 --- a/prover/prover_fri/README.md +++ b/prover/prover_fri/README.md @@ -174,7 +174,7 @@ There is an option to run compressors with the GPU, which will significantly imp 1. The hardware setup should be the same as for GPU prover 2. Install and compile `era-bellman-cuda` library ```console - git clone https://github.com/matter-labs/bellman-cuda.git --branch dev bellman-cuda; fi + git clone https://github.com/matter-labs/bellman-cuda.git --branch dev bellman-cuda cmake -Bbellman-cuda/build -Sbellman-cuda/ -DCMAKE_BUILD_TYPE=Release cmake --build bellman-cuda/build/ ``` From 049c3dd067f1264a1fdf61be91ba0613c9f4b9d1 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Thu, 9 May 2024 11:43:02 +0300 Subject: [PATCH 16/32] update dockerfile --- docker/proof-fri-compressor/Dockerfile | 36 +++++++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/docker/proof-fri-compressor/Dockerfile b/docker/proof-fri-compressor/Dockerfile index afa8477dcf72..8d7303192859 100644 --- a/docker/proof-fri-compressor/Dockerfile +++ b/docker/proof-fri-compressor/Dockerfile @@ -1,24 +1,46 @@ # Will work locally only after prior universal setup key download - -FROM matterlabs/zksync-build-base:latest as builder +FROM nvidia/cuda:12.2.0-devel-ubuntu22.04 as builder ARG DEBIAN_FRONTEND=noninteractive +ARG CUDA_ARCH=89 +ENV CUDAARCHS=${CUDA_ARCH} + +RUN apt-get update && apt-get install -y curl clang openssl libssl-dev gcc g++ git \ + pkg-config build-essential libclang-dev && \ + rm -rf /var/lib/apt/lists/* + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH + +RUN curl https://sh.rustup.rs -sSf | bash -s -- -y && \ + rustup install nightly-2023-08-21 && \ + rustup default nightly-2023-08-21 + +RUN curl -Lo cmake-3.24.2-linux-x86_64.sh https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2-linux-x86_64.sh && \ + chmod +x cmake-3.24.2-linux-x86_64.sh && \ + ./cmake-3.24.2-linux-x86_64.sh --skip-license --prefix=/usr/local + WORKDIR /usr/src/zksync COPY . . -RUN cd prover && cargo build --release --bin zksync_proof_fri_compressor +RUN mkdir keys && cd keys && mkdir setup && cd setup && curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^24.key + +RUN cd prover && \ + git clone https://github.com/matter-labs/era-bellman-cuda.git --branch main bellman-cuda && \ + cmake -Bbellman-cuda/build -Sbellman-cuda/ -DCMAKE_BUILD_TYPE=Release && \ + cmake --build bellman-cuda/build/ -FROM debian:bookworm-slim +RUN cd prover && BELLMAN_CUDA_DIR=$PWD/bellman-cuda cargo build --features "gpu" --release --bin zksync_proof_fri_compressor + +FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04 RUN apt-get update && apt-get install -y curl libpq5 ca-certificates && rm -rf /var/lib/apt/lists/* # copy VK required for proof wrapping COPY prover/vk_setup_data_generator_server_fri/data/ /prover/vk_setup_data_generator_server_fri/data/ -# copy universal setup key required for proof compression -COPY setup_2\^26.key /setup_2\^26.key - COPY --from=builder /usr/src/zksync/prover/target/release/zksync_proof_fri_compressor /usr/bin/ ENTRYPOINT ["zksync_proof_fri_compressor"] From 1db57baddbaac957fa2b6a48c8c9da18ae17f706 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Thu, 9 May 2024 11:43:33 +0300 Subject: [PATCH 17/32] fmt --- prover/prover_fri/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/prover/prover_fri/README.md b/prover/prover_fri/README.md index d195ba5e79f5..b454153e6f22 100644 --- a/prover/prover_fri/README.md +++ b/prover/prover_fri/README.md @@ -173,6 +173,7 @@ There is an option to run compressors with the GPU, which will significantly imp 1. The hardware setup should be the same as for GPU prover 2. Install and compile `era-bellman-cuda` library + ```console git clone https://github.com/matter-labs/bellman-cuda.git --branch dev bellman-cuda cmake -Bbellman-cuda/build -Sbellman-cuda/ -DCMAKE_BUILD_TYPE=Release @@ -180,16 +181,19 @@ There is an option to run compressors with the GPU, which will significantly imp ``` 3. Set path of library as environmental variable + ```console export BELLMAN_CUDA_DIR=$PWD/bellman-cuda ``` 4. GPU compressor uses `setup_2^24.key`. Download it by using: + ```console wget https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^24.key ``` 5. Set the env variable with it's path: + ```console export CRS_FILE=$PWD/setup_2^24.key ``` From 0da4604c33332e0e067db75b55d8956472f8d88f Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Thu, 9 May 2024 11:57:29 +0300 Subject: [PATCH 18/32] satisfy lint --- .github/workflows/build-prover-template.yml | 1 - prover/prover_fri/README.md | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-prover-template.yml b/.github/workflows/build-prover-template.yml index da27b7ff472a..5fc584d4419e 100644 --- a/.github/workflows/build-prover-template.yml +++ b/.github/workflows/build-prover-template.yml @@ -51,7 +51,6 @@ jobs: - witness-vector-generator - prover-fri-gateway - proof-fri-compressor - - proof-gpu-fri-compressor steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 with: diff --git a/prover/prover_fri/README.md b/prover/prover_fri/README.md index b454153e6f22..3b76023416e6 100644 --- a/prover/prover_fri/README.md +++ b/prover/prover_fri/README.md @@ -199,6 +199,7 @@ There is an option to run compressors with the GPU, which will significantly imp ``` 6. Run the compressor using: + ```console zk f cargo run ---features "gpu" --release --bin zksync_proof_fri_compressor ``` From e19ac67569ab3d7b2575d7fa2080640db2e15399 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Mon, 20 May 2024 16:06:24 +0300 Subject: [PATCH 19/32] update images --- .github/workflows/build-prover-template.yml | 4 ++-- etc/env/file_based/general.yaml | 4 ++-- prover/setup.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-prover-template.yml b/.github/workflows/build-prover-template.yml index 5fc584d4419e..2f868c4602fd 100644 --- a/.github/workflows/build-prover-template.yml +++ b/.github/workflows/build-prover-template.yml @@ -51,6 +51,7 @@ jobs: - witness-vector-generator - prover-fri-gateway - proof-fri-compressor + - proof-gpu-fri-compressor steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 with: @@ -80,10 +81,9 @@ jobs: # We need the CRS only for the fri compressor. - name: download CRS - if: matrix.component == 'proof-fri-compressor' + if: matrix.component == 'proof-fri-compressor' || matrix.component == 'proof-gpu-fri-compressor' run: | ci_run curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^24.key - ci_run curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key - name: login to Docker registries if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) diff --git a/etc/env/file_based/general.yaml b/etc/env/file_based/general.yaml index 19adec9b376c..60174d719064 100644 --- a/etc/env/file_based/general.yaml +++ b/etc/env/file_based/general.yaml @@ -200,8 +200,8 @@ proof_compressor: prometheus_push_interval_ms: 100 generation_timeout_in_secs: 3600 max_attempts: 5 - universal_setup_path: keys/setup/setup_2^26.key - universal_setup_download_url: https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^26.key + universal_setup_path: keys/setup/setup_2^24.key + universal_setup_download_url: https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^24.key verify_wrapper_proof: true prover_group: group_0: diff --git a/prover/setup.sh b/prover/setup.sh index e755f5ae433a..57a5c34a677f 100755 --- a/prover/setup.sh +++ b/prover/setup.sh @@ -18,7 +18,7 @@ sed -i.backup 's/^proof_loading_mode=.*$/proof_loading_mode="FriProofFromGcs"/' rm ../etc/env/base/eth_sender.toml.backup sed -i.backup 's/^setup_data_path=.*$/setup_data_path="vk_setup_data_generator_server_fri\/data\/"/' ../etc/env/base/fri_prover.toml rm ../etc/env/base/fri_prover.toml.backup -sed -i.backup 's/^universal_setup_path=.*$/universal_setup_path="..\/keys\/setup\/setup_2^26.key"/' ../etc/env/base/fri_proof_compressor.toml +sed -i.backup 's/^universal_setup_path=.*$/universal_setup_path="..\/keys\/setup\/setup_2^24.key"/' ../etc/env/base/fri_proof_compressor.toml rm ../etc/env/base/fri_proof_compressor.toml.backup zk config compile dev From 22e2a5d5921572aeef02ae38da75d877cd38d788 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Mon, 20 May 2024 16:09:06 +0300 Subject: [PATCH 20/32] return back dockerfile --- docker/proof-fri-compressor/Dockerfile | 38 ++++++-------------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/docker/proof-fri-compressor/Dockerfile b/docker/proof-fri-compressor/Dockerfile index 8d7303192859..947e7a60a024 100644 --- a/docker/proof-fri-compressor/Dockerfile +++ b/docker/proof-fri-compressor/Dockerfile @@ -1,46 +1,24 @@ # Will work locally only after prior universal setup key download -FROM nvidia/cuda:12.2.0-devel-ubuntu22.04 as builder -ARG DEBIAN_FRONTEND=noninteractive - -ARG CUDA_ARCH=89 -ENV CUDAARCHS=${CUDA_ARCH} - -RUN apt-get update && apt-get install -y curl clang openssl libssl-dev gcc g++ git \ - pkg-config build-essential libclang-dev && \ - rm -rf /var/lib/apt/lists/* - -ENV RUSTUP_HOME=/usr/local/rustup \ - CARGO_HOME=/usr/local/cargo \ - PATH=/usr/local/cargo/bin:$PATH - -RUN curl https://sh.rustup.rs -sSf | bash -s -- -y && \ - rustup install nightly-2023-08-21 && \ - rustup default nightly-2023-08-21 +FROM matterlabs/zksync-build-base:latest as builder -RUN curl -Lo cmake-3.24.2-linux-x86_64.sh https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2-linux-x86_64.sh && \ - chmod +x cmake-3.24.2-linux-x86_64.sh && \ - ./cmake-3.24.2-linux-x86_64.sh --skip-license --prefix=/usr/local +ARG DEBIAN_FRONTEND=noninteractive WORKDIR /usr/src/zksync COPY . . -RUN mkdir keys && cd keys && mkdir setup && cd setup && curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^24.key - -RUN cd prover && \ - git clone https://github.com/matter-labs/era-bellman-cuda.git --branch main bellman-cuda && \ - cmake -Bbellman-cuda/build -Sbellman-cuda/ -DCMAKE_BUILD_TYPE=Release && \ - cmake --build bellman-cuda/build/ +RUN cd prover && cargo build --release --bin zksync_proof_fri_compressor -RUN cd prover && BELLMAN_CUDA_DIR=$PWD/bellman-cuda cargo build --features "gpu" --release --bin zksync_proof_fri_compressor - -FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04 +FROM debian:bookworm-slim RUN apt-get update && apt-get install -y curl libpq5 ca-certificates && rm -rf /var/lib/apt/lists/* # copy VK required for proof wrapping COPY prover/vk_setup_data_generator_server_fri/data/ /prover/vk_setup_data_generator_server_fri/data/ +# copy universal setup key required for proof compression +COPY setup_2\^26.key /setup_2\^26.key + COPY --from=builder /usr/src/zksync/prover/target/release/zksync_proof_fri_compressor /usr/bin/ -ENTRYPOINT ["zksync_proof_fri_compressor"] +ENTRYPOINT ["zksync_proof_fri_compressor"] \ No newline at end of file From 36ea3ad87f9318e7283553c9ae35d2ed3556d81f Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Mon, 20 May 2024 16:17:34 +0300 Subject: [PATCH 21/32] update zk tool --- infrastructure/zk/src/docker.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/infrastructure/zk/src/docker.ts b/infrastructure/zk/src/docker.ts index fc98e8ad02a3..fd2425db9c08 100644 --- a/infrastructure/zk/src/docker.ts +++ b/infrastructure/zk/src/docker.ts @@ -1,4 +1,4 @@ -import { Command } from 'commander'; +import {Command} from 'commander'; import * as utils from './utils'; const IMAGES = [ @@ -15,6 +15,7 @@ const IMAGES = [ 'witness-vector-generator', 'prover-fri-gateway', 'proof-fri-compressor', + 'proof-gpu-fri-compressor', 'snapshots-creator', 'verified-sources-fetcher' ]; @@ -32,7 +33,7 @@ async function dockerCommand( dockerOrg: string = 'matterlabs' ) { // Generating all tags for containers. We need 2 tags here: SHA and SHA+TS - const { stdout: COMMIT_SHORT_SHA }: { stdout: string } = await utils.exec('git rev-parse --short HEAD'); + const {stdout: COMMIT_SHORT_SHA}: { stdout: string } = await utils.exec('git rev-parse --short HEAD'); // COMMIT_SHORT_SHA returns with newline, so we need to trim it const imageTagShaTS: string = process.env.IMAGE_TAG_SUFFIX ? process.env.IMAGE_TAG_SUFFIX @@ -79,6 +80,7 @@ function defaultTagList(image: string, imageTagSha: string, imageTagShaTS: strin 'witness-vector-generator', 'prover-fri-gateway', 'proof-fri-compressor', + 'proof-gpu-fri-compressor', 'snapshots-creator' ].includes(image) ? ['latest', 'latest2.0', `2.0-${imageTagSha}`, `${imageTagSha}`, `2.0-${imageTagShaTS}`, `${imageTagShaTS}`] From 014ba0e323a44ef68a9d23870373d6181cdb6928 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Mon, 20 May 2024 16:24:45 +0300 Subject: [PATCH 22/32] fmt --- infrastructure/zk/src/docker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infrastructure/zk/src/docker.ts b/infrastructure/zk/src/docker.ts index fd2425db9c08..1a8df3e9b278 100644 --- a/infrastructure/zk/src/docker.ts +++ b/infrastructure/zk/src/docker.ts @@ -1,4 +1,4 @@ -import {Command} from 'commander'; +import { Command } from 'commander'; import * as utils from './utils'; const IMAGES = [ @@ -33,7 +33,7 @@ async function dockerCommand( dockerOrg: string = 'matterlabs' ) { // Generating all tags for containers. We need 2 tags here: SHA and SHA+TS - const {stdout: COMMIT_SHORT_SHA}: { stdout: string } = await utils.exec('git rev-parse --short HEAD'); + const { stdout: COMMIT_SHORT_SHA }: { stdout: string } = await utils.exec('git rev-parse --short HEAD'); // COMMIT_SHORT_SHA returns with newline, so we need to trim it const imageTagShaTS: string = process.env.IMAGE_TAG_SUFFIX ? process.env.IMAGE_TAG_SUFFIX From 95f0d831cfadcbd3418393f4c23fd12181663d63 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Mon, 20 May 2024 16:34:15 +0300 Subject: [PATCH 23/32] update dockerfile --- .github/workflows/build-prover-template.yml | 1 + docker/proof-gpu-fri-compressor/Dockerfile | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-prover-template.yml b/.github/workflows/build-prover-template.yml index 8a1ae2702fdf..b316f4fb13b6 100644 --- a/.github/workflows/build-prover-template.yml +++ b/.github/workflows/build-prover-template.yml @@ -85,6 +85,7 @@ jobs: if: matrix.component == 'proof-fri-compressor' || matrix.component == 'proof-gpu-fri-compressor' run: | ci_run curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^24.key + ci_run curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key - name: login to Docker registries diff --git a/docker/proof-gpu-fri-compressor/Dockerfile b/docker/proof-gpu-fri-compressor/Dockerfile index 053cfda38a81..ffe8edebb9ca 100644 --- a/docker/proof-gpu-fri-compressor/Dockerfile +++ b/docker/proof-gpu-fri-compressor/Dockerfile @@ -6,7 +6,7 @@ ARG DEBIAN_FRONTEND=noninteractive ARG CUDA_ARCH=89 ENV CUDAARCHS=${CUDA_ARCH} -RUN apt-get update && apt-get install -y curl clang openssl libssl-dev gcc g++ \ +RUN apt-get update && apt-get install -y curl clang openssl libssl-dev gcc g++ git \ pkg-config build-essential libclang-dev && \ rm -rf /var/lib/apt/lists/* @@ -25,12 +25,14 @@ RUN curl -Lo cmake-3.24.2-linux-x86_64.sh https://github.com/Kitware/CMake/relea WORKDIR /usr/src/zksync COPY . . +RUN mkdir keys && cd keys && mkdir setup && cd setup && curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^24.key + RUN cd prover && \ - git clone https://github.com/matter-labs/bellman-cuda.git --branch dev bellman-cuda && \ + git clone https://github.com/matter-labs/era-bellman-cuda.git --branch main bellman-cuda && \ cmake -Bbellman-cuda/build -Sbellman-cuda/ -DCMAKE_BUILD_TYPE=Release && \ - cmake --build bellman-cuda/build/ && \ - export BELLMAN_CUDA_DIR=$PWD/bellman-cuda -RUN cd prover && cargo build --features "gpu" --release --bin zksync_proof_fri_compressor + cmake --build bellman-cuda/build/ + +RUN cd prover && BELLMAN_CUDA_DIR=$PWD/bellman-cuda cargo build --features "gpu" --release --bin zksync_proof_fri_compressor FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04 @@ -39,9 +41,6 @@ RUN apt-get update && apt-get install -y curl libpq5 ca-certificates && rm -rf / # copy VK required for proof wrapping COPY prover/vk_setup_data_generator_server_fri/data/ /prover/vk_setup_data_generator_server_fri/data/ -# copy universal setup key required for proof compression -COPY setup_2\^24.key /setup_2\^24.key - COPY --from=builder /usr/src/zksync/prover/target/release/zksync_proof_fri_compressor /usr/bin/ -ENTRYPOINT ["zksync_proof_fri_compressor"] +ENTRYPOINT ["zksync_proof_fri_compressor"] \ No newline at end of file From acd8e22d4dd12fd2099eadea1593dd7f79b2727d Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Mon, 20 May 2024 17:01:59 +0300 Subject: [PATCH 24/32] update cargo.lock --- checks-config/era.dic | 3 +++ docker/proof-gpu-fri-compressor/Dockerfile | 2 ++ prover/Cargo.lock | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/checks-config/era.dic b/checks-config/era.dic index 34610e8e8099..2441d0a25af8 100644 --- a/checks-config/era.dic +++ b/checks-config/era.dic @@ -961,3 +961,6 @@ vec zksync_merkle_tree TreeMetadata delegator +Bbellman +Sbellman +DCMAKE \ No newline at end of file diff --git a/docker/proof-gpu-fri-compressor/Dockerfile b/docker/proof-gpu-fri-compressor/Dockerfile index ffe8edebb9ca..39d551bf4b5b 100644 --- a/docker/proof-gpu-fri-compressor/Dockerfile +++ b/docker/proof-gpu-fri-compressor/Dockerfile @@ -41,6 +41,8 @@ RUN apt-get update && apt-get install -y curl libpq5 ca-certificates && rm -rf / # copy VK required for proof wrapping COPY prover/vk_setup_data_generator_server_fri/data/ /prover/vk_setup_data_generator_server_fri/data/ +COPY --from=builder /usr/src/zksync/keys/setup/setup_2\^24.key keys/setup_2\^24.key + COPY --from=builder /usr/src/zksync/prover/target/release/zksync_proof_fri_compressor /usr/bin/ ENTRYPOINT ["zksync_proof_fri_compressor"] \ No newline at end of file diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 615f925ee3d8..09e30fd4517b 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -4633,7 +4633,7 @@ version = "0.1.0" dependencies = [ "anyhow", "bincode", - "circuit_definitions", + "circuit_definitions 1.5.0", "clap 4.4.6", "colored", "dialoguer", From 087d5bc70fef5b700215ce383c51ecb3650d5d6e Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Mon, 20 May 2024 17:44:46 +0300 Subject: [PATCH 25/32] address comments --- docker/proof-fri-compressor/Dockerfile | 2 +- docker/proof-gpu-fri-compressor/Dockerfile | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docker/proof-fri-compressor/Dockerfile b/docker/proof-fri-compressor/Dockerfile index 947e7a60a024..afa8477dcf72 100644 --- a/docker/proof-fri-compressor/Dockerfile +++ b/docker/proof-fri-compressor/Dockerfile @@ -21,4 +21,4 @@ COPY setup_2\^26.key /setup_2\^26.key COPY --from=builder /usr/src/zksync/prover/target/release/zksync_proof_fri_compressor /usr/bin/ -ENTRYPOINT ["zksync_proof_fri_compressor"] \ No newline at end of file +ENTRYPOINT ["zksync_proof_fri_compressor"] diff --git a/docker/proof-gpu-fri-compressor/Dockerfile b/docker/proof-gpu-fri-compressor/Dockerfile index 39d551bf4b5b..fa6e8da0b79e 100644 --- a/docker/proof-gpu-fri-compressor/Dockerfile +++ b/docker/proof-gpu-fri-compressor/Dockerfile @@ -25,8 +25,6 @@ RUN curl -Lo cmake-3.24.2-linux-x86_64.sh https://github.com/Kitware/CMake/relea WORKDIR /usr/src/zksync COPY . . -RUN mkdir keys && cd keys && mkdir setup && cd setup && curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^24.key - RUN cd prover && \ git clone https://github.com/matter-labs/era-bellman-cuda.git --branch main bellman-cuda && \ cmake -Bbellman-cuda/build -Sbellman-cuda/ -DCMAKE_BUILD_TYPE=Release && \ @@ -41,8 +39,8 @@ RUN apt-get update && apt-get install -y curl libpq5 ca-certificates && rm -rf / # copy VK required for proof wrapping COPY prover/vk_setup_data_generator_server_fri/data/ /prover/vk_setup_data_generator_server_fri/data/ -COPY --from=builder /usr/src/zksync/keys/setup/setup_2\^24.key keys/setup_2\^24.key +RUN mkdir keys && cd keys && mkdir setup && cd setup && curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^24.key COPY --from=builder /usr/src/zksync/prover/target/release/zksync_proof_fri_compressor /usr/bin/ -ENTRYPOINT ["zksync_proof_fri_compressor"] \ No newline at end of file +ENTRYPOINT ["zksync_proof_fri_compressor"] From 646302ca3228185248fd3721186890544a64c1c2 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Mon, 20 May 2024 18:04:14 +0300 Subject: [PATCH 26/32] newline --- checks-config/era.dic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checks-config/era.dic b/checks-config/era.dic index 2441d0a25af8..2b9b8ce7239a 100644 --- a/checks-config/era.dic +++ b/checks-config/era.dic @@ -963,4 +963,4 @@ TreeMetadata delegator Bbellman Sbellman -DCMAKE \ No newline at end of file +DCMAKE From 68159785b6282c1b7eff4d661441891e5339d049 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Tue, 21 May 2024 13:21:07 +0300 Subject: [PATCH 27/32] try using 2^24.key once again --- .../build-contract-verifier-template.yml | 12 +++++------ .github/workflows/build-core-template.yml | 20 +++++++++---------- .github/workflows/build-prover-template.yml | 3 +-- .../src/configs/fri_proof_compressor.rs | 2 +- docker/proof-fri-compressor/Dockerfile | 2 +- docker/proof-gpu-fri-compressor/Dockerfile | 2 +- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-contract-verifier-template.yml b/.github/workflows/build-contract-verifier-template.yml index fab6a6f18a58..adae235e7ddb 100644 --- a/.github/workflows/build-contract-verifier-template.yml +++ b/.github/workflows/build-contract-verifier-template.yml @@ -31,11 +31,11 @@ jobs: runs-on: ${{ fromJSON('["matterlabs-ci-runner", "matterlabs-ci-runner-arm"]')[contains(matrix.platforms, 'arm')] }} strategy: matrix: - components: - - contract-verifier - - verified-sources-fetcher - platforms: - - linux/amd64 + components: + - contract-verifier + - verified-sources-fetcher + platforms: + - linux/amd64 steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 @@ -114,7 +114,7 @@ jobs: ci_run git config --global --add safe.directory /usr/src/zksync/contracts ci_run zk || true ci_run yarn zk build - ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key + ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^24.key - name: build contracts if: env.BUILD_CONTRACTS == 'true' diff --git a/.github/workflows/build-core-template.yml b/.github/workflows/build-core-template.yml index 29b66d991f01..f76dc3f71b8e 100644 --- a/.github/workflows/build-core-template.yml +++ b/.github/workflows/build-core-template.yml @@ -36,15 +36,15 @@ jobs: runs-on: ${{ fromJSON('["matterlabs-ci-runner", "matterlabs-ci-runner-arm"]')[contains(matrix.platforms, 'arm')] }} strategy: matrix: - components: - - server-v2 - - external-node - - snapshots-creator - platforms: - - linux/amd64 - include: - - components: external-node - platforms: linux/arm64 + components: + - server-v2 + - external-node + - snapshots-creator + platforms: + - linux/amd64 + include: + - components: external-node + platforms: linux/arm64 steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 @@ -123,7 +123,7 @@ jobs: ci_run git config --global --add safe.directory /usr/src/zksync/contracts ci_run zk || true ci_run yarn zk build - ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key + ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^24.key - name: build contracts if: env.BUILD_CONTRACTS == 'true' diff --git a/.github/workflows/build-prover-template.yml b/.github/workflows/build-prover-template.yml index b316f4fb13b6..6f0bcc59df66 100644 --- a/.github/workflows/build-prover-template.yml +++ b/.github/workflows/build-prover-template.yml @@ -84,8 +84,7 @@ jobs: - name: download CRS if: matrix.component == 'proof-fri-compressor' || matrix.component == 'proof-gpu-fri-compressor' run: | - ci_run curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^24.key - ci_run curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key + ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^24.key - name: login to Docker registries diff --git a/core/lib/config/src/configs/fri_proof_compressor.rs b/core/lib/config/src/configs/fri_proof_compressor.rs index 4b4e062dee28..0fceac509aca 100644 --- a/core/lib/config/src/configs/fri_proof_compressor.rs +++ b/core/lib/config/src/configs/fri_proof_compressor.rs @@ -20,7 +20,7 @@ pub struct FriProofCompressorConfig { /// Path to universal setup key file pub universal_setup_path: String, - /// https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key + /// https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^24.key pub universal_setup_download_url: String, // Whether to verify wrapper proof or not. diff --git a/docker/proof-fri-compressor/Dockerfile b/docker/proof-fri-compressor/Dockerfile index afa8477dcf72..373f0e1036ef 100644 --- a/docker/proof-fri-compressor/Dockerfile +++ b/docker/proof-fri-compressor/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get update && apt-get install -y curl libpq5 ca-certificates && rm -rf / COPY prover/vk_setup_data_generator_server_fri/data/ /prover/vk_setup_data_generator_server_fri/data/ # copy universal setup key required for proof compression -COPY setup_2\^26.key /setup_2\^26.key +COPY setup_2\^24.key /setup_2\^24.key COPY --from=builder /usr/src/zksync/prover/target/release/zksync_proof_fri_compressor /usr/bin/ diff --git a/docker/proof-gpu-fri-compressor/Dockerfile b/docker/proof-gpu-fri-compressor/Dockerfile index fa6e8da0b79e..f47e8d387d23 100644 --- a/docker/proof-gpu-fri-compressor/Dockerfile +++ b/docker/proof-gpu-fri-compressor/Dockerfile @@ -39,7 +39,7 @@ RUN apt-get update && apt-get install -y curl libpq5 ca-certificates && rm -rf / # copy VK required for proof wrapping COPY prover/vk_setup_data_generator_server_fri/data/ /prover/vk_setup_data_generator_server_fri/data/ -RUN mkdir keys && cd keys && mkdir setup && cd setup && curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^24.key +COPY setup_2\^24.key /setup_2\^24.key COPY --from=builder /usr/src/zksync/prover/target/release/zksync_proof_fri_compressor /usr/bin/ From 94ad708403a1520d8a0192a0602e6890b3010669 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Tue, 21 May 2024 13:47:05 +0300 Subject: [PATCH 28/32] update dockerignore --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 603386e55e3b..88f241c5275e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -24,6 +24,7 @@ keys/setup !Cargo.toml !contracts/ !setup_2\^26.key +!setup_2\^24.key # It's required to remove .git from contracts, # otherwise yarn tries to use .git parent directory that # doesn't exist. From 833bb265f64d6dc5875e3e0a05bf27d56820ef47 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Tue, 21 May 2024 14:05:00 +0300 Subject: [PATCH 29/32] return back 2^26 key in some places --- .github/workflows/build-contract-verifier-template.yml | 2 +- .github/workflows/build-core-template.yml | 2 +- .github/workflows/build-prover-template.yml | 9 +++++++-- docker/proof-fri-compressor/Dockerfile | 2 +- prover/setup.sh | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-contract-verifier-template.yml b/.github/workflows/build-contract-verifier-template.yml index adae235e7ddb..7042484160f3 100644 --- a/.github/workflows/build-contract-verifier-template.yml +++ b/.github/workflows/build-contract-verifier-template.yml @@ -114,7 +114,7 @@ jobs: ci_run git config --global --add safe.directory /usr/src/zksync/contracts ci_run zk || true ci_run yarn zk build - ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^24.key + ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key - name: build contracts if: env.BUILD_CONTRACTS == 'true' diff --git a/.github/workflows/build-core-template.yml b/.github/workflows/build-core-template.yml index f76dc3f71b8e..855d37665822 100644 --- a/.github/workflows/build-core-template.yml +++ b/.github/workflows/build-core-template.yml @@ -123,7 +123,7 @@ jobs: ci_run git config --global --add safe.directory /usr/src/zksync/contracts ci_run zk || true ci_run yarn zk build - ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^24.key + ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key - name: build contracts if: env.BUILD_CONTRACTS == 'true' diff --git a/.github/workflows/build-prover-template.yml b/.github/workflows/build-prover-template.yml index 6f0bcc59df66..7e26f13b3086 100644 --- a/.github/workflows/build-prover-template.yml +++ b/.github/workflows/build-prover-template.yml @@ -81,8 +81,13 @@ jobs: ci_run zk # We need the CRS only for the fri compressor. - - name: download CRS - if: matrix.component == 'proof-fri-compressor' || matrix.component == 'proof-gpu-fri-compressor' + - name: download CRS for CPU compressor + if: matrix.component == 'proof-fri-compressor' + run: | + ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key + + - name: download CRS for GPU compressor + if: matrix.component == 'proof-gpu-fri-compressor' run: | ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^24.key diff --git a/docker/proof-fri-compressor/Dockerfile b/docker/proof-fri-compressor/Dockerfile index 373f0e1036ef..afa8477dcf72 100644 --- a/docker/proof-fri-compressor/Dockerfile +++ b/docker/proof-fri-compressor/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get update && apt-get install -y curl libpq5 ca-certificates && rm -rf / COPY prover/vk_setup_data_generator_server_fri/data/ /prover/vk_setup_data_generator_server_fri/data/ # copy universal setup key required for proof compression -COPY setup_2\^24.key /setup_2\^24.key +COPY setup_2\^26.key /setup_2\^26.key COPY --from=builder /usr/src/zksync/prover/target/release/zksync_proof_fri_compressor /usr/bin/ diff --git a/prover/setup.sh b/prover/setup.sh index 57a5c34a677f..e755f5ae433a 100755 --- a/prover/setup.sh +++ b/prover/setup.sh @@ -18,7 +18,7 @@ sed -i.backup 's/^proof_loading_mode=.*$/proof_loading_mode="FriProofFromGcs"/' rm ../etc/env/base/eth_sender.toml.backup sed -i.backup 's/^setup_data_path=.*$/setup_data_path="vk_setup_data_generator_server_fri\/data\/"/' ../etc/env/base/fri_prover.toml rm ../etc/env/base/fri_prover.toml.backup -sed -i.backup 's/^universal_setup_path=.*$/universal_setup_path="..\/keys\/setup\/setup_2^24.key"/' ../etc/env/base/fri_proof_compressor.toml +sed -i.backup 's/^universal_setup_path=.*$/universal_setup_path="..\/keys\/setup\/setup_2^26.key"/' ../etc/env/base/fri_proof_compressor.toml rm ../etc/env/base/fri_proof_compressor.toml.backup zk config compile dev From 185b68b07b514497a185af361a878b97db032011 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Tue, 21 May 2024 14:06:54 +0300 Subject: [PATCH 30/32] update doc --- prover/prover_fri/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/prover/prover_fri/README.md b/prover/prover_fri/README.md index 3b76023416e6..5f0a26cfdd49 100644 --- a/prover/prover_fri/README.md +++ b/prover/prover_fri/README.md @@ -60,9 +60,10 @@ installation as a pre-requisite, alongside these machine specs: Note that it will produce a first l1 batch that can be proven (should be batch 0). -3. Generate the GPU setup data (no need to regenerate if it's already there). This will consume around 20GB of disk. You - need to be in the `prover/` directory (for all commands from here onwards, you need to be in the `prover/` directory) - and run: +3. Generate the GPU setup data (no need to regenerate if it's already there). If you want to use this with the GPU + compressors, you need to change the key in the file from `setup_2^26.key` to `setup_2^24.key`. This will consume + around 20GB of disk. You need to be in the `prover/` directory (for all commands from here onwards, you need to be in + the `prover/` directory) and run: ```console ./setup.sh gpu From 60e654da5dc9848a6b2971488bd144c3d069106a Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Tue, 21 May 2024 15:33:57 +0300 Subject: [PATCH 31/32] rename gpu compressor --- .github/workflows/build-prover-template.yml | 4 ++-- .../Dockerfile | 2 ++ infrastructure/zk/src/docker.ts | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) rename docker/{proof-gpu-fri-compressor => proof-fri-gpu-compressor}/Dockerfile (98%) diff --git a/.github/workflows/build-prover-template.yml b/.github/workflows/build-prover-template.yml index 7e26f13b3086..401c6dbc94fb 100644 --- a/.github/workflows/build-prover-template.yml +++ b/.github/workflows/build-prover-template.yml @@ -51,7 +51,7 @@ jobs: - witness-vector-generator - prover-fri-gateway - proof-fri-compressor - - proof-gpu-fri-compressor + - proof-fri-gpu-compressor steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 with: @@ -87,7 +87,7 @@ jobs: ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key - name: download CRS for GPU compressor - if: matrix.component == 'proof-gpu-fri-compressor' + if: matrix.component == 'proof-fri-gpu-compressor' run: | ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^24.key diff --git a/docker/proof-gpu-fri-compressor/Dockerfile b/docker/proof-fri-gpu-compressor/Dockerfile similarity index 98% rename from docker/proof-gpu-fri-compressor/Dockerfile rename to docker/proof-fri-gpu-compressor/Dockerfile index f47e8d387d23..ead48f6af6bb 100644 --- a/docker/proof-gpu-fri-compressor/Dockerfile +++ b/docker/proof-fri-gpu-compressor/Dockerfile @@ -41,6 +41,8 @@ COPY prover/vk_setup_data_generator_server_fri/data/ /prover/vk_setup_data_gener COPY setup_2\^24.key /setup_2\^24.key +ENV CRS_FILE=/setup_2\^24.key + COPY --from=builder /usr/src/zksync/prover/target/release/zksync_proof_fri_compressor /usr/bin/ ENTRYPOINT ["zksync_proof_fri_compressor"] diff --git a/infrastructure/zk/src/docker.ts b/infrastructure/zk/src/docker.ts index 1a8df3e9b278..33aa1e6ae527 100644 --- a/infrastructure/zk/src/docker.ts +++ b/infrastructure/zk/src/docker.ts @@ -1,4 +1,4 @@ -import { Command } from 'commander'; +import {Command} from 'commander'; import * as utils from './utils'; const IMAGES = [ @@ -15,7 +15,7 @@ const IMAGES = [ 'witness-vector-generator', 'prover-fri-gateway', 'proof-fri-compressor', - 'proof-gpu-fri-compressor', + 'proof-fri-gpu-compressor', 'snapshots-creator', 'verified-sources-fetcher' ]; @@ -33,7 +33,7 @@ async function dockerCommand( dockerOrg: string = 'matterlabs' ) { // Generating all tags for containers. We need 2 tags here: SHA and SHA+TS - const { stdout: COMMIT_SHORT_SHA }: { stdout: string } = await utils.exec('git rev-parse --short HEAD'); + const {stdout: COMMIT_SHORT_SHA}: { stdout: string } = await utils.exec('git rev-parse --short HEAD'); // COMMIT_SHORT_SHA returns with newline, so we need to trim it const imageTagShaTS: string = process.env.IMAGE_TAG_SUFFIX ? process.env.IMAGE_TAG_SUFFIX @@ -80,7 +80,7 @@ function defaultTagList(image: string, imageTagSha: string, imageTagShaTS: strin 'witness-vector-generator', 'prover-fri-gateway', 'proof-fri-compressor', - 'proof-gpu-fri-compressor', + 'proof-fri-gpu-compressor', 'snapshots-creator' ].includes(image) ? ['latest', 'latest2.0', `2.0-${imageTagSha}`, `${imageTagSha}`, `2.0-${imageTagShaTS}`, `${imageTagShaTS}`] From 3c8afb6d6ec3e66350d745eb58074386b796db4e Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Tue, 21 May 2024 15:34:34 +0300 Subject: [PATCH 32/32] fmt --- infrastructure/zk/src/docker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infrastructure/zk/src/docker.ts b/infrastructure/zk/src/docker.ts index 33aa1e6ae527..6d0edf1f4cdf 100644 --- a/infrastructure/zk/src/docker.ts +++ b/infrastructure/zk/src/docker.ts @@ -1,4 +1,4 @@ -import {Command} from 'commander'; +import { Command } from 'commander'; import * as utils from './utils'; const IMAGES = [ @@ -33,7 +33,7 @@ async function dockerCommand( dockerOrg: string = 'matterlabs' ) { // Generating all tags for containers. We need 2 tags here: SHA and SHA+TS - const {stdout: COMMIT_SHORT_SHA}: { stdout: string } = await utils.exec('git rev-parse --short HEAD'); + const { stdout: COMMIT_SHORT_SHA }: { stdout: string } = await utils.exec('git rev-parse --short HEAD'); // COMMIT_SHORT_SHA returns with newline, so we need to trim it const imageTagShaTS: string = process.env.IMAGE_TAG_SUFFIX ? process.env.IMAGE_TAG_SUFFIX