From 6b3b2b759a1f07f682c749e2e1d22e23eea2f797 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Wed, 22 Jun 2022 16:17:50 +1000 Subject: [PATCH] Tidy --- beacon_node/beacon_chain/src/beacon_chain.rs | 15 +++++++-------- .../beacon_chain/src/block_verification.rs | 4 +--- .../src/beacon_processor/worker/gossip_methods.rs | 9 --------- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index d8b48549f28..4dce61758ad 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -1434,8 +1434,8 @@ impl BeaconChain { let beacon_block_root; let beacon_state_root; let head_timer = metrics::start_timer(&metrics::ATTESTATION_PRODUCTION_HEAD_SCRAPE_SECONDS); - let cached_head_lock = self.canonical_head.cached_head(); - let head = &cached_head_lock.snapshot; + let cached_head = self.canonical_head.cached_head(); + let head = &cached_head.snapshot; let head_state = &head.beacon_state; let head_state_slot = head_state.slot(); @@ -1511,8 +1511,8 @@ impl BeaconChain { AttesterCacheKey::new(request_epoch, head_state, beacon_block_root)?; drop(head_timer); - // Drop the head lock ASAP to prevent lock contention. - drop(cached_head_lock); + // Drop the `Arc` to avoid keeping the reference alive any longer than required. + drop(cached_head); // Only attest to a block if it is fully verified (i.e. not optimistic or invalid). match self @@ -2356,11 +2356,10 @@ impl BeaconChain { let block = unverified_block.block().clone(); // A small closure to group the verification and import errors. - let chain_a = self.clone(); - let chain_b = self.clone(); + let chain = self.clone(); let import_block = async move { - let execution_pending = unverified_block.into_execution_pending_block(&chain_a)?; - chain_b + let execution_pending = unverified_block.into_execution_pending_block(&chain)?; + chain .import_execution_pending_block(execution_pending) .await }; diff --git a/beacon_node/beacon_chain/src/block_verification.rs b/beacon_node/beacon_chain/src/block_verification.rs index 82ba5545ac3..5c67f272ba3 100644 --- a/beacon_node/beacon_chain/src/block_verification.rs +++ b/beacon_node/beacon_chain/src/block_verification.rs @@ -277,9 +277,6 @@ pub enum BlockError { /// The peer sent us an invalid block, but I'm not really sure how to score this in an /// "optimistic" sync world. ParentExecutionPayloadInvalid { parent_root: Hash256 }, - /// A block import was cancelled. This error should never be surfaced, it indicates an error in - /// our programming. - BlockImportCancelled, } /// Returned when block validation failed due to some issue verifying @@ -425,6 +422,7 @@ impl From for BlockError { } } +/// Stores information about verifying a payload against an execution engine. pub struct PayloadVerificationOutcome { pub payload_verification_status: PayloadVerificationStatus, pub is_valid_merge_transition_block: bool, diff --git a/beacon_node/network/src/beacon_processor/worker/gossip_methods.rs b/beacon_node/network/src/beacon_processor/worker/gossip_methods.rs index c90771be310..a9db31e15c1 100644 --- a/beacon_node/network/src/beacon_processor/worker/gossip_methods.rs +++ b/beacon_node/network/src/beacon_processor/worker/gossip_methods.rs @@ -754,15 +754,6 @@ impl Worker { self.send_sync_message(SyncMessage::UnknownBlock(peer_id, block)); return None; } - Err(e @ BlockError::BlockImportCancelled) => { - crit!( - self.log, - "Unexpected block import error"; - "error" => ?e, - ); - self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore); - return None; - } Err(e @ BlockError::BeaconChainError(_)) => { debug!( self.log,