mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 04:01:51 +00:00
handle parent blob request edge cases correctly. fix data availability boundary check
This commit is contained in:
@@ -473,6 +473,11 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
RPCError::ErrorResponse(code, _) => match code {
|
||||
RPCResponseErrorCode::Unknown => PeerAction::HighToleranceError,
|
||||
RPCResponseErrorCode::ResourceUnavailable => {
|
||||
// Don't ban on this because we want to retry with a block by root request.
|
||||
if matches!(protocol, Protocol::BlobsByRoot) {
|
||||
return;
|
||||
}
|
||||
|
||||
// NOTE: This error only makes sense for the `BlocksByRange` and `BlocksByRoot`
|
||||
// protocols.
|
||||
//
|
||||
|
||||
@@ -531,9 +531,6 @@ fn handle_v2_request<T: EthSpec>(
|
||||
Protocol::BlocksByRoot => Ok(Some(InboundRequest::BlocksByRoot(BlocksByRootRequest {
|
||||
block_roots: VariableList::from_ssz_bytes(decoded_buffer)?,
|
||||
}))),
|
||||
Protocol::BlobsByRange => Ok(Some(InboundRequest::BlobsByRange(
|
||||
BlobsByRangeRequest::from_ssz_bytes(decoded_buffer)?,
|
||||
))),
|
||||
// MetaData requests return early from InboundUpgrade and do not reach the decoder.
|
||||
// Handle this case just for completeness.
|
||||
Protocol::MetaData => {
|
||||
@@ -826,12 +823,25 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
fn blbrange_request() -> BlobsByRangeRequest {
|
||||
BlobsByRangeRequest {
|
||||
start_slot: 0,
|
||||
count: 10,
|
||||
}
|
||||
}
|
||||
|
||||
fn bbroot_request() -> BlocksByRootRequest {
|
||||
BlocksByRootRequest {
|
||||
block_roots: VariableList::from(vec![Hash256::zero()]),
|
||||
}
|
||||
}
|
||||
|
||||
fn blbroot_request() -> BlobsByRootRequest {
|
||||
BlobsByRootRequest {
|
||||
block_roots: VariableList::from(vec![Hash256::zero()]),
|
||||
}
|
||||
}
|
||||
|
||||
fn ping_message() -> Ping {
|
||||
Ping { data: 1 }
|
||||
}
|
||||
@@ -1454,6 +1464,8 @@ mod tests {
|
||||
OutboundRequest::Goodbye(GoodbyeReason::Fault),
|
||||
OutboundRequest::BlocksByRange(bbrange_request()),
|
||||
OutboundRequest::BlocksByRoot(bbroot_request()),
|
||||
OutboundRequest::BlobsByRange(blbrange_request()),
|
||||
OutboundRequest::BlobsByRoot(blbroot_request()),
|
||||
OutboundRequest::MetaData(PhantomData::<Spec>),
|
||||
];
|
||||
for req in requests.iter() {
|
||||
|
||||
@@ -75,6 +75,8 @@ pub enum NetworkEvent<AppReqId: ReqId, TSpec: EthSpec> {
|
||||
id: AppReqId,
|
||||
/// The peer to which this request was sent.
|
||||
peer_id: PeerId,
|
||||
/// The error of the failed request.
|
||||
error: RPCError,
|
||||
},
|
||||
RequestReceived {
|
||||
/// The peer that sent the request.
|
||||
@@ -1177,9 +1179,9 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
|
||||
&error,
|
||||
ConnectionDirection::Outgoing,
|
||||
);
|
||||
// inform failures of requests comming outside the behaviour
|
||||
// inform failures of requests coming outside the behaviour
|
||||
if let RequestId::Application(id) = id {
|
||||
Some(NetworkEvent::RPCFailed { peer_id, id })
|
||||
Some(NetworkEvent::RPCFailed { peer_id, id, error })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user