Don't use the builder network if the head is optimistic (#3412)

## Issue Addressed

Resolves https://github.com/sigp/lighthouse/issues/3394

Adds a check in `is_healthy` about whether the head is optimistic when choosing whether to use the builder network. 



Co-authored-by: realbigsean <sean@sigmaprime.io>
This commit is contained in:
realbigsean
2022-08-09 06:05:16 +00:00
parent 5bb4aada92
commit 6f13727fbe
3 changed files with 74 additions and 2 deletions

View File

@@ -3333,7 +3333,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
pubkey,
slot: state.slot(),
chain_health: self
.is_healthy()
.is_healthy(&parent_root)
.map_err(BlockProductionError::BeaconChain)?,
};
@@ -4562,7 +4562,7 @@ 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) -> Result<ChainHealth, Error> {
pub fn is_healthy(&self, parent_root: &Hash256) -> Result<ChainHealth, Error> {
// Check if the merge has been finalized.
if let Some(finalized_hash) = self
.canonical_head
@@ -4577,6 +4577,17 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
return Ok(ChainHealth::PreMerge);
};
// Check that the parent is NOT optimistic.
if let Some(execution_status) = self
.canonical_head
.fork_choice_read_lock()
.get_block_execution_status(parent_root)
{
if execution_status.is_strictly_optimistic() {
return Ok(ChainHealth::Optimistic);
}
}
if self.config.builder_fallback_disable_checks {
return Ok(ChainHealth::Healthy);
}