Skip to content

Commit 38192f7

Browse files
michaelsprouleserilev
authored andcommitted
Fix descent from split check
1 parent fa6927b commit 38192f7

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

beacon_node/beacon_chain/src/block_verification.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,17 +1758,14 @@ pub fn check_block_is_finalized_checkpoint_or_descendant<
17581758
fork_choice: &BeaconForkChoice<T>,
17591759
block: B,
17601760
) -> Result<B, BlockError> {
1761-
if fork_choice.is_finalized_checkpoint_or_descendant(block.parent_root()) {
1761+
// If we have a split block newer than finalization then we also ban blocks which are not
1762+
// descended from that split block.
1763+
let split = chain.store.get_split_info();
1764+
if fork_choice.is_finalized_checkpoint_or_descendant(block.parent_root())
1765+
&& fork_choice.is_descendant(split.block_root, block.parent_root())
1766+
{
17621767
Ok(block)
17631768
} else {
1764-
// If we have a split block newer than finalization then we also ban blocks which are not
1765-
// descended from that split block.
1766-
let split = chain.store.get_split_info();
1767-
if !fork_choice.is_descendant(split.block_root, block.parent_root()) {
1768-
Err(BlockError::NotFinalizedDescendant {
1769-
block_parent_root: block.parent_root(),
1770-
})
1771-
}
17721769
// If fork choice does *not* consider the parent to be a descendant of the finalized block,
17731770
// then there are two more cases:
17741771
//
@@ -1777,7 +1774,7 @@ pub fn check_block_is_finalized_checkpoint_or_descendant<
17771774
// pre-finalization or conflicting with finalization.
17781775
// 2. The parent is unknown to us, we probably want to download it since it might actually
17791776
// descend from the finalized root.
1780-
else if chain
1777+
if chain
17811778
.store
17821779
.block_exists(&block.parent_root())
17831780
.map_err(|e| BlockError::BeaconChainError(e.into()))?

0 commit comments

Comments
 (0)