Skip to content

Commit

Permalink
fixup! Simplify conceptual design
Browse files Browse the repository at this point in the history
  • Loading branch information
emhane committed Jan 17, 2023
1 parent 3c1be35 commit 061bfa6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
7 changes: 2 additions & 5 deletions beacon_node/beacon_chain/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,13 +917,10 @@ where
if beacon_chain.store.get_config().prune_blobs {
let store = beacon_chain.store.clone();
let log = log.clone();
let current_slot = beacon_chain
.slot()
.map_err(|e| format!("Failed to get current slot: {:?}", e))?;
let current_epoch = current_slot.epoch(TEthSpec::slots_per_epoch());
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, Some(current_epoch)) {
if let Err(e) = store.try_prune_blobs(false, data_availability_boundary) {
error!(log, "Error pruning blobs in background"; "error" => ?e);
}
},
Expand Down
5 changes: 2 additions & 3 deletions beacon_node/beacon_chain/src/canonical_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,11 +1018,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
if self.store.get_config().prune_blobs {
let store = self.store.clone();
let log = self.log.clone();
let current_slot = self.slot()?;
let current_epoch = current_slot.epoch(T::EthSpec::slots_per_epoch());
let data_availability_boundary = self.data_availability_boundary();
self.task_executor.spawn_blocking(
move || {
if let Err(e) = store.try_prune_blobs(false, Some(current_epoch)) {
if let Err(e) = store.try_prune_blobs(false, data_availability_boundary) {
error!(log, "Error pruning blobs in background"; "error" => ?e);
}
},
Expand Down
17 changes: 14 additions & 3 deletions beacon_node/store/src/hot_cold_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
// finalized epoch, hence current_epoch = split_epoch + 1
let current_epoch =
self.get_split_slot().epoch(E::slots_per_epoch()) + Epoch::new(1);
current_epoch - *MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS
current_epoch.saturating_sub(*MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS)
}
};

Expand All @@ -1755,12 +1755,23 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>

let mut ops = vec![];
let mut last_pruned_block_root = None;
let end_slot = next_epoch_to_prune.start_slot(E::slots_per_epoch());
let end_slot = next_epoch_to_prune.end_slot(E::slots_per_epoch());

// todo(emhane): In the future, if the data availability boundary is less than the split
// epoch, this code will have to change to account for head candidates.
for res in self.forwards_block_roots_iterator_until(
oldest_blob_slot,
end_slot,
|| Err(HotColdDBError::UnsupportedDataAvailabilityBoundary.into()),
|| {
let split = self.get_split_info();

let split_state = self.get_state(&split.state_root, Some(split.slot))?.ok_or(
HotColdDBError::MissingSplitState(split.state_root, split.slot),
)?;
let split_block_root = split_state.get_latest_block_root(split.state_root);

Ok((split_state, split_block_root))
},
&self.spec,
)? {
let (block_root, slot) = match res {
Expand Down

0 comments on commit 061bfa6

Please sign in to comment.