Files
lighthouse/beacon_node/lighthouse_network/src
Akihito Nakano a6d2ed6119 Fix: PeerManager doesn't remove "outbound only" peers which should be pruned (#3236)
## Issue Addressed

This is one step to address https://github.com/sigp/lighthouse/issues/3092 before introducing `quickcheck`.

I noticed an issue while I was reading the pruning implementation `PeerManager::prune_excess_peers()`. If a peer with the following condition, **`outbound_peers_pruned` counter increases but the peer is not pushed to `peers_to_prune`**.

- [outbound only](https://github.com/sigp/lighthouse/blob/1e4ac8a4b9dec645af23af811475b4e4c95c69ee/beacon_node/lighthouse_network/src/peer_manager/mod.rs#L1018)
- [min_subnet_count <= MIN_SYNC_COMMITTEE_PEERS](https://github.com/sigp/lighthouse/blob/1e4ac8a4b9dec645af23af811475b4e4c95c69ee/beacon_node/lighthouse_network/src/peer_manager/mod.rs#L1047)

As a result, PeerManager doesn't remove "outbound" peers which should be pruned.

Note: [`subnet_to_peer`](https://github.com/sigp/lighthouse/blob/e0d673ea86ac0f6dab3ddd92b0de06ce5eacf8c0/beacon_node/lighthouse_network/src/peer_manager/mod.rs#L999) (HashMap) doesn't guarantee a particular order of iteration. So whether the test fails depend on the order of iteration.
2022-06-06 05:51:10 +00:00
..