Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lean_client/networking/src/network/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ use crate::{
discovery::{DiscoveryConfig, DiscoveryService},
enr_ext::EnrExt,
gossipsub::{self, config::GossipsubConfig, message::GossipsubMessage, topic::GossipsubKind},
network::behaviour::{LeanNetworkBehaviour, LeanNetworkBehaviourEvent},
network::range_sync::{MAX_SYNC_RANGE, RangeSyncState},
req_resp::{self, LeanRequest, ReqRespMessage},
network::{
behaviour::{LeanNetworkBehaviour, LeanNetworkBehaviourEvent},
range_sync::{MAX_SYNC_RANGE, RangeSyncState},
},
req_resp::{self, LeanRequest, RESPONSE_INVALID_REQUEST, ReqRespMessage},
types::{
CanonicalBlocksProvider, ChainMessage, ChainMessageSink, ConnectionState,
MAX_BLOCK_CACHE_SIZE, NetworkFinalizedSlot, OutboundP2pRequest, P2pRequestSource,
Expand Down Expand Up @@ -1676,8 +1678,10 @@ where

if count == 0 || count > req_resp::MAX_REQUEST_BLOCKS as u64 {
info!(peer = %peer, start_slot, count, "Rejecting BlocksByRange: invalid count");
// Send an empty response — peer will treat as no data.
let response = LeanResponse::BlocksByRange(Vec::new());
let response = LeanResponse::Error {
code: RESPONSE_INVALID_REQUEST,
message: "Invalid Block Request Count".to_string(),
};
if let Err(e) = self
.swarm
.behaviour_mut()
Expand Down
4 changes: 4 additions & 0 deletions lean_client/networking/src/req_resp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub enum LeanResponse {
Status(Status),
BlocksByRoot(Vec<SignedBlock>),
BlocksByRange(Vec<SignedBlock>),
Error { code: u8, message: String },
Empty,
}

Expand Down Expand Up @@ -297,6 +298,9 @@ impl LeanCodec {
}
Ok(result)
}
LeanResponse::Error { code, message } => {
Self::encode_response_chunk(*code, message.as_bytes())
}
LeanResponse::Empty => Ok(Vec::new()),
}
}
Expand Down
Loading