lighthouse/beacon_node
Kevin Lu 320a683e72 Minimum Outbound-Only Peers Requirement (#2356)
## Issue Addressed

#2325 

## Proposed Changes

This pull request changes the behavior of the Peer Manager by including a minimum outbound-only peers requirement. The peer manager will continue querying for peers if this outbound-only target number hasn't been met. Additionally, when peers are being removed, an outbound-only peer will not be disconnected if doing so brings us below the minimum. 

## Additional Info

Unit test for heartbeat function tests that disconnection behavior is correct. Continual querying for peers if outbound-only hasn't been met is not directly tested, but indirectly through unit testing of the helper function that counts the number of outbound-only peers.

EDIT: Am concerned about the behavior of ```update_peer_scores```. If we have connected to a peer with a score below the disconnection threshold (-20), then its connection status will remain connected, while its score state will change to disconnected. 

```rust
let previous_state = info.score_state();            
// Update scores            
info.score_update();
Self::handle_score_transitions(                
               previous_state,
                peer_id,
                info, 
               &mut to_ban_peers,
               &mut to_unban_peers,
               &mut self.events,
               &self.log,
);
```

```previous_state``` will be set to Disconnected, and then because ```handle_score_transitions``` only changes connection status for a peer if the state changed, the peer remains connected. Then in the heartbeat code, because we only disconnect healthy peers if we have too many peers, these peers don't get disconnected. I'm not sure realistically how often this scenario would occur, but it might be better to adjust the logic to account for scenarios where the score state implies a connection status different from the current connection status. 

Co-authored-by: Kevin Lu <kevlu93@gmail.com>
2021-05-31 04:18:19 +00:00
..
beacon_chain Enable Compatibility with Windows (#2333) 2021-05-19 23:05:16 +00:00
client Monitoring service api (#2251) 2021-05-26 05:58:41 +00:00
eth1 Reduce outbound requests to eth1 endpoints (#2340) 2021-05-31 04:18:18 +00:00
eth2_libp2p Minimum Outbound-Only Peers Requirement (#2356) 2021-05-31 04:18:19 +00:00
genesis Add SensitiveUrl to redact user secrets from endpoints (#2326) 2021-05-04 01:59:51 +00:00
http_api Network protocol upgrades (#2345) 2021-05-28 22:02:10 +00:00
http_metrics Tune GNU malloc (#2299) 2021-05-28 05:59:45 +00:00
network Network protocol upgrades (#2345) 2021-05-28 22:02:10 +00:00
operation_pool Pack attestations into blocks in parallel (#2307) 2021-04-13 05:27:42 +00:00
src Tune GNU malloc (#2299) 2021-05-28 05:59:45 +00:00
store Monitoring service api (#2251) 2021-05-26 05:58:41 +00:00
tests Update to tokio 1.1 (#2172) 2021-02-10 23:29:49 +00:00
timer Update to tokio 1.1 (#2172) 2021-02-10 23:29:49 +00:00
websocket_server Server sent events (#1920) 2020-12-04 00:18:58 +00:00
Cargo.toml Monitoring service api (#2251) 2021-05-26 05:58:41 +00:00