diff --git a/.github/workflows/ci-prover-e2e.yml b/.github/workflows/ci-prover-e2e.yml index a4a9b29e1d64..75d0617cb38d 100644 --- a/.github/workflows/ci-prover-e2e.yml +++ b/.github/workflows/ci-prover-e2e.yml @@ -5,6 +5,10 @@ on: jobs: e2e-test: runs-on: [ matterlabs-ci-gpu-l4-runner-prover-tests ] + strategy: + fail-fast: false + matrix: + compressor-mode: ["fflonk", "plonk"] env: RUNNER_COMPOSE_FILE: "docker-compose-gpu-runner-cuda-12-0.yml" @@ -24,17 +28,26 @@ jobs: echo "SCCACHE_GCS_RW_MODE=READ_WRITE" >> .env echo "RUSTC_WRAPPER=sccache" >> .env - mkdir -p prover_logs + mkdir -p prover_logs_${{matrix.compressor-mode}} - name: Start services run: | run_retried docker-compose -f ${RUNNER_COMPOSE_FILE} pull docker-compose -f ${RUNNER_COMPOSE_FILE} --profile runner up -d --wait ci_run sccache --start-server + ci_run git config --global --add safe.directory "*" + + - name: Checkout DualVerifier commit + working-directory: ./contracts + if: matrix.compressor-mode == 'fflonk' + run: | + git fetch + git checkout b4d5b984 + git submodule update --init --recursive + git rev-parse HEAD - name: Init run: | - ci_run git config --global --add safe.directory "*" ci_run chmod -R +x ./bin ci_run ./zkstack_cli/zkstackup/install -g --path ./zkstack_cli/zkstackup/zkstackup || true @@ -51,28 +64,37 @@ jobs: --base-token-price-denominator 1 \ --set-as-default true \ --ignore-prerequisites \ - --evm-emulator false + --evm-emulator false \ + --update-submodules=${{matrix.compressor-mode == 'plonk'}} + + ci_run zkstack ecosystem init --dev --update-submodules=${{matrix.compressor-mode == 'plonk'}} --verbose - ci_run zkstack ecosystem init --dev --verbose ci_run zkstack prover init --dev --verbose - echo "URL=$(grep "http_url" ./chains/proving_chain/configs/general.yaml | awk '{ print $2 }')" >> $GITHUB_ENV - - name: Build prover binaries + + - name: Switch verifier to FFLONK interface + working-directory: ./chains/proving_chain/configs + if: matrix.compressor-mode == 'fflonk' run: | - ci_run cargo build --release --workspace --manifest-path=prover/Cargo.toml + sudo sed -i 's/is_verifier_pre_fflonk: true/is_verifier_pre_fflonk: false/' general.yaml + grep "is_verifier_pre_fflonk" general.yaml | awk '{ print $2 }' + - name: Prepare prover subsystem run: | ci_run zkstack prover init-bellman-cuda --clone --verbose ci_run zkstack prover setup-keys --mode=download --region=us --verbose + - name: Run server run: | - ci_run zkstack server --uring --chain=proving_chain --components=api,tree,eth,state_keeper,commitment_generator,proof_data_handler,vm_runner_protective_reads,vm_runner_bwip &>prover_logs/server.log & + ci_run zkstack server --uring --chain=proving_chain --components=api,tree,eth,state_keeper,commitment_generator,proof_data_handler,vm_runner_protective_reads,vm_runner_bwip &>prover_logs_${{matrix.compressor-mode}}/server.log & - name: Run Gateway run: | - ci_run zkstack prover run --component=gateway --docker=false &>prover_logs/gateway.log & + ci_run zkstack prover run --component=gateway --docker=false &>prover_logs_${{matrix.compressor-mode}}/gateway.log & - name: Run Prover Job Monitor run: | - ci_run zkstack prover run --component=prover-job-monitor --docker=false &>prover_logs/prover-job-monitor.log & + ci_run zkstack prover run --component=prover-job-monitor --docker=false &>prover_logs_${{matrix.compressor-mode}}/prover-job-monitor.log & + # Sleeping until the server, gateway and prover job monitor are up + ci_run sleep 150 - name: Wait for batch to be passed through gateway env: DATABASE_URL: postgres://postgres:notsecurepassword@localhost:5432/zksync_prover_localhost_proving_chain @@ -84,16 +106,16 @@ jobs: ci_run ./bin/prover_checkers/batch_availability_checker - name: Run Witness Generator run: | - ci_run zkstack prover run --component=witness-generator --round=all-rounds --docker=false &>prover_logs/witness-generator.log & + ci_run zkstack prover run --component=witness-generator --round=all-rounds --docker=false &>prover_logs_${{matrix.compressor-mode}}/witness-generator.log & - name: Run Circuit Prover run: | - ci_run zkstack prover run --component=circuit-prover -l=23 -h=3 --docker=false &>prover_logs/circuit_prover.log & + ci_run zkstack prover run --component=circuit-prover -l=23 -h=3 --docker=false &>prover_logs_${{matrix.compressor-mode}}/circuit_prover.log & - name: Wait for prover jobs to finish env: DATABASE_URL: postgres://postgres:notsecurepassword@localhost:5432/zksync_prover_localhost_proving_chain BATCH_NUMBER: 1 INTERVAL: 30 - TIMEOUT: 1200 + TIMEOUT: 1800 run: | PASSED_ENV_VARS="DATABASE_URL,BATCH_NUMBER,INTERVAL,TIMEOUT" \ ci_run ./bin/prover_checkers/prover_jobs_status_checker @@ -101,14 +123,14 @@ jobs: - name: Kill prover & start compressor run: | sudo ./bin/prover_checkers/kill_prover + ci_run zkstack prover run --component=compressor --docker=false --mode=${{matrix.compressor-mode}} &>prover_logs_${{matrix.compressor-mode}}/compressor.log & - ci_run zkstack prover run --component=compressor --docker=false &>prover_logs/compressor.log & - name: Wait for batch to be executed on L1 env: DATABASE_URL: postgres://postgres:notsecurepassword@localhost:5432/zksync_prover_localhost_proving_chain BATCH_NUMBER: 1 INTERVAL: 30 - TIMEOUT: 600 + TIMEOUT: 1200 run: | PASSED_ENV_VARS="BATCH_NUMBER,DATABASE_URL,URL,INTERVAL,TIMEOUT" \ ci_run ./bin/prover_checkers/batch_l1_status_checker @@ -117,8 +139,8 @@ jobs: uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 if: always() with: - name: prover_logs - path: prover_logs + name: prover_logs_${{matrix.compressor-mode}} + path: prover_logs_${{matrix.compressor-mode}} - name: Show sccache logs if: always() diff --git a/Cargo.lock b/Cargo.lock index 0a98fb5ccd23..965bee5a4e7f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1289,9 +1289,9 @@ dependencies = [ [[package]] name = "boojum" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4337dc7b196fc3e5e55e2857bc21638b7441429ee1a953201a9cd2be187b764e" +checksum = "14bd053feb7173130679a2119e105b5e78af7eb6b0e752de6793e4ee63d8e899" dependencies = [ "arrayvec 0.7.6", "bincode", @@ -1688,28 +1688,42 @@ dependencies = [ "zeroize", ] +[[package]] +name = "circuit_definitions" +version = "0.150.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ebc81d5c2f6ee8de436c242f6466fb315fe25afcbc81aa1c47dfca39a55403" +dependencies = [ + "circuit_encodings", + "crossbeam", + "derivative", + "seq-macro", + "serde", + "snark_wrapper", +] + [[package]] name = "circuit_encodings" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3dcfcb4aaa17e6a81ebd2db688d980aff50aa643d9b506d4d11c84976dbc03f" +checksum = "33375d2448a78c1aed9b8755f7939a6b6f19e2fa80f44f4930a5b4c2bb7cbb44" dependencies = [ "derivative", "serde", - "zk_evm 0.150.18", + "zk_evm 0.150.19", "zkevm_circuits", ] [[package]] name = "circuit_sequencer_api" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d13ed70909e8390a4f2599d5a76d9ac4189e5bbbf16146d11b7999788740f291" +checksum = "ca2fec5c28e5a9f085279e70e13b2eebb63a95ee0bfb99d58095ac01c1c7b256" dependencies = [ "derivative", "rayon", "serde", - "zk_evm 0.150.18", + "zk_evm 0.150.19", "zksync_bellman", ] @@ -2967,6 +2981,23 @@ dependencies = [ "subtle", ] +[[package]] +name = "fflonk" +version = "0.30.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e63d70f1cbf9e572ccaf22ca1dfce4b93ff48b9a5e8dd70de50d87edb960d173" +dependencies = [ + "bincode", + "byteorder", + "franklin-crypto", + "num-bigint 0.4.6", + "num-traits", + "rand 0.4.6", + "serde", + "serde_derive", + "serde_json", +] + [[package]] name = "fiat-crypto" version = "0.2.9" @@ -3241,9 +3272,9 @@ dependencies = [ [[package]] name = "franklin-crypto" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c128e2cf791053b3aefdd7b07d6e5ffdc7cf5dd779ca270d727a403057dfb68" +checksum = "82d7b8e5864df7f3747e5e64a5b87b4a57aa2a4a20c55c9e96a3a305a8143c45" dependencies = [ "arr_macro", "bit-vec", @@ -7227,9 +7258,9 @@ dependencies = [ [[package]] name = "rescue_poseidon" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62e4ce7543582ab2df1d9544674a55897e168a23afe938a57e1547d2981a7f4" +checksum = "c250446885c257bee70bc0f2600229ce72f03073b87fb8f5dd278dba16b11f30" dependencies = [ "addchain", "arrayvec 0.7.6", @@ -8632,6 +8663,18 @@ dependencies = [ "zksync_vlog", ] +[[package]] +name = "snark_wrapper" +version = "0.30.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f361c2c47b71ee43f62954ce69f7730e14acb7fb3b0f2c697da02f97327c569" +dependencies = [ + "derivative", + "rand 0.4.6", + "rescue_poseidon", + "serde", +] + [[package]] name = "snow" version = "0.9.6" @@ -11117,9 +11160,9 @@ dependencies = [ [[package]] name = "zk_evm" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3278d0f75408ab35d25998e1124124cd108b48b2a81ed8e71e892ddc5a6be0aa" +checksum = "84ee848aa90ae045457795b1c0afeb388fbd9fa1e57aa0e8791b28f405e7cc2c" dependencies = [ "anyhow", "lazy_static", @@ -11127,7 +11170,7 @@ dependencies = [ "serde", "serde_json", "static_assertions", - "zk_evm_abstractions 0.150.18", + "zk_evm_abstractions 0.150.19", ] [[package]] @@ -11158,22 +11201,22 @@ dependencies = [ [[package]] name = "zk_evm_abstractions" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b4e5a89cfe1594b6476be16c8c1d45f22ce12bff31c49e077b381a398edd8a" +checksum = "8f08feaa3e3d99e1e57234fe6ba2aa062609492c6499b2344121c4a699292ab7" dependencies = [ "anyhow", "num_enum 0.6.1", "serde", "static_assertions", - "zkevm_opcode_defs 0.150.18", + "zkevm_opcode_defs 0.150.19", ] [[package]] name = "zkevm_circuits" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b94288d2e246aecd6eecd22ef27db0d1f29a91cb4f59b9e339a45237131a9ff" +checksum = "760cfbbce18f42bbecd2565de9bf658234cac2431cce9b0c1df08e9df645d467" dependencies = [ "arrayvec 0.7.6", "boojum", @@ -11185,7 +11228,7 @@ dependencies = [ "seq-macro", "serde", "smallvec", - "zkevm_opcode_defs 0.150.18", + "zkevm_opcode_defs 0.150.19", "zksync_cs_derive", ] @@ -11233,9 +11276,9 @@ dependencies = [ [[package]] name = "zkevm_opcode_defs" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bad437d4891536fdcc0054a3f04562c408817ff19d83b6c27569217692e6e74" +checksum = "4f2bd8ef52c8f9911dd034b91d29f087ab52f80a80f9d996deb881abbb953793" dependencies = [ "bitflags 2.6.0", "blake2 0.10.6", @@ -11294,9 +11337,9 @@ dependencies = [ [[package]] name = "zksync_bellman" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b7c0061db44757522f2d82cad02f45dc98267210ac362071234ed08e30fd4d6" +checksum = "d06d424f7e3862d7a6715179bafffbe7a5dce17129f95ac4124502ab9f1edfb8" dependencies = [ "arrayvec 0.7.6", "bit-vec", @@ -11368,7 +11411,7 @@ dependencies = [ "tokio", "tracing", "vise", - "zk_evm 0.150.18", + "zk_evm 0.150.19", "zksync_contracts", "zksync_dal", "zksync_eth_client", @@ -11713,9 +11756,9 @@ dependencies = [ [[package]] name = "zksync_cs_derive" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63296ce43c432d5d0111604173e874b2f2a856e1cb1c76378fa0bb5ac6018c27" +checksum = "23237b019a469bfa59c11108beff84a63a43f52fa3afbf1b461527031fc47644" dependencies = [ "proc-macro-error", "proc-macro2 1.0.92", @@ -12043,9 +12086,9 @@ dependencies = [ [[package]] name = "zksync_ff" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6a500c97d9286f73540c26b63ae33b159bd48fec0c8bd206b4a9b4fe1217b8a" +checksum = "4d5aa518ed0ea7ef737d50de02025f5a593dbb11104b3c1bf5a00f39581b47dc" dependencies = [ "byteorder", "hex", @@ -12056,9 +12099,9 @@ dependencies = [ [[package]] name = "zksync_ff_derive" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97bd48f18ebf350623093022d86be2f1ce23af332efa91890b751209aec8617a" +checksum = "e33b43100a1278e2f64820368db8751c2441860ea74ab5749074cf8f864647af" dependencies = [ "num-bigint 0.4.6", "num-integer", @@ -12101,9 +12144,9 @@ dependencies = [ [[package]] name = "zksync_kzg" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6384d2475e4a7e6ed4e2a703724cac1d8972d9ec40c49fdd17bf37942a81a635" +checksum = "c9da880b8282a97d9dfd6ac9f0189d310c0602059a8de20aa66a883979d6adba" dependencies = [ "boojum", "derivative", @@ -12121,6 +12164,8 @@ name = "zksync_l1_contract_interface" version = "0.1.0" dependencies = [ "anyhow", + "circuit_definitions", + "fflonk", "hex", "once_cell", "rand 0.8.5", @@ -12249,7 +12294,7 @@ dependencies = [ "zk_evm 0.133.0", "zk_evm 0.140.0", "zk_evm 0.141.0", - "zk_evm 0.150.18", + "zk_evm 0.150.19", "zksync_contracts", "zksync_eth_signer", "zksync_mini_merkle_tree", @@ -12289,7 +12334,7 @@ dependencies = [ "tower-http 0.5.2", "tracing", "vise", - "zk_evm 0.150.18", + "zk_evm 0.150.19", "zksync_config", "zksync_consensus_roles", "zksync_contracts", @@ -12586,9 +12631,9 @@ dependencies = [ [[package]] name = "zksync_pairing" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b91b38db3a3f0f80d8b1f2342c77751ee8d63b746268e5719abbb5dfb150a8c" +checksum = "43f0d96f3e386f3b4c76a614d73b71714d6712e917d462bf8053b8af352da0b3" dependencies = [ "byteorder", "cfg-if", @@ -12685,7 +12730,9 @@ version = "0.1.0" dependencies = [ "bincode", "chrono", + "circuit_definitions", "circuit_sequencer_api", + "fflonk", "serde", "serde_json", "serde_with", @@ -12795,9 +12842,9 @@ dependencies = [ [[package]] name = "zksync_solidity_vk_codegen" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f03e137db1b29be36abfa1e1e682dd3864b0335c68282c8dab68c2d397b8cbd" +checksum = "eb10f377dcc24fe2268cc5f530c16af1c879a791570d8fe64064b58ba143c7cc" dependencies = [ "ethereum-types", "franklin-crypto", @@ -13037,8 +13084,8 @@ source = "git+https://github.com/matter-labs/vm2.git?rev=457d8a7eea9093af9440662 dependencies = [ "enum_dispatch", "primitive-types", - "zk_evm_abstractions 0.150.18", - "zkevm_opcode_defs 0.150.18", + "zk_evm_abstractions 0.150.19", + "zkevm_opcode_defs 0.150.19", "zksync_vm2_interface", ] diff --git a/Cargo.toml b/Cargo.toml index 80e74f05c087..bbbfc6d5ad07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -228,16 +228,18 @@ tokio-stream = "0.1.16" # We *always* pin the latest version of protocol to disallow accidental changes in the execution logic. # However, for the historical version of protocol crates, we have lax requirements. Otherwise, # Bumping a crypto dependency like `boojum` would require us to republish all the historical packages. -circuit_encodings = { package = "circuit_encodings", version = "=0.150.18" } -circuit_sequencer_api = { package = "circuit_sequencer_api", version = "=0.150.18" } -crypto_codegen = { package = "zksync_solidity_vk_codegen", version = "=0.30.11" } -kzg = { package = "zksync_kzg", version = "=0.150.18" } +circuit_encodings = { package = "circuit_encodings", version = "0.150.19" } +circuit_sequencer_api = { package = "circuit_sequencer_api", version = "0.150.19" } +circuit_definitions = { package = "circuit_definitions", version = "0.150.19" } +crypto_codegen = { package = "zksync_solidity_vk_codegen",version = "0.30.12" } +kzg = { package = "zksync_kzg", version = "0.150.19" } zk_evm = { version = "=0.133.0" } zk_evm_1_3_1 = { package = "zk_evm", version = "0.131.0-rc.2" } zk_evm_1_3_3 = { package = "zk_evm", version = "0.133" } zk_evm_1_4_0 = { package = "zk_evm", version = "0.140" } zk_evm_1_4_1 = { package = "zk_evm", version = "0.141" } -zk_evm_1_5_0 = { package = "zk_evm", version = "=0.150.18" } +zk_evm_1_5_0 = { package = "zk_evm", version = "0.150.19" } +fflonk = { package = "fflonk", version = "0.30.12" } # New VM; pinned to a specific commit because of instability zksync_vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "457d8a7eea9093af9440662e33e598c13ba41633" } diff --git a/core/lib/basic_types/src/protocol_version.rs b/core/lib/basic_types/src/protocol_version.rs index 39b99f2d04a2..89251b3a2a40 100644 --- a/core/lib/basic_types/src/protocol_version.rs +++ b/core/lib/basic_types/src/protocol_version.rs @@ -70,6 +70,7 @@ pub enum ProtocolVersionId { Version25, Version26, Version27, + Version28, } impl ProtocolVersionId { @@ -124,6 +125,7 @@ impl ProtocolVersionId { ProtocolVersionId::Version25 => VmVersion::Vm1_5_0IncreasedBootloaderMemory, ProtocolVersionId::Version26 => VmVersion::Vm1_5_0IncreasedBootloaderMemory, ProtocolVersionId::Version27 => VmVersion::VmGateway, + ProtocolVersionId::Version28 => unreachable!("Version 28 is not yet supported"), } } @@ -149,6 +151,10 @@ impl ProtocolVersionId { self >= &Self::gateway_upgrade() } + pub fn is_pre_fflonk(&self) -> bool { + self < &Self::Version28 + } + pub fn is_1_4_0(&self) -> bool { self >= &ProtocolVersionId::Version18 && self < &ProtocolVersionId::Version20 } @@ -236,7 +242,7 @@ impl Detokenize for VerifierParams { other => { return Err(Error::InvalidOutputType(format!( "expected a tuple, got {other:?}" - ))) + ))); } }; @@ -260,6 +266,7 @@ pub struct L1VerifierConfig { rename(serialize = "recursion_scheduler_level_vk_hash") )] pub snark_wrapper_vk_hash: H256, + pub fflonk_snark_wrapper_vk_hash: Option, } impl From for VmVersion { @@ -293,6 +300,7 @@ impl From for VmVersion { ProtocolVersionId::Version25 => VmVersion::Vm1_5_0IncreasedBootloaderMemory, ProtocolVersionId::Version26 => VmVersion::Vm1_5_0IncreasedBootloaderMemory, ProtocolVersionId::Version27 => VmVersion::VmGateway, + ProtocolVersionId::Version28 => unreachable!("Version 28 is not yet supported"), } } } @@ -430,9 +438,10 @@ mod tests { } let ser = L1VerifierConfig { snark_wrapper_vk_hash: H256::repeat_byte(0x11), + fflonk_snark_wrapper_vk_hash: Some(H256::repeat_byte(0x11)), }; let ser_str = serde_json::to_string(&ser).unwrap(); - let expected_str = r#"{"recursion_scheduler_level_vk_hash":"0x1111111111111111111111111111111111111111111111111111111111111111"}"#; + let expected_str = r#"{"recursion_scheduler_level_vk_hash":"0x1111111111111111111111111111111111111111111111111111111111111111","fflonk_snark_wrapper_vk_hash":"0x1111111111111111111111111111111111111111111111111111111111111111"}"#; assert_eq!(ser_str, expected_str); } } diff --git a/core/lib/config/src/configs/eth_sender.rs b/core/lib/config/src/configs/eth_sender.rs index fb3dee3c3dd2..258aa26ec191 100644 --- a/core/lib/config/src/configs/eth_sender.rs +++ b/core/lib/config/src/configs/eth_sender.rs @@ -43,6 +43,7 @@ impl EthConfig { tx_aggregation_only_prove_and_execute: false, priority_tree_start_index: Some(0), time_in_mempool_in_l1_blocks_cap: 1800, + is_verifier_pre_fflonk: true, }), gas_adjuster: Some(GasAdjusterConfig { default_priority_fee_per_gas: 1000000000, @@ -123,6 +124,7 @@ pub struct SenderConfig { /// Cap of time in mempool for price calculations #[serde(default = "SenderConfig::default_time_in_mempool_in_l1_blocks_cap")] pub time_in_mempool_in_l1_blocks_cap: u32, + pub is_verifier_pre_fflonk: bool, } impl SenderConfig { diff --git a/core/lib/config/src/configs/genesis.rs b/core/lib/config/src/configs/genesis.rs index 6fc117f8b679..01f39fe8668b 100644 --- a/core/lib/config/src/configs/genesis.rs +++ b/core/lib/config/src/configs/genesis.rs @@ -28,6 +28,7 @@ pub struct GenesisConfig { rename(serialize = "recursion_scheduler_level_vk_hash") )] pub snark_wrapper_vk_hash: H256, + pub fflonk_snark_wrapper_vk_hash: Option, pub fee_account: Address, pub dummy_verifier: bool, pub l1_batch_commit_data_generator_mode: L1BatchCommitmentMode, @@ -40,6 +41,7 @@ impl GenesisConfig { genesis_root_hash: Some(H256::repeat_byte(0x01)), rollup_last_leaf_index: Some(26), snark_wrapper_vk_hash: H256::repeat_byte(0x02), + fflonk_snark_wrapper_vk_hash: Default::default(), fee_account: Default::default(), genesis_commitment: Some(H256::repeat_byte(0x17)), bootloader_hash: Default::default(), diff --git a/core/lib/config/src/testonly.rs b/core/lib/config/src/testonly.rs index 273015b760db..fe140544d803 100644 --- a/core/lib/config/src/testonly.rs +++ b/core/lib/config/src/testonly.rs @@ -421,6 +421,7 @@ impl Distribution for EncodeDist { tx_aggregation_only_prove_and_execute: false, priority_tree_start_index: self.sample(rng), time_in_mempool_in_l1_blocks_cap: self.sample(rng), + is_verifier_pre_fflonk: self.sample(rng), } } } @@ -743,6 +744,7 @@ impl Distribution for EncodeDist { l1_chain_id: L1ChainId(self.sample(rng)), l2_chain_id: L2ChainId::default(), snark_wrapper_vk_hash: rng.gen(), + fflonk_snark_wrapper_vk_hash: Some(rng.gen()), dummy_verifier: rng.gen(), l1_batch_commit_data_generator_mode: match rng.gen_range(0..2) { 0 => L1BatchCommitmentMode::Rollup, diff --git a/core/lib/contracts/src/lib.rs b/core/lib/contracts/src/lib.rs index 4669fc2b86b8..ba22ba8d1b95 100644 --- a/core/lib/contracts/src/lib.rs +++ b/core/lib/contracts/src/lib.rs @@ -56,10 +56,14 @@ const GETTERS_FACET_CONTRACT_FILE: (&str, &str) = ( const MULTICALL3_CONTRACT_FILE: (&str, &str) = ("dev-contracts", "Multicall3.sol/Multicall3.json"); const VERIFIER_CONTRACT_FILE: (&str, &str) = ("state-transition", "Verifier.sol/Verifier.json"); +const DUAL_VERIFIER_CONTRACT_FILE: (&str, &str) = ( + "state-transition/verifiers", + "DualVerifier.sol/DualVerifier.json", +); const _IERC20_CONTRACT_FILE: &str = "contracts/l1-contracts/artifacts/contracts/common/interfaces/IERC20.sol/IERC20.json"; -const _FAIL_ON_RECEIVE_CONTRACT_FILE: &str = +const _FAIL_ON_RECEIVE_CONTRACT_FILE: &str = "contracts/l1-contracts/artifacts/contracts/zksync/dev-contracts/FailOnReceive.sol/FailOnReceive.json"; fn home_path() -> PathBuf { @@ -167,7 +171,15 @@ pub fn multicall_contract() -> Contract { } pub fn verifier_contract() -> Contract { - load_contract_for_both_compilers(VERIFIER_CONTRACT_FILE) + let path = format!("{}/{}", FORGE_PATH_PREFIX, DUAL_VERIFIER_CONTRACT_FILE.1); + let zksync_home = home_path(); + let path = Path::new(&zksync_home).join(path); + + if path.exists() { + load_contract_for_both_compilers(DUAL_VERIFIER_CONTRACT_FILE) + } else { + load_contract_for_both_compilers(VERIFIER_CONTRACT_FILE) + } } pub fn deployer_contract() -> Contract { diff --git a/core/lib/dal/.sqlx/query-89e53b297b2b1c0dfb263f9175cb70e7a5fe02b60d5d23e4d153190138112c5b.json b/core/lib/dal/.sqlx/query-128c1139fd6f9a869013426e2c17c2b998152ed2afee44ec904499f97e4756b0.json similarity index 82% rename from core/lib/dal/.sqlx/query-89e53b297b2b1c0dfb263f9175cb70e7a5fe02b60d5d23e4d153190138112c5b.json rename to core/lib/dal/.sqlx/query-128c1139fd6f9a869013426e2c17c2b998152ed2afee44ec904499f97e4756b0.json index d944b6abf9e1..49c856e42914 100644 --- a/core/lib/dal/.sqlx/query-89e53b297b2b1c0dfb263f9175cb70e7a5fe02b60d5d23e4d153190138112c5b.json +++ b/core/lib/dal/.sqlx/query-128c1139fd6f9a869013426e2c17c2b998152ed2afee44ec904499f97e4756b0.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n protocol_versions.id AS \"minor!\",\n protocol_versions.timestamp,\n protocol_versions.bootloader_code_hash,\n protocol_versions.default_account_code_hash,\n protocol_versions.evm_emulator_code_hash,\n protocol_patches.patch,\n protocol_patches.snark_wrapper_vk_hash\n FROM\n protocol_versions\n JOIN protocol_patches ON protocol_patches.minor = protocol_versions.id\n WHERE\n id = $1\n ORDER BY\n protocol_patches.patch DESC\n LIMIT\n 1\n ", + "query": "\n SELECT\n protocol_versions.id AS \"minor!\",\n protocol_versions.timestamp,\n protocol_versions.bootloader_code_hash,\n protocol_versions.default_account_code_hash,\n protocol_versions.evm_emulator_code_hash,\n protocol_patches.patch,\n protocol_patches.snark_wrapper_vk_hash,\n protocol_patches.fflonk_snark_wrapper_vk_hash\n FROM\n protocol_versions\n JOIN protocol_patches ON protocol_patches.minor = protocol_versions.id\n WHERE\n id = $1\n ORDER BY\n protocol_patches.patch DESC\n LIMIT\n 1\n ", "describe": { "columns": [ { @@ -37,6 +37,11 @@ "ordinal": 6, "name": "snark_wrapper_vk_hash", "type_info": "Bytea" + }, + { + "ordinal": 7, + "name": "fflonk_snark_wrapper_vk_hash", + "type_info": "Bytea" } ], "parameters": { @@ -51,8 +56,9 @@ false, true, false, - false + false, + true ] }, - "hash": "89e53b297b2b1c0dfb263f9175cb70e7a5fe02b60d5d23e4d153190138112c5b" + "hash": "128c1139fd6f9a869013426e2c17c2b998152ed2afee44ec904499f97e4756b0" } diff --git a/core/lib/dal/.sqlx/query-7204d08f6fb83c83c09eb2942ecb671fa559dfdb29b315b17ae2f86533d247e9.json b/core/lib/dal/.sqlx/query-7204d08f6fb83c83c09eb2942ecb671fa559dfdb29b315b17ae2f86533d247e9.json deleted file mode 100644 index 01adb17775c3..000000000000 --- a/core/lib/dal/.sqlx/query-7204d08f6fb83c83c09eb2942ecb671fa559dfdb29b315b17ae2f86533d247e9.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n protocol_patches (minor, patch, snark_wrapper_vk_hash, created_at)\n VALUES\n ($1, $2, $3, NOW())\n ON CONFLICT DO NOTHING\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int4", - "Int4", - "Bytea" - ] - }, - "nullable": [] - }, - "hash": "7204d08f6fb83c83c09eb2942ecb671fa559dfdb29b315b17ae2f86533d247e9" -} diff --git a/core/lib/dal/.sqlx/query-740dcefc021aa2308f0402313938534f3da59803f417721eca2d96f9fa8813a2.json b/core/lib/dal/.sqlx/query-740dcefc021aa2308f0402313938534f3da59803f417721eca2d96f9fa8813a2.json new file mode 100644 index 000000000000..0823a178f54a --- /dev/null +++ b/core/lib/dal/.sqlx/query-740dcefc021aa2308f0402313938534f3da59803f417721eca2d96f9fa8813a2.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n snark_wrapper_vk_hash,\n fflonk_snark_wrapper_vk_hash\n FROM\n protocol_patches\n WHERE\n minor = $1\n AND patch = $2\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "snark_wrapper_vk_hash", + "type_info": "Bytea" + }, + { + "ordinal": 1, + "name": "fflonk_snark_wrapper_vk_hash", + "type_info": "Bytea" + } + ], + "parameters": { + "Left": [ + "Int4", + "Int4" + ] + }, + "nullable": [ + false, + true + ] + }, + "hash": "740dcefc021aa2308f0402313938534f3da59803f417721eca2d96f9fa8813a2" +} diff --git a/core/lib/dal/.sqlx/query-e0be465bbfbf677a8eafb722fc302bf37011d37c9e3ad1cbc7c33a91db443a0f.json b/core/lib/dal/.sqlx/query-e0be465bbfbf677a8eafb722fc302bf37011d37c9e3ad1cbc7c33a91db443a0f.json new file mode 100644 index 000000000000..bae85969adc1 --- /dev/null +++ b/core/lib/dal/.sqlx/query-e0be465bbfbf677a8eafb722fc302bf37011d37c9e3ad1cbc7c33a91db443a0f.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO\n protocol_patches (\n minor,\n patch,\n snark_wrapper_vk_hash,\n fflonk_snark_wrapper_vk_hash,\n created_at\n )\n VALUES\n ($1, $2, $3, $4, NOW())\n ON CONFLICT DO NOTHING\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int4", + "Int4", + "Bytea", + "Bytea" + ] + }, + "nullable": [] + }, + "hash": "e0be465bbfbf677a8eafb722fc302bf37011d37c9e3ad1cbc7c33a91db443a0f" +} diff --git a/core/lib/dal/.sqlx/query-e9d91aa8e30152a5b6a321cb94a298ed3fc5e6eb1c78c285bd20f6401771df25.json b/core/lib/dal/.sqlx/query-e9d91aa8e30152a5b6a321cb94a298ed3fc5e6eb1c78c285bd20f6401771df25.json deleted file mode 100644 index fa47ccab50ab..000000000000 --- a/core/lib/dal/.sqlx/query-e9d91aa8e30152a5b6a321cb94a298ed3fc5e6eb1c78c285bd20f6401771df25.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT\n snark_wrapper_vk_hash\n FROM\n protocol_patches\n WHERE\n minor = $1\n AND patch = $2\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "snark_wrapper_vk_hash", - "type_info": "Bytea" - } - ], - "parameters": { - "Left": [ - "Int4", - "Int4" - ] - }, - "nullable": [ - false - ] - }, - "hash": "e9d91aa8e30152a5b6a321cb94a298ed3fc5e6eb1c78c285bd20f6401771df25" -} diff --git a/core/lib/dal/migrations/20241118113804_add_flonk_verifier_vk_hash.down.sql b/core/lib/dal/migrations/20241118113804_add_flonk_verifier_vk_hash.down.sql new file mode 100644 index 000000000000..a48a80a68ed8 --- /dev/null +++ b/core/lib/dal/migrations/20241118113804_add_flonk_verifier_vk_hash.down.sql @@ -0,0 +1,2 @@ +ALTER TABLE protocol_patches +DROP COLUMN fflonk_snark_wrapper_vk_hash; diff --git a/core/lib/dal/migrations/20241118113804_add_flonk_verifier_vk_hash.up.sql b/core/lib/dal/migrations/20241118113804_add_flonk_verifier_vk_hash.up.sql new file mode 100644 index 000000000000..c57d059e41a0 --- /dev/null +++ b/core/lib/dal/migrations/20241118113804_add_flonk_verifier_vk_hash.up.sql @@ -0,0 +1,2 @@ +ALTER TABLE protocol_patches +ADD COLUMN fflonk_snark_wrapper_vk_hash BYTEA DEFAULT NULL; diff --git a/core/lib/dal/src/models/storage_protocol_version.rs b/core/lib/dal/src/models/storage_protocol_version.rs index a833236a7b62..910af63dc1ff 100644 --- a/core/lib/dal/src/models/storage_protocol_version.rs +++ b/core/lib/dal/src/models/storage_protocol_version.rs @@ -14,6 +14,7 @@ pub struct StorageProtocolVersion { pub patch: i32, pub timestamp: i64, pub snark_wrapper_vk_hash: Vec, + pub fflonk_snark_wrapper_vk_hash: Option>, pub bootloader_code_hash: Vec, pub default_account_code_hash: Vec, pub evm_emulator_code_hash: Option>, @@ -31,6 +32,10 @@ pub(crate) fn protocol_version_from_storage( timestamp: storage_version.timestamp as u64, l1_verifier_config: L1VerifierConfig { snark_wrapper_vk_hash: H256::from_slice(&storage_version.snark_wrapper_vk_hash), + fflonk_snark_wrapper_vk_hash: storage_version + .fflonk_snark_wrapper_vk_hash + .as_ref() + .map(|x| H256::from_slice(x)), }, base_system_contracts_hashes: BaseSystemContractsHashes { bootloader: H256::from_slice(&storage_version.bootloader_code_hash), diff --git a/core/lib/dal/src/protocol_versions_dal.rs b/core/lib/dal/src/protocol_versions_dal.rs index fcc756e30069..11f6a93efdc4 100644 --- a/core/lib/dal/src/protocol_versions_dal.rs +++ b/core/lib/dal/src/protocol_versions_dal.rs @@ -76,14 +76,24 @@ impl ProtocolVersionsDal<'_, '_> { sqlx::query!( r#" INSERT INTO - protocol_patches (minor, patch, snark_wrapper_vk_hash, created_at) + protocol_patches ( + minor, + patch, + snark_wrapper_vk_hash, + fflonk_snark_wrapper_vk_hash, + created_at + ) VALUES - ($1, $2, $3, NOW()) + ($1, $2, $3, $4, NOW()) ON CONFLICT DO NOTHING "#, version.minor as i32, version.patch.0 as i32, l1_verifier_config.snark_wrapper_vk_hash.as_bytes(), + l1_verifier_config + .fflonk_snark_wrapper_vk_hash + .as_ref() + .map(|x| x.as_bytes()), ) .instrument("save_protocol_version#patch") .with_arg("version", &version) @@ -280,7 +290,8 @@ impl ProtocolVersionsDal<'_, '_> { protocol_versions.default_account_code_hash, protocol_versions.evm_emulator_code_hash, protocol_patches.patch, - protocol_patches.snark_wrapper_vk_hash + protocol_patches.snark_wrapper_vk_hash, + protocol_patches.fflonk_snark_wrapper_vk_hash FROM protocol_versions JOIN protocol_patches ON protocol_patches.minor = protocol_versions.id @@ -313,7 +324,8 @@ impl ProtocolVersionsDal<'_, '_> { let row = sqlx::query!( r#" SELECT - snark_wrapper_vk_hash + snark_wrapper_vk_hash, + fflonk_snark_wrapper_vk_hash FROM protocol_patches WHERE @@ -328,6 +340,10 @@ impl ProtocolVersionsDal<'_, '_> { .unwrap()?; Some(L1VerifierConfig { snark_wrapper_vk_hash: H256::from_slice(&row.snark_wrapper_vk_hash), + fflonk_snark_wrapper_vk_hash: row + .fflonk_snark_wrapper_vk_hash + .as_ref() + .map(|x| H256::from_slice(x)), }) } diff --git a/core/lib/env_config/src/eth_sender.rs b/core/lib/env_config/src/eth_sender.rs index 5c0f042984e7..8801693b7a75 100644 --- a/core/lib/env_config/src/eth_sender.rs +++ b/core/lib/env_config/src/eth_sender.rs @@ -77,6 +77,7 @@ mod tests { tx_aggregation_paused: false, time_in_mempool_in_l1_blocks_cap: 2000, priority_tree_start_index: None, + is_verifier_pre_fflonk: true, }), gas_adjuster: Some(GasAdjusterConfig { default_priority_fee_per_gas: 20000000000, @@ -140,6 +141,7 @@ mod tests { ETH_SENDER_SENDER_L1_BATCH_MIN_AGE_BEFORE_EXECUTE_SECONDS="1000" ETH_SENDER_SENDER_MAX_ACCEPTABLE_PRIORITY_FEE_IN_GWEI="100000000000" ETH_SENDER_SENDER_PUBDATA_SENDING_MODE="Calldata" + ETH_SENDER_SENDER_is_verifier_pre_fflonk="true" ETH_WATCH_CONFIRMATIONS_FOR_ETH_EVENT="0" ETH_WATCH_ETH_NODE_POLL_INTERVAL="300" ETH_CLIENT_WEB3_URL="http://127.0.0.1:8545" diff --git a/core/lib/env_config/src/genesis.rs b/core/lib/env_config/src/genesis.rs index 234fbc85f6b9..486d354e6cb5 100644 --- a/core/lib/env_config/src/genesis.rs +++ b/core/lib/env_config/src/genesis.rs @@ -21,6 +21,7 @@ struct ContractsForGenesis { pub fri_recursion_node_level_vk_hash: H256, pub fri_recursion_leaf_level_vk_hash: H256, pub snark_wrapper_vk_hash: H256, + pub fflonk_snark_wrapper_vk_hash: Option, // These contracts will be used after shared bridge integration. pub bridgehub_proxy_addr: Option
, pub bridgehub_impl_addr: Option
, @@ -87,6 +88,7 @@ impl FromEnv for GenesisConfig { l1_chain_id: L1ChainId(network_config.network.chain_id().0), l2_chain_id: network_config.zksync_network_id, snark_wrapper_vk_hash: contracts_config.snark_wrapper_vk_hash, + fflonk_snark_wrapper_vk_hash: contracts_config.fflonk_snark_wrapper_vk_hash, fee_account: state_keeper .fee_account_addr .context("Fee account required for genesis")?, diff --git a/core/lib/eth_client/src/types.rs b/core/lib/eth_client/src/types.rs index dd332351afb0..3b6daa6cc531 100644 --- a/core/lib/eth_client/src/types.rs +++ b/core/lib/eth_client/src/types.rs @@ -124,6 +124,52 @@ impl ContractCall<'_> { } }) } + + pub async fn call_with_function( + &self, + client: &dyn EthInterface, + function: ethabi::Function, + ) -> Result { + let encoded_input = function + .encode_input(&self.inner.params) + .map_err(|source| ContractCallError::EncodeInput { + signature: function.signature(), + input: self.inner.params.clone(), + source, + })?; + + let request = web3::CallRequest { + from: self.inner.from, + to: Some(self.contract_address), + data: Some(Bytes(encoded_input)), + // Other options are never set + gas: None, + gas_price: None, + value: None, + transaction_type: None, + access_list: None, + max_fee_per_gas: None, + max_priority_fee_per_gas: None, + }; + + let encoded_output = client + .call_contract_function(request, self.inner.block) + .await?; + let output_tokens = function + .decode_output(&encoded_output.0) + .map_err(|source| ContractCallError::DecodeOutput { + signature: function.signature(), + output: encoded_output, + source, + })?; + Res::from_tokens(output_tokens.clone()).map_err(|source| { + ContractCallError::DetokenizeOutput { + signature: function.signature(), + output: output_tokens, + source, + } + }) + } } /// Contract-related subset of Ethereum client errors. diff --git a/core/lib/l1_contract_interface/Cargo.toml b/core/lib/l1_contract_interface/Cargo.toml index 1aa4c256e0fb..a0c0eb416fd1 100644 --- a/core/lib/l1_contract_interface/Cargo.toml +++ b/core/lib/l1_contract_interface/Cargo.toml @@ -18,6 +18,8 @@ zksync_prover_interface.workspace = true crypto_codegen.workspace = true # Used to calculate the kzg commitment and proofs kzg.workspace = true +fflonk.workspace = true +circuit_definitions.workspace = true anyhow.workspace = true sha2.workspace = true diff --git a/core/lib/l1_contract_interface/src/i_executor/methods/prove_batches.rs b/core/lib/l1_contract_interface/src/i_executor/methods/prove_batches.rs index a54cf407d09f..2d02bd5a1764 100644 --- a/core/lib/l1_contract_interface/src/i_executor/methods/prove_batches.rs +++ b/core/lib/l1_contract_interface/src/i_executor/methods/prove_batches.rs @@ -1,13 +1,23 @@ +use circuit_definitions::circuit_definitions::aux_layer::ZkSyncSnarkWrapperCircuitNoLookupCustomGate; use crypto_codegen::serialize_proof; +use fflonk::{ + bellman::{ + bn256, + bn256::{Bn256, Fr}, + CurveAffine, Engine, Field, PrimeField, PrimeFieldRepr, + }, + FflonkProof, +}; use zksync_prover_interface::outputs::L1BatchProofForL1; use zksync_types::{ commitment::L1BatchWithMetadata, ethabi::{encode, Token}, + U256, }; use crate::{ i_executor::structures::{StoredBatchInfo, SUPPORTED_ENCODING_VERSION}, - Tokenizable, Tokenize, + Tokenizable, }; /// Input required to encode `proveBatches` call. @@ -19,8 +29,8 @@ pub struct ProveBatches { pub should_verify: bool, } -impl Tokenize for &ProveBatches { - fn into_tokens(self) -> Vec { +impl ProveBatches { + pub fn conditional_into_tokens(&self, is_verifier_pre_fflonk: bool) -> Vec { let prev_l1_batch_info = StoredBatchInfo::from(&self.prev_l1_batch).into_token(); let batches_arg = self .l1_batches @@ -35,17 +45,31 @@ impl Tokenize for &ProveBatches { assert_eq!(self.proofs.len(), 1); assert_eq!(self.l1_batches.len(), 1); - let L1BatchProofForL1 { - scheduler_proof, .. - } = self.proofs.first().unwrap(); + let (verifier_type, proof) = match self.proofs.first().unwrap() { + L1BatchProofForL1::Fflonk(proof) => { + let scheduler_proof = proof.scheduler_proof.clone(); - let (_, proof) = serialize_proof(scheduler_proof); + let (_, serialized_proof) = serialize_fflonk_proof(&scheduler_proof); + (U256::from(0), serialized_proof) + } + L1BatchProofForL1::Plonk(proof) => { + let (_, serialized_proof) = serialize_proof(&proof.scheduler_proof); + (U256::from(1), serialized_proof) + } + }; if protocol_version.is_pre_gateway() { - let proof_input = Token::Tuple(vec![ - Token::Array(Vec::new()), - Token::Array(proof.into_iter().map(Token::Uint).collect()), - ]); + let proof_input = if !is_verifier_pre_fflonk || !protocol_version.is_pre_fflonk() { + Token::Tuple(vec![ + Token::Array(vec![verifier_type.into_token()]), + Token::Array(proof.into_iter().map(Token::Uint).collect()), + ]) + } else { + Token::Tuple(vec![ + Token::Array(vec![]), + Token::Array(proof.into_iter().map(Token::Uint).collect()), + ]) + }; vec![prev_l1_batch_info, batches_arg, proof_input] } else { @@ -86,3 +110,67 @@ impl Tokenize for &ProveBatches { } } } + +fn serialize_fe_for_ethereum(field_element: &Fr) -> U256 { + let mut be_bytes = [0u8; 32]; + field_element + .into_repr() + .write_be(&mut be_bytes[..]) + .expect("get new root BE bytes"); + U256::from_big_endian(&be_bytes[..]) +} + +fn serialize_g1_for_ethereum(point: &::G1Affine) -> (U256, U256) { + if <::G1Affine as CurveAffine>::is_zero(point) { + return (U256::zero(), U256::zero()); + } + let (x, y) = <::G1Affine as CurveAffine>::into_xy_unchecked(*point); + let _ = <::G1Affine as CurveAffine>::from_xy_checked(x, y).unwrap(); + + let mut buffer = [0u8; 32]; + x.into_repr().write_be(&mut buffer[..]).unwrap(); + let x = U256::from_big_endian(&buffer); + + let mut buffer = [0u8; 32]; + y.into_repr().write_be(&mut buffer[..]).unwrap(); + let y = U256::from_big_endian(&buffer); + + (x, y) +} + +fn serialize_fflonk_proof( + proof: &FflonkProof, +) -> (Vec, Vec) { + let mut serialized_inputs = vec![]; + for input in proof.inputs.iter() { + serialized_inputs.push(serialize_fe_for_ethereum(input)); + } + + let mut serialized_proof = vec![]; + + assert_eq!(proof.commitments.len(), 4); + + for c in proof.commitments.iter() { + let (x, y) = serialize_g1_for_ethereum(c); + serialized_proof.push(x); + serialized_proof.push(y); + } + + assert_eq!(proof.evaluations.len(), 15); + + for el in proof.evaluations.iter() { + serialized_proof.push(serialize_fe_for_ethereum(el)); + } + + assert_eq!(proof.lagrange_basis_inverses.len(), 18); + + let mut product = proof.lagrange_basis_inverses[0]; + + for i in 1..proof.lagrange_basis_inverses.len() { + product.mul_assign(&proof.lagrange_basis_inverses[i]); + } + + serialized_proof.push(serialize_fe_for_ethereum(&product)); + + (serialized_inputs, serialized_proof) +} diff --git a/core/lib/protobuf_config/src/eth.rs b/core/lib/protobuf_config/src/eth.rs index a50b452ccd16..21cc572f82da 100644 --- a/core/lib/protobuf_config/src/eth.rs +++ b/core/lib/protobuf_config/src/eth.rs @@ -129,6 +129,7 @@ impl ProtoRepr for proto::Sender { time_in_mempool_in_l1_blocks_cap: self .time_in_mempool_in_l1_blocks_cap .unwrap_or(Self::Type::default_time_in_mempool_in_l1_blocks_cap()), + is_verifier_pre_fflonk: self.is_verifier_pre_fflonk.unwrap_or(true), }) } @@ -158,6 +159,7 @@ impl ProtoRepr for proto::Sender { tx_aggregation_paused: Some(this.tx_aggregation_paused), priority_op_start_index: this.priority_tree_start_index.map(|x| x as u64), time_in_mempool_in_l1_blocks_cap: Some(this.time_in_mempool_in_l1_blocks_cap), + is_verifier_pre_fflonk: Some(this.is_verifier_pre_fflonk), } } } diff --git a/core/lib/protobuf_config/src/genesis.rs b/core/lib/protobuf_config/src/genesis.rs index 1d0ddf952c90..4040738ecd38 100644 --- a/core/lib/protobuf_config/src/genesis.rs +++ b/core/lib/protobuf_config/src/genesis.rs @@ -88,6 +88,12 @@ impl ProtoRepr for proto::Genesis { .and_then(|x| L2ChainId::try_from(*x).map_err(|a| anyhow::anyhow!(a))) .context("l2_chain_id")?, snark_wrapper_vk_hash, + fflonk_snark_wrapper_vk_hash: prover + .fflonk_snark_wrapper_vk_hash + .as_ref() + .map(|x| parse_h256(x).context("fflonk_snark_wrapper_vk_hash")) + .transpose() + .context("fflonk_snark_wrapper_vk_hash")?, fee_account: required(&self.fee_account) .and_then(|x| parse_h160(x)) .context("fee_account")?, @@ -119,6 +125,9 @@ impl ProtoRepr for proto::Genesis { recursion_scheduler_level_vk_hash: None, // Deprecated field. dummy_verifier: Some(this.dummy_verifier), snark_wrapper_vk_hash: Some(format!("{:?}", this.snark_wrapper_vk_hash)), + fflonk_snark_wrapper_vk_hash: this + .fflonk_snark_wrapper_vk_hash + .map(|x| format!("{:?}", x)), }), l1_batch_commit_data_generator_mode: Some( proto::L1BatchCommitDataGeneratorMode::new( diff --git a/core/lib/protobuf_config/src/proto/config/eth_sender.proto b/core/lib/protobuf_config/src/proto/config/eth_sender.proto index 4a9bad0acc10..bd80d2131358 100644 --- a/core/lib/protobuf_config/src/proto/config/eth_sender.proto +++ b/core/lib/protobuf_config/src/proto/config/eth_sender.proto @@ -55,6 +55,7 @@ message Sender { optional bool tx_aggregation_only_prove_and_execute = 21; // required optional uint32 time_in_mempool_in_l1_blocks_cap = 22; // optional optional uint64 priority_op_start_index = 23; // optional + optional bool is_verifier_pre_fflonk = 24; // optional } message GasAdjuster { diff --git a/core/lib/protobuf_config/src/proto/config/genesis.proto b/core/lib/protobuf_config/src/proto/config/genesis.proto index 808bcee4799b..ab948d5afdc6 100644 --- a/core/lib/protobuf_config/src/proto/config/genesis.proto +++ b/core/lib/protobuf_config/src/proto/config/genesis.proto @@ -11,6 +11,7 @@ message Prover { optional string recursion_scheduler_level_vk_hash = 1; // optional and deprecated, used as alias for `snark_wrapper_vk_hash`; H256 optional bool dummy_verifier = 5; optional string snark_wrapper_vk_hash = 6; // optional (required if `recursion_scheduler_level_vk_hash` is not set); H256 + optional string fflonk_snark_wrapper_vk_hash = 7; // optional; H256 reserved 2, 3, 4; reserved "recursion_node_level_vk_hash", "recursion_leaf_level_vk_hash", "recursion_circuits_set_vks_hash"; } diff --git a/core/lib/prover_interface/Cargo.toml b/core/lib/prover_interface/Cargo.toml index 3ed8a9ff558f..533e3bc1296a 100644 --- a/core/lib/prover_interface/Cargo.toml +++ b/core/lib/prover_interface/Cargo.toml @@ -16,6 +16,8 @@ zksync_object_store.workspace = true zksync_types.workspace = true # We can use the newest api to send proofs to L1. +circuit_definitions.workspace = true +fflonk.workspace = true circuit_sequencer_api.workspace = true serde.workspace = true diff --git a/core/lib/prover_interface/src/outputs.rs b/core/lib/prover_interface/src/outputs.rs index b6422473cea3..b536c39778a5 100644 --- a/core/lib/prover_interface/src/outputs.rs +++ b/core/lib/prover_interface/src/outputs.rs @@ -1,19 +1,62 @@ use core::fmt; +use circuit_definitions::{ + boojum::pairing::bn256::Bn256, + circuit_definitions::aux_layer::ZkSyncSnarkWrapperCircuitNoLookupCustomGate, +}; use circuit_sequencer_api::proof::FinalProof; +use fflonk::FflonkProof; use serde::{Deserialize, Serialize}; use serde_with::{hex::Hex, serde_as}; -use zksync_object_store::{serialize_using_bincode, Bucket, StoredObject}; +use zksync_object_store::{serialize_using_bincode, Bucket, StoredObject, _reexports::BoxedError}; use zksync_types::{protocol_version::ProtocolSemanticVersion, tee_types::TeeType, L1BatchNumber}; /// A "final" ZK proof that can be sent to the L1 contract. #[derive(Clone, Serialize, Deserialize)] -pub struct L1BatchProofForL1 { +#[allow(clippy::large_enum_variant)] +pub enum L1BatchProofForL1 { + Fflonk(FflonkL1BatchProofForL1), + Plonk(PlonkL1BatchProofForL1), +} + +impl L1BatchProofForL1 { + pub fn protocol_version(&self) -> ProtocolSemanticVersion { + match self { + L1BatchProofForL1::Fflonk(proof) => proof.protocol_version, + L1BatchProofForL1::Plonk(proof) => proof.protocol_version, + } + } + + pub fn aggregation_result_coords(&self) -> [[u8; 32]; 4] { + match self { + L1BatchProofForL1::Fflonk(proof) => proof.aggregation_result_coords, + L1BatchProofForL1::Plonk(proof) => proof.aggregation_result_coords, + } + } +} + +#[derive(Clone, Serialize, Deserialize)] +pub struct FflonkL1BatchProofForL1 { + pub aggregation_result_coords: [[u8; 32]; 4], + pub scheduler_proof: FflonkProof, + pub protocol_version: ProtocolSemanticVersion, +} + +#[derive(Clone, Serialize, Deserialize)] +pub struct PlonkL1BatchProofForL1 { pub aggregation_result_coords: [[u8; 32]; 4], pub scheduler_proof: FinalProof, pub protocol_version: ProtocolSemanticVersion, } +// Implementation created to allow conversion from PlonkL1BatchProofForL1(which is old L1BatchProofForL1) +// to L1BatchProofForL1 to avoid compatibility problems with serialization/deserialization +impl From for L1BatchProofForL1 { + fn from(proof: PlonkL1BatchProofForL1) -> Self { + L1BatchProofForL1::Plonk(proof) + } +} + /// A "final" TEE proof that can be sent to the L1 contract. #[serde_as] #[derive(Clone, PartialEq, Serialize, Deserialize)] @@ -36,6 +79,23 @@ impl fmt::Debug for L1BatchProofForL1 { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter .debug_struct("L1BatchProofForL1") + .finish_non_exhaustive() + } +} + +impl fmt::Debug for PlonkL1BatchProofForL1 { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + formatter + .debug_struct("PplonkL1BatchProofForL1") + .field("aggregation_result_coords", &self.aggregation_result_coords) + .finish_non_exhaustive() + } +} + +impl fmt::Debug for FflonkL1BatchProofForL1 { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + formatter + .debug_struct("FflonkL1BatchProofForL1") .field("aggregation_result_coords", &self.aggregation_result_coords) .finish_non_exhaustive() } @@ -59,7 +119,17 @@ impl StoredObject for L1BatchProofForL1 { format!("l1_batch_proof_{l1_batch_number}_{semver_suffix}.bin") } - serialize_using_bincode!(); + fn serialize(&self) -> Result, BoxedError> { + zksync_object_store::bincode::serialize(self).map_err(From::from) + } + + fn deserialize(bytes: Vec) -> Result { + zksync_object_store::bincode::deserialize::(&bytes).or_else(|_| { + zksync_object_store::bincode::deserialize::(&bytes) + .map(Into::into) + .map_err(Into::into) + }) + } } impl StoredObject for L1BatchTeeProofForL1 { diff --git a/core/lib/prover_interface/tests/job_serialization.rs b/core/lib/prover_interface/tests/job_serialization.rs index d170520798d1..cc78a9acf262 100644 --- a/core/lib/prover_interface/tests/job_serialization.rs +++ b/core/lib/prover_interface/tests/job_serialization.rs @@ -1,12 +1,12 @@ //! Integration tests for object store serialization of job objects. -use circuit_sequencer_api::proof::FinalProof; +use fflonk::FflonkProof; use tokio::fs; -use zksync_object_store::{Bucket, MockObjectStore}; +use zksync_object_store::{Bucket, MockObjectStore, StoredObject}; use zksync_prover_interface::{ api::{SubmitProofRequest, SubmitTeeProofRequest}, inputs::{StorageLogMetadata, WitnessInputMerklePaths}, - outputs::{L1BatchProofForL1, L1BatchTeeProofForL1}, + outputs::{FflonkL1BatchProofForL1, L1BatchProofForL1, L1BatchTeeProofForL1}, }; use zksync_types::{ protocol_version::ProtocolSemanticVersion, tee_types::TeeType, L1BatchNumber, ProtocolVersionId, @@ -77,88 +77,104 @@ async fn test_final_proof_deserialization() { .await .unwrap(); - let results: L1BatchProofForL1 = bincode::deserialize(&proof).unwrap(); - assert_eq!(results.aggregation_result_coords[0][0], 0); + let results: L1BatchProofForL1 = StoredObject::deserialize(proof).unwrap(); + + let coords = match results { + L1BatchProofForL1::Fflonk(proof) => proof.aggregation_result_coords, + L1BatchProofForL1::Plonk(proof) => proof.aggregation_result_coords, + }; + + assert_eq!(coords[0][0], 0); } #[test] fn test_proof_request_serialization() { - let proof = SubmitProofRequest::Proof(Box::new(L1BatchProofForL1 { - aggregation_result_coords: [[0; 32]; 4], - scheduler_proof: FinalProof::empty(), - protocol_version: ProtocolSemanticVersion { - minor: ProtocolVersionId::Version25, - patch: 10.into(), + let proof = SubmitProofRequest::Proof(Box::new(L1BatchProofForL1::Fflonk( + FflonkL1BatchProofForL1 { + aggregation_result_coords: [[0; 32]; 4], + scheduler_proof: FflonkProof::empty(), + protocol_version: ProtocolSemanticVersion { + minor: ProtocolVersionId::Version25, + patch: 10.into(), + }, }, - })); + ))); let encoded_obj = serde_json::to_string(&proof).unwrap(); let encoded_json = r#"{ "Proof": { - "aggregation_result_coords": [ - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + "Plonk": { + "aggregation_result_coords": [ + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ] ], - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ] - ], - "scheduler_proof": { - "n": 0, - "inputs": [], - "state_polys_commitments": [], - "witness_polys_commitments": [], - "copy_permutation_grand_product_commitment": { - "x": [ 0, 0, 0, 0 ], - "y": [ 1, 0, 0, 0 ], - "infinity": true - }, - "lookup_s_poly_commitment": null, - "lookup_grand_product_commitment": null, - "quotient_poly_parts_commitments": [], - "state_polys_openings_at_z": [], - "state_polys_openings_at_dilations": [], - "witness_polys_openings_at_z": [], - "witness_polys_openings_at_dilations": [], - "gate_setup_openings_at_z": [], - "gate_selectors_openings_at_z": [], - "copy_permutation_polys_openings_at_z": [], - "copy_permutation_grand_product_opening_at_z_omega": [ 0, 0, 0, 0 ], - "lookup_s_poly_opening_at_z_omega": null, - "lookup_grand_product_opening_at_z_omega": null, - "lookup_t_poly_opening_at_z": null, - "lookup_t_poly_opening_at_z_omega": null, - "lookup_selector_poly_opening_at_z": null, - "lookup_table_type_poly_opening_at_z": null, - "quotient_poly_opening_at_z": [ 0, 0, 0, 0 ], - "linearization_poly_opening_at_z": [ 0, 0, 0, 0 ], - "opening_proof_at_z": { - "x": [ 0, 0, 0, 0 ], - "y": [ 1, 0, 0, 0 ], - "infinity": true + "scheduler_proof": { + "n": 0, + "inputs": [], + "state_polys_commitments": [], + "witness_polys_commitments": [], + "copy_permutation_grand_product_commitment": { + "x": [ 0, 0, 0, 0 ], + "y": [ 1, 0, 0, 0 ], + "infinity": true + }, + "lookup_s_poly_commitment": null, + "lookup_grand_product_commitment": null, + "quotient_poly_parts_commitments": [], + "state_polys_openings_at_z": [], + "state_polys_openings_at_dilations": [], + "witness_polys_openings_at_z": [], + "witness_polys_openings_at_dilations": [], + "gate_setup_openings_at_z": [], + "gate_selectors_openings_at_z": [], + "copy_permutation_polys_openings_at_z": [], + "copy_permutation_grand_product_opening_at_z_omega": [ 0, 0, 0, 0 ], + "lookup_s_poly_opening_at_z_omega": null, + "lookup_grand_product_opening_at_z_omega": null, + "lookup_t_poly_opening_at_z": null, + "lookup_t_poly_opening_at_z_omega": null, + "lookup_selector_poly_opening_at_z": null, + "lookup_table_type_poly_opening_at_z": null, + "quotient_poly_opening_at_z": [ 0, 0, 0, 0 ], + "linearization_poly_opening_at_z": [ 0, 0, 0, 0 ], + "opening_proof_at_z": { + "x": [ 0, 0, 0, 0 ], + "y": [ 1, 0, 0, 0 ], + "infinity": true + }, + "opening_proof_at_z_omega": { + "x": [ 0, 0, 0, 0 ], + "y": [ 1, 0, 0, 0 ], + "infinity": true + } }, - "opening_proof_at_z_omega": { - "x": [ 0, 0, 0, 0 ], - "y": [ 1, 0, 0, 0 ], - "infinity": true - } - }, - "protocol_version": "0.25.10" + "protocol_version": "0.25.10" + } } }"#; let decoded_obj: SubmitProofRequest = serde_json::from_str(&encoded_obj).unwrap(); let decoded_json: SubmitProofRequest = serde_json::from_str(encoded_json).unwrap(); match (decoded_obj, decoded_json) { (SubmitProofRequest::Proof(decoded_obj), SubmitProofRequest::Proof(decoded_json)) => { - assert_eq!( - decoded_obj.aggregation_result_coords, - decoded_json.aggregation_result_coords - ); + let obj_coords = match *decoded_obj { + L1BatchProofForL1::Fflonk(obj) => obj.aggregation_result_coords, + L1BatchProofForL1::Plonk(obj) => obj.aggregation_result_coords, + }; + let json_coords = match *decoded_json { + L1BatchProofForL1::Fflonk(obj) => obj.aggregation_result_coords, + L1BatchProofForL1::Plonk(obj) => obj.aggregation_result_coords, + }; + + assert_eq!(obj_coords, json_coords); } _ => panic!("Either decoded_obj or decoded_json is not SubmitProofRequest::Proof"), } diff --git a/core/lib/types/src/protocol_upgrade.rs b/core/lib/types/src/protocol_upgrade.rs index 7d8f678fa851..4ea007239103 100644 --- a/core/lib/types/src/protocol_upgrade.rs +++ b/core/lib/types/src/protocol_upgrade.rs @@ -291,6 +291,7 @@ impl ProtocolVersion { &self, upgrade: ProtocolUpgrade, new_snark_wrapper_vk_hash: Option, + new_fflonk_snark_wrapper_vk_hash: Option, ) -> ProtocolVersion { ProtocolVersion { version: upgrade.version, @@ -298,6 +299,8 @@ impl ProtocolVersion { l1_verifier_config: L1VerifierConfig { snark_wrapper_vk_hash: new_snark_wrapper_vk_hash .unwrap_or(self.l1_verifier_config.snark_wrapper_vk_hash), + fflonk_snark_wrapper_vk_hash: new_fflonk_snark_wrapper_vk_hash + .or(self.l1_verifier_config.fflonk_snark_wrapper_vk_hash), }, base_system_contracts_hashes: BaseSystemContractsHashes { bootloader: upgrade diff --git a/core/lib/vm_executor/src/oneshot/contracts.rs b/core/lib/vm_executor/src/oneshot/contracts.rs index cacab36cb1c2..257ede5a7c7c 100644 --- a/core/lib/vm_executor/src/oneshot/contracts.rs +++ b/core/lib/vm_executor/src/oneshot/contracts.rs @@ -15,6 +15,7 @@ pub trait ContractsKind: fmt::Debug + Sealed {} pub struct EstimateGas(()); impl Sealed for EstimateGas {} + impl ContractsKind for EstimateGas {} /// Marker for [`BaseSystemContracts`] used for calls and transaction execution. @@ -22,6 +23,7 @@ impl ContractsKind for EstimateGas {} pub struct CallOrExecute(()); impl Sealed for CallOrExecute {} + impl ContractsKind for CallOrExecute {} /// Provider of [`BaseSystemContracts`] for oneshot execution. @@ -108,6 +110,7 @@ impl MultiVmBaseSystemContracts { &self.vm_protocol_defense } ProtocolVersionId::Version27 => &self.gateway, + ProtocolVersionId::Version28 => unreachable!("Version 28 is not supported yet"), }; let base = base.clone(); diff --git a/core/node/api_server/src/web3/namespaces/en.rs b/core/node/api_server/src/web3/namespaces/en.rs index e93f918ad446..b2baa8497c98 100644 --- a/core/node/api_server/src/web3/namespaces/en.rs +++ b/core/node/api_server/src/web3/namespaces/en.rs @@ -216,6 +216,7 @@ impl EnNamespace { l1_chain_id: self.state.api_config.l1_chain_id, l2_chain_id: self.state.api_config.l2_chain_id, snark_wrapper_vk_hash: verifier_config.snark_wrapper_vk_hash, + fflonk_snark_wrapper_vk_hash: verifier_config.fflonk_snark_wrapper_vk_hash, fee_account, dummy_verifier: self.state.api_config.dummy_verifier, l1_batch_commit_data_generator_mode: self diff --git a/core/node/eth_sender/src/aggregator.rs b/core/node/eth_sender/src/aggregator.rs index c5e415061409..466362a1ccfe 100644 --- a/core/node/eth_sender/src/aggregator.rs +++ b/core/node/eth_sender/src/aggregator.rs @@ -628,7 +628,10 @@ pub async fn load_wrapped_fri_proofs_for_range( allowed_versions: &[ProtocolSemanticVersion], ) -> Option { for version in allowed_versions { - match blob_store.get((l1_batch_number, *version)).await { + match blob_store + .get::((l1_batch_number, *version)) + .await + { Ok(proof) => return Some(proof), Err(ObjectStoreError::KeyNotFound(_)) => (), // do nothing, proof is not ready yet Err(err) => panic!( diff --git a/core/node/eth_sender/src/eth_tx_aggregator.rs b/core/node/eth_sender/src/eth_tx_aggregator.rs index dbef6da7b47b..113dfb840fc1 100644 --- a/core/node/eth_sender/src/eth_tx_aggregator.rs +++ b/core/node/eth_sender/src/eth_tx_aggregator.rs @@ -2,7 +2,7 @@ use tokio::sync::watch; use zksync_config::configs::eth_sender::SenderConfig; use zksync_contracts::BaseSystemContractsHashes; use zksync_dal::{Connection, ConnectionPool, Core, CoreDal}; -use zksync_eth_client::{BoundEthInterface, CallFunctionArgs}; +use zksync_eth_client::{BoundEthInterface, CallFunctionArgs, ContractCallError}; use zksync_health_check::{Health, HealthStatus, HealthUpdater, ReactiveHealthCheck}; use zksync_l1_contract_interface::{ i_executor::{ @@ -75,6 +75,8 @@ struct TxData { sidecar: Option, } +const FFLONK_VERIFIER_TYPE: i32 = 1; + impl EthTxAggregator { #[allow(clippy::too_many_arguments)] pub async fn new( @@ -130,6 +132,11 @@ impl EthTxAggregator { self.health_updater .update(Health::from(HealthStatus::Ready)); + tracing::info!( + "Initialized eth_tx_aggregator with is_pre_fflonk_verifier: {:?}", + self.config.is_verifier_pre_fflonk + ); + let pool = self.pool.clone(); loop { let mut storage = pool.connection_tagged("eth_sender").await.unwrap(); @@ -367,6 +374,7 @@ impl EthTxAggregator { verifier_address: Address, ) -> Result { let get_vk_hash = &self.functions.verification_key_hash; + let vk_hash: H256 = CallFunctionArgs::new(&get_vk_hash.name, ()) .for_contract(verifier_address, &self.functions.verifier_contract) .call((*self.eth_client).as_ref()) @@ -374,6 +382,33 @@ impl EthTxAggregator { Ok(vk_hash) } + async fn get_fflonk_snark_wrapper_vk_hash( + &mut self, + verifier_address: Address, + ) -> Result, EthSenderError> { + let get_vk_hash = &self.functions.verification_key_hash; + // We are getting function separately to get the second function with the same name, but + // overriden one + let function = self + .functions + .verifier_contract + .functions_by_name(&get_vk_hash.name) + .map_err(|x| EthSenderError::ContractCall(ContractCallError::Function(x)))? + .get(1); + + if let Some(function) = function { + let vk_hash: Option = + CallFunctionArgs::new(&get_vk_hash.name, U256::from(FFLONK_VERIFIER_TYPE)) + .for_contract(verifier_address, &self.functions.verifier_contract) + .call_with_function((*self.eth_client).as_ref(), function.clone()) + .await + .ok(); + Ok(vk_hash) + } else { + Ok(None) + } + } + #[tracing::instrument(skip_all, name = "EthTxAggregator::loop_iteration")] async fn loop_iteration( &mut self, @@ -395,8 +430,17 @@ impl EthTxAggregator { tracing::error!("Failed to get VK hash from the Verifier {err:?}"); err })?; + let fflonk_snark_wrapper_vk_hash = self + .get_fflonk_snark_wrapper_vk_hash(verifier_address) + .await + .map_err(|err| { + tracing::error!("Failed to get FFLONK VK hash from the Verifier {err:?}"); + err + })?; + let l1_verifier_config = L1VerifierConfig { snark_wrapper_vk_hash, + fflonk_snark_wrapper_vk_hash, }; if let Some(agg_op) = self .aggregator @@ -506,7 +550,7 @@ impl EthTxAggregator { Self::encode_commit_data(encoding_fn, &commit_data, l1_batch_for_sidecar) } AggregatedOperation::PublishProofOnchain(op) => { - args.extend(op.into_tokens()); + args.extend(op.conditional_into_tokens(self.config.is_verifier_pre_fflonk)); let encoding_fn = if is_op_pre_gateway { &self.functions.post_shared_bridge_prove } else { diff --git a/core/node/eth_watch/src/client.rs b/core/node/eth_watch/src/client.rs index 18e49aad0813..0197748376ae 100644 --- a/core/node/eth_watch/src/client.rs +++ b/core/node/eth_watch/src/client.rs @@ -22,6 +22,8 @@ use zksync_web3_decl::{ namespaces::{EthNamespaceClient, UnstableNamespaceClient, ZksNamespaceClient}, }; +const FFLONK_VERIFIER_TYPE: i32 = 0; + /// Common L1 and L2 client functionality used by [`EthWatch`](crate::EthWatch) and constituent event processors. #[async_trait::async_trait] pub trait EthClient: 'static + fmt::Debug + Send + Sync { @@ -45,6 +47,10 @@ pub trait EthClient: 'static + fmt::Debug + Send + Sync { /// Returns scheduler verification key hash by verifier address. async fn scheduler_vk_hash(&self, verifier_address: Address) -> Result; + async fn fflonk_scheduler_vk_hash( + &self, + verifier_address: Address, + ) -> Result, ContractCallError>; /// Returns upgrade diamond cut by packed protocol version. async fn diamond_cut_by_version( &self, @@ -258,33 +264,6 @@ where .await } - async fn diamond_cut_by_version( - &self, - packed_version: H256, - ) -> EnrichedClientResult>> { - const LOOK_BACK_BLOCK_RANGE: u64 = 1_000_000; - - let Some(state_transition_manager_address) = self.state_transition_manager_address else { - return Ok(None); - }; - - let to_block = self.client.block_number().await?; - let from_block = to_block.saturating_sub((LOOK_BACK_BLOCK_RANGE - 1).into()); - - let logs = self - .get_events_inner( - from_block.into(), - to_block.into(), - Some(vec![self.new_upgrade_cut_data_signature]), - Some(vec![packed_version]), - Some(vec![state_transition_manager_address]), - RETRY_LIMIT, - ) - .await?; - - Ok(logs.into_iter().next().map(|log| log.data.0)) - } - async fn get_events( &self, from: BlockNumber, @@ -337,6 +316,59 @@ where .map(|x: U256| x.try_into().unwrap()) } + async fn fflonk_scheduler_vk_hash( + &self, + verifier_address: Address, + ) -> Result, ContractCallError> { + // New verifier returns the hash of the verification key. + // We are getting function separately to get the second function with the same name, but + // overriden one + let function = self + .verifier_contract_abi + .functions_by_name("verificationKeyHash") + .map_err(ContractCallError::Function)? + .get(1); + + if let Some(function) = function { + Ok( + CallFunctionArgs::new("verificationKeyHash", U256::from(FFLONK_VERIFIER_TYPE)) + .for_contract(verifier_address, &self.verifier_contract_abi) + .call_with_function(&self.client, function.clone()) + .await + .ok(), + ) + } else { + Ok(None) + } + } + + async fn diamond_cut_by_version( + &self, + packed_version: H256, + ) -> EnrichedClientResult>> { + const LOOK_BACK_BLOCK_RANGE: u64 = 1_000_000; + + let Some(state_transition_manager_address) = self.state_transition_manager_address else { + return Ok(None); + }; + + let to_block = self.client.block_number().await?; + let from_block = to_block.saturating_sub((LOOK_BACK_BLOCK_RANGE - 1).into()); + + let logs = self + .get_events_inner( + from_block.into(), + to_block.into(), + Some(vec![self.new_upgrade_cut_data_signature]), + Some(vec![packed_version]), + Some(vec![state_transition_manager_address]), + RETRY_LIMIT, + ) + .await?; + + Ok(logs.into_iter().next().map(|log| log.data.0)) + } + async fn chain_id(&self) -> EnrichedClientResult { self.client.fetch_chain_id().await } @@ -473,6 +505,13 @@ impl EthClient for L2EthClientW { self.0.scheduler_vk_hash(verifier_address).await } + async fn fflonk_scheduler_vk_hash( + &self, + verifier_address: Address, + ) -> Result, ContractCallError> { + self.0.fflonk_scheduler_vk_hash(verifier_address).await + } + async fn diamond_cut_by_version( &self, packed_version: H256, diff --git a/core/node/eth_watch/src/event_processors/decentralized_upgrades.rs b/core/node/eth_watch/src/event_processors/decentralized_upgrades.rs index 3f4b0f3cf5ab..6e55b9ea0f89 100644 --- a/core/node/eth_watch/src/event_processors/decentralized_upgrades.rs +++ b/core/node/eth_watch/src/event_processors/decentralized_upgrades.rs @@ -71,26 +71,34 @@ impl EventProcessor for DecentralizedUpgradesEventProcessor { } else { None }; - upgrades.push((upgrade, scheduler_vk_hash)); + + // Scheduler VK is not present in proposal event. It is hard coded in verifier contract. + let fflonk_scheduler_vk_hash = if let Some(address) = upgrade.verifier_address { + self.sl_client.fflonk_scheduler_vk_hash(address).await? + } else { + None + }; + + upgrades.push((upgrade, scheduler_vk_hash, fflonk_scheduler_vk_hash)); } let new_upgrades: Vec<_> = upgrades .into_iter() - .skip_while(|(v, _)| v.version <= self.last_seen_protocol_version) + .skip_while(|(v, _, _)| v.version <= self.last_seen_protocol_version) .collect(); - let Some((last_upgrade, _)) = new_upgrades.last() else { + let Some((last_upgrade, _, _)) = new_upgrades.last() else { return Ok(events.len()); }; let versions: Vec<_> = new_upgrades .iter() - .map(|(u, _)| u.version.to_string()) + .map(|(u, _, _)| u.version.to_string()) .collect(); tracing::debug!("Received upgrades with versions: {versions:?}"); let last_version = last_upgrade.version; let stage_latency = METRICS.poll_eth_node[&PollStage::PersistUpgrades].start(); - for (upgrade, scheduler_vk_hash) in new_upgrades { + for (upgrade, scheduler_vk_hash, fflonk_scheduler_vk_hash) in new_upgrades { let latest_semantic_version = storage .protocol_versions_dal() .latest_semantic_version() @@ -111,7 +119,11 @@ impl EventProcessor for DecentralizedUpgradesEventProcessor { ) })?; - let new_version = latest_version.apply_upgrade(upgrade, scheduler_vk_hash); + let new_version = latest_version.apply_upgrade( + upgrade, + scheduler_vk_hash, + fflonk_scheduler_vk_hash, + ); if new_version.version.minor == latest_semantic_version.minor { // Only verification parameters may change if only patch is bumped. assert_eq!( diff --git a/core/node/eth_watch/src/tests/client.rs b/core/node/eth_watch/src/tests/client.rs index 04825f22d815..e94a32096d96 100644 --- a/core/node/eth_watch/src/tests/client.rs +++ b/core/node/eth_watch/src/tests/client.rs @@ -272,6 +272,13 @@ impl EthClient for MockEthClient { ) -> Result { unimplemented!() } + + async fn fflonk_scheduler_vk_hash( + &self, + _verifier_address: Address, + ) -> Result, ContractCallError> { + Ok(Some(H256::zero())) + } } #[async_trait::async_trait] diff --git a/core/node/external_proof_integration_api/src/types.rs b/core/node/external_proof_integration_api/src/types.rs index 16d562d4a3db..c1565282eaa2 100644 --- a/core/node/external_proof_integration_api/src/types.rs +++ b/core/node/external_proof_integration_api/src/types.rs @@ -50,7 +50,12 @@ impl ExternalProof { } pub fn verify(&self, correct: L1BatchProofForL1) -> Result<(), ProcessorError> { - if correct.protocol_version != self.protocol_version { + let protocol_version = match correct.clone() { + L1BatchProofForL1::Fflonk(proof) => proof.protocol_version, + L1BatchProofForL1::Plonk(proof) => proof.protocol_version, + }; + + if protocol_version != self.protocol_version { return Err(ProcessorError::InvalidProof); } @@ -97,9 +102,14 @@ impl FromRequest for ExternalProof { let serialized_proof = Self::extract_from_multipart(req, state).await?; let proof: L1BatchProofForL1 = bincode::deserialize(&serialized_proof)?; + let protocol_version = match proof { + L1BatchProofForL1::Fflonk(proof) => proof.protocol_version, + L1BatchProofForL1::Plonk(proof) => proof.protocol_version, + }; + Ok(Self { raw: serialized_proof, - protocol_version: proof.protocol_version, + protocol_version, }) } } diff --git a/core/node/genesis/src/lib.rs b/core/node/genesis/src/lib.rs index b3aa8de344d6..87457f3b1c01 100644 --- a/core/node/genesis/src/lib.rs +++ b/core/node/genesis/src/lib.rs @@ -35,6 +35,7 @@ use crate::utils::{ insert_base_system_contracts_to_factory_deps, insert_deduplicated_writes_and_protective_reads, insert_factory_deps, insert_storage_logs, save_genesis_l1_batch_metadata, }; + #[cfg(test)] mod tests; pub mod utils; @@ -181,6 +182,7 @@ pub fn mock_genesis_config() -> GenesisConfig { l1_chain_id: L1ChainId(9), l2_chain_id: L2ChainId::default(), snark_wrapper_vk_hash: first_l1_verifier_config.snark_wrapper_vk_hash, + fflonk_snark_wrapper_vk_hash: first_l1_verifier_config.fflonk_snark_wrapper_vk_hash, fee_account: Default::default(), dummy_verifier: false, l1_batch_commit_data_generator_mode: Default::default(), @@ -238,6 +240,7 @@ pub async fn insert_genesis_batch_with_custom_state( let mut transaction = storage.start_transaction().await?; let verifier_config = L1VerifierConfig { snark_wrapper_vk_hash: genesis_params.config.snark_wrapper_vk_hash, + fflonk_snark_wrapper_vk_hash: genesis_params.config.fflonk_snark_wrapper_vk_hash, }; // if a custom genesis state was provided, read storage logs and factory dependencies from there @@ -363,6 +366,40 @@ pub async fn validate_genesis_params( )); } + // We are getting function separately to get the second function with the same name, but + // overriden one + let function = verifier_abi + .functions_by_name("verificationKeyHash")? + .get(1); + + if let Some(function) = function { + let fflonk_verification_key_hash: Option = + CallFunctionArgs::new("verificationKeyHash", U256::from(0)) + .for_contract(verifier_address, &verifier_abi) + .call_with_function(query_client, function.clone()) + .await + .ok(); + tracing::info!( + "FFlonk verification key hash in contract: {:?}", + fflonk_verification_key_hash + ); + tracing::info!( + "FFlonk verification key hash in config: {:?}", + genesis_params.config().fflonk_snark_wrapper_vk_hash + ); + + if fflonk_verification_key_hash.is_some() + && fflonk_verification_key_hash != genesis_params.config().fflonk_snark_wrapper_vk_hash + { + return Err(anyhow::anyhow!( + "FFlonk verification key hash mismatch: {fflonk_verification_key_hash:?} on contract, {:?} in config", + genesis_params.config().fflonk_snark_wrapper_vk_hash + )); + } + } else { + tracing::warn!("FFlonk verification key hash is not present in the contract"); + } + Ok(()) } diff --git a/core/node/proof_data_handler/src/request_processor.rs b/core/node/proof_data_handler/src/request_processor.rs index 89304724a7c2..bc14e217a345 100644 --- a/core/node/proof_data_handler/src/request_processor.rs +++ b/core/node/proof_data_handler/src/request_processor.rs @@ -204,18 +204,17 @@ impl RequestProcessor { SubmitProofRequest::Proof(proof) => { let blob_url = self .blob_store - .put((l1_batch_number, proof.protocol_version), &*proof) + .put((l1_batch_number, proof.protocol_version()), &*proof) .await .map_err(RequestProcessorError::ObjectStore)?; - let system_logs_hash_from_prover = - H256::from_slice(&proof.aggregation_result_coords[0]); - let state_diff_hash_from_prover = - H256::from_slice(&proof.aggregation_result_coords[1]); + let aggregation_coords = proof.aggregation_result_coords(); + + let system_logs_hash_from_prover = H256::from_slice(&aggregation_coords[0]); + let state_diff_hash_from_prover = H256::from_slice(&aggregation_coords[1]); let bootloader_heap_initial_content_from_prover = - H256::from_slice(&proof.aggregation_result_coords[2]); - let events_queue_state_from_prover = - H256::from_slice(&proof.aggregation_result_coords[3]); + H256::from_slice(&aggregation_coords[2]); + let events_queue_state_from_prover = H256::from_slice(&aggregation_coords[3]); let mut storage = self.pool.connection().await.unwrap(); diff --git a/docker/circuit-prover-gpu/Dockerfile b/docker/circuit-prover-gpu/Dockerfile index 852f42d705ec..086f3e2d20ea 100644 --- a/docker/circuit-prover-gpu/Dockerfile +++ b/docker/circuit-prover-gpu/Dockerfile @@ -43,7 +43,7 @@ RUN curl -Lo sccache-v0.8.1-x86_64-unknown-linux-musl.tar.gz https://github.com/ WORKDIR /usr/src/zksync COPY . . -RUN cd prover && cargo build --release --bin zksync_circuit_prover +RUN cd prover && cargo build --release --package zksync_circuit_prover # Output build in CUDA architectures for debugging purposes. RUN cuobjdump /usr/src/zksync/prover/target/release/zksync_circuit_prover diff --git a/docker/prover-gpu-fri/Dockerfile b/docker/prover-gpu-fri/Dockerfile index db497fc5d500..84ca8fa9fdad 100644 --- a/docker/prover-gpu-fri/Dockerfile +++ b/docker/prover-gpu-fri/Dockerfile @@ -43,7 +43,7 @@ RUN curl -Lo sccache-v0.8.1-x86_64-unknown-linux-musl.tar.gz https://github.com/ WORKDIR /usr/src/zksync COPY . . -RUN cd prover && cargo build --release --features "gpu" --bin zksync_prover_fri +RUN cd prover && cargo build --release --features "gpu" --package zksync_prover_fri # Output build in CUDA architectures for debugging purposes. RUN cuobjdump /usr/src/zksync/prover/target/release/zksync_prover_fri diff --git a/etc/env/base/contracts.toml b/etc/env/base/contracts.toml index 735da993058b..ef52ed4c711b 100644 --- a/etc/env/base/contracts.toml +++ b/etc/env/base/contracts.toml @@ -57,8 +57,9 @@ L2_SHARED_BRIDGE_ADDR = "0xFC073319977e314F251EAE6ae6bE76B0B3BAeeCF" L2_SHARED_BRIDGE_IMPL_ADDR = "0xFC073319977e314F251EAE6ae6bE76B0B3BAeeCF" FRI_RECURSION_LEAF_LEVEL_VK_HASH = "0xf9664f4324c1400fa5c3822d667f30e873f53f1b8033180cd15fe41c1e2355c6" FRI_RECURSION_NODE_LEVEL_VK_HASH = "0xf520cd5b37e74e19fdb369c8d676a04dce8a19457497ac6686d2bb95d94109c8" -FRI_RECURSION_SCHEDULER_LEVEL_VK_HASH = "0xe6ba9d6b042440c480fa1c7182be32387db6e90281e82f37398d3f98f63f098a" +FRI_RECURSION_SCHEDULER_LEVEL_VK_HASH = "0x14f97b81e54b35fe673d8708cc1a19e1ea5b5e348e12d31e39824ed4f42bbca2" SNARK_WRAPPER_VK_HASH = "0x14f97b81e54b35fe673d8708cc1a19e1ea5b5e348e12d31e39824ed4f42bbca2" +FFLONK_SNARK_WRAPPER_VK_HASH = "0x560b19cfd6bcf1049c6409c18d81db288ab7639db080ed3b48df17ddfbcc4666" SHARED_BRIDGE_UPGRADE_STORAGE_SWITCH = 0 ERA_CHAIN_ID = 9 ERA_DIAMOND_PROXY_ADDR = "0x0000000000000000000000000000000000000000" diff --git a/etc/env/base/eth_sender.toml b/etc/env/base/eth_sender.toml index ad5709551c45..f6b2312e4232 100644 --- a/etc/env/base/eth_sender.toml +++ b/etc/env/base/eth_sender.toml @@ -48,6 +48,8 @@ max_acceptable_priority_fee_in_gwei = 100000000000 pubdata_sending_mode = "Blobs" +is_verifier_pre_fflonk = true + [eth_sender.gas_adjuster] # Priority fee to be used by GasAdjuster (in wei). default_priority_fee_per_gas = 1_000_000_000 diff --git a/etc/env/base/fri_proof_compressor.toml b/etc/env/base/fri_proof_compressor.toml index 9d26fe876896..80aab77ce056 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 +compression_mode = 5 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" +universal_setup_path = "../keys/setup/" +universal_setup_download_url = "https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/" verify_wrapper_proof = true diff --git a/etc/env/file_based/general.yaml b/etc/env/file_based/general.yaml index 62c264a376db..cd095dae23f2 100644 --- a/etc/env/file_based/general.yaml +++ b/etc/env/file_based/general.yaml @@ -104,6 +104,7 @@ eth: max_aggregated_tx_gas: 15000000 max_acceptable_priority_fee_in_gwei: 100000000000 # typo: value is in wei (100 gwei) pubdata_sending_mode: BLOBS + is_verifier_pre_fflonk: true gas_adjuster: default_priority_fee_per_gas: 1000000000 max_base_fee_samples: 100 @@ -175,14 +176,14 @@ prover_gateway: prometheus_pushgateway_url: http://127.0.0.1:9091 prometheus_push_interval_ms: 100 proof_compressor: - compression_mode: 1 + compression_mode: 5 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 + universal_setup_path: keys/setup/ + universal_setup_download_url: https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/ verify_wrapper_proof: true prover_group: group_0: diff --git a/etc/env/file_based/genesis.yaml b/etc/env/file_based/genesis.yaml index cbc29b9d0312..9f94dd0c04b6 100644 --- a/etc/env/file_based/genesis.yaml +++ b/etc/env/file_based/genesis.yaml @@ -8,6 +8,7 @@ l1_chain_id: 9 l2_chain_id: 270 fee_account: '0x0000000000000000000000000000000000000001' prover: + fflonk_snark_wrapper_vk_hash: 0x560b19cfd6bcf1049c6409c18d81db288ab7639db080ed3b48df17ddfbcc4666 dummy_verifier: true snark_wrapper_vk_hash: 0x14f97b81e54b35fe673d8708cc1a19e1ea5b5e348e12d31e39824ed4f42bbca2 genesis_protocol_semantic_version: 0.25.0 diff --git a/prover/Cargo.lock b/prover/Cargo.lock index fa8de019c740..8018f8e8fa87 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -625,9 +625,9 @@ dependencies = [ [[package]] name = "boojum" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4337dc7b196fc3e5e55e2857bc21638b7441429ee1a953201a9cd2be187b764e" +checksum = "14bd053feb7173130679a2119e105b5e78af7eb6b0e752de6793e4ee63d8e899" dependencies = [ "arrayvec 0.7.6", "bincode", @@ -657,9 +657,9 @@ dependencies = [ [[package]] name = "boojum-cuda" -version = "0.152.9" +version = "0.152.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380468fadcba5dcc4021f18f4516a7aa4f4d0ec598c76cd7e7c5f2ff6a56733f" +checksum = "bbd43bc7fc457920cb3b823e4f95ffbbf180b2c48b8d643125cd121325cdd8db" dependencies = [ "boojum", "cmake", @@ -805,9 +805,9 @@ dependencies = [ [[package]] name = "circuit_definitions" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931448074d9dad8aa7cf8f8f8d67101d4b2aac4d1f4699708b0744a9c000fc0b" +checksum = "10ebc81d5c2f6ee8de436c242f6466fb315fe25afcbc81aa1c47dfca39a55403" dependencies = [ "circuit_encodings", "crossbeam", @@ -819,26 +819,26 @@ dependencies = [ [[package]] name = "circuit_encodings" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3dcfcb4aaa17e6a81ebd2db688d980aff50aa643d9b506d4d11c84976dbc03f" +checksum = "33375d2448a78c1aed9b8755f7939a6b6f19e2fa80f44f4930a5b4c2bb7cbb44" dependencies = [ "derivative", "serde", - "zk_evm 0.150.18", + "zk_evm 0.150.19", "zkevm_circuits", ] [[package]] name = "circuit_sequencer_api" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d13ed70909e8390a4f2599d5a76d9ac4189e5bbbf16146d11b7999788740f291" +checksum = "ca2fec5c28e5a9f085279e70e13b2eebb63a95ee0bfb99d58095ac01c1c7b256" dependencies = [ "derivative", "rayon", "serde", - "zk_evm 0.150.18", + "zk_evm 0.150.19", "zksync_bellman", ] @@ -1706,9 +1706,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "era_cudart" -version = "0.152.9" +version = "0.152.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac345935bc5d367922a8e44f8b9b8f909f564b4cdc922567e9d3fe6b0fafab28" +checksum = "d6f881cf689ba889bb0fa04c0e71aba701acd7fafd3fa545e3f2782f2a8c0ba0" dependencies = [ "bitflags 2.6.0", "era_cudart_sys", @@ -1717,9 +1717,9 @@ dependencies = [ [[package]] name = "era_cudart_sys" -version = "0.152.9" +version = "0.152.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50eca396c549365468fa210b0c9c4a38895e4bff4ae5ce6f6626c337010de143" +checksum = "5f29cbd9e6d97fc1f05b484f960e921fe69548b4773a361b2e403e4cb9d6d575" dependencies = [ "serde_json", ] @@ -1836,6 +1836,41 @@ dependencies = [ "subtle", ] +[[package]] +name = "fflonk" +version = "0.30.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e63d70f1cbf9e572ccaf22ca1dfce4b93ff48b9a5e8dd70de50d87edb960d173" +dependencies = [ + "bincode", + "byteorder", + "franklin-crypto", + "num-bigint 0.4.6", + "num-traits", + "rand 0.4.6", + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "fflonk-cuda" +version = "0.152.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b008e6158c95747b3b135adbd7f6d563c406849a10c00abfef109b4d0442a589" +dependencies = [ + "bincode", + "byteorder", + "circuit_definitions", + "derivative", + "fflonk", + "rand 0.4.6", + "serde", + "serde_derive", + "serde_json", + "zksync-gpu-ffi", +] + [[package]] name = "fiat-crypto" version = "0.2.9" @@ -1940,9 +1975,9 @@ dependencies = [ [[package]] name = "franklin-crypto" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c128e2cf791053b3aefdd7b07d6e5ffdc7cf5dd779ca270d727a403057dfb68" +checksum = "82d7b8e5864df7f3747e5e64a5b87b4a57aa2a4a20c55c9e96a3a305a8143c45" dependencies = [ "arr_macro", "bit-vec 0.6.3", @@ -4513,6 +4548,22 @@ dependencies = [ "syn 2.0.90", ] +[[package]] +name = "proof-compression" +version = "0.152.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40624617ed1535349cf31671a7091703d3a31e64d6a7760a5e952c68ee1f4f0e" +dependencies = [ + "bincode", + "byteorder", + "cfg-if", + "circuit_definitions", + "fflonk-cuda", + "serde", + "serde_json", + "shivini", +] + [[package]] name = "proptest" version = "1.6.0" @@ -5019,9 +5070,9 @@ dependencies = [ [[package]] name = "rescue_poseidon" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62e4ce7543582ab2df1d9544674a55897e168a23afe938a57e1547d2981a7f4" +checksum = "c250446885c257bee70bc0f2600229ce72f03073b87fb8f5dd278dba16b11f30" dependencies = [ "addchain", "arrayvec 0.7.6", @@ -5809,9 +5860,9 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "shivini" -version = "0.152.9" +version = "0.152.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2673af97e7ea5aef8d1d2ad395e3833a2a9fd8aca6361c2516c44734c0ed92e2" +checksum = "8c336213e4ec7651d2984e892326d09c195ee166493c192b0d8aad36288e5c5f" dependencies = [ "bincode", "boojum", @@ -5900,9 +5951,9 @@ dependencies = [ [[package]] name = "snark_wrapper" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74645922ea9e18fbd4b6ae9c58e6a7080403edd81e558b610cf5b9dc60a90351" +checksum = "8f361c2c47b71ee43f62954ce69f7730e14acb7fb3b0f2c697da02f97327c569" dependencies = [ "derivative", "rand 0.4.6", @@ -7788,9 +7839,9 @@ dependencies = [ [[package]] name = "zk_evm" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3278d0f75408ab35d25998e1124124cd108b48b2a81ed8e71e892ddc5a6be0aa" +checksum = "84ee848aa90ae045457795b1c0afeb388fbd9fa1e57aa0e8791b28f405e7cc2c" dependencies = [ "anyhow", "lazy_static", @@ -7798,7 +7849,7 @@ dependencies = [ "serde", "serde_json", "static_assertions", - "zk_evm_abstractions 0.150.18", + "zk_evm_abstractions 0.150.19", ] [[package]] @@ -7829,22 +7880,22 @@ dependencies = [ [[package]] name = "zk_evm_abstractions" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b4e5a89cfe1594b6476be16c8c1d45f22ce12bff31c49e077b381a398edd8a" +checksum = "8f08feaa3e3d99e1e57234fe6ba2aa062609492c6499b2344121c4a699292ab7" dependencies = [ "anyhow", "num_enum 0.6.1", "serde", "static_assertions", - "zkevm_opcode_defs 0.150.18", + "zkevm_opcode_defs 0.150.19", ] [[package]] name = "zkevm-assembly" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4fdb2b380c43157160ec5f3f4f6912c6c9923e2a00886e79b7f5464f59108a7" +checksum = "ecd4bc83f3a711d820829dccce24fa59ab4c588c2745203ec6a6ad8c871362b7" dependencies = [ "env_logger 0.9.3", "hex", @@ -7857,14 +7908,14 @@ dependencies = [ "smallvec", "structopt", "thiserror 1.0.69", - "zkevm_opcode_defs 0.150.18", + "zkevm_opcode_defs 0.150.19", ] [[package]] name = "zkevm_circuits" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b94288d2e246aecd6eecd22ef27db0d1f29a91cb4f59b9e339a45237131a9ff" +checksum = "760cfbbce18f42bbecd2565de9bf658234cac2431cce9b0c1df08e9df645d467" dependencies = [ "arrayvec 0.7.6", "boojum", @@ -7876,7 +7927,7 @@ dependencies = [ "seq-macro", "serde", "smallvec", - "zkevm_opcode_defs 0.150.18", + "zkevm_opcode_defs 0.150.19", "zksync_cs_derive", ] @@ -7924,9 +7975,9 @@ dependencies = [ [[package]] name = "zkevm_opcode_defs" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bad437d4891536fdcc0054a3f04562c408817ff19d83b6c27569217692e6e74" +checksum = "4f2bd8ef52c8f9911dd034b91d29f087ab52f80a80f9d996deb881abbb953793" dependencies = [ "bitflags 2.6.0", "blake2 0.10.6", @@ -7941,9 +7992,9 @@ dependencies = [ [[package]] name = "zkevm_test_harness" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd2de75d0bf68137ba150e05dd5d36baad03e682e06b8616643c72b3fcce05d" +checksum = "e24b28c5b855e4e28d85455b48f346e9d46a00c6af84d5bbc38e5b5f7410b5cb" dependencies = [ "bincode", "circuit_definitions", @@ -7969,9 +8020,9 @@ dependencies = [ [[package]] name = "zksync-gpu-ffi" -version = "0.152.9" +version = "0.152.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc1f77eb5f1a513357e53fba148f46a03fdbea222dc71f270123984059c285bf" +checksum = "36f6a84e4e361977a2dc5dbe783e3856e40b1050dc1b9bb3e9833a5e59c20697" dependencies = [ "cmake", "crossbeam", @@ -7984,9 +8035,9 @@ dependencies = [ [[package]] name = "zksync-gpu-prover" -version = "0.152.9" +version = "0.152.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cc0c452445a120c5928e0ac89d47242f407b303ee819e3b7b2a97f6ce7491e4" +checksum = "2ba58bbaf4920c635553d3dfb7796636223f55e75ae6512eb9c98f48f0a03215" dependencies = [ "bit-vec 0.6.3", "cfg-if", @@ -8001,9 +8052,9 @@ dependencies = [ [[package]] name = "zksync-wrapper-prover" -version = "0.152.9" +version = "0.152.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972dc1059d4a97ad075ab5a3589722b16d22c5241ba6e711ac18a73195aa6584" +checksum = "c4bcf41946f95a1e64ce99cde1d54966a04c5ef2c89d9a87f0fa61e39987510b" dependencies = [ "circuit_definitions", "zkevm_test_harness", @@ -8033,9 +8084,9 @@ dependencies = [ [[package]] name = "zksync_bellman" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b7c0061db44757522f2d82cad02f45dc98267210ac362071234ed08e30fd4d6" +checksum = "d06d424f7e3862d7a6715179bafffbe7a5dce17129f95ac4124502ab9f1edfb8" dependencies = [ "arrayvec 0.7.6", "bit-vec 0.6.3", @@ -8259,9 +8310,9 @@ dependencies = [ [[package]] name = "zksync_cs_derive" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63296ce43c432d5d0111604173e874b2f2a856e1cb1c76378fa0bb5ac6018c27" +checksum = "23237b019a469bfa59c11108beff84a63a43f52fa3afbf1b461527031fc47644" dependencies = [ "proc-macro-error", "proc-macro2 1.0.92", @@ -8361,9 +8412,9 @@ dependencies = [ [[package]] name = "zksync_ff" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6a500c97d9286f73540c26b63ae33b159bd48fec0c8bd206b4a9b4fe1217b8a" +checksum = "4d5aa518ed0ea7ef737d50de02025f5a593dbb11104b3c1bf5a00f39581b47dc" dependencies = [ "byteorder", "hex", @@ -8374,9 +8425,9 @@ dependencies = [ [[package]] name = "zksync_ff_derive" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97bd48f18ebf350623093022d86be2f1ce23af332efa91890b751209aec8617a" +checksum = "e33b43100a1278e2f64820368db8751c2441860ea74ab5749074cf8f864647af" dependencies = [ "num-bigint 0.4.6", "num-integer", @@ -8389,9 +8440,9 @@ dependencies = [ [[package]] name = "zksync_kzg" -version = "0.150.18" +version = "0.150.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6384d2475e4a7e6ed4e2a703724cac1d8972d9ec40c49fdd17bf37942a81a635" +checksum = "c9da880b8282a97d9dfd6ac9f0189d310c0602059a8de20aa66a883979d6adba" dependencies = [ "boojum", "derivative", @@ -8409,6 +8460,8 @@ name = "zksync_l1_contract_interface" version = "0.1.0" dependencies = [ "anyhow", + "circuit_definitions", + "fflonk", "hex", "once_cell", "sha2 0.10.8", @@ -8445,7 +8498,7 @@ dependencies = [ "zk_evm 0.133.0", "zk_evm 0.140.0", "zk_evm 0.141.0", - "zk_evm 0.150.18", + "zk_evm 0.150.19", "zksync_contracts", "zksync_mini_merkle_tree", "zksync_system_constants", @@ -8479,9 +8532,9 @@ dependencies = [ [[package]] name = "zksync_pairing" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b91b38db3a3f0f80d8b1f2342c77751ee8d63b746268e5719abbb5dfb150a8c" +checksum = "43f0d96f3e386f3b4c76a614d73b71714d6712e917d462bf8053b8af352da0b3" dependencies = [ "byteorder", "cfg-if", @@ -8500,7 +8553,10 @@ dependencies = [ "circuit_sequencer_api", "clap 4.5.23", "ctrlc", + "fflonk-cuda", + "franklin-crypto", "futures 0.3.31", + "proof-compression", "reqwest 0.12.9", "serde", "serde_json", @@ -8722,7 +8778,9 @@ name = "zksync_prover_interface" version = "0.1.0" dependencies = [ "chrono", + "circuit_definitions", "circuit_sequencer_api", + "fflonk", "serde", "serde_with", "strum", @@ -8775,7 +8833,9 @@ dependencies = [ "anyhow", "bincode", "boojum-cuda", + "byteorder", "circuit_definitions", + "fflonk-cuda", "futures 0.3.31", "hex", "md5", @@ -8806,9 +8866,9 @@ dependencies = [ [[package]] name = "zksync_solidity_vk_codegen" -version = "0.30.11" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f03e137db1b29be36abfa1e1e682dd3864b0335c68282c8dab68c2d397b8cbd" +checksum = "eb10f377dcc24fe2268cc5f530c16af1c879a791570d8fe64064b58ba143c7cc" dependencies = [ "ethereum-types", "franklin-crypto", @@ -8880,10 +8940,14 @@ name = "zksync_vk_setup_data_generator_server_fri" version = "0.1.0" dependencies = [ "anyhow", + "bincode", "circuit_definitions", "clap 4.5.23", "indicatif", + "proof-compression", "proptest", + "serde_json", + "shivini", "toml_edit 0.14.4", "tracing", "tracing-subscriber", @@ -8927,8 +8991,8 @@ source = "git+https://github.com/matter-labs/vm2.git?rev=457d8a7eea9093af9440662 dependencies = [ "enum_dispatch", "primitive-types", - "zk_evm_abstractions 0.150.18", - "zkevm_opcode_defs 0.150.18", + "zk_evm_abstractions 0.150.19", + "zkevm_opcode_defs 0.150.19", "zksync_vm2_interface", ] diff --git a/prover/Cargo.toml b/prover/Cargo.toml index aea458cb9e48..71749416b839 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -19,6 +19,7 @@ anyhow = "1.0" async-trait = "0.1" axum = "0.7.5" bincode = "1" +byteorder = "1.5.0" chrono = "0.4.38" clap = "4.4.6" colored = "2.0" @@ -67,14 +68,17 @@ url = "2.5.2" vise = "0.2.0" # Proving dependencies -circuit_definitions = "=0.150.18" -circuit_sequencer_api = "=0.150.18" -zkevm_test_harness = "=0.150.18" +circuit_definitions = { package = "circuit_definitions", version = "=0.150.19" } +circuit_sequencer_api = { package = "circuit_sequencer_api", version = "=0.150.19" } +zkevm_test_harness = { package = "zkevm_test_harness", version = "=0.150.19" } +proof-compression-gpu = { package = "proof-compression", version = "=0.152.10"} +fflonk-gpu = { package = "fflonk-cuda", version = "=0.152.10"} +franklin-crypto = { package = "franklin-crypto", version = "0.30.12" } # GPU proving dependencies -wrapper_prover = { package = "zksync-wrapper-prover", version = "=0.152.9" } -shivini = "=0.152.9" -boojum-cuda = "=0.152.9" +wrapper_prover = { package = "zksync-wrapper-prover", version = "=0.152.10"} +shivini = { package = "shivini", version = "=0.152.10" } +boojum-cuda = { package = "boojum-cuda", version = "=0.152.10" } # Core workspace dependencies zksync_multivm = { path = "../core/lib/multivm", version = "0.1.0" } diff --git a/prover/crates/bin/circuit_prover/Cargo.toml b/prover/crates/bin/circuit_prover/Cargo.toml index 8fecc7a7a6a1..d1b87f0ce075 100644 --- a/prover/crates/bin/circuit_prover/Cargo.toml +++ b/prover/crates/bin/circuit_prover/Cargo.toml @@ -20,14 +20,14 @@ tracing.workspace = true bincode.workspace = true clap = { workspace = true, features = ["derive"] } -zksync_config.workspace = true +zksync_config = {workspace = true, features = ["observability_ext"]} zksync_object_store.workspace = true zksync_prover_dal.workspace = true zksync_prover_fri_types.workspace = true zksync_prover_fri_utils.workspace = true zksync_queued_job_processor.workspace = true zksync_types.workspace = true -zksync_prover_keystore = { workspace = true, features = ["gpu"] } +zksync_prover_keystore = { workspace = true, features = ["gpu-light"] } zksync_env_config.workspace = true zksync_core_leftovers.workspace = true zksync_utils.workspace = true diff --git a/prover/crates/bin/proof_fri_compressor/Cargo.toml b/prover/crates/bin/proof_fri_compressor/Cargo.toml index 936f0cb5100b..008a9a73addc 100644 --- a/prover/crates/bin/proof_fri_compressor/Cargo.toml +++ b/prover/crates/bin/proof_fri_compressor/Cargo.toml @@ -21,12 +21,18 @@ zksync_utils.workspace = true zksync_core_leftovers.workspace = true zksync_prover_fri_types.workspace = true zksync_queued_job_processor.workspace = true -zksync_prover_keystore.workspace = true +zksync_prover_keystore = { workspace = true, features = ["gpu"] } zksync_vlog.workspace = true circuit_sequencer_api.workspace = true zkevm_test_harness.workspace = true +proof-compression-gpu.workspace = true +fflonk-gpu.workspace = true +franklin-crypto.workspace = true + +wrapper_prover.workspace = true + anyhow.workspace = true tracing.workspace = true structopt.workspace = true @@ -39,9 +45,3 @@ bincode.workspace = true reqwest = { workspace = true, features = ["blocking"] } serde_json.workspace = true serde = { workspace = true, features = ["derive"] } -wrapper_prover = { workspace = true, optional = true } - -[features] -default = [] -gpu = ["wrapper_prover"] - diff --git a/prover/crates/bin/proof_fri_compressor/src/compressor.rs b/prover/crates/bin/proof_fri_compressor/src/compressor.rs index e462097e38d0..3671fa183b5d 100644 --- a/prover/crates/bin/proof_fri_compressor/src/compressor.rs +++ b/prover/crates/bin/proof_fri_compressor/src/compressor.rs @@ -3,26 +3,33 @@ use std::{sync::Arc, time::Instant}; use anyhow::Context as _; use async_trait::async_trait; use circuit_sequencer_api::proof::FinalProof; +use fflonk_gpu::{FflonkSnarkVerifierCircuit, FflonkSnarkVerifierCircuitProof}; use tokio::task::JoinHandle; -#[cfg(feature = "gpu")] -use wrapper_prover::{Bn256, GPUWrapperConfigs, WrapperProver, 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}; +use wrapper_prover::{GPUWrapperConfigs, WrapperProver}; +use zkevm_test_harness::proof_wrapper_utils::{get_trusted_setup, DEFAULT_WRAPPER_CONFIG}; use zksync_object_store::ObjectStore; use zksync_prover_dal::{ConnectionPool, Prover, ProverDal}; use zksync_prover_fri_types::{ circuit_definitions::{ boojum::field::goldilocks::GoldilocksField, - circuit_definitions::recursion_layer::{ - ZkSyncRecursionLayerProof, ZkSyncRecursionLayerStorageType, + circuit_definitions::{ + aux_layer::{ + wrapper::ZkSyncCompressionWrapper, ZkSyncCompressionForWrapperCircuit, + ZkSyncCompressionLayerCircuit, ZkSyncCompressionProof, + ZkSyncCompressionProofForWrapper, ZkSyncCompressionVerificationKeyForWrapper, + }, + recursion_layer::{ + ZkSyncRecursionLayerProof, ZkSyncRecursionLayerStorageType, + ZkSyncRecursionVerificationKey, + }, }, zkevm_circuits::scheduler::block_header::BlockAuxilaryOutputWitness, }, get_current_pod_name, AuxOutputWitnessWrapper, FriProofWrapper, }; -use zksync_prover_interface::outputs::L1BatchProofForL1; +use zksync_prover_interface::outputs::{ + FflonkL1BatchProofForL1, L1BatchProofForL1, PlonkL1BatchProofForL1, +}; use zksync_prover_keystore::keystore::Keystore; use zksync_queued_job_processor::JobProcessor; use zksync_types::{protocol_version::ProtocolSemanticVersion, L1BatchNumber}; @@ -36,6 +43,12 @@ pub struct ProofCompressor { max_attempts: u32, protocol_version: ProtocolSemanticVersion, keystore: Keystore, + is_fflonk: bool, +} + +pub enum Proof { + Plonk(Box), + Fflonk(FflonkSnarkVerifierCircuitProof), } impl ProofCompressor { @@ -46,6 +59,7 @@ impl ProofCompressor { max_attempts: u32, protocol_version: ProtocolSemanticVersion, keystore: Keystore, + is_fflonk: bool, ) -> Self { Self { blob_store, @@ -54,11 +68,26 @@ impl ProofCompressor { max_attempts, protocol_version, keystore, + is_fflonk, + } + } + + fn aux_output_witness_to_array( + aux_output_witness: BlockAuxilaryOutputWitness, + ) -> [[u8; 32]; 4] { + let mut array: [[u8; 32]; 4] = [[0; 32]; 4]; + + for i in 0..32 { + array[0][i] = aux_output_witness.l1_messages_linear_hash[i]; + array[1][i] = aux_output_witness.rollup_state_diff_for_compression[i]; + array[2][i] = aux_output_witness.bootloader_heap_initial_content[i]; + array[3][i] = aux_output_witness.events_queue_state[i]; } + array } #[tracing::instrument(skip(proof, _compression_mode))] - pub fn compress_proof( + pub fn generate_plonk_proof( proof: ZkSyncRecursionLayerProof, _compression_mode: u8, keystore: Keystore, @@ -69,7 +98,6 @@ 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; @@ -82,13 +110,6 @@ impl ProofCompressor { prover.get_wrapper_proof().unwrap() }; - #[cfg(not(feature = "gpu"))] - 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) @@ -101,18 +122,113 @@ impl ProofCompressor { Ok(final_proof) } - fn aux_output_witness_to_array( - aux_output_witness: BlockAuxilaryOutputWitness, - ) -> [[u8; 32]; 4] { - let mut array: [[u8; 32]; 4] = [[0; 32]; 4]; + #[tracing::instrument(skip(proof, compression_mode, keystore))] + pub fn generate_fflonk_proof( + proof: ZkSyncRecursionLayerProof, + compression_mode: u8, + keystore: Keystore, + ) -> anyhow::Result { + let scheduler_vk = keystore + .load_recursive_layer_verification_key( + ZkSyncRecursionLayerStorageType::SchedulerCircuit as u8, + ) + .context("get_recursiver_layer_vk_for_circuit_type()")?; - for i in 0..32 { - array[0][i] = aux_output_witness.l1_messages_linear_hash[i]; - array[1][i] = aux_output_witness.rollup_state_diff_for_compression[i]; - array[2][i] = aux_output_witness.bootloader_heap_initial_content[i]; - array[3][i] = aux_output_witness.events_queue_state[i]; + // compress proof step by step: 1 -> 2 -> 3 -> 4 -> 5(wrapper) + let (compression_wrapper_proof, compression_wrapper_vk) = Self::compress_proof( + &keystore, + proof.into_inner(), + scheduler_vk.into_inner(), + compression_mode, + )?; + + // construct fflonk snark verifier circuit + let wrapper_function = + ZkSyncCompressionWrapper::from_numeric_circuit_type(compression_mode); + let fixed_parameters = compression_wrapper_vk.fixed_parameters.clone(); + let circuit = FflonkSnarkVerifierCircuit { + witness: Some(compression_wrapper_proof), + vk: compression_wrapper_vk, + fixed_parameters, + transcript_params: (), + wrapper_function, + }; + + tracing::info!("Proving FFLONK snark verifier"); + + let setup = keystore.load_fflonk_snark_verifier_setup_data()?; + + tracing::info!("Loaded setup data for FFLONK verification"); + + let proof = fflonk_gpu::gpu_prove_fflonk_snark_verifier_circuit_with_precomputation( + &circuit, + &setup, + &setup.get_verification_key(), + ); + tracing::info!("Finished proof generation"); + Ok(proof) + } + + pub fn compress_proof( + keystore: &Keystore, + proof: ZkSyncCompressionProof, + vk: ZkSyncRecursionVerificationKey, + compression_steps: u8, + ) -> anyhow::Result<( + ZkSyncCompressionProofForWrapper, + ZkSyncCompressionVerificationKeyForWrapper, + )> { + let worker = franklin_crypto::boojum::worker::Worker::new(); + let mut compression_circuit = + ZkSyncCompressionLayerCircuit::from_witness_and_vk(Some(proof), vk.clone(), 1); + let mut compression_wrapper_circuit = None; + + for step_idx in 1..compression_steps { + tracing::info!("Proving compression {:?}", step_idx); + let setup_data = keystore.load_compression_setup_data(step_idx)?; + let (proof, vk) = + proof_compression_gpu::prove_compression_layer_circuit_with_precomputations( + compression_circuit.clone(), + &setup_data.setup, + setup_data.finalization_hint, + setup_data.vk, + &worker, + ); + tracing::info!("Proof for compression {:?} is generated!", step_idx); + + if step_idx + 1 == compression_steps { + compression_wrapper_circuit = + Some(ZkSyncCompressionForWrapperCircuit::from_witness_and_vk( + Some(proof), + vk, + compression_steps, + )); + } else { + compression_circuit = ZkSyncCompressionLayerCircuit::from_witness_and_vk( + Some(proof), + vk, + step_idx + 1, + ); + } } - array + + // last wrapping step + tracing::info!("Proving compression {} for wrapper", compression_steps); + + let setup_data = keystore.load_compression_wrapper_setup_data(compression_steps)?; + let (proof, vk) = + proof_compression_gpu::prove_compression_wrapper_circuit_with_precomputations( + compression_wrapper_circuit.unwrap(), + &setup_data.setup, + setup_data.finalization_hint, + setup_data.vk, + &worker, + ); + tracing::info!( + "Proof for compression wrapper {} is generated!", + compression_steps + ); + Ok((proof, vk)) } } @@ -120,7 +236,9 @@ impl ProofCompressor { impl JobProcessor for ProofCompressor { type Job = ZkSyncRecursionLayerProof; type JobId = L1BatchNumber; - type JobArtifacts = FinalProof; + + type JobArtifacts = Proof; + const SERVICE_NAME: &'static str = "ProofCompressor"; async fn get_next_job(&self) -> anyhow::Result> { @@ -176,14 +294,29 @@ impl JobProcessor for ProofCompressor { ) -> JoinHandle> { let compression_mode = self.compression_mode; let keystore = self.keystore.clone(); - tokio::task::spawn_blocking(move || Self::compress_proof(job, compression_mode, keystore)) + let is_fflonk = self.is_fflonk; + tokio::task::spawn_blocking(move || { + if !is_fflonk { + Ok(Proof::Plonk(Box::new(Self::generate_plonk_proof( + job, + compression_mode, + keystore, + )?))) + } else { + Ok(Proof::Fflonk(Self::generate_fflonk_proof( + job, + compression_mode, + keystore, + )?)) + } + }) } async fn save_result( &self, job_id: Self::JobId, started_at: Instant, - artifacts: FinalProof, + artifacts: Self::JobArtifacts, ) -> anyhow::Result<()> { METRICS.compression_time.observe(started_at.elapsed()); tracing::info!( @@ -198,11 +331,20 @@ impl JobProcessor for ProofCompressor { .context("Failed to get aggregation result coords from blob store")?; let aggregation_result_coords = Self::aux_output_witness_to_array(aux_output_witness_wrapper.0); - let l1_batch_proof = L1BatchProofForL1 { - aggregation_result_coords, - scheduler_proof: artifacts, - protocol_version: self.protocol_version, + + let l1_batch_proof = match artifacts { + Proof::Plonk(proof) => L1BatchProofForL1::Plonk(PlonkL1BatchProofForL1 { + aggregation_result_coords, + scheduler_proof: *proof, + protocol_version: self.protocol_version, + }), + Proof::Fflonk(proof) => L1BatchProofForL1::Fflonk(FflonkL1BatchProofForL1 { + aggregation_result_coords, + scheduler_proof: proof, + protocol_version: self.protocol_version, + }), }; + let blob_save_started_at = Instant::now(); let blob_url = self .blob_store diff --git a/prover/crates/bin/proof_fri_compressor/src/initial_setup_keys.rs b/prover/crates/bin/proof_fri_compressor/src/initial_setup_keys.rs index 172c6054b7db..f7dc2faba388 100644 --- a/prover/crates/bin/proof_fri_compressor/src/initial_setup_keys.rs +++ b/prover/crates/bin/proof_fri_compressor/src/initial_setup_keys.rs @@ -4,7 +4,7 @@ use std::{fs::create_dir_all, io::Cursor, path::Path, time::Duration}; fn download_initial_setup(key_download_url: &str) -> reqwest::Result> { tracing::info!("Downloading initial setup from {:?}", key_download_url); - const DOWNLOAD_TIMEOUT: Duration = Duration::from_secs(120); + const DOWNLOAD_TIMEOUT: Duration = Duration::from_secs(600); let client = reqwest::blocking::Client::builder() .timeout(DOWNLOAD_TIMEOUT) .build() @@ -20,7 +20,10 @@ fn download_initial_setup(key_download_url: &str) -> reqwest::Result> { .and_then(|response| response.bytes().map(|bytes| bytes.to_vec())); match bytes { Ok(bytes) => return Ok(bytes), - Err(_) => retry_count += 1, + Err(e) => { + tracing::warn!("Failed to download keys: {}", e); + retry_count += 1 + } } tracing::warn!("Failed to download keys. Backing off for 5 second"); diff --git a/prover/crates/bin/proof_fri_compressor/src/main.rs b/prover/crates/bin/proof_fri_compressor/src/main.rs index f06b4b8f89e5..bbdf7fbae6f3 100644 --- a/prover/crates/bin/proof_fri_compressor/src/main.rs +++ b/prover/crates/bin/proof_fri_compressor/src/main.rs @@ -6,10 +6,11 @@ use std::{env, time::Duration}; use anyhow::Context as _; use clap::Parser; use tokio::sync::{oneshot, watch}; +use zksync_config::configs::FriProofCompressorConfig; use zksync_core_leftovers::temp_config_store::{load_database_secrets, load_general_config}; use zksync_env_config::object_store::ProverObjectStoreConfig; use zksync_object_store::ObjectStoreFactory; -use zksync_prover_dal::{ConnectionPool, Prover}; +use zksync_prover_dal::{ConnectionPool, Prover, ProverDal}; use zksync_prover_fri_types::PROVER_PROTOCOL_SEMANTIC_VERSION; use zksync_prover_keystore::keystore::Keystore; use zksync_queued_job_processor::JobProcessor; @@ -24,6 +25,10 @@ mod compressor; mod initial_setup_keys; mod metrics; +pub const PLONK_CRS_KEY: &str = "setup_2^24.key"; +pub const FFLONK_CRS_KEY: &str = "setup_fflonk.key"; +pub const FFLONK_COMPACT_CRS_KEY: &str = "setup_fflonk_compact.key"; + #[derive(Debug, Parser)] #[command(author = "Matter Labs", version)] struct Cli { @@ -32,6 +37,8 @@ struct Cli { #[arg(short)] number_of_iterations: Option, #[arg(long)] + pub(crate) fflonk: Option, + #[arg(long)] pub(crate) config_path: Option, #[arg(long)] pub(crate) secrets_path: Option, @@ -41,6 +48,8 @@ struct Cli { async fn main() -> anyhow::Result<()> { let opt = Cli::parse(); + let is_fflonk = opt.fflonk.unwrap_or(false); + let general_config = load_general_config(opt.config_path).context("general config")?; let database_secrets = load_database_secrets(opt.secrets_path).context("database secrets")?; @@ -76,6 +85,18 @@ async fn main() -> anyhow::Result<()> { .expect("ProverConfig doesn't exist"); let keystore = Keystore::locate().with_setup_path(Some(prover_config.setup_data_path.clone().into())); + + let l1_verifier_config = pool + .connection() + .await? + .fri_protocol_versions_dal() + .get_l1_verifier_config() + .await + .map_err(|_| anyhow::anyhow!("Failed to get L1 verifier config from database"))?; + if l1_verifier_config.fflonk_snark_wrapper_vk_hash.is_none() && is_fflonk { + anyhow::bail!("There was no FFLONK verification hash found in the database while trying to run compressor in FFLONK mode, aborting"); + } + let proof_compressor = ProofCompressor::new( blob_store, pool, @@ -83,6 +104,7 @@ async fn main() -> anyhow::Result<()> { config.max_attempts, protocol_version, keystore, + is_fflonk, ); let (stop_sender, stop_receiver) = watch::channel(false); @@ -96,11 +118,7 @@ async fn main() -> anyhow::Result<()> { }) .expect("Error setting Ctrl+C handler"); // Setting handler should always succeed. - download_initial_setup_keys_if_not_present( - &config.universal_setup_path, - &config.universal_setup_download_url, - ); - env::set_var("CRS_FILE", config.universal_setup_path.clone()); + setup_crs_keys(&config, is_fflonk); tracing::info!("Starting proof compressor"); @@ -124,3 +142,46 @@ async fn main() -> anyhow::Result<()> { tasks.complete(Duration::from_secs(5)).await; Ok(()) } + +fn setup_crs_keys(config: &FriProofCompressorConfig, is_fflonk: bool) { + if is_fflonk { + let crs_path = format!("{}{}", config.universal_setup_path.clone(), FFLONK_CRS_KEY); + + let crs_download_url = format!( + "{}{}", + config.universal_setup_download_url.clone(), + FFLONK_CRS_KEY + ); + download_initial_setup_keys_if_not_present(&crs_path, &crs_download_url); + + download_initial_setup_keys_if_not_present( + &format!("{}{}", config.universal_setup_path, FFLONK_COMPACT_CRS_KEY), + &format!( + "{}{}", + config.universal_setup_download_url, FFLONK_COMPACT_CRS_KEY + ), + ); + + env::set_var( + "COMPACT_CRS_FILE", + format!( + "{}{}", + config.universal_setup_path.clone(), + FFLONK_COMPACT_CRS_KEY + ), + ); + + env::set_var("CRS_FILE", crs_path); + } else { + let crs_path = format!("{}{}", config.universal_setup_path.clone(), PLONK_CRS_KEY); + + let crs_download_url = format!( + "{}{}", + config.universal_setup_download_url.clone(), + PLONK_CRS_KEY + ); + + download_initial_setup_keys_if_not_present(&crs_path, &crs_download_url); + env::set_var("CRS_FILE", crs_path); + } +} diff --git a/prover/crates/bin/prover_cli/src/commands/get_file_info.rs b/prover/crates/bin/prover_cli/src/commands/get_file_info.rs index 271cf38c37a8..e5a0658bffcc 100644 --- a/prover/crates/bin/prover_cli/src/commands/get_file_info.rs +++ b/prover/crates/bin/prover_cli/src/commands/get_file_info.rs @@ -171,24 +171,32 @@ fn pretty_print_proof(result: &FriProofWrapper) { fn pretty_print_l1_proof(result: &L1BatchProofForL1) { println!("{}", "== Snark wrapped L1 proof ==".to_string().bold()); println!("AUX info:"); + + let aggregation_result_coords = result.aggregation_result_coords(); + println!( " L1 msg linear hash: 0x{}", - hex::encode(result.aggregation_result_coords[0]) + hex::encode(aggregation_result_coords[0]) ); println!( " Rollup_state_diff_for_compression: 0x{}", - hex::encode(result.aggregation_result_coords[1]) + hex::encode(aggregation_result_coords[1]) ); println!( " bootloader_heap_initial_content: 0x{}", - hex::encode(result.aggregation_result_coords[2]) + hex::encode(aggregation_result_coords[2]) ); println!( " events_queue_state: 0x{}", - hex::encode(result.aggregation_result_coords[3]) + hex::encode(aggregation_result_coords[3]) ); - println!("Inputs: {:?}", result.scheduler_proof.inputs); + let inputs = match result { + L1BatchProofForL1::Fflonk(proof) => &proof.scheduler_proof.inputs, + L1BatchProofForL1::Plonk(proof) => &proof.scheduler_proof.inputs, + }; + + println!("Inputs: {:?}", inputs); println!(" This proof will pass on L1, if L1 executor computes the block commitment that is matching exactly the Inputs value above"); } diff --git a/prover/crates/bin/prover_cli/src/commands/insert_version.rs b/prover/crates/bin/prover_cli/src/commands/insert_version.rs index e89d2024e26f..a9f6323c978b 100644 --- a/prover/crates/bin/prover_cli/src/commands/insert_version.rs +++ b/prover/crates/bin/prover_cli/src/commands/insert_version.rs @@ -21,6 +21,8 @@ pub struct Args { pub patch: u32, #[clap(short, long)] pub snark_wrapper: String, + #[clap(short, long)] + pub fflonk_snark_wrapper: String, } pub async fn run(args: Args, config: ProverCLIConfig) -> anyhow::Result<()> { @@ -39,11 +41,17 @@ pub async fn run(args: Args, config: ProverCLIConfig) -> anyhow::Result<()> { panic!("Invalid snark wrapper hash"); }); + let fflonk_snark_wrapper_vk_hash = + H256::from_str(&args.fflonk_snark_wrapper).unwrap_or_else(|_| { + panic!("Invalid FFLONK snark wrapper hash"); + }); + conn.fri_protocol_versions_dal() .save_prover_protocol_version( ProtocolSemanticVersion::new(protocol_version, protocol_version_patch), L1VerifierConfig { snark_wrapper_vk_hash, + fflonk_snark_wrapper_vk_hash: Some(fflonk_snark_wrapper_vk_hash), }, ) .await; diff --git a/prover/crates/bin/prover_cli/src/commands/status/l1.rs b/prover/crates/bin/prover_cli/src/commands/status/l1.rs index 4b403215e9c2..7eb7a25e78be 100644 --- a/prover/crates/bin/prover_cli/src/commands/status/l1.rs +++ b/prover/crates/bin/prover_cli/src/commands/status/l1.rs @@ -8,12 +8,14 @@ use zksync_dal::{ConnectionPool, Core, CoreDal}; use zksync_env_config::FromEnv; use zksync_eth_client::{ clients::{Client, L1}, - CallFunctionArgs, + CallFunctionArgs, ContractCallError, }; use zksync_prover_dal::{Prover, ProverDal}; use crate::helper; +const FFLONK_VERIFIER_TYPE: i32 = 0; + pub(crate) async fn run() -> anyhow::Result<()> { println!(" ====== L1 Status ====== "); let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env")?; @@ -77,8 +79,27 @@ pub(crate) async fn run() -> anyhow::Result<()> { .call(&query_client) .await?; + // We are getting function separately to get the second function with the same name, but + // overriden one + let contract = helper::verifier_contract(); + let function = contract + .functions_by_name("verificationKeyHash") + .map_err(ContractCallError::Function)? + .get(1); + + let fflonk_verification_key_hash: Option = if let Some(function) = function { + CallFunctionArgs::new("verificationKeyHash", U256::from(FFLONK_VERIFIER_TYPE)) + .for_contract(contracts_config.verifier_addr, &helper::verifier_contract()) + .call_with_function(&query_client, function.clone()) + .await + .ok() + } else { + None + }; + let node_l1_verifier_config = L1VerifierConfig { snark_wrapper_vk_hash: node_verification_key_hash, + fflonk_snark_wrapper_vk_hash: fflonk_verification_key_hash, }; let prover_connection_pool = ConnectionPool::::builder( @@ -124,7 +145,7 @@ fn pretty_print_l1_status( let eth_sender_lag = U256::from(last_state_keeper_l1_batch.0) - total_batches_committed; if eth_sender_lag > U256::zero() { println!( - "Eth sender is {} behind. Last block committed: {}. Most recent sealed state keeper batch: {}.", + "Eth sender is {} behind. Last block committed: {}. Most recent sealed state keeper batch: {}.", eth_sender_lag, total_batches_committed, last_state_keeper_l1_batch diff --git a/prover/crates/bin/prover_fri/Cargo.toml b/prover/crates/bin/prover_fri/Cargo.toml index e41244cecbf7..f9938ad45ba3 100644 --- a/prover/crates/bin/prover_fri/Cargo.toml +++ b/prover/crates/bin/prover_fri/Cargo.toml @@ -48,4 +48,4 @@ tracing-subscriber.workspace = true [features] default = [] -gpu = ["shivini", "zksync_prover_keystore/gpu"] +gpu = ["shivini", "zksync_prover_keystore/gpu-light"] diff --git a/prover/crates/bin/prover_fri/src/utils.rs b/prover/crates/bin/prover_fri/src/utils.rs index 86e6568f8e40..e4328dde8ddb 100644 --- a/prover/crates/bin/prover_fri/src/utils.rs +++ b/prover/crates/bin/prover_fri/src/utils.rs @@ -20,7 +20,7 @@ use zksync_prover_fri_types::{ }, }, queue::FixedSizeQueue, - CircuitWrapper, FriProofWrapper, ProverServiceDataKey, WitnessVectorArtifacts, + CircuitWrapper, FriProofWrapper, ProverServiceDataKey, ProvingStage, WitnessVectorArtifacts, }; use zksync_types::{ basic_fri_types::{AggregationRound, CircuitIdRoundTuple}, @@ -149,23 +149,23 @@ pub fn setup_metadata_to_setup_data_key( // For node aggregation only one key exist for all circuit types ProverServiceDataKey { circuit_id: ZkSyncRecursionLayerStorageType::NodeLayerCircuit as u8, - round, + stage: round.into(), } } _ => ProverServiceDataKey { circuit_id: setup_metadata.circuit_id, - round, + stage: round.into(), }, } } pub fn get_setup_data_key(key: ProverServiceDataKey) -> ProverServiceDataKey { - match key.round { - AggregationRound::NodeAggregation => { + match key.stage { + ProvingStage::NodeAggregation => { // For node aggregation only one key exist for all circuit types ProverServiceDataKey { circuit_id: ZkSyncRecursionLayerStorageType::NodeLayerCircuit as u8, - round: key.round, + stage: key.stage, } } _ => key, @@ -180,11 +180,11 @@ mod tests { fn test_get_setup_data_key_for_node_agg_key() { let key = ProverServiceDataKey { circuit_id: 10, - round: AggregationRound::NodeAggregation, + stage: ProvingStage::NodeAggregation, }; let expected = ProverServiceDataKey { circuit_id: ZkSyncRecursionLayerStorageType::NodeLayerCircuit as u8, - round: AggregationRound::NodeAggregation, + stage: ProvingStage::NodeAggregation, }; let result = get_setup_data_key(key); @@ -197,7 +197,7 @@ mod tests { fn test_get_setup_data_key_for_non_node_agg_key() { let key = ProverServiceDataKey { circuit_id: 10, - round: AggregationRound::BasicCircuits, + stage: ProvingStage::BasicCircuits, }; let result = get_setup_data_key(key); diff --git a/prover/crates/bin/prover_fri/tests/basic_test.rs b/prover/crates/bin/prover_fri/tests/basic_test.rs index 1cf376bf8157..d469be112afb 100644 --- a/prover/crates/bin/prover_fri/tests/basic_test.rs +++ b/prover/crates/bin/prover_fri/tests/basic_test.rs @@ -64,7 +64,7 @@ async fn prover_and_assert_base_layer( ) .context("generate_cpu_base_layers_setup_data()")?; let setup_data = Arc::new(circuit_setup_data.into()); - let setup_key = ProverServiceDataKey::new(circuit_id, aggregation_round); + let setup_key = ProverServiceDataKey::new(circuit_id, aggregation_round.into()); let prover_job = ProverJob::new(block_number, expected_proof_id, circuit_wrapper, setup_key); let artifacts = Prover::prove( prover_job, diff --git a/prover/crates/bin/vk_setup_data_generator_server_fri/Cargo.toml b/prover/crates/bin/vk_setup_data_generator_server_fri/Cargo.toml index 4830f2277a79..f385c33dd6ad 100644 --- a/prover/crates/bin/vk_setup_data_generator_server_fri/Cargo.toml +++ b/prover/crates/bin/vk_setup_data_generator_server_fri/Cargo.toml @@ -23,6 +23,8 @@ zksync_prover_keystore.workspace = true zksync_utils.workspace = true zkevm_test_harness.workspace = true circuit_definitions = { workspace = true, features = ["log_tracing"] } +proof-compression-gpu = {workspace = true, optional = true} +shivini = { workspace = true, optional = true} anyhow.workspace = true clap = { workspace = true, features = ["derive"] } @@ -30,10 +32,12 @@ tracing.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter"] } toml_edit.workspace = true indicatif.workspace = true +bincode.workspace = true +serde_json.workspace = true [dev-dependencies] proptest.workspace = true [features] default = [] -gpu = ["zksync_prover_keystore/gpu"] +gpu = ["zksync_prover_keystore/gpu", "proof-compression-gpu", "shivini"] diff --git a/prover/crates/bin/vk_setup_data_generator_server_fri/src/main.rs b/prover/crates/bin/vk_setup_data_generator_server_fri/src/main.rs index 59d989037c4b..edd88846d1bc 100644 --- a/prover/crates/bin/vk_setup_data_generator_server_fri/src/main.rs +++ b/prover/crates/bin/vk_setup_data_generator_server_fri/src/main.rs @@ -1,3 +1,7 @@ +#![feature(allocator_api)] +#![allow(dead_code)] // todo: remove after setup is generated +#![allow(unused_imports)] // todo: remove after setup is generated + //! Tool to generate different types of keys used by the proving system. //! //! It can generate verification keys, setup keys, and also commitments. @@ -7,8 +11,11 @@ use anyhow::Context as _; use clap::{Parser, Subcommand}; use commitment_generator::read_and_update_contract_toml; use indicatif::{ProgressBar, ProgressStyle}; +#[cfg(feature = "gpu")] +use shivini::ProverContext; use tracing::level_filters::LevelFilter; use zkevm_test_harness::{ + boojum::worker::Worker, compute_setups::{ basic_vk_count, generate_base_layer_vks, generate_recursive_layer_vks, recursive_layer_vk_count, @@ -23,17 +30,25 @@ use zksync_prover_fri_types::{ circuit_definitions::circuit_definitions::recursion_layer::ZkSyncRecursionLayerStorageType, ProverServiceDataKey, }; +#[cfg(feature = "gpu")] +use zksync_prover_keystore::setup_data_generator::get_fflonk_snark_verifier_setup_and_vk; use zksync_prover_keystore::{ keystore::Keystore, setup_data_generator::{CPUSetupDataGenerator, GPUSetupDataGenerator, SetupDataGenerator}, }; +#[cfg(feature = "gpu")] +use crate::utils::{ + generate_compression_for_wrapper_vks, generate_compression_vks, + get_plonk_wrapper_setup_and_vk_from_scheduler_vk, +}; + mod commitment_generator; +mod utils; mod vk_commitment_helper; #[cfg(test)] mod tests; - /// Generates new verification keys, and stores them in `keystore`. /// Jobs describe how many generators can run in parallel (each one is around 30 GB). /// If quiet is true, it doesn't display any progress bar. @@ -46,7 +61,7 @@ fn generate_vks(keystore: &Keystore, jobs: usize, quiet: bool) -> anyhow::Result let progress_bar = if quiet { None } else { - let count = basic_vk_count() + recursive_layer_vk_count() + 1; + let count = basic_vk_count() + recursive_layer_vk_count() + 2; let progress_bar = ProgressBar::new(count as u64); progress_bar.set_style(ProgressStyle::default_bar() .template("{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {pos:>7}/{len:7} ({eta})") @@ -74,7 +89,23 @@ fn generate_vks(keystore: &Keystore, jobs: usize, quiet: bool) -> anyhow::Result }) .map_err(|err| anyhow::anyhow!("Failed generating recursive vk's: {err}"))?; - tracing::info!("Saving keys & hints"); + #[cfg(feature = "gpu")] + { + let config = WrapperConfig::new(5); + let worker = Worker::new(); + + tracing::info!("Creating prover context"); + + let _context = ProverContext::create().context("failed initializing gpu prover context")?; + tracing::info!("Generating verification keys for compression layers."); + generate_compression_vks(config, &mut in_memory_source, &worker); + + tracing::info!("Generating verification keys for compression for wrapper."); + + generate_compression_for_wrapper_vks(config, &mut in_memory_source, &worker); + + tracing::info!("Saving keys & hints"); + } keystore.save_keys_from_data_source(&in_memory_source)?; @@ -82,20 +113,39 @@ fn generate_vks(keystore: &Keystore, jobs: usize, quiet: bool) -> anyhow::Result let scheduler_vk = in_memory_source .get_recursion_layer_vk(ZkSyncRecursionLayerStorageType::SchedulerCircuit as u8) .map_err(|err| anyhow::anyhow!("Failed to get scheduler vk: {err}"))?; - tracing::info!("Generating verification keys for snark wrapper."); - // Compression mode is 1 - let config = WrapperConfig::new(1); + tracing::info!("Generating PLONK verification keys for snark wrapper."); + + let (_, plonk_vk) = + get_wrapper_setup_and_vk_from_scheduler_vk(scheduler_vk.clone(), WrapperConfig::new(1)); - let (_, vk) = get_wrapper_setup_and_vk_from_scheduler_vk(scheduler_vk, config); keystore - .save_snark_verification_key(vk) - .context("save_snark_vk")?; + .save_snark_verification_key(plonk_vk) + .context("save_plonk_snark_vk")?; if let Some(p) = pb.lock().unwrap().as_ref() { p.inc(1) } + tracing::info!("PLONK vk is generated"); + + #[cfg(feature = "gpu")] + { + tracing::info!("Generating FFLONK verification keys for snark wrapper."); + + let (_, fflonk_vk) = get_fflonk_snark_verifier_setup_and_vk(&mut in_memory_source); + + keystore + .save_fflonk_snark_verification_key(fflonk_vk) + .context("save_fflonk_snark_vk")?; + + if let Some(p) = pb.lock().unwrap().as_ref() { + p.inc(1) + } + + tracing::info!("FFLONK vk is generated"); + } + // Let's also update the commitments file. let commitments = keystore.generate_commitments()?; keystore.save_commitments(&commitments) @@ -121,6 +171,9 @@ enum CircuitSelector { Recursive, /// Select circuits from basic group. Basic, + Compression, + CompressionWrapper, + Snark, } #[derive(Debug, Parser)] @@ -227,6 +280,17 @@ fn generate_setup_keys( .numeric_circuit .expect("--numeric-circuit must be provided"), ), + CircuitSelector::Compression => ProverServiceDataKey::new_compression( + options + .numeric_circuit + .expect("--numeric-circuit must be provided"), + ), + CircuitSelector::CompressionWrapper => ProverServiceDataKey::new_compression_wrapper( + options + .numeric_circuit + .expect("--numeric-circuit must be provided"), + ), + CircuitSelector::Snark => ProverServiceDataKey::snark(), }; let digest = generator diff --git a/prover/crates/bin/vk_setup_data_generator_server_fri/src/tests.rs b/prover/crates/bin/vk_setup_data_generator_server_fri/src/tests.rs index 0a9548197fd7..0d98abbd6d58 100644 --- a/prover/crates/bin/vk_setup_data_generator_server_fri/src/tests.rs +++ b/prover/crates/bin/vk_setup_data_generator_server_fri/src/tests.rs @@ -4,31 +4,27 @@ use zksync_prover_fri_types::{ circuit_definitions::recursion_layer::base_circuit_type_into_recursive_leaf_circuit_type, zkevm_circuits::scheduler::aux::BaseLayerCircuitType, }, - ProverServiceDataKey, + ProverServiceDataKey, ProvingStage, }; use zksync_prover_keystore::keystore::Keystore; -use zksync_types::basic_fri_types::AggregationRound; fn all_possible_prover_service_data_key() -> impl Strategy { let mut keys = Vec::with_capacity(30); for circuit_type in 1..=13 { keys.push(ProverServiceDataKey::new( circuit_type, - AggregationRound::BasicCircuits, + ProvingStage::BasicCircuits, )); let recursive_circuit_type = base_circuit_type_into_recursive_leaf_circuit_type( BaseLayerCircuitType::from_numeric_value(circuit_type), ) as u8; keys.push(ProverServiceDataKey::new( recursive_circuit_type, - AggregationRound::LeafAggregation, + ProvingStage::LeafAggregation, )); } - keys.push(ProverServiceDataKey::new(1, AggregationRound::Scheduler)); - keys.push(ProverServiceDataKey::new( - 2, - AggregationRound::NodeAggregation, - )); + keys.push(ProverServiceDataKey::new(1, ProvingStage::Scheduler)); + keys.push(ProverServiceDataKey::new(2, ProvingStage::NodeAggregation)); prop::sample::select(keys) } @@ -66,14 +62,14 @@ proptest! { // Test `ProverServiceDataKey::new` method #[test] fn test_proverservicedatakey_new() { - let key = ProverServiceDataKey::new(1, AggregationRound::BasicCircuits); + let key = ProverServiceDataKey::new(1, ProvingStage::BasicCircuits); assert_eq!( key.circuit_id, 1, "Circuit id should be equal to the given value" ); assert_eq!( - key.round, - AggregationRound::BasicCircuits, + key.stage, + ProvingStage::BasicCircuits, "Round should be equal to the given value" ); } diff --git a/prover/crates/bin/vk_setup_data_generator_server_fri/src/utils.rs b/prover/crates/bin/vk_setup_data_generator_server_fri/src/utils.rs new file mode 100644 index 000000000000..85ce0b5be0b6 --- /dev/null +++ b/prover/crates/bin/vk_setup_data_generator_server_fri/src/utils.rs @@ -0,0 +1,141 @@ +use circuit_definitions::{ + boojum::worker::Worker, + circuit_definitions::{ + aux_layer::{ + ZkSyncCompressionForWrapperCircuit, ZkSyncCompressionLayerCircuit, + ZkSyncCompressionLayerStorage, ZkSyncSnarkWrapperSetup, ZkSyncSnarkWrapperVK, + }, + recursion_layer::{ZkSyncRecursionLayerStorageType, ZkSyncRecursionLayerVerificationKey}, + }, +}; +#[cfg(feature = "gpu")] +use shivini::cs::gpu_setup_and_vk_from_base_setup_vk_params_and_hints; +use zkevm_test_harness::{ + data_source::{BlockDataSource, SetupDataSource}, + proof_wrapper_utils::{ + check_trusted_setup_file_existace, get_vk_for_previous_circuit, + get_wrapper_setup_and_vk_from_compression_vk, WrapperConfig, + }, + prover_utils::light::{ + create_light_compression_for_wrapper_setup_data, create_light_compression_layer_setup_data, + }, +}; + +#[cfg(feature = "gpu")] +pub(crate) fn generate_compression_vks( + config: WrapperConfig, + source: &mut DS, + worker: &Worker, +) { + for circuit_type in config.get_compression_types() { + let vk = get_vk_for_previous_circuit(source, circuit_type).unwrap_or_else(|_| { + panic!( + "VK of previous circuit should be present. Current circuit type: {}", + circuit_type + ) + }); + + let compression_circuit = + ZkSyncCompressionLayerCircuit::from_witness_and_vk(None, vk, circuit_type); + let proof_config = compression_circuit.proof_config_for_compression_step(); + + let (setup_base, vk_geometry, vars_hint, witness_hint, finalization_hint) = + create_light_compression_layer_setup_data( + compression_circuit, + worker, + proof_config.fri_lde_factor, + proof_config.merkle_tree_cap_size, + ); + + let (_, vk) = gpu_setup_and_vk_from_base_setup_vk_params_and_hints( + setup_base, + vk_geometry, + vars_hint.clone(), + witness_hint, + worker, + ) + .expect("failed creating GPU compression layer setup data"); + + source + .set_compression_vk(ZkSyncCompressionLayerStorage::from_inner( + circuit_type, + vk.clone(), + )) + .unwrap(); + source + .set_compression_hint(ZkSyncCompressionLayerStorage::from_inner( + circuit_type, + finalization_hint.clone(), + )) + .unwrap(); + } +} + +#[cfg(feature = "gpu")] +pub(crate) fn generate_compression_for_wrapper_vks( + config: WrapperConfig, + source: &mut DS, + worker: &Worker, +) { + let compression_for_wrapper_type = config.get_compression_for_wrapper_type(); + let vk = get_vk_for_previous_circuit(source, compression_for_wrapper_type).unwrap(); + + let circuit = ZkSyncCompressionForWrapperCircuit::from_witness_and_vk( + None, + vk, + compression_for_wrapper_type, + ); + + let proof_config = circuit.proof_config_for_compression_step(); + + let (setup_base, vk_geometry, vars_hint, witness_hint, finalization_hint) = + create_light_compression_for_wrapper_setup_data( + circuit, + worker, + proof_config.fri_lde_factor, + proof_config.merkle_tree_cap_size, + ); + + let (_, vk) = gpu_setup_and_vk_from_base_setup_vk_params_and_hints( + setup_base, + vk_geometry, + vars_hint.clone(), + witness_hint, + worker, + ) + .expect("failed creating GPU compression for wrapper layer setup data"); + + source + .set_compression_for_wrapper_vk(ZkSyncCompressionLayerStorage::from_inner( + compression_for_wrapper_type, + vk.clone(), + )) + .unwrap(); + source + .set_compression_for_wrapper_hint(ZkSyncCompressionLayerStorage::from_inner( + compression_for_wrapper_type, + finalization_hint.clone(), + )) + .unwrap(); +} + +/// Computes wrapper vk from scheduler vk +/// We store all vks in the RAM +pub fn get_plonk_wrapper_setup_and_vk_from_scheduler_vk( + source: &mut DS, + vk: ZkSyncRecursionLayerVerificationKey, + config: WrapperConfig, +) -> (ZkSyncSnarkWrapperSetup, ZkSyncSnarkWrapperVK) { + // Check trusted setup file for later + check_trusted_setup_file_existace(); + + // Check circuit type correctness + assert_eq!( + vk.numeric_circuit_type(), + ZkSyncRecursionLayerStorageType::SchedulerCircuit as u8 + ); + + let wrapper_type = config.get_wrapper_type(); + let wrapper_vk = source.get_compression_for_wrapper_vk(wrapper_type).unwrap(); + get_wrapper_setup_and_vk_from_compression_vk(wrapper_vk, config) +} diff --git a/prover/crates/bin/witness_generator/src/main.rs b/prover/crates/bin/witness_generator/src/main.rs index 38aacf5d7a52..8b28ecf3cdd6 100644 --- a/prover/crates/bin/witness_generator/src/main.rs +++ b/prover/crates/bin/witness_generator/src/main.rs @@ -140,6 +140,7 @@ async fn main() -> anyhow::Result<()> { let (stop_sender, stop_receiver) = watch::channel(false); let protocol_version = PROVER_PROTOCOL_SEMANTIC_VERSION; + ensure_protocol_alignment(&connection_pool, protocol_version, &keystore) .await .unwrap_or_else(|err| panic!("Protocol alignment check failed: {:?}", err)); diff --git a/prover/crates/bin/witness_generator/src/rounds/basic_circuits/utils.rs b/prover/crates/bin/witness_generator/src/rounds/basic_circuits/utils.rs index 348ba1dcd996..6a0769072eaf 100644 --- a/prover/crates/bin/witness_generator/src/rounds/basic_circuits/utils.rs +++ b/prover/crates/bin/witness_generator/src/rounds/basic_circuits/utils.rs @@ -130,7 +130,7 @@ pub(super) async fn generate_witness( geometry_config, storage_oracle, tree, - path.to_owned(), + path.to_string(), input.eip_4844_blobs.blobs(), artifacts_sender, ); diff --git a/prover/crates/bin/witness_vector_generator/tests/basic_test.rs b/prover/crates/bin/witness_vector_generator/tests/basic_test.rs index bcf01ddc4061..9588cca5f826 100644 --- a/prover/crates/bin/witness_vector_generator/tests/basic_test.rs +++ b/prover/crates/bin/witness_vector_generator/tests/basic_test.rs @@ -1,8 +1,8 @@ use std::fs; -use zksync_prover_fri_types::{CircuitWrapper, ProverJob, ProverServiceDataKey}; +use zksync_prover_fri_types::{CircuitWrapper, ProverJob, ProverServiceDataKey, ProvingStage}; use zksync_prover_keystore::keystore::Keystore; -use zksync_types::{basic_fri_types::AggregationRound, L1BatchNumber}; +use zksync_types::L1BatchNumber; use zksync_witness_vector_generator::generator::WitnessVectorGenerator; #[test] @@ -14,7 +14,7 @@ fn test_generate_witness_vector() { .expect("circuit wrapper deserialization failed"); let key = ProverServiceDataKey { circuit_id: 1, - round: AggregationRound::BasicCircuits, + stage: ProvingStage::BasicCircuits, }; let job = ProverJob { block_number: L1BatchNumber(1), diff --git a/prover/crates/lib/circuit_prover_service/src/gpu_circuit_prover/gpu_circuit_prover_job_picker.rs b/prover/crates/lib/circuit_prover_service/src/gpu_circuit_prover/gpu_circuit_prover_job_picker.rs index 76dc0cda66d3..12c62a6913af 100644 --- a/prover/crates/lib/circuit_prover_service/src/gpu_circuit_prover/gpu_circuit_prover_job_picker.rs +++ b/prover/crates/lib/circuit_prover_service/src/gpu_circuit_prover/gpu_circuit_prover_job_picker.rs @@ -62,7 +62,7 @@ impl JobPicker for GpuCircuitProverJobPicker { let key = ProverServiceDataKey { circuit_id: metadata.circuit_id, - round: metadata.aggregation_round, + stage: metadata.aggregation_round.into(), } .crypto_setup_key(); let setup_data = self diff --git a/prover/crates/lib/circuit_prover_service/src/lib.rs b/prover/crates/lib/circuit_prover_service/src/lib.rs index bbf1f9733f6f..19e7bb1f41ee 100644 --- a/prover/crates/lib/circuit_prover_service/src/lib.rs +++ b/prover/crates/lib/circuit_prover_service/src/lib.rs @@ -1,5 +1,7 @@ -#![allow(incomplete_features)] // Crypto code uses generic const exprs +#![allow(incomplete_features)] +// Crypto code uses generic const exprs, allocator_api is needed to use global allocators #![feature(generic_const_exprs, allocator_api)] + mod gpu_circuit_prover; pub mod job_runner; mod metrics; diff --git a/prover/crates/lib/circuit_prover_service/src/witness_vector_generator/witness_vector_generator_job_picker.rs b/prover/crates/lib/circuit_prover_service/src/witness_vector_generator/witness_vector_generator_job_picker.rs index 76e0f151c7ca..b83baa8bbd35 100644 --- a/prover/crates/lib/circuit_prover_service/src/witness_vector_generator/witness_vector_generator_job_picker.rs +++ b/prover/crates/lib/circuit_prover_service/src/witness_vector_generator/witness_vector_generator_job_picker.rs @@ -138,7 +138,7 @@ impl JobPicker for WitnessVectorGeneratorJobPic let key = ProverServiceDataKey { circuit_id: metadata.circuit_id, - round: metadata.aggregation_round, + stage: metadata.aggregation_round.into(), } .crypto_setup_key(); let finalization_hints = self diff --git a/prover/crates/lib/keystore/Cargo.toml b/prover/crates/lib/keystore/Cargo.toml index 8dac09b782c0..8ae3c9fd16c1 100644 --- a/prover/crates/lib/keystore/Cargo.toml +++ b/prover/crates/lib/keystore/Cargo.toml @@ -9,7 +9,6 @@ license.workspace = true keywords.workspace = true categories.workspace = true - [dependencies] zksync_basic_types.workspace = true zksync_utils.workspace = true @@ -17,8 +16,10 @@ zksync_prover_fri_types.workspace = true zkevm_test_harness.workspace = true circuit_definitions = { workspace = true, features = ["log_tracing"] } shivini = { workspace = true, optional = true } +fflonk-gpu = { workspace = true, optional = true } boojum-cuda = { workspace = true, optional = true } +byteorder.workspace = true anyhow.workspace = true tracing.workspace = true serde_json.workspace = true @@ -33,4 +34,6 @@ futures = { workspace = true, features = ["compat"] } [features] default = [] -gpu = ["shivini", "boojum-cuda"] +# feature to not compile era-bellman-cuda, but to be able to use GPU features +gpu-light = ["dep:shivini", "dep:boojum-cuda"] +gpu = ["dep:shivini", "dep:fflonk-gpu", "dep:boojum-cuda"] diff --git a/prover/crates/lib/keystore/src/commitment_utils.rs b/prover/crates/lib/keystore/src/commitment_utils.rs index 6973f86bf41e..9379ffc7ea81 100644 --- a/prover/crates/lib/keystore/src/commitment_utils.rs +++ b/prover/crates/lib/keystore/src/commitment_utils.rs @@ -11,6 +11,8 @@ use zksync_prover_fri_types::circuit_definitions::{ circuit_definitions::recursion_layer::ZkSyncRecursionLayerStorageType, }; +#[cfg(feature = "gpu")] +use crate::utils::calculate_fflonk_snark_vk_hash; use crate::{ keystore::Keystore, utils::{calculate_snark_vk_hash, get_leaf_vk_params}, @@ -54,13 +56,24 @@ impl Keystore { let leaf_aggregation_commitment_hex = hex_concatenator(leaf_vk_commitment); let node_aggregation_commitment_hex = hex_concatenator(node_vk_commitment); let scheduler_commitment_hex = hex_concatenator(scheduler_vk_commitment); - let snark_vk_hash: String = calculate_snark_vk_hash(self)?.encode_hex(); + let plonk_snark_vk_hash: String = + calculate_snark_vk_hash(self.load_snark_verification_key().unwrap())?.encode_hex(); + #[cfg(feature = "gpu")] + let fflonk_snark_vk_hash: String = + calculate_fflonk_snark_vk_hash(self.load_fflonk_snark_verification_key().unwrap())? + .encode_hex(); + #[cfg(not(feature = "gpu"))] + let fflonk_snark_vk_hash = { + tracing::warn!("To generate FFLONK SNARK VK hash, please enable the `gpu` feature."); + "0x".to_owned() + }; let result = VkCommitments { leaf: leaf_aggregation_commitment_hex, node: node_aggregation_commitment_hex, scheduler: scheduler_commitment_hex, - snark_wrapper: format!("0x{}", snark_vk_hash), + snark_wrapper: format!("0x{}", plonk_snark_vk_hash), + fflonk_snark_wrapper: format!("0x{}", fflonk_snark_vk_hash), }; tracing::info!("Commitments: {:?}", result); Ok(result) diff --git a/prover/crates/lib/keystore/src/keystore.rs b/prover/crates/lib/keystore/src/keystore.rs index ab3b115bc635..fb84436916e7 100644 --- a/prover/crates/lib/keystore/src/keystore.rs +++ b/prover/crates/lib/keystore/src/keystore.rs @@ -7,23 +7,33 @@ use std::{ }; use anyhow::Context as _; +#[cfg(any(feature = "gpu", feature = "gpu-light"))] +use circuit_definitions::circuit_definitions::aux_layer::{ + CompressionProofsTreeHasher, CompressionProofsTreeHasherForWrapper, +}; use circuit_definitions::{ boojum::cs::implementations::setup::FinalizationHintsForProver, circuit_definitions::{ - aux_layer::ZkSyncSnarkWrapperVK, + aux_layer::{ + ZkSyncCompressionForWrapperVerificationKey, ZkSyncCompressionLayerVerificationKey, + ZkSyncSnarkWrapperVK, + }, base_layer::ZkSyncBaseLayerVerificationKey, recursion_layer::{ZkSyncRecursionLayerStorageType, ZkSyncRecursionLayerVerificationKey}, }, zkevm_circuits::scheduler::aux::BaseLayerCircuitType, }; +#[cfg(feature = "gpu")] +use fflonk_gpu::{FflonkSnarkVerifierCircuitDeviceSetup, FflonkSnarkVerifierCircuitVK}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; +#[cfg(any(feature = "gpu", feature = "gpu-light"))] +use shivini::boojum::field::goldilocks::GoldilocksField; use zkevm_test_harness::data_source::{in_memory_data_source::InMemoryDataSource, SetupDataSource}; -use zksync_basic_types::basic_fri_types::AggregationRound; -use zksync_prover_fri_types::ProverServiceDataKey; +use zksync_prover_fri_types::{ProverServiceDataKey, ProvingStage, MAX_COMPRESSION_CIRCUITS}; use zksync_utils::env::Workspace; -#[cfg(feature = "gpu")] -use crate::GoldilocksGpuProverSetupData; +#[cfg(any(feature = "gpu", feature = "gpu-light"))] +use crate::{GoldilocksGpuProverSetupData, GpuProverSetupData}; use crate::{GoldilocksProverSetupData, VkCommitments}; #[derive(Debug, Clone, Copy)] @@ -32,6 +42,7 @@ pub enum ProverServiceDataType { SetupData, FinalizationHints, SnarkVerificationKey, + FflonkSnarkVerificationKey, } /// Key store manages all the prover keys. @@ -119,9 +130,12 @@ impl Keystore { ProverServiceDataType::FinalizationHints => self .basedir .join(format!("finalization_hints_{}.bin", name)), - ProverServiceDataType::SnarkVerificationKey => self + ProverServiceDataType::SnarkVerificationKey => { + self.basedir.join(format!("verification_{}_key.json", name)) + } + ProverServiceDataType::FflonkSnarkVerificationKey => self .basedir - .join(format!("snark_verification_{}_key.json", name)), + .join(format!("fflonk_verification_{}_key.json", name)), } } @@ -164,7 +178,7 @@ impl Keystore { circuit_type: u8, ) -> anyhow::Result { Self::load_json_from_file(self.get_file_path( - ProverServiceDataKey::new(circuit_type, AggregationRound::BasicCircuits), + ProverServiceDataKey::new(circuit_type, ProvingStage::BasicCircuits), ProverServiceDataType::VerificationKey, )) } @@ -179,12 +193,32 @@ impl Keystore { )) } + pub fn load_compression_vk( + &self, + circuit_type: u8, + ) -> anyhow::Result { + Self::load_json_from_file(self.get_file_path( + ProverServiceDataKey::new_compression(circuit_type), + ProverServiceDataType::VerificationKey, + )) + } + + pub fn load_compression_for_wrapper_vk( + &self, + circuit_type: u8, + ) -> anyhow::Result { + Self::load_json_from_file(self.get_file_path( + ProverServiceDataKey::new_compression_wrapper(circuit_type), + ProverServiceDataType::VerificationKey, + )) + } + pub fn save_base_layer_verification_key( &self, vk: ZkSyncBaseLayerVerificationKey, ) -> anyhow::Result<()> { let filepath = self.get_file_path( - ProverServiceDataKey::new(vk.numeric_circuit_type(), AggregationRound::BasicCircuits), + ProverServiceDataKey::new(vk.numeric_circuit_type(), ProvingStage::BasicCircuits), ProverServiceDataType::VerificationKey, ); tracing::info!("saving basic verification key to: {:?}", filepath); @@ -203,6 +237,36 @@ impl Keystore { Self::save_json_pretty(filepath, &vk) } + pub fn save_compression_vk( + &self, + vk: ZkSyncCompressionLayerVerificationKey, + ) -> anyhow::Result<()> { + let filepath = self.get_file_path( + ProverServiceDataKey::new_compression(vk.numeric_circuit_type()), + ProverServiceDataType::VerificationKey, + ); + tracing::info!( + "saving compression layer verification key to: {:?}", + filepath + ); + Self::save_json_pretty(filepath, &vk) + } + + pub fn save_compression_for_wrapper_vk( + &self, + vk: ZkSyncCompressionForWrapperVerificationKey, + ) -> anyhow::Result<()> { + let filepath = self.get_file_path( + ProverServiceDataKey::new_compression_wrapper(vk.numeric_circuit_type()), + ProverServiceDataType::VerificationKey, + ); + tracing::info!( + "saving compression wrapper verification key to: {:?}", + filepath + ); + Self::save_json_pretty(filepath, &vk) + } + /// /// Finalization hints /// @@ -227,7 +291,7 @@ impl Keystore { let mut key = key; // For `NodeAggregation` round we have only 1 finalization hints for all circuit type. // TODO: is this needed?? - if key.round == AggregationRound::NodeAggregation { + if key.stage == ProvingStage::NodeAggregation { key.circuit_id = ZkSyncRecursionLayerStorageType::NodeLayerCircuit as u8; } Self::load_bincode_from_file( @@ -253,6 +317,16 @@ impl Keystore { }) } + pub fn load_fflonk_snark_verification_key(&self) -> anyhow::Result { + let filepath = self.get_file_path( + ProverServiceDataKey::snark(), + ProverServiceDataType::FflonkSnarkVerificationKey, + ); + std::fs::read_to_string(&filepath).with_context(|| { + format!("Failed reading FFLONK Snark verification key from path: {filepath:?}") + }) + } + pub fn save_snark_verification_key(&self, vk: ZkSyncSnarkWrapperVK) -> anyhow::Result<()> { let filepath = self.get_file_path( ProverServiceDataKey::snark(), @@ -262,6 +336,19 @@ impl Keystore { Self::save_json_pretty(filepath, &vk.into_inner()) } + #[cfg(feature = "gpu")] + pub fn save_fflonk_snark_verification_key( + &self, + vk: FflonkSnarkVerifierCircuitVK, + ) -> anyhow::Result<()> { + let filepath = self.get_file_path( + ProverServiceDataKey::snark(), + ProverServiceDataType::FflonkSnarkVerificationKey, + ); + tracing::info!("saving snark verification key to: {:?}", filepath); + Self::save_json_pretty(filepath, &vk) + } + /// /// Setup keys /// @@ -284,7 +371,7 @@ impl Keystore { }) } - #[cfg(feature = "gpu")] + #[cfg(any(feature = "gpu", feature = "gpu-light"))] pub fn load_gpu_setup_data_for_circuit_type( &self, key: ProverServiceDataKey, @@ -303,6 +390,78 @@ impl Keystore { }) } + #[cfg(any(feature = "gpu", feature = "gpu-light"))] + pub fn load_compression_setup_data( + &self, + circuit: u8, + ) -> anyhow::Result> { + let filepath = self.get_file_path( + ProverServiceDataKey::new_compression(circuit), + ProverServiceDataType::SetupData, + ); + + let mut file = File::open(filepath.clone()) + .with_context(|| format!("Failed reading setup-data from path: {filepath:?}"))?; + let mut buffer = Vec::new(); + file.read_to_end(&mut buffer).with_context(|| { + format!("Failed reading setup-data to buffer from path: {filepath:?}") + })?; + tracing::info!( + "loading compression wrapper setup data from path: {:?}", + filepath + ); + bincode::deserialize::>( + &buffer, + ) + .with_context(|| { + format!("Failed deserializing compression wrapper setup data at path: {filepath:?}") + }) + } + + #[cfg(any(feature = "gpu", feature = "gpu-light"))] + pub fn load_compression_wrapper_setup_data( + &self, + circuit: u8, + ) -> anyhow::Result> + { + let filepath = self.get_file_path( + ProverServiceDataKey::new_compression_wrapper(circuit), + ProverServiceDataType::SetupData, + ); + + let mut file = File::open(filepath.clone()) + .with_context(|| format!("Failed reading setup-data from path: {filepath:?}"))?; + let mut buffer = Vec::new(); + file.read_to_end(&mut buffer).with_context(|| { + format!("Failed reading setup-data to buffer from path: {filepath:?}") + })?; + tracing::info!( + "loading compression wrapper setup data from path: {:?}", + filepath + ); + bincode::deserialize::< + GpuProverSetupData, + >(&buffer) + .with_context(|| { + format!("Failed deserializing compression wrapper setup data at path: {filepath:?}") + }) + } + + #[cfg(feature = "gpu")] + pub fn load_fflonk_snark_verifier_setup_data( + &self, + ) -> anyhow::Result { + let filepath = self.get_file_path( + ProverServiceDataKey::snark(), + ProverServiceDataType::SetupData, + ); + + let file = File::open(filepath.clone()) + .with_context(|| format!("Failed reading setup-data from path: {filepath:?}"))?; + FflonkSnarkVerifierCircuitDeviceSetup::read(file) + .context("Failed reading FFLONK SNARK setup data from a file") + } + pub fn is_setup_data_present(&self, key: &ProverServiceDataKey) -> bool { Path::new(&self.get_file_path(*key, ProverServiceDataType::SetupData)).exists() } @@ -318,6 +477,24 @@ impl Keystore { .with_context(|| format!("Failed saving setup-data at path: {filepath:?}")) } + #[cfg(feature = "gpu")] + pub fn save_fflonk_snark_setup_data( + &self, + setup_data: FflonkSnarkVerifierCircuitDeviceSetup, + ) -> anyhow::Result<()> { + let filepath = self.get_file_path( + ProverServiceDataKey::snark(), + ProverServiceDataType::SetupData, + ); + + let file = File::create(filepath.clone()) + .with_context(|| format!("Failed creating setup-data file at path: {filepath:?}"))?; + + setup_data + .write(file) + .context("Failed writing FFLONK SNARK setup data to a file") + } + /// Loads all the verification keys into the Data Source. /// Keys are loaded from the default 'base path' files. pub fn load_keys_to_data_source(&self) -> anyhow::Result { @@ -345,6 +522,16 @@ impl Keystore { )?) .unwrap(); + for circuit in 1..MAX_COMPRESSION_CIRCUITS { + data_source + .set_compression_vk(self.load_compression_vk(circuit)?) + .unwrap(); + } + + data_source + .set_compression_for_wrapper_vk(self.load_compression_for_wrapper_vk(5)?) + .unwrap(); + Ok(data_source) } @@ -365,7 +552,7 @@ impl Keystore { ) })? .into_inner(); - let key = ProverServiceDataKey::new(base_circuit_type, AggregationRound::BasicCircuits); + let key = ProverServiceDataKey::new(base_circuit_type, ProvingStage::BasicCircuits); self.save_finalization_hints(key, &hint) .context("save_finalization_hints()")?; } @@ -458,6 +645,45 @@ impl Keystore { ) .context("save_finalization_hints()")?; + // Compression + // todo: don't use hardcoded values + for circuit in 1..5 { + let vk = source + .get_compression_vk(circuit as u8) + .map_err(|err| anyhow::anyhow!("No vk exist for circuit type: {circuit}: {err}"))?; + + self.save_compression_vk(vk) + .context("save_compression_vk()")?; + + let hint = source.get_compression_hint(circuit as u8).map_err(|err| { + anyhow::anyhow!("No finalization hint exist for circuit type: {circuit}: {err}") + })?; + + self.save_finalization_hints( + ProverServiceDataKey::new_compression(circuit as u8), + &hint.into_inner(), + ) + .context("save_finalization_hints()")?; + } + + // Compression wrapper + let vk = source + .get_compression_for_wrapper_vk(5) + .map_err(|err| anyhow::anyhow!("No vk exist for circuit type: 5: {err}"))?; + + self.save_compression_for_wrapper_vk(vk) + .context("save_compression_wrapper_vk()")?; + + let hint = source.get_compression_for_wrapper_hint(5).map_err(|err| { + anyhow::anyhow!("No finalization hint exist for circuit type: 5: {err}") + })?; + + self.save_finalization_hints( + ProverServiceDataKey::new_compression_wrapper(5), + &hint.into_inner(), + ) + .context("save_finalization_hints()")?; + Ok(()) } @@ -470,7 +696,7 @@ impl Keystore { } /// Async loads mapping of all circuits to setup key, if successful - #[cfg(feature = "gpu")] + #[cfg(any(feature = "gpu", feature = "gpu-light"))] pub async fn load_all_setup_key_mapping( &self, ) -> anyhow::Result>> { @@ -498,7 +724,7 @@ impl Keystore { // deserialization is. For larger files, it makes a big difference. // Note: `collect` is important, because iterators are lazy, and otherwise we won't actually // spawn threads. - let handles: Vec<_> = ProverServiceDataKey::all() + let handles: Vec<_> = ProverServiceDataKey::all_boojum() .into_iter() .map(|key| { let filepath = self.get_file_path(key, data_type); diff --git a/prover/crates/lib/keystore/src/lib.rs b/prover/crates/lib/keystore/src/lib.rs index 543b7b18ffe5..e5f00fd307ba 100644 --- a/prover/crates/lib/keystore/src/lib.rs +++ b/prover/crates/lib/keystore/src/lib.rs @@ -1,7 +1,8 @@ -#![feature(allocator_api)] +#![feature(allocator_api, generic_const_exprs)] +#![allow(incomplete_features)] use serde::{Deserialize, Serialize}; -#[cfg(feature = "gpu")] +#[cfg(any(feature = "gpu", feature = "gpu-light"))] use shivini::cs::GpuSetup; use zkevm_test_harness::compute_setups::CircuitSetupData; use zksync_prover_fri_types::circuit_definitions::boojum::{ @@ -81,7 +82,7 @@ impl From for GoldilocksProverSetupData { } } -#[cfg(feature = "gpu")] +#[cfg(any(feature = "gpu", feature = "gpu-light"))] #[derive(Debug, Serialize, Deserialize)] #[serde(bound = "F: serde::Serialize + serde::de::DeserializeOwned")] pub struct GpuProverSetupData> @@ -95,7 +96,7 @@ pub struct GpuProverSetupData anyhow::Result { let mut data_source = keystore.load_keys_to_data_source()?; - let circuit_setup_data = generate_circuit_setup_data( - circuit.round as u8, // TODO: Actually it's called "ProvingStage" now - circuit.circuit_id, - &mut data_source, - ) - .unwrap(); - - let (finalization, vk) = if circuit.is_base_layer() { - ( + let circuit_setup_data = + generate_circuit_setup_data(circuit.stage as u8, circuit.circuit_id, &mut data_source) + .unwrap(); + + let (finalization, vk) = match circuit.stage { + ProvingStage::BasicCircuits => ( Some(keystore.load_finalization_hints(circuit)?), data_source .get_base_layer_vk(circuit.circuit_id) .unwrap() .into_inner(), - ) - } else { - ( + ), + ProvingStage::Compression => { + unreachable!("Compression stage should not be generated with CPU.") + } + ProvingStage::CompressionWrapper => { + unreachable!("CompressionWrapper stage should not be generated with CPU.") + } + _ => ( Some(keystore.load_finalization_hints(circuit)?), data_source .get_recursion_layer_vk(circuit.circuit_id) .unwrap() .into_inner(), - ) + ), }; // Sanity check to make sure that generated setup data is matching. @@ -90,6 +106,27 @@ pub trait SetupDataGenerator { ); return Ok("Skipped".to_string()); } + + if circuit == ProverServiceDataKey::snark() { + #[cfg(not(feature = "gpu"))] + { + anyhow::bail!("Must compile with --gpu feature to use this option."); + } + #[cfg(feature = "gpu")] + { + let mut data_source = self.keystore().load_keys_to_data_source()?; + let (setup, _) = get_fflonk_snark_verifier_setup_and_vk(&mut data_source); + if !dry_run { + self.keystore() + .save_fflonk_snark_setup_data(setup) + .context("save_setup_data()")?; + } + return Ok(String::from( + "FFLONK is serialized differently, skipping hashing.", + )); + } + } + let serialized = self.generate_setup_data(circuit)?; let digest = md5::compute(&serialized); @@ -109,9 +146,10 @@ pub trait SetupDataGenerator { dry_run: bool, recompute_if_missing: bool, ) -> anyhow::Result> { - Ok(ProverServiceDataKey::all_boojum() + Ok(ProverServiceDataKey::all() .iter() .map(|circuit| { + tracing::info!("Generating setup data for {:?}", circuit.name()); let digest = self .generate_and_write_setup_data(*circuit, dry_run, recompute_if_missing) .context(circuit.name()) @@ -146,42 +184,99 @@ pub struct GPUSetupDataGenerator { impl SetupDataGenerator for GPUSetupDataGenerator { fn generate_setup_data(&self, circuit: ProverServiceDataKey) -> anyhow::Result> { - #[cfg(not(feature = "gpu"))] + #[cfg(not(any(feature = "gpu", feature = "gpu-light")))] { let _ = circuit; anyhow::bail!("Must compile with --gpu feature to use this option."); } - #[cfg(feature = "gpu")] + #[cfg(any(feature = "gpu", feature = "gpu-light"))] { let _context = ProverContext::create().context("failed initializing gpu prover context")?; let mut data_source = self.keystore.load_keys_to_data_source()?; + let circuit_setup_data = generate_light_circuit_setup_data( - circuit.round as u8, + circuit.stage as u8, circuit.circuit_id, &mut data_source, ) .unwrap(); let worker = Worker::new(); - // TODO: add required assertions - let (gpu_setup_data, vk) = - gpu_setup_and_vk_from_base_setup_vk_params_and_hints::( - circuit_setup_data.setup_base, - circuit_setup_data.vk_geometry, - circuit_setup_data.vars_hint.clone(), - circuit_setup_data.wits_hint, - &worker, - ) - .context("failed creating GPU base layer setup data")?; - let gpu_prover_setup_data = GpuProverSetupData { - setup: gpu_setup_data, - vk: vk.clone(), - finalization_hint: circuit_setup_data.finalization_hint, - }; - // Serialization should always succeed. - Ok(bincode::serialize(&gpu_prover_setup_data).expect("Failed serializing setup data")) + + match circuit.stage { + ProvingStage::CompressionWrapper => { + let (gpu_setup_data, verification_key) = + gpu_setup_and_vk_from_base_setup_vk_params_and_hints::< + CompressionProofsTreeHasherForWrapper, + _, + >( + circuit_setup_data.setup_base, + circuit_setup_data.vk_geometry, + circuit_setup_data.vars_hint.clone(), + circuit_setup_data.wits_hint, + &worker, + ) + .context("failed creating GPU base layer setup data")?; + + let gpu_prover_setup_data = GpuProverSetupData { + setup: gpu_setup_data, + vk: verification_key.clone(), + finalization_hint: circuit_setup_data.finalization_hint, + }; + + let serialized_vk = get_vk_by_circuit(self.keystore.clone(), circuit)?; + + assert_eq!( + bincode::serialize(&verification_key) + .expect("Failed serializing setup data"), + serialized_vk, + "Verification key mismatch for circuit: {:?}", + circuit.name() + ); + + // Serialization should always succeed. + Ok(bincode::serialize(&gpu_prover_setup_data) + .expect("Failed serializing setup data")) + } + ProvingStage::Snark => { + unreachable!( + "We cannot serialize Fflonk data with bincode, it is done separately" + ) + } + _ => { + let (gpu_setup_data, verification_key) = + gpu_setup_and_vk_from_base_setup_vk_params_and_hints::( + circuit_setup_data.setup_base, + circuit_setup_data.vk_geometry, + circuit_setup_data.vars_hint.clone(), + circuit_setup_data.wits_hint, + &worker, + ) + .context("failed creating GPU base layer setup data")?; + + let gpu_prover_setup_data = GpuProverSetupData { + setup: gpu_setup_data, + vk: verification_key.clone(), + finalization_hint: circuit_setup_data.finalization_hint, + }; + + let serialized_vk = get_vk_by_circuit(self.keystore.clone(), circuit)?; + + assert_eq!( + bincode::serialize(&verification_key) + .expect("Failed serializing setup data"), + serialized_vk, + "Verification key mismatch for circuit: {:?}", + circuit.name() + ); + + // Serialization should always succeed. + Ok(bincode::serialize(&gpu_prover_setup_data) + .expect("Failed serializing setup data")) + } + } } } @@ -189,3 +284,67 @@ impl SetupDataGenerator for GPUSetupDataGenerator { &self.keystore } } + +#[cfg(any(feature = "gpu", feature = "gpu-light"))] +fn get_vk_by_circuit(keystore: Keystore, circuit: ProverServiceDataKey) -> anyhow::Result> { + let data_source = keystore.load_keys_to_data_source()?; + + match circuit.stage { + ProvingStage::BasicCircuits => { + let vk = data_source + .get_base_layer_vk(circuit.circuit_id) + .unwrap() + .into_inner(); + Ok(bincode::serialize(&vk).expect("Failed serializing setup data")) + } + ProvingStage::Compression => { + let vk = data_source + .get_compression_vk(circuit.circuit_id) + .unwrap() + .into_inner(); + Ok(bincode::serialize(&vk).expect("Failed serializing setup data")) + } + ProvingStage::CompressionWrapper => { + let vk = data_source + .get_compression_for_wrapper_vk(circuit.circuit_id) + .unwrap() + .into_inner(); + Ok(bincode::serialize(&vk).expect("Failed serializing setup data")) + } + _ => { + let vk = data_source + .get_recursion_layer_vk(circuit.circuit_id) + .unwrap() + .into_inner(); + Ok(bincode::serialize(&vk).expect("Failed serializing setup data")) + } + } +} + +#[cfg(feature = "gpu")] +pub fn get_fflonk_snark_verifier_setup_and_vk( + data_source: &mut InMemoryDataSource, +) -> ( + FflonkSnarkVerifierCircuitDeviceSetup, + FflonkSnarkVerifierCircuitVK, +) { + let vk = data_source + .get_compression_for_wrapper_vk(5) + .unwrap() + .into_inner(); + let fixed_parameters = vk.fixed_parameters.clone(); + // todo: do not hardcode this value + let wrapper_function = ZkSyncCompressionWrapper::from_numeric_circuit_type(5); + + let circuit = FflonkSnarkVerifierCircuit { + witness: None, + vk, + fixed_parameters, + transcript_params: (), + wrapper_function, + }; + let setup = FflonkDeviceSetup::<_, _, _>::create_setup_on_device(&circuit).unwrap(); + let snark_vk = setup.get_verification_key(); + + (setup, snark_vk) +} diff --git a/prover/crates/lib/keystore/src/utils.rs b/prover/crates/lib/keystore/src/utils.rs index 10504292d64f..f76f8b48d9b8 100644 --- a/prover/crates/lib/keystore/src/utils.rs +++ b/prover/crates/lib/keystore/src/utils.rs @@ -6,12 +6,16 @@ use circuit_definitions::{ plonk::better_better_cs::setup::VerificationKey as SnarkVK, }, }; +#[cfg(feature = "gpu")] +use fflonk_gpu::FflonkSnarkVerifierCircuitVK; use sha3::Digest; use zkevm_test_harness::{ franklin_crypto::bellman::{CurveAffine, PrimeField, PrimeFieldRepr}, witness::recursive_aggregation::compute_leaf_params, }; use zksync_basic_types::H256; +#[cfg(feature = "gpu")] +use zksync_basic_types::U256; use zksync_prover_fri_types::circuit_definitions::{ boojum::field::goldilocks::GoldilocksField, circuit_definitions::recursion_layer::base_circuit_type_into_recursive_leaf_circuit_type, @@ -48,9 +52,9 @@ pub fn get_leaf_vk_params( /// Calculates the hash of a snark verification key. // This function corresponds 1:1 with the following solidity code: https://github.com/matter-labs/era-contracts/blob/3e2bee96e412bac7c0a58c4b919837b59e9af36e/ethereum/contracts/zksync/Verifier.sol#L260 -pub fn calculate_snark_vk_hash(keystore: &Keystore) -> anyhow::Result { +pub fn calculate_snark_vk_hash(verification_key: String) -> anyhow::Result { let verification_key: SnarkVK = - serde_json::from_str(&keystore.load_snark_verification_key()?)?; + serde_json::from_str(&verification_key)?; let mut res = vec![]; @@ -112,6 +116,43 @@ pub fn calculate_snark_vk_hash(keystore: &Keystore) -> anyhow::Result { Ok(H256::from_slice(&computed_vk_hash)) } +#[cfg(feature = "gpu")] +pub fn calculate_fflonk_snark_vk_hash(verification_key: String) -> anyhow::Result { + let verification_key: FflonkSnarkVerifierCircuitVK = serde_json::from_str(&verification_key)?; + + let mut res = vec![0u8; 32]; + + // NUM INPUTS + // Writing as u256 to comply with the contract + let num_inputs = U256::from(verification_key.num_inputs); + num_inputs.to_big_endian(&mut res[0..32]); + + // C0 G1 + let c0_g1 = verification_key.c0; + let (x, y) = c0_g1.as_xy(); + + x.into_repr().write_be(&mut res)?; + y.into_repr().write_be(&mut res)?; + + // NON RESIDUES + let non_residues = verification_key.non_residues; + for non_residue in non_residues { + non_residue.into_repr().write_be(&mut res)?; + } + + // G2 ELEMENTS + let g2_elements = verification_key.g2_elements; + for g2_element in g2_elements { + res.extend(g2_element.into_uncompressed().as_ref()); + } + + let mut hasher = sha3::Keccak256::new(); + hasher.update(&res); + let computed_vk_hash = hasher.finalize(); + + Ok(H256::from_slice(&computed_vk_hash)) +} + #[cfg(test)] mod tests { use std::str::FromStr; @@ -120,6 +161,8 @@ mod tests { use super::*; + // todo: test is ignored due to serialization issues for now + #[ignore] #[test] fn test_keyhash_generation() { let path_to_input = Workspace::locate().prover().join("data/historical_data"); @@ -134,7 +177,8 @@ mod tests { assert_eq!( expected, - calculate_snark_vk_hash(&keystore).unwrap(), + calculate_snark_vk_hash(keystore.load_snark_verification_key().unwrap()) + .unwrap(), "VK computation failed for {:?}", basepath ); diff --git a/prover/crates/lib/prover_dal/.sqlx/query-419206075cd24f96f00d65f3d138c05583e8415d2e1d8c503f640e77d282b0d5.json b/prover/crates/lib/prover_dal/.sqlx/query-419206075cd24f96f00d65f3d138c05583e8415d2e1d8c503f640e77d282b0d5.json deleted file mode 100644 index ff5b1727e26a..000000000000 --- a/prover/crates/lib/prover_dal/.sqlx/query-419206075cd24f96f00d65f3d138c05583e8415d2e1d8c503f640e77d282b0d5.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT\n snark_wrapper_vk_hash\n FROM\n prover_fri_protocol_versions\n WHERE\n id = $1\n AND protocol_version_patch = $2\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "snark_wrapper_vk_hash", - "type_info": "Bytea" - } - ], - "parameters": { - "Left": [ - "Int4", - "Int4" - ] - }, - "nullable": [ - false - ] - }, - "hash": "419206075cd24f96f00d65f3d138c05583e8415d2e1d8c503f640e77d282b0d5" -} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-6e58af820b4dd867cd794a04c97c23ff743fc01c92e28ed447a8e124062fa62c.json b/prover/crates/lib/prover_dal/.sqlx/query-6e58af820b4dd867cd794a04c97c23ff743fc01c92e28ed447a8e124062fa62c.json deleted file mode 100644 index b5025c6ed18d..000000000000 --- a/prover/crates/lib/prover_dal/.sqlx/query-6e58af820b4dd867cd794a04c97c23ff743fc01c92e28ed447a8e124062fa62c.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT\n snark_wrapper_vk_hash\n FROM\n prover_fri_protocol_versions\n ORDER BY\n id DESC\n LIMIT\n 1\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "snark_wrapper_vk_hash", - "type_info": "Bytea" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - false - ] - }, - "hash": "6e58af820b4dd867cd794a04c97c23ff743fc01c92e28ed447a8e124062fa62c" -} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-720fbd707f5e72415abffb0d48f28982279adec38e2f5405821147c9da56a5f3.json b/prover/crates/lib/prover_dal/.sqlx/query-720fbd707f5e72415abffb0d48f28982279adec38e2f5405821147c9da56a5f3.json new file mode 100644 index 000000000000..2be8d9120701 --- /dev/null +++ b/prover/crates/lib/prover_dal/.sqlx/query-720fbd707f5e72415abffb0d48f28982279adec38e2f5405821147c9da56a5f3.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO\n prover_fri_protocol_versions (\n id,\n snark_wrapper_vk_hash,\n fflonk_snark_wrapper_vk_hash,\n created_at,\n protocol_version_patch\n )\n VALUES\n ($1, $2, $3, NOW(), $4)\n ON CONFLICT (id, protocol_version_patch) DO NOTHING\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int4", + "Bytea", + "Bytea", + "Int4" + ] + }, + "nullable": [] + }, + "hash": "720fbd707f5e72415abffb0d48f28982279adec38e2f5405821147c9da56a5f3" +} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-8c5aeb19a03699a25bd0cb4b0d81ed45f339794303da1d7b66a3ce8983846b3a.json b/prover/crates/lib/prover_dal/.sqlx/query-8c5aeb19a03699a25bd0cb4b0d81ed45f339794303da1d7b66a3ce8983846b3a.json new file mode 100644 index 000000000000..e4868d1ef89a --- /dev/null +++ b/prover/crates/lib/prover_dal/.sqlx/query-8c5aeb19a03699a25bd0cb4b0d81ed45f339794303da1d7b66a3ce8983846b3a.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n snark_wrapper_vk_hash,\n fflonk_snark_wrapper_vk_hash\n FROM\n prover_fri_protocol_versions\n WHERE\n id = $1\n AND protocol_version_patch = $2\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "snark_wrapper_vk_hash", + "type_info": "Bytea" + }, + { + "ordinal": 1, + "name": "fflonk_snark_wrapper_vk_hash", + "type_info": "Bytea" + } + ], + "parameters": { + "Left": [ + "Int4", + "Int4" + ] + }, + "nullable": [ + false, + true + ] + }, + "hash": "8c5aeb19a03699a25bd0cb4b0d81ed45f339794303da1d7b66a3ce8983846b3a" +} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-c37a16566258380ef19a32b2d78ad0d60cc20fd9260fa63328ed4d8dae13c1c1.json b/prover/crates/lib/prover_dal/.sqlx/query-c37a16566258380ef19a32b2d78ad0d60cc20fd9260fa63328ed4d8dae13c1c1.json new file mode 100644 index 000000000000..444ca846fcb2 --- /dev/null +++ b/prover/crates/lib/prover_dal/.sqlx/query-c37a16566258380ef19a32b2d78ad0d60cc20fd9260fa63328ed4d8dae13c1c1.json @@ -0,0 +1,26 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n snark_wrapper_vk_hash,\n fflonk_snark_wrapper_vk_hash\n FROM\n prover_fri_protocol_versions\n ORDER BY\n id DESC\n LIMIT\n 1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "snark_wrapper_vk_hash", + "type_info": "Bytea" + }, + { + "ordinal": 1, + "name": "fflonk_snark_wrapper_vk_hash", + "type_info": "Bytea" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false, + true + ] + }, + "hash": "c37a16566258380ef19a32b2d78ad0d60cc20fd9260fa63328ed4d8dae13c1c1" +} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-f68afde603675b0853547c61a74cbb33d511e07d80a5acd79bc559abdbda49bc.json b/prover/crates/lib/prover_dal/.sqlx/query-f68afde603675b0853547c61a74cbb33d511e07d80a5acd79bc559abdbda49bc.json deleted file mode 100644 index 3820754145db..000000000000 --- a/prover/crates/lib/prover_dal/.sqlx/query-f68afde603675b0853547c61a74cbb33d511e07d80a5acd79bc559abdbda49bc.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n prover_fri_protocol_versions (\n id, snark_wrapper_vk_hash, created_at, protocol_version_patch\n )\n VALUES\n ($1, $2, NOW(), $3)\n ON CONFLICT (id, protocol_version_patch) DO NOTHING\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int4", - "Bytea", - "Int4" - ] - }, - "nullable": [] - }, - "hash": "f68afde603675b0853547c61a74cbb33d511e07d80a5acd79bc559abdbda49bc" -} diff --git a/prover/crates/lib/prover_dal/migrations/20241120092231_add_fflonk_snark_wrapper_vk_hash.down.sql b/prover/crates/lib/prover_dal/migrations/20241120092231_add_fflonk_snark_wrapper_vk_hash.down.sql new file mode 100644 index 000000000000..33ac798fc3bb --- /dev/null +++ b/prover/crates/lib/prover_dal/migrations/20241120092231_add_fflonk_snark_wrapper_vk_hash.down.sql @@ -0,0 +1,2 @@ +ALTER TABLE prover_fri_protocol_versions +DROP COLUMN fflonk_snark_wrapper_vk_hash; diff --git a/prover/crates/lib/prover_dal/migrations/20241120092231_add_fflonk_snark_wrapper_vk_hash.up.sql b/prover/crates/lib/prover_dal/migrations/20241120092231_add_fflonk_snark_wrapper_vk_hash.up.sql new file mode 100644 index 000000000000..2bbd0616b70d --- /dev/null +++ b/prover/crates/lib/prover_dal/migrations/20241120092231_add_fflonk_snark_wrapper_vk_hash.up.sql @@ -0,0 +1,2 @@ +ALTER TABLE prover_fri_protocol_versions +ADD COLUMN fflonk_snark_wrapper_vk_hash BYTEA DEFAULT NULL; diff --git a/prover/crates/lib/prover_dal/src/fri_protocol_versions_dal.rs b/prover/crates/lib/prover_dal/src/fri_protocol_versions_dal.rs index 7128344e5b34..310f12025962 100644 --- a/prover/crates/lib/prover_dal/src/fri_protocol_versions_dal.rs +++ b/prover/crates/lib/prover_dal/src/fri_protocol_versions_dal.rs @@ -21,14 +21,22 @@ impl FriProtocolVersionsDal<'_, '_> { r#" INSERT INTO prover_fri_protocol_versions ( - id, snark_wrapper_vk_hash, created_at, protocol_version_patch + id, + snark_wrapper_vk_hash, + fflonk_snark_wrapper_vk_hash, + created_at, + protocol_version_patch ) VALUES - ($1, $2, NOW(), $3) + ($1, $2, $3, NOW(), $4) ON CONFLICT (id, protocol_version_patch) DO NOTHING "#, id.minor as i32, l1_verifier_config.snark_wrapper_vk_hash.as_bytes(), + l1_verifier_config + .fflonk_snark_wrapper_vk_hash + .as_ref() + .map(|x| x.as_bytes()), id.patch.0 as i32 ) .execute(self.storage.conn()) @@ -43,7 +51,8 @@ impl FriProtocolVersionsDal<'_, '_> { sqlx::query!( r#" SELECT - snark_wrapper_vk_hash + snark_wrapper_vk_hash, + fflonk_snark_wrapper_vk_hash FROM prover_fri_protocol_versions WHERE @@ -58,6 +67,10 @@ impl FriProtocolVersionsDal<'_, '_> { .unwrap() .map(|row| L1VerifierConfig { snark_wrapper_vk_hash: H256::from_slice(&row.snark_wrapper_vk_hash), + fflonk_snark_wrapper_vk_hash: row + .fflonk_snark_wrapper_vk_hash + .as_ref() + .map(|x| H256::from_slice(x)), }) } @@ -65,7 +78,8 @@ impl FriProtocolVersionsDal<'_, '_> { let result = sqlx::query!( r#" SELECT - snark_wrapper_vk_hash + snark_wrapper_vk_hash, + fflonk_snark_wrapper_vk_hash FROM prover_fri_protocol_versions ORDER BY @@ -79,6 +93,10 @@ impl FriProtocolVersionsDal<'_, '_> { Ok(L1VerifierConfig { snark_wrapper_vk_hash: H256::from_slice(&result.snark_wrapper_vk_hash), + fflonk_snark_wrapper_vk_hash: result + .fflonk_snark_wrapper_vk_hash + .as_ref() + .map(|x| H256::from_slice(x)), }) } diff --git a/prover/crates/lib/prover_fri_types/src/lib.rs b/prover/crates/lib/prover_fri_types/src/lib.rs index 37e004d54ecc..44c54da578ee 100644 --- a/prover/crates/lib/prover_fri_types/src/lib.rs +++ b/prover/crates/lib/prover_fri_types/src/lib.rs @@ -27,6 +27,8 @@ use crate::keys::FriCircuitKey; pub mod keys; pub mod queue; +pub const MAX_COMPRESSION_CIRCUITS: u8 = 5; + // THESE VALUES SHOULD BE UPDATED ON ANY PROTOCOL UPGRADE OF PROVERS pub const PROVER_PROTOCOL_VERSION: ProtocolVersionId = ProtocolVersionId::Version25; pub const PROVER_PROTOCOL_PATCH: VersionPatch = VersionPatch(0); @@ -164,7 +166,52 @@ impl ProverJob { #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)] pub struct ProverServiceDataKey { pub circuit_id: u8, - pub round: AggregationRound, + pub stage: ProvingStage, +} + +#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)] +pub enum ProvingStage { + BasicCircuits = 0, + LeafAggregation = 1, + NodeAggregation = 2, + RecursionTip = 3, + Scheduler = 4, + Compression = 5, + CompressionWrapper = 6, + Snark = 7, +} + +impl From for AggregationRound { + fn from(stage: ProvingStage) -> Self { + match stage { + ProvingStage::BasicCircuits => AggregationRound::BasicCircuits, + ProvingStage::LeafAggregation => AggregationRound::LeafAggregation, + ProvingStage::NodeAggregation => AggregationRound::NodeAggregation, + ProvingStage::RecursionTip => AggregationRound::RecursionTip, + ProvingStage::Scheduler => AggregationRound::Scheduler, + ProvingStage::Compression => { + unreachable!("Compression stage is not a part of the aggregation rounds") + } + ProvingStage::CompressionWrapper => { + unreachable!("Compression wrapper stage is not a part of the aggregation rounds") + } + ProvingStage::Snark => { + unreachable!("Snark stage is not a part of the aggregation rounds") + } + } + } +} + +impl From for ProvingStage { + fn from(round: AggregationRound) -> Self { + match round { + AggregationRound::BasicCircuits => ProvingStage::BasicCircuits, + AggregationRound::LeafAggregation => ProvingStage::LeafAggregation, + AggregationRound::NodeAggregation => ProvingStage::NodeAggregation, + AggregationRound::RecursionTip => ProvingStage::RecursionTip, + AggregationRound::Scheduler => ProvingStage::Scheduler, + } + } } impl ProverServiceDataKey { @@ -175,12 +222,13 @@ impl ProverServiceDataKey { /// The 2 overlap on all aggregation rounds, but NodeAggregation. /// There's only 1 node key and that belongs to circuit 2. pub fn crypto_setup_key(self) -> Self { - if let AggregationRound::NodeAggregation = self.round { + if self.stage == ProvingStage::NodeAggregation { return Self { circuit_id: 2, - round: self.round, + stage: ProvingStage::NodeAggregation, }; } + self } } @@ -203,21 +251,38 @@ fn get_round_for_recursive_circuit_type(circuit_type: u8) -> AggregationRound { } impl ProverServiceDataKey { - pub fn new(circuit_id: u8, round: AggregationRound) -> Self { - Self { circuit_id, round } + pub fn new(circuit_id: u8, round: ProvingStage) -> Self { + Self { + circuit_id, + stage: round, + } } /// Creates a new data key for recursive type - with auto selection of the aggregation round. pub fn new_recursive(circuit_id: u8) -> Self { Self { circuit_id, - round: get_round_for_recursive_circuit_type(circuit_id), + stage: get_round_for_recursive_circuit_type(circuit_id).into(), } } pub fn new_basic(circuit_id: u8) -> Self { Self { circuit_id, - round: AggregationRound::BasicCircuits, + stage: ProvingStage::BasicCircuits, + } + } + + pub fn new_compression(circuit_id: u8) -> Self { + Self { + circuit_id, + stage: ProvingStage::Compression, + } + } + + pub fn new_compression_wrapper(circuit_id: u8) -> Self { + Self { + circuit_id, + stage: ProvingStage::CompressionWrapper, } } @@ -230,7 +295,10 @@ impl ProverServiceDataKey { results.push(ProverServiceDataKey::new_recursive(numeric_circuit)) } - // Don't include snark, as it uses the old proving system. + for numeric_circuit in 1..MAX_COMPRESSION_CIRCUITS { + results.push(ProverServiceDataKey::new_compression(numeric_circuit)); + } + results.push(ProverServiceDataKey::new_compression_wrapper(5)); results } @@ -239,7 +307,7 @@ impl ProverServiceDataKey { pub fn snark() -> Self { Self { circuit_id: 1, - round: AggregationRound::Scheduler, + stage: ProvingStage::Snark, } } @@ -250,20 +318,23 @@ impl ProverServiceDataKey { } pub fn is_base_layer(&self) -> bool { - self.round == AggregationRound::BasicCircuits + self.stage == ProvingStage::BasicCircuits } pub fn name(&self) -> String { - match self.round { - AggregationRound::BasicCircuits => { + match self.stage { + ProvingStage::BasicCircuits => { format!("basic_{}", self.circuit_id) } - AggregationRound::LeafAggregation => { + ProvingStage::LeafAggregation => { format!("leaf_{}", self.circuit_id) } - AggregationRound::NodeAggregation => "node".to_string(), - AggregationRound::RecursionTip => "recursion_tip".to_string(), - AggregationRound::Scheduler => "scheduler".to_string(), + ProvingStage::NodeAggregation => "node".to_string(), + ProvingStage::RecursionTip => "recursion_tip".to_string(), + ProvingStage::Scheduler => "scheduler".to_string(), + ProvingStage::Compression => format!("compression_{}", self.circuit_id), + ProvingStage::CompressionWrapper => format!("compression_wrapper_{}", self.circuit_id), + ProvingStage::Snark => "snark".to_string(), } } } diff --git a/prover/crates/lib/prover_fri_utils/src/lib.rs b/prover/crates/lib/prover_fri_utils/src/lib.rs index 02c6da3d5f51..341eaa213698 100644 --- a/prover/crates/lib/prover_fri_utils/src/lib.rs +++ b/prover/crates/lib/prover_fri_utils/src/lib.rs @@ -120,7 +120,7 @@ pub async fn fetch_next_circuit( let setup_data_key = ProverServiceDataKey { circuit_id: prover_job.circuit_id, - round: prover_job.aggregation_round, + stage: prover_job.aggregation_round.into(), }; Some(ProverJob::new( prover_job.block_number, diff --git a/prover/data/keys/commitments.json b/prover/data/keys/commitments.json index 086609a5822b..ff89f17cc723 100644 --- a/prover/data/keys/commitments.json +++ b/prover/data/keys/commitments.json @@ -2,5 +2,6 @@ "leaf": "0xf9664f4324c1400fa5c3822d667f30e873f53f1b8033180cd15fe41c1e2355c6", "node": "0xf520cd5b37e74e19fdb369c8d676a04dce8a19457497ac6686d2bb95d94109c8", "scheduler": "0xe6ba9d6b042440c480fa1c7182be32387db6e90281e82f37398d3f98f63f098a", - "snark_wrapper": "0x14f97b81e54b35fe673d8708cc1a19e1ea5b5e348e12d31e39824ed4f42bbca2" + "snark_wrapper": "0x14f97b81e54b35fe673d8708cc1a19e1ea5b5e348e12d31e39824ed4f42bbca2", + "fflonk_snark_wrapper": "0x560b19cfd6bcf1049c6409c18d81db288ab7639db080ed3b48df17ddfbcc4666" } \ No newline at end of file diff --git a/prover/data/keys/compression_wrapper_setup_data.bin b/prover/data/keys/compression_wrapper_setup_data.bin new file mode 100644 index 000000000000..79570479942b Binary files /dev/null and b/prover/data/keys/compression_wrapper_setup_data.bin differ diff --git a/prover/data/keys/fflonk_verification_snark_key.json b/prover/data/keys/fflonk_verification_snark_key.json new file mode 100644 index 000000000000..1a3e574087f9 --- /dev/null +++ b/prover/data/keys/fflonk_verification_snark_key.json @@ -0,0 +1,100 @@ +{ + "n": 8388607, + "c0": { + "x": [ + 567544074442165672, + 13354717851181412284, + 3162323342193286480, + 2325730709376302348 + ], + "y": [ + 6823582351851933504, + 10833859904006380911, + 14065230796268133554, + 2923459656706414695 + ], + "infinity": false + }, + "num_inputs": 1, + "num_state_polys": 3, + "num_witness_polys": 0, + "total_lookup_entries_length": 0, + "non_residues": [ + [ + 5, + 0, + 0, + 0 + ], + [ + 7, + 0, + 0, + 0 + ] + ], + "g2_elements": [ + { + "x": { + "c0": [ + 5106727233969649389, + 7440829307424791261, + 4785637993704342649, + 1729627375292849782 + ], + "c1": [ + 10945020018377822914, + 17413811393473931026, + 8241798111626485029, + 1841571559660931130 + ] + }, + "y": { + "c0": [ + 5541340697920699818, + 16416156555105522555, + 5380518976772849807, + 1353435754470862315 + ], + "c1": [ + 6173549831154472795, + 13567992399387660019, + 17050234209342075797, + 650358724130500725 + ] + }, + "infinity": false + }, + { + "x": { + "c0": [ + 9089143573911733168, + 11482283522806384523, + 13585589533905622862, + 79029415676722370 + ], + "c1": [ + 5692040832573735873, + 16884514497384809355, + 16717166481813659368, + 2742131088506155463 + ] + }, + "y": { + "c0": [ + 9604638503594647125, + 1289961608472612514, + 6217038149984805214, + 2521661352385209130 + ], + "c1": [ + 17168069778630926308, + 11309277837895768996, + 15154989611154567813, + 359271377050603491 + ] + }, + "infinity": false + } + ] +} \ No newline at end of file diff --git a/prover/data/keys/finalization_hints_compression_1.bin b/prover/data/keys/finalization_hints_compression_1.bin new file mode 100644 index 000000000000..8f5cadc55c57 Binary files /dev/null and b/prover/data/keys/finalization_hints_compression_1.bin differ diff --git a/prover/data/keys/finalization_hints_compression_2.bin b/prover/data/keys/finalization_hints_compression_2.bin new file mode 100644 index 000000000000..c6a4253d81e6 Binary files /dev/null and b/prover/data/keys/finalization_hints_compression_2.bin differ diff --git a/prover/data/keys/finalization_hints_compression_3.bin b/prover/data/keys/finalization_hints_compression_3.bin new file mode 100644 index 000000000000..ef3f24e18c23 Binary files /dev/null and b/prover/data/keys/finalization_hints_compression_3.bin differ diff --git a/prover/data/keys/finalization_hints_compression_4.bin b/prover/data/keys/finalization_hints_compression_4.bin new file mode 100644 index 000000000000..ca6c08bab1f1 Binary files /dev/null and b/prover/data/keys/finalization_hints_compression_4.bin differ diff --git a/prover/data/keys/finalization_hints_compression_wrapper_5.bin b/prover/data/keys/finalization_hints_compression_wrapper_5.bin new file mode 100644 index 000000000000..cb61da940e2a Binary files /dev/null and b/prover/data/keys/finalization_hints_compression_wrapper_5.bin differ diff --git a/prover/data/keys/verification_compression_1_key.json b/prover/data/keys/verification_compression_1_key.json new file mode 100644 index 000000000000..3de9e823d17b --- /dev/null +++ b/prover/data/keys/verification_compression_1_key.json @@ -0,0 +1,262 @@ +{ + "CompressionMode1Circuit": { + "fixed_parameters": { + "parameters": { + "num_columns_under_copy_permutation": 52, + "num_witness_columns": 78, + "num_constant_columns": 4, + "max_allowed_constraint_degree": 8 + }, + "lookup_parameters": "NoLookup", + "domain_size": 65536, + "total_tables_len": 0, + "public_inputs_locations": [ + [ + 0, + 43116 + ], + [ + 1, + 43116 + ], + [ + 2, + 43116 + ], + [ + 3, + 43116 + ] + ], + "extra_constant_polys_for_selectors": 4, + "table_ids_column_idxes": [], + "quotient_degree": 8, + "selectors_placement": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 1, + "num_constants": 0, + "degree": 7, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "Fork": { + "left": { + "Fork": { + "left": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 4, + "num_constants": 4, + "degree": 3, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "Fork": { + "left": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 2, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 6, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + } + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 5, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 7, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + } + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 9, + "num_constants": 4, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 0, + "num_constants": 4, + "degree": 1, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 3, + "num_constants": 2, + "degree": 3, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 8, + "num_constants": 0, + "degree": 0, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + } + } + }, + "fri_lde_factor": 32, + "cap_size": 16 + }, + "setup_merkle_tree_cap": [ + [ + 18429053439012828355, + 13569717100398864647, + 5674934326174107161, + 17602965228088658523 + ], + [ + 1853596005538808278, + 4863986522266180298, + 1446747858708973345, + 6556557904065432671 + ], + [ + 15389763462077761347, + 347990863686799186, + 9600431685918762723, + 18230110007683373373 + ], + [ + 4488979291903240149, + 15827713959121695389, + 5212372431509901484, + 15330056117710268303 + ], + [ + 2154621009093329369, + 2697922564969508975, + 8553713447457143603, + 11909287098676194610 + ], + [ + 17675899931204043754, + 1900641380227488316, + 13799770936458315711, + 16155696965522802314 + ], + [ + 4325071727231912895, + 15495124842543512517, + 7693387508183911518, + 2229191662604882855 + ], + [ + 12528623798638620709, + 7099783078856962509, + 1026199882135084179, + 7487829827063298337 + ], + [ + 17775767559834649815, + 11648203906640999220, + 18372230812591541111, + 2380029132644171876 + ], + [ + 17282415096853816692, + 7048528242178291549, + 1168458073834679094, + 4050365242852861872 + ], + [ + 12458945294827240519, + 9750085849866836452, + 10571283035096727478, + 296889776702427073 + ], + [ + 3087401981646414061, + 5145016559209358338, + 198041048326501493, + 16681321004258095323 + ], + [ + 15873896825395209700, + 17464513449028297769, + 6391802199611869536, + 24117562251396832 + ], + [ + 5930377685985813311, + 11344757707146885659, + 17036003029203547492, + 15372566160771512018 + ], + [ + 3165044285750289057, + 15764455157826377125, + 729334742516289605, + 8335221493745507200 + ], + [ + 318679242859206967, + 16131519447675179661, + 1921616860721123326, + 9785286945407043240 + ] + ] + } +} \ No newline at end of file diff --git a/prover/data/keys/verification_compression_2_key.json b/prover/data/keys/verification_compression_2_key.json new file mode 100644 index 000000000000..6110bba910d2 --- /dev/null +++ b/prover/data/keys/verification_compression_2_key.json @@ -0,0 +1,275 @@ +{ + "CompressionMode2Circuit": { + "fixed_parameters": { + "parameters": { + "num_columns_under_copy_permutation": 56, + "num_witness_columns": 74, + "num_constant_columns": 4, + "max_allowed_constraint_degree": 8 + }, + "lookup_parameters": "NoLookup", + "domain_size": 8192, + "total_tables_len": 0, + "public_inputs_locations": [ + [ + 0, + 6733 + ], + [ + 1, + 6733 + ], + [ + 2, + 6733 + ], + [ + 3, + 6733 + ] + ], + "extra_constant_polys_for_selectors": 4, + "table_ids_column_idxes": [], + "quotient_degree": 8, + "selectors_placement": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 2, + "num_constants": 0, + "degree": 7, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "Fork": { + "left": { + "Fork": { + "left": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 5, + "num_constants": 4, + "degree": 3, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "Fork": { + "left": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 1, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 6, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + } + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 3, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 7, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + } + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 10, + "num_constants": 4, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 8, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 9, + "num_constants": 0, + "degree": 0, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + } + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 4, + "num_constants": 2, + "degree": 3, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 0, + "num_constants": 4, + "degree": 1, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + } + } + }, + "fri_lde_factor": 512, + "cap_size": 16 + }, + "setup_merkle_tree_cap": [ + [ + 547951636004245258, + 2067145936569319297, + 17315326678965070615, + 9012275275825325303 + ], + [ + 2486396189205338767, + 5385179748876990489, + 12789897155193748843, + 7497933664242847399 + ], + [ + 13702746436389342903, + 9589251880490084074, + 13207771356722054410, + 18277427829245158207 + ], + [ + 4132253692687914984, + 18227617432180132982, + 15881065677296839946, + 1403286368390823633 + ], + [ + 10537224762035068222, + 6013042199447780632, + 4527978597574086909, + 3232268373890188602 + ], + [ + 2586162944092407317, + 10215063509965051427, + 2471146708845362031, + 2843440288814318700 + ], + [ + 13819482850499157207, + 16859612470974380629, + 12731935288150853121, + 2902152945695153589 + ], + [ + 9392752661572461801, + 18377486933710861607, + 16200620130393023183, + 8365721844043961790 + ], + [ + 13954020715669265948, + 16716522360195023699, + 5205834515171426098, + 956788140632831896 + ], + [ + 3827733001679131898, + 17013298671136301019, + 3148453751188517867, + 16820158206874288178 + ], + [ + 2520856291381872645, + 4479900374678830382, + 13546063785562157656, + 3382667115615401371 + ], + [ + 15571586947246471933, + 17916455524698235528, + 4478607733734426679, + 12215920239082917056 + ], + [ + 12759564984587008435, + 5665565051416464627, + 4275508608287240845, + 7137116798231081511 + ], + [ + 5980650793630714101, + 9419587808931370936, + 7668041611691340219, + 1071524060976592787 + ], + [ + 8785315220105920748, + 14191148990050265889, + 8665763888918223523, + 10691214928896807830 + ], + [ + 16389667087475658615, + 7098223971082400278, + 3821718345101781981, + 17410025916491040451 + ] + ] + } +} \ No newline at end of file diff --git a/prover/data/keys/verification_compression_3_key.json b/prover/data/keys/verification_compression_3_key.json new file mode 100644 index 000000000000..63bcbca918d1 --- /dev/null +++ b/prover/data/keys/verification_compression_3_key.json @@ -0,0 +1,275 @@ +{ + "CompressionMode3Circuit": { + "fixed_parameters": { + "parameters": { + "num_columns_under_copy_permutation": 68, + "num_witness_columns": 62, + "num_constant_columns": 4, + "max_allowed_constraint_degree": 8 + }, + "lookup_parameters": "NoLookup", + "domain_size": 4096, + "total_tables_len": 0, + "public_inputs_locations": [ + [ + 0, + 3921 + ], + [ + 1, + 3921 + ], + [ + 2, + 3921 + ], + [ + 3, + 3921 + ] + ], + "extra_constant_polys_for_selectors": 4, + "table_ids_column_idxes": [], + "quotient_degree": 8, + "selectors_placement": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 2, + "num_constants": 0, + "degree": 7, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "Fork": { + "left": { + "Fork": { + "left": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 5, + "num_constants": 4, + "degree": 3, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "Fork": { + "left": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 1, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 6, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + } + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 3, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 7, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + } + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 10, + "num_constants": 4, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 8, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 9, + "num_constants": 0, + "degree": 0, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + } + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 4, + "num_constants": 2, + "degree": 3, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 0, + "num_constants": 4, + "degree": 1, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + } + } + }, + "fri_lde_factor": 1024, + "cap_size": 16 + }, + "setup_merkle_tree_cap": [ + [ + 10641025459109778062, + 11883023202620503830, + 1683460580494782039, + 519148484945527748 + ], + [ + 16854836347499347615, + 303914895048281273, + 8827365744032766288, + 7504886056916538809 + ], + [ + 18314198719448317357, + 10244100031050759980, + 9715483427672900470, + 13743747809877920521 + ], + [ + 1369713858293079339, + 2549296113044324317, + 10668787197724003505, + 13374818625902068059 + ], + [ + 11103822364554965998, + 1026596418533733662, + 11884006841460801711, + 16731940920918762822 + ], + [ + 8630324660886613970, + 15367922833873963141, + 538631244507362153, + 7257912375828853679 + ], + [ + 9919593341926293968, + 3835923795731948402, + 11747327108631657899, + 16458305757432722328 + ], + [ + 2324222966121258034, + 7413735041546781516, + 3485204485068670103, + 13438812829186206067 + ], + [ + 14474408113900929346, + 18061817840123336299, + 13649805566841328142, + 7129805169327250752 + ], + [ + 7300284926102090815, + 9725670656634972183, + 8151388754725946636, + 16128844202426193104 + ], + [ + 14707729241338825087, + 3836468945858242082, + 16768198593546824923, + 14062570092263697929 + ], + [ + 14327921344401839882, + 6479671009164937102, + 13089063982746955768, + 2683374136101896185 + ], + [ + 14787507835189907449, + 6738567890582174761, + 16728637974735308667, + 537766695323716501 + ], + [ + 8795483109816567655, + 14842674875555441461, + 11332449659964817297, + 4865859390541196365 + ], + [ + 11192585970910716125, + 3048970808099494060, + 7684470944992674010, + 9304044469675055850 + ], + [ + 5655924464102745207, + 8506077190272738679, + 8512156535337592685, + 15415747564657306809 + ] + ] + } +} \ No newline at end of file diff --git a/prover/data/keys/verification_compression_4_key.json b/prover/data/keys/verification_compression_4_key.json new file mode 100644 index 000000000000..5bd28e4d6d6b --- /dev/null +++ b/prover/data/keys/verification_compression_4_key.json @@ -0,0 +1,1741 @@ +{ + "CompressionMode4Circuit": { + "fixed_parameters": { + "parameters": { + "num_columns_under_copy_permutation": 48, + "num_witness_columns": 0, + "num_constant_columns": 4, + "max_allowed_constraint_degree": 8 + }, + "lookup_parameters": "NoLookup", + "domain_size": 32768, + "total_tables_len": 0, + "public_inputs_locations": [ + [ + 0, + 31025 + ], + [ + 1, + 31025 + ], + [ + 2, + 31025 + ], + [ + 3, + 31025 + ] + ], + "extra_constant_polys_for_selectors": 4, + "table_ids_column_idxes": [], + "quotient_degree": 8, + "selectors_placement": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 4, + "num_constants": 1, + "degree": 7, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "Fork": { + "left": { + "Fork": { + "left": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 7, + "num_constants": 4, + "degree": 3, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "Fork": { + "left": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 1, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 8, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + } + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 5, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 9, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + } + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 12, + "num_constants": 4, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "Fork": { + "left": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 10, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 3, + "num_constants": 0, + "degree": 1, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 11, + "num_constants": 0, + "degree": 0, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + }, + "right": { + "GateOnly": { + "gate_idx": 2, + "num_constants": 0, + "degree": 1, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + } + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 6, + "num_constants": 2, + "degree": 3, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 0, + "num_constants": 4, + "degree": 1, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + } + } + }, + "fri_lde_factor": 1024, + "cap_size": 256 + }, + "setup_merkle_tree_cap": [ + [ + 4079970138244939135, + 8104423815789893989, + 13632023733358255593, + 13346032064987220184 + ], + [ + 12809474467971181399, + 17625072709782170540, + 6594064732490183681, + 8714625183861721175 + ], + [ + 7171332554251640845, + 18284102552959382973, + 3637671217742590741, + 16765711635591410580 + ], + [ + 763060458426938791, + 16159161330183244037, + 2533596966746622429, + 13441156130846388257 + ], + [ + 5525639466278377590, + 11073269405581050439, + 4833809564449931762, + 9314656237570540457 + ], + [ + 1137979745697828455, + 14966651582384421379, + 13384164937770371175, + 14074716572336098280 + ], + [ + 11906323633157650458, + 1175046947414337453, + 4283188400738641426, + 13792950671402095073 + ], + [ + 9310952691940114113, + 4820182619662404377, + 9479969369442954044, + 8512369778696933060 + ], + [ + 16946138649176650488, + 9475913097060757863, + 6608972026504748865, + 7215353463715689998 + ], + [ + 349222139041408316, + 1507489261015035841, + 7596560681014222842, + 8808235055298411214 + ], + [ + 8007370340350072341, + 2549612240734498963, + 105233771877650291, + 8758305155554767568 + ], + [ + 17190433766023179459, + 1755290160765045579, + 5619893747453895498, + 9139477571875211116 + ], + [ + 15755591792726495281, + 17501027650687476798, + 5579351800673089158, + 5931628352091930640 + ], + [ + 7269556889579729096, + 8636006399519326592, + 15556402257631967994, + 12423945489648480054 + ], + [ + 6411602498376025591, + 16377643789139599240, + 1264958035077382258, + 16706608130239118866 + ], + [ + 14246313207191082462, + 2201136836754342130, + 12301078636732201867, + 10991169525653220176 + ], + [ + 2101214821629968022, + 11996351959015322539, + 15461759537099893272, + 5820786797852667153 + ], + [ + 10546547765646585412, + 16670337245061195679, + 14026017154393171841, + 15865302123450709636 + ], + [ + 14546229884213013754, + 1736742091912698149, + 9563343697509131991, + 15957923614096898715 + ], + [ + 10053685874691243725, + 4837706724113512400, + 2806343138575002644, + 1217140278849814125 + ], + [ + 1445801437405723985, + 16370378782744105412, + 14937074551650631907, + 9349528097788576916 + ], + [ + 313624596753562026, + 2737902703720676400, + 1491628534561577719, + 4958865646973460786 + ], + [ + 4749220647213961766, + 1523283588343260013, + 14435216093380418825, + 12058673416937256217 + ], + [ + 12221430523773573392, + 2119312783391782040, + 113666136908336034, + 5557001496562966971 + ], + [ + 8943540790257615175, + 15963411684352909178, + 12833466372967679781, + 16755820399299554647 + ], + [ + 10568513175105063273, + 8152439411055527457, + 13191469024927433668, + 16583335250317103083 + ], + [ + 8728976170665901948, + 12047344511237318236, + 2665537844838432218, + 17220904479682973198 + ], + [ + 9924606303320583729, + 15168541434821629608, + 15267127988736394576, + 4612730729137963542 + ], + [ + 15187295020445613202, + 10979580190616738578, + 2487576517666265788, + 7799526392944971411 + ], + [ + 14001553124798608592, + 983427750240831173, + 10498633617369923042, + 15506856636873354247 + ], + [ + 9695584132680310661, + 15058940491468263542, + 16902767176197422459, + 4307070711535476522 + ], + [ + 16170129192711277380, + 15594325905653564554, + 8589261531750893019, + 16380506012444184509 + ], + [ + 1298482137029698068, + 7046350962355653091, + 4851290198964994943, + 9583994567704854822 + ], + [ + 12002196043506075596, + 6568364019768992619, + 2982180816490272604, + 11005221893883916442 + ], + [ + 11195444762924129211, + 4080035169749061493, + 12552903944803877103, + 1737834024116304977 + ], + [ + 14989371064091658414, + 7021573041416327989, + 10313274026717983047, + 12022812057768375145 + ], + [ + 4605818886224729183, + 1445887803225464457, + 10940822604464014966, + 9884898953608657154 + ], + [ + 16595525430044003662, + 4052207436631314262, + 10293047811043558578, + 12338411972889057265 + ], + [ + 17022547446139753073, + 10651710177937554340, + 6940830771318907626, + 6641453047926556761 + ], + [ + 10509711725088536487, + 4962100381463002257, + 770256729671337313, + 5857473086438310769 + ], + [ + 13267845343537121240, + 12321261427265206453, + 7120567552214639265, + 17302478469072029437 + ], + [ + 15157833123384882226, + 8158551777234184706, + 12348570826200339644, + 14734791159756873167 + ], + [ + 3385809684799950973, + 12900259269431347094, + 17672545490781962423, + 8013657472810936941 + ], + [ + 9546288143416776531, + 8356139039634733121, + 17477514712681213981, + 9515108802170635886 + ], + [ + 15455406291521834876, + 18083571768045422071, + 2009769659787731673, + 7263333966403015872 + ], + [ + 61130843037975416, + 18121830552682131571, + 9667884638217866764, + 6932529860678316702 + ], + [ + 15509823136620654552, + 6676934950708893059, + 13351533805402596549, + 14340984679679191575 + ], + [ + 15880919573481609124, + 14836853565796210968, + 15058034487233879726, + 11000215022533975317 + ], + [ + 10611445668418674805, + 9013654201900818768, + 1617123938865368568, + 16484766808972651318 + ], + [ + 13652743593752436493, + 13843264938563223779, + 10417182020840583510, + 16106479734523413326 + ], + [ + 17003899699844258217, + 17283344455088140068, + 17379245612757089745, + 1779134255761065541 + ], + [ + 11263035503709897880, + 1042839549428969974, + 6638626002246118718, + 1733549590874866310 + ], + [ + 13054247239013491523, + 14047141927303128296, + 2417752406294216107, + 5255181314162279551 + ], + [ + 1784021430104795099, + 3912913366054617723, + 8208877227749479136, + 4259205675774136108 + ], + [ + 801501735568309733, + 3220301656144181340, + 6144806934797449899, + 10479314068206076631 + ], + [ + 864619228795552444, + 2705960387071331097, + 15702747436396598972, + 14131926486457006694 + ], + [ + 15349058561965444062, + 16738574548455051915, + 4609208407223910426, + 11352062762791244662 + ], + [ + 16513285945090237658, + 6443875617703638442, + 17271016792575259072, + 426511686464611712 + ], + [ + 13863640462921288570, + 3362196992389213358, + 3576502768827883720, + 49219399301262346 + ], + [ + 14852014958673205840, + 11855705779815876870, + 8141476064801289266, + 15234506534160954104 + ], + [ + 6292328028167907211, + 6280576736728723621, + 1814915348986377963, + 3167789754322444841 + ], + [ + 6093870088272451581, + 12912333461662707605, + 16038365026642624017, + 10037265733136426182 + ], + [ + 5658473063427008398, + 18194712009700816671, + 3316188885192160812, + 15032222957557455487 + ], + [ + 10746739009272326386, + 4381896503060636995, + 13390900032103397758, + 11290296227744685851 + ], + [ + 7946268274905655961, + 12464655577446728520, + 3476152367809517039, + 3103729420470642525 + ], + [ + 15652670185218353632, + 17922284652588341925, + 3502474425690015164, + 3577240886292713575 + ], + [ + 13130871911189865405, + 2598654314674217849, + 6130707868677033708, + 11318789126458218054 + ], + [ + 14442525432094720658, + 10861520212227307580, + 10308956417568414174, + 101391938116250123 + ], + [ + 8015353735581004985, + 11791356411393233202, + 15134704188872104026, + 2916434958525680154 + ], + [ + 17776268955107890735, + 3978578384988358930, + 7512482176825678493, + 4207030036138354730 + ], + [ + 4778990000266723258, + 12646326430153649418, + 15602744563429649630, + 13225673449752707138 + ], + [ + 9874615904187846642, + 785813436574501824, + 7422887093860615814, + 12575067740028803899 + ], + [ + 2168314129068013776, + 5876170257821873353, + 6574425448964925595, + 13006818379253162445 + ], + [ + 18203396842093379784, + 1637929000957737331, + 16472903772026963266, + 10222221849709050007 + ], + [ + 8175241234035594021, + 11131701218615583700, + 2590544239124773213, + 13103205380700956240 + ], + [ + 10265760611171832222, + 10772001381712818941, + 9769892419500727073, + 3757944212165946207 + ], + [ + 12890674101364520820, + 17436315026775313277, + 17685632275460283213, + 11597862884205200021 + ], + [ + 6541476428026208530, + 1572664979326233234, + 7220008363221767753, + 5030515443926464143 + ], + [ + 1736392533925503753, + 4028348047388923757, + 1322644146499193870, + 7899110541856172042 + ], + [ + 824249951832333568, + 3650442342240934725, + 9551872020421810878, + 4459093260544332906 + ], + [ + 4897538583957298940, + 9763535759998548001, + 17962120881583547780, + 16423532894596203353 + ], + [ + 15621981029420175013, + 12716027808121583594, + 5698997410684688521, + 14893034348453337964 + ], + [ + 57123003983559085, + 1764189019842202487, + 12021079431755992353, + 4611397927843211028 + ], + [ + 11271204071286517021, + 11016763947620063917, + 10240257375147160558, + 6936015967868091242 + ], + [ + 13263159746058683924, + 2115544844352440396, + 17037308825725243672, + 15392971905394245550 + ], + [ + 3040132672294734369, + 8799577028392802142, + 4698252977355096983, + 12029143421110018733 + ], + [ + 3367138533962530706, + 11052858577054708144, + 13777717310915519372, + 1118835749836496249 + ], + [ + 18247935773305597594, + 4791613470261596504, + 2831278673598556804, + 13054754323096013606 + ], + [ + 16660028838922677973, + 9396606308613201784, + 10417460426584440111, + 8380249813777095858 + ], + [ + 8666375557464313815, + 6304275044317841466, + 17005733772133350822, + 14343984316653970581 + ], + [ + 6123226050306352446, + 17155936354664339685, + 8617663439980301335, + 15168460408431057703 + ], + [ + 4711490317757564870, + 4007952793500570494, + 1619724888362180342, + 135640370275358583 + ], + [ + 3568489405188009952, + 10063008786740635782, + 3645030669998184283, + 11251876386972219611 + ], + [ + 8493411482257270591, + 2420069605766207080, + 4319637578909518850, + 7366398383772225801 + ], + [ + 10514279907222008963, + 4576784878418470993, + 13703409256143697610, + 12595458216589602418 + ], + [ + 6518196967791403281, + 6267315352755318878, + 17017845178414282191, + 6219869337455185408 + ], + [ + 9419176152740350408, + 7255025946876060056, + 13692775553690785222, + 6482964045212267647 + ], + [ + 10371771524251272238, + 7264554963155886115, + 11851596230763322123, + 9644034659422561803 + ], + [ + 16478128758974022864, + 10586973455001136017, + 10940854718906381238, + 4322569144361190672 + ], + [ + 1408324526595066767, + 8225966379387133915, + 575234437450946120, + 4532159296152332514 + ], + [ + 14713730919085929141, + 8299030584912591200, + 12653081274697230155, + 7281510145820913452 + ], + [ + 13065256168386635886, + 11725981090441231815, + 9241488846717901227, + 2660860847185625194 + ], + [ + 17344786539017984359, + 16667262327893622443, + 2245517842543022928, + 5289295469095289187 + ], + [ + 7712996453163241402, + 13291387059438293554, + 15475873660461985862, + 421113001330390910 + ], + [ + 6600556276994686684, + 15236925279661890975, + 9085425445873596043, + 13489979627098239874 + ], + [ + 16522817509787049424, + 7880119001244729499, + 2065132977854154043, + 13961595284131100852 + ], + [ + 10136466656472241068, + 7462847284592418995, + 5211060891495522982, + 3429812446680794228 + ], + [ + 1290650595638649346, + 13577818566931833714, + 2388552128026682549, + 13062451014076475307 + ], + [ + 6070278064232182539, + 12399409837026713208, + 7006572737093555522, + 15229533042676039053 + ], + [ + 4546934482854074283, + 12178466512696871783, + 1691876649621188863, + 11473100481876466355 + ], + [ + 1236556729692669368, + 5549499687074217624, + 5958432331744161923, + 17960851426383425726 + ], + [ + 11313384441935481196, + 506230122531558484, + 17480105233549292653, + 3497216050489019068 + ], + [ + 14180330000703954943, + 17537654316605413864, + 13893109338811179145, + 12773435230801104558 + ], + [ + 1789329554161917105, + 3821166735342421302, + 492899993274707886, + 12499398353307226422 + ], + [ + 3089012429777109607, + 10341877957962585240, + 7745611914889843192, + 7156440096296115871 + ], + [ + 14047653524331542619, + 14986552290847971271, + 8344707263938736217, + 5768162811052933747 + ], + [ + 3282503115484594392, + 3455102204735354908, + 6152707383721113591, + 17881334209336571790 + ], + [ + 6895592993382091339, + 14944664838702526606, + 14158277091240311047, + 13527182248087302901 + ], + [ + 3709694612749923839, + 2612160447494745836, + 1406956200130224054, + 1366284088614500522 + ], + [ + 9948565747047514924, + 7052268914527763961, + 18019747825808196928, + 14284818641981927036 + ], + [ + 3586214080877747437, + 18259935751422321449, + 7615481956713457290, + 14815795422370035012 + ], + [ + 127402153735286355, + 14056365981282611643, + 13874770993027970720, + 619630456240824192 + ], + [ + 14160230678035047748, + 5889480608083619036, + 7255863117098942211, + 15199656156616971091 + ], + [ + 3095946492180700178, + 4006392168790405864, + 6879209997262175243, + 299198988833119182 + ], + [ + 7324876720724904977, + 16163169761447383767, + 12506750534396872240, + 2471214392724636123 + ], + [ + 9097827375986012190, + 14565705700237004602, + 14313871429102448506, + 11871591868576605558 + ], + [ + 9799079875206163527, + 16651435323107739422, + 12479220145998529239, + 3293893419326195678 + ], + [ + 10308258292354323463, + 12348814193023657478, + 7617037745166680507, + 4395321161975898727 + ], + [ + 5350571522462508856, + 13168312859432101164, + 16051585591307343397, + 14229124174436500603 + ], + [ + 7166265506509230502, + 7161154874163920078, + 8397077088165043439, + 11599821267858973994 + ], + [ + 7480649953471058826, + 10095090134750662786, + 10564643199160392009, + 13520621355659318250 + ], + [ + 10857779123272725120, + 15686674254635154618, + 8867730228951457290, + 10801878621148582310 + ], + [ + 15060256657026761959, + 9661131710054923901, + 672914961534049680, + 12834176932586128630 + ], + [ + 949448556211506716, + 15381404281513795275, + 11155631745566842701, + 2704703395424058389 + ], + [ + 9515248836992226419, + 8107063249314601218, + 7169007343668853680, + 4398533039543530267 + ], + [ + 5048521287079394266, + 469091126174822039, + 15224036421670482877, + 2109812614761568090 + ], + [ + 16374381239073062350, + 1415659237932604676, + 15755278916993952324, + 4477381067900828660 + ], + [ + 5908643369108814128, + 16993840892601214320, + 9745154490046936812, + 12675544964328790510 + ], + [ + 13069705042519055121, + 114347527485448732, + 13607966080279761362, + 3198027414138631154 + ], + [ + 2126201229935790021, + 11762486874095747924, + 4405447136645256490, + 4546150485765128281 + ], + [ + 11517522298498019347, + 9683562397139382420, + 17997189851623366056, + 15075626419278367114 + ], + [ + 17300749044902256514, + 13180322067670835054, + 13510754977375972746, + 16789287824862069583 + ], + [ + 12482184120647536152, + 6673581288163589602, + 12763923036507066435, + 14094147320392535720 + ], + [ + 14259634259170511729, + 4875730172347810212, + 84468584086030163, + 8303744294867418687 + ], + [ + 12134644548742181831, + 8520649738990136053, + 16059641390155564470, + 5416979754786543764 + ], + [ + 2092318536537973522, + 11767101658840205425, + 6426865564773940591, + 14647807617379392454 + ], + [ + 450267335414320409, + 9743488482513949727, + 60939637019009091, + 17766639401038188429 + ], + [ + 10940698167282175513, + 14751185897733548414, + 12951179730146965260, + 10875205992060835228 + ], + [ + 13364210655207872649, + 6433202412249539021, + 9336639704508334838, + 13505754981533474450 + ], + [ + 13696994814871272283, + 4490009507613100808, + 13804331039068475494, + 5468505803402562249 + ], + [ + 4777271447313491592, + 9940020440702119485, + 1101181637482946058, + 644606693604161858 + ], + [ + 15097959041405784257, + 12307130809829041484, + 17258499521253983865, + 10749514694060779271 + ], + [ + 10190208760039486310, + 4226050742652743727, + 8941293745652956008, + 16590522505585423775 + ], + [ + 345192297192706835, + 446809322130030426, + 14301758245246751976, + 9719056934946360728 + ], + [ + 12881116110058824616, + 9527685388634025534, + 11091584611747550280, + 17824266919172201804 + ], + [ + 1574239507079237453, + 8582461342969153012, + 12264251495254783586, + 17637680562426650364 + ], + [ + 10192143269632239849, + 13007991288866360616, + 15140175217087410009, + 12752906480866993968 + ], + [ + 1870988781431107523, + 12976682012942521853, + 16429062848935476734, + 5798003006437035985 + ], + [ + 14584766751103981854, + 17047930049374537599, + 16615811923791215213, + 4382675641211926136 + ], + [ + 2714557854446349417, + 7104188094330759435, + 4252584297915226480, + 8214575447584991866 + ], + [ + 11055975993893155083, + 4263965260378501220, + 14890629048371839452, + 12114106467257211085 + ], + [ + 1696215674801501046, + 2266423673248165355, + 17663731467117251495, + 3131727223950690444 + ], + [ + 9538270027605424981, + 14695627410990929758, + 1100103051852107643, + 7780696685697285282 + ], + [ + 3640909033400638252, + 4685184407249885115, + 1159593584695683466, + 5810155451150284456 + ], + [ + 2142365296746734893, + 15072293834204351367, + 10906328353503930623, + 567086761313849045 + ], + [ + 16792244974449676806, + 5281042885555694958, + 803668749758477336, + 9632569928427671141 + ], + [ + 11458024915503659884, + 12163640565717382175, + 5426693528062973190, + 5318451835514658298 + ], + [ + 17468129298890753615, + 16365877952312079431, + 4255216049796249864, + 17519162521801620751 + ], + [ + 16881958987441626136, + 5348165195536725074, + 1110205049250373278, + 3270960662287149636 + ], + [ + 1226689297335858879, + 5569006707448968175, + 12862213669554513549, + 13476251685033412618 + ], + [ + 17469709307599228055, + 10239286546577328519, + 11089348310818650527, + 16456908862000481769 + ], + [ + 1488822551903623063, + 1027724056630207939, + 17697306299429716060, + 16855149560650760331 + ], + [ + 6973362373999440967, + 10660889882557485296, + 10425405668156759777, + 6301066711999204638 + ], + [ + 414734469595850357, + 14255487988571755338, + 8593074929345797359, + 16605827151888774599 + ], + [ + 16875797800314241514, + 12421815564591930411, + 2652019482537730851, + 6038511721575984408 + ], + [ + 5083130506118840282, + 10236076700696608757, + 89798661707215807, + 11047945556430945234 + ], + [ + 9052849932438286930, + 766869919370273028, + 9513938692410545262, + 9325822678740812785 + ], + [ + 12214954222172122496, + 2137993706327729295, + 9068121284446752470, + 16719368474204358065 + ], + [ + 12846496216910539260, + 14961944612175511231, + 4871177192578157967, + 871092876547424272 + ], + [ + 8432570778385641968, + 16742266319428376459, + 5202631662503988626, + 9179077767480984950 + ], + [ + 6907086971366422845, + 3630230185711868320, + 6363326632303072661, + 2155376917773117715 + ], + [ + 7260111458604834720, + 15869987976273960274, + 5471864801301693834, + 6186332987204233992 + ], + [ + 7579472070725254127, + 4175627325036864033, + 2726864388901619006, + 17182366690618521544 + ], + [ + 10366850615209571638, + 594983328964439422, + 5708701194817491298, + 8320252948121397632 + ], + [ + 7681701787398279771, + 8922827186766353002, + 16390646056989747875, + 16861016347708202354 + ], + [ + 18349539097929417681, + 11011444774390028397, + 14929165998832565332, + 4785028369071377058 + ], + [ + 12474665121325276393, + 6203136048752329670, + 8857782650797383532, + 1205842604249274162 + ], + [ + 4986065786927816995, + 16774907198741044886, + 3781179129421387661, + 10415439284245950953 + ], + [ + 11574881136629381449, + 12379735189792408408, + 16543138864606381298, + 2352837174543239308 + ], + [ + 2755808935111250351, + 11413691641496289631, + 7433067894962399074, + 9263092778396333619 + ], + [ + 510815690565069916, + 1326078112306964442, + 2280931398968953373, + 16372347667232436246 + ], + [ + 13049250986319352420, + 1312888884206484061, + 5191125907416704942, + 12910692959434040696 + ], + [ + 12641131533859353693, + 806990755667531292, + 8339582499246533062, + 15459494525405539126 + ], + [ + 5334506198163160487, + 12788298331318017466, + 3878039519170214619, + 14733573925349283487 + ], + [ + 5190557862976962645, + 13714749928322729293, + 10374841881342744627, + 15288181470367912639 + ], + [ + 16231478233162755783, + 12802076246758748329, + 14761367109514758527, + 14411193599867587859 + ], + [ + 8198731374774297764, + 3230920736551397516, + 11406632512199098782, + 10984385724696684374 + ], + [ + 2230082119129443391, + 15626857176238648658, + 10525636546408036753, + 713830293126230928 + ], + [ + 4947353515945045110, + 14890750024678328507, + 11992121003625623155, + 9247439145474008589 + ], + [ + 2476255618728017726, + 12423839440278091466, + 11131574346213868564, + 15878857548422208415 + ], + [ + 14063080495591128251, + 17832973426635180302, + 16234044432643152520, + 3790040177800561340 + ], + [ + 17654367747593125286, + 14771556851404254590, + 7054247606189603403, + 16389491650139306501 + ], + [ + 16945878684828151504, + 3218677612764542854, + 4129066622553533042, + 12411143505986390453 + ], + [ + 18139421373310678346, + 12565918292252415379, + 15834446535016534449, + 6148063108469358612 + ], + [ + 12292679265601130740, + 13386299384345137465, + 13364501573803460934, + 8733289102497600737 + ], + [ + 6160628888236701076, + 812243480588759160, + 13247424403141713486, + 10099500208290322254 + ], + [ + 10969580462260030094, + 16960852675866882693, + 14194600920049272873, + 2806447904271636378 + ], + [ + 5308612537476412691, + 2017232117327961782, + 4894043882170046108, + 7279530397891640384 + ], + [ + 4144733560007592583, + 5771344498053405563, + 15232642512723560772, + 17432794023851843115 + ], + [ + 13083133801966421336, + 6640909047775641455, + 7780326336877273740, + 3087015496142074629 + ], + [ + 4093431377560277258, + 11212918479165511440, + 8471957796338043904, + 10134266515436065987 + ], + [ + 7717602192687906239, + 16498238127262085325, + 2796866393834457756, + 6080730252731365434 + ], + [ + 15198975112515001105, + 3427384774999580491, + 9100144446909554927, + 12939101842468805683 + ], + [ + 3513270711153070627, + 6760090775854266850, + 2266114679123970134, + 2453164217927145379 + ], + [ + 8454909244339253322, + 3937159550392777548, + 17092850706817714179, + 14355781411083550660 + ], + [ + 14878805576521609961, + 14710363931287834639, + 3026158727470434848, + 664513313042659381 + ], + [ + 8491751794767535837, + 13990906406579930747, + 10128524312616192734, + 11329057191619161908 + ], + [ + 14453858867510385195, + 7990714203132759977, + 5706371533563158927, + 4128865490009717707 + ], + [ + 7793399965923611298, + 13429890700846305668, + 6463577189314693043, + 1403793223780405881 + ], + [ + 14506683092001193039, + 2676502583153744002, + 432387115071868059, + 5324230977146090619 + ], + [ + 5163412501615965388, + 13723489526376938207, + 13122017355634831416, + 9867447233188068220 + ], + [ + 2169005641163984550, + 9186165665928554404, + 17910278673295197365, + 11381918494994166306 + ], + [ + 5758488670302072688, + 18181832326798847807, + 10253561012448568621, + 6796662601196927726 + ], + [ + 15384372095875884299, + 15758325895562962606, + 979979951038690002, + 4884709252008623452 + ], + [ + 9658033725016409161, + 11061216333798295999, + 10656853269529126466, + 10494481123210514991 + ], + [ + 10565302142069456280, + 4482395191206056917, + 1026499487185603956, + 7313927946426328835 + ], + [ + 914075172237814299, + 4712333083011398137, + 5903513285138462152, + 27234332817070790 + ], + [ + 6165097805071238615, + 12405114942064306895, + 644764352603959519, + 9890780672007958877 + ], + [ + 15139300154181340570, + 3763515407393500498, + 747278468332165545, + 12401993133389174873 + ], + [ + 1560524376846745097, + 4692895970840561536, + 8733218268882211058, + 11050746819680980390 + ], + [ + 2481724169828996194, + 13708290945708520871, + 4344699263192501279, + 7140288180697285542 + ], + [ + 296768972336373070, + 10813546555235346490, + 16170115378690748299, + 12802703395795280191 + ], + [ + 14251656741089442088, + 4214370918062569580, + 10032045984805229135, + 10373930023291015419 + ], + [ + 17093829866009459220, + 12859940170163163826, + 18210851741109329458, + 16336121553624015019 + ], + [ + 4407838941860440582, + 11854162025145257857, + 12199975997855699065, + 2502264419023857875 + ], + [ + 12466276041107521420, + 5321886014476179588, + 7215900333286173827, + 6244069735947509039 + ], + [ + 5660993473650802623, + 11420246285415070761, + 4658057095848491886, + 6674509485613885322 + ], + [ + 16443753989364975722, + 553371339109155814, + 6176240530340905521, + 5112633271096324804 + ], + [ + 17344015413911877127, + 17921285748955845167, + 472207513366524064, + 9508903352311585055 + ], + [ + 2373580342727259876, + 17626197481532596235, + 5443748763702275935, + 16239948710647217063 + ], + [ + 1893590215294085348, + 16922448579707654020, + 3562803535149926022, + 5008057946422210179 + ], + [ + 9528486283906265098, + 16540897732900210948, + 7987610981843235045, + 8503796247003141361 + ], + [ + 7151582572260738324, + 8798367050545135378, + 17208414855521381994, + 16950417755338618580 + ], + [ + 16098392335079248174, + 15218667139563807688, + 3579977320329860139, + 5640122365751888962 + ], + [ + 9584075531015381817, + 16275032664923657166, + 13987470479712899701, + 2201274726914907785 + ], + [ + 9927398107804295577, + 5687396867124688978, + 10639332412514046012, + 10390174472889436172 + ], + [ + 7906944927470502930, + 9629467849018808831, + 16716405557811073978, + 2687565502976952246 + ], + [ + 2357326643063601119, + 12372080030488676843, + 17862973568880540528, + 9758076484635237383 + ], + [ + 6955909340644692347, + 9788637714503672561, + 10015565612607022102, + 5622624961359105679 + ], + [ + 8476474886341847071, + 14658488683343597259, + 14961921379651609802, + 14123545985510427091 + ], + [ + 1388357604146037902, + 15713286211316016536, + 5612470285625982657, + 6487364037172184435 + ], + [ + 15189267229737199628, + 6502744762576006736, + 13803864300857374808, + 5415597147102054081 + ], + [ + 11784930967835797340, + 11401415610557072973, + 1534900691166631710, + 4724373879472771719 + ], + [ + 10801273164646452905, + 11959510535773071656, + 13440563277297614072, + 11732355214966685480 + ], + [ + 709242285317259075, + 14093566268118334778, + 17068650979174969466, + 14497803119243527377 + ], + [ + 1887862044793269490, + 8537802901513975848, + 1791222441789963991, + 9563652556460700888 + ] + ] + } +} \ No newline at end of file diff --git a/prover/data/keys/verification_compression_wrapper_5_key.json b/prover/data/keys/verification_compression_wrapper_5_key.json new file mode 100644 index 000000000000..8dd3feeabf37 --- /dev/null +++ b/prover/data/keys/verification_compression_wrapper_5_key.json @@ -0,0 +1,240 @@ +{ + "CompressionMode5Circuit": { + "fixed_parameters": { + "parameters": { + "num_columns_under_copy_permutation": 28, + "num_witness_columns": 0, + "num_constant_columns": 4, + "max_allowed_constraint_degree": 4 + }, + "lookup_parameters": "NoLookup", + "domain_size": 131072, + "total_tables_len": 0, + "public_inputs_locations": [ + [ + 0, + 102321 + ], + [ + 1, + 102321 + ], + [ + 2, + 102321 + ], + [ + 3, + 102321 + ] + ], + "extra_constant_polys_for_selectors": 4, + "table_ids_column_idxes": [], + "quotient_degree": 8, + "selectors_placement": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 4, + "num_constants": 1, + "degree": 7, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "Fork": { + "left": { + "Fork": { + "left": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 7, + "num_constants": 4, + "degree": 3, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "Fork": { + "left": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 1, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 8, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + } + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 5, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 9, + "num_constants": 0, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + } + } + }, + "right": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 11, + "num_constants": 4, + "degree": 2, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 0, + "num_constants": 4, + "degree": 1, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + }, + "right": { + "Fork": { + "left": { + "Fork": { + "left": { + "Fork": { + "left": { + "GateOnly": { + "gate_idx": 6, + "num_constants": 2, + "degree": 3, + "needs_selector": true, + "is_lookup": false + } + }, + "right": { + "GateOnly": { + "gate_idx": 10, + "num_constants": 0, + "degree": 0, + "needs_selector": true, + "is_lookup": false + } + } + } + }, + "right": { + "GateOnly": { + "gate_idx": 3, + "num_constants": 0, + "degree": 1, + "needs_selector": true, + "is_lookup": false + } + } + } + }, + "right": { + "GateOnly": { + "gate_idx": 2, + "num_constants": 0, + "degree": 1, + "needs_selector": true, + "is_lookup": false + } + } + } + } + } + } + } + }, + "fri_lde_factor": 512, + "cap_size": 8 + }, + "setup_merkle_tree_cap": [ + [ + 16914330110517127429, + 16187587722999224490, + 18023818126147572005, + 2874604292345707728 + ], + [ + 16768425182336866443, + 12214564422923037261, + 13582724864735257774, + 1643211286062672867 + ], + [ + 15218535791823658828, + 14934144541713644491, + 5667321981618564549, + 961076974096461270 + ], + [ + 12538243484307626811, + 154885234119673688, + 6664593122905080257, + 3057958811251130407 + ], + [ + 12286013330322000138, + 5761148084208728264, + 2870132557697656188, + 1515812049810917361 + ], + [ + 12416599860285890728, + 16995984316626848023, + 6201310732706348436, + 3434944201786144260 + ], + [ + 2716626386491435001, + 128784567533803364, + 15547067112370735343, + 1561596902164897368 + ], + [ + 8739964537157479045, + 17599924720345455572, + 12386657679573206086, + 835122317104749492 + ] + ] + } +} \ No newline at end of file diff --git a/prover/data/keys/snark_verification_scheduler_key.json b/prover/data/keys/verification_snark_key.json similarity index 100% rename from prover/data/keys/snark_verification_scheduler_key.json rename to prover/data/keys/verification_snark_key.json diff --git a/zkstack_cli/crates/zkstack/completion/_zkstack.zsh b/zkstack_cli/crates/zkstack/completion/_zkstack.zsh index 7a03ea3c9ffc..f372a7f8ea3d 100644 --- a/zkstack_cli/crates/zkstack/completion/_zkstack.zsh +++ b/zkstack_cli/crates/zkstack/completion/_zkstack.zsh @@ -82,7 +82,9 @@ in-file\:"Specify file with wallets"))' \ '--base-token-price-denominator=[Base token denominator]:BASE_TOKEN_PRICE_DENOMINATOR:_default' \ '--set-as-default=[Set as default chain]' \ '--evm-emulator=[Enable EVM emulator]' \ +'--update-submodules=[Whether to update git submodules of repo]:UPDATE_SUBMODULES:(true false)' \ '--start-containers=[Start reth and postgres containers after creation]' \ +'--update-submodules=[]:UPDATE_SUBMODULES:(true false)' \ '--chain=[Chain to use]:CHAIN:_default' \ '--legacy-bridge[]' \ '-v[Verbose mode]' \ @@ -130,6 +132,7 @@ _arguments "${_arguments_options[@]}" : \ '--server-db-name=[Server database name]:SERVER_DB_NAME:_default' \ '-o+[Enable Grafana]' \ '--observability=[Enable Grafana]' \ +'--update-submodules=[]:UPDATE_SUBMODULES:(true false)' \ '--chain=[Chain to use]:CHAIN:_default' \ '--resume[]' \ '-d[]' \ @@ -243,6 +246,7 @@ in-file\:"Specify file with wallets"))' \ '--base-token-price-denominator=[Base token denominator]:BASE_TOKEN_PRICE_DENOMINATOR:_default' \ '--set-as-default=[Set as default chain]' \ '--evm-emulator=[Enable EVM emulator]' \ +'--update-submodules=[Whether to update git submodules of repo]:UPDATE_SUBMODULES:(true false)' \ '--chain=[Chain to use]:CHAIN:_default' \ '--legacy-bridge[]' \ '-v[Verbose mode]' \ @@ -284,6 +288,7 @@ _arguments "${_arguments_options[@]}" : \ '--server-db-name=[Server database name]:SERVER_DB_NAME:_default' \ '--deploy-paymaster=[]' \ '--l1-rpc-url=[L1 RPC URL]:L1_RPC_URL:_default' \ +'--update-submodules=[]:UPDATE_SUBMODULES:(true false)' \ '--chain=[Chain to use]:CHAIN:_default' \ '--resume[]' \ '-d[]' \ @@ -1442,6 +1447,7 @@ _arguments "${_arguments_options[@]}" : \ _arguments "${_arguments_options[@]}" : \ '--version=[]:VERSION:_default' \ '--snark-wrapper=[]:SNARK_WRAPPER:_default' \ +'--fflonk-snark-wrapper=[]:FFLONK_SNARK_WRAPPER:_default' \ '--chain=[Chain to use]:CHAIN:_default' \ '--default[]' \ '-v[Verbose mode]' \ @@ -1903,6 +1909,7 @@ _arguments "${_arguments_options[@]}" : \ '--bellman-cuda=[]' \ '--setup-compressor-key=[]' \ '--path=[]:PATH:_default' \ +'--compressor-type=[]:COMPRESSOR_TYPE:(fflonk plonk)' \ '--region=[]:REGION:(us europe asia)' \ '--mode=[]:MODE:(download generate)' \ '--setup-keys=[]' \ @@ -1948,6 +1955,7 @@ _arguments "${_arguments_options[@]}" : \ '--heavy-wvg-count=[]:HEAVY_WVG_COUNT:_default' \ '-m+[]:MAX_ALLOCATION:_default' \ '--max-allocation=[]:MAX_ALLOCATION:_default' \ +'--mode=[]:MODE:(fflonk plonk)' \ '--docker=[]:DOCKER:(true false)' \ '--tag=[]:TAG:_default' \ '--chain=[Chain to use]:CHAIN:_default' \ @@ -1973,6 +1981,7 @@ _arguments "${_arguments_options[@]}" : \ (compressor-keys) _arguments "${_arguments_options[@]}" : \ '--path=[]:PATH:_default' \ +'--compressor-type=[]:COMPRESSOR_TYPE:(fflonk plonk)' \ '--chain=[Chain to use]:CHAIN:_default' \ '-v[Verbose mode]' \ '--verbose[Verbose mode]' \ diff --git a/zkstack_cli/crates/zkstack/completion/zkstack.fish b/zkstack_cli/crates/zkstack/completion/zkstack.fish index f25707a32d95..834ced01b662 100644 --- a/zkstack_cli/crates/zkstack/completion/zkstack.fish +++ b/zkstack_cli/crates/zkstack/completion/zkstack.fish @@ -74,7 +74,9 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_se complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from create" -l base-token-price-denominator -d 'Base token denominator' -r complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from create" -l set-as-default -d 'Set as default chain' -r -f -a "{true\t'',false\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from create" -l evm-emulator -d 'Enable EVM emulator' -r -f -a "{true\t'',false\t''}" +complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from create" -l update-submodules -d 'Whether to update git submodules of repo' -r -f -a "{true\t'',false\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from create" -l start-containers -d 'Start reth and postgres containers after creation' -r -f -a "{true\t'',false\t''}" +complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from create" -l update-submodules -r -f -a "{true\t'',false\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from create" -l chain -d 'Chain to use' -r complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from create" -l legacy-bridge complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from create" -s v -l verbose -d 'Verbose mode' @@ -106,6 +108,7 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_se complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -l server-db-url -d 'Server database url without database name' -r complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -l server-db-name -d 'Server database name' -r complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -s o -l observability -d 'Enable Grafana' -r -f -a "{true\t'',false\t''}" +complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -l update-submodules -r -f -a "{true\t'',false\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -l chain -d 'Chain to use' -r complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -l resume complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -s d -l dont-drop @@ -160,6 +163,7 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_s complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from create" -l base-token-price-denominator -d 'Base token denominator' -r complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from create" -l set-as-default -d 'Set as default chain' -r -f -a "{true\t'',false\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from create" -l evm-emulator -d 'Enable EVM emulator' -r -f -a "{true\t'',false\t''}" +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from create" -l update-submodules -d 'Whether to update git submodules of repo' -r -f -a "{true\t'',false\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from create" -l chain -d 'Chain to use' -r complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from create" -l legacy-bridge complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from create" -s v -l verbose -d 'Verbose mode' @@ -186,6 +190,7 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_s complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -l server-db-name -d 'Server database name' -r complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -l deploy-paymaster -r -f -a "{true\t'',false\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -l l1-rpc-url -d 'L1 RPC URL' -r +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -l update-submodules -r -f -a "{true\t'',false\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -l chain -d 'Chain to use' -r complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -l resume complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -s d -l dont-drop @@ -486,6 +491,7 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_ complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from init" -l bellman-cuda -r -f -a "{true\t'',false\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from init" -l setup-compressor-key -r -f -a "{true\t'',false\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from init" -l path -r +complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from init" -l compressor-type -r -f -a "{fflonk\t'',plonk\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from init" -l region -r -f -a "{us\t'',europe\t'',asia\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from init" -l mode -r -f -a "{download\t'',generate\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from init" -l setup-keys -r -f -a "{true\t'',false\t''}" @@ -514,6 +520,7 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_ complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from run" -s l -l light-wvg-count -r complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from run" -s h -l heavy-wvg-count -r complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from run" -s m -l max-allocation -r +complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from run" -l mode -r -f -a "{fflonk\t'',plonk\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from run" -l docker -r -f -a "{true\t'',false\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from run" -l tag -r complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from run" -l chain -d 'Chain to use' -r @@ -527,6 +534,7 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_ complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from init-bellman-cuda" -l ignore-prerequisites -d 'Ignores prerequisites checks' complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from init-bellman-cuda" -s h -l help -d 'Print help' complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from compressor-keys" -l path -r +complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from compressor-keys" -l compressor-type -r -f -a "{fflonk\t'',plonk\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from compressor-keys" -l chain -d 'Chain to use' -r complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from compressor-keys" -s v -l verbose -d 'Verbose mode' complete -c zkstack -n "__fish_zkstack_using_subcommand prover; and __fish_seen_subcommand_from compressor-keys" -l ignore-prerequisites -d 'Ignores prerequisites checks' diff --git a/zkstack_cli/crates/zkstack/completion/zkstack.sh b/zkstack_cli/crates/zkstack/completion/zkstack.sh index 5e4566eba486..dfbc40350eb5 100644 --- a/zkstack_cli/crates/zkstack/completion/zkstack.sh +++ b/zkstack_cli/crates/zkstack/completion/zkstack.sh @@ -1258,7 +1258,7 @@ _zkstack() { return 0 ;; zkstack__chain__create) - opts="-v -h --chain-name --chain-id --prover-mode --wallet-creation --wallet-path --l1-batch-commit-data-generator-mode --base-token-address --base-token-price-nominator --base-token-price-denominator --set-as-default --legacy-bridge --evm-emulator --verbose --chain --ignore-prerequisites --help" + opts="-v -h --chain-name --chain-id --prover-mode --wallet-creation --wallet-path --l1-batch-commit-data-generator-mode --base-token-address --base-token-price-nominator --base-token-price-denominator --set-as-default --legacy-bridge --evm-emulator --update-submodules --verbose --chain --ignore-prerequisites --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -1319,6 +1319,10 @@ _zkstack() { COMPREPLY=($(compgen -W "true false" -- "${cur}")) return 0 ;; + --update-submodules) + COMPREPLY=($(compgen -W "true false" -- "${cur}")) + return 0 + ;; --chain) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -2031,7 +2035,7 @@ _zkstack() { return 0 ;; zkstack__chain__init) - opts="-a -d -v -h --verify --verifier --verifier-url --verifier-api-key --resume --additional-args --server-db-url --server-db-name --dont-drop --deploy-paymaster --l1-rpc-url --no-port-reallocation --dev --verbose --chain --ignore-prerequisites --help configs help" + opts="-a -d -v -h --verify --verifier --verifier-url --verifier-api-key --resume --additional-args --server-db-url --server-db-name --dont-drop --deploy-paymaster --l1-rpc-url --no-port-reallocation --update-submodules --dev --verbose --chain --ignore-prerequisites --help configs help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -2077,6 +2081,10 @@ _zkstack() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --update-submodules) + COMPREPLY=($(compgen -W "true false" -- "${cur}")) + return 0 + ;; --chain) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -4243,7 +4251,7 @@ _zkstack() { return 0 ;; zkstack__dev__prover__insert__version) - opts="-v -h --default --version --snark-wrapper --verbose --chain --ignore-prerequisites --help" + opts="-v -h --default --version --snark-wrapper --fflonk-snark-wrapper --verbose --chain --ignore-prerequisites --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -4257,6 +4265,10 @@ _zkstack() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --fflonk-snark-wrapper) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; --chain) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -4971,7 +4983,7 @@ _zkstack() { return 0 ;; zkstack__ecosystem__create) - opts="-v -h --ecosystem-name --l1-network --link-to-code --chain-name --chain-id --prover-mode --wallet-creation --wallet-path --l1-batch-commit-data-generator-mode --base-token-address --base-token-price-nominator --base-token-price-denominator --set-as-default --legacy-bridge --evm-emulator --start-containers --verbose --chain --ignore-prerequisites --help" + opts="-v -h --ecosystem-name --l1-network --link-to-code --chain-name --chain-id --prover-mode --wallet-creation --wallet-path --l1-batch-commit-data-generator-mode --base-token-address --base-token-price-nominator --base-token-price-denominator --set-as-default --legacy-bridge --evm-emulator --update-submodules --start-containers --update-submodules --verbose --chain --ignore-prerequisites --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -5047,10 +5059,18 @@ _zkstack() { COMPREPLY=($(compgen -W "true false" -- "${cur}")) return 0 ;; + --update-submodules) + COMPREPLY=($(compgen -W "true false" -- "${cur}")) + return 0 + ;; --start-containers) COMPREPLY=($(compgen -W "true false" -- "${cur}")) return 0 ;; + --update-submodules) + COMPREPLY=($(compgen -W "true false" -- "${cur}")) + return 0 + ;; --chain) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -5161,7 +5181,7 @@ _zkstack() { return 0 ;; zkstack__ecosystem__init) - opts="-a -d -o -v -h --deploy-erc20 --deploy-ecosystem --ecosystem-contracts-path --l1-rpc-url --verify --verifier --verifier-url --verifier-api-key --resume --additional-args --deploy-paymaster --server-db-url --server-db-name --dont-drop --ecosystem-only --dev --observability --no-port-reallocation --verbose --chain --ignore-prerequisites --help" + opts="-a -d -o -v -h --deploy-erc20 --deploy-ecosystem --ecosystem-contracts-path --l1-rpc-url --verify --verifier --verifier-url --verifier-api-key --resume --additional-args --deploy-paymaster --server-db-url --server-db-name --dont-drop --ecosystem-only --dev --observability --no-port-reallocation --update-submodules --verbose --chain --ignore-prerequisites --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -5227,6 +5247,10 @@ _zkstack() { COMPREPLY=($(compgen -W "true false" -- "${cur}")) return 0 ;; + --update-submodules) + COMPREPLY=($(compgen -W "true false" -- "${cur}")) + return 0 + ;; --chain) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -7145,7 +7169,7 @@ _zkstack() { return 0 ;; zkstack__prover__compressor__keys) - opts="-v -h --path --verbose --chain --ignore-prerequisites --help" + opts="-v -h --path --compressor-type --verbose --chain --ignore-prerequisites --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -7155,6 +7179,10 @@ _zkstack() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --compressor-type) + COMPREPLY=($(compgen -W "fflonk plonk" -- "${cur}")) + return 0 + ;; --chain) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -7265,7 +7293,7 @@ _zkstack() { return 0 ;; zkstack__prover__init) - opts="-u -d -v -h --dev --proof-store-dir --bucket-base-url --credentials-file --bucket-name --location --project-id --shall-save-to-public-bucket --public-store-dir --public-bucket-base-url --public-credentials-file --public-bucket-name --public-location --public-project-id --clone --bellman-cuda-dir --bellman-cuda --setup-compressor-key --path --region --mode --setup-keys --setup-database --prover-db-url --prover-db-name --use-default --dont-drop --cloud-type --verbose --chain --ignore-prerequisites --help" + opts="-u -d -v -h --dev --proof-store-dir --bucket-base-url --credentials-file --bucket-name --location --project-id --shall-save-to-public-bucket --public-store-dir --public-bucket-base-url --public-credentials-file --public-bucket-name --public-location --public-project-id --clone --bellman-cuda-dir --bellman-cuda --setup-compressor-key --path --compressor-type --region --mode --setup-keys --setup-database --prover-db-url --prover-db-name --use-default --dont-drop --cloud-type --verbose --chain --ignore-prerequisites --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -7339,6 +7367,10 @@ _zkstack() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --compressor-type) + COMPREPLY=($(compgen -W "fflonk plonk" -- "${cur}")) + return 0 + ;; --region) COMPREPLY=($(compgen -W "us europe asia" -- "${cur}")) return 0 @@ -7417,7 +7449,7 @@ _zkstack() { return 0 ;; zkstack__prover__run) - opts="-l -h -m -v -h --component --round --threads --max-allocation --light-wvg-count --heavy-wvg-count --max-allocation --docker --tag --verbose --chain --ignore-prerequisites --help" + opts="-l -h -m -v -h --component --round --threads --max-allocation --light-wvg-count --heavy-wvg-count --max-allocation --mode --docker --tag --verbose --chain --ignore-prerequisites --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -7463,6 +7495,10 @@ _zkstack() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --mode) + COMPREPLY=($(compgen -W "fflonk plonk" -- "${cur}")) + return 0 + ;; --docker) COMPREPLY=($(compgen -W "true false" -- "${cur}")) return 0 diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/args/create.rs b/zkstack_cli/crates/zkstack/src/commands/chain/args/create.rs index ec37f9ba0304..5310a46d23c4 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/args/create.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/args/create.rs @@ -70,6 +70,8 @@ pub struct ChainCreateArgs { pub(crate) legacy_bridge: bool, #[arg(long, help = MSG_EVM_EMULATOR_HELP, default_missing_value = "true", num_args = 0..=1)] evm_emulator: Option, + #[clap(long, help = "Whether to update git submodules of repo")] + update_submodules: Option, } impl ChainCreateArgs { @@ -239,6 +241,7 @@ impl ChainCreateArgs { legacy_bridge: self.legacy_bridge, evm_emulator, link_to_code, + update_submodules: self.update_submodules, }) } } @@ -256,6 +259,7 @@ pub struct ChainCreateArgsFinal { pub legacy_bridge: bool, pub evm_emulator: bool, pub link_to_code: String, + pub update_submodules: Option, } #[derive(Debug, Clone, EnumIter, Display, PartialEq, Eq)] diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/args/init/mod.rs b/zkstack_cli/crates/zkstack/src/commands/chain/args/init/mod.rs index a5c7a6890ca1..59810964d2c3 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/args/init/mod.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/args/init/mod.rs @@ -35,6 +35,8 @@ pub struct InitArgs { pub l1_rpc_url: Option, #[clap(long, help = MSG_NO_PORT_REALLOCATION_HELP)] pub no_port_reallocation: bool, + #[clap(long)] + pub update_submodules: Option, #[clap(long, help = MSG_DEV_ARG_HELP)] pub dev: bool, } diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/create.rs b/zkstack_cli/crates/zkstack/src/commands/chain/create.rs index 730c1df8d3f2..367dddd95884 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/create.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/create.rs @@ -76,7 +76,12 @@ pub(crate) fn create_chain_inner( (L2ChainId::from(args.chain_id), None) }; let internal_id = ecosystem_config.list_of_chains().len() as u32; - let link_to_code = resolve_link_to_code(shell, chain_path.clone(), args.link_to_code.clone())?; + let link_to_code = resolve_link_to_code( + shell, + chain_path.clone(), + args.link_to_code.clone(), + args.update_submodules, + )?; let default_genesis_config = GenesisConfig::read_with_base_path( shell, EcosystemConfig::default_configs_path(&link_to_code), diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs b/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs index b582f49cf4a4..a4c21b5bc5d1 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs @@ -59,11 +59,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) { + git::submodule_update(shell, config.link_to_code.clone())?; + } + let args = args.fill_values_with_prompt(&chain_config); logger::note(MSG_SELECTED_CONFIG, logger::object_to_string(&chain_config)); logger::info(msg_initializing_chain("")); - git::submodule_update(shell, config.link_to_code.clone())?; init(&args, shell, &config, &chain_config).await?; diff --git a/zkstack_cli/crates/zkstack/src/commands/dev/commands/fmt.rs b/zkstack_cli/crates/zkstack/src/commands/dev/commands/fmt.rs index ebaf27845e0a..569d2a61294e 100644 --- a/zkstack_cli/crates/zkstack/src/commands/dev/commands/fmt.rs +++ b/zkstack_cli/crates/zkstack/src/commands/dev/commands/fmt.rs @@ -85,6 +85,7 @@ pub struct FmtArgs { pub async fn run(shell: Shell, args: FmtArgs) -> anyhow::Result<()> { let ecosystem = EcosystemConfig::from_file(&shell)?; + shell.set_var("ZKSYNC_USE_CUDA_STUBS", "true"); match args.formatter { None => { let mut tasks = vec![]; diff --git a/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint.rs b/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint.rs index 04955726706f..fa17ef518901 100644 --- a/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint.rs +++ b/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint.rs @@ -32,6 +32,7 @@ pub struct LintArgs { } pub fn run(shell: &Shell, args: LintArgs) -> anyhow::Result<()> { + shell.set_var("ZKSYNC_USE_CUDA_STUBS", "true"); let targets = if args.targets.is_empty() { vec![ Target::Rs, diff --git a/zkstack_cli/crates/zkstack/src/commands/dev/commands/prover/args/insert_version.rs b/zkstack_cli/crates/zkstack/src/commands/dev/commands/prover/args/insert_version.rs index 97e60fb38f8c..7af98c4a7a43 100644 --- a/zkstack_cli/crates/zkstack/src/commands/dev/commands/prover/args/insert_version.rs +++ b/zkstack_cli/crates/zkstack/src/commands/dev/commands/prover/args/insert_version.rs @@ -8,11 +8,14 @@ pub struct InsertVersionArgs { pub version: Option, #[clap(long)] pub snark_wrapper: Option, + #[clap(long)] + pub fflonk_snark_wrapper: Option, } #[derive(Debug)] pub struct InsertVersionArgsFinal { pub snark_wrapper: String, + pub fflonk_snark_wrapper: String, pub version: String, } @@ -21,10 +24,12 @@ impl InsertVersionArgs { self, era_version: String, snark_wrapper: String, + fflonk_snark_wrapper: String, ) -> InsertVersionArgsFinal { if self.default { return InsertVersionArgsFinal { snark_wrapper, + fflonk_snark_wrapper, version: era_version, }; } @@ -41,8 +46,15 @@ impl InsertVersionArgs { .ask() }); + let fflonk_snark_wrapper = self.fflonk_snark_wrapper.unwrap_or_else(|| { + common::Prompt::new("Enter the fflonk snark wrapper of the protocol to insert") + .default(&fflonk_snark_wrapper) + .ask() + }); + InsertVersionArgsFinal { snark_wrapper, + fflonk_snark_wrapper, version, } } diff --git a/zkstack_cli/crates/zkstack/src/commands/dev/commands/prover/info.rs b/zkstack_cli/crates/zkstack/src/commands/dev/commands/prover/info.rs index 84873e931b3e..baf0e6f881cd 100644 --- a/zkstack_cli/crates/zkstack/src/commands/dev/commands/prover/info.rs +++ b/zkstack_cli/crates/zkstack/src/commands/dev/commands/prover/info.rs @@ -21,6 +21,7 @@ pub async fn run(shell: &Shell) -> anyhow::Result<()> { let protocol_version = get_protocol_version(shell, &link_to_prover).await?; let snark_wrapper = get_snark_wrapper(&link_to_prover).await?; + let fflonk_snark_wrapper = get_fflonk_snark_wrapper(&link_to_prover).await?; let prover_url = get_database_url(&chain_config).await?; logger::info(format!( @@ -28,10 +29,11 @@ pub async fn run(shell: &Shell) -> anyhow::Result<()> { =============================== \n Current prover setup information: \n Protocol version: {} \n -Snark wrapper: {} \n +Snark wrapper: {} \n\ +FFLONK Snark wrapper: {} \n Database URL: {}\n ===============================", - protocol_version, snark_wrapper, prover_url + protocol_version, snark_wrapper, fflonk_snark_wrapper, prover_url )); Ok(()) @@ -64,6 +66,23 @@ pub(crate) async fn get_snark_wrapper(link_to_prover: &Path) -> anyhow::Result anyhow::Result { + let path = link_to_prover.join("data/keys/commitments.json"); + let file = fs::File::open(path).expect("Could not find commitments file in zksync-era"); + let json: serde_json::Value = + serde_json::from_reader(file).expect("Could not parse commitments.json"); + + let snark_wrapper = json + .get("fflonk_snark_wrapper") + .expect("Could not find snark_wrapper in commitments.json"); + + let mut snark_wrapper = snark_wrapper.to_string(); + snark_wrapper.pop(); + snark_wrapper.remove(0); + + Ok(snark_wrapper) +} + pub(crate) async fn get_database_url(chain: &ChainConfig) -> anyhow::Result { let prover_url = chain .get_secrets_config()? diff --git a/zkstack_cli/crates/zkstack/src/commands/dev/commands/prover/insert_version.rs b/zkstack_cli/crates/zkstack/src/commands/dev/commands/prover/insert_version.rs index f7bd175f577a..86cd73c926b2 100644 --- a/zkstack_cli/crates/zkstack/src/commands/dev/commands/prover/insert_version.rs +++ b/zkstack_cli/crates/zkstack/src/commands/dev/commands/prover/insert_version.rs @@ -20,13 +20,16 @@ pub async fn run(shell: &Shell, args: InsertVersionArgs) -> anyhow::Result<()> { let version = info::get_protocol_version(shell, &get_link_to_prover(&ecosystem_config)).await?; let snark_wrapper = info::get_snark_wrapper(&get_link_to_prover(&ecosystem_config)).await?; + let fflonk_snark_wrapper = + info::get_fflonk_snark_wrapper(&get_link_to_prover(&ecosystem_config)).await?; let prover_url = info::get_database_url(&chain_config).await?; let InsertVersionArgsFinal { version, snark_wrapper, - } = args.fill_values_with_prompts(version, snark_wrapper); + fflonk_snark_wrapper, + } = args.fill_values_with_prompts(version, snark_wrapper, fflonk_snark_wrapper); let (minor, patch) = info::parse_version(&version)?; @@ -35,7 +38,7 @@ pub async fn run(shell: &Shell, args: InsertVersionArgs) -> anyhow::Result<()> { version, snark_wrapper )); - let cmd = Cmd::new(cmd!(shell, "prover_cli {prover_url} insert-version --version={minor} --patch={patch} --snark-wrapper={snark_wrapper}")); + let cmd = Cmd::new(cmd!(shell, "prover_cli {prover_url} insert-version --version={minor} --patch={patch} --snark-wrapper={snark_wrapper} --fflonk-snark-wrapper={fflonk_snark_wrapper}")); cmd.run()?; logger::info("Done."); diff --git a/zkstack_cli/crates/zkstack/src/commands/ecosystem/args/create.rs b/zkstack_cli/crates/zkstack/src/commands/ecosystem/args/create.rs index 53d9c27be60b..9665516945e0 100644 --- a/zkstack_cli/crates/zkstack/src/commands/ecosystem/args/create.rs +++ b/zkstack_cli/crates/zkstack/src/commands/ecosystem/args/create.rs @@ -32,6 +32,8 @@ pub struct EcosystemCreateArgs { long, help = MSG_START_CONTAINERS_HELP, default_missing_value = "true", num_args = 0..=1 )] pub start_containers: Option, + #[clap(long)] + pub update_submodules: Option, } impl EcosystemCreateArgs { @@ -70,6 +72,7 @@ impl EcosystemCreateArgs { wallet_path: chain.wallet_path.clone(), chain_args: chain, start_containers, + update_submodules: self.update_submodules, }) } } @@ -83,6 +86,7 @@ pub struct EcosystemCreateArgsFinal { pub wallet_path: Option, pub chain_args: ChainCreateArgsFinal, pub start_containers: bool, + pub update_submodules: Option, } impl EcosystemCreateArgsFinal { diff --git a/zkstack_cli/crates/zkstack/src/commands/ecosystem/args/init.rs b/zkstack_cli/crates/zkstack/src/commands/ecosystem/args/init.rs index 09115fd49ba7..9b7ab5abf089 100644 --- a/zkstack_cli/crates/zkstack/src/commands/ecosystem/args/init.rs +++ b/zkstack_cli/crates/zkstack/src/commands/ecosystem/args/init.rs @@ -97,10 +97,14 @@ pub struct EcosystemInitArgs { pub ecosystem_only: bool, #[clap(long, help = MSG_DEV_ARG_HELP)] pub dev: bool, - #[clap(long, short = 'o', help = MSG_OBSERVABILITY_HELP, default_missing_value = "true", num_args = 0..=1)] + #[clap( + long, short = 'o', help = MSG_OBSERVABILITY_HELP, default_missing_value = "true", num_args = 0..=1 + )] pub observability: Option, #[clap(long, help = MSG_NO_PORT_REALLOCATION_HELP)] pub no_port_reallocation: bool, + #[clap(long)] + pub update_submodules: Option, } impl EcosystemInitArgs { diff --git a/zkstack_cli/crates/zkstack/src/commands/ecosystem/create.rs b/zkstack_cli/crates/zkstack/src/commands/ecosystem/create.rs index 203c667ade65..d7c6005cd1aa 100644 --- a/zkstack_cli/crates/zkstack/src/commands/ecosystem/create.rs +++ b/zkstack_cli/crates/zkstack/src/commands/ecosystem/create.rs @@ -53,7 +53,12 @@ fn create(args: EcosystemCreateArgs, shell: &Shell) -> anyhow::Result<()> { let configs_path = create_local_configs_dir(shell, ".")?; - let link_to_code = resolve_link_to_code(shell, shell.current_dir(), args.link_to_code.clone())?; + let link_to_code = resolve_link_to_code( + shell, + shell.current_dir(), + args.link_to_code.clone(), + args.update_submodules, + )?; let spinner = Spinner::new(MSG_CREATING_INITIAL_CONFIGURATIONS_SPINNER); let chain_config = args.chain_config(); diff --git a/zkstack_cli/crates/zkstack/src/commands/ecosystem/init.rs b/zkstack_cli/crates/zkstack/src/commands/ecosystem/init.rs index 7b01abf03b9a..1d110c72fb77 100644 --- a/zkstack_cli/crates/zkstack/src/commands/ecosystem/init.rs +++ b/zkstack_cli/crates/zkstack/src/commands/ecosystem/init.rs @@ -49,7 +49,9 @@ use crate::{ pub async fn run(args: EcosystemInitArgs, shell: &Shell) -> anyhow::Result<()> { let ecosystem_config = EcosystemConfig::from_file(shell)?; - git::submodule_update(shell, ecosystem_config.link_to_code.clone())?; + if args.update_submodules.is_none() || args.update_submodules == Some(true) { + git::submodule_update(shell, ecosystem_config.link_to_code.clone())?; + } let initial_deployment_config = match ecosystem_config.get_initial_deployment_config() { Ok(config) => config, @@ -369,6 +371,7 @@ async fn init_chains( deploy_paymaster, l1_rpc_url: Some(final_init_args.ecosystem.l1_rpc_url.clone()), no_port_reallocation: final_init_args.no_port_reallocation, + update_submodules: init_args.update_submodules, dev: final_init_args.dev, }; let final_chain_init_args = chain_init_args.fill_values_with_prompt(&chain_config); diff --git a/zkstack_cli/crates/zkstack/src/commands/prover/args/compressor_keys.rs b/zkstack_cli/crates/zkstack/src/commands/prover/args/compressor_keys.rs index 095dccf00b38..8adc52740592 100644 --- a/zkstack_cli/crates/zkstack/src/commands/prover/args/compressor_keys.rs +++ b/zkstack_cli/crates/zkstack/src/commands/prover/args/compressor_keys.rs @@ -1,5 +1,6 @@ -use clap::Parser; +use clap::{Parser, ValueEnum}; use common::Prompt; +use strum::EnumIter; use crate::messages::MSG_SETUP_COMPRESSOR_KEY_PATH_PROMPT; @@ -7,6 +8,16 @@ use crate::messages::MSG_SETUP_COMPRESSOR_KEY_PATH_PROMPT; pub struct CompressorKeysArgs { #[clap(long)] pub path: Option, + #[clap(long, default_value = "plonk")] + pub compressor_type: CompressorType, +} + +#[derive(Debug, Clone, ValueEnum, EnumIter, strum::Display, PartialEq, Eq, Default)] +pub enum CompressorType { + Fflonk, + #[default] + Plonk, + All, } impl CompressorKeysArgs { @@ -17,6 +28,9 @@ impl CompressorKeysArgs { .ask() }); - CompressorKeysArgs { path: Some(path) } + CompressorKeysArgs { + path: Some(path), + ..self + } } } diff --git a/zkstack_cli/crates/zkstack/src/commands/prover/args/init.rs b/zkstack_cli/crates/zkstack/src/commands/prover/args/init.rs index fab798993025..204cad2c84a8 100644 --- a/zkstack_cli/crates/zkstack/src/commands/prover/args/init.rs +++ b/zkstack_cli/crates/zkstack/src/commands/prover/args/init.rs @@ -360,6 +360,7 @@ impl ProverInitArgs { if self.dev { return Some(CompressorKeysArgs { path: Some(default_path.to_string()), + ..self.compressor_keys_args.clone() }); } diff --git a/zkstack_cli/crates/zkstack/src/commands/prover/args/run.rs b/zkstack_cli/crates/zkstack/src/commands/prover/args/run.rs index 4b3a16a38fca..a356f1874b7a 100644 --- a/zkstack_cli/crates/zkstack/src/commands/prover/args/run.rs +++ b/zkstack_cli/crates/zkstack/src/commands/prover/args/run.rs @@ -4,6 +4,7 @@ use anyhow::anyhow; use clap::{Parser, ValueEnum}; use common::{Prompt, PromptSelect}; use config::ChainConfig; +use serde::{Deserialize, Serialize}; use strum::{EnumIter, IntoEnumIterator}; use crate::{ @@ -33,6 +34,8 @@ pub struct ProverRunArgs { pub fri_prover_args: FriProverRunArgs, #[clap(flatten)] pub circuit_prover_args: CircuitProverArgs, + #[clap(flatten)] + pub compressor_args: CompressorArgs, #[clap(long)] pub docker: Option, #[clap(long)] @@ -87,12 +90,14 @@ impl ProverComponent { pub fn get_application_args(&self, in_docker: bool) -> anyhow::Result> { let mut application_args = vec![]; - if self == &Self::Prover || self == &Self::Compressor || self == &Self::CircuitProver { - if in_docker { - application_args.push("--gpus=all".to_string()); - } else if self != &Self::CircuitProver { - application_args.push("--features=gpu".to_string()); - } + if (self == &Self::Prover || self == &Self::Compressor || self == &Self::CircuitProver) + && in_docker + { + application_args.push("--gpus=all".to_string()); + } + + if self == &Self::Prover { + application_args.push("--features=gpu".to_string()); } Ok(application_args) @@ -189,6 +194,11 @@ impl ProverComponent { )); }; } + Self::Compressor => { + if args.compressor_args.mode == CompressorMode::Fflonk { + additional_args.push("--fflonk=true".to_string()); + } + } _ => {} }; @@ -279,6 +289,30 @@ impl CircuitProverArgs { } } +#[derive(Debug, Clone, Parser, Default)] +pub struct CompressorArgs { + #[clap(long, default_value = "plonk")] + pub mode: CompressorMode, +} + +#[derive( + Default, + Debug, + Clone, + ValueEnum, + EnumIter, + strum::Display, + PartialEq, + Eq, + Deserialize, + Serialize, +)] +pub enum CompressorMode { + Fflonk, + #[default] + Plonk, +} + #[derive(Debug, Clone, Parser, Default)] pub struct FriProverRunArgs { /// Memory allocation limit in bytes (for prover component) @@ -318,6 +352,7 @@ impl ProverRunArgs { witness_vector_generator_args, fri_prover_args: self.fri_prover_args, circuit_prover_args, + compressor_args: self.compressor_args, docker: Some(docker), tag: Some(tag), }) diff --git a/zkstack_cli/crates/zkstack/src/commands/prover/compressor_keys.rs b/zkstack_cli/crates/zkstack/src/commands/prover/compressor_keys.rs index a3d40c957281..ec102d92ea77 100644 --- a/zkstack_cli/crates/zkstack/src/commands/prover/compressor_keys.rs +++ b/zkstack_cli/crates/zkstack/src/commands/prover/compressor_keys.rs @@ -1,12 +1,15 @@ use anyhow::Context; -use common::spinner::Spinner; +use common::{logger, spinner::Spinner}; use config::{get_link_to_prover, EcosystemConfig, GeneralConfig}; use xshell::Shell; -use super::args::compressor_keys::CompressorKeysArgs; -use crate::messages::{ - MSG_CHAIN_NOT_FOUND_ERR, MSG_DOWNLOADING_SETUP_COMPRESSOR_KEY_SPINNER, - MSG_PROOF_COMPRESSOR_CONFIG_NOT_FOUND_ERR, MSG_SETUP_KEY_PATH_ERROR, +use super::args::compressor_keys::{CompressorKeysArgs, CompressorType}; +use crate::{ + consts::{FFLONK_COMPACT_CRS_KEY, FFLONK_CRS_KEY, PLONK_CRS_KEY}, + messages::{ + MSG_CHAIN_NOT_FOUND_ERR, MSG_DOWNLOADING_SETUP_COMPRESSOR_KEY_SPINNER, + MSG_PROOF_COMPRESSOR_CONFIG_NOT_FOUND_ERR, MSG_SETUP_KEY_PATH_ERROR, + }, }; pub(crate) async fn run(shell: &Shell, args: CompressorKeysArgs) -> anyhow::Result<()> { @@ -19,11 +22,56 @@ pub(crate) async fn run(shell: &Shell, args: CompressorKeysArgs) -> anyhow::Resu let default_path = get_default_compressor_keys_path(&ecosystem_config)?; let args = args.fill_values_with_prompt(&default_path); - download_compressor_key( - shell, - &mut general_config, - &args.path.context(MSG_SETUP_KEY_PATH_ERROR)?, - )?; + match args.compressor_type { + CompressorType::Fflonk => { + let path = args.clone().path.context(MSG_SETUP_KEY_PATH_ERROR)?; + + download_compressor_key( + shell, + &mut general_config, + FFLONK_CRS_KEY, + &format!("{}{}", path, FFLONK_CRS_KEY), + )?; + download_compressor_key( + shell, + &mut general_config, + FFLONK_COMPACT_CRS_KEY, + &format!("{}{}", path, FFLONK_COMPACT_CRS_KEY), + )?; + } + CompressorType::Plonk => { + let path = args.path.context(MSG_SETUP_KEY_PATH_ERROR)?; + + download_compressor_key( + shell, + &mut general_config, + PLONK_CRS_KEY, + &format!("{}{}", path, PLONK_CRS_KEY), + )?; + } + CompressorType::All => { + let path = args.clone().path.context(MSG_SETUP_KEY_PATH_ERROR)?; + + download_compressor_key( + shell, + &mut general_config, + FFLONK_CRS_KEY, + &format!("{}{}", path, FFLONK_CRS_KEY), + )?; + download_compressor_key( + shell, + &mut general_config, + FFLONK_COMPACT_CRS_KEY, + &format!("{}{}", path, FFLONK_COMPACT_CRS_KEY), + )?; + download_compressor_key( + shell, + &mut general_config, + PLONK_CRS_KEY, + &format!("{}{}", path, PLONK_CRS_KEY), + )?; + } + } chain_config.save_general_config(&general_config)?; @@ -33,6 +81,7 @@ pub(crate) async fn run(shell: &Shell, args: CompressorKeysArgs) -> anyhow::Resu pub(crate) fn download_compressor_key( shell: &Shell, general_config: &mut GeneralConfig, + key: &str, path: &str, ) -> anyhow::Result<()> { let spinner = Spinner::new(MSG_DOWNLOADING_SETUP_COMPRESSOR_KEY_SPINNER); @@ -41,12 +90,17 @@ pub(crate) fn download_compressor_key( .as_ref() .expect(MSG_PROOF_COMPRESSOR_CONFIG_NOT_FOUND_ERR) .clone(); + compressor_config.universal_setup_path = path.to_string(); general_config.proof_compressor_config = Some(compressor_config.clone()); - let url = compressor_config.universal_setup_download_url; + let mut url = compressor_config.universal_setup_download_url; + url.push_str(key); + let path = std::path::Path::new(path); + logger::info(format!("Downloading setup key {} by URL: {}", key, url)); + let client = reqwest::blocking::Client::builder() .timeout(std::time::Duration::from_secs(600)) .build()?; @@ -62,7 +116,7 @@ pub fn get_default_compressor_keys_path( ecosystem_config: &EcosystemConfig, ) -> anyhow::Result { let link_to_prover = get_link_to_prover(ecosystem_config); - let path = link_to_prover.join("keys/setup/setup_2^24.key"); + let path = link_to_prover.join("keys/setup/"); let string = path.to_str().unwrap(); Ok(String::from(string)) diff --git a/zkstack_cli/crates/zkstack/src/commands/prover/init.rs b/zkstack_cli/crates/zkstack/src/commands/prover/init.rs index ad92180aea9b..0734f9306ec2 100644 --- a/zkstack_cli/crates/zkstack/src/commands/prover/init.rs +++ b/zkstack_cli/crates/zkstack/src/commands/prover/init.rs @@ -23,8 +23,11 @@ use super::{ setup_keys, }; use crate::{ - commands::prover::args::init::ProofStorageFileBacked, - consts::{PROVER_MIGRATIONS, PROVER_STORE_MAX_RETRIES}, + commands::prover::args::{compressor_keys::CompressorType, init::ProofStorageFileBacked}, + consts::{ + FFLONK_COMPACT_CRS_KEY, FFLONK_CRS_KEY, PLONK_CRS_KEY, PROVER_MIGRATIONS, + PROVER_STORE_MAX_RETRIES, + }, messages::{ MSG_CHAIN_NOT_FOUND_ERR, MSG_FAILED_TO_DROP_PROVER_DATABASE_ERR, MSG_GENERAL_CONFIG_NOT_FOUND_ERR, MSG_INITIALIZING_DATABASES_SPINNER, @@ -55,8 +58,56 @@ pub(crate) async fn run(args: ProverInitArgs, shell: &Shell) -> anyhow::Result<( let public_object_store_config = get_object_store_config(shell, args.public_store)?; if let Some(args) = args.compressor_key_args { - let path = args.path.context(MSG_SETUP_KEY_PATH_ERROR)?; - download_compressor_key(shell, &mut general_config, &path)?; + match args.compressor_type { + CompressorType::Fflonk => { + let path = args.clone().path.context(MSG_SETUP_KEY_PATH_ERROR)?; + + download_compressor_key( + shell, + &mut general_config, + FFLONK_CRS_KEY, + &format!("{}{}", path, FFLONK_CRS_KEY), + )?; + download_compressor_key( + shell, + &mut general_config, + FFLONK_COMPACT_CRS_KEY, + &format!("{}{}", path, FFLONK_COMPACT_CRS_KEY), + )?; + } + CompressorType::Plonk => { + let path = args.path.context(MSG_SETUP_KEY_PATH_ERROR)?; + + download_compressor_key( + shell, + &mut general_config, + PLONK_CRS_KEY, + &format!("{}{}", path, PLONK_CRS_KEY), + )?; + } + CompressorType::All => { + let path = args.clone().path.context(MSG_SETUP_KEY_PATH_ERROR)?; + + download_compressor_key( + shell, + &mut general_config, + FFLONK_CRS_KEY, + &format!("{}{}", path, FFLONK_CRS_KEY), + )?; + download_compressor_key( + shell, + &mut general_config, + FFLONK_COMPACT_CRS_KEY, + &format!("{}{}", path, FFLONK_COMPACT_CRS_KEY), + )?; + download_compressor_key( + shell, + &mut general_config, + PLONK_CRS_KEY, + &format!("{}{}", path, PLONK_CRS_KEY), + )?; + } + } } if let Some(args) = args.setup_keys { diff --git a/zkstack_cli/crates/zkstack/src/commands/prover/run.rs b/zkstack_cli/crates/zkstack/src/commands/prover/run.rs index 85495d124041..c9bf837f787d 100644 --- a/zkstack_cli/crates/zkstack/src/commands/prover/run.rs +++ b/zkstack_cli/crates/zkstack/src/commands/prover/run.rs @@ -145,7 +145,7 @@ fn run_binary_component( let mut cmd = Cmd::new(cmd!( shell, - "cargo run {application_args...} --release --bin {binary_name} -- {args...}" + "cargo run {application_args...} --release --package {binary_name} -- {args...}" )); cmd = cmd.with_force_run(); cmd.run().context(error) diff --git a/zkstack_cli/crates/zkstack/src/consts.rs b/zkstack_cli/crates/zkstack/src/consts.rs index f5fbf0b0c9bb..fb3f0fbe3461 100644 --- a/zkstack_cli/crates/zkstack/src/consts.rs +++ b/zkstack_cli/crates/zkstack/src/consts.rs @@ -36,3 +36,6 @@ pub const PROVER_JOB_MONITOR_BINARY_NAME: &str = "zksync_prover_job_monitor"; pub const PATH_TO_ONLY_REAL_PROOFS_OVERRIDE_CONFIG: &str = "etc/env/file_based/overrides/only_real_proofs.yaml"; pub const PATH_TO_VALIDIUM_OVERRIDE_CONFIG: &str = "etc/env/file_based/overrides/validium.yaml"; +pub const PLONK_CRS_KEY: &str = "setup_2^24.key"; +pub const FFLONK_CRS_KEY: &str = "setup_fflonk.key"; +pub const FFLONK_COMPACT_CRS_KEY: &str = "setup_fflonk_compact.key"; diff --git a/zkstack_cli/crates/zkstack/src/utils/link_to_code.rs b/zkstack_cli/crates/zkstack/src/utils/link_to_code.rs index 1f2eb487849d..fcae429966dc 100644 --- a/zkstack_cli/crates/zkstack/src/utils/link_to_code.rs +++ b/zkstack_cli/crates/zkstack/src/utils/link_to_code.rs @@ -89,6 +89,7 @@ pub(crate) fn resolve_link_to_code( shell: &Shell, base_path: PathBuf, link_to_code: String, + update_submodules: Option, ) -> anyhow::Result { if link_to_code.is_empty() { if base_path.join("zksync-era").exists() { @@ -103,7 +104,9 @@ pub(crate) fn resolve_link_to_code( Ok(link_to_code) } else { let path = PathBuf::from_str(&link_to_code)?; - git::submodule_update(shell, path.clone())?; + if update_submodules.is_none() || update_submodules == Some(true) { + git::submodule_update(shell, path.clone())?; + } Ok(path) } }