tests/simulation/start.sh: refactoring [skip ci]

to avoid NIMFLAGS duplication
This commit is contained in:
Ștefan Talpalaru 2020-02-14 13:35:23 +01:00
parent e5629ebc1f
commit 98160d3227
No known key found for this signature in database
GPG Key ID: CBF7934204F1B6F9
3 changed files with 15 additions and 17 deletions

View File

@ -108,13 +108,13 @@ endif
$(TOOLS): | build deps $(TOOLS): | build deps
for D in $(TOOLS_DIRS); do [ -e "$${D}/$@.nim" ] && TOOL_DIR="$${D}" && break; done && \ for D in $(TOOLS_DIRS); do [ -e "$${D}/$@.nim" ] && TOOL_DIR="$${D}" && break; done && \
echo -e $(BUILD_MSG) "build/$@" && \ echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim c $(NIM_PARAMS) -o:build/$@ "$${TOOL_DIR}/$@.nim" $(ENV_SCRIPT) nim c -o:build/$@ $(NIM_PARAMS) "$${TOOL_DIR}/$@.nim"
clean_eth2_network_simulation_files: clean_eth2_network_simulation_files:
rm -rf tests/simulation/{data,validators} rm -rf tests/simulation/{data,validators}
eth2_network_simulation: | build deps p2pd clean_eth2_network_simulation_files process_dashboard eth2_network_simulation: | build deps p2pd clean_eth2_network_simulation_files process_dashboard
GIT_ROOT="$$PWD" tests/simulation/start.sh + GIT_ROOT="$$PWD" NIMFLAGS="$(NIMFLAGS)" tests/simulation/start.sh
clean-testnet0: clean-testnet0:
rm -rf build/data/testnet0 rm -rf build/data/testnet0
@ -134,13 +134,13 @@ clean: | clean-common
libnfuzz.so: | build deps-common beacon_chain.nims libnfuzz.so: | build deps-common beacon_chain.nims
echo -e $(BUILD_MSG) "build/$@" && \ echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim c -d:release --app:lib --noMain --nimcache:nimcache/libnfuzz $(NIM_PARAMS) -o:build/$@.0 nfuzz/libnfuzz.nim && \ $(ENV_SCRIPT) nim c -d:release --app:lib --noMain --nimcache:nimcache/libnfuzz -o:build/$@.0 $(NIM_PARAMS) nfuzz/libnfuzz.nim && \
rm -f build/$@ && \ rm -f build/$@ && \
ln -s $@.0 build/$@ ln -s $@.0 build/$@
libnfuzz.a: | build deps-common beacon_chain.nims libnfuzz.a: | build deps-common beacon_chain.nims
echo -e $(BUILD_MSG) "build/$@" && \ echo -e $(BUILD_MSG) "build/$@" && \
rm -f build/$@ && \ rm -f build/$@ && \
$(ENV_SCRIPT) nim c -d:release --app:staticlib --noMain --nimcache:nimcache/libnfuzz_static $(NIM_PARAMS) -o:build/$@ nfuzz/libnfuzz.nim && \ $(ENV_SCRIPT) nim c -d:release --app:staticlib --noMain --nimcache:nimcache/libnfuzz_static -o:build/$@ $(NIM_PARAMS) nfuzz/libnfuzz.nim && \
[[ -e "$@" ]] && mv "$@" build/ # workaround for https://github.com/nim-lang/Nim/issues/12745 [[ -e "$@" ]] && mv "$@" build/ # workaround for https://github.com/nim-lang/Nim/issues/12745

View File

@ -52,6 +52,7 @@ if [[ $NODE_ID == $MASTER_NODE ]]; then
NODE_BIN=$BOOTSTRAP_NODE_BIN NODE_BIN=$BOOTSTRAP_NODE_BIN
fi fi
# if you want tracing messages, add "--log-level=TRACE" below
cd "$DATA_DIR" && $NODE_BIN \ cd "$DATA_DIR" && $NODE_BIN \
--bootstrap-file=$BOOTSTRAP_ADDRESS_FILE \ --bootstrap-file=$BOOTSTRAP_ADDRESS_FILE \
--data-dir=$DATA_DIR \ --data-dir=$DATA_DIR \

View File

