|  | 
|  | 1 | +# The devp2p command | 
|  | 2 | + | 
|  | 3 | +The devp2p command line tool is a utility for low-level peer-to-peer debugging and | 
|  | 4 | +protocol development purposes. It can do many things. | 
|  | 5 | + | 
|  | 6 | +### ENR Decoding | 
|  | 7 | + | 
|  | 8 | +Use `devp2p enrdump <base64>` to verify and display an Ethereum Node Record. | 
|  | 9 | + | 
|  | 10 | +### Node Key Management | 
|  | 11 | + | 
|  | 12 | +The `devp2p key ...` command family deals with node key files. | 
|  | 13 | + | 
|  | 14 | +Run `devp2p key generate mynode.key` to create a new node key in the `mynode.key` file. | 
|  | 15 | + | 
|  | 16 | +Run `devp2p key to-enode mynode.key -ip 127.0.0.1 -tcp 30303` to create an enode:// URL | 
|  | 17 | +corresponding to the given node key and address information. | 
|  | 18 | + | 
|  | 19 | +### Maintaining DNS Discovery Node Lists | 
|  | 20 | + | 
|  | 21 | +The devp2p command can create and publish DNS discovery node lists. | 
|  | 22 | + | 
|  | 23 | +Run `devp2p dns sign <directory>` to update the signature of a DNS discovery tree. | 
|  | 24 | + | 
|  | 25 | +Run `devp2p dns sync <enrtree-URL>` to download a complete DNS discovery tree. | 
|  | 26 | + | 
|  | 27 | +Run `devp2p dns to-cloudflare <directory>` to publish a tree to CloudFlare DNS. | 
|  | 28 | + | 
|  | 29 | +Run `devp2p dns to-route53 <directory>` to publish a tree to Amazon Route53. | 
|  | 30 | + | 
|  | 31 | +You can find more information about these commands in the [DNS Discovery Setup Guide][dns-tutorial]. | 
|  | 32 | + | 
|  | 33 | +### Discovery v4 Utilities | 
|  | 34 | + | 
|  | 35 | +The `devp2p discv4 ...` command family deals with the [Node Discovery v4][discv4] | 
|  | 36 | +protocol. | 
|  | 37 | + | 
|  | 38 | +Run `devp2p discv4 ping <enode/ENR>` to ping a node. | 
|  | 39 | + | 
|  | 40 | +Run `devp2p discv4 resolve <enode/ENR>` to find the most recent node record of a node in | 
|  | 41 | +the DHT. | 
|  | 42 | + | 
|  | 43 | +Run `devp2p discv4 crawl <nodes.json path>` to create or update a JSON node set. | 
|  | 44 | + | 
|  | 45 | +### Discovery v5 Utilities | 
|  | 46 | + | 
|  | 47 | +The `devp2p discv5 ...` command family deals with the [Node Discovery v5][discv5] | 
|  | 48 | +protocol. This protocol is currently under active development. | 
|  | 49 | + | 
|  | 50 | +Run `devp2p discv5 ping <ENR>` to ping a node. | 
|  | 51 | + | 
|  | 52 | +Run `devp2p discv5 resolve <ENR>` to find the most recent node record of a node in | 
|  | 53 | +the discv5 DHT. | 
|  | 54 | + | 
|  | 55 | +Run `devp2p discv5 listen` to run a Discovery v5 node. | 
|  | 56 | + | 
|  | 57 | +Run `devp2p discv5 crawl <nodes.json path>` to create or update a JSON node set containing | 
|  | 58 | +discv5 nodes. | 
|  | 59 | + | 
|  | 60 | +### Discovery Test Suites | 
|  | 61 | + | 
|  | 62 | +The devp2p command also contains interactive test suites for Discovery v4 and Discovery | 
|  | 63 | +v5. | 
|  | 64 | + | 
|  | 65 | +To run these tests against your implementation, you need to set up a networking | 
|  | 66 | +environment where two separate UDP listening addresses are available on the same machine. | 
|  | 67 | +The two listening addresses must also be routed such that they are able to reach the node | 
|  | 68 | +you want to test. | 
|  | 69 | + | 
|  | 70 | +For example, if you want to run the test on your local host, and the node under test is | 
|  | 71 | +also on the local host, you need to assign two IP addresses (or a larger range) to your | 
|  | 72 | +loopback interface. On macOS, this can be done by executing the following command: | 
|  | 73 | + | 
|  | 74 | +    sudo ifconfig lo0 add 127.0.0.2 | 
|  | 75 | + | 
|  | 76 | +You can now run either test suite as follows: Start the node under test first, ensuring | 
|  | 77 | +that it won't talk to the Internet (i.e. disable bootstrapping). An easy way to prevent | 
|  | 78 | +unintended connections to the global DHT is listening on `127.0.0.1`. | 
|  | 79 | + | 
|  | 80 | +Now get the ENR of your node and store it in the `NODE` environment variable. | 
|  | 81 | + | 
|  | 82 | +Start the test by running `devp2p discv5 test -listen1 127.0.0.1 -listen2 127.0.0.2 $NODE`. | 
|  | 83 | + | 
|  | 84 | +[dns-tutorial]: https://geth.ethereum.org/docs/developers/dns-discovery-setup | 
|  | 85 | +[discv4]: https://github.com/ethereum/devp2p/tree/master/discv4.md | 
|  | 86 | +[discv5]: https://github.com/ethereum/devp2p/tree/master/discv5/discv5.md | 
0 commit comments