Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prover): Fix path to vk_setup_data_generator_server_fri #2025

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 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 @@ -44,14 +43,14 @@ pub struct Keystore {
setup_data_path: Option<String>,
}

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()")
Expand Down
11 changes: 11 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::PathBuf;

use anyhow::Context as _;
use circuit_definitions::{
circuit_definitions::aux_layer::ZkSyncSnarkWrapperCircuit,
Expand All @@ -20,6 +22,7 @@ use zksync_prover_fri_types::circuit_definitions::{
},
};
use zksync_types::H256;
use zksync_utils::locate_workspace;

use crate::keystore::Keystore;

Expand Down Expand Up @@ -112,6 +115,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() -> PathBuf {
locate_workspace()
.map(|a| a.join(".."))
.unwrap_or_else(|| PathBuf::from("."))
}

#[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")
}
Loading