Remove Unnecessary Option in Blob Pruning (#4363)
This commit is contained in:
parent
ceaa740841
commit
aef232cb20
@ -963,9 +963,11 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prune blobs sidecars older than the blob data availability boundary in the background.
|
// Prune blobs sidecars older than the blob data availability boundary in the background.
|
||||||
beacon_chain
|
if let Some(data_availability_boundary) = beacon_chain.data_availability_boundary() {
|
||||||
.store_migrator
|
beacon_chain
|
||||||
.process_prune_blobs(beacon_chain.data_availability_boundary());
|
.store_migrator
|
||||||
|
.process_prune_blobs(data_availability_boundary);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(beacon_chain)
|
Ok(beacon_chain)
|
||||||
}
|
}
|
||||||
|
@ -758,8 +758,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
drop(old_cached_head);
|
drop(old_cached_head);
|
||||||
|
|
||||||
// Prune blobs in the background.
|
// Prune blobs in the background.
|
||||||
self.store_migrator
|
if let Some(data_availability_boundary) = self.data_availability_boundary() {
|
||||||
.process_prune_blobs(self.data_availability_boundary());
|
self.store_migrator
|
||||||
|
.process_prune_blobs(data_availability_boundary);
|
||||||
|
}
|
||||||
|
|
||||||
// If the finalized checkpoint changed, perform some updates.
|
// If the finalized checkpoint changed, perform some updates.
|
||||||
//
|
//
|
||||||
|
@ -86,7 +86,7 @@ pub enum PruningError {
|
|||||||
pub enum Notification {
|
pub enum Notification {
|
||||||
Finalization(FinalizationNotification),
|
Finalization(FinalizationNotification),
|
||||||
Reconstruction,
|
Reconstruction,
|
||||||
PruneBlobs(Option<Epoch>),
|
PruneBlobs(Epoch),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FinalizationNotification {
|
pub struct FinalizationNotification {
|
||||||
@ -153,7 +153,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_prune_blobs(&self, data_availability_boundary: Option<Epoch>) {
|
pub fn process_prune_blobs(&self, data_availability_boundary: Epoch) {
|
||||||
if let Some(Notification::PruneBlobs(data_availability_boundary)) =
|
if let Some(Notification::PruneBlobs(data_availability_boundary)) =
|
||||||
self.send_background_notification(Notification::PruneBlobs(data_availability_boundary))
|
self.send_background_notification(Notification::PruneBlobs(data_availability_boundary))
|
||||||
{
|
{
|
||||||
@ -173,7 +173,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
|
|||||||
|
|
||||||
pub fn run_prune_blobs(
|
pub fn run_prune_blobs(
|
||||||
db: Arc<HotColdDB<E, Hot, Cold>>,
|
db: Arc<HotColdDB<E, Hot, Cold>>,
|
||||||
data_availability_boundary: Option<Epoch>,
|
data_availability_boundary: Epoch,
|
||||||
log: &Logger,
|
log: &Logger,
|
||||||
) {
|
) {
|
||||||
if let Err(e) = db.try_prune_blobs(false, data_availability_boundary) {
|
if let Err(e) = db.try_prune_blobs(false, data_availability_boundary) {
|
||||||
@ -606,7 +606,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
|
|||||||
StoreOp::DeleteBlock(block_root),
|
StoreOp::DeleteBlock(block_root),
|
||||||
StoreOp::DeleteExecutionPayload(block_root),
|
StoreOp::DeleteExecutionPayload(block_root),
|
||||||
];
|
];
|
||||||
if let Ok(true) = store.blobs_sidecar_exists(&block_root) {
|
if store.blobs_sidecar_exists(&block_root).unwrap_or(false) {
|
||||||
// Keep track of non-empty orphaned blobs sidecars.
|
// Keep track of non-empty orphaned blobs sidecars.
|
||||||
store_ops.extend([
|
store_ops.extend([
|
||||||
StoreOp::DeleteBlobs(block_root),
|
StoreOp::DeleteBlobs(block_root),
|
||||||
|
@ -1905,23 +1905,22 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
min_current_epoch.saturating_sub(*MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS),
|
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.
|
/// Try to prune blobs older than the data availability boundary.
|
||||||
pub fn try_prune_blobs(
|
pub fn try_prune_blobs(
|
||||||
&self,
|
&self,
|
||||||
force: bool,
|
force: bool,
|
||||||
data_availability_boundary: Option<Epoch>,
|
data_availability_boundary: Epoch,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let (data_availability_boundary, deneb_fork) =
|
let deneb_fork = match self.spec.deneb_fork_epoch {
|
||||||
match (data_availability_boundary, self.spec.deneb_fork_epoch) {
|
Some(epoch) => epoch,
|
||||||
(Some(boundary_epoch), Some(fork_epoch)) => (boundary_epoch, fork_epoch),
|
None => {
|
||||||
_ => {
|
debug!(self.log, "Deneb fork is disabled");
|
||||||
debug!(self.log, "Deneb fork is disabled");
|
return Ok(());
|
||||||
return Ok(());
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
let should_prune_blobs = self.get_config().prune_blobs;
|
let should_prune_blobs = self.get_config().prune_blobs;
|
||||||
if !should_prune_blobs && !force {
|
if !should_prune_blobs && !force {
|
||||||
|
Loading…
Reference in New Issue
Block a user