Skip to content

Commit

Permalink
avoid relocking head during builder health check (sigp#4323)
Browse files Browse the repository at this point in the history
## Issue Addressed

sigp#4314 

## Proposed Changes

avoid relocking head during builder health check

## Additional Info

NA
  • Loading branch information
int88 authored and Woodpile37 committed Jan 6, 2024
1 parent 07ad05f commit 94140a7
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5311,13 +5311,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
/// Since we are likely calling this during the slot we are going to propose in, don't take into
/// account the current slot when accounting for skips.
pub fn is_healthy(&self, parent_root: &Hash256) -> Result<ChainHealth, Error> {
let cached_head = self.canonical_head.cached_head();
// Check if the merge has been finalized.
if let Some(finalized_hash) = self
.canonical_head
.cached_head()
.forkchoice_update_parameters()
.finalized_hash
{
if let Some(finalized_hash) = cached_head.forkchoice_update_parameters().finalized_hash {
if ExecutionBlockHash::zero() == finalized_hash {
return Ok(ChainHealth::PreMerge);
}
Expand All @@ -5344,17 +5340,13 @@ impl<T: BeaconChainTypes> BeaconChain<T> {

// Check slots at the head of the chain.
let prev_slot = current_slot.saturating_sub(Slot::new(1));
let head_skips = prev_slot.saturating_sub(self.canonical_head.cached_head().head_slot());
let head_skips = prev_slot.saturating_sub(cached_head.head_slot());
let head_skips_check = head_skips.as_usize() <= self.config.builder_fallback_skips;

// Check if finalization is advancing.
let current_epoch = current_slot.epoch(T::EthSpec::slots_per_epoch());
let epochs_since_finalization = current_epoch.saturating_sub(
self.canonical_head
.cached_head()
.finalized_checkpoint()
.epoch,
);
let epochs_since_finalization =
current_epoch.saturating_sub(cached_head.finalized_checkpoint().epoch);
let finalization_check = epochs_since_finalization.as_usize()
<= self.config.builder_fallback_epochs_since_finalization;

Expand Down

0 comments on commit 94140a7

Please sign in to comment.