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

Commit

Permalink
fix(prover_cli): Fix delete command (matter-labs#2119)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ColoCarletti and ilitteri authored Jun 7, 2024
1 parent 1e18af2 commit 214f981
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 78 deletions.
2 changes: 1 addition & 1 deletion prover/prover_cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand Down
9 changes: 4 additions & 5 deletions prover/prover_cli/src/commands/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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::<String>::with_theme(&ColorfulTheme::default())
.with_prompt("Are you sure you want to delete the data?")
.default("no".to_owned())
Expand All @@ -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::<Prover>::singleton(secrets.prover_url()?)
let prover_connection_pool = ConnectionPool::<Prover>::singleton(config.db_url)
.build()
.await
.context("failed to build a prover_connection_pool")?;
Expand Down

This file was deleted.

This file was deleted.

15 changes: 1 addition & 14 deletions prover/prover_dal/src/fri_gpu_prover_queue_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,7 @@ impl FriGpuProverQueueDal<'_, '_> {
.await
}

pub async fn delete_gpu_prover_queue_fri_archive(
&mut self,
) -> sqlx::Result<sqlx::postgres::PgQueryResult> {
sqlx::query!(
r#"
DELETE FROM gpu_prover_queue_fri
"#
)
.execute(self.storage.conn())
.await
}

pub async fn delete(&mut self) -> sqlx::Result<sqlx::postgres::PgQueryResult> {
self.delete_gpu_prover_queue_fri().await?;
self.delete_gpu_prover_queue_fri_archive().await
self.delete_gpu_prover_queue_fri().await
}
}
33 changes: 1 addition & 32 deletions prover/prover_dal/src/fri_prover_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::postgres::PgQueryResult> {
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<sqlx::postgres::PgQueryResult> {
self.delete_prover_jobs_fri_batch_data(l1_batch_number)
.await?;
self.delete_prover_jobs_fri_archive_batch_data(l1_batch_number)
.await
}

Expand All @@ -773,21 +755,8 @@ impl FriProverDal<'_, '_> {
.await
}

pub async fn delete_prover_jobs_fri_archive(
&mut self,
) -> sqlx::Result<sqlx::postgres::PgQueryResult> {
sqlx::query!(
r#"
DELETE FROM prover_jobs_fri_archive
"#
)
.execute(self.storage.conn())
.await
}

pub async fn delete(&mut self) -> sqlx::Result<sqlx::postgres::PgQueryResult> {
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(
Expand Down

0 comments on commit 214f981

Please sign in to comment.