From caa04db58a3c41ae49d780f0f945846390a4adec Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Wed, 18 Jan 2023 21:26:17 +0100 Subject: [PATCH] Run prune blobs on migrator thread --- beacon_node/beacon_chain/src/migrate.rs | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/beacon_node/beacon_chain/src/migrate.rs b/beacon_node/beacon_chain/src/migrate.rs index 8fb00c105..fa07be42a 100644 --- a/beacon_node/beacon_chain/src/migrate.rs +++ b/beacon_node/beacon_chain/src/migrate.rs @@ -86,6 +86,7 @@ pub enum PruningError { pub enum Notification { Finalization(FinalizationNotification), Reconstruction, + PruneBlobs(Option), } pub struct FinalizationNotification { @@ -152,6 +153,14 @@ impl, Cold: ItemStore> BackgroundMigrator) { + if let Some(Notification::PruneBlobs(data_availability_boundary)) = + self.send_background_notification(Notification::PruneBlobs(data_availability_boundary)) + { + Self::run_prune_blobs(self.db.clone(), data_availability_boundary, &self.log); + } + } + pub fn run_reconstruction(db: Arc>, log: &Logger) { if let Err(e) = db.reconstruct_historic_states() { error!( @@ -162,6 +171,20 @@ impl, Cold: ItemStore> BackgroundMigrator>, + data_availability_boundary: Option, + log: &Logger, + ) { + if let Err(e) = db.try_prune_blobs(false, data_availability_boundary) { + error!( + log, + "Blobs pruning failed"; + "error" => ?e, + ); + } + } + /// If configured to run in the background, send `notif` to the background thread. /// /// Return `None` if the message was sent to the background thread, `Some(notif)` otherwise. @@ -320,11 +343,15 @@ impl, Cold: ItemStore> BackgroundMigrator best, + (Notification::PruneBlobs(_), Notification::Finalization(_)) => other, + (Notification::PruneBlobs(_), Notification::PruneBlobs(_)) => best, }); match notif { Notification::Reconstruction => Self::run_reconstruction(db.clone(), &log), Notification::Finalization(fin) => Self::run_migration(db.clone(), fin, &log), + Notification::PruneBlobs(dab) => Self::run_prune_blobs(db.clone(), dab, &log), } } });