From f3efb311b6cf6a293446009827f69256f6deb801 Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Wed, 12 Jun 2024 12:33:41 +0200 Subject: [PATCH 01/12] Add init command boilerplate --- .../crates/zk_inception/src/commands/mod.rs | 1 + .../src/commands/prover/args/init.rs | 5 +++++ .../src/commands/prover/args/mod.rs | 1 + .../zk_inception/src/commands/prover/init.rs | 10 ++++++++++ .../zk_inception/src/commands/prover/mod.rs | 17 +++++++++++++++++ zk_toolbox/crates/zk_inception/src/main.rs | 8 +++++++- 6 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 zk_toolbox/crates/zk_inception/src/commands/prover/args/init.rs create mode 100644 zk_toolbox/crates/zk_inception/src/commands/prover/args/mod.rs create mode 100644 zk_toolbox/crates/zk_inception/src/commands/prover/init.rs create mode 100644 zk_toolbox/crates/zk_inception/src/commands/prover/mod.rs diff --git a/zk_toolbox/crates/zk_inception/src/commands/mod.rs b/zk_toolbox/crates/zk_inception/src/commands/mod.rs index 8ed7a82b8334..ccdf5b082caa 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/mod.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/mod.rs @@ -2,4 +2,5 @@ pub mod args; pub mod chain; pub mod containers; pub mod ecosystem; +pub mod prover; pub mod server; diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/args/init.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/args/init.rs new file mode 100644 index 000000000000..8a8709b69e25 --- /dev/null +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/args/init.rs @@ -0,0 +1,5 @@ +use clap::Parser; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize, Parser)] +pub struct InitArgs {} diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/args/mod.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/args/mod.rs new file mode 100644 index 000000000000..43763f10a418 --- /dev/null +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/args/mod.rs @@ -0,0 +1 @@ +pub mod init; diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs new file mode 100644 index 000000000000..3792d45a63a9 --- /dev/null +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs @@ -0,0 +1,10 @@ +use anyhow::Ok; +use common::logger; +use xshell::Shell; + +use super::args::init::InitArgs; + +pub(crate) async fn run(_args: InitArgs, _shell: &Shell) -> anyhow::Result<()> { + logger::debug("Initializing prover"); + Ok(()) +} diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/mod.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/mod.rs new file mode 100644 index 000000000000..fef963f624eb --- /dev/null +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/mod.rs @@ -0,0 +1,17 @@ +use args::init::InitArgs; +use clap::Subcommand; +use xshell::Shell; +mod args; +mod init; + +#[derive(Subcommand, Debug)] +pub enum ProverCommands { + /// Initialize prover + Init(InitArgs), +} + +pub(crate) async fn run(shell: &Shell, args: ProverCommands) -> anyhow::Result<()> { + match args { + ProverCommands::Init(args) => init::run(args, shell).await, + } +} diff --git a/zk_toolbox/crates/zk_inception/src/main.rs b/zk_toolbox/crates/zk_inception/src/main.rs index b0e8e8f4fd69..dff9e479e01f 100644 --- a/zk_toolbox/crates/zk_inception/src/main.rs +++ b/zk_toolbox/crates/zk_inception/src/main.rs @@ -7,7 +7,9 @@ use common::{ use config::EcosystemConfig; use xshell::Shell; -use crate::commands::{args::RunServerArgs, chain::ChainCommands, ecosystem::EcosystemCommands}; +use crate::commands::{ + args::RunServerArgs, chain::ChainCommands, ecosystem::EcosystemCommands, prover::ProverCommands, +}; pub mod accept_ownership; mod commands; @@ -35,6 +37,9 @@ pub enum InceptionSubcommands { /// Chain related commands #[command(subcommand)] Chain(ChainCommands), + /// Prover related commands + #[command(subcommand)] + Prover(ProverCommands), /// Run server Server(RunServerArgs), /// Run containers for local development @@ -101,6 +106,7 @@ async fn run_subcommand(inception_args: Inception, shell: &Shell) -> anyhow::Res match inception_args.command { InceptionSubcommands::Ecosystem(args) => commands::ecosystem::run(shell, args).await?, InceptionSubcommands::Chain(args) => commands::chain::run(shell, args).await?, + InceptionSubcommands::Prover(args) => commands::prover::run(shell, args).await?, InceptionSubcommands::Server(args) => commands::server::run(shell, args)?, InceptionSubcommands::Containers => commands::containers::run(shell)?, } From d82b8b30700fc266948d72de4f68fbc419e1c6b4 Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Thu, 13 Jun 2024 12:46:13 +0200 Subject: [PATCH 02/12] Run key generator --- .../zk_inception/src/commands/prover/init.rs | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 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 3792d45a63a9..4e491882657b 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs @@ -1,10 +1,29 @@ use anyhow::Ok; -use common::logger; -use xshell::Shell; +use common::{cmd::Cmd, logger, spinner::Spinner}; +use config::EcosystemConfig; +use xshell::{cmd, Shell}; use super::args::init::InitArgs; -pub(crate) async fn run(_args: InitArgs, _shell: &Shell) -> anyhow::Result<()> { - logger::debug("Initializing prover"); +pub(crate) async fn run(_args: InitArgs, shell: &Shell) -> anyhow::Result<()> { + logger::info("Initializing prover"); + let ecosystem_config = EcosystemConfig::from_file(shell)?; + let mut link_to_prover = ecosystem_config.link_to_code.into_os_string(); + link_to_prover.push("/prover"); + shell.change_dir(link_to_prover); + + let spinner = Spinner::new("Generating setup keys..."); + + let mut cmd = Cmd::new(cmd!( + shell, + "cargo run --features gpu --release --bin key_generator -- + generate-sk all --recompute-if-missing + --setup-path=vk_setup_data_generator_server_fri/data + --path=prover/vk_setup_data_generator_server_fri/data" + )); + cmd.run()?; + spinner.finish(); + logger::info("Setup keys generated successfully"); + Ok(()) } From 351c9eeed31a45de64b93034b1eacfa936b6c0df Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Thu, 13 Jun 2024 13:05:46 +0200 Subject: [PATCH 03/12] fix setup data path --- .../crates/zk_inception/src/commands/prover/init.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 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 4e491882657b..90325072eb50 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs @@ -10,20 +10,19 @@ pub(crate) async fn run(_args: InitArgs, shell: &Shell) -> anyhow::Result<()> { let ecosystem_config = EcosystemConfig::from_file(shell)?; let mut link_to_prover = ecosystem_config.link_to_code.into_os_string(); link_to_prover.push("/prover"); - shell.change_dir(link_to_prover); - - let spinner = Spinner::new("Generating setup keys..."); + shell.change_dir(link_to_prover.clone()); + let spinner = Spinner::new("Generating verification keys..."); let mut cmd = Cmd::new(cmd!( shell, "cargo run --features gpu --release --bin key_generator -- generate-sk all --recompute-if-missing --setup-path=vk_setup_data_generator_server_fri/data - --path=prover/vk_setup_data_generator_server_fri/data" + --path={link_to_prover}/vk_setup_data_generator_server_fri/data" )); cmd.run()?; spinner.finish(); - logger::info("Setup keys generated successfully"); + logger::info("Verification keys generated successfully"); Ok(()) } From 866bdc9a513f73213d75f9eb4459be0c0edfed7d Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Thu, 13 Jun 2024 13:28:20 +0200 Subject: [PATCH 04/12] Refactor msgs --- .../crates/zk_inception/src/commands/prover/init.rs | 8 +++++--- zk_toolbox/crates/zk_inception/src/messages.rs | 5 +++++ 2 files changed, 10 insertions(+), 3 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 90325072eb50..9a9d40d5a38b 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs @@ -3,16 +3,18 @@ use common::{cmd::Cmd, logger, spinner::Spinner}; use config::EcosystemConfig; use xshell::{cmd, Shell}; +use crate::messages::{MSG_GENERATING_VK_SPINNER, MSG_INITIALIZING_PROVER, MSG_PROVER_INITIALIZED}; + use super::args::init::InitArgs; pub(crate) async fn run(_args: InitArgs, shell: &Shell) -> anyhow::Result<()> { - logger::info("Initializing prover"); + logger::info(MSG_INITIALIZING_PROVER); let ecosystem_config = EcosystemConfig::from_file(shell)?; let mut link_to_prover = ecosystem_config.link_to_code.into_os_string(); link_to_prover.push("/prover"); shell.change_dir(link_to_prover.clone()); - let spinner = Spinner::new("Generating verification keys..."); + let spinner = Spinner::new(MSG_GENERATING_VK_SPINNER); let mut cmd = Cmd::new(cmd!( shell, "cargo run --features gpu --release --bin key_generator -- @@ -22,7 +24,7 @@ pub(crate) async fn run(_args: InitArgs, shell: &Shell) -> anyhow::Result<()> { )); cmd.run()?; spinner.finish(); - logger::info("Verification keys generated successfully"); + logger::outro(MSG_PROVER_INITIALIZED); Ok(()) } diff --git a/zk_toolbox/crates/zk_inception/src/messages.rs b/zk_toolbox/crates/zk_inception/src/messages.rs index 7221f030d415..884884062a14 100644 --- a/zk_toolbox/crates/zk_inception/src/messages.rs +++ b/zk_toolbox/crates/zk_inception/src/messages.rs @@ -173,3 +173,8 @@ pub(super) fn msg_address_doesnt_have_enough_money_prompt(address: &H160) -> Str "Address {address:?} doesn't have enough money to deploy contracts do you want to try again?" ) } + +/// Prover related messages +pub(super) const MSG_INITIALIZING_PROVER: &str = "Initializing prover"; +pub(super) const MSG_PROVER_INITIALIZED: &str = "Prover initialized successfully"; +pub(super) const MSG_GENERATING_VK_SPINNER: &str = "Generating verification keys..."; From 535fd18e127159a9fbac39d8f57a87ac79482eed Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Thu, 13 Jun 2024 13:28:47 +0200 Subject: [PATCH 05/12] fmt --- zk_toolbox/crates/zk_inception/src/commands/prover/init.rs | 3 +-- 1 file changed, 1 insertion(+), 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 9a9d40d5a38b..f82b798b5cba 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs @@ -3,9 +3,8 @@ use common::{cmd::Cmd, logger, spinner::Spinner}; use config::EcosystemConfig; use xshell::{cmd, Shell}; -use crate::messages::{MSG_GENERATING_VK_SPINNER, MSG_INITIALIZING_PROVER, MSG_PROVER_INITIALIZED}; - use super::args::init::InitArgs; +use crate::messages::{MSG_GENERATING_VK_SPINNER, MSG_INITIALIZING_PROVER, MSG_PROVER_INITIALIZED}; pub(crate) async fn run(_args: InitArgs, shell: &Shell) -> anyhow::Result<()> { logger::info(MSG_INITIALIZING_PROVER); From 29e4459926b8c4f29df61b37c56029fac1a6aa88 Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Fri, 14 Jun 2024 12:32:59 +0200 Subject: [PATCH 06/12] Save link to prover in ecosystem config --- zk_toolbox/crates/config/src/ecosystem.rs | 12 ++++++++++++ .../zk_inception/src/commands/ecosystem/create.rs | 6 +++++- .../crates/zk_inception/src/commands/prover/init.rs | 5 ++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/zk_toolbox/crates/config/src/ecosystem.rs b/zk_toolbox/crates/config/src/ecosystem.rs index 1557ab21646f..932e1177b10f 100644 --- a/zk_toolbox/crates/config/src/ecosystem.rs +++ b/zk_toolbox/crates/config/src/ecosystem.rs @@ -25,6 +25,7 @@ struct EcosystemConfigInternal { pub name: String, pub l1_network: L1Network, pub link_to_code: PathBuf, + pub link_to_prover: PathBuf, pub chains: PathBuf, pub config: PathBuf, pub default_chain: String, @@ -40,6 +41,7 @@ pub struct EcosystemConfig { pub name: String, pub l1_network: L1Network, pub link_to_code: PathBuf, + pub link_to_prover: PathBuf, pub chains: PathBuf, pub config: PathBuf, pub default_chain: String, @@ -72,6 +74,11 @@ impl<'de> Deserialize<'de> for EcosystemConfig { .absolutize() .expect("Failed to parse zksync-era path") .to_path_buf(), + link_to_prover: config + .link_to_prover + .absolutize() + .expect("Failed to parse prover path") + .to_path_buf(), chains: config.chains.clone(), config: config.config.clone(), default_chain: config.default_chain.clone(), @@ -201,6 +208,11 @@ impl EcosystemConfig { .absolutize() .expect("Failed to parse zksync-era path") .into(), + link_to_prover: self + .link_to_prover + .absolutize() + .expect("Failed to parse prover path") + .into(), chains: self.chains.clone(), config: self.config.clone(), default_chain: self.default_chain.clone(), diff --git a/zk_toolbox/crates/zk_inception/src/commands/ecosystem/create.rs b/zk_toolbox/crates/zk_inception/src/commands/ecosystem/create.rs index 4daab36c56b8..af31120b3a49 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/ecosystem/create.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/ecosystem/create.rs @@ -51,7 +51,7 @@ fn create(args: EcosystemCreateArgs, shell: &Shell) -> anyhow::Result<()> { shell.create_dir(ecosystem_name)?; shell.change_dir(ecosystem_name); - let configs_path = create_local_configs_dir(shell, ".")?; + let configs_path: PathBuf = create_local_configs_dir(shell, ".")?; let link_to_code = if args.link_to_code.is_empty() { let spinner = Spinner::new(MSG_CLONING_ERA_REPO_SPINNER); @@ -64,6 +64,9 @@ fn create(args: EcosystemCreateArgs, shell: &Shell) -> anyhow::Result<()> { path }; + let mut link_to_prover = link_to_code.clone().into_os_string(); + link_to_prover.push("/prover"); + let spinner = Spinner::new(MSG_CREATING_INITIAL_CONFIGURATIONS_SPINNER); let chain_config = args.chain_config(); let chains_path = shell.create_dir("chains")?; @@ -76,6 +79,7 @@ fn create(args: EcosystemCreateArgs, shell: &Shell) -> anyhow::Result<()> { name: ecosystem_name.clone(), l1_network: args.l1_network, link_to_code: link_to_code.clone(), + link_to_prover: link_to_prover.into(), chains: chains_path.clone(), config: configs_path, era_chain_id: get_default_era_chain_id(), 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 f82b798b5cba..4804f11da10f 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs @@ -9,9 +9,8 @@ use crate::messages::{MSG_GENERATING_VK_SPINNER, MSG_INITIALIZING_PROVER, MSG_PR pub(crate) async fn run(_args: InitArgs, shell: &Shell) -> anyhow::Result<()> { logger::info(MSG_INITIALIZING_PROVER); let ecosystem_config = EcosystemConfig::from_file(shell)?; - let mut link_to_prover = ecosystem_config.link_to_code.into_os_string(); - link_to_prover.push("/prover"); - shell.change_dir(link_to_prover.clone()); + let link_to_prover = ecosystem_config.link_to_prover; + shell.change_dir(&link_to_prover); let spinner = Spinner::new(MSG_GENERATING_VK_SPINNER); let mut cmd = Cmd::new(cmd!( From 8766e45c2ce242ae511269d042c9cf04e030fa8f Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Fri, 14 Jun 2024 13:08:42 +0200 Subject: [PATCH 07/12] Add link_to_prover to ZkStack config --- ZkStack.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/ZkStack.yaml b/ZkStack.yaml index 33af09572190..7993598f7802 100644 --- a/ZkStack.yaml +++ b/ZkStack.yaml @@ -1,6 +1,7 @@ name: zk l1_network: Localhost link_to_code: . +link_to_prover: ./prover chains: ./chains config: ./configs/ default_chain: era From 511c318b3942c7b83faacb555c91f0f853f49eef Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Fri, 14 Jun 2024 17:03:28 +0200 Subject: [PATCH 08/12] Remove type annotation --- zk_toolbox/crates/zk_inception/src/commands/ecosystem/create.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zk_toolbox/crates/zk_inception/src/commands/ecosystem/create.rs b/zk_toolbox/crates/zk_inception/src/commands/ecosystem/create.rs index af31120b3a49..c7ad0ebfe369 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/ecosystem/create.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/ecosystem/create.rs @@ -51,7 +51,7 @@ fn create(args: EcosystemCreateArgs, shell: &Shell) -> anyhow::Result<()> { shell.create_dir(ecosystem_name)?; shell.change_dir(ecosystem_name); - let configs_path: PathBuf = create_local_configs_dir(shell, ".")?; + let configs_path = create_local_configs_dir(shell, ".")?; let link_to_code = if args.link_to_code.is_empty() { let spinner = Spinner::new(MSG_CLONING_ERA_REPO_SPINNER); From f58ef92adf0d7b08cf63c3787e402864b9932812 Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Tue, 18 Jun 2024 11:11:55 +0200 Subject: [PATCH 09/12] Rename command to generate-sk --- .../zk_inception/src/commands/prover/args/init.rs | 5 ----- .../zk_inception/src/commands/prover/args/mod.rs | 1 - .../src/commands/prover/{init.rs => generate_sk.rs} | 10 ++++------ .../crates/zk_inception/src/commands/prover/mod.rs | 8 +++----- zk_toolbox/crates/zk_inception/src/messages.rs | 5 ++--- 5 files changed, 9 insertions(+), 20 deletions(-) delete mode 100644 zk_toolbox/crates/zk_inception/src/commands/prover/args/init.rs delete mode 100644 zk_toolbox/crates/zk_inception/src/commands/prover/args/mod.rs rename zk_toolbox/crates/zk_inception/src/commands/prover/{init.rs => generate_sk.rs} (64%) diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/args/init.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/args/init.rs deleted file mode 100644 index 8a8709b69e25..000000000000 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/args/init.rs +++ /dev/null @@ -1,5 +0,0 @@ -use clap::Parser; -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Clone, Serialize, Deserialize, Parser)] -pub struct InitArgs {} diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/args/mod.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/args/mod.rs deleted file mode 100644 index 43763f10a418..000000000000 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/args/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod init; diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/generate_sk.rs similarity index 64% rename from zk_toolbox/crates/zk_inception/src/commands/prover/init.rs rename to zk_toolbox/crates/zk_inception/src/commands/prover/generate_sk.rs index 4804f11da10f..ce63af761f48 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/init.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/generate_sk.rs @@ -3,16 +3,14 @@ use common::{cmd::Cmd, logger, spinner::Spinner}; use config::EcosystemConfig; use xshell::{cmd, Shell}; -use super::args::init::InitArgs; -use crate::messages::{MSG_GENERATING_VK_SPINNER, MSG_INITIALIZING_PROVER, MSG_PROVER_INITIALIZED}; +use crate::messages::{MSG_GENERATING_SK_SPINNER, MSG_SK_GENERATED}; -pub(crate) async fn run(_args: InitArgs, shell: &Shell) -> anyhow::Result<()> { - logger::info(MSG_INITIALIZING_PROVER); +pub(crate) async fn run(shell: &Shell) -> anyhow::Result<()> { let ecosystem_config = EcosystemConfig::from_file(shell)?; let link_to_prover = ecosystem_config.link_to_prover; shell.change_dir(&link_to_prover); - let spinner = Spinner::new(MSG_GENERATING_VK_SPINNER); + let spinner = Spinner::new(MSG_GENERATING_SK_SPINNER); let mut cmd = Cmd::new(cmd!( shell, "cargo run --features gpu --release --bin key_generator -- @@ -22,7 +20,7 @@ pub(crate) async fn run(_args: InitArgs, shell: &Shell) -> anyhow::Result<()> { )); cmd.run()?; spinner.finish(); - logger::outro(MSG_PROVER_INITIALIZED); + logger::outro(MSG_SK_GENERATED); Ok(()) } diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/mod.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/mod.rs index fef963f624eb..ea0843eb0f96 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/mod.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/mod.rs @@ -1,17 +1,15 @@ -use args::init::InitArgs; use clap::Subcommand; use xshell::Shell; -mod args; -mod init; +mod generate_sk; #[derive(Subcommand, Debug)] pub enum ProverCommands { /// Initialize prover - Init(InitArgs), + GenerateSK, } pub(crate) async fn run(shell: &Shell, args: ProverCommands) -> anyhow::Result<()> { match args { - ProverCommands::Init(args) => init::run(args, shell).await, + ProverCommands::GenerateSK => generate_sk::run(shell).await, } } diff --git a/zk_toolbox/crates/zk_inception/src/messages.rs b/zk_toolbox/crates/zk_inception/src/messages.rs index c54dbf3995c2..1b3c05258753 100644 --- a/zk_toolbox/crates/zk_inception/src/messages.rs +++ b/zk_toolbox/crates/zk_inception/src/messages.rs @@ -190,6 +190,5 @@ pub(super) fn msg_address_doesnt_have_enough_money_prompt( } /// Prover related messages -pub(super) const MSG_INITIALIZING_PROVER: &str = "Initializing prover"; -pub(super) const MSG_PROVER_INITIALIZED: &str = "Prover initialized successfully"; -pub(super) const MSG_GENERATING_VK_SPINNER: &str = "Generating verification keys..."; +pub(super) const MSG_GENERATING_SK_SPINNER: &str = "Generating setup keys..."; +pub(super) const MSG_SK_GENERATED: &str = "Setup keys generated successfully"; From 3891d63a2c728cfed652f75bf2a9e50ef9853f03 Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Tue, 18 Jun 2024 11:20:06 +0200 Subject: [PATCH 10/12] Add get_link_to_prover --- zk_toolbox/crates/config/src/ecosystem.rs | 12 ------------ .../zk_inception/src/commands/ecosystem/create.rs | 4 ---- .../zk_inception/src/commands/prover/generate_sk.rs | 4 +++- .../crates/zk_inception/src/commands/prover/mod.rs | 1 + .../crates/zk_inception/src/commands/prover/utils.rs | 10 ++++++++++ 5 files changed, 14 insertions(+), 17 deletions(-) create mode 100644 zk_toolbox/crates/zk_inception/src/commands/prover/utils.rs diff --git a/zk_toolbox/crates/config/src/ecosystem.rs b/zk_toolbox/crates/config/src/ecosystem.rs index 932e1177b10f..1557ab21646f 100644 --- a/zk_toolbox/crates/config/src/ecosystem.rs +++ b/zk_toolbox/crates/config/src/ecosystem.rs @@ -25,7 +25,6 @@ struct EcosystemConfigInternal { pub name: String, pub l1_network: L1Network, pub link_to_code: PathBuf, - pub link_to_prover: PathBuf, pub chains: PathBuf, pub config: PathBuf, pub default_chain: String, @@ -41,7 +40,6 @@ pub struct EcosystemConfig { pub name: String, pub l1_network: L1Network, pub link_to_code: PathBuf, - pub link_to_prover: PathBuf, pub chains: PathBuf, pub config: PathBuf, pub default_chain: String, @@ -74,11 +72,6 @@ impl<'de> Deserialize<'de> for EcosystemConfig { .absolutize() .expect("Failed to parse zksync-era path") .to_path_buf(), - link_to_prover: config - .link_to_prover - .absolutize() - .expect("Failed to parse prover path") - .to_path_buf(), chains: config.chains.clone(), config: config.config.clone(), default_chain: config.default_chain.clone(), @@ -208,11 +201,6 @@ impl EcosystemConfig { .absolutize() .expect("Failed to parse zksync-era path") .into(), - link_to_prover: self - .link_to_prover - .absolutize() - .expect("Failed to parse prover path") - .into(), chains: self.chains.clone(), config: self.config.clone(), default_chain: self.default_chain.clone(), diff --git a/zk_toolbox/crates/zk_inception/src/commands/ecosystem/create.rs b/zk_toolbox/crates/zk_inception/src/commands/ecosystem/create.rs index c7ad0ebfe369..4daab36c56b8 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/ecosystem/create.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/ecosystem/create.rs @@ -64,9 +64,6 @@ fn create(args: EcosystemCreateArgs, shell: &Shell) -> anyhow::Result<()> { path }; - let mut link_to_prover = link_to_code.clone().into_os_string(); - link_to_prover.push("/prover"); - let spinner = Spinner::new(MSG_CREATING_INITIAL_CONFIGURATIONS_SPINNER); let chain_config = args.chain_config(); let chains_path = shell.create_dir("chains")?; @@ -79,7 +76,6 @@ fn create(args: EcosystemCreateArgs, shell: &Shell) -> anyhow::Result<()> { name: ecosystem_name.clone(), l1_network: args.l1_network, link_to_code: link_to_code.clone(), - link_to_prover: link_to_prover.into(), chains: chains_path.clone(), config: configs_path, era_chain_id: get_default_era_chain_id(), diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/generate_sk.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/generate_sk.rs index ce63af761f48..a12832923aea 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/generate_sk.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/generate_sk.rs @@ -5,9 +5,11 @@ use xshell::{cmd, Shell}; use crate::messages::{MSG_GENERATING_SK_SPINNER, MSG_SK_GENERATED}; +use super::utils::get_link_to_prover; + pub(crate) async fn run(shell: &Shell) -> anyhow::Result<()> { let ecosystem_config = EcosystemConfig::from_file(shell)?; - let link_to_prover = ecosystem_config.link_to_prover; + let link_to_prover = get_link_to_prover(&ecosystem_config); shell.change_dir(&link_to_prover); let spinner = Spinner::new(MSG_GENERATING_SK_SPINNER); diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/mod.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/mod.rs index ea0843eb0f96..c617b915a52c 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/mod.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/mod.rs @@ -1,6 +1,7 @@ use clap::Subcommand; use xshell::Shell; mod generate_sk; +mod utils; #[derive(Subcommand, Debug)] pub enum ProverCommands { diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/utils.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/utils.rs new file mode 100644 index 000000000000..4dae70863dc9 --- /dev/null +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/utils.rs @@ -0,0 +1,10 @@ +use std::path::PathBuf; + +use config::EcosystemConfig; + +pub(crate) fn get_link_to_prover(config: &EcosystemConfig) -> PathBuf { + let link_to_code = config.link_to_code.clone(); + let mut link_to_prover = link_to_code.into_os_string(); + link_to_prover.push("/prover"); + link_to_prover.into() +} From 595e98fbfce65b81aebb06f202d24f69f0678d31 Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Tue, 18 Jun 2024 11:20:59 +0200 Subject: [PATCH 11/12] fmt --- .../crates/zk_inception/src/commands/prover/generate_sk.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zk_toolbox/crates/zk_inception/src/commands/prover/generate_sk.rs b/zk_toolbox/crates/zk_inception/src/commands/prover/generate_sk.rs index a12832923aea..a14dd6fb87e5 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/prover/generate_sk.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/prover/generate_sk.rs @@ -3,9 +3,8 @@ use common::{cmd::Cmd, logger, spinner::Spinner}; use config::EcosystemConfig; use xshell::{cmd, Shell}; -use crate::messages::{MSG_GENERATING_SK_SPINNER, MSG_SK_GENERATED}; - use super::utils::get_link_to_prover; +use crate::messages::{MSG_GENERATING_SK_SPINNER, MSG_SK_GENERATED}; pub(crate) async fn run(shell: &Shell) -> anyhow::Result<()> { let ecosystem_config = EcosystemConfig::from_file(shell)?; From 8a84d66736d82a5e1a4b071f3a0815ea7f93346b Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Tue, 18 Jun 2024 14:20:02 +0200 Subject: [PATCH 12/12] Remove link_to_prover from ZkStack config --- ZkStack.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/ZkStack.yaml b/ZkStack.yaml index 7993598f7802..33af09572190 100644 --- a/ZkStack.yaml +++ b/ZkStack.yaml @@ -1,7 +1,6 @@ name: zk l1_network: Localhost link_to_code: . -link_to_prover: ./prover chains: ./chains config: ./configs/ default_chain: era