Skip to content
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

ETCM-463: Add PeerStatisticsActor to track message counts #849

Merged
merged 33 commits into from
Dec 15, 2020

Conversation

aakoshh
Copy link
Contributor

@aakoshh aakoshh commented Dec 9, 2020

Description

Allow #833 to prioritise which peers to prune by counting the number of messages coming from them in a fixed time window.

Proposed Solution

Adds a TimeSlotStats counter to the PeerManagerActor, which now subscribes to MessageFromPeer events by the event bus and adds 1 to the peer every time we receive a response for a request we sent. Doesn't increment the counter for requests sent by the other side, although that could make sense too, depends on what we consider a valuable connection: one that serves us data, or one that makes its presence known by requesting it.

Some of this can be abused though, like NewBlockHashes, if it sends the same notification repeatedly, or the notifications about non-existing hashes; these conditions should be monitored on a different level and penalised. I'm guessing that would mean another component would have to publish events to the message bus about such faults, which would be a new event type.

The TimeSlotStats can be used with any statistic that can be merged, so we can always extend it to include faults, data size; less obvious would be the response time, at least not with this subscription, but perhaps the PeerActor can send messages to its parent directly instead.

The idea is that we can call peerMessageStats.getAll() when we want to prune and use it to provide an ordering for which peers to prune first: the ones which we haven't pulled any data from in the last 30 minutes for example.

(I added the counter as a var to the actor, seemed like there would be quite some noise if I introduce some kind of state wrapper for all the places context become ... occurs, but let me know if that's preferred).

@aakoshh aakoshh force-pushed the ETCM-463-track-peer-stats branch 2 times, most recently from 06dd621 to a891426 Compare December 9, 2020 21:06
@aakoshh aakoshh force-pushed the ETCM-463-track-peer-stats branch from a891426 to 8637bea Compare December 9, 2020 21:08
@aakoshh aakoshh changed the title ETCM-463: Track message stats in PeerManagerActor ETCM-463: Add PeerStatisticsActor to track message counts Dec 11, 2020
@KonradStaniec
Copy link
Contributor

KonradStaniec commented Dec 11, 2020

@lemastero @biandratti @enriquerodbe as you will taking over project soon, I have added you as a reviewers so you will be aware what is happening here

@aakoshh aakoshh force-pushed the ETCM-463-track-peer-stats branch from d4a6110 to 8876c38 Compare December 11, 2020 17:36
@aakoshh aakoshh force-pushed the ETCM-463-track-peer-stats branch from 0becdfb to 505dda9 Compare December 13, 2020 09:13
@ntallar ntallar removed their request for review December 14, 2020 18:25
@aakoshh aakoshh merged commit e76316d into develop Dec 15, 2020
@aakoshh aakoshh deleted the ETCM-463-track-peer-stats branch December 15, 2020 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants