Improve peer handling (#1796)

## Issue Addressed

Potentially resolves #1647 and sync stalls. 

## Proposed Changes

The handling of the state of banned peers was inadequate for the complex peerdb data structure. We store a limited number of disconnected and banned peers in the db. We were not tracking intermediate "disconnecting" states and the in some circumstances we were updating the peer state without informing the peerdb. This lead to a number of inconsistencies in the peer state. 

Further, the peer manager could ban a peer changing a peer's state from being connected to banned. In this circumstance, if the peer then disconnected, we didn't inform the application layer, which lead to applications like sync not being informed of a peers disconnection. This could lead to sync stalling and having to require a lighthouse restart. 

Improved handling for peer states and interactions with the peerdb is made in this PR.
This commit is contained in:
Age Manning
2020-10-23 01:27:48 +00:00
parent 4298efeb23
commit 66f0cf4430
7 changed files with 581 additions and 362 deletions

View File

@@ -1259,7 +1259,7 @@ pub fn serve<T: BeaconChainTypes>(
&dir,
),
state: api_types::PeerState::from_peer_connection_status(
&peer_info.connection_status,
&peer_info.connection_status(),
),
}));
}
@@ -1301,7 +1301,7 @@ pub fn serve<T: BeaconChainTypes>(
&dir,
),
state: api_types::PeerState::from_peer_connection_status(
&peer_info.connection_status,
&peer_info.connection_status(),
),
});
}