From 9ceaac35183d6f8fe3ee24514c6cdae7963933d4 Mon Sep 17 00:00:00 2001 From: Artem Fomiuk <88630083+Artemka374@users.noreply.github.com> Date: Mon, 8 Jul 2024 15:26:09 +0300 Subject: [PATCH] feat: Remove cached commitments, add BWIP to docs (#2400) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ Remove lazy loading of commitments in BWG Add BWIP to docs ## Why ❔ It is not needed, because it is called only once ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zk fmt` and `zk lint`. --- prover/prover_fri/README.md | 2 +- .../src/commitment_utils.rs | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/prover/prover_fri/README.md b/prover/prover_fri/README.md index 5f0a26cfdd49..c5f434d84d0f 100644 --- a/prover/prover_fri/README.md +++ b/prover/prover_fri/README.md @@ -55,7 +55,7 @@ installation as a pre-requisite, alongside these machine specs: 2. Run the server. In the root of the repository: ```console - zk server --components=api,eth,tree,state_keeper,housekeeper,commitment_generator,proof_data_handler + zk server --components=api,eth,tree,state_keeper,housekeeper,commitment_generator,proof_data_handler,vm_runner_bwip ``` Note that it will produce a first l1 batch that can be proven (should be batch 0). diff --git a/prover/vk_setup_data_generator_server_fri/src/commitment_utils.rs b/prover/vk_setup_data_generator_server_fri/src/commitment_utils.rs index 58fd36ab4a59..471e76e1a680 100644 --- a/prover/vk_setup_data_generator_server_fri/src/commitment_utils.rs +++ b/prover/vk_setup_data_generator_server_fri/src/commitment_utils.rs @@ -3,7 +3,6 @@ use std::{str::FromStr, sync::Mutex}; use anyhow::Context as _; use hex::ToHex; use once_cell::sync::Lazy; -use structopt::lazy_static::lazy_static; use zkevm_test_harness::witness::recursive_aggregation::{ compute_leaf_vks_and_params_commitment, compute_node_vk_commitment, }; @@ -24,14 +23,6 @@ use crate::{ static KEYSTORE: Lazy>> = Lazy::new(|| Mutex::new(None)); -lazy_static! { - // TODO: do not initialize a static const with data read in runtime. - static ref COMMITMENTS: Lazy = Lazy::new(|| { - let keystore = KEYSTORE.lock().unwrap().clone().unwrap_or_default(); - circuit_commitments(&keystore).unwrap() - }); -} - fn circuit_commitments(keystore: &Keystore) -> anyhow::Result { let commitments = generate_commitments(keystore).context("generate_commitments()")?; Ok(L1VerifierConfig { @@ -108,8 +99,12 @@ pub fn get_cached_commitments(setup_data_path: Option) -> L1VerifierConf let mut keystore_lock = KEYSTORE.lock().unwrap(); *keystore_lock = Some(keystore); } - tracing::info!("Using cached commitments {:?}", **COMMITMENTS); - **COMMITMENTS + + let keystore = KEYSTORE.lock().unwrap().clone().unwrap_or_default(); + let commitments = circuit_commitments(&keystore).unwrap(); + + tracing::info!("Using cached commitments {:?}", commitments); + commitments } #[test]