2021-11-15 11:48:19 +00:00
|
|
|
#!/usr/bin/env bash
|
2020-01-20 22:28:48 +00:00
|
|
|
|
2023-04-08 00:18:29 +00:00
|
|
|
# Copyright (c) 2020-2023 Status Research & Development GmbH. Licensed under
|
2020-02-18 23:33:26 +00:00
|
|
|
# either of:
|
|
|
|
# - Apache License, version 2.0
|
|
|
|
# - MIT license
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
2020-01-20 22:28:48 +00:00
|
|
|
# Mostly a duplication of "tests/simulation/{start.sh,run_node.sh}", but with a focus on
|
2020-02-13 12:19:12 +00:00
|
|
|
# replicating testnets as closely as possible, which means following the Docker execution labyrinth.
|
2020-01-20 22:28:48 +00:00
|
|
|
|
2022-06-27 08:34:12 +00:00
|
|
|
set -euo pipefail
|
2020-01-20 22:28:48 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
SCRIPTS_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
|
|
|
cd "$SCRIPTS_DIR/.."
|
|
|
|
BUILD_DIR="$(pwd)/build"
|
2022-06-27 08:34:12 +00:00
|
|
|
|
|
|
|
VERBOSE="0"
|
|
|
|
|
|
|
|
log() {
|
|
|
|
if [[ "${VERBOSE}" -ge "1" ]]; then
|
|
|
|
echo "${@}"
|
|
|
|
fi
|
|
|
|
}
|
2020-01-20 22:28:48 +00:00
|
|
|
|
2023-03-17 18:43:52 +00:00
|
|
|
source "$SCRIPTS_DIR/detect_platform.sh"
|
2022-03-11 12:44:56 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
# Created processed that will be cleaned up when the script exits
|
2023-05-25 15:05:38 +00:00
|
|
|
PIDS_TO_WAIT=""
|
2023-02-23 02:10:07 +00:00
|
|
|
|
2020-02-18 23:33:26 +00:00
|
|
|
####################
|
|
|
|
# argument parsing #
|
|
|
|
####################
|
2020-07-29 12:08:27 +00:00
|
|
|
|
|
|
|
GETOPT_BINARY="getopt"
|
2022-03-11 12:44:56 +00:00
|
|
|
if [[ "${OS}" == "macos" ]]; then
|
2023-04-08 00:18:29 +00:00
|
|
|
# Without the head -n1 constraint, it gets confused by multiple matches
|
|
|
|
GETOPT_BINARY=$(find /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt 2> /dev/null | head -n1 || true)
|
2020-07-30 00:46:10 +00:00
|
|
|
[[ -f "$GETOPT_BINARY" ]] || { echo "GNU getopt not installed. Please run 'brew install gnu-getopt'. Aborting."; exit 1; }
|
2020-07-29 12:08:27 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
! ${GETOPT_BINARY} --test > /dev/null
|
2022-03-11 12:44:56 +00:00
|
|
|
if [[ ${PIPESTATUS[0]} != 4 ]]; then
|
2022-02-12 11:27:43 +00:00
|
|
|
# shellcheck disable=2016
|
2020-07-30 00:46:10 +00:00
|
|
|
echo '`getopt --test` failed in this environment.'
|
|
|
|
exit 1
|
2020-02-18 23:33:26 +00:00
|
|
|
fi
|
|
|
|
|
2022-05-31 10:45:37 +00:00
|
|
|
CURL_BINARY="$(command -v curl)" || { echo "Curl not installed. Aborting."; exit 1; }
|
2023-11-26 14:38:19 +00:00
|
|
|
JQ_BINARY="$(command -v jq)" || { echo "jq not installed. Aborting."; exit 1; }
|
2022-05-31 10:45:37 +00:00
|
|
|
|
2021-02-02 18:02:52 +00:00
|
|
|
OPTS="ht:n:d:g"
|
2023-05-25 15:05:38 +00:00
|
|
|
LONGOPTS="help,preset:,nodes:,data-dir:,remote-validators-count:,threshold:,signer-nodes:,signer-type:,with-ganache,stop-at-epoch:,disable-htop,use-vc:,disable-vc,enable-payload-builder,enable-logtrace,log-level:,base-port:,base-rest-port:,base-metrics-port:,base-vc-metrics-port:,base-vc-keymanager-port:,base-remote-signer-port:,base-remote-signer-metrics-port:,base-el-net-port:,base-el-rpc-port:,base-el-ws-port:,base-el-auth-rpc-port:,el-port-offset:,reuse-existing-data-dir,reuse-binaries,timeout:,kill-old-processes,eth2-docker-image:,lighthouse-vc-nodes:,run-geth,dl-geth,dl-nimbus-eth1,dl-nimbus-eth2,light-clients:,run-nimbus-eth1,verbose,altair-fork-epoch:,bellatrix-fork-epoch:,capella-fork-epoch:,deneb-fork-epoch:"
|
2020-01-20 22:28:48 +00:00
|
|
|
|
2020-02-18 23:33:26 +00:00
|
|
|
# default values
|
2022-08-12 14:41:11 +00:00
|
|
|
BINARIES=""
|
2020-02-18 23:33:26 +00:00
|
|
|
NUM_NODES="10"
|
2020-01-20 22:28:48 +00:00
|
|
|
DATA_DIR="local_testnet_data"
|
2020-02-18 23:33:26 +00:00
|
|
|
USE_HTOP="1"
|
2023-04-27 21:21:01 +00:00
|
|
|
: ${USE_VC:="1"}
|
2023-02-23 02:10:07 +00:00
|
|
|
USE_PAYLOAD_BUILDER="false"
|
|
|
|
: ${PAYLOAD_BUILDER_HOST:=127.0.0.1}
|
|
|
|
: ${PAYLOAD_BUILDER_PORT:=4888}
|
2022-03-11 12:44:56 +00:00
|
|
|
LIGHTHOUSE_VC_NODES="0"
|
2021-08-13 14:12:40 +00:00
|
|
|
LOG_LEVEL="DEBUG; TRACE:networking"
|
2020-05-14 17:34:47 +00:00
|
|
|
BASE_PORT="9000"
|
2022-05-10 00:32:12 +00:00
|
|
|
BASE_REMOTE_SIGNER_PORT="6000"
|
2023-02-23 02:10:07 +00:00
|
|
|
BASE_REMOTE_SIGNER_METRICS_PORT="6100"
|
2020-05-14 17:34:47 +00:00
|
|
|
BASE_METRICS_PORT="8008"
|
2022-02-12 11:27:43 +00:00
|
|
|
BASE_REST_PORT="7500"
|
2022-08-19 10:30:07 +00:00
|
|
|
BASE_VC_KEYMANAGER_PORT="8500"
|
2022-11-30 10:47:11 +00:00
|
|
|
BASE_VC_METRICS_PORT="9008"
|
2022-07-23 14:28:10 +00:00
|
|
|
BASE_EL_NET_PORT="30303"
|
2023-02-23 02:10:07 +00:00
|
|
|
BASE_EL_RPC_PORT="8545"
|
2022-07-23 14:28:10 +00:00
|
|
|
BASE_EL_WS_PORT="8546"
|
|
|
|
BASE_EL_AUTH_RPC_PORT="8551"
|
|
|
|
EL_PORT_OFFSET="10"
|
2023-02-23 02:10:07 +00:00
|
|
|
: ${REUSE_EXISTING_DATA_DIR:=0}
|
|
|
|
: ${REUSE_BINARIES:=0}
|
|
|
|
: ${NIMFLAGS:=""}
|
|
|
|
: ${MIN_DEPOSIT_SENDING_DELAY:=1}
|
|
|
|
: ${MAX_DEPOSIT_SENDING_DELAY:=25}
|
2020-08-16 09:12:19 +00:00
|
|
|
ENABLE_LOGTRACE="0"
|
2023-02-23 02:10:07 +00:00
|
|
|
STOP_AT_EPOCH=9999999
|
2020-09-01 13:38:34 +00:00
|
|
|
STOP_AT_EPOCH_FLAG=""
|
2021-02-02 18:02:52 +00:00
|
|
|
TIMEOUT_DURATION="0"
|
2021-07-16 10:02:27 +00:00
|
|
|
CONST_PRESET="mainnet"
|
2021-07-27 15:57:16 +00:00
|
|
|
KILL_OLD_PROCESSES="0"
|
2021-11-30 18:56:22 +00:00
|
|
|
ETH2_DOCKER_IMAGE=""
|
2022-05-10 00:32:12 +00:00
|
|
|
REMOTE_SIGNER_THRESHOLD=1
|
|
|
|
REMOTE_VALIDATORS_COUNT=0
|
2022-07-12 11:38:50 +00:00
|
|
|
LC_NODES=1
|
2022-06-27 08:34:12 +00:00
|
|
|
ACCOUNT_PASSWORD="nimbus"
|
|
|
|
RUN_GETH="0"
|
|
|
|
DL_GETH="0"
|
2023-02-23 02:10:07 +00:00
|
|
|
: ${DL_NIMBUS_ETH1:="0"}
|
|
|
|
: ${DL_NIMBUS_ETH2:="0"}
|
2022-06-27 08:34:12 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
# TODO: Add command-line flags for these
|
2023-04-05 16:12:28 +00:00
|
|
|
: ${NIMBUS_ETH2_VERSION:=23.3.2}
|
|
|
|
: ${NIMBUS_ETH2_REVISION:=6c0d756d}
|
2022-06-27 08:34:12 +00:00
|
|
|
|
2023-03-17 18:43:52 +00:00
|
|
|
: ${BEACON_NODE_COMMAND:="./build/nimbus_beacon_node$EXE_EXTENSION"}
|
2023-09-11 09:26:21 +00:00
|
|
|
: ${CAPELLA_FORK_EPOCH:=0}
|
2023-02-23 02:10:07 +00:00
|
|
|
: ${DENEB_FORK_EPOCH:=50}
|
|
|
|
#NIMBUS EL VARS
|
|
|
|
RUN_NIMBUS_ETH1="0"
|
2023-03-17 18:43:52 +00:00
|
|
|
: ${NIMBUS_ETH1_BINARY:="./build/downloads/nimbus$EXE_EXTENSION"}
|
2023-06-02 21:41:57 +00:00
|
|
|
: ${WEB3SIGNER_VERSION:=23.1.0}
|
2023-02-23 02:10:07 +00:00
|
|
|
: ${WEB3SIGNER_DIR:="${BUILD_DIR}/downloads/web3signer-${WEB3SIGNER_VERSION}"}
|
2023-03-17 18:43:52 +00:00
|
|
|
: ${WEB3SIGNER_BINARY:="${WEB3SIGNER_DIR}/bin/web3signer$BAT_EXTENSION"}
|
2023-05-25 15:05:38 +00:00
|
|
|
: ${SIGNER_NODES:=0}
|
|
|
|
: ${SIGNER_TYPE:="nimbus"}
|
2022-08-12 14:41:11 +00:00
|
|
|
PORTS_TO_KILL=()
|
2023-02-23 02:10:07 +00:00
|
|
|
WEB3_ARG=()
|
|
|
|
CLEANUP_DIRS=()
|
2020-02-18 23:33:26 +00:00
|
|
|
|
|
|
|
print_help() {
|
2020-07-30 00:46:10 +00:00
|
|
|
cat <<EOF
|
2021-07-16 10:02:27 +00:00
|
|
|
Usage: $(basename "$0") [OPTIONS] -- [BEACON NODE OPTIONS]
|
|
|
|
E.g.: $(basename "$0") --nodes ${NUM_NODES} --stop-at-epoch 5 --data-dir "${DATA_DIR}" # defaults
|
2020-09-01 13:38:34 +00:00
|
|
|
CI run: $(basename "$0") --disable-htop -- --verify-finalization
|
2020-02-18 23:33:26 +00:00
|
|
|
|
2022-03-11 12:44:56 +00:00
|
|
|
-h, --help show this help message
|
2020-07-30 00:46:10 +00:00
|
|
|
-n, --nodes number of nodes to launch (default: ${NUM_NODES})
|
|
|
|
-g, --with-ganache simulate a genesis event based on a deposit contract
|
2020-09-01 13:38:34 +00:00
|
|
|
-s, --stop-at-epoch stop simulation at epoch (default: infinite)
|
2020-07-30 00:46:10 +00:00
|
|
|
-d, --data-dir directory where all the node data and logs will end up
|
|
|
|
(default: "${DATA_DIR}")
|
2021-07-16 10:02:27 +00:00
|
|
|
--preset Const preset to be (default: mainnet)
|
2020-07-30 00:46:10 +00:00
|
|
|
--base-port bootstrap node's Eth2 traffic port (default: ${BASE_PORT})
|
2022-02-12 11:27:43 +00:00
|
|
|
--base-rest-port bootstrap node's REST port (default: ${BASE_REST_PORT})
|
2022-11-30 10:47:11 +00:00
|
|
|
--base-metrics-port bootstrap node's metrics port (default: ${BASE_METRICS_PORT})
|
2023-01-04 17:59:35 +00:00
|
|
|
--base-vc-keymanager-port The first validator client keymanager port (default: ${BASE_VC_KEYMANAGER_PORT})
|
2022-11-30 10:47:11 +00:00
|
|
|
--base-vc-metrics-port The first validator client metrics port (default: ${BASE_VC_METRICS_PORT})
|
2023-02-23 02:10:07 +00:00
|
|
|
--base-remote-signer-port first remote signer's port (default: ${BASE_REMOTE_SIGNER_PORT})
|
|
|
|
--base-remote-signer-metrics-port first remote signer's metrics port (default: ${BASE_REMOTE_SIGNER_METRICS_PORT})
|
2022-07-23 14:28:10 +00:00
|
|
|
--base-el-net-port first EL's network traffic port (default: ${BASE_EL_NET_PORT})
|
2023-02-23 02:10:07 +00:00
|
|
|
--base-el-rpc-port first EL's HTTP JSON-RPC port (default: ${BASE_EL_RPC_PORT})
|
2022-07-23 14:28:10 +00:00
|
|
|
--base-el-ws-port first EL's WebSocket web3 port (default: ${BASE_EL_WS_PORT})
|
|
|
|
--base-el-auth-rpc-port first EL's authenticated engine API port (default: ${BASE_EL_AUTH_RPC_PORT})
|
|
|
|
--el-port-offset offset to apply between ports of multiple ELs (default: ${EL_PORT_OFFSET})
|
2020-11-07 18:00:31 +00:00
|
|
|
--disable-htop don't use "htop" to see the nimbus_beacon_node processes
|
2022-03-11 12:44:56 +00:00
|
|
|
--disable-vc don't use validator client binaries for validators
|
|
|
|
(by default validators are split 50/50 between beacon nodes
|
|
|
|
and validator clients, with all beacon nodes being paired up
|
|
|
|
with a corresponding validator client)
|
|
|
|
--lighthouse-vc-nodes number of Lighthouse VC nodes (assigned before Nimbus VC nodes, default: ${LIGHTHOUSE_VC_NODES})
|
2022-05-10 10:03:40 +00:00
|
|
|
--enable-logtrace display logtrace analysis
|
2022-03-11 12:44:56 +00:00
|
|
|
--log-level set the log level (default: "${LOG_LEVEL}")
|
2020-07-30 00:46:10 +00:00
|
|
|
--reuse-existing-data-dir instead of deleting and recreating the data dir, keep it and reuse everything we can from it
|
2022-03-11 12:44:56 +00:00
|
|
|
--reuse-binaries don't (re)build the binaries we need and don't delete them at the end (speeds up testing)
|
2021-02-02 18:02:52 +00:00
|
|
|
--timeout timeout in seconds (default: ${TIMEOUT_DURATION} - no timeout)
|
2021-07-27 15:57:16 +00:00
|
|
|
--kill-old-processes if any process is found listening on a port we use, kill it (default: disabled)
|
2021-11-30 18:56:22 +00:00
|
|
|
--eth2-docker-image use docker image instead of compiling the beacon node
|
2022-05-10 00:32:12 +00:00
|
|
|
--remote-validators-count number of remote validators which will be generated
|
|
|
|
--threshold used by a threshold secret sharing mechanism and determine how many shares are need to
|
|
|
|
restore signature of the original secret key
|
2023-05-25 15:05:38 +00:00
|
|
|
--signer-nodes number of remote signer nodes
|
|
|
|
--signer-type a script in the scripts/signers directory, used to launch remote signers
|
2022-05-31 10:45:37 +00:00
|
|
|
--light-clients number of light clients
|
2023-02-23 02:10:07 +00:00
|
|
|
--run-nimbus-eth1 Run nimbush-eth1 as EL
|
2022-06-27 08:34:12 +00:00
|
|
|
--run-geth Run geth EL clients
|
|
|
|
--dl-geth Download geth binary if not found
|
2023-02-23 02:10:07 +00:00
|
|
|
--dl-nimbus-eth2 Download Nimbus CL binary
|
2022-06-27 08:34:12 +00:00
|
|
|
--verbose Verbose output
|
2020-02-18 23:33:26 +00:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2020-07-29 12:08:27 +00:00
|
|
|
! PARSED=$(${GETOPT_BINARY} --options=${OPTS} --longoptions=${LONGOPTS} --name "$0" -- "$@")
|
2022-03-11 12:44:56 +00:00
|
|
|
if [[ ${PIPESTATUS[0]} != 0 ]]; then
|
2020-07-30 00:46:10 +00:00
|
|
|
# getopt has complained about wrong arguments to stdout
|
|
|
|
exit 1
|
2020-02-18 23:33:26 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# read getopt's output this way to handle the quoting right
|
|
|
|
eval set -- "$PARSED"
|
|
|
|
while true; do
|
2020-07-30 00:46:10 +00:00
|
|
|
case "$1" in
|
|
|
|
-h|--help)
|
|
|
|
print_help
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
-n|--nodes)
|
|
|
|
NUM_NODES="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2023-05-25 15:05:38 +00:00
|
|
|
--signer-nodes)
|
|
|
|
SIGNER_NODES=$2
|
2023-02-23 02:10:07 +00:00
|
|
|
shift 2
|
|
|
|
;;
|
2023-05-25 15:05:38 +00:00
|
|
|
--signer-type)
|
|
|
|
SIGNER_TYPE=$2
|
2022-05-10 00:32:12 +00:00
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
--remote-validators-count)
|
|
|
|
REMOTE_VALIDATORS_COUNT=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
--threshold)
|
|
|
|
REMOTE_SIGNER_THRESHOLD=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
2020-07-30 00:46:10 +00:00
|
|
|
-d|--data-dir)
|
|
|
|
DATA_DIR="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2021-07-16 10:02:27 +00:00
|
|
|
--preset)
|
|
|
|
CONST_PRESET="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2023-02-23 02:10:07 +00:00
|
|
|
--capella-fork-epoch)
|
|
|
|
CAPELLA_FORK_EPOCH="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
--deneb-fork-epoch)
|
|
|
|
DENEB_FORK_EPOCH="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2021-02-02 18:02:52 +00:00
|
|
|
--stop-at-epoch)
|
2023-02-23 02:10:07 +00:00
|
|
|
STOP_AT_EPOCH=$2
|
2023-08-30 11:15:19 +00:00
|
|
|
STOP_AT_EPOCH_FLAG="--debug-stop-at-epoch=$2"
|
2021-02-02 18:02:52 +00:00
|
|
|
shift 2
|
|
|
|
;;
|
2020-07-30 00:46:10 +00:00
|
|
|
--disable-htop)
|
|
|
|
USE_HTOP="0"
|
|
|
|
shift
|
|
|
|
;;
|
2020-09-01 13:38:34 +00:00
|
|
|
--disable-vc)
|
|
|
|
USE_VC="0"
|
|
|
|
shift
|
|
|
|
;;
|
2023-04-27 21:21:01 +00:00
|
|
|
--use-vc)
|
|
|
|
USE_VC="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2023-02-23 02:10:07 +00:00
|
|
|
--enable-payload-builder)
|
|
|
|
USE_PAYLOAD_BUILDER="true"
|
|
|
|
shift
|
|
|
|
;;
|
2021-02-02 18:02:52 +00:00
|
|
|
--enable-logtrace)
|
|
|
|
ENABLE_LOGTRACE="1"
|
2020-07-30 00:46:10 +00:00
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--log-level)
|
|
|
|
LOG_LEVEL="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
--base-port)
|
|
|
|
BASE_PORT="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2022-02-12 11:27:43 +00:00
|
|
|
--base-rest-port)
|
|
|
|
BASE_REST_PORT="$2"
|
2020-09-01 13:38:34 +00:00
|
|
|
shift 2
|
|
|
|
;;
|
2020-07-30 00:46:10 +00:00
|
|
|
--base-metrics-port)
|
|
|
|
BASE_METRICS_PORT="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2023-01-04 17:59:35 +00:00
|
|
|
--base-vc-keymanager-port)
|
|
|
|
BASE_VC_KEYMANAGER_PORT="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2022-11-30 10:47:11 +00:00
|
|
|
--base-vc-metrics-port)
|
|
|
|
BASE_VC_METRICS_PORT="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2022-07-23 14:28:10 +00:00
|
|
|
--base-remote-signer-port)
|
|
|
|
BASE_REMOTE_SIGNER_PORT="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2023-02-23 02:10:07 +00:00
|
|
|
--base-remote-signer-metrics-port)
|
|
|
|
BASE_REMOTE_SIGNER_METRICS_PORT="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2022-07-23 14:28:10 +00:00
|
|
|
--base-el-net-port)
|
|
|
|
BASE_EL_NET_PORT="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2023-02-23 02:10:07 +00:00
|
|
|
--base-el-rpc-port)
|
|
|
|
BASE_EL_RPC_PORT="$2"
|
2022-07-23 14:28:10 +00:00
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
--base-el-ws-port)
|
|
|
|
BASE_EL_WS_PORT="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
--base-el-auth-rpc-port)
|
|
|
|
BASE_EL_AUTH_RPC_PORT="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
--el-port-offset)
|
|
|
|
EL_PORT_OFFSET="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2020-07-30 00:46:10 +00:00
|
|
|
--reuse-existing-data-dir)
|
|
|
|
REUSE_EXISTING_DATA_DIR="1"
|
|
|
|
shift
|
|
|
|
;;
|
2022-03-11 12:44:56 +00:00
|
|
|
--reuse-binaries)
|
|
|
|
REUSE_BINARIES="1"
|
|
|
|
shift
|
|
|
|
;;
|
2021-02-02 18:02:52 +00:00
|
|
|
--timeout)
|
|
|
|
TIMEOUT_DURATION="$2"
|
|
|
|
shift 2
|
2020-08-16 09:12:19 +00:00
|
|
|
;;
|
2021-07-27 15:57:16 +00:00
|
|
|
--kill-old-processes)
|
|
|
|
KILL_OLD_PROCESSES="1"
|
|
|
|
shift
|
|
|
|
;;
|
2021-11-30 18:56:22 +00:00
|
|
|
--eth2-docker-image)
|
|
|
|
ETH2_DOCKER_IMAGE="$2"
|
|
|
|
shift 2
|
2022-07-12 11:38:50 +00:00
|
|
|
# TODO The validator client and light client are not being shipped with
|
|
|
|
# our docker images, so we must disable them:
|
|
|
|
echo "warning: --eth-docker-image implies --disable-vc --light-clients=0"
|
2021-11-30 18:56:22 +00:00
|
|
|
USE_VC="0"
|
2022-07-12 11:38:50 +00:00
|
|
|
LC_NODES="0"
|
2021-11-30 18:56:22 +00:00
|
|
|
;;
|
2022-03-11 12:44:56 +00:00
|
|
|
--lighthouse-vc-nodes)
|
|
|
|
LIGHTHOUSE_VC_NODES="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2022-05-31 10:45:37 +00:00
|
|
|
--light-clients)
|
|
|
|
LC_NODES="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2022-06-27 08:34:12 +00:00
|
|
|
--run-geth)
|
|
|
|
RUN_GETH="1"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--dl-geth)
|
|
|
|
DL_GETH="1"
|
|
|
|
shift
|
|
|
|
;;
|
2023-02-23 02:10:07 +00:00
|
|
|
--dl-nimbus-eth2)
|
|
|
|
DL_NIMBUS_ETH2="1"
|
2022-08-12 14:41:11 +00:00
|
|
|
shift
|
|
|
|
;;
|
2023-02-23 02:10:07 +00:00
|
|
|
--run-nimbus-eth1)
|
|
|
|
RUN_NIMBUS_ETH1="1"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--dl-nimbus-eth1)
|
|
|
|
DL_NIMBUS_ETH1="1"
|
2022-06-27 08:34:12 +00:00
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--verbose)
|
|
|
|
VERBOSE="1"
|
|
|
|
shift
|
|
|
|
;;
|
2020-07-30 00:46:10 +00:00
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "argument parsing error"
|
|
|
|
print_help
|
|
|
|
exit 1
|
|
|
|
esac
|
2020-02-18 23:33:26 +00:00
|
|
|
done
|
2022-07-12 11:38:50 +00:00
|
|
|
if [[ -n "${ETH2_DOCKER_IMAGE}" ]]; then
|
|
|
|
if (( USE_VC || LC_NODES )); then
|
|
|
|
echo "invalid config: USE_VC=${USE_VC} LC_NODES=${LC_NODES}"
|
|
|
|
false
|
|
|
|
fi
|
|
|
|
fi
|
2020-02-18 23:33:26 +00:00
|
|
|
|
2020-02-26 00:14:20 +00:00
|
|
|
# when sourcing env.sh, it will try to execute $@, so empty it
|
|
|
|
EXTRA_ARGS="$@"
|
|
|
|
if [[ $# != 0 ]]; then
|
2020-07-30 00:46:10 +00:00
|
|
|
shift $#
|
2020-02-26 00:14:20 +00:00
|
|
|
fi
|
2020-02-18 23:33:26 +00:00
|
|
|
|
2020-07-30 00:46:10 +00:00
|
|
|
if [[ "$REUSE_EXISTING_DATA_DIR" == "0" ]]; then
|
2022-06-27 08:34:12 +00:00
|
|
|
log "Deleting ${DATA_DIR}"
|
2020-07-30 00:46:10 +00:00
|
|
|
rm -rf "${DATA_DIR}"
|
|
|
|
fi
|
2020-06-01 19:48:20 +00:00
|
|
|
|
2023-05-25 15:05:38 +00:00
|
|
|
rm -rf "${DATA_DIR}/pids/*"
|
|
|
|
mkdir -p "${DATA_DIR}/pids" "${DATA_DIR}/logs"
|
|
|
|
|
2022-03-11 12:44:56 +00:00
|
|
|
if [[ "${LIGHTHOUSE_VC_NODES}" != "0" && "${CONST_PRESET}" != "mainnet" ]]; then
|
|
|
|
echo "The prebuilt Lighthouse binary we're using only supports mainnet. Aborting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-07-13 11:15:07 +00:00
|
|
|
scripts/makedir.sh "${DATA_DIR}"
|
2022-08-19 10:30:07 +00:00
|
|
|
echo x > "${DATA_DIR}/keymanager-token"
|
2020-08-25 13:16:45 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
JWT_FILE="${DATA_DIR}/jwtsecret"
|
|
|
|
echo "Generating JWT file '$JWT_FILE'..."
|
|
|
|
openssl rand -hex 32 | tr -d "\n" > "${JWT_FILE}"
|
|
|
|
|
|
|
|
if [[ "$CONST_PRESET" == "minimal" ]]; then
|
|
|
|
SECONDS_PER_SLOT=6
|
|
|
|
SLOTS_PER_EPOCH=8
|
|
|
|
else
|
|
|
|
SECONDS_PER_SLOT=12
|
|
|
|
SLOTS_PER_EPOCH=32
|
|
|
|
fi
|
|
|
|
|
2020-07-27 19:26:30 +00:00
|
|
|
VALIDATORS_DIR="${DATA_DIR}/validators"
|
2021-07-13 11:15:07 +00:00
|
|
|
scripts/makedir.sh "${VALIDATORS_DIR}"
|
2020-06-01 19:48:20 +00:00
|
|
|
|
|
|
|
SECRETS_DIR="${DATA_DIR}/secrets"
|
2021-07-13 11:15:07 +00:00
|
|
|
scripts/makedir.sh "${SECRETS_DIR}"
|
2020-06-01 19:48:20 +00:00
|
|
|
|
2021-07-16 10:02:27 +00:00
|
|
|
USER_VALIDATORS=8
|
2022-10-04 16:44:20 +00:00
|
|
|
TOTAL_VALIDATORS=1024
|
2020-01-20 22:28:48 +00:00
|
|
|
|
2022-03-11 12:44:56 +00:00
|
|
|
# "Make" binary
|
|
|
|
if [[ "${OS}" == "windows" ]]; then
|
2020-07-30 00:46:10 +00:00
|
|
|
MAKE="mingw32-make"
|
2020-02-18 23:33:26 +00:00
|
|
|
else
|
2020-07-30 00:46:10 +00:00
|
|
|
MAKE="make"
|
2020-02-18 23:33:26 +00:00
|
|
|
fi
|
|
|
|
|
2021-02-11 18:28:37 +00:00
|
|
|
# number of CPU cores
|
|
|
|
if uname | grep -qi darwin; then
|
|
|
|
NPROC="$(sysctl -n hw.logicalcpu)"
|
|
|
|
else
|
|
|
|
NPROC="$(nproc)"
|
|
|
|
fi
|
|
|
|
|
2022-08-12 14:41:11 +00:00
|
|
|
# Kill all processes which have open ports in the array passed as parameter
|
|
|
|
kill_by_port() {
|
|
|
|
local ports=("$@")
|
|
|
|
for PORT in "${ports[@]}"; do
|
|
|
|
for PID in $(lsof -n -i tcp:${PORT} -sTCP:LISTEN -t); do
|
|
|
|
echo -n "Found old process listening on port ${PORT}, with PID ${PID}. "
|
|
|
|
if [[ "${KILL_OLD_PROCESSES}" == "1" ]]; then
|
|
|
|
echo "Killing it."
|
2022-09-22 11:55:50 +00:00
|
|
|
kill -SIGKILL "${PID}" || true
|
2022-08-12 14:41:11 +00:00
|
|
|
else
|
|
|
|
echo "Aborting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-11-16 10:12:20 +00:00
|
|
|
GETH_NUM_NODES="$(( NUM_NODES + LC_NODES ))"
|
2023-02-23 02:10:07 +00:00
|
|
|
NIMBUS_ETH1_NUM_NODES="$(( NUM_NODES + LC_NODES ))"
|
2023-05-25 15:05:38 +00:00
|
|
|
LAST_SIGNER_NODE_IDX=$(( SIGNER_NODES - 1 ))
|
2023-02-23 02:10:07 +00:00
|
|
|
|
|
|
|
if [[ "${RUN_GETH}" == "1" ]]; then
|
|
|
|
source "${SCRIPTS_DIR}/geth_binaries.sh"
|
|
|
|
|
|
|
|
if [[ $DENEB_FORK_EPOCH -lt $STOP_AT_EPOCH ]]; then
|
2023-03-12 01:47:24 +00:00
|
|
|
download_geth_deneb
|
|
|
|
GETH_BINARY="$GETH_DENEB_BINARY"
|
2023-02-23 02:10:07 +00:00
|
|
|
else
|
|
|
|
download_geth_capella
|
|
|
|
GETH_BINARY="$GETH_CAPELLA_BINARY"
|
|
|
|
fi
|
|
|
|
|
|
|
|
source ./scripts/geth_vars.sh
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${RUN_NIMBUS_ETH1}" == "1" ]]; then
|
|
|
|
. ./scripts/nimbus_el_vars.sh
|
|
|
|
fi
|
2022-08-12 14:41:11 +00:00
|
|
|
|
2021-07-27 15:57:16 +00:00
|
|
|
# kill lingering processes from a previous run
|
2022-03-11 12:44:56 +00:00
|
|
|
if [[ "${OS}" != "windows" ]]; then
|
|
|
|
which lsof &>/dev/null || \
|
|
|
|
{ echo "'lsof' not installed and we need it to check for ports already in use. Aborting."; exit 1; }
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
# Stop geth nodes
|
2022-06-27 08:34:12 +00:00
|
|
|
if [[ "${RUN_GETH}" == "1" ]]; then
|
2023-02-23 02:10:07 +00:00
|
|
|
for GETH_NODE_IDX in $(seq 0 $GETH_LAST_NODE_IDX); do
|
|
|
|
for PORT in ${GETH_NET_PORTS[GETH_NODE_IDX]} \
|
|
|
|
${GETH_RPC_PORTS[GETH_NODE_IDX]} \
|
|
|
|
${GETH_AUTH_RPC_PORTS[GETH_NODE_IDX]};
|
2022-08-12 14:41:11 +00:00
|
|
|
do
|
|
|
|
PORTS_TO_KILL+=("${PORT}")
|
2022-06-27 08:34:12 +00:00
|
|
|
done
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
# Stop Nimbus EL nodes
|
|
|
|
if [[ "${RUN_NIMBUS_ETH1}" == "1" ]]; then
|
|
|
|
for NIMBUS_ETH1_NODE_IDX in $(seq 0 $NIMBUS_ETH1_LAST_NODE_IDX); do
|
2023-02-27 19:39:50 +00:00
|
|
|
for PORT in ${NIMBUS_ETH1_NET_PORTS[NIMBUS_ETH1_NODE_IDX]} \
|
|
|
|
${NIMBUS_ETH1_RPC_PORTS[NIMBUS_ETH1_NODE_IDX]} \
|
|
|
|
${NIMBUS_ETH1_AUTH_RPC_PORTS[NIMBUS_ETH1_NODE_IDX]};
|
2022-08-12 14:41:11 +00:00
|
|
|
do
|
|
|
|
PORTS_TO_KILL+=("${PORT}")
|
2022-06-27 08:34:12 +00:00
|
|
|
done
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
# Stop Remote Signers
|
2023-05-25 15:05:38 +00:00
|
|
|
for NUM_REMOTE in $(seq 0 $LAST_SIGNER_NODE_IDX); do
|
2023-02-23 02:10:07 +00:00
|
|
|
for PORT in $(( BASE_REMOTE_SIGNER_PORT + NUM_REMOTE )) \
|
|
|
|
$(( BASE_REMOTE_SIGNER_METRICS_PORT + NUM_REMOTE )) ; do
|
|
|
|
PORTS_TO_KILL+=("${PORT}")
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
# Stop Nimbus validator clients
|
|
|
|
if [[ "${USE_VC}" == "1" ]]; then
|
|
|
|
for NUM_NODE in $(seq 1 $NUM_NODES); do
|
|
|
|
for PORT in $(( BASE_VC_METRICS_PORT + NUM_NODE - 1 )) \
|
|
|
|
$(( BASE_VC_KEYMANAGER_PORT + NUM_NODE - 1 )); do
|
|
|
|
PORTS_TO_KILL+=("${PORT}")
|
|
|
|
done
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Stop Nimbus CL nodes
|
|
|
|
for NUM_NODE in $(seq 1 $NUM_NODES); do
|
|
|
|
for PORT in $(( BASE_PORT + NUM_NODE - 1 )) $(( BASE_METRICS_PORT + NUM_NODE - 1)) $(( BASE_REST_PORT + NUM_NODE - 1)); do
|
2022-08-12 14:41:11 +00:00
|
|
|
PORTS_TO_KILL+=("${PORT}")
|
2021-07-27 15:57:16 +00:00
|
|
|
done
|
|
|
|
done
|
2022-08-12 14:41:11 +00:00
|
|
|
|
|
|
|
kill_by_port "${PORTS_TO_KILL[@]}"
|
2021-08-05 08:49:34 +00:00
|
|
|
fi
|
2021-07-27 15:57:16 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
download_web3signer() {
|
|
|
|
if [[ ! -d "${WEB3SIGNER_DIR}" ]]; then
|
|
|
|
log "Downloading Web3Signer binary"
|
2022-08-12 14:41:11 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
WEB3SIGNER_TARBALL="web3signer-${WEB3SIGNER_VERSION}.tar.gz"
|
|
|
|
WEB3SIGNER_URL="https://artifacts.consensys.net/public/web3signer/raw/names/web3signer.tar.gz/versions/${WEB3SIGNER_VERSION}/${WEB3SIGNER_TARBALL}"
|
2022-06-27 08:34:12 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
mkdir -p "${WEB3SIGNER_DIR}"
|
|
|
|
"${CURL_BINARY}" -sSL "${WEB3SIGNER_URL}" \
|
|
|
|
| tar -xzf - --directory "${WEB3SIGNER_DIR}" --strip-components=1
|
|
|
|
fi
|
|
|
|
}
|
2022-06-27 08:34:12 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
download_nimbus_eth1() {
|
|
|
|
if [[ ! -e "${NIMBUS_ETH1_BINARY}" ]]; then
|
|
|
|
case "${OS}-${ARCH}" in
|
|
|
|
linux-amd64|linux-x86_64)
|
|
|
|
NIMBUS_ETH1_PLATFORM=Linux_amd64
|
|
|
|
;;
|
|
|
|
linux-arm|linux-arm32|linux-aarch32)
|
|
|
|
NIMBUS_PLATFORM=Linux_arm32v7
|
|
|
|
;;
|
|
|
|
linux-arm64|linux-aarch64)
|
|
|
|
NIMBUS_ETH1_PLATFORM=Linux_arm64v8
|
|
|
|
;;
|
|
|
|
macos-amd64|macos-x86_64)
|
|
|
|
NIMBUS_ETH1_PLATFORM=macOS_arm64
|
|
|
|
;;
|
|
|
|
macos-arm64|macos-aarch64)
|
|
|
|
NIMBUS_ETH1_PLATFORM=macOS_amd64
|
|
|
|
;;
|
|
|
|
windows-amd64|windows-x86_64)
|
|
|
|
NIMBUS_ETH1_PLATFORM=Windows_amd64
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "No nimbus-eth1 binaries available for ${OS}-${ARCH}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2022-06-27 08:34:12 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
NIMBUS_ETH1_FULL_BINARY_VERSION=20221205_f4cacdfc
|
|
|
|
NIMBUS_ETH1_TARBALL_NAME="nimbus-eth1_${NIMBUS_ETH1_PLATFORM}_${NIMBUS_ETH1_FULL_BINARY_VERSION}.tar.gz"
|
|
|
|
|
|
|
|
NIMBUS_ETH1_TARBALL_URL="https://github.com/status-im/nimbus-simulation-binaries/raw/master/nimbus-eth1/nightly-20221205/${NIMBUS_ETH1_TARBALL_NAME}"
|
|
|
|
|
|
|
|
log "Downloading Nimbus ETH1 binary"
|
2022-06-27 08:34:12 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
"${CURL_BINARY}" -o "$NIMBUS_ETH1_TARBALL_NAME" -sSLO "$NIMBUS_ETH1_TARBALL_URL"
|
2022-06-27 08:34:12 +00:00
|
|
|
local tmp_extract_dir
|
2023-02-23 02:10:07 +00:00
|
|
|
tmp_extract_dir=$(mktemp -d nimbus-eth1-tarball-XXX)
|
|
|
|
CLEANUP_DIRS+=("$tmp_extract_dir")
|
|
|
|
tar -xzf "${NIMBUS_ETH1_TARBALL_NAME}" -C "$tmp_extract_dir" --strip-components=1
|
|
|
|
mkdir -p "$(dirname "$NIMBUS_ETH1_BINARY")"
|
2023-03-17 18:43:52 +00:00
|
|
|
mv "$tmp_extract_dir/build/nimbus$EXE_EXTENSION" "$NIMBUS_ETH1_BINARY"
|
2023-02-23 02:10:07 +00:00
|
|
|
chmod +x "$NIMBUS_ETH1_BINARY"
|
2023-03-30 16:37:29 +00:00
|
|
|
patchelf_when_on_nixos "$NIMBUS_ETH1_BINARY"
|
2022-06-27 08:34:12 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
download_nimbus_eth2() {
|
|
|
|
if [[ ! -e "${BEACON_NODE_COMMAND}" ]]; then
|
|
|
|
case "${OS}-${ARCH}" in
|
|
|
|
linux-amd64|linux-x86_64)
|
|
|
|
NIMBUS_PLATFORM=Linux_amd64
|
|
|
|
;;
|
|
|
|
linux-arm|linux-arm32|linux-aarch32)
|
|
|
|
NIMBUS_PLATFORM=Linux_arm32v7
|
|
|
|
;;
|
|
|
|
linux-arm64|linux-aarch64)
|
|
|
|
NIMBUS_PLATFORM=Linux_arm64v8
|
|
|
|
;;
|
|
|
|
macos-amd64|macos-x86_64)
|
|
|
|
NIMBUS_PLATFORM=macOS_amd64
|
|
|
|
;;
|
|
|
|
macos-arm64|macos-aarch64)
|
|
|
|
NIMBUS_PLATFORM=macOS_arm64
|
|
|
|
;;
|
|
|
|
windows-amd64|windows-x86_64)
|
|
|
|
NIMBUS_PLATFORM=Windows_amd64
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
NIMBUS_ETH2_FULL_BINARY_VERSION="${NIMBUS_ETH2_VERSION}_${NIMBUS_ETH2_REVISION}"
|
|
|
|
NIMBUS_ETH2_TARBALL_NAME="nimbus-eth2_${NIMBUS_PLATFORM}_${NIMBUS_ETH2_FULL_BINARY_VERSION}.tar.gz"
|
|
|
|
NIMBUS_ETH2_TARBALL_URL="https://github.com/status-im/nimbus-eth2/releases/download/v${NIMBUS_ETH2_VERSION}/${NIMBUS_ETH2_TARBALL_NAME}"
|
2022-08-12 14:41:11 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
log "Downloading Nimbus ETH2 binary"
|
|
|
|
"${CURL_BINARY}" -o "$NIMBUS_ETH2_TARBALL_NAME" -sSL "$NIMBUS_ETH2_TARBALL_URL"
|
|
|
|
local tmp_extract_dir
|
|
|
|
tmp_extract_dir=$(mktemp -d nimbus-eth2-tarball-XXX)
|
|
|
|
CLEANUP_DIRS+=("$tmp_extract_dir")
|
|
|
|
tar -xzf "${NIMBUS_ETH2_TARBALL_NAME}" -C "$tmp_extract_dir" --strip-components=1
|
|
|
|
mkdir -p "$(dirname "$BEACON_NODE_COMMAND")"
|
2023-03-17 18:43:52 +00:00
|
|
|
mv "$tmp_extract_dir/build/nimbus_beacon_node$EXE_EXTENSION" "$BEACON_NODE_COMMAND"
|
2023-02-23 02:10:07 +00:00
|
|
|
chmod +x "$BEACON_NODE_COMMAND"
|
2023-04-05 16:12:28 +00:00
|
|
|
patchelf_when_on_nixos "$BEACON_NODE_COMMAND"
|
2022-08-12 14:41:11 +00:00
|
|
|
|
|
|
|
REUSE_BINARIES=1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-03-11 12:44:56 +00:00
|
|
|
# Download the Lighthouse binary.
|
|
|
|
LH_VERSION="2.1.3"
|
|
|
|
LH_ARCH="${ARCH}"
|
|
|
|
if [[ "${LH_ARCH}" == "arm64" ]]; then
|
|
|
|
LH_ARCH="aarch64"
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "${OS}" in
|
|
|
|
linux)
|
|
|
|
LH_TARBALL="lighthouse-v${LH_VERSION}-${LH_ARCH}-unknown-linux-gnu-portable.tar.gz"
|
|
|
|
;;
|
|
|
|
macos)
|
|
|
|
LH_TARBALL="lighthouse-v${LH_VERSION}-${LH_ARCH}-apple-darwin-portable.tar.gz"
|
|
|
|
;;
|
|
|
|
windows)
|
|
|
|
LH_TARBALL="lighthouse-v${LH_VERSION}-${LH_ARCH}-windows-portable.tar.gz"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
LH_URL="https://github.com/sigp/lighthouse/releases/download/v${LH_VERSION}/${LH_TARBALL}"
|
2023-03-17 18:43:52 +00:00
|
|
|
LH_BINARY="lighthouse-${LH_VERSION}${EXE_EXTENSION}"
|
2022-03-11 12:44:56 +00:00
|
|
|
|
|
|
|
if [[ "${USE_VC}" == "1" && "${LIGHTHOUSE_VC_NODES}" != "0" && ! -e "build/${LH_BINARY}" ]]; then
|
2022-06-27 08:34:12 +00:00
|
|
|
echo "Downloading Lighthouse binary"
|
2022-03-11 12:44:56 +00:00
|
|
|
pushd "build" >/dev/null
|
2022-05-31 10:45:37 +00:00
|
|
|
"${CURL_BINARY}" -sSLO "${LH_URL}"
|
2022-03-11 12:44:56 +00:00
|
|
|
tar -xzf "${LH_TARBALL}" # contains just one file named "lighthouse"
|
|
|
|
rm lighthouse-* # deletes both the tarball and old binary versions
|
2023-03-17 18:43:52 +00:00
|
|
|
mv "lighthouse$EXE_EXTENSION" "${LH_BINARY}"
|
2022-03-11 12:44:56 +00:00
|
|
|
popd >/dev/null
|
|
|
|
fi
|
|
|
|
|
2023-04-05 16:12:28 +00:00
|
|
|
BINARIES="ncli_testnet"
|
|
|
|
|
|
|
|
if [[ "$LC_NODES" -ge "1" ]]; then
|
|
|
|
BINARIES="${BINARIES} nimbus_light_client"
|
|
|
|
fi
|
|
|
|
|
2023-05-25 15:05:38 +00:00
|
|
|
if [[ "$SIGNER_NODES" -gt "0" ]]; then
|
|
|
|
if [[ "$SIGNER_TYPE" == "nimbus" ]]; then
|
|
|
|
BINARIES="${BINARIES} nimbus_signing_node"
|
|
|
|
elif [[ "$SIGNER_TYPE" == "web3signer" ]]; then
|
|
|
|
download_web3signer
|
|
|
|
fi
|
2023-04-05 16:12:28 +00:00
|
|
|
fi
|
2022-03-11 12:44:56 +00:00
|
|
|
|
2022-08-12 14:41:11 +00:00
|
|
|
# Don't build binaries if we are downloading them
|
2023-02-23 02:10:07 +00:00
|
|
|
if [[ "${DL_NIMBUS_ETH2}" != "1" ]]; then
|
2022-08-12 14:41:11 +00:00
|
|
|
# Build the binaries
|
2021-11-30 18:56:22 +00:00
|
|
|
|
2022-08-12 14:41:11 +00:00
|
|
|
if [[ "${USE_VC}" == "1" ]]; then
|
|
|
|
BINARIES="${BINARIES} nimbus_validator_client"
|
|
|
|
fi
|
|
|
|
|
|
|
|
BINARIES="${BINARIES} nimbus_beacon_node"
|
2020-08-16 09:12:19 +00:00
|
|
|
fi
|
2021-07-16 10:02:27 +00:00
|
|
|
|
2022-03-11 12:44:56 +00:00
|
|
|
if [[ -n "${ETH2_DOCKER_IMAGE}" ]]; then
|
|
|
|
DATA_DIR_FULL_PATH="$(cd "${DATA_DIR}"; pwd)"
|
2021-11-30 18:56:22 +00:00
|
|
|
# CONTAINER_DATA_DIR must be used everywhere where paths are supplied to BEACON_NODE_COMMAND executions.
|
|
|
|
# We'll use the CONTAINER_ prefix throughout the file to indicate such paths.
|
2022-03-11 12:44:56 +00:00
|
|
|
CONTAINER_DATA_DIR="/home/user/nimbus-eth2/testnet"
|
2021-11-30 18:56:22 +00:00
|
|
|
BEACON_NODE_COMMAND="docker run -v /etc/passwd:/etc/passwd -u $(id -u):$(id -g) --net=host -v ${DATA_DIR_FULL_PATH}:${CONTAINER_DATA_DIR}:rw $ETH2_DOCKER_IMAGE"
|
|
|
|
else
|
|
|
|
# When docker is not used CONTAINER_DATA_DIR is just an alias for DATA_DIR
|
2022-03-11 12:44:56 +00:00
|
|
|
CONTAINER_DATA_DIR="${DATA_DIR}"
|
2023-02-23 02:10:07 +00:00
|
|
|
if [[ "${DL_NIMBUS_ETH2}" == "1" ]]; then
|
|
|
|
download_nimbus_eth2
|
2022-08-12 14:41:11 +00:00
|
|
|
fi
|
2021-11-30 18:56:22 +00:00
|
|
|
fi
|
|
|
|
|
2022-03-11 12:44:56 +00:00
|
|
|
BINARIES_MISSING="0"
|
|
|
|
for BINARY in ${BINARIES}; do
|
|
|
|
if [[ ! -e "build/${BINARY}" ]]; then
|
2023-11-26 14:38:19 +00:00
|
|
|
log "Missing binary build/${BINARY}"
|
2022-03-11 12:44:56 +00:00
|
|
|
BINARIES_MISSING="1"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2022-06-27 08:34:12 +00:00
|
|
|
|
2022-03-11 12:44:56 +00:00
|
|
|
if [[ "${REUSE_BINARIES}" == "0" || "${BINARIES_MISSING}" == "1" ]]; then
|
2023-04-05 16:12:28 +00:00
|
|
|
log "Rebuilding binaries ${BINARIES}"
|
2023-10-19 13:12:21 +00:00
|
|
|
${MAKE} -j ${NPROC} LOG_LEVEL=TRACE NIMFLAGS="${NIMFLAGS} -d:local_testnet -d:const_preset=${CONST_PRESET} -d:FIELD_ELEMENTS_PER_BLOB=4096" ${BINARIES}
|
2022-03-11 12:44:56 +00:00
|
|
|
fi
|
2020-01-20 22:28:48 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
if [[ "${RUN_NIMBUS_ETH1}" == "1" ]]; then
|
|
|
|
if [[ "${DL_NIMBUS_ETH1}" == "1" ]]; then
|
|
|
|
download_nimbus_eth1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-08-03 10:12:21 +00:00
|
|
|
# Kill child processes on Ctrl-C/SIGTERM/exit, passing the PID of this shell
|
|
|
|
# instance as the parent and the target process name as a pattern to the
|
|
|
|
# "pkill" command.
|
|
|
|
cleanup() {
|
2023-08-18 22:24:40 +00:00
|
|
|
echo "Current port usage:"
|
|
|
|
lsof -i -P | grep LISTEN
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
echo "Cleaning up"
|
|
|
|
|
|
|
|
# Avoid the trap enterring an infinite loop
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
2022-06-27 08:34:12 +00:00
|
|
|
|
2023-02-27 16:38:57 +00:00
|
|
|
PKILL_ECHO_FLAG='-e'
|
|
|
|
if [[ "${OS}" == "macos" ]]; then
|
|
|
|
PKILL_ECHO_FLAG='-l'
|
|
|
|
fi
|
|
|
|
|
2023-05-25 15:05:38 +00:00
|
|
|
PIDS_TO_KILL=$(find "${DATA_DIR}/pids" -type f -exec cat {} \+ 2>/dev/null)
|
2023-02-27 18:48:07 +00:00
|
|
|
|
2023-05-25 15:05:38 +00:00
|
|
|
echo Terminating processes...
|
|
|
|
for PID in $PIDS_TO_KILL; do
|
|
|
|
kill -SIGTERM $PID 2>/dev/null || true
|
2022-06-27 08:34:12 +00:00
|
|
|
done
|
|
|
|
|
2021-08-03 10:12:21 +00:00
|
|
|
sleep 2
|
2022-06-27 08:34:12 +00:00
|
|
|
|
2023-05-25 15:05:38 +00:00
|
|
|
echo Killing processes...
|
|
|
|
for PID in $PIDS_TO_KILL; do
|
|
|
|
kill -SIGKILL $PID 2>/dev/null || true
|
2022-06-27 08:34:12 +00:00
|
|
|
done
|
2021-08-03 10:12:21 +00:00
|
|
|
|
2022-03-11 12:44:56 +00:00
|
|
|
# Delete all binaries we just built, because these are unusable outside this
|
2021-08-03 10:12:21 +00:00
|
|
|
# local testnet.
|
2022-03-11 12:44:56 +00:00
|
|
|
if [[ "${REUSE_BINARIES}" == "0" ]]; then
|
|
|
|
for BINARY in ${BINARIES}; do
|
|
|
|
rm -f build/${BINARY}
|
|
|
|
done
|
|
|
|
fi
|
2021-11-30 18:56:22 +00:00
|
|
|
|
2022-02-12 11:27:43 +00:00
|
|
|
if [[ -n "$ETH2_DOCKER_IMAGE" ]]; then
|
2021-11-30 18:56:22 +00:00
|
|
|
docker rm $(docker stop $(docker ps -a -q --filter ancestor=$ETH2_DOCKER_IMAGE --format="{{.ID}}"))
|
|
|
|
fi
|
2022-06-27 08:34:12 +00:00
|
|
|
|
|
|
|
if [ ${#CLEANUP_DIRS[@]} -ne 0 ]; then # check if the array is empty
|
|
|
|
for dir in "${CLEANUP_DIRS[@]}"
|
|
|
|
do
|
|
|
|
log "Deleting ${dir}"
|
|
|
|
rm -rf "${dir}"
|
|
|
|
done
|
|
|
|
fi
|
2023-03-01 16:27:55 +00:00
|
|
|
|
|
|
|
echo "Jobs status after cleanup:"
|
|
|
|
jobs
|
2021-08-03 10:12:21 +00:00
|
|
|
}
|
2022-06-27 08:34:12 +00:00
|
|
|
|
2021-08-03 10:12:21 +00:00
|
|
|
trap 'cleanup' SIGINT SIGTERM EXIT
|
|
|
|
|
|
|
|
# timeout - implemented with a background job
|
|
|
|
timeout_reached() {
|
|
|
|
echo -e "\nTimeout reached. Aborting.\n"
|
|
|
|
cleanup
|
|
|
|
}
|
|
|
|
trap 'timeout_reached' SIGALRM
|
|
|
|
|
|
|
|
if [[ "${TIMEOUT_DURATION}" != "0" ]]; then
|
|
|
|
export PARENT_PID=$$
|
|
|
|
( sleep ${TIMEOUT_DURATION} && kill -ALRM ${PARENT_PID} ) 2>/dev/null & WATCHER_PID=$!
|
|
|
|
fi
|
|
|
|
|
2022-05-10 00:32:12 +00:00
|
|
|
REMOTE_URLS=""
|
|
|
|
|
2023-05-25 15:05:38 +00:00
|
|
|
for NUM_REMOTE in $(seq 0 $LAST_SIGNER_NODE_IDX); do
|
2022-05-31 10:45:37 +00:00
|
|
|
REMOTE_PORT=$(( BASE_REMOTE_SIGNER_PORT + NUM_REMOTE ))
|
2022-05-10 00:32:12 +00:00
|
|
|
REMOTE_URLS="${REMOTE_URLS} --remote-signer=http://127.0.0.1:${REMOTE_PORT}"
|
|
|
|
done
|
|
|
|
|
2021-08-03 10:12:21 +00:00
|
|
|
# deposit and testnet creation
|
2020-07-23 20:51:56 +00:00
|
|
|
BOOTSTRAP_TIMEOUT=30 # in seconds
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
RUNTIME_CONFIG_FILE="${DATA_DIR}/config.yaml"
|
2020-09-01 13:38:34 +00:00
|
|
|
NUM_JOBS=${NUM_NODES}
|
2020-06-22 18:22:45 +00:00
|
|
|
|
2021-11-30 18:56:22 +00:00
|
|
|
DEPOSITS_FILE="${DATA_DIR}/deposits.json"
|
|
|
|
CONTAINER_DEPOSITS_FILE="${CONTAINER_DATA_DIR}/deposits.json"
|
2023-02-23 02:10:07 +00:00
|
|
|
CONTAINER_DEPOSIT_TREE_SNAPSHOT_FILE="${CONTAINER_DATA_DIR}/deposit_tree_snapshot.ssz"
|
2021-11-30 18:56:22 +00:00
|
|
|
|
2023-09-15 18:45:55 +00:00
|
|
|
CONTAINER_BOOTSTRAP_NETWORK_KEYFILE="bootstrap_network_key.json"
|
|
|
|
DIRECTPEER_NETWORK_KEYFILE="directpeer_network_key.json"
|
|
|
|
|
|
|
|
|
|
|
|
BOOTSTRAP_NODE=1
|
|
|
|
DIRECTPEER_NODE=2
|
|
|
|
|
2023-05-25 15:05:38 +00:00
|
|
|
if command -v ulimit; then
|
|
|
|
echo "Raising limits"
|
|
|
|
ulimit -n $((TOTAL_VALIDATORS * 10))
|
|
|
|
fi
|
|
|
|
|
2020-07-30 00:46:10 +00:00
|
|
|
if [[ "$REUSE_EXISTING_DATA_DIR" == "0" ]]; then
|
2023-02-23 02:10:07 +00:00
|
|
|
./build/ncli_testnet generateDeposits \
|
2020-07-30 00:46:10 +00:00
|
|
|
--count=${TOTAL_VALIDATORS} \
|
|
|
|
--out-validators-dir="${VALIDATORS_DIR}" \
|
|
|
|
--out-secrets-dir="${SECRETS_DIR}" \
|
2022-05-10 00:32:12 +00:00
|
|
|
--out-deposits-file="${DEPOSITS_FILE}" \
|
|
|
|
--threshold=${REMOTE_SIGNER_THRESHOLD} \
|
|
|
|
--remote-validators-count=${REMOTE_VALIDATORS_COUNT} \
|
|
|
|
${REMOTE_URLS}
|
2020-07-30 00:46:10 +00:00
|
|
|
fi
|
2020-01-20 22:28:48 +00:00
|
|
|
|
2023-11-22 23:19:54 +00:00
|
|
|
GENESIS_OFFSET=60 # See `Scheduling first slot action` > `startTime`
|
2023-02-23 02:10:07 +00:00
|
|
|
NOW_UNIX_TIMESTAMP=$(date +%s)
|
|
|
|
GENESIS_TIME=$((NOW_UNIX_TIMESTAMP + GENESIS_OFFSET))
|
|
|
|
SHANGHAI_FORK_TIME=$((GENESIS_TIME + SECONDS_PER_SLOT * SLOTS_PER_EPOCH * CAPELLA_FORK_EPOCH))
|
2023-11-26 14:38:19 +00:00
|
|
|
CANCUN_FORK_TIME=$((GENESIS_TIME + SECONDS_PER_SLOT * SLOTS_PER_EPOCH * DENEB_FORK_EPOCH))
|
2023-02-23 02:10:07 +00:00
|
|
|
|
|
|
|
EXECUTION_GENESIS_JSON="${DATA_DIR}/execution_genesis.json"
|
|
|
|
EXECUTION_GENESIS_BLOCK_JSON="${DATA_DIR}/execution_genesis_block.json"
|
|
|
|
|
|
|
|
# TODO The storage state of the deposit contract that is baked into the execution genesis state
|
|
|
|
# currently hard-codes some merkle branches that won't match the random deposits generated
|
|
|
|
# by this simulation. This doesn't happen to produce problems only by accident. If we enable
|
|
|
|
# the `deposit_root` safety-checks in the deposit downloader, it will detect the discrepancy.
|
2023-11-26 14:38:19 +00:00
|
|
|
sed "s/SHANGHAI_FORK_TIME/${SHANGHAI_FORK_TIME}/g; s/CANCUN_FORK_TIME/${CANCUN_FORK_TIME}/g" \
|
2023-02-23 02:10:07 +00:00
|
|
|
"${SCRIPTS_DIR}/execution_genesis.json.template" > "$EXECUTION_GENESIS_JSON"
|
|
|
|
|
|
|
|
DEPOSIT_CONTRACT_ADDRESS="0x4242424242424242424242424242424242424242"
|
|
|
|
DEPOSIT_CONTRACT_BLOCK=0
|
|
|
|
|
|
|
|
get_execution_genesis_block() {
|
|
|
|
${CURL_BINARY} -s -X POST \
|
|
|
|
-H 'Content-Type: application/json' \
|
|
|
|
--data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", true],"id":1}' \
|
|
|
|
$1 | jq '.result'
|
|
|
|
}
|
2020-06-22 18:22:45 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
if [[ "${RUN_GETH}" == "1" ]]; then
|
|
|
|
if [[ ! -e "${GETH_BINARY}" ]]; then
|
|
|
|
echo "Missing geth executable"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-07-09 22:08:54 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
source "./scripts/start_geth_nodes.sh"
|
2020-07-09 22:08:54 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
CLEANUP_DIRS+=("${GETH_DATA_DIRS[@]}")
|
|
|
|
MAIN_WEB3_URL="http://127.0.0.1:${GETH_RPC_PORTS[0]}"
|
|
|
|
get_execution_genesis_block "${MAIN_WEB3_URL}" > "$EXECUTION_GENESIS_BLOCK_JSON"
|
|
|
|
fi
|
2020-06-11 13:31:35 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
if [[ "${RUN_NIMBUS_ETH1}" == "1" ]]; then
|
|
|
|
if [[ ! -e "${NIMBUS_ETH1_BINARY}" ]]; then
|
|
|
|
echo "Missing nimbus EL executable"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-06-22 18:22:45 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
source "./scripts/start_nimbus_el_nodes.sh"
|
2020-06-22 18:22:45 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
CLEANUP_DIRS+=("${NIMBUS_ETH1_DATA_DIRS[@]}")
|
2020-06-22 18:22:45 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
MAIN_WEB3_URL="http://127.0.0.1:${NIMBUS_ETH1_RPC_PORTS[0]}"
|
|
|
|
get_execution_genesis_block "$MAIN_WEB3_URL" > "$EXECUTION_GENESIS_BLOCK_JSON.nimbus"
|
|
|
|
if [ -f "$EXECUTION_GENESIS_BLOCK_JSON" ]; then
|
|
|
|
if ! cmp <(jq --compact-output --sort-keys . "$EXECUTION_GENESIS_BLOCK_JSON") <(jq --compact-output --sort-keys . "$EXECUTION_GENESIS_BLOCK_JSON.nimbus"); then
|
|
|
|
echo "Nimbus and Geth disagree regarding the genesis execution block"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
mv "$EXECUTION_GENESIS_BLOCK_JSON.nimbus" "$EXECUTION_GENESIS_BLOCK_JSON"
|
|
|
|
fi
|
2020-06-22 18:22:45 +00:00
|
|
|
fi
|
2020-01-20 22:28:48 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
jq -r '.hash' "$EXECUTION_GENESIS_BLOCK_JSON" > "${DATA_DIR}/deposit_contract_block_hash.txt"
|
|
|
|
|
2023-09-15 18:45:55 +00:00
|
|
|
for NUM_NODE in $(seq 1 $NUM_NODES); do
|
|
|
|
NODE_DATA_DIR="${DATA_DIR}/node${NUM_NODE}"
|
|
|
|
rm -rf "${NODE_DATA_DIR}"
|
|
|
|
scripts/makedir.sh "${NODE_DATA_DIR}" 2>&1
|
|
|
|
done
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
./build/ncli_testnet createTestnet \
|
2023-09-15 18:45:55 +00:00
|
|
|
--data-dir="$CONTAINER_DATA_DIR/node$BOOTSTRAP_NODE" \
|
2023-02-23 02:10:07 +00:00
|
|
|
--deposits-file="$CONTAINER_DEPOSITS_FILE" \
|
|
|
|
--total-validators=$TOTAL_VALIDATORS \
|
|
|
|
--output-genesis="$CONTAINER_DATA_DIR/genesis.ssz" \
|
|
|
|
--output-bootstrap-file="$CONTAINER_DATA_DIR/bootstrap_nodes.txt" \
|
|
|
|
--output-deposit-tree-snapshot="$CONTAINER_DEPOSIT_TREE_SNAPSHOT_FILE" \
|
|
|
|
--bootstrap-address=127.0.0.1 \
|
2023-09-15 18:45:55 +00:00
|
|
|
--bootstrap-port=$(( BASE_PORT + BOOTSTRAP_NODE - 1 )) \
|
|
|
|
--netkey-file=$CONTAINER_BOOTSTRAP_NETWORK_KEYFILE \
|
2023-02-23 02:10:07 +00:00
|
|
|
--insecure-netkey-password=true \
|
|
|
|
--genesis-time=$GENESIS_TIME \
|
|
|
|
--capella-fork-epoch=$CAPELLA_FORK_EPOCH \
|
|
|
|
--deneb-fork-epoch=$DENEB_FORK_EPOCH \
|
|
|
|
--execution-genesis-block="$EXECUTION_GENESIS_BLOCK_JSON"
|
|
|
|
|
2023-09-15 18:45:55 +00:00
|
|
|
DIRECTPEER_ENR=$(
|
|
|
|
./build/ncli_testnet createTestnetEnr \
|
|
|
|
--data-dir="$CONTAINER_DATA_DIR/node$DIRECTPEER_NODE" \
|
|
|
|
--bootstrap-enr="$CONTAINER_DATA_DIR/bootstrap_nodes.txt" \
|
|
|
|
--enr-address=127.0.0.1 \
|
|
|
|
--enr-port=$(( BASE_PORT + DIRECTPEER_NODE - 1 )) \
|
|
|
|
--enr-netkey-file=$DIRECTPEER_NETWORK_KEYFILE \
|
|
|
|
--insecure-netkey-password=true 2>&1 > /dev/null
|
|
|
|
)
|
|
|
|
|
2020-06-10 15:21:32 +00:00
|
|
|
./scripts/make_prometheus_config.sh \
|
2020-07-30 00:46:10 +00:00
|
|
|
--nodes ${NUM_NODES} \
|
|
|
|
--base-metrics-port ${BASE_METRICS_PORT} \
|
|
|
|
--config-file "${DATA_DIR}/prometheus.yml" || true # TODO: this currently fails on macOS,
|
|
|
|
# but it can be considered non-critical
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
cp "$SCRIPTS_DIR/$CONST_PRESET-non-overriden-config.yaml" "$RUNTIME_CONFIG_FILE"
|
2021-08-10 20:46:35 +00:00
|
|
|
# TODO the runtime config file should be used during deposit generation as well!
|
2023-02-23 02:10:07 +00:00
|
|
|
echo Wrote $RUNTIME_CONFIG_FILE:
|
|
|
|
tee -a "$RUNTIME_CONFIG_FILE" <<EOF
|
2021-07-16 10:02:27 +00:00
|
|
|
PRESET_BASE: ${CONST_PRESET}
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: ${TOTAL_VALIDATORS}
|
|
|
|
MIN_GENESIS_TIME: 0
|
|
|
|
GENESIS_DELAY: 10
|
|
|
|
DEPOSIT_CONTRACT_ADDRESS: ${DEPOSIT_CONTRACT_ADDRESS}
|
|
|
|
ETH1_FOLLOW_DISTANCE: 1
|
2023-02-23 02:10:07 +00:00
|
|
|
ALTAIR_FORK_EPOCH: 0
|
|
|
|
BELLATRIX_FORK_EPOCH: 0
|
|
|
|
CAPELLA_FORK_EPOCH: ${CAPELLA_FORK_EPOCH}
|
|
|
|
DENEB_FORK_EPOCH: ${DENEB_FORK_EPOCH}
|
2022-09-08 13:22:31 +00:00
|
|
|
TERMINAL_TOTAL_DIFFICULTY: 0
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
EOF
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
echo $DEPOSIT_CONTRACT_BLOCK > "${DATA_DIR}/deposit_contract_block.txt"
|
|
|
|
|
2022-03-11 12:44:56 +00:00
|
|
|
if [[ "${LIGHTHOUSE_VC_NODES}" != "0" ]]; then
|
|
|
|
# I don't know what this is, but Lighthouse wants it, so we recreate it from
|
|
|
|
# Lighthouse's own local testnet.
|
2023-02-23 02:10:07 +00:00
|
|
|
echo $DEPOSIT_CONTRACT_BLOCK > "${DATA_DIR}/deploy_block.txt"
|
2022-03-11 12:44:56 +00:00
|
|
|
fi
|
|
|
|
|
2020-05-01 22:09:04 +00:00
|
|
|
dump_logs() {
|
2023-08-07 16:02:08 +00:00
|
|
|
LOG_LINES=50
|
2023-05-25 15:05:38 +00:00
|
|
|
for LOG in "${DATA_DIR}"/logs/*; do
|
2020-07-30 00:46:10 +00:00
|
|
|
echo "Last ${LOG_LINES} lines of ${LOG}:"
|
|
|
|
tail -n ${LOG_LINES} "${LOG}"
|
|
|
|
echo "======"
|
|
|
|
done
|
2020-05-01 22:09:04 +00:00
|
|
|
}
|
|
|
|
|
2020-08-16 09:12:19 +00:00
|
|
|
dump_logtrace() {
|
|
|
|
if [[ "$ENABLE_LOGTRACE" == "1" ]]; then
|
2023-05-25 15:05:38 +00:00
|
|
|
find "${DATA_DIR}/logs" -maxdepth 1 -type f -regex 'nimbus_beacon_node[0-9]+.jsonl' | sed -e"s/${DATA_DIR}\//--nodes=/" | sort | xargs ./build/ncli_testnet analyzeLogs --log-dir="${DATA_DIR}" --const-preset=${CONST_PRESET} || true
|
2020-08-16 09:12:19 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
NODES_WITH_VALIDATORS=${NODES_WITH_VALIDATORS:-$NUM_NODES}
|
2020-06-03 11:40:14 +00:00
|
|
|
SYSTEM_VALIDATORS=$(( TOTAL_VALIDATORS - USER_VALIDATORS ))
|
|
|
|
VALIDATORS_PER_NODE=$(( SYSTEM_VALIDATORS / NODES_WITH_VALIDATORS ))
|
2022-03-11 12:44:56 +00:00
|
|
|
if [[ "${USE_VC}" == "1" ]]; then
|
2020-09-01 13:38:34 +00:00
|
|
|
# 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
|
2022-06-27 08:34:12 +00:00
|
|
|
VALIDATORS_PER_NODE=$(( VALIDATORS_PER_NODE / 2 ))
|
|
|
|
NUM_JOBS=$(( NUM_JOBS * 2 ))
|
2020-09-01 13:38:34 +00:00
|
|
|
fi
|
2022-05-10 00:32:12 +00:00
|
|
|
|
2023-05-25 15:05:38 +00:00
|
|
|
if [[ "$SIGNER_NODES" -ge "0" ]]; then
|
|
|
|
NUM_JOBS=$(( NUM_JOBS + SIGNER_NODES ))
|
2022-05-10 00:32:12 +00:00
|
|
|
fi
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
if [[ "$LC_NODES" -ge "1" ]]; then
|
2022-06-27 08:34:12 +00:00
|
|
|
NUM_JOBS=$(( NUM_JOBS + LC_NODES ))
|
|
|
|
fi
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
if [[ "${RUN_GETH}" == "1" ]]; then
|
2022-06-27 08:34:12 +00:00
|
|
|
NUM_JOBS=$(( NUM_JOBS + GETH_NUM_NODES ))
|
|
|
|
fi
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
if [[ "${RUN_NIMBUS_ETH1}" == "1" ]]; then
|
|
|
|
NUM_JOBS=$(( NUM_JOBS + NIMBUS_ETH1_NUM_NODES ))
|
2022-05-31 10:45:37 +00:00
|
|
|
fi
|
|
|
|
|
2020-09-01 13:38:34 +00:00
|
|
|
VALIDATORS_PER_VALIDATOR=$(( (SYSTEM_VALIDATORS / NODES_WITH_VALIDATORS) / 2 ))
|
2023-02-23 02:10:07 +00:00
|
|
|
VALIDATOR_OFFSET=$(( SYSTEM_VALIDATORS / 2 ))
|
2021-11-30 18:56:22 +00:00
|
|
|
|
2020-07-30 00:46:10 +00:00
|
|
|
BOOTSTRAP_ENR="${DATA_DIR}/node${BOOTSTRAP_NODE}/beacon_node.enr"
|
2021-11-30 18:56:22 +00:00
|
|
|
CONTAINER_BOOTSTRAP_ENR="${CONTAINER_DATA_DIR}/node${BOOTSTRAP_NODE}/beacon_node.enr"
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
# TODO The deposit generator tool needs to gain support for generating two sets
|
|
|
|
# of deposits (genesis + submitted ones). Then we can enable the sending of
|
|
|
|
# deposits here.
|
|
|
|
#
|
|
|
|
#./build/ncli_testnet sendDeposits \
|
|
|
|
# --deposits-file="$DEPOSITS_FILE" \
|
|
|
|
# --min-delay=$MIN_DEPOSIT_SENDING_DELAY --max-delay=$MAX_DEPOSIT_SENDING_DELAY \
|
|
|
|
# --web3-url="$MAIN_WEB3_URL" \
|
|
|
|
# --deposit-contract=$DEPOSIT_CONTRACT_ADDRESS > "$DATA_DIR/log_deposit_maker.txt" 2>&1 &
|
|
|
|
|
|
|
|
for NUM_NODE in $(seq 1 $NUM_NODES); do
|
2021-07-13 11:15:07 +00:00
|
|
|
# Copy validators to individual nodes.
|
|
|
|
# The first $NODES_WITH_VALIDATORS nodes split them equally between them,
|
|
|
|
# after skipping the first $USER_VALIDATORS.
|
|
|
|
NODE_DATA_DIR="${DATA_DIR}/node${NUM_NODE}"
|
|
|
|
scripts/makedir.sh "${NODE_DATA_DIR}/validators" 2>&1
|
|
|
|
scripts/makedir.sh "${NODE_DATA_DIR}/secrets" 2>&1
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
if [[ $NUM_NODE -le $NODES_WITH_VALIDATORS ]]; then
|
2022-03-11 12:44:56 +00:00
|
|
|
if [[ "${USE_VC}" == "1" ]]; then
|
2021-07-13 11:15:07 +00:00
|
|
|
VALIDATOR_DATA_DIR="${DATA_DIR}/validator${NUM_NODE}"
|
|
|
|
rm -rf "${VALIDATOR_DATA_DIR}"
|
|
|
|
scripts/makedir.sh "${VALIDATOR_DATA_DIR}" 2>&1
|
|
|
|
scripts/makedir.sh "${VALIDATOR_DATA_DIR}/validators" 2>&1
|
|
|
|
scripts/makedir.sh "${VALIDATOR_DATA_DIR}/secrets" 2>&1
|
2023-02-23 02:10:07 +00:00
|
|
|
for VALIDATOR in $(ls "${VALIDATORS_DIR}" | tail -n +$(( USER_VALIDATORS + (VALIDATORS_PER_VALIDATOR * (NUM_NODE - 1)) + 1 + VALIDATOR_OFFSET )) | head -n $VALIDATORS_PER_VALIDATOR); do
|
|
|
|
cp -a "${VALIDATORS_DIR}/${VALIDATOR}" "${VALIDATOR_DATA_DIR}/validators/" 2>&1
|
|
|
|
# Remote validators won't have a secret file
|
|
|
|
if [ -f "${SECRETS_DIR}/${VALIDATOR}" ]; then
|
2022-05-10 00:32:12 +00:00
|
|
|
cp -a "${SECRETS_DIR}/${VALIDATOR}" "${VALIDATOR_DATA_DIR}/secrets/" 2>&1
|
|
|
|
fi
|
2021-07-13 11:15:07 +00:00
|
|
|
done
|
2022-03-11 12:44:56 +00:00
|
|
|
if [[ "${OS}" == "Windows_NT" ]]; then
|
2021-07-13 11:15:07 +00:00
|
|
|
find "${VALIDATOR_DATA_DIR}" -type f \( -iname "*.json" -o ! -iname "*.*" \) -exec icacls "{}" /inheritance:r /grant:r ${USERDOMAIN}\\${USERNAME}:\(F\) \;
|
|
|
|
fi
|
|
|
|
fi
|
2023-02-23 02:10:07 +00:00
|
|
|
for VALIDATOR in $(ls "${VALIDATORS_DIR}" | tail -n +$(( USER_VALIDATORS + (VALIDATORS_PER_NODE * (NUM_NODE - 1)) + 1 )) | head -n $VALIDATORS_PER_NODE); do
|
2021-07-13 11:15:07 +00:00
|
|
|
cp -a "${VALIDATORS_DIR}/${VALIDATOR}" "${NODE_DATA_DIR}/validators/" 2>&1
|
2022-05-10 00:32:12 +00:00
|
|
|
if [[ -f "${VALIDATORS_DIR}/${VALIDATOR}/keystore.json" ]]; then
|
|
|
|
# Only remote key stores doesn't have a secret
|
|
|
|
cp -a "${SECRETS_DIR}/${VALIDATOR}" "${NODE_DATA_DIR}/secrets/" 2>&1
|
|
|
|
fi
|
2021-07-13 11:15:07 +00:00
|
|
|
done
|
2022-03-11 12:44:56 +00:00
|
|
|
if [[ "${OS}" == "Windows_NT" ]]; then
|
2021-07-13 11:15:07 +00:00
|
|
|
find "${NODE_DATA_DIR}" -type f \( -iname "*.json" -o ! -iname "*.*" \) -exec icacls "{}" /inheritance:r /grant:r ${USERDOMAIN}\\${USERNAME}:\(F\) \;
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2023-02-23 02:10:07 +00:00
|
|
|
|
|
|
|
for NUM_LC in $(seq 1 $LC_NODES); do
|
2022-07-14 04:07:40 +00:00
|
|
|
LC_DATA_DIR="${DATA_DIR}/lc${NUM_LC}"
|
|
|
|
rm -rf "${LC_DATA_DIR}"
|
|
|
|
scripts/makedir.sh "${LC_DATA_DIR}" 2>&1
|
|
|
|
done
|
2021-07-13 11:15:07 +00:00
|
|
|
|
2022-03-05 02:33:15 +00:00
|
|
|
CLI_CONF_FILE="$CONTAINER_DATA_DIR/config.toml"
|
|
|
|
|
|
|
|
cat > "$CLI_CONF_FILE" <<END_CLI_CONFIG
|
|
|
|
non-interactive = true
|
|
|
|
nat = "extip:127.0.0.1"
|
|
|
|
network = "${CONTAINER_DATA_DIR}"
|
|
|
|
log-level = "${LOG_LEVEL}"
|
|
|
|
log-format = "json"
|
|
|
|
rest = true
|
|
|
|
rest-address = "127.0.0.1"
|
|
|
|
metrics = true
|
|
|
|
metrics-address = "127.0.0.1"
|
|
|
|
END_CLI_CONFIG
|
|
|
|
|
2023-05-25 15:05:38 +00:00
|
|
|
# Export some variables that can be used by the signer launch scripts
|
|
|
|
export DATA_DIR
|
|
|
|
export BASE_REMOTE_SIGNER_PORT
|
|
|
|
export WEB3SIGNER_BINARY
|
|
|
|
export RUNTIME_CONFIG_FILE
|
|
|
|
|
2022-06-13 17:01:39 +00:00
|
|
|
# https://ss64.com/osx/seq.html documents that at macOS seq(1) counts backwards
|
|
|
|
# as probably do some others
|
2023-05-25 15:05:38 +00:00
|
|
|
if ((SIGNER_NODES > 0)); then
|
|
|
|
for NUM_REMOTE in $(seq 0 $LAST_SIGNER_NODE_IDX); do
|
2022-06-13 17:01:39 +00:00
|
|
|
# TODO find some way for this and other background-launched processes to
|
|
|
|
# still participate in set -e, ideally
|
2023-05-25 15:05:38 +00:00
|
|
|
source "${SCRIPTS_DIR}/signers/${SIGNER_TYPE}.sh" $NUM_REMOTE
|
2022-06-13 17:01:39 +00:00
|
|
|
done
|
|
|
|
fi
|
2022-05-10 00:32:12 +00:00
|
|
|
|
|
|
|
# give each node time to load keys
|
|
|
|
sleep 10
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
for NUM_NODE in $(seq 1 $NUM_NODES); do
|
2021-07-13 11:15:07 +00:00
|
|
|
NODE_DATA_DIR="${DATA_DIR}/node${NUM_NODE}"
|
2021-11-30 18:56:22 +00:00
|
|
|
CONTAINER_NODE_DATA_DIR="${CONTAINER_DATA_DIR}/node${NUM_NODE}"
|
2021-07-13 11:15:07 +00:00
|
|
|
VALIDATOR_DATA_DIR="${DATA_DIR}/validator${NUM_NODE}"
|
2020-07-30 00:46:10 +00:00
|
|
|
if [[ ${NUM_NODE} == ${BOOTSTRAP_NODE} ]]; then
|
2021-07-26 17:34:13 +00:00
|
|
|
# Due to star topology, the bootstrap node must relay all attestations,
|
|
|
|
# even if it itself is not interested. --subscribe-all-subnets could be
|
|
|
|
# removed by switching to a fully-connected topology.
|
2023-09-15 18:45:55 +00:00
|
|
|
BOOTSTRAP_ARG="--netkey-file=${CONTAINER_BOOTSTRAP_NETWORK_KEYFILE} --insecure-netkey-password=true --subscribe-all-subnets --direct-peer=$DIRECTPEER_ENR"
|
|
|
|
elif [[ ${NUM_NODE} == ${DIRECTPEER_NODE} ]]; then
|
|
|
|
# Start a node using the Direct Peer functionality instead of regular bootstraping
|
|
|
|
BOOTSTRAP_ARG="--netkey-file=${DIRECTPEER_NETWORK_KEYFILE} --direct-peer=$(cat $CONTAINER_BOOTSTRAP_ENR) --insecure-netkey-password=true"
|
2020-07-30 00:46:10 +00:00
|
|
|
else
|
2021-11-30 18:56:22 +00:00
|
|
|
BOOTSTRAP_ARG="--bootstrap-file=${CONTAINER_BOOTSTRAP_ENR}"
|
2023-09-15 18:45:55 +00:00
|
|
|
fi
|
2021-08-20 14:41:16 +00:00
|
|
|
|
2023-09-15 18:45:55 +00:00
|
|
|
if [[ ${NUM_NODE} != ${BOOTSTRAP_NODE} ]]; then
|
2021-08-20 14:41:16 +00:00
|
|
|
if [[ "${CONST_PRESET}" == "minimal" ]]; then
|
|
|
|
# The fast epoch and slot times in the minimal config might cause the
|
|
|
|
# mesh to break down due to re-subscriptions happening within the prune
|
|
|
|
# backoff time
|
|
|
|
BOOTSTRAP_ARG="${BOOTSTRAP_ARG} --subscribe-all-subnets"
|
|
|
|
fi
|
2020-07-30 00:46:10 +00:00
|
|
|
fi
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
WEB3_ARG=()
|
|
|
|
if [ "${RUN_NIMBUS_ETH1}" == "1" ]; then
|
|
|
|
WEB3_ARG+=("--web3-url=http://127.0.0.1:${NIMBUS_ETH1_RPC_PORTS[$(( NUM_NODE - 1 ))]}")
|
2022-06-27 08:34:12 +00:00
|
|
|
fi
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
if [ "${RUN_GETH}" == "1" ]; then
|
|
|
|
WEB3_ARG+=("--web3-url=http://127.0.0.1:${GETH_AUTH_RPC_PORTS[$((NUM_NODE - 1))]}")
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${#WEB3_ARG[@]} -eq 0 ]; then # check if the array is empty
|
|
|
|
WEB3_ARG=("--require-engine-api-in-bellatrix=no")
|
|
|
|
fi
|
|
|
|
|
|
|
|
# We enabled the keymanager on half of the nodes in order
|
|
|
|
# to make sure that the client can work without it.
|
2022-08-19 21:51:30 +00:00
|
|
|
KEYMANAGER_FLAG=""
|
|
|
|
if [ $((NUM_NODE % 2)) -eq 0 ]; then
|
|
|
|
KEYMANAGER_FLAG="--keymanager"
|
|
|
|
fi
|
|
|
|
|
2022-03-11 12:44:56 +00:00
|
|
|
${BEACON_NODE_COMMAND} \
|
|
|
|
--config-file="${CLI_CONF_FILE}" \
|
2023-02-23 02:10:07 +00:00
|
|
|
--tcp-port=$(( BASE_PORT + NUM_NODE - 1 )) \
|
|
|
|
--udp-port=$(( BASE_PORT + NUM_NODE - 1 )) \
|
2022-05-31 10:45:37 +00:00
|
|
|
--max-peers=$(( NUM_NODES + LC_NODES - 1 )) \
|
2021-11-30 18:56:22 +00:00
|
|
|
--data-dir="${CONTAINER_NODE_DATA_DIR}" \
|
2020-07-30 00:46:10 +00:00
|
|
|
${BOOTSTRAP_ARG} \
|
2023-02-23 02:10:07 +00:00
|
|
|
--jwt-secret=${JWT_FILE} \
|
2022-09-08 13:22:31 +00:00
|
|
|
"${WEB3_ARG[@]}" \
|
2023-02-23 02:10:07 +00:00
|
|
|
--payload-builder=${USE_PAYLOAD_BUILDER} \
|
|
|
|
--payload-builder-url="http://${PAYLOAD_BUILDER_HOST}:${PAYLOAD_BUILDER_PORT}" \
|
|
|
|
--light-client-data-serve=on \
|
|
|
|
--light-client-data-import-mode=full \
|
|
|
|
--light-client-data-max-periods=999999 \
|
2020-09-01 13:38:34 +00:00
|
|
|
${STOP_AT_EPOCH_FLAG} \
|
2022-08-19 21:51:30 +00:00
|
|
|
${KEYMANAGER_FLAG} \
|
2022-08-19 10:30:07 +00:00
|
|
|
--keymanager-token-file="${DATA_DIR}/keymanager-token" \
|
2023-02-23 02:10:07 +00:00
|
|
|
--finalized-deposit-tree-snapshot="$CONTAINER_DEPOSIT_TREE_SNAPSHOT_FILE" \
|
|
|
|
--rest-port="$(( BASE_REST_PORT + NUM_NODE - 1 ))" \
|
|
|
|
--metrics-port="$(( BASE_METRICS_PORT + NUM_NODE - 1 ))" \
|
|
|
|
--doppelganger-detection=off \
|
2020-07-30 00:46:10 +00:00
|
|
|
${EXTRA_ARGS} \
|
2023-05-25 15:05:38 +00:00
|
|
|
&> "${DATA_DIR}/logs/nimbus_beacon_node.${NUM_NODE}.jsonl" &
|
|
|
|
PID=$!
|
|
|
|
PIDS_TO_WAIT="${PIDS_TO_WAIT},$!"
|
|
|
|
echo $PID > "$DATA_DIR/pids/nimbus_beacon_node.${NUM_NODE}"
|
2020-09-01 13:38:34 +00:00
|
|
|
|
2022-03-11 12:44:56 +00:00
|
|
|
if [[ "${USE_VC}" == "1" ]]; then
|
2023-02-23 02:10:07 +00:00
|
|
|
if [[ "${LIGHTHOUSE_VC_NODES}" -ge "${NUM_NODE}" ]]; then
|
2022-03-11 12:44:56 +00:00
|
|
|
# Lighthouse needs a different keystore filename for its auto-discovery process.
|
|
|
|
for D in "${VALIDATOR_DATA_DIR}/validators"/0x*; do
|
|
|
|
if [[ -e "${D}/keystore.json" ]]; then
|
|
|
|
mv "${D}/keystore.json" "${D}/voting-keystore.json"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
./build/${LH_BINARY} vc \
|
|
|
|
--debug-level "debug" \
|
|
|
|
--logfile-max-number 0 \
|
|
|
|
--log-format "JSON" \
|
|
|
|
--validators-dir "${VALIDATOR_DATA_DIR}" \
|
|
|
|
--secrets-dir "${VALIDATOR_DATA_DIR}/secrets" \
|
|
|
|
--beacon-nodes "http://127.0.0.1:$((BASE_REST_PORT + NUM_NODE))" \
|
|
|
|
--testnet-dir "${DATA_DIR}" \
|
|
|
|
--init-slashing-protection \
|
2023-05-25 15:05:38 +00:00
|
|
|
&> "${DATA_DIR}/logs/lighthouse_vc.${NUM_NODE}.txt" &
|
|
|
|
echo $! > "$DATA_DIR/pids/lighthouse_vc.${NUM_NODE}"
|
2022-03-11 12:44:56 +00:00
|
|
|
else
|
|
|
|
./build/nimbus_validator_client \
|
|
|
|
--log-level="${LOG_LEVEL}" \
|
|
|
|
${STOP_AT_EPOCH_FLAG} \
|
|
|
|
--data-dir="${VALIDATOR_DATA_DIR}" \
|
2022-11-30 10:47:11 +00:00
|
|
|
--metrics \
|
2023-02-23 02:10:07 +00:00
|
|
|
--metrics-port=$(( BASE_VC_METRICS_PORT + NUM_NODE - 1 )) \
|
|
|
|
--payload-builder=${USE_PAYLOAD_BUILDER} \
|
2022-08-19 21:51:30 +00:00
|
|
|
${KEYMANAGER_FLAG} \
|
2023-02-23 02:10:07 +00:00
|
|
|
--keymanager-port=$(( BASE_VC_KEYMANAGER_PORT + NUM_NODE - 1 )) \
|
2022-08-19 10:30:07 +00:00
|
|
|
--keymanager-token-file="${DATA_DIR}/keymanager-token" \
|
2023-02-23 02:10:07 +00:00
|
|
|
--beacon-node="http://127.0.0.1:$(( BASE_REST_PORT + NUM_NODE - 1 ))" \
|
2023-05-25 15:05:38 +00:00
|
|
|
&> "${DATA_DIR}/logs/nimbus_validator_client.${NUM_NODE}.jsonl" &
|
|
|
|
PID=$!
|
|
|
|
PIDS_TO_WAIT="${PIDS_TO_WAIT},$PID"
|
|
|
|
echo $PID > "$DATA_DIR/pids/nimbus_validator_client.${NUM_NODE}"
|
2022-03-11 12:44:56 +00:00
|
|
|
fi
|
2020-09-01 13:38:34 +00:00
|
|
|
fi
|
2023-09-15 18:45:55 +00:00
|
|
|
|
|
|
|
# Wait for the master node to write out its address file
|
|
|
|
START_TIMESTAMP=$(date +%s)
|
|
|
|
while [[ ! -f "${BOOTSTRAP_ENR}" ]]; do
|
|
|
|
sleep 0.1
|
|
|
|
NOW_TIMESTAMP=$(date +%s)
|
|
|
|
if [[ "$(( NOW_TIMESTAMP - START_TIMESTAMP - GENESIS_OFFSET ))" -ge "$BOOTSTRAP_TIMEOUT" ]]; then
|
|
|
|
echo "Bootstrap node failed to start in ${BOOTSTRAP_TIMEOUT} seconds. Aborting."
|
|
|
|
dump_logs
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
2020-01-20 22:28:48 +00:00
|
|
|
done
|
|
|
|
|
2022-05-31 10:45:37 +00:00
|
|
|
# light clients
|
|
|
|
if [ "$LC_NODES" -ge "1" ]; then
|
|
|
|
echo "Waiting for Altair finalization"
|
2022-06-14 08:38:39 +00:00
|
|
|
while :; do
|
2023-02-23 02:10:07 +00:00
|
|
|
BN_ALTAIR_FORK_EPOCH="$(
|
2022-06-14 08:38:39 +00:00
|
|
|
"${CURL_BINARY}" -s "http://localhost:${BASE_REST_PORT}/eth/v1/config/spec" | \
|
|
|
|
"${JQ_BINARY}" -r '.data.ALTAIR_FORK_EPOCH')"
|
2023-02-23 02:10:07 +00:00
|
|
|
if [ "${BN_ALTAIR_FORK_EPOCH}" -eq "${BN_ALTAIR_FORK_EPOCH}" ]; then # check for number
|
2022-06-14 08:38:39 +00:00
|
|
|
break
|
|
|
|
fi
|
2023-02-23 02:10:07 +00:00
|
|
|
echo "ALTAIR_FORK_EPOCH: ${BN_ALTAIR_FORK_EPOCH}"
|
2022-06-14 08:38:39 +00:00
|
|
|
sleep 1
|
|
|
|
done
|
2022-05-31 10:45:37 +00:00
|
|
|
while :; do
|
|
|
|
CURRENT_FORK_EPOCH="$(
|
|
|
|
"${CURL_BINARY}" -s "http://localhost:${BASE_REST_PORT}/eth/v1/beacon/states/finalized/fork" | \
|
2022-06-28 11:33:49 +00:00
|
|
|
"${JQ_BINARY}" -r '.data.epoch')"
|
2023-02-23 02:10:07 +00:00
|
|
|
if [ "${CURRENT_FORK_EPOCH}" -ge "${BN_ALTAIR_FORK_EPOCH}" ]; then
|
2022-05-31 10:45:37 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
2022-06-27 08:34:12 +00:00
|
|
|
log "After ALTAIR_FORK_EPOCH"
|
|
|
|
|
2022-05-31 10:45:37 +00:00
|
|
|
echo "Altair finalized, launching $LC_NODES light client(s)"
|
|
|
|
LC_BOOTSTRAP_NODE="$(
|
|
|
|
"${CURL_BINARY}" -s "http://localhost:${BASE_REST_PORT}/eth/v1/node/identity" | \
|
|
|
|
"${JQ_BINARY}" -r '.data.enr')"
|
|
|
|
LC_TRUSTED_BLOCK_ROOT="$(
|
|
|
|
"${CURL_BINARY}" -s "http://localhost:${BASE_REST_PORT}/eth/v1/beacon/headers/finalized" | \
|
|
|
|
"${JQ_BINARY}" -r '.data.root')"
|
2023-02-23 02:10:07 +00:00
|
|
|
for NUM_LC in $(seq 1 $LC_NODES); do
|
2022-07-14 04:07:40 +00:00
|
|
|
LC_DATA_DIR="${DATA_DIR}/lc${NUM_LC}"
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
WEB3_ARG=()
|
|
|
|
if [ "${RUN_NIMBUS_ETH1}" == "1" ]; then
|
|
|
|
WEB3_ARG+=("--web3-url=http://127.0.0.1:${NIMBUS_ETH1_RPC_PORTS[$(( NUM_NODES + NUM_LC - 1 ))]}")
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${RUN_GETH}" == "1" ]; then
|
|
|
|
WEB3_ARG+=("--web3-url=http://127.0.0.1:${GETH_AUTH_RPC_PORTS[$(( NUM_NODES + NUM_LC - 1 ))]}")
|
2022-07-14 04:07:40 +00:00
|
|
|
fi
|
|
|
|
|
2022-05-31 10:45:37 +00:00
|
|
|
./build/nimbus_light_client \
|
|
|
|
--log-level="${LOG_LEVEL}" \
|
|
|
|
--log-format="json" \
|
2022-07-14 04:07:40 +00:00
|
|
|
--data-dir="${LC_DATA_DIR}" \
|
2022-05-31 10:45:37 +00:00
|
|
|
--network="${CONTAINER_DATA_DIR}" \
|
|
|
|
--bootstrap-node="${LC_BOOTSTRAP_NODE}" \
|
2023-02-23 02:10:07 +00:00
|
|
|
--tcp-port=$(( BASE_PORT + NUM_NODES + NUM_LC - 1 )) \
|
|
|
|
--udp-port=$(( BASE_PORT + NUM_NODES + NUM_LC - 1 )) \
|
2022-05-31 10:45:37 +00:00
|
|
|
--max-peers=$(( NUM_NODES + LC_NODES - 1 )) \
|
|
|
|
--nat="extip:127.0.0.1" \
|
|
|
|
--trusted-block-root="${LC_TRUSTED_BLOCK_ROOT}" \
|
2023-02-23 02:10:07 +00:00
|
|
|
--jwt-secret="${JWT_FILE}" \
|
2022-09-08 13:22:31 +00:00
|
|
|
"${WEB3_ARG[@]}" \
|
2022-05-31 10:45:37 +00:00
|
|
|
${STOP_AT_EPOCH_FLAG} \
|
2023-05-25 15:05:38 +00:00
|
|
|
&> "${DATA_DIR}/logs/nimbus_light_client.${NUM_LC}.jsonl" &
|
|
|
|
PID=$!
|
|
|
|
PIDS_TO_WAIT="${PIDS_TO_WAIT},${PID}"
|
|
|
|
echo $PID > "${DATA_DIR}/pids/nimbus_light_client.${NUM_LC}"
|
2022-05-31 10:45:37 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2020-05-01 18:57:12 +00:00
|
|
|
# give the regular nodes time to crash
|
|
|
|
sleep 5
|
2020-07-29 12:08:27 +00:00
|
|
|
BG_JOBS="$(jobs | wc -l | tr -d ' ')"
|
2021-08-03 10:12:21 +00:00
|
|
|
if [[ "${TIMEOUT_DURATION}" != "0" ]]; then
|
|
|
|
BG_JOBS=$(( BG_JOBS - 1 )) # minus the timeout bg job
|
|
|
|
fi
|
2023-05-25 15:05:38 +00:00
|
|
|
|
2020-09-01 13:38:34 +00:00
|
|
|
if [[ "$BG_JOBS" != "$NUM_JOBS" ]]; then
|
2022-05-31 10:45:37 +00:00
|
|
|
echo "$(( NUM_JOBS - BG_JOBS )) nimbus_beacon_node/nimbus_validator_client/nimbus_light_client instance(s) exited early. Aborting."
|
2020-07-30 00:46:10 +00:00
|
|
|
dump_logs
|
2020-08-16 09:12:19 +00:00
|
|
|
dump_logtrace
|
2020-07-30 00:46:10 +00:00
|
|
|
exit 1
|
2020-05-01 18:57:12 +00:00
|
|
|
fi
|
|
|
|
|
2023-05-25 15:05:38 +00:00
|
|
|
echo "About to wait for the following sub-processes: " $PIDS_TO_WAIT
|
2023-02-23 02:10:07 +00:00
|
|
|
|
2022-03-11 12:44:56 +00:00
|
|
|
# launch "htop" or wait for background jobs
|
2020-02-18 23:33:26 +00:00
|
|
|
if [[ "$USE_HTOP" == "1" ]]; then
|
2023-05-25 15:05:38 +00:00
|
|
|
htop -p "$PIDS_TO_WAIT"
|
2022-03-11 12:44:56 +00:00
|
|
|
# Cleanup is done when this script exists, since we listen to the EXIT signal.
|
2020-02-18 23:33:26 +00:00
|
|
|
else
|
2020-07-30 00:46:10 +00:00
|
|
|
FAILED=0
|
2023-05-25 15:05:38 +00:00
|
|
|
for PID in $(echo "$PIDS_TO_WAIT" | tr ',' ' '); do
|
2020-08-17 06:36:29 +00:00
|
|
|
wait "$PID" || FAILED="$(( FAILED += 1 ))"
|
2023-02-23 02:10:07 +00:00
|
|
|
echo $PID has completed
|
2020-07-30 00:46:10 +00:00
|
|
|
done
|
|
|
|
if [[ "$FAILED" != "0" ]]; then
|
|
|
|
echo "${FAILED} child processes had non-zero exit codes (or exited early)."
|
|
|
|
dump_logs
|
2020-08-16 09:12:19 +00:00
|
|
|
dump_logtrace
|
2021-02-02 18:02:52 +00:00
|
|
|
if [[ "${TIMEOUT_DURATION}" != "0" ]]; then
|
2021-07-13 11:15:07 +00:00
|
|
|
if uname | grep -qiE "mingw|msys"; then
|
|
|
|
taskkill //F //PID ${WATCHER_PID}
|
|
|
|
else
|
|
|
|
pkill -HUP -P ${WATCHER_PID}
|
|
|
|
fi
|
2021-02-02 18:02:52 +00:00
|
|
|
fi
|
2020-07-30 00:46:10 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2020-02-18 23:33:26 +00:00
|
|
|
fi
|
2020-08-16 09:12:19 +00:00
|
|
|
|
|
|
|
dump_logtrace
|
2021-02-02 18:02:52 +00:00
|
|
|
|
|
|
|
if [[ "${TIMEOUT_DURATION}" != "0" ]]; then
|
2021-07-13 11:15:07 +00:00
|
|
|
if uname | grep -qiE "mingw|msys"; then
|
|
|
|
taskkill //F //PID ${WATCHER_PID}
|
|
|
|
else
|
|
|
|
pkill -HUP -P ${WATCHER_PID}
|
|
|
|
fi
|
2021-02-02 18:02:52 +00:00
|
|
|
fi
|
2023-02-23 02:10:07 +00:00
|
|
|
|
|
|
|
echo The simulation completed successfully
|
|
|
|
exit 0
|