Merge pull request #1161 from status-im/wittinodes

support multiple local Witti nodes [skip ci]
This commit is contained in:
Ștefan Talpalaru 2020-06-11 23:24:54 +02:00 committed by GitHub
commit 8e76b7d9a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 8 deletions

View File

@ -131,10 +131,10 @@ eth2_network_simulation: | build deps clean_eth2_network_simulation_files
+ GIT_ROOT="$$PWD" NIMFLAGS="$(NIMFLAGS)" LOG_LEVEL="$(LOG_LEVEL)" tests/simulation/start.sh + GIT_ROOT="$$PWD" NIMFLAGS="$(NIMFLAGS)" LOG_LEVEL="$(LOG_LEVEL)" tests/simulation/start.sh
clean-testnet0: clean-testnet0:
rm -rf build/data/testnet0 rm -rf build/data/testnet0*
clean-testnet1: clean-testnet1:
rm -rf build/data/testnet1 rm -rf build/data/testnet1*
# - we're getting the preset from a testnet-specific .env file # - we're getting the preset from a testnet-specific .env file
# - try SCRIPT_PARAMS="--skipGoerliKey" # - try SCRIPT_PARAMS="--skipGoerliKey"
@ -143,7 +143,7 @@ testnet0 testnet1: | build deps
NIM_PARAMS="$(subst ",\",$(NIM_PARAMS))" LOG_LEVEL="$(LOG_LEVEL)" $(ENV_SCRIPT) nim $(NIM_PARAMS) scripts/connect_to_testnet.nims $(SCRIPT_PARAMS) --const-preset=$$CONST_PRESET --dev-build $@ NIM_PARAMS="$(subst ",\",$(NIM_PARAMS))" LOG_LEVEL="$(LOG_LEVEL)" $(ENV_SCRIPT) nim $(NIM_PARAMS) scripts/connect_to_testnet.nims $(SCRIPT_PARAMS) --const-preset=$$CONST_PRESET --dev-build $@
clean-schlesi: clean-schlesi:
rm -rf build/data/shared_schlesi rm -rf build/data/shared_schlesi*
schlesi: | build deps schlesi: | build deps
NIM_PARAMS="$(subst ",\",$(NIM_PARAMS))" LOG_LEVEL="$(LOG_LEVEL)" $(ENV_SCRIPT) nim $(NIM_PARAMS) scripts/connect_to_testnet.nims $(SCRIPT_PARAMS) shared/schlesi NIM_PARAMS="$(subst ",\",$(NIM_PARAMS))" LOG_LEVEL="$(LOG_LEVEL)" $(ENV_SCRIPT) nim $(NIM_PARAMS) scripts/connect_to_testnet.nims $(SCRIPT_PARAMS) shared/schlesi
@ -152,7 +152,7 @@ schlesi-dev: | build deps
NIM_PARAMS="$(subst ",\",$(NIM_PARAMS))" LOG_LEVEL="DEBUG; TRACE:discv5,networking; REQUIRED:none; DISABLED:none" $(ENV_SCRIPT) nim $(NIM_PARAMS) scripts/connect_to_testnet.nims $(SCRIPT_PARAMS) shared/schlesi NIM_PARAMS="$(subst ",\",$(NIM_PARAMS))" LOG_LEVEL="DEBUG; TRACE:discv5,networking; REQUIRED:none; DISABLED:none" $(ENV_SCRIPT) nim $(NIM_PARAMS) scripts/connect_to_testnet.nims $(SCRIPT_PARAMS) shared/schlesi
clean-witti: clean-witti:
rm -rf build/data/shared_witti rm -rf build/data/shared_witti*
witti: | build deps witti: | build deps
NIM_PARAMS="$(subst ",\",$(NIM_PARAMS))" LOG_LEVEL="$(LOG_LEVEL)" $(ENV_SCRIPT) nim $(NIM_PARAMS) scripts/connect_to_testnet.nims $(SCRIPT_PARAMS) shared/witti NIM_PARAMS="$(subst ",\",$(NIM_PARAMS))" LOG_LEVEL="$(LOG_LEVEL)" $(ENV_SCRIPT) nim $(NIM_PARAMS) scripts/connect_to_testnet.nims $(SCRIPT_PARAMS) shared/witti
@ -161,7 +161,7 @@ witti-dev: | build deps
NIM_PARAMS="$(subst ",\",$(NIM_PARAMS))" LOG_LEVEL="DEBUG; TRACE:discv5,networking; REQUIRED:none; DISABLED:none" $(ENV_SCRIPT) nim $(NIM_PARAMS) scripts/connect_to_testnet.nims $(SCRIPT_PARAMS) shared/witti NIM_PARAMS="$(subst ",\",$(NIM_PARAMS))" LOG_LEVEL="DEBUG; TRACE:discv5,networking; REQUIRED:none; DISABLED:none" $(ENV_SCRIPT) nim $(NIM_PARAMS) scripts/connect_to_testnet.nims $(SCRIPT_PARAMS) shared/witti
clean: | clean-common clean: | clean-common
rm -rf build/{$(TOOLS_CSV),all_tests,*_node,*ssz*,beacon_node_testnet*,block_sim,state_sim,transition*} rm -rf build/{$(TOOLS_CSV),all_tests,*_node,*ssz*,beacon_node_*,block_sim,state_sim,transition*}
ifneq ($(USE_LIBBACKTRACE), 0) ifneq ($(USE_LIBBACKTRACE), 0)
+ $(MAKE) -C vendor/nim-libbacktrace clean $(HANDLE_OUTPUT) + $(MAKE) -C vendor/nim-libbacktrace clean $(HANDLE_OUTPUT)
endif endif

