Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Do not issue empty remote read request + fix rr-related trace on full node #4619

Merged
merged 1 commit into from
Jan 14, 2020
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: 14 additions & 0 deletions client/network/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,13 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
who: PeerId,
request: message::RemoteReadRequest<B::Hash>,
) {
if request.keys.is_empty() {
debug!(target: "sync", "Invalid remote read request sent by {}", who);
self.behaviour.disconnect_peer(&who);
self.peerset_handle.report_peer(who, rep::BAD_MESSAGE);
return;
}

let keys_str = || match request.keys.len() {
1 => request.keys[0].to_hex::<String>(),
_ => format!(
Expand Down Expand Up @@ -1510,6 +1517,13 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
who: PeerId,
request: message::RemoteReadChildRequest<B::Hash>,
) {
if request.keys.is_empty() {
debug!(target: "sync", "Invalid remote child read request sent by {}", who);
self.behaviour.disconnect_peer(&who);
self.peerset_handle.report_peer(who, rep::BAD_MESSAGE);
return;
}

let keys_str = || match request.keys.len() {
1 => request.keys[0].to_hex::<String>(),
_ => format!(
Expand Down
4 changes: 2 additions & 2 deletions client/rpc/src/state/state_light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ impl<Block, F, B, E, RA> StateBackend<B, E, Block, RA> for LightState<Block, F,
keys: Option<Vec<StorageKey>>
) {
let keys = match keys {
Some(keys) => keys,
None => {
Some(keys) if !keys.is_empty() => keys,
_ => {
warn!("Cannot subscribe to all keys on light client. Subscription rejected.");
return;
}
Expand Down