Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
feat(prover): Add file based config for compressor (matter-labs#2353)
Browse files Browse the repository at this point in the history
Add file based config for compressor
  • Loading branch information
matias-gonz authored Jun 28, 2024
1 parent 159af3c commit 1d6f87d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
2 changes: 2 additions & 0 deletions prover/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions prover/proof_fri_compressor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"] }
Expand Down
52 changes: 33 additions & 19 deletions prover/proof_fri_compressor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<usize>,
#[arg(long)]
#[arg(short)]
n_iterations: Option<usize>,
#[arg(long)]
pub(crate) config_path: Option<std::path::PathBuf>,
#[arg(long)]
pub(crate) secrets_path: Option<std::path::PathBuf>,
}

#[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()
Expand All @@ -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::<Prover>::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?;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 1d6f87d

Please sign in to comment.