-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
p2p: enable dht based disovery (#4736)
this makes use of "native" libp2p discovery by enabling kad dht, peers exchange (adjusting score) and relay servers. the primary reason is to benefit from hole punching and multiple transports support (quic, webrtc). in general peers will be obtained by one of the following methods: - getting more peers from dht. in order for peer to be added to public dht it needs to have dialable address and advertise it to the neighbors. this is pretty much analogous to our current setup, but it also supports multiple addresses so we can enable quic in next change. as it is udp based it may work on nat/firewall devices where tcp was restricted. - peer exchange (as a part of gossipsub) will advertise peers to other nodes as part of PRUNE message, once other node sees relayed address it will initiate holepunch. if peer is not publicly dialable it will request relay reservation from the bootnodes. once received this reservation will be communicated to bootnode as one of the peer addresses. - additionally we will persist peers in p2p/connected.txt every 30minutes, and try to reconnect with them on startup to decrease load on bootnodes/relays. configuration changes: - `p2p-bootnode` option needs to be set explicitly on bootnodes in order to start dht in server mode, and adjust gossipsub configuration - `p2p-reachability` can be either `public` or `private`. we have to set `public` on bootnodes, otherwise autonat might be confused by out setup, beside that it is only useful for testing. - `p2p-holepunching` will enable relay client and holepunching. enabled by default - `p2p-disable-legacy-discovery` disables our own discovery. it can be run in parallel, but we will have no reason to keep it if all works as expected - `p2p-private-network` disables dht filtering by public address, it is mostly useful for testing - `relay-server` section: - `enable` enable relay server, has to be enabled on bootnodes - `reservations` number of relay reservations, 512 by default - `ttl` reservation ttl, 20 minutes example of the p2p config section: ```json "p2p": { "listen": "/ip4/0.0.0.0/tcp/5000", "p2p-disable-legacy-discovery": true, "relay-server": { "enable": "true" }, "p2p-reachability": "public", "p2p-bootnode": true, } ```
- Loading branch information
Showing
13 changed files
with
791 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.