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

feat(zk_toolbox): Add prover generate-sk command #2222

Merged
merged 23 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f3efb31
Add init command boilerplate
matias-gonz Jun 12, 2024
0a694dc
Merge branch 'main' into matias-gonz-zk-toolbox-add-prover-init
matias-gonz Jun 12, 2024
ee26056
Merge branch 'main' into matias-gonz-zk-toolbox-add-prover-init
matias-gonz Jun 13, 2024
d82b8b3
Run key generator
matias-gonz Jun 13, 2024
351c9ee
fix setup data path
matias-gonz Jun 13, 2024
866bdc9
Refactor msgs
matias-gonz Jun 13, 2024
535fd18
fmt
matias-gonz Jun 13, 2024
4458d71
Merge branch 'main' into matias-gonz-zk-toolbox-add-prover-init
matias-gonz Jun 13, 2024
ae75d11
Merge branch 'main' into matias-gonz-zk-toolbox-add-prover-init
matias-gonz Jun 14, 2024
660f1f8
Merge branch 'main' into matias-gonz-zk-toolbox-add-prover-init
matias-gonz Jun 14, 2024
29e4459
Save link to prover in ecosystem config
matias-gonz Jun 14, 2024
8766e45
Add link_to_prover to ZkStack config
matias-gonz Jun 14, 2024
511c318
Remove type annotation
matias-gonz Jun 14, 2024
8ed3f19
Merge branch 'main' into matias-gonz-zk-toolbox-add-prover-init
matias-gonz Jun 14, 2024
6628238
Merge branch 'main' into matias-gonz-zk-toolbox-add-prover-init
matias-gonz Jun 18, 2024
f58ef92
Rename command to generate-sk
matias-gonz Jun 18, 2024
3891d63
Add get_link_to_prover
matias-gonz Jun 18, 2024
595e98f
fmt
matias-gonz Jun 18, 2024
15002a8
Merge branch 'main' into matias-gonz-zk-toolbox-add-prover-init
matias-gonz Jun 18, 2024
8a84d66
Remove link_to_prover from ZkStack config
matias-gonz Jun 18, 2024
4eb1363
Merge branch 'matias-gonz-zk-toolbox-add-prover-init' of github.com:m…
matias-gonz Jun 18, 2024
af51320
Merge branch 'main' into matias-gonz-zk-toolbox-add-prover-init
matias-gonz Jun 18, 2024
ec60f96
Merge branch 'main' into matias-gonz-zk-toolbox-add-prover-init
matias-gonz Jun 18, 2024
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
1 change: 1 addition & 0 deletions zk_toolbox/crates/zk_inception/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ pub mod args;
pub mod chain;
pub mod containers;
pub mod ecosystem;
pub mod prover;
pub mod server;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use clap::Parser;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, Parser)]
pub struct InitArgs {}
Deniallugo marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod init;
29 changes: 29 additions & 0 deletions zk_toolbox/crates/zk_inception/src/commands/prover/init.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use anyhow::Ok;
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};

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");
Deniallugo marked this conversation as resolved.
Show resolved Hide resolved
shell.change_dir(link_to_prover.clone());

let spinner = Spinner::new(MSG_GENERATING_VK_SPINNER);
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={link_to_prover}/vk_setup_data_generator_server_fri/data"
));
Deniallugo marked this conversation as resolved.
Show resolved Hide resolved
cmd.run()?;
spinner.finish();
logger::outro(MSG_PROVER_INITIALIZED);

Ok(())
}
17 changes: 17 additions & 0 deletions zk_toolbox/crates/zk_inception/src/commands/prover/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
}
}
8 changes: 7 additions & 1 deletion zk_toolbox/crates/zk_inception/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)?,
}
Expand Down
5 changes: 5 additions & 0 deletions zk_toolbox/crates/zk_inception/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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...";
Loading