Skip to content

Commit 4acc294

Browse files
committed
ensure we don't reset requested_ids during rpc download
1 parent 4d629db commit 4acc294

File tree

4 files changed

+46
-33
lines changed

4 files changed

+46
-33
lines changed

beacon_node/beacon_chain/src/data_availability_checker.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,14 @@ impl MissingBlobs {
655655
MissingBlobs::BlobsNotRequired => vec![],
656656
}
657657
}
658+
659+
pub fn clear(&mut self) {
660+
match self {
661+
MissingBlobs::KnownMissing(ref mut v) => v.clear(),
662+
MissingBlobs::PossibleMissing(ref mut v) => v.clear(),
663+
MissingBlobs::BlobsNotRequired => (),
664+
}
665+
}
658666
}
659667

660668
impl Into<Vec<BlobIdentifier>> for MissingBlobs {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ impl<L: Lookup, T: BeaconChainTypes> RequestState<L, T> for BlobRequestState<L,
396396
None => {
397397
self.state.state = State::Processing { peer_id };
398398
let blobs = std::mem::take(&mut self.blob_download_queue);
399+
self.requested_ids.clear();
400+
399401
Ok(Some(blobs))
400402
}
401403
}

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

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,19 @@ impl<L: Lookup, T: BeaconChainTypes> SingleBlockLookup<L, T> {
115115
cx: &SyncNetworkContext<T>,
116116
) -> Result<(), LookupRequestError> {
117117
let block_already_downloaded = self.block_already_downloaded();
118-
let blobs_already_downloaded = self.blobs_already_downloaded();
118+
let should_request_blobs = if self.blob_request_state.requested_ids.is_empty() {
119+
let blob_ids = self.missing_blob_ids();
120+
self.blob_request_state.requested_ids = blob_ids;
121+
!self.blob_request_state.requested_ids.is_empty()
122+
} else {
123+
false
124+
};
119125

120126
if !block_already_downloaded {
121127
self.block_request_state
122128
.build_request_and_send(self.id, cx)?;
123129
}
124-
if !blobs_already_downloaded {
130+
if should_request_blobs {
125131
self.blob_request_state
126132
.build_request_and_send(self.id, cx)?;
127133
}
@@ -253,19 +259,6 @@ impl<L: Lookup, T: BeaconChainTypes> SingleBlockLookup<L, T> {
253259
}
254260
}
255261

256-
/// Updates the `requested_ids` field of the `BlockRequestState` with the most recent picture
257-
/// of which blobs still need to be requested. Returns `true` if there are no more blobs to
258-
/// request.
259-
pub(crate) fn blobs_already_downloaded(&mut self) -> bool {
260-
self.update_blobs_request();
261-
self.blob_request_state.requested_ids.is_empty()
262-
}
263-
264-
/// Updates this request with the most recent picture of which blobs still need to be requested.
265-
pub fn update_blobs_request(&mut self) {
266-
self.blob_request_state.requested_ids = self.missing_blob_ids();
267-
}
268-
269262
/// If `child_components` is `Some`, we know block components won't hit the data
270263
/// availability cache, so we don't check its processing cache unless `child_components`
271264
/// is `None`.

beacon_node/network/src/sync/manager.rs

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -831,27 +831,37 @@ impl<T: BeaconChainTypes> SyncManager<T> {
831831
seen_timestamp: Duration,
832832
) {
833833
match request_id {
834-
RequestId::SingleBlock { id } => self
835-
.block_lookups
836-
.single_lookup_response::<BlockRequestState<Current>>(
837-
id,
838-
peer_id,
839-
block,
840-
seen_timestamp,
841-
&self.network,
842-
),
834+
RequestId::SingleBlock { id } => {
835+
debug!(self.log,
836+
"Peer returned block for single lookup";
837+
"peer_id" => %peer_id ,
838+
);
839+
self.block_lookups
840+
.single_lookup_response::<BlockRequestState<Current>>(
841+
id,
842+
peer_id,
843+
block,
844+
seen_timestamp,
845+
&self.network,
846+
)
847+
}
843848
RequestId::SingleBlob { .. } => {
844849
crit!(self.log, "Block received during blob request"; "peer_id" => %peer_id );
845850
}
846-
RequestId::ParentLookup { id } => self
847-
.block_lookups
848-
.parent_lookup_response::<BlockRequestState<Parent>>(
849-
id,
850-
peer_id,
851-
block,
852-
seen_timestamp,
853-
&self.network,
854-
),
851+
RequestId::ParentLookup { id } => {
852+
debug!(self.log,
853+
"Peer returned block for single lookup";
854+
"peer_id" => %peer_id ,
855+
);
856+
self.block_lookups
857+
.parent_lookup_response::<BlockRequestState<Parent>>(
858+
id,
859+
peer_id,
860+
block,
861+
seen_timestamp,
862+
&self.network,
863+
)
864+
}
855865
RequestId::ParentLookupBlob { id: _ } => {
856866
crit!(self.log, "Block received during parent blob request"; "peer_id" => %peer_id );
857867
}

0 commit comments

Comments
 (0)