View File

@ -113,6 +113,20 @@ make witti # This will build Nimbus and all other dependencies
# and connect you to Witti # and connect you to Witti
``` ```
Sometimes, you may want to disable the interactive prompt asking you for a Goerli key in order to become a validator:
```bash
make SCRIPT_PARAMS="--skipGoerliKey" witti # not a validator
```
You can also start multiple local nodes, in different terminal windows/tabs, by specifying their numeric IDs:
```bash
make SCRIPT_PARAMS="--nodeID=0" witti # the default
make SCRIPT_PARAMS="--nodeID=1" witti
make SCRIPT_PARAMS="--nodeID=2" witti
```
### Getting metrics from a local testnet client ### Getting metrics from a local testnet client
```bash ```bash
@ -123,7 +137,8 @@ make NIMFLAGS="-d:insecure" witti
You can now see the raw metrics on http://127.0.0.1:8008/metrics but they're not very useful like this, so let's feed them to a Prometheus instance: You can now see the raw metrics on http://127.0.0.1:8008/metrics but they're not very useful like this, so let's feed them to a Prometheus instance:
```bash ```bash
prometheus --config.file=build/data/shared_witti/prometheus.yml prometheus --config.file=build/data/shared_witti_0/prometheus.yml
# when starting multiple nodes at the same time, just use the config file from the one with the highest ID
``` ```
For some pretty pictures, get [Grafana](https://grafana.com/) up and running, then import the dashboard definition in "grafana/beacon\_nodes\_Grafana\_dashboard.json". For some pretty pictures, get [Grafana](https://grafana.com/) up and running, then import the dashboard definition in "grafana/beacon\_nodes\_Grafana\_dashboard.json".

View File

@ -34,6 +34,15 @@ cli do (skipGoerliKey {.
desc: "Enables more extensive logging and debugging support" desc: "Enables more extensive logging and debugging support"
name: "dev-build" .} = false, name: "dev-build" .} = false,
nodeID {.
desc: "Node ID" .} = 0.int,
basePort {.
desc: "Base TCP/UDP port (nodeID will be added to it)" .} = 9000.int,
baseMetricsPort {.
desc: "Base metrics port (nodeID will be added to it)" .} = 8008.int,
testnetName {.argument .}: string): testnetName {.argument .}: string):
let let
nameParts = testnetName.split "/" nameParts = testnetName.split "/"
@ -84,7 +93,7 @@ cli do (skipGoerliKey {.
let let
dataDirName = testnetName.replace("/", "_") dataDirName = testnetName.replace("/", "_")
.replace("(", "_") .replace("(", "_")
.replace(")", "_") .replace(")", "_") & "_" & $nodeID
dataDir = buildDir / "data" / dataDirName dataDir = buildDir / "data" / dataDirName
validatorsDir = dataDir / "validators" validatorsDir = dataDir / "validators"
secretsDir = dataDir / "secrets" secretsDir = dataDir / "secrets"
@ -123,7 +132,7 @@ cli do (skipGoerliKey {.
mkDir dataDir mkDir dataDir
# macOS may not have gnu-getopts installed and in the PATH # macOS may not have gnu-getopts installed and in the PATH
execIgnoringExitCode &"""./scripts/make_prometheus_config.sh --nodes 1 --base-metrics-port 8008 --config-file "{dataDir}/prometheus.yml"""" execIgnoringExitCode &"""./scripts/make_prometheus_config.sh --nodes """ & $(1 + nodeID) & &""" --base-metrics-port {baseMetricsPort} --config-file "{dataDir}/prometheus.yml""""
exec &"""nim c {nimFlags} -d:"const_preset={preset}" -o:"{beaconNodeBinary}" beacon_chain/beacon_node.nim""" exec &"""nim c {nimFlags} -d:"const_preset={preset}" -o:"{beaconNodeBinary}" beacon_chain/beacon_node.nim"""
@ -159,7 +168,10 @@ cli do (skipGoerliKey {.
--data-dir="{dataDir}" --data-dir="{dataDir}"
--dump --dump
--web3-url={web3Url} --web3-url={web3Url}
--tcp-port=""" & $(basePort + nodeID) & &"""
--udp-port=""" & $(basePort + nodeID) & &"""
--metrics --metrics
--metrics-port=""" & $(baseMetricsPort + nodeID) & &"""
{bootstrapFileOpt} {bootstrapFileOpt}
{logLevelOpt} {logLevelOpt}
{depositContractOpt} {depositContractOpt}