Move dcli tool to a tools folder (#584)

This commit is contained in:
Kim De Mey 2023-01-27 18:40:40 +01:00 committed by GitHub
parent 20d2d318f0
commit 4d55bfc9e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -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