github.com/kisexp/xdchain@v0.0.0-20211206025815-490d6b732aa7/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  ### 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  ### Eth Protocol Test Suite
    85  
    86  The Eth Protocol test suite is a conformance test suite for the [eth protocol][eth].
    87  
    88  To run the eth protocol test suite against your implementation, the node needs to be initialized as such:
    89  
    90  1. initialize the geth node with the `genesis.json` file contained in the `testdata` directory
    91  2. import the `halfchain.rlp` file in the `testdata` directory
    92  3. run geth with the following flags:
    93  ```
    94  geth --datadir <datadir> --nodiscover --nat=none --networkid 19763 --verbosity 5
    95  ```
    96  
    97  Then, run the following command, replacing `<enode ID>` with the enode of the geth node: 
    98   ```
    99   devp2p rlpx eth-test <enode ID> cmd/devp2p/internal/ethtest/testdata/fullchain.rlp cmd/devp2p/internal/ethtest/testdata/genesis.json
   100  ```
   101   
   102  [eth]: https://github.com/ethereum/devp2p/blob/master/caps/eth.md
   103  [dns-tutorial]: https://geth.ethereum.org/docs/developers/dns-discovery-setup
   104  [discv4]: https://github.com/ethereum/devp2p/tree/master/discv4.md
   105  [discv5]: https://github.com/ethereum/devp2p/tree/master/discv5/discv5.md