Skip to content

Commit

Permalink
Locate prover path properly
Browse files Browse the repository at this point in the history
Signed-off-by: Danil <deniallugo@gmail.com>
  • Loading branch information
Deniallugo committed May 23, 2024
1 parent 07aebd8 commit 1de247d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 2 additions & 3 deletions prover/vk_setup_data_generator_server_fri/src/keystore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -45,7 +44,7 @@ pub struct Keystore {
}

fn get_base_path() -> PathBuf {
workspace_dir_or_current_dir().join("prover/vk_setup_data_generator_server_fri/data")
core_workspace_dir_or_current_dir().join("prover/vk_setup_data_generator_server_fri/data")
}

impl Default for Keystore {
Expand Down
10 changes: 10 additions & 0 deletions prover/vk_setup_data_generator_server_fri/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::path::Path;

use anyhow::Context as _;
use circuit_definitions::{
circuit_definitions::aux_layer::ZkSyncSnarkWrapperCircuit,
Expand Down Expand Up @@ -112,6 +114,14 @@ pub fn calculate_snark_vk_hash(keystore: &Keystore) -> anyhow::Result<H256> {
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() -> &'static Path {
locate_workspace()
.map(|a| a.join(".."))
.unwrap_or_else(|| Path::new("."))
}

#[cfg(test)]
mod tests {
use std::{path::PathBuf, str::FromStr};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -23,5 +24,5 @@ pub fn read_contract_toml() -> anyhow::Result<Document> {
}

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")
}

0 comments on commit 1de247d

Please sign in to comment.