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 go-kademlia to remove dependency on go-libp2p. #61

Closed
iand opened this issue Jul 11, 2023 · 6 comments
Closed

Refactor go-kademlia to remove dependency on go-libp2p. #61

iand opened this issue Jul 11, 2023 · 6 comments
Labels
kind/enhancement New feature or request

Comments

@iand
Copy link
Contributor

iand commented Jul 11, 2023

ETA: 2023-08-18

Description: go-kademlia should not depend on go-libp2p but should be compatible with it. All libp2p functionality should move to go-libp2p-kad-dht version 2 (see libp2p/go-libp2p-kad-dht#855)

@guillaumemichel
Copy link
Contributor

I have a mixed feelings about this.

On the one hand, if go-kademlia (to be renamed) is to be a tool box to build DHTs it can contain standard networking transports that could be used to build any DHT. I think that go-kademlia should define what a transport endpoint is, and ideally provide a few generic endpoint implementations (e.g libp2p, QUIC, TCP, UDP). This would allow go-kademlia users to build their DHTs without having to reimplement a libp2p or TCP endpoint themselves, or depend on go-libp2p-kad-dht which is a full DHT implementation.

However, on the other hand, I agree that go-kademlia should be a tool box to build DHTs, and hence shouldn't depend on libp2p, it is libp2p that has to depend on go-kademlia because it is using it to implement the go-libp2p-kad-dht. Also, if the libp2p endpoint contains go-libp2p-kad-dht specific enhancements (e.g backpressure), it wouldn't be considered to be generic enough to remain in go-kademlia.

I think that having a dependency on go-libp2p (not go-libp2p-kad-dht) should be seen like a dependency on TCP or UDP. So for me the question should be: do we want to give go-kademlia generic transport endpoints that they can already use in their DHT implementation, or should they build their transport endpoint themselves?

@Wondertan
Copy link

libp2p already abstracts over any known transport. There is not so much value in adding another layer of indirection to avoid depending on it, as user can choose whatever transport on the libp2p level.

@guillaumemichel
Copy link
Contributor

This is not what I am saying.

This repository shouldn't solely depend on libp2p as a transport. It should be possible to build a DHT with go-kademlia using standard networking libraries as well (e.g net package).

@iand
Copy link
Contributor Author

iand commented Aug 11, 2023

go-kademlia should definitely support more than libp2p by abstracting the transports, addressing and node identification (the last two are already abstracted)

I think the libp2p implementation of those types should live in go-libp2p-kad-dht. If you are in the libp2p world then you should be using go-libp2p-kad-dht. If you are building a custom DHT that uses, for example, the Ethereum p2p stack then that should also be possible to do cleanly.

@guillaumemichel
Copy link
Contributor

OK, but in this case, I am in favor of having a clean module e.g go-libp2p-kad-dht/net that could be easily imported in different projects. We need to make it clear that go-kademlia + go-libp2p != go-libp2p-kad-dht.

For instance, if I want to create a DHT for my custom app, that would be using libp2p as transport, but I don't want provider records nor IPNS, I should be able to easily find and import go-libp2p-kad-dht/net only and not the rest of the go-libp2p-kad-dht repo that is not relevant for my project. The libp2p endpoint is useful beyond just the go-libp2p-kad-dht implementation.

I am slightly concerned that it becomes too complex to build a basic DHT using the building blocks that are available at go-kademlia if there are no implementations of endpoint. We shouldn't expect from developers that they build they own transport endpoint when exploring the repo. As an alternative, we could write a simple TCP endpoint using the net package and have the libp2p endpoint in the go-libp2p-kad-dht repo.

I think that transport endpoints that are generic enough to be used in multiple DHT implementations (e.g TCP, UDP, QUIC, libp2p, eth p2p, etc.) could be part of go-kademlia (or at least 1 should to serve as example).

@iand
Copy link
Contributor Author

iand commented Oct 2, 2023

Superceded by migration of core types to go-libdht

@iand iand closed this as completed Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

3 participants