From 214f981880ca1ea879e805f8fc392f5c422be08d Mon Sep 17 00:00:00 2001 From: Joaquin Carletti <56092489+ColoCarletti@users.noreply.github.com> Date: Fri, 7 Jun 2024 10:26:49 -0300 Subject: [PATCH] fix(prover_cli): Fix delete command (#2119) Changes: - Get database url from the `prover_cli` config. - Remove the deletion of archived jobs. --------- Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> --- prover/prover_cli/src/cli.rs | 2 +- prover/prover_cli/src/commands/delete.rs | 9 +++-- ...c5fa3bc52bdf0cde06a6dbd40ed5362b61535.json | 12 ------- ...855d36a2d280a5a021155a8d6aafe7b9689c9.json | 14 -------- .../src/fri_gpu_prover_queue_dal.rs | 15 +-------- prover/prover_dal/src/fri_prover_dal.rs | 33 +------------------ 6 files changed, 7 insertions(+), 78 deletions(-) delete mode 100644 prover/prover_dal/.sqlx/query-18a14b47eaac25e8a446530da97c5fa3bc52bdf0cde06a6dbd40ed5362b61535.json delete mode 100644 prover/prover_dal/.sqlx/query-dcde8cc1a522b90a03c25f2fc5b855d36a2d280a5a021155a8d6aafe7b9689c9.json diff --git a/prover/prover_cli/src/cli.rs b/prover/prover_cli/src/cli.rs index 08025c904e7c..57422a448881 100644 --- a/prover/prover_cli/src/cli.rs +++ b/prover/prover_cli/src/cli.rs @@ -42,7 +42,7 @@ pub async fn start() -> anyhow::Result<()> { match command { ProverCommand::FileInfo(args) => get_file_info::run(args).await?, ProverCommand::Config(cfg) => config::run(cfg).await?, - ProverCommand::Delete(args) => delete::run(args).await?, + ProverCommand::Delete(args) => delete::run(args, config).await?, ProverCommand::Status(cmd) => cmd.run(config).await?, ProverCommand::Requeue(args) => requeue::run(args, config).await?, ProverCommand::Restart(args) => restart::run(args).await?, diff --git a/prover/prover_cli/src/commands/delete.rs b/prover/prover_cli/src/commands/delete.rs index 48bc56defeec..7df869b1311b 100644 --- a/prover/prover_cli/src/commands/delete.rs +++ b/prover/prover_cli/src/commands/delete.rs @@ -2,10 +2,10 @@ use anyhow::Context; use clap::Args as ClapArgs; use dialoguer::{theme::ColorfulTheme, Input}; use prover_dal::{Connection, ConnectionPool, Prover, ProverDal}; -use zksync_config::configs::DatabaseSecrets; -use zksync_env_config::FromEnv; use zksync_types::L1BatchNumber; +use crate::cli::ProverCLIConfig; + #[derive(ClapArgs)] pub(crate) struct Args { /// Delete data from all batches @@ -22,7 +22,7 @@ pub(crate) struct Args { batch: L1BatchNumber, } -pub(crate) async fn run(args: Args) -> anyhow::Result<()> { +pub(crate) async fn run(args: Args, config: ProverCLIConfig) -> anyhow::Result<()> { let confirmation = Input::::with_theme(&ColorfulTheme::default()) .with_prompt("Are you sure you want to delete the data?") .default("no".to_owned()) @@ -33,8 +33,7 @@ pub(crate) async fn run(args: Args) -> anyhow::Result<()> { return Ok(()); } - let secrets = DatabaseSecrets::from_env()?; - let prover_connection_pool = ConnectionPool::::singleton(secrets.prover_url()?) + let prover_connection_pool = ConnectionPool::::singleton(config.db_url) .build() .await .context("failed to build a prover_connection_pool")?; diff --git a/prover/prover_dal/.sqlx/query-18a14b47eaac25e8a446530da97c5fa3bc52bdf0cde06a6dbd40ed5362b61535.json b/prover/prover_dal/.sqlx/query-18a14b47eaac25e8a446530da97c5fa3bc52bdf0cde06a6dbd40ed5362b61535.json deleted file mode 100644 index 957df12c566a..000000000000 --- a/prover/prover_dal/.sqlx/query-18a14b47eaac25e8a446530da97c5fa3bc52bdf0cde06a6dbd40ed5362b61535.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n DELETE FROM prover_jobs_fri_archive\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [] - }, - "nullable": [] - }, - "hash": "18a14b47eaac25e8a446530da97c5fa3bc52bdf0cde06a6dbd40ed5362b61535" -} diff --git a/prover/prover_dal/.sqlx/query-dcde8cc1a522b90a03c25f2fc5b855d36a2d280a5a021155a8d6aafe7b9689c9.json b/prover/prover_dal/.sqlx/query-dcde8cc1a522b90a03c25f2fc5b855d36a2d280a5a021155a8d6aafe7b9689c9.json deleted file mode 100644 index 42710feda153..000000000000 --- a/prover/prover_dal/.sqlx/query-dcde8cc1a522b90a03c25f2fc5b855d36a2d280a5a021155a8d6aafe7b9689c9.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n DELETE FROM prover_jobs_fri_archive\n WHERE\n l1_batch_number = $1;\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "dcde8cc1a522b90a03c25f2fc5b855d36a2d280a5a021155a8d6aafe7b9689c9" -} diff --git a/prover/prover_dal/src/fri_gpu_prover_queue_dal.rs b/prover/prover_dal/src/fri_gpu_prover_queue_dal.rs index 8cb5a7ad4163..753b65b4ef06 100644 --- a/prover/prover_dal/src/fri_gpu_prover_queue_dal.rs +++ b/prover/prover_dal/src/fri_gpu_prover_queue_dal.rs @@ -248,20 +248,7 @@ impl FriGpuProverQueueDal<'_, '_> { .await } - pub async fn delete_gpu_prover_queue_fri_archive( - &mut self, - ) -> sqlx::Result { - sqlx::query!( - r#" - DELETE FROM gpu_prover_queue_fri - "# - ) - .execute(self.storage.conn()) - .await - } - pub async fn delete(&mut self) -> sqlx::Result { - self.delete_gpu_prover_queue_fri().await?; - self.delete_gpu_prover_queue_fri_archive().await + self.delete_gpu_prover_queue_fri().await } } diff --git a/prover/prover_dal/src/fri_prover_dal.rs b/prover/prover_dal/src/fri_prover_dal.rs index 35fb46e8aff3..2dfb0f7e0baa 100644 --- a/prover/prover_dal/src/fri_prover_dal.rs +++ b/prover/prover_dal/src/fri_prover_dal.rs @@ -737,29 +737,11 @@ impl FriProverDal<'_, '_> { .await } - pub async fn delete_prover_jobs_fri_archive_batch_data( - &mut self, - l1_batch_number: L1BatchNumber, - ) -> sqlx::Result { - sqlx::query!( - r#" - DELETE FROM prover_jobs_fri_archive - WHERE - l1_batch_number = $1; - "#, - i64::from(l1_batch_number.0) - ) - .execute(self.storage.conn()) - .await - } - pub async fn delete_batch_data( &mut self, l1_batch_number: L1BatchNumber, ) -> sqlx::Result { self.delete_prover_jobs_fri_batch_data(l1_batch_number) - .await?; - self.delete_prover_jobs_fri_archive_batch_data(l1_batch_number) .await } @@ -773,21 +755,8 @@ impl FriProverDal<'_, '_> { .await } - pub async fn delete_prover_jobs_fri_archive( - &mut self, - ) -> sqlx::Result { - sqlx::query!( - r#" - DELETE FROM prover_jobs_fri_archive - "# - ) - .execute(self.storage.conn()) - .await - } - pub async fn delete(&mut self) -> sqlx::Result { - self.delete_prover_jobs_fri().await?; - self.delete_prover_jobs_fri_archive().await + self.delete_prover_jobs_fri().await } pub async fn requeue_stuck_jobs_for_batch(