-
Notifications
You must be signed in to change notification settings - Fork 679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DropReason and DropPeer structs to pass reason string to logs about Dropping a Neighbor #5720
base: develop
Are you sure you want to change the base?
Conversation
…with them Signed-off-by: Jacinta Ferrant <[email protected]>
I like this approach overall. I think it may be worth consolidating Can this PR also implement a better formatter for |
Can do! EDIT: just a quick question, does this mean the event_id is not really relevant for matching on a neighbor key? just the neighbor_key.addrbytes, i.e. PeerAddress? Specifically...can multiple neighbor_keys with the same peer_address (even if sep port) match to the same event_id... Cause then it might not be so straightforward cause deregister_peer highly relies on event_id. For example I see this in deregister_peer which makes me think that there are multiple matching neighbor keys per event id... let mut nk_remove: Vec<(NeighborKey, Hash160)> = vec![];
for (neighbor_key, ev_id) in self.events.iter() {
if event_id == ev_id {
let pubkh = self
.get_p2p_convo(event_id)
.and_then(|convo| convo.get_public_key_hash())
.unwrap_or(Hash160([0x00; 20]));
nk_remove.push((neighbor_key.clone(), pubkh, event_id));
}
} |
… into chore/add-drop-reason-to-p2p-logs
…mplementation of fmt::Display Signed-off-by: Jacinta Ferrant <[email protected]>
The system won't register a new socket to a peer that already has a socket open, so there won't be multiple |
Perfect! This was my only concern I think. so I should be able ot make this work. |
… into chore/add-drop-reason-to-p2p-logs
Signed-off-by: Jacinta Ferrant <[email protected]>
A couple things you could add here, potentially:
|
… into chore/add-drop-reason-to-p2p-logs
… into chore/add-drop-reason-to-p2p-logs
Signed-off-by: Jacinta Ferrant <[email protected]>
@jcnelson I tried to combine DropPeer and DropNeighbor but I had a really hard time replacing it in much of the code base as the neighbor key is used to deregister and ban neighbors and it seems like a LOT of the code is based on the nieghbor key itself, not just the PeerAddress. I don't mind trying to refactor this code, but it will be substantial and I am worried that we might introduce bugs as the PeerAddress would ignore ports whereas NeighborKey would not. Also, when you say "only log peers' acceptance after they've completed a handshake", do you mean maybe remove the "Neighbor accepted log" since we already have a debug log: debug!(
"{:?}: Registered {} as event {} ({:?},outbound={})",
&self.local_peer, &client_addr, event_id, &neighbor_key, outbound
); And then attempt to add an info level log in |
… into chore/add-drop-reason-to-p2p-logs
Signed-off-by: Jacinta Ferrant <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM; just had one minor comment.
Signed-off-by: Jacinta Ferrant <[email protected]>
… into chore/add-drop-reason-to-p2p-logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good, just two minor comments.
|
||
### Changed | ||
|
||
- Logging improvements: | ||
- P2P logs now includes a reason for dropping a peer or neighbor | ||
- Imrpovements to how a PeerAddress is logged (human readable format vs hex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Imrpovements to how a PeerAddress is logged (human readable format vs hex) | |
- Improvements to how a PeerAddress is logged (human readable format vs hex) |
@@ -2301,6 +2302,7 @@ impl PeerNetwork { | |||
stats.done | |||
); | |||
if !stats.done { | |||
// TODO: the result of this match doesn't seem to be used? is that intentional? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this result is intentionally ignored. @jcnelson can you confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes; this was written in a time when I was a lot less idiomatic in my Rust code and when we didn't really prioritize conforming to it.
Closes #5714