diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 172042d..e81a331 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -239,7 +239,7 @@ jobs: export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib" nim --version nimble --version - nimble install -y --depsOnly + nimble install -y nimble test nimble build_dcli nimble build_fuzzers diff --git a/eth.nimble b/eth.nimble index 1223cb7..6121262 100644 --- a/eth.nimble +++ b/eth.nimble @@ -106,7 +106,7 @@ task test_discv5_full, "Run discovery v5 and its dependencies tests": test_discv5_task() task build_dcli, "Build dcli": - buildBinary("eth/p2p/discoveryv5/dcli") + buildBinary("tools/dcli") import os, strutils diff --git a/eth/p2p/discoveryv5/dcli.nim b/tools/dcli.nim similarity index 97% rename from eth/p2p/discoveryv5/dcli.nim rename to tools/dcli.nim index 62d0cdc..e85b44e 100644 --- a/eth/p2p/discoveryv5/dcli.nim +++ b/tools/dcli.nim @@ -2,9 +2,9 @@ import std/[options, strutils, tables, sets], confutils, confutils/std/net, chronicles, chronicles/topics_registry, chronos, metrics, metrics/chronos_httpserver, stew/byteutils, stew/bitops2, - ../../keys, ../../net/nat, - "."/[enr, node], - "."/protocol as discv5_protocol + ./eth/keys, ./eth/net/nat, + ./eth/p2p/discoveryv5/[enr, node], + ./eth/p2p/discoveryv5/protocol as discv5_protocol type DiscoveryCmd* = enum @@ -145,34 +145,34 @@ proc discover(d: discv5_protocol.Protocol, psFile: string) {.async.} = let ps = open(psFile, fmWrite) defer: ps.close() ps.write("pubkey,node_id,fork_digest,ip:port,attnets,attnets_number\n") - + while true: let iTime = now(chronos.Moment) let discovered = await d.queryRandom() let qDuration = now(chronos.Moment) - iTime info "Lookup finished", query_time = qDuration.secs, new_nodes = discovered.len, tot_peers=len(ethNodes) - + for dNode in discovered: - let eth2 = dNode.record.tryGet("eth2", seq[byte]) + let eth2 = dNode.record.tryGet("eth2", seq[byte]) let pubkey = dNode.record.tryGet("secp256k1", seq[byte]) let attnets = dNode.record.tryGet("attnets", seq[byte]) if eth2.isNone or attnets.isNone or pubkey.isNone: continue if pubkey.get() in ethNodes: continue ethNodes.incl(pubkey.get()) - + let forkDigest = eth2.get() var bits = 0 for byt in attnets.get(): - bits.inc(countOnes(byt.uint)) + bits.inc(countOnes(byt.uint)) let str = "$#,$#,$#,$#,$#,$#\n" let newLine = str % [pubkey.get().toHex, dNode.id.toHex, forkDigest[0..3].toHex, $dNode.address.get(), attnets.get().toHex, $bits] ps.write(newLine) await sleepAsync(1000) # 1 sec of delay - + proc run(config: DiscoveryConf) = let diff --git a/eth/p2p/discoveryv5/dcli.nim.cfg b/tools/dcli.nim.cfg similarity index 100% rename from eth/p2p/discoveryv5/dcli.nim.cfg rename to tools/dcli.nim.cfg