From 52e50835029d9cee00982caba07ff617e01b46a6 Mon Sep 17 00:00:00 2001 From: ethDreamer <37123614+ethDreamer@users.noreply.github.com> Date: Mon, 4 Oct 2021 08:17:36 -0500 Subject: [PATCH] Fixed bugs for m3 readiness (#2669) * Fixed bugs for m3 readiness * woops * cargo fmt.. --- beacon_node/beacon_chain/src/beacon_chain.rs | 57 ++++++++++---------- beacon_node/src/config.rs | 4 +- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 5f3358754f..87fdbf6f71 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -3137,6 +3137,7 @@ impl BeaconChain { .body() .execution_payload() .map(|ep| ep.block_hash); + let is_merge_complete = is_merge_complete(&new_head.beacon_state); drop(lag_timer); @@ -3342,34 +3343,36 @@ impl BeaconChain { } // If this is a post-merge block, update the execution layer. - if let Some(new_head_execution_block_hash) = new_head_execution_block_hash { - let execution_layer = self - .execution_layer - .clone() - .ok_or(Error::ExecutionLayerMissing)?; - let store = self.store.clone(); - let log = self.log.clone(); + if let Some(block_hash) = new_head_execution_block_hash { + if is_merge_complete { + let execution_layer = self + .execution_layer + .clone() + .ok_or(Error::ExecutionLayerMissing)?; + let store = self.store.clone(); + let log = self.log.clone(); - // Spawn the update task, without waiting for it to complete. - execution_layer.spawn( - move |execution_layer| async move { - if let Err(e) = Self::update_execution_engine_forkchoice( - execution_layer, - store, - new_finalized_checkpoint.root, - new_head_execution_block_hash, - ) - .await - { - error!( - log, - "Failed to update execution head"; - "error" => ?e - ); - } - }, - "update_execution_engine_forkchoice", - ) + // Spawn the update task, without waiting for it to complete. + execution_layer.spawn( + move |execution_layer| async move { + if let Err(e) = Self::update_execution_engine_forkchoice( + execution_layer, + store, + new_finalized_checkpoint.root, + block_hash, + ) + .await + { + error!( + log, + "Failed to update execution head"; + "error" => ?e + ); + } + }, + "update_execution_engine_forkchoice", + ) + } } Ok(()) diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index 9061da5743..d9452534c3 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -249,11 +249,11 @@ pub fn get_config( } if let Some(terminal_total_difficulty) = - clap_utils::parse_optional(cli_args, "total-terminal-difficulty-override")? + clap_utils::parse_optional(cli_args, "terminal-total-difficulty-override")? { if client_config.execution_endpoints.is_none() { return Err( - "The --merge flag must be provided when using --total-terminal-difficulty-override" + "The --merge flag must be provided when using --terminal-total-difficulty-override" .into(), ); }