Skip to content

Commit

Permalink
fix(prover): Fix path to vk_setup_data_generator_server_fri (#2025)
Browse files Browse the repository at this point in the history
## What ❔

Fix path after migration to non zksync home dir


## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] 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 <deniallugo@gmail.com>
  • Loading branch information
Deniallugo committed May 23, 2024
1 parent 86355d6 commit dbe4d6f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
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")
}

0 comments on commit dbe4d6f

Please sign in to comment.