Skip to content

Commit

Permalink
Tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Jun 28, 2022
1 parent b46088d commit 5f67350
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions beacon_node/beacon_chain/src/canonical_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ impl<T: BeaconChainTypes> CanonicalHead<T> {
/// run `BeaconChain::recompute_head` to update the cached values.
pub fn head_execution_status(&self) -> Result<ExecutionStatus, Error> {
let head_block_root = self.cached_head().head_block_root();
self.fork_choice
.read()
self.fork_choice_read_lock()
.get_block_execution_status(&head_block_root)
.ok_or(Error::HeadMissingFromForkChoice(head_block_root))
}
Expand All @@ -305,7 +304,7 @@ impl<T: BeaconChainTypes> CanonicalHead<T> {
///
/// This function is safe to be public since it does not expose any locks.
pub fn cached_head(&self) -> CachedHead<T::EthSpec> {
self.cached_head.read().clone()
self.cached_head_read_lock().clone()
}

/// Access a write-lock for the cached head.
Expand Down Expand Up @@ -866,6 +865,22 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
);
});

self.attester_cache
.prune_below(new_view.finalized_checkpoint.epoch);

if let Some(event_handler) = self.event_handler.as_ref() {
if event_handler.has_finalized_subscribers() {
event_handler.register(EventKind::FinalizedCheckpoint(SseFinalizedCheckpoint {
epoch: new_view.finalized_checkpoint.epoch,
block: new_view.finalized_checkpoint.root,
// Provide the state root of the latest finalized block, rather than the
// specific state root at the first slot of the finalized epoch (which
// might be a skip slot).
state: finalized_proto_block.state_root,
}));
}
}

// The store migration task requires the *state at the slot of the finalized epoch*,
// rather than the state of the latest finalized block. These two values will only
// differ when the first slot of the finalized epoch is a skip slot.
Expand Down Expand Up @@ -896,22 +911,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
self.head_tracker.clone(),
)?;

self.attester_cache
.prune_below(new_view.finalized_checkpoint.epoch);

if let Some(event_handler) = self.event_handler.as_ref() {
if event_handler.has_finalized_subscribers() {
event_handler.register(EventKind::FinalizedCheckpoint(SseFinalizedCheckpoint {
epoch: new_view.finalized_checkpoint.epoch,
block: new_view.finalized_checkpoint.root,
// Provide the state root of the latest finalized block, rather than the
// specific state root at the first slot of the finalized epoch (which
// might be a skip slot).
state: finalized_proto_block.state_root,
}));
}
}

Ok(())
}

Expand Down

0 comments on commit 5f67350

Please sign in to comment.