nknorg / nkn

Official Go implementation of NKN full node.
https://www.nkn.org
Apache License 2.0
473 stars 158 forks source link

Chrod vs Kademlia #173

Closed drasko closed 6 years ago

drasko commented 6 years ago

I have noticed that NKN uses Chord DHT.

What is the reason using Chord over Kademlia, when Kademlia has much simpler (and less error prone) implementation?

yilunzhang commented 6 years ago

Kad DHT is definitely more popular in industry, and its routing could be more efficient. However, as a public chain, it is very important for the choice of neighbors and route to be verifiable.

Chord DHT, despite having more complex protocol, has the unique advantage that the choice of neighbors and route is deterministic given all nodes address on the ring. Both are verifiable to any other nodes.

However, in Kad DHT, each node is supposed to choose neighbors that have specific address prefix and are most recently seen, which is not verifiable to other nodes. Thus, a node effectively has freedom to choose its neighbors in each bucket as long as the prefix are the same, and it's very hard to prevent a node in a malicious party from choosing other nodes in the party as neighbors or next hop in route. By doing so, the malicious party can gain unfair economic rewards, and can even control the election of mining nodes. This is not a problem in other (non-incentive) distributed systems, but is a disaster in (public) blockchain.

drasko commented 6 years ago

@yilunzhang thanks a lot for this very detailed answer!

I propose that we add this to the official documentation and wiki, as the reason for not using Kademlia (simpler implementation - less bugs) should be argumented in front of technical crowd.

yilunzhang commented 6 years ago

That's a good idea. I added it to the tech design doc (in wiki): https://github.com/nknorg/nkn/wiki/Tech-Design-Doc:-Distributed-Data-Transmission-Network-(DDTN)