fixup! Prune blobs before data availability breakpoint
This commit is contained in:
parent
fe0c911402
commit
2a41f25d68
@ -3029,7 +3029,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
blob_info.last_pruned_epoch + *MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS;
|
blob_info.last_pruned_epoch + *MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS;
|
||||||
|
|
||||||
if current_epoch > next_epoch_to_prune {
|
if current_epoch > next_epoch_to_prune {
|
||||||
blob_info.availability_breakpoint = block_root;
|
blob_info.data_availability_breakpoint = block_root;
|
||||||
self.store.compare_and_set_blob_info_with_write(
|
self.store.compare_and_set_blob_info_with_write(
|
||||||
self.store.get_blob_info(),
|
self.store.get_blob_info(),
|
||||||
Some(blob_info),
|
Some(blob_info),
|
||||||
|
@ -1696,25 +1696,24 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if blob_info.availability_breakpoint == blob_info.oldest_blob_parent {
|
if blob_info.data_availability_breakpoint == blob_info.oldest_blob_parent {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the state from which to prune blobs so we can backtrack.
|
// Load the state from which to prune blobs so we can backtrack.
|
||||||
let erase_state = self
|
let erase_state = self
|
||||||
.get_state(
|
.get_state(
|
||||||
&blob_info.availability_breakpoint,
|
&blob_info.data_availability_breakpoint,
|
||||||
Some(blob_info.last_pruned_epoch.end_slot(E::slots_per_epoch())),
|
Some(blob_info.last_pruned_epoch.end_slot(E::slots_per_epoch())),
|
||||||
)?
|
)?
|
||||||
.ok_or(HotColdDBError::MissingStateToPruneBlobs(
|
.ok_or(HotColdDBError::MissingStateToPruneBlobs(
|
||||||
blob_info.availability_breakpoint,
|
blob_info.data_availability_breakpoint,
|
||||||
blob_info.oldest_blob_slot,
|
blob_info.oldest_blob_slot,
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
// The data availability breakpoint is set at the start of an epoch indicating the epoch
|
// The data availability breakpoint is set at the start of an epoch indicating the epoch
|
||||||
// before can be pruned.
|
// before can be pruned.
|
||||||
let erase_epoch = erase_state.current_epoch() - 1;
|
let erase_epoch = erase_state.current_epoch() - 1;
|
||||||
let erase_slot = erase_epoch.end_slot(E::slots_per_epoch());
|
|
||||||
|
|
||||||
// The finalized block may or may not have its blobs sidecar stored, depending on
|
// The finalized block may or may not have its blobs sidecar stored, depending on
|
||||||
// whether it was at a skipped slot. However for a fully pruned database its parent
|
// whether it was at a skipped slot. However for a fully pruned database its parent
|
||||||
@ -1724,12 +1723,9 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
let already_pruned = process_results(
|
let already_pruned = process_results(
|
||||||
BlockRootsIter::new(&erase_state, blob_info.oldest_blob_slot),
|
BlockRootsIter::new(&erase_state, blob_info.oldest_blob_slot),
|
||||||
|mut iter| {
|
|mut iter| {
|
||||||
iter.find(|(slot, block_root)| {
|
iter.find(|(_, block_root)| {
|
||||||
move || -> bool {
|
move || -> bool {
|
||||||
if *slot <= erase_slot {
|
if let Ok(Some(erase_parent_block)) = self.get_blinded_block(&block_root) {
|
||||||
if let Ok(Some(erase_parent_block)) =
|
|
||||||
self.get_blinded_block(&block_root)
|
|
||||||
{
|
|
||||||
if let Ok(expected_kzg_commitments) =
|
if let Ok(expected_kzg_commitments) =
|
||||||
erase_parent_block.message().body().blob_kzg_commitments()
|
erase_parent_block.message().body().blob_kzg_commitments()
|
||||||
{
|
{
|
||||||
@ -1738,7 +1734,6 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
false
|
false
|
||||||
}()
|
}()
|
||||||
})
|
})
|
||||||
@ -1790,10 +1785,10 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
ops.push(StoreOp::DeleteBlobs(block_root));
|
ops.push(StoreOp::DeleteBlobs(block_root));
|
||||||
}
|
}
|
||||||
|
|
||||||
if slot <= erase_slot {
|
if block_root == blob_info.oldest_blob_parent {
|
||||||
info!(
|
info!(
|
||||||
self.log,
|
self.log,
|
||||||
"Blobs sidecar pruning reached earliest available blob state";
|
"Blobs sidecar pruning reached earliest available blobs sidecar";
|
||||||
"slot" => slot
|
"slot" => slot
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
@ -1809,7 +1804,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
);
|
);
|
||||||
|
|
||||||
blob_info.last_pruned_epoch = erase_epoch;
|
blob_info.last_pruned_epoch = erase_epoch;
|
||||||
blob_info.oldest_blob_parent = blob_info.availability_breakpoint;
|
blob_info.oldest_blob_parent = blob_info.data_availability_breakpoint;
|
||||||
self.compare_and_set_blob_info_with_write(self.get_blob_info(), Some(blob_info))?;
|
self.compare_and_set_blob_info_with_write(self.get_blob_info(), Some(blob_info))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -125,7 +125,7 @@ pub struct BlobInfo {
|
|||||||
/// The latest epoch that blobs were pruned.
|
/// The latest epoch that blobs were pruned.
|
||||||
pub last_pruned_epoch: Epoch,
|
pub last_pruned_epoch: Epoch,
|
||||||
/// The block root of the next blobs to prune from.
|
/// The block root of the next blobs to prune from.
|
||||||
pub availability_breakpoint: Hash256,
|
pub data_availability_breakpoint: Hash256,
|
||||||
/// The block root of the next blob that needs to be added to fill in the history.
|
/// The block root of the next blob that needs to be added to fill in the history.
|
||||||
pub oldest_blob_parent: Hash256,
|
pub oldest_blob_parent: Hash256,
|
||||||
/// The slot before which blobs are available.
|
/// The slot before which blobs are available.
|
||||||
|
Loading…
Reference in New Issue
Block a user