render tests/simulation/start.sh more robust to paths with spaces (#340)
This commit is contained in:
parent
3e587d4667
commit
cba25b087c
|
@ -1,9 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
set -euo pipefail
|
||||
|
||||
# Read in variables
|
||||
. $(dirname $0)/vars.sh
|
||||
. "$(dirname "$0")/vars.sh"
|
||||
|
||||
# Set a default value for the env vars usually supplied by nimbus Makefile
|
||||
|
||||
|
@ -22,7 +22,7 @@ mkdir -p "$SIMULATION_DIR"
|
|||
mkdir -p "$VALIDATORS_DIR"
|
||||
|
||||
cd "$GIT_ROOT"
|
||||
mkdir -p $BUILD_OUTPUTS_DIR
|
||||
mkdir -p "${BUILD_OUTPUTS_DIR}"
|
||||
|
||||
# Run with "SHARD_COUNT=4 ./start.sh" to change these
|
||||
DEFS="-d:chronicles_log_level=DEBUG "
|
||||
|
@ -30,10 +30,10 @@ DEFS+="-d:SHARD_COUNT=${SHARD_COUNT:-16} " # Spec default: 1024
|
|||
DEFS+="-d:SLOTS_PER_EPOCH=${SLOTS_PER_EPOCH:-16} " # Spec default: 64
|
||||
DEFS+="-d:SECONDS_PER_SLOT=${SECONDS_PER_SLOT:-18} " # Spec default: 6
|
||||
|
||||
LAST_VALIDATOR_NUM=$(( $NUM_VALIDATORS - 1 ))
|
||||
LAST_VALIDATOR_NUM=$(( NUM_VALIDATORS - 1 ))
|
||||
LAST_VALIDATOR="$VALIDATORS_DIR/v$(printf '%07d' $LAST_VALIDATOR_NUM).deposit.json"
|
||||
|
||||
if [ ! -f $LAST_VALIDATOR ]; then
|
||||
if [ ! -f "${LAST_VALIDATOR}" ]; then
|
||||
if [[ -z "$SKIP_BUILDS" ]]; then
|
||||
nim c -o:"$VALIDATOR_KEYGEN_BIN" $DEFS -d:release beacon_chain/validator_keygen
|
||||
nim c -o:"$DEPLOY_DEPOSIT_CONTRACT_BIN" $DEFS -d:release beacon_chain/deploy_deposit_contract
|
||||
|
@ -41,38 +41,39 @@ if [ ! -f $LAST_VALIDATOR ]; then
|
|||
fi
|
||||
|
||||
if [ "$DEPOSIT_WEB3_URL_ARG" != "" ]; then
|
||||
export DEPOSIT_CONTRACT_ADDRESS=$($DEPLOY_DEPOSIT_CONTRACT_BIN $DEPOSIT_WEB3_URL_ARG)
|
||||
DEPOSIT_CONTRACT_ADDRESS=$($DEPLOY_DEPOSIT_CONTRACT_BIN $DEPOSIT_WEB3_URL_ARG)
|
||||
export DEPOSIT_CONTRACT_ADDRESS
|
||||
fi
|
||||
|
||||
$VALIDATOR_KEYGEN_BIN \
|
||||
--totalValidators=$NUM_VALIDATORS \
|
||||
--totalValidators="${NUM_VALIDATORS}" \
|
||||
--outputDir="$VALIDATORS_DIR" \
|
||||
--generateFakeKeys=yes \
|
||||
$DEPOSIT_WEB3_URL_ARG \
|
||||
--depositContractAddress=$DEPOSIT_CONTRACT_ADDRESS
|
||||
--depositContractAddress="${DEPOSIT_CONTRACT_ADDRESS}"
|
||||
fi
|
||||
|
||||
if [[ -z "$SKIP_BUILDS" ]]; then
|
||||
nim c -o:"$BEACON_NODE_BIN" $DEFS --opt:speed --debuginfo beacon_chain/beacon_node
|
||||
fi
|
||||
|
||||
if [ ! -f $SNAPSHOT_FILE ]; then
|
||||
if [ ! -f "${SNAPSHOT_FILE}" ]; then
|
||||
$BEACON_NODE_BIN \
|
||||
--dataDir=$SIMULATION_DIR/node-0 \
|
||||
--dataDir="${SIMULATION_DIR}/node-0" \
|
||||
createTestnet \
|
||||
--networkId=1000 \
|
||||
--validatorsDir=$VALIDATORS_DIR \
|
||||
--totalValidators=$NUM_VALIDATORS \
|
||||
--outputGenesis=$SNAPSHOT_FILE \
|
||||
--outputNetwork=$NETWORK_METADATA_FILE \
|
||||
--validatorsDir="${VALIDATORS_DIR}" \
|
||||
--totalValidators="${NUM_VALIDATORS}" \
|
||||
--outputGenesis="${SNAPSHOT_FILE}" \
|
||||
--outputNetwork="${NETWORK_METADATA_FILE}" \
|
||||
--bootstrapAddress=127.0.0.1 \
|
||||
--bootstrapPort=50000 \
|
||||
--genesisOffset=5 # Delay in seconds
|
||||
fi
|
||||
|
||||
# Delete any leftover address files from a previous session
|
||||
if [ -f $MASTER_NODE_ADDRESS_FILE ]; then
|
||||
rm $MASTER_NODE_ADDRESS_FILE
|
||||
if [ -f "${MASTER_NODE_ADDRESS_FILE}" ]; then
|
||||
rm "${MASTER_NODE_ADDRESS_FILE}"
|
||||
fi
|
||||
|
||||
# multitail support
|
||||
|
@ -85,18 +86,18 @@ type "$MULTITAIL" &>/dev/null || USE_MULTITAIL="no"
|
|||
# Trap and ignore SIGTERM, so we don't kill this process along with its children.
|
||||
if [ "$USE_MULTITAIL" = "no" ]; then
|
||||
trap '' SIGTERM
|
||||
trap "kill -- -$$" SIGINT EXIT
|
||||
trap 'kill -- -$$' SIGINT EXIT
|
||||
fi
|
||||
|
||||
COMMANDS=()
|
||||
LAST_NODE=$(( $NUM_NODES - 1 ))
|
||||
LAST_NODE=$(( NUM_NODES - 1 ))
|
||||
|
||||
for i in $(seq 0 $LAST_NODE); do
|
||||
if [[ "$i" == "0" ]]; then
|
||||
sleep 0
|
||||
elif [ "$USE_MULTITAIL" = "no" ]; then
|
||||
# Wait for the master node to write out its address file
|
||||
while [ ! -f $MASTER_NODE_ADDRESS_FILE ]; do
|
||||
while [ ! -f "${MASTER_NODE_ADDRESS_FILE}" ]; do
|
||||
sleep 0.1
|
||||
done
|
||||
fi
|
||||
|
@ -112,7 +113,7 @@ for i in $(seq 0 $LAST_NODE); do
|
|||
# "multitail" closes the corresponding panel when a command exits, so let's make sure it doesn't exit
|
||||
COMMANDS+=( " -cT ansi -t 'node #$i' -l 'sleep $SLEEP; $CMD; echo [node execution completed]; while true; do sleep 100; done'" )
|
||||
else
|
||||
eval $CMD &
|
||||
eval "${CMD}" &
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in New Issue