From aef232cb20843fb3342b3d501a98f62aca67ddbd Mon Sep 17 00:00:00 2001 From: ethDreamer <37123614+ethDreamer@users.noreply.github.com> Date: Mon, 5 Jun 2023 08:11:18 -0500 Subject: [PATCH] Remove Unnecessary Option in Blob Pruning (#4363) --- beacon_node/beacon_chain/src/builder.rs | 8 +++++--- .../beacon_chain/src/canonical_head.rs | 6 ++++-- beacon_node/beacon_chain/src/migrate.rs | 8 ++++---- beacon_node/store/src/hot_cold_store.rs | 19 +++++++++---------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/beacon_node/beacon_chain/src/builder.rs b/beacon_node/beacon_chain/src/builder.rs index 056714417..9fd3514fd 100644 --- a/beacon_node/beacon_chain/src/builder.rs +++ b/beacon_node/beacon_chain/src/builder.rs @@ -963,9 +963,11 @@ where } // Prune blobs sidecars older than the blob data availability boundary in the background. - beacon_chain - .store_migrator - .process_prune_blobs(beacon_chain.data_availability_boundary()); + if let Some(data_availability_boundary) = beacon_chain.data_availability_boundary() { + beacon_chain + .store_migrator + .process_prune_blobs(data_availability_boundary); + } Ok(beacon_chain) } diff --git a/beacon_node/beacon_chain/src/canonical_head.rs b/beacon_node/beacon_chain/src/canonical_head.rs index 35a701a54..40ac3ad34 100644 --- a/beacon_node/beacon_chain/src/canonical_head.rs +++ b/beacon_node/beacon_chain/src/canonical_head.rs @@ -758,8 +758,10 @@ impl BeaconChain { drop(old_cached_head); // Prune blobs in the background. - self.store_migrator - .process_prune_blobs(self.data_availability_boundary()); + if let Some(data_availability_boundary) = self.data_availability_boundary() { + self.store_migrator + .process_prune_blobs(data_availability_boundary); + } // If the finalized checkpoint changed, perform some updates. // diff --git a/beacon_node/beacon_chain/src/migrate.rs b/beacon_node/beacon_chain/src/migrate.rs index 0690d0767..6f04da31f 100644 --- a/beacon_node/beacon_chain/src/migrate.rs +++ b/beacon_node/beacon_chain/src/migrate.rs @@ -86,7 +86,7 @@ pub enum PruningError { pub enum Notification { Finalization(FinalizationNotification), Reconstruction, - PruneBlobs(Option), + PruneBlobs(Epoch), } pub struct FinalizationNotification { @@ -153,7 +153,7 @@ impl, Cold: ItemStore> BackgroundMigrator) { + pub fn process_prune_blobs(&self, data_availability_boundary: Epoch) { if let Some(Notification::PruneBlobs(data_availability_boundary)) = self.send_background_notification(Notification::PruneBlobs(data_availability_boundary)) { @@ -173,7 +173,7 @@ impl, Cold: ItemStore> BackgroundMigrator>, - data_availability_boundary: Option, + data_availability_boundary: Epoch, log: &Logger, ) { if let Err(e) = db.try_prune_blobs(false, data_availability_boundary) { @@ -606,7 +606,7 @@ impl, Cold: ItemStore> BackgroundMigrator, Cold: ItemStore> HotColdDB min_current_epoch.saturating_sub(*MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS), ); - self.try_prune_blobs(force, Some(min_data_availability_boundary)) + self.try_prune_blobs(force, min_data_availability_boundary) } /// Try to prune blobs older than the data availability boundary. pub fn try_prune_blobs( &self, force: bool, - data_availability_boundary: Option, + data_availability_boundary: Epoch, ) -> Result<(), Error> { - let (data_availability_boundary, deneb_fork) = - match (data_availability_boundary, self.spec.deneb_fork_epoch) { - (Some(boundary_epoch), Some(fork_epoch)) => (boundary_epoch, fork_epoch), - _ => { - debug!(self.log, "Deneb fork is disabled"); - return Ok(()); - } - }; + let deneb_fork = match self.spec.deneb_fork_epoch { + Some(epoch) => epoch, + None => { + debug!(self.log, "Deneb fork is disabled"); + return Ok(()); + } + }; let should_prune_blobs = self.get_config().prune_blobs; if !should_prune_blobs && !force {