Skip to content

Commit

Permalink
Tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Jun 28, 2022
1 parent 19870a8 commit 6b3b2b7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
15 changes: 7 additions & 8 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1434,8 +1434,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
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();

Expand Down Expand Up @@ -1511,8 +1511,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
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
Expand Down Expand Up @@ -2356,11 +2356,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
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
};
Expand Down
4 changes: 1 addition & 3 deletions beacon_node/beacon_chain/src/block_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,6 @@ pub enum BlockError<T: EthSpec> {
/// 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
Expand Down Expand Up @@ -425,6 +422,7 @@ impl<T: EthSpec> From<ArithError> for BlockError<T> {
}
}

/// 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,15 +754,6 @@ impl<T: BeaconChainTypes> Worker<T> {
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,
Expand Down

0 comments on commit 6b3b2b7

Please sign in to comment.