From be92a68d4c8524bb375d96269ae5df3a3a47995c Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Tue, 16 Feb 2021 11:44:03 +0100 Subject: [PATCH] Update discv5.md Update some documentation in the discv5 docs. --- doc/discv5.md | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/doc/discv5.md b/doc/discv5.md index 4e65bf9..401f67d 100644 --- a/doc/discv5.md +++ b/doc/discv5.md @@ -1,18 +1,15 @@ -# Discovery v5 +# Node Discovery Protocol v5 ## Introduction -This `eth/p2p/discoveryv5` directory holds a Nim implementation of the -discovery v5 protocol specified -[here](https://github.com/ethereum/devp2p/blob/master/discv5/discv5.md). +The `eth/p2p/discoveryv5` directory holds a Nim implementation of the +[Node Discovery Protocol v5.1](https://github.com/ethereum/devp2p/blob/master/discv5/discv5.md). -This specification is still in DRAFT and thus subject to change. In fact, it is -likely that the current packet format will change, see -https://github.com/ethereum/devp2p/issues/152. +The implemented specification is Protocol version v5.1. -This implementation does not support "Topic Advertisement" yet. +This implementation does not support "Topic Advertisement" yet as this part of +the specification is not complete. The implementation relies on other modules in the `eth` package, namely: `keys`, -`rlp`, `async_utils` and `trie/db`. The latter is likely to change, see -https://github.com/status-im/nim-eth/issues/242 +`rlp` and `async_utils`. ## How to use @@ -21,8 +18,7 @@ let rng = keys.newRng privKey = PrivateKey.random(rng[]) (ip, tcpPort, udpPort) = setupNat(config) # Or fill in external IP/ports manually - ddb = DiscoveryDB.init(newMemoryDB()) - d = newProtocol(privKey, ddb, ip, tcpPort, udpPort, rng = rng) + d = newProtocol(privKey, ip, tcpPort, udpPort, rng = rng) d.open() # Start listening ``` @@ -35,7 +31,7 @@ other nodes in the network. To initialize with a bootnode or a set of bootnodes, the ENRs need to be passed as parameter in `newProtocol`. ```Nim -d = newProtocol(privKey, ddb, ip, tcpPort, udpPort, +d = newProtocol(privKey, ip, tcpPort, udpPort, bootstrapRecords = bootnodes) d.open() # Start listening and add bootstrap nodes to the routing table. ``` @@ -60,8 +56,6 @@ or `lookup` calls for this. `randomNodes` can also be used to find nodes, but this will only look into the current routing table and not actively search for nodes on the network. - - Or, one can decide not to run `d.start()` and do this manually within its application by using the available calls: - `query`, `queryRandom` or `lookup` for discovering more peers. @@ -104,14 +98,11 @@ nim c -d:chronicles_log_level:trace -d:release --threads:on eth/p2p/discoveryv5/ ``` ### Metrics -Metrics are available for `routing_table_nodes`, which holds the amount of nodes -in the routing table. - To compile in an HTTP endpoint for accessing the metrics add the `insecure` compile time flag: ```sh # Build dcli with metrics -nim c -d:insecure -d:chronicles_log_level:trace -d:release eth/p2p/discoveryv5/dcli +nim c -d:insecure -d:chronicles_log_level:trace -d:release --threads:on eth/p2p/discoveryv5/dcli # Run dcli with metrics ./eth/p2p/discoveryv5/dcli --metrics --bootnode:enr: ```