send error answering bbrange requests when an error occurrs (#3800)

## Issue Addressed

While testing withdrawals with @ethDreamer we noticed lighthouse is sending empty batches when an error occurs. As LH peer receiving this, we would consider this a low tolerance action because the peer is claiming the batch is right and is empty.

## Proposed Changes
If any kind of error occurs, send a error response instead

## Additional Info
Right now we don't handle such thing as a partial batch with an error. If an error is received, the whole batch is discarded. Because of this it makes little sense to send partial batches that end with an error, so it's better to do the proposed solution instead of sending empty batches.
This commit is contained in:
Divma 2022-12-15 00:16:38 +00:00
parent 023674ab3b
commit 63c74b37f4

View File

@ -398,6 +398,15 @@ impl<T: BeaconChainTypes> Worker<T> {
"block_root" => ?root,
"error" => ?e
);
// send the stream terminator
self.send_error_response(
peer_id,
RPCResponseErrorCode::ServerError,
"Failed fetching blocks".into(),
request_id,
);
send_response = false;
break;
}
}