diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 9c3ecb04a85a..63c9601fab6a 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -8078,6 +8078,7 @@ dependencies = [ "async-trait", "bincode", "circuit_sequencer_api 0.1.50", + "clap 4.5.4", "ctrlc", "futures 0.3.30", "reqwest", @@ -8094,6 +8095,7 @@ dependencies = [ "zksync_config", "zksync_env_config", "zksync_object_store", + "zksync_prover_config", "zksync_prover_dal", "zksync_prover_fri_types", "zksync_prover_interface", diff --git a/prover/proof_fri_compressor/Cargo.toml b/prover/proof_fri_compressor/Cargo.toml index f32ee9a1fc0a..3342aafe4baa 100644 --- a/prover/proof_fri_compressor/Cargo.toml +++ b/prover/proof_fri_compressor/Cargo.toml @@ -18,6 +18,7 @@ zksync_env_config.workspace = true zksync_object_store.workspace = true zksync_prover_interface.workspace = true zksync_utils.workspace = true +zksync_prover_config.workspace = true zksync_prover_fri_types.workspace = true zksync_queued_job_processor.workspace = true vk_setup_data_generator_server_fri.workspace = true @@ -33,6 +34,7 @@ structopt.workspace = true tokio = { workspace = true, features = ["time", "macros"] } futures = { workspace = true, features = ["compat"] } ctrlc = { workspace = true, features = ["termination"] } +clap = { workspace = true, features = ["derive"] } async-trait.workspace = true bincode.workspace = true reqwest = { workspace = true, features = ["blocking"] } diff --git a/prover/proof_fri_compressor/src/main.rs b/prover/proof_fri_compressor/src/main.rs index 7a249dfe2ef1..7eb31c97ae29 100644 --- a/prover/proof_fri_compressor/src/main.rs +++ b/prover/proof_fri_compressor/src/main.rs @@ -3,11 +3,11 @@ use std::{env, time::Duration}; use anyhow::Context as _; -use structopt::StructOpt; +use clap::Parser; use tokio::sync::{oneshot, watch}; -use zksync_config::configs::{DatabaseSecrets, FriProofCompressorConfig, ObservabilityConfig}; -use zksync_env_config::{object_store::ProverObjectStoreConfig, FromEnv}; +use zksync_env_config::object_store::ProverObjectStoreConfig; use zksync_object_store::ObjectStoreFactory; +use zksync_prover_config::{load_database_secrets, load_general_config}; use zksync_prover_dal::{ConnectionPool, Prover}; use zksync_prover_fri_types::PROVER_PROTOCOL_SEMANTIC_VERSION; use zksync_queued_job_processor::JobProcessor; @@ -22,21 +22,30 @@ mod compressor; mod initial_setup_keys; mod metrics; -#[derive(Debug, StructOpt)] -#[structopt( - name = "zksync_proof_fri_compressor", - about = "Tool for compressing FRI proofs to old bellman proof" -)] -struct Opt { +#[derive(Debug, Parser)] +#[command(author = "Matter Labs", version)] +struct Cli { /// Number of times proof fri compressor should be run. - #[structopt(short = "n", long = "n_iterations")] - number_of_iterations: Option, + #[arg(long)] + #[arg(short)] + n_iterations: Option, + #[arg(long)] + pub(crate) config_path: Option, + #[arg(long)] + pub(crate) secrets_path: Option, } #[tokio::main] async fn main() -> anyhow::Result<()> { - let observability_config = - ObservabilityConfig::from_env().context("ObservabilityConfig::from_env()")?; + let opt = Cli::parse(); + + let general_config = load_general_config(opt.config_path).context("general config")?; + let database_secrets = load_database_secrets(opt.secrets_path).context("database secrets")?; + + let observability_config = general_config + .observability + .expect("observability config") + .clone(); let log_format: zksync_vlog::LogFormat = observability_config .log_format .parse() @@ -60,15 +69,20 @@ async fn main() -> anyhow::Result<()> { } let _guard = builder.build(); - let opt = Opt::from_args(); - let config = FriProofCompressorConfig::from_env().context("FriProofCompressorConfig")?; - let database_secrets = DatabaseSecrets::from_env().context("PostgresConfig::from_env()")?; + let config = general_config + .proof_compressor_config + .context("FriProofCompressorConfig")?; let pool = ConnectionPool::::singleton(database_secrets.prover_url()?) .build() .await .context("failed to build a connection pool")?; - let object_store_config = - ProverObjectStoreConfig::from_env().context("ProverObjectStoreConfig::from_env()")?; + let object_store_config = ProverObjectStoreConfig( + general_config + .prover_config + .expect("ProverConfig") + .prover_object_store + .context("ProverObjectStoreConfig")?, + ); let blob_store = ObjectStoreFactory::new(object_store_config.0) .create_store() .await?; @@ -109,7 +123,7 @@ async fn main() -> anyhow::Result<()> { ); let tasks = vec![ tokio::spawn(prometheus_config.run(stop_receiver.clone())), - tokio::spawn(proof_compressor.run(stop_receiver, opt.number_of_iterations)), + tokio::spawn(proof_compressor.run(stop_receiver, opt.n_iterations)), ]; let mut tasks = ManagedTasks::new(tasks).allow_tasks_to_finish();