fixup! Plug in pruning of blobs into app

This commit is contained in:
Emilia Hane 2023-01-08 20:51:40 +01:00
parent b88d888145
commit d21c66ddf4
No known key found for this signature in database
GPG Key ID: E73394F9C09206FA
3 changed files with 15 additions and 8 deletions

View File

@ -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.data_availability_breakpoint = block_root; blob_info.data_availability_breakpoint = Some(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),

View File

@ -213,7 +213,7 @@ impl<E: EthSpec> HotColdDB<E, LevelDB<E>, LevelDB<E>> {
} }
if db.spec.eip4844_fork_epoch.is_some() { if db.spec.eip4844_fork_epoch.is_some() {
*db.blob_info.write() = db.load_blob_info()?; *db.blob_info.write() = db.load_blob_info()?.or(Some(BlobInfo::default()));
} }
// Ensure that the schema version of the on-disk database matches the software. // Ensure that the schema version of the on-disk database matches the software.
@ -1700,18 +1700,25 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
return Ok(()); return Ok(());
} }
if blob_info.data_availability_breakpoint == blob_info.oldest_blob_parent { let data_availability_breakpoint: Hash256;
if let Some(breakpoint) = blob_info.data_availability_breakpoint {
if breakpoint == blob_info.oldest_blob_parent {
return Ok(());
}
data_availability_breakpoint = breakpoint;
} else {
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.data_availability_breakpoint, &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.data_availability_breakpoint, data_availability_breakpoint,
blob_info.oldest_blob_slot, blob_info.oldest_blob_slot,
))?; ))?;
@ -1808,7 +1815,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.data_availability_breakpoint; blob_info.oldest_blob_parent = 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(())

View File

@ -120,12 +120,12 @@ impl StoreItem for AnchorInfo {
} }
/// Database parameters relevant to blob sync. /// Database parameters relevant to blob sync.
#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Encode, Decode, Serialize, Deserialize, Default)]
pub struct BlobInfo { 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 data_availability_breakpoint: Hash256, pub data_availability_breakpoint: Option<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.