@ -6,21 +6,16 @@ set -eo pipefail
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "$(dirname "$0")/vars.sh" source "$(dirname "$0")/vars.sh"
# set up the environment
# shellcheck source=/dev/null
source "${SIM_ROOT}/../../env.sh"
cd "$SIM_ROOT" cd "$SIM_ROOT"
mkdir -p "$SIMULATION_DIR" mkdir -p "$SIMULATION_DIR"
mkdir -p "$VALIDATORS_DIR" mkdir -p "$VALIDATORS_DIR"
cd "$GIT_ROOT" cd "$GIT_ROOT"
NIMFLAGS="-d:chronicles_log_level=TRACE -d:chronicles_sinks:textlines,json[file] --hints:off --warnings:off --verbosity:0 --opt:speed --debuginfo" CUSTOM_NIMFLAGS="${NIMFLAGS} -d:chronicles_log_level=TRACE -d:chronicles_sinks:textlines,json[file]"
# Run with "SLOTS_PER_EPOCH=8 ./start.sh" to change these # Run with "SLOTS_PER_EPOCH=8 ./start.sh" to change these
DEFS="" DEFS=""
DEFS+="-d:MAX_COMMITTEES_PER_SLOT=${MAX_COMMITTEES_PER_SLOT:-1} " # Spec default: 64 DEFS+="-d:MAX_COMMITTEES_PER_SLOT=${MAX_COMMITTEES_PER_SLOT:-1} " # Spec default: 64
DEFS+="-d:SLOTS_PER_EPOCH=${SLOTS_PER_EPOCH:-6} " # Spec default: 32 DEFS+="-d:SLOTS_PER_EPOCH=${SLOTS_PER_EPOCH:-6} " # Spec default: 32
DEFS+="-d:SECONDS_PER_SLOT=${SECONDS_PER_SLOT:-6} " # Spec default: 12 DEFS+="-d:SECONDS_PER_SLOT=${SECONDS_PER_SLOT:-6} " # Spec default: 12
@ -30,9 +25,9 @@ LAST_VALIDATOR="$VALIDATORS_DIR/v$(printf '%07d' $LAST_VALIDATOR_NUM).deposit.js
build_beacon_node () { build_beacon_node () {
OUTPUT_BIN=$1; shift OUTPUT_BIN=$1; shift
PARAMS="$NIMFLAGS $DEFS $@" PARAMS="$CUSTOM_NIMFLAGS $DEFS $@"
echo "Building $OUTPUT_BIN ($PARAMS)" echo "Building $OUTPUT_BIN ($PARAMS)"
nim c -o:$OUTPUT_BIN $PARAMS beacon_chain/beacon_node make NIMFLAGS="-o:$OUTPUT_BIN $PARAMS" beacon_node
} }
build_beacon_node $BEACON_NODE_BIN -d:"NETWORK_TYPE=$NETWORK_TYPE" build_beacon_node $BEACON_NODE_BIN -d:"NETWORK_TYPE=$NETWORK_TYPE"
@ -47,7 +42,7 @@ fi
if [ ! -f "${LAST_VALIDATOR}" ]; then if [ ! -f "${LAST_VALIDATOR}" ]; then
echo Building $DEPLOY_DEPOSIT_CONTRACT_BIN echo Building $DEPLOY_DEPOSIT_CONTRACT_BIN
nim c -o:"$DEPLOY_DEPOSIT_CONTRACT_BIN" $NIMFLAGS $DEFS -d:release beacon_chain/deposit_contract make NIMFLAGS="-o:\"$DEPLOY_DEPOSIT_CONTRACT_BIN\" $CUSTOM_NIMFLAGS $DEFS" deposit_contract
if [ "$DEPOSIT_WEB3_URL_ARG" != "" ]; then if [ "$DEPOSIT_WEB3_URL_ARG" != "" ]; then
DEPOSIT_CONTRACT_ADDRESS=$($DEPLOY_DEPOSIT_CONTRACT_BIN deploy $DEPOSIT_WEB3_URL_ARG) DEPOSIT_CONTRACT_ADDRESS=$($DEPLOY_DEPOSIT_CONTRACT_BIN deploy $DEPOSIT_WEB3_URL_ARG)
@ -74,6 +69,8 @@ if [ ! -f "${SNAPSHOT_FILE}" ]; then
--genesis-offset=5 # Delay in seconds --genesis-offset=5 # Delay in seconds
fi fi
rm -f beacon_node.log
# Delete any leftover address files from a previous session # Delete any leftover address files from a previous session
if [ -f "${MASTER_NODE_ADDRESS_FILE}" ]; then if [ -f "${MASTER_NODE_ADDRESS_FILE}" ]; then
rm "${MASTER_NODE_ADDRESS_FILE}" rm "${MASTER_NODE_ADDRESS_FILE}"
@ -102,14 +99,14 @@ scrape_configs:
static_configs: static_configs:
EOF EOF
PROCESS_DASHBOARD_BIN="${SIM_ROOT}/../../build/process_dashboard" PROCESS_DASHBOARD_BIN="build/process_dashboard"
if [ ! -f "$PROCESS_DASHBOARD_BIN" ]; then if [[ ! -f "$PROCESS_DASHBOARD_BIN" ]]; then
nim c -d:release --outdir:build tests/simulation/process_dashboard.nim make NIMFLAGS="$CUSTOM_NIMFLAGS" process_dashboard
fi fi
# use the exported Grafana dashboard for a single node to create one for all nodes # use the exported Grafana dashboard for a single node to create one for all nodes
"${SIM_ROOT}/../../build/process_dashboard" \ "${PROCESS_DASHBOARD_BIN}" \
--nodes=${TOTAL_NODES} \ --nodes=${TOTAL_NODES} \
--in="${SIM_ROOT}/beacon-chain-sim-node0-Grafana-dashboard.json" \ --in="${SIM_ROOT}/beacon-chain-sim-node0-Grafana-dashboard.json" \
--out="${SIM_ROOT}/beacon-chain-sim-all-nodes-Grafana-dashboard.json" --out="${SIM_ROOT}/beacon-chain-sim-all-nodes-Grafana-dashboard.json"