Skip to content

Commit

Permalink
Squash merge of #3057
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit c03670e
Author: Paul Hauner <[email protected]>
Date:   Fri Mar 4 09:41:11 2022 +1100

    Filter out zero-hashes

commit 6d269dd
Author: Paul Hauner <[email protected]>
Date:   Fri Mar 4 09:09:28 2022 +1100

    Avoid sending fcU with zero hash
  • Loading branch information
paulhauner committed Mar 3, 2022
1 parent 81cd85f commit b783e86
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
13 changes: 12 additions & 1 deletion beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3653,7 +3653,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}

// If this is a post-merge block, update the execution layer.
if let Some(new_head_execution_block_hash) = new_head_execution_block_hash_opt {
if let Some(new_head_execution_block_hash) =
new_head_execution_block_hash_opt.filter(|h| *h != ExecutionBlockHash::zero())
{
if is_merge_transition_complete {
let finalized_execution_block_hash = finalized_block
.execution_status
Expand Down Expand Up @@ -3704,6 +3706,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
head_block_root: Hash256,
head_execution_block_hash: ExecutionBlockHash,
) -> Result<(), Error> {
if head_execution_block_hash == ExecutionBlockHash::zero() {
debug!(
self.log,
"Not sending forkchoice updated";
"msg" => "head block hash is zero"
);
return Ok(());
}

let forkchoice_updated_response = self
.execution_layer
.as_ref()
Expand Down
5 changes: 4 additions & 1 deletion beacon_node/client/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,10 @@ where

// Issue the head to the execution engine on startup. This ensures it can start
// syncing.
if let Some(block_hash) = head.execution_payload_block_hash {
if let Some(block_hash) = head
.execution_payload_block_hash
.filter(|h| *h != ExecutionBlockHash::zero())
{
let finalized_root = head.finalized_checkpoint.root;
let finalized_block = beacon_chain
.store
Expand Down
10 changes: 10 additions & 0 deletions beacon_node/execution_layer/src/engines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ impl<T: EngineApi> Engines<T> {
let latest_forkchoice_state = self.get_latest_forkchoice_state().await;

if let Some(forkchoice_state) = latest_forkchoice_state {
if forkchoice_state.head_block_hash == ExecutionBlockHash::zero() {
debug!(
self.log,
"No need to call forkchoiceUpdated";
"msg" => "head does not have execution enabled",
"id" => &engine.id,
);
return;
}

info!(
self.log,
"Issuing forkchoiceUpdated";
Expand Down

0 comments on commit b783e86

Please sign in to comment.