switch to chronos metrics, remove insecure (#580)

* switch to chronos metrics, remove insecure

See https://github.com/status-im/nimbus-eth2/pull/2468

also fixes pcre linking for real, and adds some random build flags that
help nimbus-eth2 stay afloat

* fix help

* don't omit frame pointers on windows
This commit is contained in:
Jacek Sieka 2021-04-09 09:26:06 +02:00 committed by GitHub
parent 8a806da600
commit 3147df0dcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 30 deletions

View File

@ -1,15 +1,17 @@
# Copyright (c) 2018-2020 Status Research & Development GmbH. Licensed under
# Copyright (c) 2018-2021 Status Research & Development GmbH. Licensed under
# either of:
# - Apache License, version 2.0
# - MIT license
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.
SHELL := bash # the shell used internally by Make
SHELL := bash # the shell used internally by "make"
# used inside the included makefiles
BUILD_SYSTEM_DIR := vendor/nimbus-build-system
LINK_PCRE := 0
# we don't want an error here, so we can handle things later, in the ".DEFAULT" target
-include $(BUILD_SYSTEM_DIR)/makefiles/variables.mk
@ -57,8 +59,6 @@ all: | $(TOOLS) nimbus
# must be included after the default target
-include $(BUILD_SYSTEM_DIR)/makefiles/targets.mk
LINK_PCRE := 0
# default: use blst
USE_MIRACL := 0

View File

@ -308,8 +308,8 @@ cd vendor/nim-rocksdb
Install Prometheus and Grafana. On Gentoo, it's `emerge prometheus grafana-bin`.
```bash
# build Nimbus with support for the HTTP endpoint
make NIMFLAGS="-d:insecure" nimbus
# build Nimbus
make nimbus
# the Prometheus daemon will create its data dir in the current dir, so give it its own directory
mkdir ../my_metrics
# copy the basic config file over there

View File

@ -14,21 +14,42 @@ if defined(windows):
# set the IMAGE_FILE_LARGE_ADDRESS_AWARE flag so we can use PAE, if enabled, and access more than 2 GiB of RAM
switch("passL", "-Wl,--large-address-aware")
# remember to disable -march=native for reproducible builds
# This helps especially for 32-bit x86, which sans SSE2 and newer instructions
# requires quite roundabout code generation for cryptography, and other 64-bit
# and larger arithmetic use cases, along with register starvation issues. When
# engineering a more portable binary release, this should be tweaked but still
# use at least -msse2 or -msse3.
if defined(disableMarchNative):
switch("passC", "-msse3")
if defined(i386) or defined(amd64):
switch("passC", "-msse3")
switch("passL", "-msse3")
else:
switch("passC", "-march=native")
switch("passL", "-march=native")
if defined(windows):
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65782
# ("-fno-asynchronous-unwind-tables" breaks Nim's exception raising, sometimes)
switch("passC", "-mno-avx512vl")
switch("passC", "-mno-avx512f")
switch("passL", "-mno-avx512f")
# omitting frame pointers in nim breaks the GC
# https://github.com/nim-lang/Nim/issues/10625
if not defined(windows):
# ...except on windows where the option crashes GCC:
# https://sourceforge.net/p/mingw-w64/bugs/880/
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86593
switch("passC", "-fno-omit-frame-pointer")
switch("passL", "-fno-omit-frame-pointer")
--threads:on
--opt:speed
--excessiveStackTrace:on
# enable metric collection
--define:metrics
# for heap-usage-by-instance-type metrics and object base-type strings
--define:nimTypeNames
switch("define", "withoutPCRE")
# the default open files limit is too low on macOS (512), breaking the
# "--debugger:native" build. It can be increased with `ulimit -n 1024`.

View File

@ -698,9 +698,9 @@ proc processNetArguments(key, value: string): ConfigStatus =
result = processInteger(value, res)
if result == Success:
config.net.discPort = uint16(res and 0xFFFF)
elif skey == "metricsserver" and defined(insecure):
elif skey == "metricsserver":
config.net.metricsServer = true
elif skey == "metricsserverport" and defined(insecure):
elif skey == "metricsserverport":
var res = 0
result = processInteger(value, res)
if result == Success:
@ -893,14 +893,6 @@ proc getHelpString*(): string =
continue
logLevels.add($level)
when defined(insecure):
let metricsServerHelp = """
--metricsServer Enable the metrics HTTP server
--metricsServerPort:<value> Metrics HTTP server port on localhost (default: 9093)"""
else:
let metricsServerHelp = ""
result = """
USAGE:
@ -918,14 +910,16 @@ NETWORKING OPTIONS:
--bootnodesv5:<value> Comma separated enode URLs for P2P v5 discovery bootstrap (light server, light nodes)
--staticnodes:<value> Comma separated enode URLs to connect with
--port:<value> Network listening TCP port (default: 30303)
--discport:<value> Network listening UDP port (defaults to --port argument)$7
--discport:<value> Network listening UDP port (defaults to --port argument)
--metricsServer Enable the metrics HTTP server
--metricsServerPort:<value> Metrics HTTP server port on localhost (default: 9093)
--maxpeers:<value> Maximum number of network peers (default: 25)
--maxpendpeers:<value> Maximum number of pending connection attempts (default: 0)
--nat:<value> NAT port mapping mechanism (any|none|upnp|pmp|<external IP>) (default: "any")
--nodiscover Disables the peer discovery mechanism (manual peer addition)
--v5discover Enables the experimental RLPx V5 (Topic Discovery) mechanism
--nodekey:<value> P2P node private key (as hexadecimal string)
--networkid:<value> Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby) (default: $8)
--networkid:<value> Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby) (default: $7)
--testnet Use Ethereum Default Test Network (Ropsten)
--ropsten Use Ethereum Ropsten Test Network
--rinkeby Use Ethereum Rinkeby Test Network
@ -957,7 +951,6 @@ LOGGING AND DEBUGGING OPTIONS:
strip($defaultProtocols, chars = {'{','}'}),
$defaultMaxMsgSize,
$defaultMinPow,
metricsServerHelp,
$ord(defaultNetwork)
]

View File

@ -15,7 +15,8 @@ import
eth/p2p/rlpx_protocols/[eth_protocol, les_protocol, whisper_protocol],
eth/p2p/blockchain_sync, eth/net/nat, eth/p2p/peer_pool,
config, genesis, rpc/[common, p2p, debug, whisper, key_storage], p2p/chain,
eth/trie/db, metrics, metrics/chronicles_support, utils, ./conf_utils
eth/trie/db, metrics, metrics/[chronos_httpserver, chronicles_support],
utils, ./conf_utils
## TODO:
## * No IPv6 support
@ -53,7 +54,7 @@ proc start(nimbus: NimbusNode) =
if canonicalHeadHashKey().toOpenArray notin trieDB:
initializeEmptyDb(chainDb)
doAssert(canonicalHeadHashKey().toOpenArray in trieDB)
if conf.importFile.len > 0:
importRlpBlock(conf.importFile, chainDB)
quit(QuitSuccess)
@ -137,11 +138,10 @@ proc start(nimbus: NimbusNode) =
nimbus.rpcServer.start()
# metrics server
when defined(insecure):
if conf.net.metricsServer:
let metricsAddress = "127.0.0.1"
info "Starting metrics HTTP server", address = metricsAddress, port = conf.net.metricsServerPort
metrics.startHttpServer(metricsAddress, Port(conf.net.metricsServerPort))
if conf.net.metricsServer:
let metricsAddress = "127.0.0.1"
info "Starting metrics HTTP server", address = metricsAddress, port = conf.net.metricsServerPort
startMetricsHttpServer(metricsAddress, Port(conf.net.metricsServerPort))
# Connect directly to the static nodes
for enode in conf.net.staticNodes:

2
vendor/nim-metrics vendored

@ -1 +1 @@
Subproject commit 16ec7aeccc2020666d6b7c63288153f3917222fb
Subproject commit 1edce7ebde5b629f3f128ca09e25c3068dac3f0d