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 dbde4bf commit 08082fb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/beacon_proposer_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ pub fn compute_proposer_duties_from_head<T: BeaconChainTypes>(
current_epoch: Epoch,
chain: &BeaconChain<T>,
) -> Result<(Vec<usize>, Hash256, ExecutionStatus, Fork), BeaconChainError> {
// Atomically collect information about the head whilst hogging the `canonical_head_lock` as
// little as possible.
// Atomically collect information about the head whilst holding the canonical head `Arc` as
// short as possible.
let (mut state, head_state_root, head_block_root) = {
let head = chain.canonical_head.cached_head();
// Take a copy of the head state.
Expand Down
15 changes: 0 additions & 15 deletions beacon_node/beacon_chain/src/canonical_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +619,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}

/// Perform updates to caches and other components after the canonical head has been changed.
///
/// # Deadlock Warning
///
/// Taking a write lock on the `self.canonical_head` in this function will result in a deadlock!
/// This is because `Self::recompute_head_internal` will already be holding a read-lock.
fn after_new_head(
self: &Arc<Self>,
old_cached_head: &CachedHead<T::EthSpec>,
Expand Down Expand Up @@ -753,11 +748,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {

/// Perform updates to caches and other components after the finalized checkpoint has been
/// changed.
///
/// # Deadlock Warning
///
/// Taking a write lock on the `self.canonical_head` in this function will result in a deadlock!
/// This is because `Self::recompute_head_internal` will already be holding a read-lock.
fn after_finalization(
self: &Arc<Self>,
new_cached_head: &CachedHead<T::EthSpec>,
Expand Down Expand Up @@ -899,11 +889,6 @@ fn check_finalized_payload_validity<T: BeaconChainTypes>(
}

/// Check to ensure that the transition from `old_view` to `new_view` will not revert finality.
///
/// ## Notes
///
/// This function is called whilst holding a write-lock on the `canonical_head`. To ensure dead-lock
/// safety, **do not take any other locks inside this function**.
fn check_against_finality_reversion(
old_view: &ForkChoiceView,
new_view: &ForkChoiceView,
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/execution_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ pub async fn validate_merge_block<'a, T: BeaconChainTypes>(
.now()
.ok_or(BeaconChainError::UnableToReadSlot)?;
// Use a blocking task to check if the block is an optimistic candidate. Interacting
// with the `canonical_head` lock in an async task can block the core executor.
// with the `fork_choice` lock in an async task can block the core executor.
let inner_chain = chain.clone();
let block_parent_root = block.parent_root();
let block_slot = block.slot();
Expand Down Expand Up @@ -403,7 +403,7 @@ where

// Try to obtain the finalized proto block from fork choice.
//
// Use a blocking task to interact with the `canonical_head` lock otherwise we risk blocking the
// Use a blocking task to interact with the `fork_choice` lock otherwise we risk blocking the
// core `tokio` executor.
let inner_chain = chain.clone();
let finalized_proto_block = chain
Expand Down

0 comments on commit 08082fb

Please sign in to comment.