github.com/theQRL/go-zond@v0.2.1/cmd/devp2p/README.md (about)

     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  ### Node Set Utilities
    34  
    35  There are several commands for working with JSON node set files. These files are generated
    36  by the discovery crawlers and DNS client commands. Node sets also used as the input of the
    37  DNS deployer commands.
    38  
    39  Run `devp2p nodeset info <nodes.json>` to display statistics of a node set.
    40  
    41  Run `devp2p nodeset filter <nodes.json> <filter flags...>` to write a new, filtered node
    42  set to standard output. The following filters are supported:
    43  
    44  - `-limit <N>` limits the output set to N entries, taking the top N nodes by score
    45  - `-ip <CIDR>` filters nodes by IP subnet
    46  - `-min-age <duration>` filters nodes by 'first seen' time
    47  - `-eth-network <mainnet/goerli/sepolia/holesky>` filters nodes by "eth" ENR entry
    48  - `-snap` filters nodes by snap protocol support
    49  
    50  For example, given a node set in `nodes.json`, you could create a filtered set containing
    51  up to 20 eth mainnet nodes which also support snap sync using this command:
    52  
    53      devp2p nodeset filter nodes.json -eth-network mainnet -snap -limit 20
    54  
    55  ### Discovery v4 Utilities
    56  
    57  The `devp2p discv4 ...` command family deals with the [Node Discovery v4][discv4]
    58  protocol.
    59  
    60  Run `devp2p discv4 ping <enode/ENR>` to ping a node.
    61  
    62  Run `devp2p discv4 resolve <enode/ENR>` to find the most recent node record of a node in
    63  the DHT.
    64  
    65  Run `devp2p discv4 crawl <nodes.json path>` to create or update a JSON node set.
    66  
    67  ### Discovery v5 Utilities
    68  
    69  The `devp2p discv5 ...` command family deals with the [Node Discovery v5][discv5]
    70  protocol. This protocol is currently under active development.
    71  
    72  Run `devp2p discv5 ping <ENR>` to ping a node.
    73  
    74  Run `devp2p discv5 resolve <ENR>` to find the most recent node record of a node in
    75  the discv5 DHT.
    76  
    77  Run `devp2p discv5 listen` to run a Discovery v5 node.
    78  
    79  Run `devp2p discv5 crawl <nodes.json path>` to create or update a JSON node set containing
    80  discv5 nodes.
    81  
    82  ### Discovery Test Suites
    83  
    84  The devp2p command also contains interactive test suites for Discovery v4 and Discovery
    85  v5.
    86  
    87  To run these tests against your implementation, you need to set up a networking
    88  environment where two separate UDP listening addresses are available on the same machine.
    89  The two listening addresses must also be routed such that they are able to reach the node
    90  you want to test.
    91  
    92  For example, if you want to run the test on your local host, and the node under test is
    93  also on the local host, you need to assign two IP addresses (or a larger range) to your
    94  loopback interface. On macOS, this can be done by executing the following command:
    95  
    96      sudo ifconfig lo0 add 127.0.0.2
    97  
    98  You can now run either test suite as follows: Start the node under test first, ensuring
    99  that it won't talk to the Internet (i.e. disable bootstrapping). An easy way to prevent
   100  unintended connections to the global DHT is listening on `127.0.0.1`.
   101  
   102  Now get the ENR of your node and store it in the `NODE` environment variable.
   103  
   104  Start the test by running `devp2p discv5 test -listen1 127.0.0.1 -listen2 127.0.0.2 $NODE`.
   105  
   106  ### Eth Protocol Test Suite
   107  
   108  The Eth Protocol test suite is a conformance test suite for the [eth protocol][eth].
   109  
   110  To run the eth protocol test suite against your implementation, the node needs to be initialized as such:
   111  
   112  1. initialize the geth node with the `genesis.json` file contained in the `testdata` directory
   113  2. import the `halfchain.rlp` file in the `testdata` directory
   114  3. run geth with the following flags:
   115  ```
   116  geth --datadir <datadir> --nodiscover --nat=none --networkid 19763 --verbosity 5
   117  ```
   118  
   119  Then, run the following command, replacing `<enode>` with the enode of the geth node:
   120   ```
   121   devp2p rlpx eth-test <enode> cmd/devp2p/internal/ethtest/testdata/chain.rlp cmd/devp2p/internal/ethtest/testdata/genesis.json
   122  ```
   123  
   124  Repeat the above process (re-initialising the node) in order to run the Eth Protocol test suite again.
   125  
   126  #### Eth66 Test Suite
   127  
   128  The Eth66 test suite is also a conformance test suite for the eth 66 protocol version specifically.
   129  To run the eth66 protocol test suite, initialize a geth node as described above and run the following command,
   130  replacing `<enode>` with the enode of the geth node:
   131  
   132   ```
   133   devp2p rlpx eth66-test <enode> cmd/devp2p/internal/ethtest/testdata/chain.rlp cmd/devp2p/internal/ethtest/testdata/genesis.json
   134  ```
   135  
   136  [eth]: https://github.com/ethereum/devp2p/blob/master/caps/eth.md
   137  [dns-tutorial]: https://geth.ethereum.org/docs/developers/geth-developer/dns-discovery-setup
   138  [discv4]: https://github.com/ethereum/devp2p/tree/master/discv4.md
   139  [discv5]: https://github.com/ethereum/devp2p/tree/master/discv5/discv5.md