-
-
Notifications
You must be signed in to change notification settings - Fork 323
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
Return peer count #3860
Return peer count #3860
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3860 +/- ##
=======================================
Coverage 36.11% 36.11%
=======================================
Files 325 325
Lines 9043 9043
Branches 1419 1419
=======================================
Hits 3266 3266
Misses 5634 5634
Partials 143 143 |
Trying the same endpoint on lighthouse after running for about 5 minutes returns count for both connected and disconnected, while for lodestar, the endpoint only returns count for connected and nothing for disconnected or the other status. Still need to see if the current way is the most accurate way of getting the connection info from libp2p. |
Performance Report✔️ no performance regression detected Full benchmark results
|
disconnected++; | ||
break; | ||
default: | ||
connecting++; |
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.
So if we have 1 peer with 20 open connections it will return connected: 20
, is this the expected behavior?
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.
updated to use the most relevant connection for a peer in the counting
…and used that in returning the peer count
Looked into trying to get disconnected peer by making a diff with the peers found in the peerstore and the one returned by the connection manager (reasoning is if it is found in the peerstore but not in the connection manager, then those are disconnected). The issue with that is the peerstore persists across restarts, meaning the result of the diff would keep on increasing. Leaving the implementation for now to use the connection manager for all the counting. Open to other suggestions, if that is not fit enough |
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.
LGTM, I think its fine as is to just use the connection manager.
@@ -51,13 +51,34 @@ export function getNodeApi(opts: IApiOptions, {network, sync}: Pick<ApiModules, | |||
}, | |||
|
|||
async getPeerCount() { | |||
// TODO: Implement | |||
let disconnected = 0; |
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.
So disconnected means all peers that have ever connected to us and are no longer connected? That sounds like a memory leak to track lol. How does Lighthouse track this?
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.
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.
It's persisted to disk that's how it doesn't leak memory. I would leave a // TODO: Implement disconnect count with on-disk persistence
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 assumed it is not being persisted as the values don't persist after each restarts. Will dig later to see how that is implemented...
I would leave a // TODO: Implement disconnect count with on-disk persistence
Ok. Will do.
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.
Will dig later to see how that is implemented...
I would ignore completely, tracking disconnected peers is an extremely unnecessary feature in my opinion haha
Motivation
Implements the endpoint to get the peer count which was not implemented before
Closes #3857
Steps to test or reproduce
curl localhost:9596/eth/v1/node/peer_count
should not return just 0 for all values