Skip to content

Commit

Permalink
Remove obsolete deps for verifier bin
Browse files Browse the repository at this point in the history
  • Loading branch information
slowli committed Nov 7, 2024
1 parent 2135621 commit db5ecfc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 43 deletions.
5 changes: 1 addition & 4 deletions Cargo.lock

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

5 changes: 1 addition & 4 deletions core/bin/contract-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ publish = false

[dependencies]
zksync_dal.workspace = true
zksync_env_config.workspace = true
zksync_config = { workspace = true, features = ["observability_ext"] }
zksync_contract_verifier_lib.workspace = true
zksync_queued_job_processor.workspace = true
Expand All @@ -21,8 +20,6 @@ zksync_vlog.workspace = true
zksync_core_leftovers.workspace = true

anyhow.workspace = true
clap = { workspace = true, features = ["derive"] }
tokio = { workspace = true, features = ["full"] }
futures.workspace = true
ctrlc.workspace = true
structopt.workspace = true
tracing.workspace = true
53 changes: 18 additions & 35 deletions core/bin/contract-verifier/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::{cell::RefCell, time::Duration};
use std::{path::PathBuf, time::Duration};

use anyhow::Context;
use futures::{channel::mpsc, executor::block_on, SinkExt, StreamExt};
use structopt::StructOpt;
use anyhow::Context as _;
use clap::Parser;
use tokio::sync::watch;
use zksync_config::configs::PrometheusConfig;
use zksync_contract_verifier_lib::ContractVerifier;
Expand All @@ -12,27 +11,31 @@ use zksync_queued_job_processor::JobProcessor;
use zksync_utils::wait_for_tasks::ManagedTasks;
use zksync_vlog::prometheus::PrometheusExporterConfig;

#[derive(StructOpt)]
#[structopt(name = "ZKsync contract code verifier", author = "Matter Labs")]
#[derive(Debug, Parser)]
#[command(name = "ZKsync contract code verifier", author = "Matter Labs")]
struct Opt {
/// Number of jobs to process. If None, runs indefinitely.
#[structopt(long)]
#[arg(long)]
jobs_number: Option<usize>,
/// Path to the configuration file.
#[structopt(long)]
config_path: Option<std::path::PathBuf>,
#[arg(long)]
config_path: Option<PathBuf>,
/// Path to the secrets file.
#[structopt(long)]
secrets_path: Option<std::path::PathBuf>,
#[arg(long)]
secrets_path: Option<PathBuf>,
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let opt = Opt::from_args();
let opt = Opt::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("ObservabilityConfig")?;
let _observability_guard = observability_config.install()?;

let database_secrets = load_database_secrets(opt.secrets_path).context("database secrets")?;
let verifier_config = general_config
.contract_verifier
.context("ContractVerifierConfig")?;
Expand All @@ -46,33 +49,13 @@ async fn main() -> anyhow::Result<()> {
.context("Master DB URL is absent")?,
)
.build()
.await
.unwrap();

let observability_config = general_config
.observability
.context("ObservabilityConfig")?;

let _observability_guard = observability_config.install()?;
.await?;

let (stop_sender, stop_receiver) = watch::channel(false);
let (stop_signal_sender, mut stop_signal_receiver) = mpsc::channel(256);
{
let stop_signal_sender = RefCell::new(stop_signal_sender.clone());
ctrlc::set_handler(move || {
let mut sender = stop_signal_sender.borrow_mut();
block_on(sender.send(true)).expect("Ctrl+C signal send");
})
.expect("Error setting Ctrl+C handler");
}

let contract_verifier = ContractVerifier::new(verifier_config.compilation_timeout(), pool)
.await
.context("failed initializing contract verifier")?;
let tasks = vec![
// TODO PLA-335: Leftovers after the prover DB split.
// The prover connection pool is not used by the contract verifier, but we need to pass it
// since `JobProcessor` trait requires it.
tokio::spawn(contract_verifier.run(stop_receiver.clone(), opt.jobs_number)),
tokio::spawn(
PrometheusExporterConfig::pull(prometheus_config.listener_port).run(stop_receiver),
Expand All @@ -82,7 +65,7 @@ async fn main() -> anyhow::Result<()> {
let mut tasks = ManagedTasks::new(tasks);
tokio::select! {
() = tasks.wait_single() => {},
_ = stop_signal_receiver.next() => {
_ = tokio::signal::ctrl_c() => {
tracing::info!("Stop signal received, shutting down");
},
};
Expand Down

0 comments on commit db5ecfc

Please sign in to comment.