Cleanup metrics + accounting flag + bump deps (#37)

* Cleaner metrics logging + accounting behind flag + some cleanup

* Bump vendor
This commit is contained in:
Kim De Mey 2020-07-02 23:52:54 +02:00 committed by GitHub
parent f38bdf2900
commit 181889dcd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 33 additions and 27 deletions

View File

@ -1,5 +1,5 @@
import
unittest, strformat, options, os, stew/byteutils,
unittest, options, os, stew/byteutils,
json_rpc/[rpcserver, rpcclient],
eth/common as eth_common, eth/[rlp, keys, p2p],
../../waku/protocol/v1/waku_protocol,

2
vendor/nim-chronos vendored

@ -1 +1 @@
Subproject commit bedd1ded5edc3bfb6877f7025ca4b21f62492ffe
Subproject commit 528688d01e8983763c51fbd9ccd0c797190fc0fe

@ -1 +1 @@
Subproject commit 26667818be48d428892b26be9535c1f0a98d1510
Subproject commit 39456fa3d5b637053b616e50a8350b2b932a1d4c

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit 4d0a7a46ba38947b8daecb1b5ae817c82c8e16c5
Subproject commit 4f533eb5e6d6248ee2c1e94a628d1bc77880da67

2
vendor/nim-json-rpc vendored

@ -1 +1 @@
Subproject commit 8c1a8ef8d9fd1705d4e8640b4c30df2caee76881
Subproject commit 244254632b15c745b6e15537aafd401f360d9928

@ -1 +1 @@
Subproject commit c478b7bbbab6ee298a25c29c7357783d94aaecaa
Subproject commit 1cf51931f1037a2c44fa0912386273c01a0e0e42

@ -1 +1 @@
Subproject commit fc63983c73ba541413f12ee70a2b6f025b03efea
Subproject commit dc2c199d41dc90de75043d1ee4efe5e0323932bf

@ -1 +1 @@
Subproject commit e8fa92a0c6217103eecce2a9e6f274c7eedac13b
Subproject commit be989635994377e0e421e4a039230098ba5ccd28

@ -1 +1 @@
Subproject commit d8ca3daf3a788f357bf96b8e61b3ffce9a018ea2
Subproject commit e0e51015b7348b61aa5d7391af4f8f4487713f91

2
vendor/nim-stew vendored

@ -1 +1 @@
Subproject commit cf82e2d51d12c3ca461cb170c2a4e2eada3bfe67
Subproject commit 61d5cfc37677f2b434d43c06d06695b00e56613b

View File

@ -137,6 +137,11 @@ type
defaultValue: false
name: "log-metrics" .}: bool
logAccounting* {.
desc: "Enable peer accounting logging."
defaultValue: false
name: "log-accounting" .}: bool
# TODO:
# - discv5 + topic register
# - mailserver functionality
@ -146,7 +151,7 @@ type
proc parseCmdArg*(T: type KeyPair, p: TaintedString): T =
try:
let privkey = PrivateKey.fromHex(string(p)).tryGet()
result = privkey.toKeyPair.expect("a valid private key after check above")
result = privkey.toKeyPair()
except CatchableError as e:
raise newException(ConfigurationError, "Invalid private key")

View File

@ -81,7 +81,7 @@ proc setupWakuRPC*(node: EthereumNode, keys: KeyStorage, rpcsrv: RpcServer) =
## Returns key identifier on success and an error on failure.
result = generateRandomID().Identifier
keys.asymKeys.add(result.string, key.toKeyPair().tryGet())
keys.asymKeys.add(result.string, key.toKeyPair())
rpcsrv.rpc("waku_deleteKeyPair") do(id: Identifier) -> bool:
## Deletes the specifies key if it exists.

View File

@ -1,6 +1,6 @@
import
confutils, config, strutils, chronos, json_rpc/rpcserver, metrics,
chronicles/topics_registry, # TODO: What? Need this for setLoglevel, weird.
metrics/chronicles_support,
eth/[keys, p2p, async_utils], eth/common/utils, eth/net/nat,
eth/p2p/[discovery, enode, peer_pool, bootnodes, whispernodes],
eth/p2p/rlpx_protocols/whisper_protocol,
@ -116,19 +116,20 @@ proc run(config: WakuNodeConf) =
setupWakuSimRPC(node, rpcServer)
rpcServer.start()
proc logPeerAccounting(udata: pointer) {.closure, gcsafe.} =
{.gcsafe.}:
for peer in node.peerPool.peers:
let
sent = peer.state(Waku).accounting.sent
received = peer.state(Waku).accounting.received
id = peer.network.toEnode
info "Peer Metrics", id, sent, received
peer.state(Waku).accounting = Accounting(sent: 0, received: 0)
addTimer(Moment.fromNow(2.seconds), logPeerAccounting)
addTimer(Moment.fromNow(2.seconds), logPeerAccounting)
if config.logAccounting:
proc logPeerAccounting(udata: pointer) {.closure, gcsafe.} =
{.gcsafe.}:
for peer in node.peerPool.peers:
let
sent = peer.state(Waku).accounting.sent
received = peer.state(Waku).accounting.received
id = peer.network.toEnode
info "Peer accounting", id, sent, received
peer.state(Waku).accounting = Accounting(sent: 0, received: 0)
discard setTimer(Moment.fromNow(2.seconds), logPeerAccounting)
discard setTimer(Moment.fromNow(2.seconds), logPeerAccounting)
when defined(insecure):
if config.metricsServer:
@ -147,8 +148,8 @@ proc run(config: WakuNodeConf) =
droppedEnvelopes = waku_protocol.envelopes_dropped
info "Node metrics", connectedPeers, validEnvelopes, droppedEnvelopes
addTimer(Moment.fromNow(2.seconds), logMetrics)
addTimer(Moment.fromNow(2.seconds), logMetrics)
discard setTimer(Moment.fromNow(2.seconds), logMetrics)
discard setTimer(Moment.fromNow(2.seconds), logMetrics)
runForever()