eth2_network_simulation: fixes (#1368)

- delete "tests/simulation/{data,validators}" by default, because old
  validator keys can lead to a crash with a cryptic error message
- actually start the Prometheus daemon on `make eth2_network_simulation`
- kill any running Prometheus daemon on exit
- fix some shell script syntax incompatible with Bash
This commit is contained in:
Ștefan Talpalaru 2020-07-23 17:58:54 +02:00 committed by GitHub
parent fb2f742972
commit e9193fc9da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 6 deletions

View File

@ -154,8 +154,9 @@ GOERLI_TESTNETS_PARAMS := \
--rpc \ --rpc \
--rpc-port=$$(( $(BASE_RPC_PORT) +$(NODE_ID) )) --rpc-port=$$(( $(BASE_RPC_PORT) +$(NODE_ID) ))
eth2_network_simulation: | build deps clean_eth2_network_simulation_data eth2_network_simulation: | build deps clean_eth2_network_simulation_all
+ GIT_ROOT="$$PWD" NIMFLAGS="$(NIMFLAGS)" LOG_LEVEL="$(LOG_LEVEL)" tests/simulation/start-in-tmux.sh + GIT_ROOT="$$PWD" NIMFLAGS="$(NIMFLAGS)" LOG_LEVEL="$(LOG_LEVEL)" tests/simulation/start-in-tmux.sh
killall prometheus &>/dev/null
clean-testnet0: clean-testnet0:
rm -rf build/data/testnet0* rm -rf build/data/testnet0*

View File

@ -226,7 +226,7 @@ type
lastUserValidator* {. lastUserValidator* {.
defaultValue: config.totalValidators - 1, defaultValue: config.totalValidators - 1,
desc: "The last validator index that will free for taking from a testnet participant" desc: "The last validator index that will be free for taking from a testnet participant"
name: "last-user-validator" }: uint64 name: "last-user-validator" }: uint64
bootstrapAddress* {. bootstrapAddress* {.

View File

@ -15,9 +15,12 @@ if [[ "$USE_TMUX" != "no" ]]; then
type "$TMUX_CMD" &>/dev/null || { echo "${TMUX_CMD}" is missing; USE_TMUX="no"; } type "$TMUX_CMD" &>/dev/null || { echo "${TMUX_CMD}" is missing; USE_TMUX="no"; }
fi fi
export TMUX_CMD USE_TMUX
if [[ "$USE_TMUX" != "no" ]]; then if [[ "$USE_TMUX" != "no" ]]; then
TMUX_SESSION_NAME="${TMUX_SESSION_NAME:-nbc-sim}" TMUX_SESSION_NAME="${TMUX_SESSION_NAME:-nbc-sim}"
$TMUX_CMD kill-session -t "${TMUX_SESSION_NAME}" &>/dev/null || true
$TMUX_CMD new-session -s "${TMUX_SESSION_NAME}" -d $TMUX_CMD new-session -s "${TMUX_SESSION_NAME}" -d
$TMUX_CMD setenv -t "${TMUX_SESSION_NAME}" USE_TMUX yes $TMUX_CMD setenv -t "${TMUX_SESSION_NAME}" USE_TMUX yes
@ -32,7 +35,7 @@ if [[ "$USE_TMUX" != "no" ]]; then
$TMUX_CMD new-window -d -t "${TMUX_SESSION_NAME}" -n "sim" $TMUX_CMD new-window -d -t "${TMUX_SESSION_NAME}" -n "sim"
$TMUX_CMD kill-pane -t "${TMUX_SESSION_NAME}:0" $TMUX_CMD kill-pane -t "${TMUX_SESSION_NAME}:0"
$TMUX_CMD new-window -t "${TMUX_SESSION_NAME}" -n "start-script" "if ! $PWD/start.sh; then; read; tmux kill-session; fi" $TMUX_CMD new-window -t "${TMUX_SESSION_NAME}" -n "start-script" "if ! $PWD/start.sh; then echo -en '\nPress any key to exit... '; read; tmux kill-session; fi"
$TMUX_CMD select-window -t "${TMUX_SESSION_NAME}:start-script" $TMUX_CMD select-window -t "${TMUX_SESSION_NAME}:start-script"
$TMUX_CMD attach-session -t "${TMUX_SESSION_NAME}" $TMUX_CMD attach-session -t "${TMUX_SESSION_NAME}"

View File

@ -90,7 +90,7 @@ if [[ "$USE_PROMETHEUS" == "yes" ]]; then
rm -rf "${METRICS_DIR}/data" rm -rf "${METRICS_DIR}/data"
mkdir -p "${METRICS_DIR}/data" mkdir -p "${METRICS_DIR}/data"
# TODO: Prometheus is not shut down properly on tmux kill-session # TODO: Prometheus is not shut down properly on tmux kill-session
killall prometheus > /dev/null || true killall prometheus &>/dev/null || true
PROMETHEUS_FLAGS="--config.file=./prometheus.yml --storage.tsdb.path=./data" PROMETHEUS_FLAGS="--config.file=./prometheus.yml --storage.tsdb.path=./data"
$TMUX_CMD new-window -d -t $TMUX_SESSION_NAME -n "$PROMETHEUS_CMD" "cd '$METRICS_DIR' && $PROMETHEUS_CMD $PROMETHEUS_FLAGS" $TMUX_CMD new-window -d -t $TMUX_SESSION_NAME -n "$PROMETHEUS_CMD" "cd '$METRICS_DIR' && $PROMETHEUS_CMD $PROMETHEUS_FLAGS"
else else
@ -99,7 +99,7 @@ if [[ "$USE_PROMETHEUS" == "yes" ]]; then
fi fi
fi fi
$MAKE -j3 --no-print-directory NIMFLAGS="$CUSTOM_NIMFLAGS $DEFS" LOG_LEVEL="${LOG_LEVEL:-DEBUG}" beacon_node validator_client $MAKE -j2 --no-print-directory NIMFLAGS="$CUSTOM_NIMFLAGS $DEFS" LOG_LEVEL="${LOG_LEVEL:-DEBUG}" beacon_node validator_client
count_files () { count_files () {
{ ls -1q $1 2> /dev/null || true ; } | wc -l { ls -1q $1 2> /dev/null || true ; } | wc -l
@ -145,7 +145,7 @@ function run_cmd {
if [[ "$USE_TMUX" == "yes" ]]; then if [[ "$USE_TMUX" == "yes" ]]; then
echo "Starting node $i..." echo "Starting node $i..."
$TMUX_CMD select-window -t "${TMUX_SESSION_NAME}:sim" $TMUX_CMD select-window -t "${TMUX_SESSION_NAME}:sim"
$TMUX_CMD split-window -t "${TMUX_SESSION_NAME}" "if ! $CMD; then; read; fi" $TMUX_CMD split-window -t "${TMUX_SESSION_NAME}" "if ! $CMD; then read; fi"
$TMUX_CMD select-layout -t "${TMUX_SESSION_NAME}:sim" tiled $TMUX_CMD select-layout -t "${TMUX_SESSION_NAME}:sim" tiled
elif [[ "$USE_MULTITAIL" != "no" ]]; then elif [[ "$USE_MULTITAIL" != "no" ]]; then
if [[ "$i" == "$BOOTSTRAP_NODE" ]]; then if [[ "$i" == "$BOOTSTRAP_NODE" ]]; then