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

Routed hosts should search for new addresses if the available adresses do not work issue#351 #366

Closed
wants to merge 3 commits into from

Conversation

jmintb
Copy link

@jmintb jmintb commented Jun 24, 2018

Currently if a routed host attempts a connection, it would only search for new addresses if no addresses were present in the peerinfo for that peer.
This means that if the connection using the known addresses failed, there was no attempt to search for new addresses so that the connection might succeed.

This pr alters the Connect function for the routed host, so it searches for new addresses if it cannot connect using the known addresses. If new addresses are found, it attempts to connect using these.

I have also implemented a test that covers this case. It uses a mock test router which keeps peerinfo in a map and implements the Routing interface. Using the mock router makes it easy to manipulate the available peerinfo and avoids depending on an actual routing package.

This test case covers issue libp2p#351, which covers the routed
host searching for new addresses if the current addresses
for a peer do not work when connecting.

The test uses a mock testrouter which implements the routing
interface. This makes it easy to manipulate which addresses
are available through the router and also makes the test
self contained, meaning it isn't dependent on an external
router.
If there were addresses available for a given peer,
and they did not work, an err would be returned.
This doesn't make sense as there should be an attempt
to find new addresses through the router before determining
that a connection cannot be made.

Now the router is searched if a connection with the current
addresses cannot be made. If the router had already been
searched(This happens if no addresses were present in the peerinfo)
then we do not search repeat the search as it doesn't to
search the router twice within such a short timespan.
Tests that a routed host will use the router to search
for addresses if no known addresses were present in the
peerinfo supplied in the Connect function or in the routed
host's own peerstore.
@Stebalien
Copy link
Member

I'm not sure if this will work:

  1. Due to our backoff logic in go-libp2p-swarm, I'm kind of surprised the tests work. If we fail a dial, we should refuse to dial for a period of time.
  2. It has to retry all the old addresses.

Before we can fix this, we may need to fix #1554. That way, we can backoff on a per-multiaddr basis.

@jmintb
Copy link
Author

jmintb commented Jun 25, 2018

In that case should I leave this until #1554 is fixed?
Edit:
go-libp2p-swarm isn't used when creating the hosts, so that is probably why the tests pass.

@Stebalien
Copy link
Member

libp2p.New uses go-libp2p-swarm under the hood. I'll have to look at those tests in depth to figure out what's going on.

@jmintb jmintb closed this Dec 28, 2023
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