Skip to content

Commit bad87b1

Browse files
committed
Merge current and parent lookups tests
1 parent 5d29618 commit bad87b1

File tree

11 files changed

+682
-265
lines changed

11 files changed

+682
-265
lines changed

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,6 +2918,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
29182918
.fork_choice_read_lock()
29192919
.contains_block(&block_root)
29202920
{
2921+
// TODO: Should also check for:
2922+
// - Parent block is known
2923+
// - Slot is not in the future
29212924
return Err(BlockError::BlockIsAlreadyKnown(block_root));
29222925
}
29232926

beacon_node/network/src/sync/block_lookups/common.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub trait RequestState<T: BeaconChainTypes> {
4949
id: Id,
5050
awaiting_parent: bool,
5151
downloaded_block_expected_blobs: Option<usize>,
52+
block_is_processed: bool,
5253
cx: &mut SyncNetworkContext<T>,
5354
) -> Result<(), LookupRequestError> {
5455
// Attempt to progress awaiting downloads
@@ -75,7 +76,12 @@ pub trait RequestState<T: BeaconChainTypes> {
7576
// Otherwise, attempt to progress awaiting processing
7677
// If this request is awaiting a parent lookup to be processed, do not send for processing.
7778
// The request will be rejected with unknown parent error.
78-
} else if !awaiting_parent {
79+
} else if !awaiting_parent &&
80+
// TODO: Blob processing / import does not check for unknown parent. As a temporary fix
81+
// and to emulate the behaviour before this PR, hold blobs for processing until the
82+
// block has been processed i.e. it has a known parent.
83+
(block_is_processed || matches!(Self::response_type(), ResponseType::Block))
84+
{
7985
// maybe_start_processing returns Some if state == AwaitingProcess. This pattern is
8086
// useful to conditionally access the result data.
8187
if let Some(result) = self.get_state_mut().maybe_start_processing() {

0 commit comments

Comments
 (0)