Skip to content

Commit

Permalink
add forK_choice_read_lock as parameter (#4978)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gua00va authored Dec 13, 2023
1 parent 7f64738 commit a3fb27c
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions beacon_node/beacon_chain/src/block_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,10 +838,11 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
&fork_choice_read_lock,
block,
)?;
drop(fork_choice_read_lock);

let block_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch());
let (parent_block, block) = verify_parent_block_is_known(block_root, chain, block)?;
let (parent_block, block) =
verify_parent_block_is_known::<T>(block_root, &fork_choice_read_lock, block)?;
drop(fork_choice_read_lock);

// Track the number of skip slots between the block and its parent.
metrics::set_gauge(
Expand Down Expand Up @@ -1775,14 +1776,10 @@ pub fn get_block_root<E: EthSpec>(block: &SignedBeaconBlock<E>) -> Hash256 {
#[allow(clippy::type_complexity)]
fn verify_parent_block_is_known<T: BeaconChainTypes>(
block_root: Hash256,
chain: &BeaconChain<T>,
fork_choice_read_lock: &RwLockReadGuard<BeaconForkChoice<T>>,
block: Arc<SignedBeaconBlock<T::EthSpec>>,
) -> Result<(ProtoBlock, Arc<SignedBeaconBlock<T::EthSpec>>), BlockError<T::EthSpec>> {
if let Some(proto_block) = chain
.canonical_head
.fork_choice_read_lock()
.get_block(&block.parent_root())
{
if let Some(proto_block) = fork_choice_read_lock.get_block(&block.parent_root()) {
Ok((proto_block, block))
} else {
Err(BlockError::ParentUnknown(RpcBlock::new_without_blobs(
Expand Down

0 comments on commit a3fb27c

Please sign in to comment.