mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 05:18:30 +00:00
Plug in running blob pruning in migrator, related bug fixes and add todos
This commit is contained in:
@@ -3015,9 +3015,11 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
ops.push(StoreOp::PutBlock(block_root, signed_block.clone()));
|
||||
ops.push(StoreOp::PutState(block.state_root(), &state));
|
||||
|
||||
// Only store blobs at the data availability boundary or younger.
|
||||
//
|
||||
// todo(emhane): Should we add a marginal of one epoch here to ensure data availability
|
||||
// consistency across network at epoch boundaries?
|
||||
let block_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch());
|
||||
|
||||
// Only store blobs that haven't passed the data availability boundary.
|
||||
if Some(block_epoch) >= self.data_availability_boundary() {
|
||||
if let Some(blobs) = blobs? {
|
||||
if blobs.blobs.len() > 0 {
|
||||
|
||||
@@ -915,19 +915,9 @@ where
|
||||
}
|
||||
|
||||
// Prune blobs sidecars older than the blob data availability boundary in the background.
|
||||
if beacon_chain.store.get_config().prune_blobs {
|
||||
let store = beacon_chain.store.clone();
|
||||
let log = log.clone();
|
||||
let data_availability_boundary = beacon_chain.data_availability_boundary();
|
||||
beacon_chain.task_executor.spawn_blocking(
|
||||
move || {
|
||||
if let Err(e) = store.try_prune_blobs(false, data_availability_boundary) {
|
||||
error!(log, "Error pruning blobs in background"; "error" => ?e);
|
||||
}
|
||||
},
|
||||
"prune_blobs_background",
|
||||
);
|
||||
}
|
||||
beacon_chain
|
||||
.store_migrator
|
||||
.process_prune_blobs(beacon_chain.data_availability_boundary());
|
||||
|
||||
Ok(beacon_chain)
|
||||
}
|
||||
|
||||
@@ -751,6 +751,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
// Drop the old cache head nice and early to try and free the memory as soon as possible.
|
||||
drop(old_cached_head);
|
||||
|
||||
// Prune blobs in the background.
|
||||
self.store_migrator
|
||||
.process_prune_blobs(self.data_availability_boundary());
|
||||
|
||||
// If the finalized checkpoint changed, perform some updates.
|
||||
//
|
||||
// The `after_finalization` function will take a write-lock on `fork_choice`, therefore it
|
||||
@@ -1014,21 +1018,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
// Take a write-lock on the canonical head and signal for it to prune.
|
||||
self.canonical_head.fork_choice_write_lock().prune()?;
|
||||
|
||||
// Prune blobs.
|
||||
if self.store.get_config().prune_blobs {
|
||||
let store = self.store.clone();
|
||||
let log = self.log.clone();
|
||||
let data_availability_boundary = self.data_availability_boundary();
|
||||
self.task_executor.spawn_blocking(
|
||||
move || {
|
||||
if let Err(e) = store.try_prune_blobs(false, data_availability_boundary) {
|
||||
error!(log, "Error pruning blobs in background"; "error" => ?e);
|
||||
}
|
||||
},
|
||||
"prune_blobs_background",
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user