From 2db50636aa254fc7963711f45d5840216549c466 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Fri, 20 Dec 2024 21:37:13 +0200 Subject: [PATCH] address comments --- .github/workflows/ci-prover-e2e.yml | 7 +++--- core/lib/config/src/configs/eth_sender.rs | 4 ++-- core/lib/config/src/testonly.rs | 2 +- core/lib/env_config/src/eth_sender.rs | 4 ++-- .../src/i_executor/methods/prove_batches.rs | 4 ++-- core/lib/protobuf_config/src/eth.rs | 4 ++-- .../src/proto/config/eth_sender.proto | 2 +- core/node/eth_sender/src/eth_tx_aggregator.rs | 4 ++-- etc/env/base/eth_sender.toml | 2 +- etc/env/file_based/general.yaml | 2 +- .../bin/circuit_prover/src/circuit_prover.rs | 0 .../proof_fri_compressor/src/compressor.rs | 2 +- .../crates/bin/witness_generator/src/main.rs | 9 ++++---- .../lib/circuit_prover_service/src/lib.rs | 4 +++- prover/crates/lib/keystore/src/lib.rs | 4 +--- prover/crates/lib/keystore/src/utils.rs | 2 +- .../commands/prover/args/compressor_keys.rs | 1 + .../src/commands/prover/compressor_keys.rs | 22 +++++++++++++++++++ 18 files changed, 51 insertions(+), 28 deletions(-) delete mode 100644 prover/crates/bin/circuit_prover/src/circuit_prover.rs diff --git a/.github/workflows/ci-prover-e2e.yml b/.github/workflows/ci-prover-e2e.yml index e2944fcee53a..75d0617cb38d 100644 --- a/.github/workflows/ci-prover-e2e.yml +++ b/.github/workflows/ci-prover-e2e.yml @@ -66,7 +66,7 @@ jobs: --ignore-prerequisites \ --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 prover init --dev --verbose @@ -76,8 +76,8 @@ jobs: working-directory: ./chains/proving_chain/configs if: matrix.compressor-mode == 'fflonk' run: | - sudo sed -i 's/verifier_pre_fflonk: true/verifier_pre_fflonk: false/' general.yaml - grep "verifier_pre_fflonk" general.yaml | awk '{ print $2 }' + 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: | @@ -93,6 +93,7 @@ jobs: - name: Run Prover Job Monitor run: | 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: diff --git a/core/lib/config/src/configs/eth_sender.rs b/core/lib/config/src/configs/eth_sender.rs index 29a389ca7e87..258aa26ec191 100644 --- a/core/lib/config/src/configs/eth_sender.rs +++ b/core/lib/config/src/configs/eth_sender.rs @@ -43,7 +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, - verifier_pre_fflonk: true, + is_verifier_pre_fflonk: true, }), gas_adjuster: Some(GasAdjusterConfig { default_priority_fee_per_gas: 1000000000, @@ -124,7 +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 verifier_pre_fflonk: bool, + pub is_verifier_pre_fflonk: bool, } impl SenderConfig { diff --git a/core/lib/config/src/testonly.rs b/core/lib/config/src/testonly.rs index 22b1f4966d00..fe140544d803 100644 --- a/core/lib/config/src/testonly.rs +++ b/core/lib/config/src/testonly.rs @@ -421,7 +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), - verifier_pre_fflonk: self.sample(rng), + is_verifier_pre_fflonk: self.sample(rng), } } } diff --git a/core/lib/env_config/src/eth_sender.rs b/core/lib/env_config/src/eth_sender.rs index 7d99aac48758..8801693b7a75 100644 --- a/core/lib/env_config/src/eth_sender.rs +++ b/core/lib/env_config/src/eth_sender.rs @@ -77,7 +77,7 @@ mod tests { tx_aggregation_paused: false, time_in_mempool_in_l1_blocks_cap: 2000, priority_tree_start_index: None, - verifier_pre_fflonk: true, + is_verifier_pre_fflonk: true, }), gas_adjuster: Some(GasAdjusterConfig { default_priority_fee_per_gas: 20000000000, @@ -141,7 +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_VERIFIER_PRE_FFLONK="true" + 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/l1_contract_interface/src/i_executor/methods/prove_batches.rs b/core/lib/l1_contract_interface/src/i_executor/methods/prove_batches.rs index 2505fc31bf05..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 @@ -30,7 +30,7 @@ pub struct ProveBatches { } impl ProveBatches { - pub fn conditional_into_tokens(&self, verifier_pre_fflonk: bool) -> Vec { + 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 @@ -59,7 +59,7 @@ impl ProveBatches { }; if protocol_version.is_pre_gateway() { - let proof_input = if !verifier_pre_fflonk || !protocol_version.is_pre_fflonk() { + 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()), diff --git a/core/lib/protobuf_config/src/eth.rs b/core/lib/protobuf_config/src/eth.rs index e68c2c336509..21cc572f82da 100644 --- a/core/lib/protobuf_config/src/eth.rs +++ b/core/lib/protobuf_config/src/eth.rs @@ -129,7 +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()), - verifier_pre_fflonk: self.verifier_pre_fflonk.unwrap_or(true), + is_verifier_pre_fflonk: self.is_verifier_pre_fflonk.unwrap_or(true), }) } @@ -159,7 +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), - verifier_pre_fflonk: Some(this.verifier_pre_fflonk), + is_verifier_pre_fflonk: Some(this.is_verifier_pre_fflonk), } } } 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 20a2030b6722..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,7 +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 verifier_pre_fflonk = 24; // optional + optional bool is_verifier_pre_fflonk = 24; // optional } message GasAdjuster { diff --git a/core/node/eth_sender/src/eth_tx_aggregator.rs b/core/node/eth_sender/src/eth_tx_aggregator.rs index 3ad96fdc2b0c..113dfb840fc1 100644 --- a/core/node/eth_sender/src/eth_tx_aggregator.rs +++ b/core/node/eth_sender/src/eth_tx_aggregator.rs @@ -134,7 +134,7 @@ impl EthTxAggregator { tracing::info!( "Initialized eth_tx_aggregator with is_pre_fflonk_verifier: {:?}", - self.config.verifier_pre_fflonk + self.config.is_verifier_pre_fflonk ); let pool = self.pool.clone(); @@ -550,7 +550,7 @@ impl EthTxAggregator { Self::encode_commit_data(encoding_fn, &commit_data, l1_batch_for_sidecar) } AggregatedOperation::PublishProofOnchain(op) => { - args.extend(op.conditional_into_tokens(self.config.verifier_pre_fflonk)); + 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/etc/env/base/eth_sender.toml b/etc/env/base/eth_sender.toml index d901536fb7cf..f6b2312e4232 100644 --- a/etc/env/base/eth_sender.toml +++ b/etc/env/base/eth_sender.toml @@ -48,7 +48,7 @@ max_acceptable_priority_fee_in_gwei = 100000000000 pubdata_sending_mode = "Blobs" -verifier_pre_fflonk = true +is_verifier_pre_fflonk = true [eth_sender.gas_adjuster] # Priority fee to be used by GasAdjuster (in wei). diff --git a/etc/env/file_based/general.yaml b/etc/env/file_based/general.yaml index 086018b3a3b2..cd095dae23f2 100644 --- a/etc/env/file_based/general.yaml +++ b/etc/env/file_based/general.yaml @@ -104,7 +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 - verifier_pre_fflonk: true + is_verifier_pre_fflonk: true gas_adjuster: default_priority_fee_per_gas: 1000000000 max_base_fee_samples: 100 diff --git a/prover/crates/bin/circuit_prover/src/circuit_prover.rs b/prover/crates/bin/circuit_prover/src/circuit_prover.rs deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/prover/crates/bin/proof_fri_compressor/src/compressor.rs b/prover/crates/bin/proof_fri_compressor/src/compressor.rs index 84ccce22bffc..3671fa183b5d 100644 --- a/prover/crates/bin/proof_fri_compressor/src/compressor.rs +++ b/prover/crates/bin/proof_fri_compressor/src/compressor.rs @@ -122,7 +122,7 @@ impl ProofCompressor { Ok(final_proof) } - #[tracing::instrument(skip(proof, compression_mode))] + #[tracing::instrument(skip(proof, compression_mode, keystore))] pub fn generate_fflonk_proof( proof: ZkSyncRecursionLayerProof, compression_mode: u8, diff --git a/prover/crates/bin/witness_generator/src/main.rs b/prover/crates/bin/witness_generator/src/main.rs index e1b361251888..8b28ecf3cdd6 100644 --- a/prover/crates/bin/witness_generator/src/main.rs +++ b/prover/crates/bin/witness_generator/src/main.rs @@ -59,7 +59,6 @@ struct Opt { /// This function recalculates the commitment in order to check the exact code that /// will run, instead of loading `commitments.json` (which also may correct misaligned /// information). -#[allow(dead_code)] // todo: remove after VK issue is resolved async fn ensure_protocol_alignment( prover_pool: &ConnectionPool, protocol_version: ProtocolSemanticVersion, @@ -141,10 +140,10 @@ async fn main() -> anyhow::Result<()> { let (stop_sender, stop_receiver) = watch::channel(false); let protocol_version = PROVER_PROTOCOL_SEMANTIC_VERSION; - // TODO: enable when VK issue is resolved - // ensure_protocol_alignment(&connection_pool, protocol_version, &keystore) - // .await - // .unwrap_or_else(|err| panic!("Protocol alignment check failed: {:?}", err)); + + ensure_protocol_alignment(&connection_pool, protocol_version, &keystore) + .await + .unwrap_or_else(|err| panic!("Protocol alignment check failed: {:?}", err)); let rounds = match (opt.round, opt.all_rounds) { (Some(round), false) => vec![round], 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/keystore/src/lib.rs b/prover/crates/lib/keystore/src/lib.rs index c5b59092b36b..e5f00fd307ba 100644 --- a/prover/crates/lib/keystore/src/lib.rs +++ b/prover/crates/lib/keystore/src/lib.rs @@ -1,7 +1,5 @@ -#![feature(allocator_api)] -#![feature(generic_const_exprs)] +#![feature(allocator_api, generic_const_exprs)] #![allow(incomplete_features)] -#![allow(unused_imports)] //todo: remove after setup is generated use serde::{Deserialize, Serialize}; #[cfg(any(feature = "gpu", feature = "gpu-light"))] diff --git a/prover/crates/lib/keystore/src/utils.rs b/prover/crates/lib/keystore/src/utils.rs index fa4de809f9a6..f76f8b48d9b8 100644 --- a/prover/crates/lib/keystore/src/utils.rs +++ b/prover/crates/lib/keystore/src/utils.rs @@ -7,7 +7,7 @@ use circuit_definitions::{ }, }; #[cfg(feature = "gpu")] -use fflonk_gpu::{bellman::bn256::Fq2, FflonkSnarkVerifierCircuitVK}; +use fflonk_gpu::FflonkSnarkVerifierCircuitVK; use sha3::Digest; use zkevm_test_harness::{ franklin_crypto::bellman::{CurveAffine, PrimeField, PrimeFieldRepr}, 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 713cf3ea9cba..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 @@ -17,6 +17,7 @@ pub enum CompressorType { Fflonk, #[default] Plonk, + All, } impl CompressorKeysArgs { 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 468f66b24734..ec102d92ea77 100644 --- a/zkstack_cli/crates/zkstack/src/commands/prover/compressor_keys.rs +++ b/zkstack_cli/crates/zkstack/src/commands/prover/compressor_keys.rs @@ -49,6 +49,28 @@ pub(crate) async fn run(shell: &Shell, args: CompressorKeysArgs) -> anyhow::Resu &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)?;