Skip to content
Snippets Groups Projects
Unverified Commit f2d9d6e9 authored by paritytech-cmd-bot-polkadot-sdk[bot]'s avatar paritytech-cmd-bot-polkadot-sdk[bot] Committed by GitHub
Browse files

[stable2409] Backport #7158 (#7181)


Backport #7158 into `stable2409` from lexnv.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

Co-authored-by: default avatarAlexandru Vasile <60601340+lexnv@users.noreply.github.com>
parent 799dd045
No related merge requests found
title: Reject litep2p inbound requests from banned peers
doc:
- audience: Node Dev
description: |
This PR rejects inbound requests from banned peers (reputation is below the banned threshold).
This mirrors the request-response implementation from the libp2p side.
While at it, have registered a new inbound failure metric to have visibility into this.
crates:
- name: sc-network
bump: patch
......@@ -271,6 +271,13 @@ impl RequestResponseProtocol {
request_id: RequestId,
request: Vec<u8>,
) {
log::trace!(
target: LOG_TARGET,
"{}: request received from {peer:?} ({fallback:?} {request_id:?}), request size {:?}",
self.protocol,
request.len(),
);
let Some(inbound_queue) = &self.inbound_queue else {
log::trace!(
target: LOG_TARGET,
......@@ -282,12 +289,18 @@ impl RequestResponseProtocol {
return;
};
log::trace!(
target: LOG_TARGET,
"{}: request received from {peer:?} ({fallback:?} {request_id:?}), request size {:?}",
self.protocol,
request.len(),
);
if self.peerstore_handle.is_banned(&peer.into()) {
log::trace!(
target: LOG_TARGET,
"{}: rejecting inbound request from banned {peer:?} ({request_id:?})",
self.protocol,
);
self.handle.reject_request(request_id);
self.metrics.register_inbound_request_failure("banned-peer");
return;
}
let (tx, rx) = oneshot::channel();
match inbound_queue.try_send(IncomingRequest {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment