Installing the devp2p command
cmd/devp2p
is a developer utility and is not included in the Parallax client distribution. You can install this command using go get:
parallaxkey
utility is needed.
Crawling the v4 DHT
Our first step is to compile a list of all reachable nodes. The DHT crawler in cmd/devp2p is a batch process which runs for a set amount of time. You should schedule this command to run at a regular interval. To create a node list, runall-nodes.json
file. Subsequent runs of the same command will revalidate previously discovered node records, add newly-found nodes to the set, and remove nodes which are no longer alive. The quality of the node set improves with each run because the number of revalidations is tracked alongside each node in the set.
Creating sub-lists through filtering
Onceall-nodes.json
has been created and the set contains a sizeable number of nodes, useful sub-sets of nodes can be extracted using the devp2p nodeset filter
command. This command takes a node set file as argument and applies filters given as command-line flags.
To create a filtered node set, first create a new directory to hold the output set. You can use any directory name, though it’s good practice to use the DNS domain name as the name of this directory.
-eth-network
(mainnet
|testnet
) selects a Parallax network.-les-server
selects LES server nodes.-ip <mask>
restricts nodes to the given IP range.-min-age <duration>
restricts the result to nodes which have been live for the given duration.
Creating DNS trees
To turn a node list into a DNS node tree, the list needs to be signed. To do this, a key pair is required. To create the key file in the correct format, thecmd/parallaxkey
utility should be used. Choose a strong password to encrypt the key on disk!
devp2p dns sign
to update the signature of the node list. If the list’s directory name differs from the name it will be published at, specify the DNS name using the -domain
flag. This command will prompt for the key file password and update the tree signature.
mainnet.nodes.example.org/enrtree-info.json
file.
Publishing DNS trees
Now that the tree is signed, it can be published to a DNS provider.cmd/devp2p
currently supports publishing to CloudFlare DNS and Amazon Route53.TXT records can also be exported as a JSON file and published independently.
To publish to CloudFlare, first create an API token in the management console. cmd/devp2p
expects the API token in the CLOUDFLARE_API_TOKEN
environment variable. Now use the following command to upload DNS TXT records via the CloudFlare API:
cmd/devp2p
.
Using DNS trees with the Parallax client
Once a tree is available through a DNS name, the Parallax client can use it with the--discovery.dns
command line flag. Node trees are referenced using the enrtree://
URL scheme. The URL of the tree can be found in the enrtree-info.json
file created by devp2p dns sign
. Pass the URL as an argument to the flag in order to make use of the published tree.