Skip to content

Commit da505f0

Browse files
committed
Fix unexpected UnrequestedBlobId and ExtraBlocksReturned errors due to race conditions.
1 parent 19b0db2 commit da505f0

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

beacon_node/beacon_chain/src/data_availability_checker.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
110110
self.processing_cache.read().get(&block_root).cloned()
111111
}
112112

113-
/// A `None` indicates blobs are not required.
114-
///
115113
/// If there's no block, all possible ids will be returned that don't exist in the given blobs.
116114
/// If there no blobs, all possible ids will be returned.
117115
pub fn get_missing_blob_ids<V: AvailabilityView<T::EthSpec>>(

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,16 +371,21 @@ impl<L: Lookup, T: BeaconChainTypes> RequestState<L, T> for BlobRequestState<L,
371371

372372
fn verify_response_inner(
373373
&mut self,
374-
_expected_block_root: Hash256,
374+
expected_block_root: Hash256,
375375
blob: Option<Self::ResponseType>,
376376
peer_id: PeerId,
377377
) -> Result<Option<FixedBlobSidecarList<T::EthSpec>>, LookupVerifyError> {
378378
match blob {
379379
Some(blob) => {
380380
let received_id = blob.id();
381381
if !self.requested_ids.contains(&received_id) {
382+
if expected_block_root == received_id.block_root {
383+
// We may have already received this blob via gossip since the lookup,
384+
// so don't return an error here.
385+
return Ok(None);
386+
}
382387
self.state.register_failure_downloading();
383-
Err(LookupVerifyError::UnrequestedBlobId)
388+
Err(LookupVerifyError::UnrequestedBlobId(received_id))
384389
} else {
385390
// State should remain downloading until we receive the stream terminator.
386391
self.requested_ids.remove(&received_id);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
540540
| ParentVerifyError::NoBlockReturned
541541
| ParentVerifyError::NotEnoughBlobsReturned
542542
| ParentVerifyError::ExtraBlocksReturned
543-
| ParentVerifyError::UnrequestedBlobId
543+
| ParentVerifyError::UnrequestedBlobId(_)
544544
| ParentVerifyError::ExtraBlobsReturned
545545
| ParentVerifyError::InvalidIndex(_) => {
546546
let e = e.into();

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::collections::VecDeque;
1212
use std::sync::Arc;
1313
use store::Hash256;
1414
use strum::IntoStaticStr;
15+
use types::blob_sidecar::BlobIdentifier;
1516

1617
/// How many attempts we try to find a parent of a block before we give up trying.
1718
pub(crate) const PARENT_FAIL_TOLERANCE: u8 = 5;
@@ -36,7 +37,7 @@ pub enum ParentVerifyError {
3637
NoBlockReturned,
3738
NotEnoughBlobsReturned,
3839
ExtraBlocksReturned,
39-
UnrequestedBlobId,
40+
UnrequestedBlobId(BlobIdentifier),
4041
ExtraBlobsReturned,
4142
InvalidIndex(u64),
4243
PreviousFailure { parent_root: Hash256 },
@@ -242,7 +243,7 @@ impl From<LookupVerifyError> for ParentVerifyError {
242243
E::RootMismatch => ParentVerifyError::RootMismatch,
243244
E::NoBlockReturned => ParentVerifyError::NoBlockReturned,
244245
E::ExtraBlocksReturned => ParentVerifyError::ExtraBlocksReturned,
245-
E::UnrequestedBlobId => ParentVerifyError::UnrequestedBlobId,
246+
E::UnrequestedBlobId(blob_id) => ParentVerifyError::UnrequestedBlobId(blob_id),
246247
E::ExtraBlobsReturned => ParentVerifyError::ExtraBlobsReturned,
247248
E::InvalidIndex(index) => ParentVerifyError::InvalidIndex(index),
248249
E::NotEnoughBlobsReturned => ParentVerifyError::NotEnoughBlobsReturned,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::marker::PhantomData;
1616
use std::sync::Arc;
1717
use store::Hash256;
1818
use strum::IntoStaticStr;
19-
use types::blob_sidecar::FixedBlobSidecarList;
19+
use types::blob_sidecar::{BlobIdentifier, FixedBlobSidecarList};
2020
use types::EthSpec;
2121

2222
#[derive(Debug, PartialEq, Eq)]
@@ -31,7 +31,7 @@ pub enum LookupVerifyError {
3131
RootMismatch,
3232
NoBlockReturned,
3333
ExtraBlocksReturned,
34-
UnrequestedBlobId,
34+
UnrequestedBlobId(BlobIdentifier),
3535
ExtraBlobsReturned,
3636
NotEnoughBlobsReturned,
3737
InvalidIndex(u64),
@@ -184,6 +184,7 @@ impl<L: Lookup, T: BeaconChainTypes> SingleBlockLookup<L, T> {
184184
existing_components.merge_block(block);
185185
}
186186
existing_components.merge_blobs(downloaded_blobs);
187+
// TODO check if we could send it to processing?
187188
} else {
188189
self.child_components = Some(components);
189190
}

0 commit comments

Comments
 (0)