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(zk_toolbox): secrets path, artifacts path #2850

Merged
merged 4 commits into from
Sep 12, 2024
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
4 changes: 2 additions & 2 deletions zk_toolbox/crates/zk_inception/src/commands/prover/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fn init_file_backed_proof_storage(
ecosystem_config: &EcosystemConfig,
config: ProofStorageFileBacked,
) -> anyhow::Result<ObjectStoreConfig> {
let proof_store_dir = config.proof_store_dir;
let proof_store_dir = config.proof_store_dir.clone();
let prover_path = get_link_to_prover(ecosystem_config);

let proof_store_dir = prover_path.join(proof_store_dir).join("witness_inputs");
Expand All @@ -173,7 +173,7 @@ fn init_file_backed_proof_storage(

let object_store_config = ObjectStoreConfig {
mode: ObjectStoreMode::FileBacked {
file_backed_base_path: proof_store_dir.into_os_string().into_string().unwrap(),
file_backed_base_path: config.proof_store_dir,
},
max_retries: PROVER_STORE_MAX_RETRIES,
local_mirror_path: None,
Expand Down
15 changes: 14 additions & 1 deletion zk_toolbox/crates/zk_inception/src/commands/prover/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::path::PathBuf;

use anyhow::{anyhow, Context};
use common::{check_prerequisites, cmd::Cmd, config::global_config, logger, GPU_PREREQUISITES};
use config::{get_link_to_prover, EcosystemConfig};
use config::{get_link_to_prover, ChainConfig, EcosystemConfig};
use xshell::{cmd, Shell};

use super::args::run::{ProverComponent, ProverRunArgs};
Expand Down Expand Up @@ -69,6 +69,7 @@ pub(crate) async fn run(args: ProverRunArgs, shell: &Shell) -> anyhow::Result<()
if in_docker {
let path_to_configs = chain.configs.clone();
let path_to_prover = get_link_to_prover(&ecosystem_config);
update_setup_data_path(&chain, "prover/data/keys".to_string())?;
run_dockerized_component(
shell,
component.image_name(),
Expand All @@ -80,6 +81,7 @@ pub(crate) async fn run(args: ProverRunArgs, shell: &Shell) -> anyhow::Result<()
&path_to_prover,
)?
} else {
update_setup_data_path(&chain, "data/keys".to_string())?;
run_binary_component(
shell,
component.binary_name(),
Expand Down Expand Up @@ -132,3 +134,14 @@ fn run_binary_component(
cmd = cmd.with_force_run();
cmd.run().context(error)
}

fn update_setup_data_path(chain: &ChainConfig, path: String) -> anyhow::Result<()> {
let mut general_config = chain.get_general_config()?;
general_config
Artemka374 marked this conversation as resolved.
Show resolved Hide resolved
.prover_config
.as_mut()
.expect("Prover config not found")
.setup_data_path = path;
chain.save_general_config(&general_config)?;
Ok(())
}
20 changes: 10 additions & 10 deletions zk_toolbox/crates/zk_supervisor/src/commands/prover/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@ use std::{

use anyhow::Context as _;
use common::{config::global_config, logger};
use config::EcosystemConfig;
use config::{ChainConfig, EcosystemConfig};
use xshell::{cmd, Shell};

use crate::messages::MSG_CHAIN_NOT_FOUND_ERR;

pub async fn run(shell: &Shell) -> anyhow::Result<()> {
let link_to_code = EcosystemConfig::from_file(shell)?.link_to_code;
let ecosystem_config = EcosystemConfig::from_file(shell)?;
let chain_config = ecosystem_config
.load_chain(global_config().chain_name.clone())
.expect(MSG_CHAIN_NOT_FOUND_ERR);

let link_to_code = ecosystem_config.link_to_code;
let link_to_prover = link_to_code.join("prover");

let protocol_version = get_protocol_version(shell, &link_to_prover).await?;
let snark_wrapper = get_snark_wrapper(&link_to_prover).await?;
let prover_url = get_database_url(shell).await?;
let prover_url = get_database_url(&chain_config).await?;

logger::info(format!(
"
Expand Down Expand Up @@ -59,13 +64,8 @@ pub(crate) async fn get_snark_wrapper(link_to_prover: &Path) -> anyhow::Result<S
Ok(snark_wrapper)
}

pub(crate) async fn get_database_url(shell: &Shell) -> anyhow::Result<String> {
let ecosystem = EcosystemConfig::from_file(shell)?;
let chain_config = ecosystem
.load_chain(global_config().chain_name.clone())
.context(MSG_CHAIN_NOT_FOUND_ERR)?;

let prover_url = chain_config
pub(crate) async fn get_database_url(chain: &ChainConfig) -> anyhow::Result<String> {
let prover_url = chain
.get_secrets_config()?
.database
.context("Database secrets not found")?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
use common::{check_prerequisites, cmd::Cmd, logger, PROVER_CLI_PREREQUISITE};
use common::{
check_prerequisites, cmd::Cmd, config::global_config, logger, PROVER_CLI_PREREQUISITE,
};
use config::{get_link_to_prover, EcosystemConfig};
use xshell::{cmd, Shell};

use crate::commands::prover::{
args::insert_batch::{InsertBatchArgs, InsertBatchArgsFinal},
info,
use crate::{
commands::prover::{
args::insert_batch::{InsertBatchArgs, InsertBatchArgsFinal},
info,
},
messages::MSG_CHAIN_NOT_FOUND_ERR,
};

pub async fn run(shell: &Shell, args: InsertBatchArgs) -> anyhow::Result<()> {
check_prerequisites(shell, &PROVER_CLI_PREREQUISITE, false);

let ecosystem_config = EcosystemConfig::from_file(shell)?;
let chain_config = ecosystem_config
.load_chain(global_config().chain_name.clone())
.expect(MSG_CHAIN_NOT_FOUND_ERR);

let version = info::get_protocol_version(shell, &get_link_to_prover(&ecosystem_config)).await?;
let prover_url = info::get_database_url(shell).await?;
let prover_url = info::get_database_url(&chain_config).await?;

let InsertBatchArgsFinal { number, version } = args.fill_values_with_prompts(version);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
use common::{check_prerequisites, cmd::Cmd, logger, PROVER_CLI_PREREQUISITE};
use common::{
check_prerequisites, cmd::Cmd, config::global_config, logger, PROVER_CLI_PREREQUISITE,
};
use config::{get_link_to_prover, EcosystemConfig};
use xshell::{cmd, Shell};

use crate::commands::prover::{
args::insert_version::{InsertVersionArgs, InsertVersionArgsFinal},
info,
use crate::{
commands::prover::{
args::insert_version::{InsertVersionArgs, InsertVersionArgsFinal},
info,
},
messages::MSG_CHAIN_NOT_FOUND_ERR,
};

pub async fn run(shell: &Shell, args: InsertVersionArgs) -> anyhow::Result<()> {
check_prerequisites(shell, &PROVER_CLI_PREREQUISITE, false);

let ecosystem_config = EcosystemConfig::from_file(shell)?;
let chain_config = ecosystem_config
.load_chain(global_config().chain_name.clone())
.expect(MSG_CHAIN_NOT_FOUND_ERR);

let version = info::get_protocol_version(shell, &get_link_to_prover(&ecosystem_config)).await?;
let snark_wrapper = info::get_snark_wrapper(&get_link_to_prover(&ecosystem_config)).await?;

let prover_url = info::get_database_url(shell).await?;
let prover_url = info::get_database_url(&chain_config).await?;

let InsertVersionArgsFinal {
version,
Expand Down
Loading