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

Fix the dialing priority system #907

Merged
merged 6 commits into from
Feb 1, 2019
Merged

Conversation

tomaka
Copy link
Member

@tomaka tomaka commented Jan 31, 2019

Fixes maybe #883, I'm not sure.

Right now, when we dial a node and receive an incoming connection from that same node, we cancel the outgoing attempt.
The problem is that this outgoing attempt may have already succeeded (and we don't know yet), in which case the remote has maybe cancelled its own connection. The outcome is no connection at all.

There is a dialing priority system in place, but it applied only if we receive a new connection from a node we are already connected to.

This PR does the following:

  • We no longer cancel outgoing attempts when we receiving an incoming connection. However we remove the addresses in the queue.
  • Closing an open connection also cancels the outgoing connection attempt.
  • We can now receive DialError events from nodes we are connected to. In order to clarify this, I changed the remaining_addresses field (indicating the number of addresses in queue) into a new_state field that indicates the state of the peer.

@ghost ghost assigned tomaka Jan 31, 2019
@ghost ghost added the in progress label Jan 31, 2019
@tomaka
Copy link
Member Author

tomaka commented Jan 31, 2019

cc paritytech/substrate#1634

// knowing. It is possible that the remote has already closed its ougoing attempt because
// it sees our outgoing attempt as a success.
// However we cancel any further multiaddress to attempt.
// TODO: cancel if we don't have dial priority? we should write tests first
Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is critical to do this as well; otherwise our dialing attempt will always replace the remote's connection, regardless of whether we have priority.

@tomaka tomaka force-pushed the fix-priority-system branch from dd8e559 to 94ad788 Compare January 31, 2019 15:47
@tomaka tomaka force-pushed the fix-priority-system branch from b769969 to dc406b6 Compare February 1, 2019 13:09
@tomaka
Copy link
Member Author

tomaka commented Feb 1, 2019

The test I added fails on master.

EDIT: Actually no; I'm having a hard time writing a test that fails on master.

@tomaka
Copy link
Member Author

tomaka commented Feb 1, 2019

Oh well, let's merge this.

@tomaka tomaka merged commit f999fd5 into libp2p:master Feb 1, 2019
@ghost ghost removed the in progress label Feb 1, 2019
@tomaka tomaka deleted the fix-priority-system branch February 1, 2019 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants