paritytech / substrate

Substrate: The platform for blockchain innovators
Apache License 2.0
8.39k stars 2.65k forks source link

Make peer evictions less aggressive #14619

Closed altonen closed 1 year ago

altonen commented 1 year ago

The original implementation of peer eviction prioritized aliveness over connection stability which made the peer count unstable for some users.

As this may cause discomfort or infrastructure alerts if stability is tracked, adjust the eviction to be less aggressive by only evicting peers when the node has fully stalled. This causes the node to have some peers who are inactive and won't send any block announcements. These nodes are removed if the local node is able to receive at least one block announcement from one of its peers as the inactivity of the substream is detected when a notification is sent.

If the node won't send or receive any block annoucements for 30 seconds, it's considered stalled and it will evict all peers, causing ProtocolController to accept and establish connections from new peers.

altonen commented 1 year ago

@kpp please take a look

altonen commented 1 year ago

bot rebase

paritytech-processbot[bot] commented 1 year ago

Rebased