diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 44c2a8b8395f..c739cc990453 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -9298,6 +9298,7 @@ dependencies = [ "anyhow", "async-trait", "circuit_definitions 1.5.0", + "clap 4.5.4", "ctrlc", "futures 0.3.30", "local-ip-address", @@ -9316,6 +9317,7 @@ dependencies = [ "zksync_config", "zksync_env_config", "zksync_object_store", + "zksync_prover_config", "zksync_prover_fri_types", "zksync_prover_fri_utils", "zksync_queued_job_processor", diff --git a/prover/prover_fri/Cargo.toml b/prover/prover_fri/Cargo.toml index 5b618c928ed4..9bce1f2581b8 100644 --- a/prover/prover_fri/Cargo.toml +++ b/prover/prover_fri/Cargo.toml @@ -20,6 +20,7 @@ vlog.workspace = true zksync_object_store.workspace = true zksync_queued_job_processor.workspace = true zksync_prover_fri_utils.workspace = true +zksync_prover_config.workspace = true zksync_prover_fri_types.workspace = true zksync_utils.workspace = true vk_setup_data_generator_server_fri.workspace = true @@ -41,6 +42,7 @@ async-trait.workspace = true local-ip-address.workspace = true reqwest = { workspace = true, features = ["blocking"] } regex.workspace = true +clap = { workspace = true, features = ["derive"] } [features] default = [] diff --git a/prover/prover_fri/src/main.rs b/prover/prover_fri/src/main.rs index 86fd114fa12e..ab2a4d1575c5 100644 --- a/prover/prover_fri/src/main.rs +++ b/prover/prover_fri/src/main.rs @@ -3,6 +3,7 @@ use std::{future::Future, sync::Arc, time::Duration}; use anyhow::Context as _; +use clap::Parser; use local_ip_address::local_ip; use prometheus_exporter::PrometheusExporterConfig; use prover_dal::{ConnectionPool, Prover, ProverDal}; @@ -10,14 +11,10 @@ use tokio::{ sync::{oneshot, watch::Receiver, Notify}, task::JoinHandle, }; -use zksync_config::configs::{ - fri_prover_group::FriProverGroupConfig, DatabaseSecrets, FriProverConfig, ObservabilityConfig, -}; -use zksync_env_config::{ - object_store::{ProverObjectStoreConfig, PublicObjectStoreConfig}, - FromEnv, -}; +use zksync_config::configs::{DatabaseSecrets, FriProverConfig}; +use zksync_env_config::FromEnv; use zksync_object_store::{ObjectStore, ObjectStoreFactory}; +use zksync_prover_config::{load_database_secrets, load_general_config}; use zksync_prover_fri_types::PROVER_PROTOCOL_SEMANTIC_VERSION; use zksync_prover_fri_utils::{get_all_circuit_id_round_tuples_for, region_fetcher::get_zone}; use zksync_queued_job_processor::JobProcessor; @@ -58,8 +55,14 @@ async fn graceful_shutdown(port: u16) -> anyhow::Result #[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 + .context("observability config")?; let log_format: vlog::LogFormat = observability_config .log_format .parse() @@ -91,7 +94,7 @@ async fn main() -> anyhow::Result<()> { tracing::info!("No sentry URL was provided"); } - let prover_config = FriProverConfig::from_env().context("FriProverConfig::from_env()")?; + let prover_config = general_config.prover_config.context("fri_prover config")?; let exporter_config = PrometheusExporterConfig::pull(prover_config.prometheus_port); let (stop_signal_sender, stop_signal_receiver) = oneshot::channel(); @@ -104,23 +107,28 @@ async fn main() -> anyhow::Result<()> { .context("Error setting Ctrl+C handler")?; let (stop_sender, stop_receiver) = tokio::sync::watch::channel(false); - let object_store_config = - ProverObjectStoreConfig::from_env().context("ProverObjectStoreConfig::from_env()")?; - let object_store_factory = ObjectStoreFactory::new(object_store_config.0); - let public_object_store_config = - PublicObjectStoreConfig::from_env().context("PublicObjectStoreConfig::from_env()")?; + let prover_object_store_config = prover_config + .prover_object_store + .clone() + .context("prover object store config")?; + let object_store_factory = ObjectStoreFactory::new(prover_object_store_config); + let public_object_store_config = prover_config + .public_object_store + .clone() + .context("public object store config")?; let public_blob_store = match prover_config.shall_save_to_public_bucket { false => None, true => Some( - ObjectStoreFactory::new(public_object_store_config.0) + ObjectStoreFactory::new(public_object_store_config) .create_store() .await?, ), }; let specialized_group_id = prover_config.specialized_group_id; - let circuit_ids_for_round_to_be_proven = FriProverGroupConfig::from_env() - .context("FriProverGroupConfig::from_env()")? + let circuit_ids_for_round_to_be_proven = general_config + .prover_group_config + .context("prover group config")? .get_circuit_ids_for_group_id(specialized_group_id) .unwrap_or_default(); let circuit_ids_for_round_to_be_proven = @@ -131,7 +139,6 @@ async fn main() -> anyhow::Result<()> { specialized_group_id, circuit_ids_for_round_to_be_proven.clone() ); - let database_secrets = DatabaseSecrets::from_env().context("DatabaseSecrets")?; // There are 2 threads using the connection pool: // 1. The prover thread, which is used to update the prover job status. @@ -302,3 +309,12 @@ async fn get_prover_tasks( Ok(tasks) } + +#[derive(Debug, Parser)] +#[command(author = "Matter Labs", version)] +pub(crate) struct Cli { + #[arg(long)] + pub(crate) config_path: Option, + #[arg(long)] + pub(crate) secrets_path: Option, +}