2019-02-28 21:21:29 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-11-02 21:58:07 +00:00
|
|
|
set -e
|
2019-02-28 21:21:29 +00:00
|
|
|
|
2019-10-03 01:51:44 +00:00
|
|
|
NODE_ID=${1}
|
|
|
|
shift
|
|
|
|
|
2019-11-02 21:58:07 +00:00
|
|
|
# Read in variables
|
2019-11-14 17:37:51 +00:00
|
|
|
# shellcheck source=/dev/null
|
2019-09-05 10:55:47 +00:00
|
|
|
source "$(dirname "$0")/vars.sh"
|
2019-11-02 21:58:07 +00:00
|
|
|
|
2020-10-27 17:21:35 +00:00
|
|
|
if [[ -n "$1" ]]; then
|
2020-03-26 20:32:13 +00:00
|
|
|
ADDITIONAL_BEACON_NODE_ARGS=$1
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
ADDITIONAL_BEACON_NODE_ARGS=""
|
|
|
|
fi
|
|
|
|
|
2020-06-16 18:38:51 +00:00
|
|
|
BOOTSTRAP_ARG=""
|
|
|
|
|
2020-10-27 17:21:35 +00:00
|
|
|
if [[ -n "$1" ]]; then
|
2019-11-25 19:56:28 +00:00
|
|
|
BOOTSTRAP_NODE_ID=$1
|
|
|
|
shift
|
|
|
|
else
|
2020-06-22 18:22:45 +00:00
|
|
|
BOOTSTRAP_NODE_ID=$BOOTSTRAP_NODE
|
2019-11-25 19:56:28 +00:00
|
|
|
fi
|
|
|
|
|
2020-06-19 17:42:28 +00:00
|
|
|
BOOTSTRAP_ADDRESS_FILE="${SIMULATION_DIR}/node-${BOOTSTRAP_NODE_ID}/beacon_node.enr"
|
|
|
|
|
2020-06-22 18:22:45 +00:00
|
|
|
if [[ "$NODE_ID" != "$BOOTSTRAP_NODE" ]]; then
|
2020-06-16 18:38:51 +00:00
|
|
|
BOOTSTRAP_ARG="--bootstrap-file=$BOOTSTRAP_ADDRESS_FILE"
|
2020-08-25 12:49:05 +00:00
|
|
|
else
|
|
|
|
BOOTSTRAP_ARG="--netkey-file=network_key.json --insecure-netkey-password"
|
2020-06-16 18:38:51 +00:00
|
|
|
fi
|
|
|
|
|
2019-11-02 21:58:07 +00:00
|
|
|
# set up the environment
|
2019-11-14 17:37:51 +00:00
|
|
|
# shellcheck source=/dev/null
|
2019-11-02 21:58:07 +00:00
|
|
|
source "${SIM_ROOT}/../../env.sh"
|
|
|
|
|
2019-03-28 15:18:59 +00:00
|
|
|
cd "$GIT_ROOT"
|
2019-02-28 21:21:29 +00:00
|
|
|
|
2020-06-02 19:59:51 +00:00
|
|
|
NODE_DATA_DIR="${SIMULATION_DIR}/node-$NODE_ID"
|
|
|
|
NODE_VALIDATORS_DIR=$NODE_DATA_DIR/validators/
|
|
|
|
NODE_SECRETS_DIR=$NODE_DATA_DIR/secrets/
|
2020-10-27 11:04:17 +00:00
|
|
|
MAKEDIR=$GIT_ROOT/scripts/makedir.sh
|
|
|
|
COPYFILE=$GIT_ROOT/scripts/copyfile.sh
|
2020-06-02 19:59:51 +00:00
|
|
|
|
2019-11-11 01:28:13 +00:00
|
|
|
PORT=$(( BASE_P2P_PORT + NODE_ID ))
|
2019-03-19 18:57:57 +00:00
|
|
|
|
2020-03-24 11:13:07 +00:00
|
|
|
NAT_ARG="--nat:extip:127.0.0.1"
|
2019-03-19 18:57:57 +00:00
|
|
|
if [ "${NAT:-}" == "1" ]; then
|
2020-03-24 11:13:07 +00:00
|
|
|
NAT_ARG="--nat:any"
|
2019-03-19 18:57:57 +00:00
|
|
|
fi
|
2019-03-07 13:59:28 +00:00
|
|
|
|
2020-10-27 11:04:17 +00:00
|
|
|
"$MAKEDIR" "$NODE_DATA_DIR"
|
2020-10-07 13:02:43 +00:00
|
|
|
|
2020-06-02 19:59:51 +00:00
|
|
|
rm -rf "$NODE_VALIDATORS_DIR"
|
2020-10-27 11:04:17 +00:00
|
|
|
"$MAKEDIR" "$NODE_VALIDATORS_DIR"
|
2020-06-02 19:59:51 +00:00
|
|
|
|
|
|
|
rm -rf "$NODE_SECRETS_DIR"
|
2020-10-27 11:04:17 +00:00
|
|
|
"$MAKEDIR" "$NODE_SECRETS_DIR"
|
2020-06-02 19:59:51 +00:00
|
|
|
|
2020-06-22 18:22:45 +00:00
|
|
|
VALIDATORS_PER_NODE=$(( NUM_VALIDATORS / (TOTAL_NODES - 1) ))
|
2020-07-15 13:15:25 +00:00
|
|
|
if [ "${USE_BN_VC_VALIDATOR_SPLIT:-}" == "yes" ]; then
|
|
|
|
# if using validator client binaries in addition to beacon nodes we will
|
|
|
|
# split the keys for this instance in half between the BN and the VC
|
|
|
|
# and the validators for the BNs will be from the first half of all validators
|
|
|
|
VALIDATORS_PER_NODE=$((VALIDATORS_PER_NODE / 2 ))
|
|
|
|
fi
|
2019-05-14 13:31:19 +00:00
|
|
|
|
2020-06-22 18:22:45 +00:00
|
|
|
if [[ $NODE_ID -lt $BOOTSTRAP_NODE ]]; then
|
2019-11-21 09:15:10 +00:00
|
|
|
pushd "$VALIDATORS_DIR" >/dev/null
|
2020-07-15 13:15:25 +00:00
|
|
|
for VALIDATOR in $(ls | tail -n +$(( ($VALIDATORS_PER_NODE * $NODE_ID) + 1 )) | head -n $VALIDATORS_PER_NODE); do
|
2020-10-27 11:04:17 +00:00
|
|
|
"$COPYFILE" "$VALIDATOR" "$NODE_VALIDATORS_DIR"
|
|
|
|
"$COPYFILE" "$SECRETS_DIR/$VALIDATOR" "$NODE_SECRETS_DIR"
|
2020-06-02 19:59:51 +00:00
|
|
|
done
|
2019-11-11 01:28:13 +00:00
|
|
|
popd >/dev/null
|
|
|
|
fi
|
2019-03-28 22:36:39 +00:00
|
|
|
|
2020-06-02 19:59:51 +00:00
|
|
|
rm -rf "$NODE_DATA_DIR/dump"
|
2020-10-27 11:04:17 +00:00
|
|
|
"$MAKEDIR" "$NODE_DATA_DIR/dump"
|
2019-12-03 11:32:27 +00:00
|
|
|
|
2020-03-24 11:13:07 +00:00
|
|
|
SNAPSHOT_ARG=""
|
|
|
|
if [ -f "${SNAPSHOT_FILE}" ]; then
|
2020-09-22 20:42:42 +00:00
|
|
|
SNAPSHOT_ARG="--finalized-checkpoint-state=${SNAPSHOT_FILE}"
|
2020-03-24 11:13:07 +00:00
|
|
|
fi
|
|
|
|
|
2020-06-02 19:59:51 +00:00
|
|
|
cd "$NODE_DATA_DIR"
|
2020-05-22 17:04:52 +00:00
|
|
|
|
|
|
|
$BEACON_NODE_BIN \
|
2020-03-09 00:32:58 +00:00
|
|
|
--log-level=${LOG_LEVEL:-DEBUG} \
|
2020-06-16 18:38:51 +00:00
|
|
|
$BOOTSTRAP_ARG \
|
2020-07-09 22:08:54 +00:00
|
|
|
--network=$NETWORK_METADATA_FILE \
|
2020-06-02 19:59:51 +00:00
|
|
|
--data-dir=$NODE_DATA_DIR \
|
|
|
|
--secrets-dir=$NODE_SECRETS_DIR \
|
2019-10-28 23:04:52 +00:00
|
|
|
--node-name=$NODE_ID \
|
|
|
|
--tcp-port=$PORT \
|
|
|
|
--udp-port=$PORT \
|
2020-03-24 11:13:07 +00:00
|
|
|
$SNAPSHOT_ARG \
|
|
|
|
$NAT_ARG \
|
2020-07-09 22:08:54 +00:00
|
|
|
$WEB3_ARG \
|
2020-03-16 22:28:54 +00:00
|
|
|
--rpc \
|
|
|
|
--rpc-address="127.0.0.1" \
|
|
|
|
--rpc-port="$(( $BASE_RPC_PORT + $NODE_ID ))" \
|
|
|
|
--metrics \
|
|
|
|
--metrics-address="127.0.0.1" \
|
|
|
|
--metrics-port="$(( $BASE_METRICS_PORT + $NODE_ID ))" \
|
2020-10-27 17:21:35 +00:00
|
|
|
--gossip-slashing-protection=dontcheck \
|
2020-03-26 20:32:13 +00:00
|
|
|
${ADDITIONAL_BEACON_NODE_ARGS} \
|
2019-11-12 17:45:57 +00:00
|
|
|
"$@"
|