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

DHTClient mode breaks peer routing #161

Closed
Stebalien opened this issue Jun 12, 2018 · 10 comments · Fixed by #166
Closed

DHTClient mode breaks peer routing #161

Stebalien opened this issue Jun 12, 2018 · 10 comments · Fixed by #166
Assignees
Labels
kind/bug A bug in existing code (including security flaws)

Comments

@Stebalien
Copy link
Member

In order for peer routing to work, the peer being found needs to be in someone's routing table. That doesn't happen (for obvious reasons) when the peer is running the DHT in client-only mode.

We need a way to say "I'm actually looking for info on this peer, they don't need to be a server".

@Stebalien Stebalien added the kind/bug A bug in existing code (including security flaws) label Jun 12, 2018
@Stebalien
Copy link
Member Author

@whyrusleeping ^^ does this sound right?

@Stebalien
Copy link
Member Author

Note: this sort of works currently because, while the peer won't get added to the routing table on connect, they will when they make a request.

Of course, that's also a bug #162

@whyrusleeping
Copy link
Contributor

@Stebalien great catch. I knew something felt a little off about client mode.

In handleFindPeer we should check if the target peer is in our peerstore, and if so, add it to the output.

@Stebalien
Copy link
Member Author

In handleFindPeer we should check if the target peer is in our peerstore, and if so, add it to the output.

Unfortunately, we'll probably end up with outdated peer info if we did that. To fully fix this, we'd probably want FindPeer to actually try connecting to the peer in question before ending the search.

Alternatively, (additionally?) we could add an extra field to the peer info records indicating age. A missing age field would mean "currently connected".

@whyrusleeping
Copy link
Contributor

@Stebalien hrm... i guess we could add a connectedness check before looking in the peerstore, which should solve that issue

@Stebalien
Copy link
Member Author

i guess we could add a connectedness check before looking in the peerstore, which should solve that issue

Maybe? I'm worried that these peers will have no weight in the connection manager so the DHT server will just disconnect them. We could just weight the N (20?) closest peers highly in the connection manager. Actually, that's not a bad idea.

However, there's annother issue. It turns out we use the FIND_NODE request for GetClosestPeers. This will cause us to try to put values to DHT nodes in client-only mode.

Speaking of which... we already have that problem. I doubt there are many DHT client-only nodes, but they're probably contributing to our DHT problems.


I think we really do need a "is DHT server" bit.

@whyrusleeping
Copy link
Contributor

I think we really do need a "is DHT server" bit.

We have that. Check the peerstore for a peers supported protocols. If they support the DHT protocols, they are a 'server'.

@Stebalien
Copy link
Member Author

We have that. Check the peerstore for a peers supported protocols. If they support the DHT protocols, they are a 'server'.

Once you actually connect to the node. However, they'll still count towards the closest neighbors and you'll still have to connect to the node to find this out.

@whyrusleeping
Copy link
Contributor

but you only get them in your closest peers if they are in someones routing table, and they only get in someones routing table if that someone connects to them, and if someone connects to them, they can check if they are a server before adding them to their routing table, no?

@Stebalien
Copy link
Member Author

Ah, I misunderstood:

In handleFindPeer we should check if the target peer is in our peerstore, and if so, add it to the output.

That means just add the target, not the all nearest peers found in the peerstore. Got it.

Stebalien added a commit that referenced this issue Jun 15, 2018
This way, users who are actually trying to find a peer (not just nodes near a
key in the DHT) can find that peer, even if they aren't a DHT server and/or
aren't in anyone's routing table.

fixes #161
Stebalien added a commit that referenced this issue Jun 15, 2018
This way, users who are actually trying to find a peer (not just nodes near a
key in the DHT) can find that peer, even if they aren't a DHT server and/or
aren't in anyone's routing table.

fixes #161
@ghost ghost assigned Stebalien Jun 15, 2018
@ghost ghost added the status/in-progress In progress label Jun 15, 2018
@ghost ghost removed the status/in-progress In progress label Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants