Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prover_cli): Fix delete command #2119

Merged
merged 11 commits into from
Jun 7, 2024
2 changes: 1 addition & 1 deletion prover/prover_cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,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.

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
Loading