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

Refactor discovery, improve Hello handling/peer management #975

Merged
merged 11 commits into from
Feb 1, 2021

Conversation

austinabell
Copy link
Contributor

@austinabell austinabell commented Jan 30, 2021

Summary of changes
Changes introduced in this pull request:

  • Refactors discovery into it's own behaviour and improves interactions

    • Sends random kad queries when under the discovery limit (default 50) to ensure quick bootstrapping and maintaining peers if ever drops below (but opposite issue is more common, of having too many peers)
    • Disable mdns by default. Better to not have the overhead by default, Lotus removed it altogether
    • Improve peer connect and disconnect events
  • Handle hello responses as well as correctly logging failure and marking peers as bad on libp2p errors such as unsupported protocols or dial failures

    • Change peer manager api to allow for removing but not marking bad (on peer disconnect, to allow them to be reconnected)
    • On request success or failure, insert a peer in the set if doesn't exist. Before it was relying on the fact that an empty peer was added on inbound hello request, but this handled the case when we send the first request poorly

How the hello responses are handled is when a hello request is sent, a boxed future is returned. This future is added to a FuturesUnordered and polled in the chain syncer.

Reference issue to close (if applicable)

Closes #966

Other information and links

Output = (
PeerId,
SystemTime,
Option<Result<HelloResponse, RequestResponseError>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I normally really like rustfmt... This is one of the rare cases lol

@austinabell austinabell merged commit d0a46ba into main Feb 1, 2021
@austinabell austinabell deleted the austin/discovery branch February 1, 2021 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle Libp2p Disconnects
2 participants