From 72e29e36b15b45bbc4030f4d4d11523eb00d28f1 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:14:27 +0300 Subject: [PATCH 1/3] fix secrets path --- .../zk_supervisor/src/commands/prover/info.rs | 20 +++++++++---------- .../src/commands/prover/insert_batch.rs | 18 ++++++++++++----- .../src/commands/prover/insert_version.rs | 18 ++++++++++++----- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/zk_toolbox/crates/zk_supervisor/src/commands/prover/info.rs b/zk_toolbox/crates/zk_supervisor/src/commands/prover/info.rs index 05964cf689fd..6a7d7ddeda8a 100644 --- a/zk_toolbox/crates/zk_supervisor/src/commands/prover/info.rs +++ b/zk_toolbox/crates/zk_supervisor/src/commands/prover/info.rs @@ -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!( " @@ -59,13 +64,8 @@ pub(crate) async fn get_snark_wrapper(link_to_prover: &Path) -> anyhow::Result anyhow::Result { - 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 { + let prover_url = chain .get_secrets_config()? .database .context("Database secrets not found")? diff --git a/zk_toolbox/crates/zk_supervisor/src/commands/prover/insert_batch.rs b/zk_toolbox/crates/zk_supervisor/src/commands/prover/insert_batch.rs index 2c4a1cf97513..b1c02c9a9fea 100644 --- a/zk_toolbox/crates/zk_supervisor/src/commands/prover/insert_batch.rs +++ b/zk_toolbox/crates/zk_supervisor/src/commands/prover/insert_batch.rs @@ -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); diff --git a/zk_toolbox/crates/zk_supervisor/src/commands/prover/insert_version.rs b/zk_toolbox/crates/zk_supervisor/src/commands/prover/insert_version.rs index ab28efca9446..16bbdf13df4f 100644 --- a/zk_toolbox/crates/zk_supervisor/src/commands/prover/insert_version.rs +++ b/zk_toolbox/crates/zk_supervisor/src/commands/prover/insert_version.rs @@ -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, From 346d3e74c275eb4b5d9562f4cee25db688709a33 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Wed, 11 Sep 2024 20:38:40 +0300 Subject: [PATCH 2/3] fix artifacts path --- zk_toolbox/crates/zk_inception/src/commands/prover/init.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs index 1d92357635c5..20e682745870 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs @@ -163,7 +163,7 @@ fn init_file_backed_proof_storage( ecosystem_config: &EcosystemConfig, config: ProofStorageFileBacked, ) -> anyhow::Result { - 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"); @@ -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, From 003599eb33d3f845133ef421ae012c254702a68a Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Thu, 12 Sep 2024 09:32:08 +0300 Subject: [PATCH 3/3] fix setup data path --- .../zk_inception/src/commands/prover/run.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/run.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/run.rs index 8f72da03f3b3..5f4bf2f4a671 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/run.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/run.rs @@ -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}; @@ -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(), @@ -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(), @@ -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 + .prover_config + .as_mut() + .expect("Prover config not found") + .setup_data_path = path; + chain.save_general_config(&general_config)?; + Ok(()) +}