mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-16 20:39:10 +00:00
Send byrange responses in the correct requested range (#7611)
N/A For responding to by_range requests , we should ideally only respond with items in the range `req.start_slot()..req.start_slot() + req.count`. We were not filtering the generated response for blobs and data columns, only for blocks. This PR adds the filtering for the sidecars as well.
This commit is contained in:
@@ -945,6 +945,11 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
|||||||
match self.chain.get_blobs(&root) {
|
match self.chain.get_blobs(&root) {
|
||||||
Ok(blob_sidecar_list) => {
|
Ok(blob_sidecar_list) => {
|
||||||
for blob_sidecar in blob_sidecar_list.iter() {
|
for blob_sidecar in blob_sidecar_list.iter() {
|
||||||
|
// Due to skip slots, blobs could be out of the range, we ensure they
|
||||||
|
// are in the range before sending
|
||||||
|
if blob_sidecar.slot() >= request_start_slot
|
||||||
|
&& blob_sidecar.slot() < request_start_slot + req.count
|
||||||
|
{
|
||||||
blobs_sent += 1;
|
blobs_sent += 1;
|
||||||
self.send_network_message(NetworkMessage::SendResponse {
|
self.send_network_message(NetworkMessage::SendResponse {
|
||||||
peer_id,
|
peer_id,
|
||||||
@@ -953,6 +958,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!(
|
error!(
|
||||||
request = ?req,
|
request = ?req,
|
||||||
@@ -1058,6 +1064,11 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
|||||||
for index in &req.columns {
|
for index in &req.columns {
|
||||||
match self.chain.get_data_column(&root, index) {
|
match self.chain.get_data_column(&root, index) {
|
||||||
Ok(Some(data_column_sidecar)) => {
|
Ok(Some(data_column_sidecar)) => {
|
||||||
|
// Due to skip slots, data columns could be out of the range, we ensure they
|
||||||
|
// are in the range before sending
|
||||||
|
if data_column_sidecar.slot() >= request_start_slot
|
||||||
|
&& data_column_sidecar.slot() < request_start_slot + req.count
|
||||||
|
{
|
||||||
data_columns_sent += 1;
|
data_columns_sent += 1;
|
||||||
self.send_network_message(NetworkMessage::SendResponse {
|
self.send_network_message(NetworkMessage::SendResponse {
|
||||||
peer_id,
|
peer_id,
|
||||||
@@ -1067,6 +1078,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
|||||||
)),
|
)),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Ok(None) => {} // no-op
|
Ok(None) => {} // no-op
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!(
|
error!(
|
||||||
|
|||||||
Reference in New Issue
Block a user