Add lightNode and logMetrics options
This commit is contained in:
parent
8c3595ff94
commit
574c5ec0af
4
Makefile
4
Makefile
|
@ -107,3 +107,7 @@ wrappers-static: | build deps libnimbus.a go-checks
|
||||||
wakunode: | build deps
|
wakunode: | build deps
|
||||||
echo -e $(BUILD_MSG) "build/$@" && \
|
echo -e $(BUILD_MSG) "build/$@" && \
|
||||||
$(ENV_SCRIPT) nim wakunode $(NIM_PARAMS) nimbus.nims
|
$(ENV_SCRIPT) nim wakunode $(NIM_PARAMS) nimbus.nims
|
||||||
|
|
||||||
|
wakusim: | build deps wakunode
|
||||||
|
echo -e $(BUILD_MSG) "build/$@" && \
|
||||||
|
$(ENV_SCRIPT) nim quicksim $(NIM_PARAMS) nimbus.nims
|
||||||
|
|
|
@ -40,6 +40,8 @@ task test, "Run tests":
|
||||||
task nimbus, "Build Nimbus":
|
task nimbus, "Build Nimbus":
|
||||||
buildBinary "nimbus", "nimbus/", "-d:chronicles_log_level=TRACE"
|
buildBinary "nimbus", "nimbus/", "-d:chronicles_log_level=TRACE"
|
||||||
|
|
||||||
task wakunode, "Build Waku":
|
task wakunode, "Build Waku node":
|
||||||
buildBinary "wakunode", "waku/", "-d:chronicles_log_level=TRACE"
|
buildBinary "wakunode", "waku/", "-d:chronicles_log_level=TRACE"
|
||||||
buildBinary "quicksim", "waku/", "-d:chronicles_log_level=TRACE"
|
|
||||||
|
task quicksim, "Build quicksim":
|
||||||
|
buildBinary "quicksim", "waku/", "-d:chronicles_log_level=INFO"
|
||||||
|
|
|
@ -62,6 +62,11 @@ type
|
||||||
defaultValue: false
|
defaultValue: false
|
||||||
name: "whisper-bridge" }: bool
|
name: "whisper-bridge" }: bool
|
||||||
|
|
||||||
|
lightNode* {.
|
||||||
|
desc: "Run as light node (no message relay).",
|
||||||
|
defaultValue: false
|
||||||
|
name: "light-node" }: bool
|
||||||
|
|
||||||
wakuMode* {.
|
wakuMode* {.
|
||||||
desc: "Select the Waku mode.",
|
desc: "Select the Waku mode.",
|
||||||
defaultValue: WakuSan
|
defaultValue: WakuSan
|
||||||
|
@ -113,6 +118,11 @@ type
|
||||||
defaultValue: 8008
|
defaultValue: 8008
|
||||||
name: "metrics-server-port" }: uint16
|
name: "metrics-server-port" }: uint16
|
||||||
|
|
||||||
|
logMetrics* {.
|
||||||
|
desc: "Enable metrics logging."
|
||||||
|
defaultValue: false
|
||||||
|
name: "log-metrics" }: bool
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
# - nat
|
# - nat
|
||||||
# - discv5 + topic register
|
# - discv5 + topic register
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import
|
import
|
||||||
confutils, config, chronos, json_rpc/rpcserver, metrics,
|
confutils, config, chronos, json_rpc/rpcserver, metrics,
|
||||||
chronicles/topics_registry, # TODO: What? Need this for setLoglevel, weird.
|
chronicles/topics_registry, # TODO: What? Need this for setLoglevel, weird.
|
||||||
eth/[keys, p2p, async_utils],
|
eth/[keys, p2p, async_utils], eth/common/utils,
|
||||||
eth/p2p/[discovery, enode, peer_pool, bootnodes, whispernodes],
|
eth/p2p/[discovery, enode, peer_pool, bootnodes, whispernodes],
|
||||||
eth/p2p/rlpx_protocols/[whisper_protocol, waku_protocol, waku_bridge],
|
eth/p2p/rlpx_protocols/[whisper_protocol, waku_protocol, waku_bridge],
|
||||||
../nimbus/rpc/waku
|
../nimbus/rpc/waku
|
||||||
|
@ -39,7 +39,7 @@ proc run(config: WakuNodeConf) =
|
||||||
node.addCapability Waku # Always enable Waku protocol
|
node.addCapability Waku # Always enable Waku protocol
|
||||||
let wakuConfig = WakuConfig(powRequirement: config.wakuPow,
|
let wakuConfig = WakuConfig(powRequirement: config.wakuPow,
|
||||||
bloom: fullBloom(),
|
bloom: fullBloom(),
|
||||||
isLightNode: false,
|
isLightNode: config.lightNode,
|
||||||
maxMsgSize: waku_protocol.defaultMaxMsgSize,
|
maxMsgSize: waku_protocol.defaultMaxMsgSize,
|
||||||
wakuMode: config.wakuMode,
|
wakuMode: config.wakuMode,
|
||||||
topics: @[])
|
topics: @[])
|
||||||
|
@ -81,6 +81,25 @@ proc run(config: WakuNodeConf) =
|
||||||
info "Starting metrics HTTP server", address, port
|
info "Starting metrics HTTP server", address, port
|
||||||
metrics.startHttpServer($address, Port(port))
|
metrics.startHttpServer($address, Port(port))
|
||||||
|
|
||||||
|
if config.logMetrics:
|
||||||
|
proc logMetrics(udata: pointer) {.closure, gcsafe.} =
|
||||||
|
{.gcsafe.}:
|
||||||
|
let
|
||||||
|
connectedPeers = connected_peers.value
|
||||||
|
validEnvelopes = waku_protocol.valid_envelopes.value
|
||||||
|
invalidEnvelopes = waku_protocol.dropped_expired_envelopes.value +
|
||||||
|
waku_protocol.dropped_from_future_envelopes.value +
|
||||||
|
waku_protocol.dropped_low_pow_envelopes.value +
|
||||||
|
waku_protocol.dropped_too_large_envelopes.value +
|
||||||
|
waku_protocol.dropped_bloom_filter_mismatch_envelopes.value +
|
||||||
|
waku_protocol.dropped_topic_mismatch_envelopes.value +
|
||||||
|
waku_protocol.dropped_benign_duplicate_envelopes.value +
|
||||||
|
waku_protocol.dropped_malicious_duplicate_envelopes.value
|
||||||
|
|
||||||
|
info "Node metrics", connectedPeers, validEnvelopes, invalidEnvelopes
|
||||||
|
addTimer(Moment.fromNow(2.seconds), logMetrics)
|
||||||
|
addTimer(Moment.fromNow(2.seconds), logMetrics)
|
||||||
|
|
||||||
runForever()
|
runForever()
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
|
|
Loading…
Reference in New Issue