-
Notifications
You must be signed in to change notification settings - Fork 74
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
feat: Shard DHT #3104
base: v6/develop
Are you sure you want to change the base?
feat: Shard DHT #3104
Conversation
merge v6/develop
There is an alternative solution to this which is to create a new libp2p protocol for peer routing, as we did for content routing (GET protocol) and completely remove the DHT from the network module. This would definetly be a better option as we would have better separation of concerns (netork module and blockchain module completely separate), and would not need to have the routing table in addition to the sharding table. |
Hi @zeroxbt, i'm not sure that i understand need for this. Also we want to allow nodes that don't have stake to perform get on the network (light nodes), are these changes going to affect this?
When searching for the neighbourhood for the publish or get we are only considering nodes that are in sharding table (nodes that have stake). So i don't think that we will have this issue.
You are right for this. But also i think that network module should not be aware of blockchains that node is connected to. They should work independently and network should be in charge of sending and receiving message, and then somewhere on different layer we should do some processing depending on blockchain.
Also this is true and it would be good that we don't do this. Thanks for sending this PR, i will try to reply faster in the future :-) |
Hey @djordjekovac, light nodes still work, as they will be able to find all nodes in the sharding table. What changes is that light nodes are not used to "spread" information about other nodes on the network anymore. For your second question, it is true that we use sharding table for the routing of content ("publish", "get" and "update"). The problem here is that for the routing of peers we still use ("findPeer"), which uses the KadDHT and not the sharding table. This means that the node asks for peers information like IP, protocols etc. to all nodes in the DHT. The main problem, which I am attempting to solve with this PR, is that we should only rely on sharding table nodes for peers information, same as we do for content. For the third comment I completely agree. I left a comment regarding this. There is a way to do peer routing using a new protocol route, so we could remove the DHT completely by exchanging peer information through a new "get" route, which would mean only querying nodes in the sharding table. The only problem with this is that it is not backwards compatible: if we remove DHT from new nodes, nodes on older versions won't be able to find information about nodes on newer versions, and vice versa. |
If this is not clear I can give a practical example: Sharding table nodes for NeuroWeb: [A, B, C] -> Node A joins the network You can see from this example that right now, peer information is exchanged between all nodes on the network, independently from the chosen blockchain or if node is in sharding table or not. This is not great, as we don't really want to trust node H (or any other node that is not present in our sharding table) to give us peer information. I hope it's clearer now |
Description
This PR replaces the libp2p-kad-dht dependency with a modified version, which attempts to simplify the peer discovery mechanism and make it more in line with the sharding table implementation.
The problem
With the current network implementation, peer discovery is done through the
libp2p-kad-dht
module. Every time a node connects to our node, it is added to the routing table and the peer information is added to the peer store. This means that the peer routing table contains nodes that are potentially not in the node's sharding table, because of different blockchain implementations, or just because they don't have the required stake.This is problematic for a number of reasons:
How it is solved
The
libp2p-kad-dht
module was copied and moved to the network module, so that we can make changes to it (i left it as separate package for simplicity, but can be change obviously). All unnecessary functions and dependencies were removed, and the routing table was changed from KBucket list to a simple Map of peer ids with their respective blockchain implementations. The routing table is now updated same way as for the local sharding table, so on NodeAdded and NodeRemoved events.At start, the bootstrap nodes will be added to the Shard DHT, and all nodes from the sharding table will be added to the Shard DHT routing table.
How to review
As this change involved the copying of the whole
libp2p-kad-dht
module there are a lot of new files and it's hard to review on github, so I suggest looking at individual commits after "solving linter errors".Type of change
How Has This Been Tested?
Run nodes in local environment, and ensure they are connecting to each other as expected. All nodes with same blockchain implementation should be able to discover and connect to each other, while nodes with different implementations should not.
Checklist: