From ee9d35bf3f77897d1175594cb570d87b217fd1c9 Mon Sep 17 00:00:00 2001 From: Ivan Litteri Date: Tue, 16 Apr 2024 17:33:34 -0300 Subject: [PATCH 1/4] Move jobs cmd to status cmd module --- .../{jobs_status.rs => status/jobs.rs} | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) rename prover/prover_cli/src/commands/{jobs_status.rs => status/jobs.rs} (100%) diff --git a/prover/prover_cli/src/commands/jobs_status.rs b/prover/prover_cli/src/commands/status/jobs.rs similarity index 100% rename from prover/prover_cli/src/commands/jobs_status.rs rename to prover/prover_cli/src/commands/status/jobs.rs index 54a5bf04598..01205964752 100644 --- a/prover/prover_cli/src/commands/jobs_status.rs +++ b/prover/prover_cli/src/commands/status/jobs.rs @@ -13,27 +13,6 @@ pub(crate) struct Args { verbose: bool, } -fn pretty_print_job_status( - l1_batch_number: &L1BatchNumber, - statistics: &JobCountStatistics, - verbose: bool, -) { - let total_jobs = - statistics.queued + statistics.in_progress + statistics.failed + statistics.successful; - let progress = (statistics.successful as f32 / total_jobs as f32) * 100.0; - println!("Batch number: {}", l1_batch_number); - println!( - "Progress: {:.2}% ({}/{})", - progress, statistics.successful, total_jobs - ); - if verbose { - println!("In progress: {}", statistics.in_progress); - println!("Queued: {}", statistics.in_progress); - println!("Successful: {}", statistics.in_progress); - } - println!("Failed: {}", statistics.failed); -} - pub(crate) async fn run(args: Args) -> anyhow::Result<()> { let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?; @@ -61,3 +40,24 @@ pub(crate) async fn run(args: Args) -> anyhow::Result<()> { } Ok(()) } + +fn pretty_print_job_status( + l1_batch_number: &L1BatchNumber, + statistics: &JobCountStatistics, + verbose: bool, +) { + let total_jobs = + statistics.queued + statistics.in_progress + statistics.failed + statistics.successful; + let progress = (statistics.successful as f32 / total_jobs as f32) * 100.0; + println!("Batch number: {}", l1_batch_number); + println!( + "Progress: {:.2}% ({}/{})", + progress, statistics.successful, total_jobs + ); + if verbose { + println!("In progress: {}", statistics.in_progress); + println!("Queued: {}", statistics.in_progress); + println!("Successful: {}", statistics.in_progress); + } + println!("Failed: {}", statistics.failed); +} From 82faf32849c2904f7e5162c561731476cd1de9ab Mon Sep 17 00:00:00 2001 From: Ivan Litteri Date: Tue, 16 Apr 2024 17:34:23 -0300 Subject: [PATCH 2/4] Refactor status cmd --- prover/prover_cli/src/cli.rs | 7 ++++--- prover/prover_cli/src/commands/mod.rs | 10 +++++++++- prover/prover_cli/src/commands/status/mod.rs | 9 +++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 prover/prover_cli/src/commands/status/mod.rs diff --git a/prover/prover_cli/src/cli.rs b/prover/prover_cli/src/cli.rs index aae354d09ea..cafdd2dff99 100644 --- a/prover/prover_cli/src/cli.rs +++ b/prover/prover_cli/src/cli.rs @@ -1,6 +1,6 @@ use clap::{command, Parser, Subcommand}; -use crate::commands::{get_file_info, jobs_status}; +use crate::commands::{self, get_file_info, status}; pub const VERSION_STRING: &str = env!("CARGO_PKG_VERSION"); @@ -14,14 +14,15 @@ struct ProverCLI { #[derive(Subcommand)] enum ProverCommand { FileInfo(get_file_info::Args), - StatusJobs(jobs_status::Args), + #[command(subcommand)] + Status(commands::StatusCommand), } pub async fn start() -> anyhow::Result<()> { let ProverCLI { command } = ProverCLI::parse(); match command { ProverCommand::FileInfo(args) => get_file_info::run(args).await?, - ProverCommand::StatusJobs(args) => jobs_status::run(args).await?, + ProverCommand::Status(status_cmd) => status::run(status_cmd).await?, }; Ok(()) diff --git a/prover/prover_cli/src/commands/mod.rs b/prover/prover_cli/src/commands/mod.rs index 57da8f98a9c..e53bb47fdc3 100644 --- a/prover/prover_cli/src/commands/mod.rs +++ b/prover/prover_cli/src/commands/mod.rs @@ -1,2 +1,10 @@ +use clap::Subcommand; +use status::jobs; + pub(crate) mod get_file_info; -pub(crate) mod jobs_status; +pub(crate) mod status; + +#[derive(Subcommand)] +pub(crate) enum StatusCommand { + Jobs(jobs::Args), +} diff --git a/prover/prover_cli/src/commands/status/mod.rs b/prover/prover_cli/src/commands/status/mod.rs new file mode 100644 index 00000000000..761bf53c57a --- /dev/null +++ b/prover/prover_cli/src/commands/status/mod.rs @@ -0,0 +1,9 @@ +use super::StatusCommand; + +pub(crate) mod jobs; + +pub(crate) async fn run(status_cmd: StatusCommand) -> anyhow::Result<()> { + match status_cmd { + StatusCommand::Jobs(args) => jobs::run(args).await, + } +} From aa448645ace357a4be504695cde5735e7327aff1 Mon Sep 17 00:00:00 2001 From: Ivan Litteri Date: Tue, 16 Apr 2024 17:34:35 -0300 Subject: [PATCH 3/4] Update Cargo.lock --- prover/Cargo.lock | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/prover/Cargo.lock b/prover/Cargo.lock index edaf63a367a..7262bd7ecda 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -1756,15 +1756,11 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ - "humantime", - "is-terminal", "humantime", "is-terminal", "log", "regex", "termcolor", - "regex", - "termcolor", ] [[package]] @@ -1875,16 +1871,6 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" -[[package]] -name = "eyre" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" -dependencies = [ - "indenter", - "once_cell", -] - [[package]] name = "fastrand" version = "2.0.1" @@ -2731,12 +2717,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "indenter" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" - [[package]] name = "indexmap" version = "1.9.3" @@ -4359,11 +4339,9 @@ dependencies = [ "clap 4.4.6", "colored", "env_logger 0.10.2", - "eyre", "hex", "log", "prover_dal", - "sqlx", "tokio", "tracing", "tracing-subscriber", From 3fe32b6e164a54528dca3cb4034a73c978a62d18 Mon Sep 17 00:00:00 2001 From: Ivan Litteri Date: Tue, 16 Apr 2024 17:40:30 -0300 Subject: [PATCH 4/4] zk fmt --- prover/prover_cli/src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/prover/prover_cli/src/main.rs b/prover/prover_cli/src/main.rs index f2a7dd71026..a1060476be3 100644 --- a/prover/prover_cli/src/main.rs +++ b/prover/prover_cli/src/main.rs @@ -3,6 +3,8 @@ use prover_cli::cli; #[tokio::main] async fn main() { env_logger::builder() + .filter_module("zksync_db_connection::connection_pool", log::LevelFilter::Off) + .filter_module("sqlx::query", log::LevelFilter::Off) .filter_level(log::LevelFilter::Debug) .init();