From dbe4d6f1724a458e61ab56cd94d17e1ecfa4c207 Mon Sep 17 00:00:00 2001 From: Danil Date: Thu, 23 May 2024 10:55:02 +0200 Subject: [PATCH] fix(prover): Fix path to vk_setup_data_generator_server_fri (#2025) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ Fix path after migration to non zksync home dir ## Checklist - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk fmt` and `zk lint`. - [ ] Spellcheck has been run via `zk spellcheck`. --------- Signed-off-by: Danil --- .../src/keystore.rs | 9 ++++----- .../vk_setup_data_generator_server_fri/src/utils.rs | 11 +++++++++++ .../src/vk_commitment_helper.rs | 5 +++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/prover/vk_setup_data_generator_server_fri/src/keystore.rs b/prover/vk_setup_data_generator_server_fri/src/keystore.rs index d68957353aa..d1ba66e1fd2 100644 --- a/prover/vk_setup_data_generator_server_fri/src/keystore.rs +++ b/prover/vk_setup_data_generator_server_fri/src/keystore.rs @@ -20,11 +20,10 @@ use zksync_config::configs::FriProverConfig; use zksync_env_config::FromEnv; use zksync_prover_fri_types::ProverServiceDataKey; use zksync_types::basic_fri_types::AggregationRound; -use zksync_utils::workspace_dir_or_current_dir; #[cfg(feature = "gpu")] use crate::GoldilocksGpuProverSetupData; -use crate::{GoldilocksProverSetupData, VkCommitments}; +use crate::{utils::core_workspace_dir_or_current_dir, GoldilocksProverSetupData, VkCommitments}; pub enum ProverServiceDataType { VerificationKey, @@ -44,14 +43,14 @@ pub struct Keystore { setup_data_path: Option, } -fn get_base_path_from_env() -> PathBuf { - workspace_dir_or_current_dir().join("vk_setup_data_generator_server_fri/data") +fn get_base_path() -> PathBuf { + core_workspace_dir_or_current_dir().join("prover/vk_setup_data_generator_server_fri/data") } impl Default for Keystore { fn default() -> Self { Self { - basedir: get_base_path_from_env(), + basedir: get_base_path(), setup_data_path: Some( FriProverConfig::from_env() .expect("FriProverConfig::from_env()") diff --git a/prover/vk_setup_data_generator_server_fri/src/utils.rs b/prover/vk_setup_data_generator_server_fri/src/utils.rs index a1fa832df8a..0dff2f36cec 100644 --- a/prover/vk_setup_data_generator_server_fri/src/utils.rs +++ b/prover/vk_setup_data_generator_server_fri/src/utils.rs @@ -1,3 +1,5 @@ +use std::path::PathBuf; + use anyhow::Context as _; use circuit_definitions::{ circuit_definitions::aux_layer::ZkSyncSnarkWrapperCircuit, @@ -20,6 +22,7 @@ use zksync_prover_fri_types::circuit_definitions::{ }, }; use zksync_types::H256; +use zksync_utils::locate_workspace; use crate::keystore::Keystore; @@ -112,6 +115,14 @@ pub fn calculate_snark_vk_hash(keystore: &Keystore) -> anyhow::Result { Ok(H256::from_slice(&computed_vk_hash)) } +/// Returns workspace of the core component, we assume that prover is one folder deeper. +/// Or fallback to current dir +pub fn core_workspace_dir_or_current_dir() -> PathBuf { + locate_workspace() + .map(|a| a.join("..")) + .unwrap_or_else(|| PathBuf::from(".")) +} + #[cfg(test)] mod tests { use std::{path::PathBuf, str::FromStr}; diff --git a/prover/vk_setup_data_generator_server_fri/src/vk_commitment_helper.rs b/prover/vk_setup_data_generator_server_fri/src/vk_commitment_helper.rs index 5a2c274d467..bf568e06157 100644 --- a/prover/vk_setup_data_generator_server_fri/src/vk_commitment_helper.rs +++ b/prover/vk_setup_data_generator_server_fri/src/vk_commitment_helper.rs @@ -2,7 +2,8 @@ use std::{fs, path::PathBuf}; use anyhow::Context as _; use toml_edit::{Document, Item, Value}; -use zksync_utils::workspace_dir_or_current_dir; + +use crate::utils::core_workspace_dir_or_current_dir; pub fn get_toml_formatted_value(string_value: String) -> Item { let mut value = Value::from(string_value); @@ -23,5 +24,5 @@ pub fn read_contract_toml() -> anyhow::Result { } pub fn get_contract_toml_path() -> PathBuf { - workspace_dir_or_current_dir().join("../etc/env/base/contracts.toml") + core_workspace_dir_or_current_dir().join("etc/env/base/contracts.toml") }