From 08cd6f759be0863cc8710113436cc100bd0f2629 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Thu, 19 Sep 2024 13:02:27 +0300 Subject: [PATCH 1/4] afo/fix-local-prover-run --- .../src/commands/prover/args/run.rs | 21 +++++++++++++++++++ .../zk_inception/src/commands/prover/run.rs | 13 +++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs index 751cc48074fe..b209b67c4d32 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs @@ -1,3 +1,5 @@ +use std::path::PathBuf; + use anyhow::anyhow; use clap::{Parser, ValueEnum}; use common::{Prompt, PromptSelect}; @@ -92,6 +94,7 @@ impl ProverComponent { in_docker: bool, args: ProverRunArgs, chain: &ChainConfig, + path_to_ecosystem: &PathBuf, ) -> anyhow::Result> { let mut additional_args = vec![]; if in_docker { @@ -109,6 +112,24 @@ impl ProverComponent { .into_string() .map_err(|_| anyhow!("Failed to convert path to string"))?; + let general_config = if general_config.starts_with("./") { + path_to_ecosystem.join(general_config) + } else { + PathBuf::from(general_config) + } + .into_os_string() + .into_string() + .unwrap(); + + let secrets_config = if secrets_config.starts_with("./") { + path_to_ecosystem.join(secrets_config) + } else { + PathBuf::from(secrets_config) + } + .into_os_string() + .into_string() + .unwrap(); + additional_args.push(format!("--config-path={}", general_config)); additional_args.push(format!("--secrets-path={}", secrets_config)); } 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 5f4bf2f4a671..216d35f6c25e 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/run.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/run.rs @@ -22,6 +22,8 @@ pub(crate) async fn run(args: ProverRunArgs, shell: &Shell) -> anyhow::Result<() .load_chain(global_config().chain_name.clone()) .expect(MSG_CHAIN_NOT_FOUND_ERR); + let path_to_ecosystem = shell.current_dir(); + let link_to_prover = get_link_to_prover(&ecosystem_config); shell.change_dir(link_to_prover.clone()); @@ -29,7 +31,8 @@ pub(crate) async fn run(args: ProverRunArgs, shell: &Shell) -> anyhow::Result<() let in_docker = args.docker.unwrap_or(false); let application_args = component.get_application_args(in_docker)?; - let additional_args = component.get_additional_args(in_docker, args, &chain)?; + let additional_args = + component.get_additional_args(in_docker, args, &chain, &path_to_ecosystem)?; let (message, error) = match component { ProverComponent::WitnessGenerator => ( @@ -79,6 +82,7 @@ pub(crate) async fn run(args: ProverRunArgs, shell: &Shell) -> anyhow::Result<() error, &path_to_configs, &path_to_prover, + &path_to_ecosystem, )? } else { update_setup_data_path(&chain, "data/keys".to_string())?; @@ -105,9 +109,16 @@ fn run_dockerized_component( error: &'static str, path_to_configs: &PathBuf, path_to_prover: &PathBuf, + path_to_ecosystem: &PathBuf, ) -> anyhow::Result<()> { logger::info(message); + let path_to_configs = if path_to_configs.starts_with("./") { + path_to_ecosystem.join(path_to_configs) + } else { + path_to_configs.clone() + }; + let mut cmd = Cmd::new(cmd!( shell, "docker run --net=host -v {path_to_prover}/data/keys:/prover/data/keys -v {path_to_prover}/artifacts:/artifacts -v {path_to_configs}:/configs {application_args...} {image_name} {args...}" From c964bfbafdcdd872fb7658f75edd953453af5b81 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Thu, 19 Sep 2024 13:22:47 +0300 Subject: [PATCH 2/4] fix lint --- .../crates/zk_inception/src/commands/prover/args/run.rs | 4 ++-- zk_toolbox/crates/zk_inception/src/commands/prover/run.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs index b209b67c4d32..b6c02feb3ee3 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs @@ -1,4 +1,4 @@ -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use anyhow::anyhow; use clap::{Parser, ValueEnum}; @@ -94,7 +94,7 @@ impl ProverComponent { in_docker: bool, args: ProverRunArgs, chain: &ChainConfig, - path_to_ecosystem: &PathBuf, + path_to_ecosystem: &Path, ) -> anyhow::Result> { let mut additional_args = vec![]; if in_docker { 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 216d35f6c25e..be0047dcda7d 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/run.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/run.rs @@ -1,4 +1,4 @@ -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use anyhow::{anyhow, Context}; use common::{check_prerequisites, cmd::Cmd, config::global_config, logger, GPU_PREREQUISITES}; @@ -109,7 +109,7 @@ fn run_dockerized_component( error: &'static str, path_to_configs: &PathBuf, path_to_prover: &PathBuf, - path_to_ecosystem: &PathBuf, + path_to_ecosystem: &Path, ) -> anyhow::Result<()> { logger::info(message); From 903cf84a2a3f90fbbcc8a40e5b0d7611548bbdb4 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:32:09 +0300 Subject: [PATCH 3/4] remove check for path --- .../src/commands/prover/args/run.rs | 26 +++++++------------ .../zk_inception/src/commands/prover/run.rs | 6 +---- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs index b6c02feb3ee3..d7d144a05523 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs @@ -112,23 +112,17 @@ impl ProverComponent { .into_string() .map_err(|_| anyhow!("Failed to convert path to string"))?; - let general_config = if general_config.starts_with("./") { - path_to_ecosystem.join(general_config) - } else { - PathBuf::from(general_config) - } - .into_os_string() - .into_string() - .unwrap(); + let general_config = path_to_ecosystem + .join(general_config) + .into_os_string() + .into_string() + .unwrap(); - let secrets_config = if secrets_config.starts_with("./") { - path_to_ecosystem.join(secrets_config) - } else { - PathBuf::from(secrets_config) - } - .into_os_string() - .into_string() - .unwrap(); + let secrets_config = path_to_ecosystem + .join(secrets_config) + .into_os_string() + .into_string() + .unwrap(); additional_args.push(format!("--config-path={}", general_config)); additional_args.push(format!("--secrets-path={}", secrets_config)); 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 be0047dcda7d..953b6c47f269 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/run.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/run.rs @@ -113,11 +113,7 @@ fn run_dockerized_component( ) -> anyhow::Result<()> { logger::info(message); - let path_to_configs = if path_to_configs.starts_with("./") { - path_to_ecosystem.join(path_to_configs) - } else { - path_to_configs.clone() - }; + let path_to_configs = path_to_ecosystem.join(path_to_configs); let mut cmd = Cmd::new(cmd!( shell, From 74de9f361e99b63b29e74bcf851c18764297e972 Mon Sep 17 00:00:00 2001 From: Lech <88630083+Artemka374@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:50:03 +0300 Subject: [PATCH 4/4] fix lint --- zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs index d7d144a05523..59a82152f1ff 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/args/run.rs @@ -1,4 +1,4 @@ -use std::path::{Path, PathBuf}; +use std::path::Path; use anyhow::anyhow; use clap::{Parser, ValueEnum};