Skip to content

Commit

Permalink
Merge current and parent lookups tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Apr 26, 2024
1 parent 5d29618 commit bad87b1
Show file tree
Hide file tree
Showing 11 changed files with 682 additions and 265 deletions.
3 changes: 3 additions & 0 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2918,6 +2918,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.fork_choice_read_lock()
.contains_block(&block_root)
{
// TODO: Should also check for:
// - Parent block is known
// - Slot is not in the future
return Err(BlockError::BlockIsAlreadyKnown(block_root));
}

Expand Down
8 changes: 7 additions & 1 deletion beacon_node/network/src/sync/block_lookups/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub trait RequestState<T: BeaconChainTypes> {
id: Id,
awaiting_parent: bool,
downloaded_block_expected_blobs: Option<usize>,
block_is_processed: bool,
cx: &mut SyncNetworkContext<T>,
) -> Result<(), LookupRequestError> {
// Attempt to progress awaiting downloads
Expand All @@ -75,7 +76,12 @@ pub trait RequestState<T: BeaconChainTypes> {
// Otherwise, attempt to progress awaiting processing
// If this request is awaiting a parent lookup to be processed, do not send for processing.
// The request will be rejected with unknown parent error.
} else if !awaiting_parent {
} else if !awaiting_parent &&
// TODO: Blob processing / import does not check for unknown parent. As a temporary fix
// and to emulate the behaviour before this PR, hold blobs for processing until the
// block has been processed i.e. it has a known parent.
(block_is_processed || matches!(Self::response_type(), ResponseType::Block))
{
// maybe_start_processing returns Some if state == AwaitingProcess. This pattern is
// useful to conditionally access the result data.
if let Some(result) = self.get_state_mut().maybe_start_processing() {
Expand Down
Loading

0 comments on commit bad87b1

Please sign in to comment.