log upgrades + prevent dialing of disconnecting peers (#3148)
## Issue Addressed We still ping peers that are considered in a disconnecting state ## Proposed Changes Do not ping peers once we decide they are disconnecting Upgrade logs about ignored rpc messages ## Additional Info --
This commit is contained in:
parent
b49b4291a3
commit
580d2f7873
@ -991,7 +991,7 @@ where
|
||||
debug!(
|
||||
self.log,
|
||||
"Ignoring rpc message of disconnecting peer";
|
||||
"peer" => %peer_id
|
||||
event
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -213,6 +213,8 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
ScoreUpdateResult::Disconnect => {
|
||||
// The peer has transitioned to a disconnect state and has been marked as such in
|
||||
// the peer db. We must inform libp2p to disconnect this peer.
|
||||
self.inbound_ping_peers.remove(peer_id);
|
||||
self.outbound_ping_peers.remove(peer_id);
|
||||
self.events.push(PeerManagerEvent::DisconnectPeer(
|
||||
*peer_id,
|
||||
GoodbyeReason::BadScore,
|
||||
|
@ -335,6 +335,19 @@ impl RPCResponseErrorCode {
|
||||
}
|
||||
}
|
||||
|
||||
use super::Protocol;
|
||||
impl<T: EthSpec> RPCResponse<T> {
|
||||
pub fn protocol(&self) -> Protocol {
|
||||
match self {
|
||||
RPCResponse::Status(_) => Protocol::Status,
|
||||
RPCResponse::BlocksByRange(_) => Protocol::BlocksByRange,
|
||||
RPCResponse::BlocksByRoot(_) => Protocol::BlocksByRoot,
|
||||
RPCResponse::Pong(_) => Protocol::Ping,
|
||||
RPCResponse::MetaData(_) => Protocol::MetaData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for RPCResponseErrorCode {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let repr = match self {
|
||||
|
@ -271,3 +271,38 @@ where
|
||||
Poll::Pending
|
||||
}
|
||||
}
|
||||
|
||||
impl<Id, TSpec> slog::KV for RPCMessage<Id, TSpec>
|
||||
where
|
||||
TSpec: EthSpec,
|
||||
Id: ReqId,
|
||||
{
|
||||
fn serialize(
|
||||
&self,
|
||||
_record: &slog::Record,
|
||||
serializer: &mut dyn slog::Serializer,
|
||||
) -> slog::Result {
|
||||
serializer.emit_arguments("peer_id", &format_args!("{}", self.peer_id))?;
|
||||
let (msg_kind, protocol) = match &self.event {
|
||||
Ok(received) => match received {
|
||||
RPCReceived::Request(_, req) => ("request", req.protocol()),
|
||||
RPCReceived::Response(_, res) => ("response", res.protocol()),
|
||||
RPCReceived::EndOfStream(_, end) => (
|
||||
"end_of_stream",
|
||||
match end {
|
||||
ResponseTermination::BlocksByRange => Protocol::BlocksByRange,
|
||||
ResponseTermination::BlocksByRoot => Protocol::BlocksByRoot,
|
||||
},
|
||||
),
|
||||
},
|
||||
Err(error) => match &error {
|
||||
HandlerErr::Inbound { proto, .. } => ("inbound_err", *proto),
|
||||
HandlerErr::Outbound { proto, .. } => ("outbound_err", *proto),
|
||||
},
|
||||
};
|
||||
serializer.emit_str("msg_kind", msg_kind)?;
|
||||
serializer.emit_arguments("protocol", &format_args!("{}", protocol))?;
|
||||
|
||||
slog::Result::Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user