2019-02-28 15:21:29 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-11-02 22:58:07 +01:00
|
|
|
set -e
|
2019-02-28 15:21:29 -06:00
|
|
|
|
2019-10-03 04:51:44 +03:00
|
|
|
NODE_ID=${1}
|
|
|
|
shift
|
|
|
|
|
2019-11-02 22:58:07 +01:00
|
|
|
# Read in variables
|
2019-09-05 12:55:47 +02:00
|
|
|
source "$(dirname "$0")/vars.sh"
|
2019-11-02 22:58:07 +01:00
|
|
|
|
|
|
|
# set up the environment
|
|
|
|
source "${SIM_ROOT}/../../env.sh"
|
|
|
|
|
2019-03-28 16:18:59 +01:00
|
|
|
cd "$GIT_ROOT"
|
2019-02-28 15:21:29 -06:00
|
|
|
|
2019-10-03 04:51:44 +03:00
|
|
|
DATA_DIR="${SIMULATION_DIR}/node-$NODE_ID"
|
2019-11-11 01:28:13 +00:00
|
|
|
PORT=$(( BASE_P2P_PORT + NODE_ID ))
|
2019-03-19 12:57:57 -06:00
|
|
|
|
2019-04-18 02:02:14 +02:00
|
|
|
NAT_FLAG="--nat:none"
|
2019-03-19 12:57:57 -06:00
|
|
|
if [ "${NAT:-}" == "1" ]; then
|
2019-04-18 02:02:14 +02:00
|
|
|
NAT_FLAG="--nat:any"
|
2019-03-19 12:57:57 -06:00
|
|
|
fi
|
2019-03-07 07:59:28 -06:00
|
|
|
|
2019-03-29 00:36:39 +02:00
|
|
|
mkdir -p $DATA_DIR/validators
|
|
|
|
rm -f $DATA_DIR/validators/*
|
2019-05-14 16:31:19 +03:00
|
|
|
|
2019-11-11 01:28:13 +00:00
|
|
|
if [[ $NODE_ID -lt $TOTAL_NODES ]]; then
|
|
|
|
FIRST_VALIDATOR_IDX=$(( (NUM_VALIDATORS / TOTAL_NODES) * NODE_ID ))
|
|
|
|
LAST_VALIDATOR_IDX=$(( (NUM_VALIDATORS / TOTAL_NODES) * (NODE_ID + 1) - 1 ))
|
|
|
|
|
|
|
|
pushd $VALIDATORS_DIR >/dev/null
|
|
|
|
cp $(seq -s " " -f v%07g.privkey $FIRST_VALIDATOR_IDX $LAST_VALIDATOR_IDX) $DATA_DIR/validators
|
|
|
|
popd >/dev/null
|
|
|
|
fi
|
2019-03-29 00:36:39 +02:00
|
|
|
|
2019-02-28 15:21:29 -06:00
|
|
|
$BEACON_NODE_BIN \
|
2019-10-29 01:04:52 +02:00
|
|
|
--bootstrap-file=$NETWORK_BOOTSTRAP_FILE \
|
|
|
|
--data-dir=$DATA_DIR \
|
|
|
|
--node-name=$NODE_ID \
|
|
|
|
--tcp-port=$PORT \
|
|
|
|
--udp-port=$PORT \
|
2019-03-19 12:57:57 -06:00
|
|
|
$NAT_FLAG \
|
2019-10-29 01:04:52 +02:00
|
|
|
--state-snapshot=$SNAPSHOT_FILE \
|
2019-07-18 14:36:53 +03:00
|
|
|
$DEPOSIT_WEB3_URL_ARG \
|
2019-10-29 01:04:52 +02:00
|
|
|
--deposit-contract=$DEPOSIT_CONTRACT_ADDRESS \
|
|
|
|
--metrics-server=on \
|
|
|
|
--metrics-server-address="127.0.0.1" \
|
|
|
|
--metrics-server-port="$(( $BASE_METRICS_PORT + $NODE_ID ))" \
|
2019-11-12 17:45:57 +00:00
|
|
|
"$@"
|
2019-10-03 04:51:44 +03:00
|
|
|
|