support jwtsecret in `launch_local_testnet` (#4097)

To allow testing more thoroughly with connected EL, pass `jwtsecret`
as part of running local testnets.
This commit is contained in:
Etan Kissling 2022-09-08 15:22:31 +02:00 committed by GitHub
parent 667c3c97eb
commit 317e91bfc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 9 deletions

View File

@ -105,6 +105,7 @@ echo "${NIMBUSEL_BINARY}"
EL_HTTP_PORTS=()
EL_RPC_PORTS=()
EL_DATA_DIRS=()
PROCS_TO_KILL=("nimbus_beacon_node" "nimbus_validator_client" "nimbus_signing_node" "nimbus_light_client")
PORTS_TO_KILL=()
@ -522,6 +523,7 @@ if [[ "${RUN_GETH}" == "1" ]]; then
. "./scripts/start_geth_nodes.sh"
EL_HTTP_PORTS+=("${GETH_HTTP_PORTS[@]}")
EL_RPC_PORTS+=("${GETH_RPC_PORTS[@]}")
EL_DATA_DIRS+=("${GETH_DATA_DIRS[@]}")
PROCS_TO_KILL+=("${GETH_BINARY}")
CLEANUP_DIRS+=("${GETH_DATA_DIRS[@]}")
fi
@ -535,6 +537,7 @@ if [[ "${RUN_NIMBUS}" == "1" ]]; then
. "./scripts/start_nimbus_el_nodes.sh"
EL_HTTP_PORTS+=("${NIMBUSEL_HTTP_PORTS[@]}")
EL_RPC_PORTS+=("${NIMBUSEL_RPC_PORTS[@]}")
EL_DATA_DIRS+=("${NIMBUSEL_DATA_DIRS[@]}")
PROCS_TO_KILL+=("${NIMBUSEL_BINARY}")
CLEANUP_DIRS+=("${NIMBUSEL_DATA_DIRS[@]}")
fi
@ -772,6 +775,7 @@ DEPOSIT_CONTRACT_ADDRESS: ${DEPOSIT_CONTRACT_ADDRESS}
ETH1_FOLLOW_DISTANCE: 1
ALTAIR_FORK_EPOCH: 1
BELLATRIX_FORK_EPOCH: 2
TERMINAL_TOTAL_DIFFICULTY: 0
EOF
if [[ "${LIGHTHOUSE_VC_NODES}" != "0" ]]; then
@ -961,9 +965,14 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
fi
if [ ${#EL_RPC_PORTS[@]} -eq 0 ]; then # check if the array is empty
WEB3_ARG=""
WEB3_ARG=(
"--require-engine-api-in-bellatrix=no"
)
else
WEB3_ARG="--web3-url=http://127.0.0.1:${EL_RPC_PORTS[${NUM_NODE}]}"
WEB3_ARG=(
"--web3-url=http://127.0.0.1:${EL_RPC_PORTS[${NUM_NODE}]}"
"--jwt-secret=${EL_DATA_DIRS[${NUM_NODE}]}/jwtsecret"
)
fi
# We enabled the keymanager on half of the nodes
@ -972,7 +981,6 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
KEYMANAGER_FLAG="--keymanager"
fi
# TODO re-add --jwt-secret
${BEACON_NODE_COMMAND} \
--config-file="${CLI_CONF_FILE}" \
--tcp-port=$(( BASE_PORT + NUM_NODE )) \
@ -980,7 +988,7 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
--max-peers=$(( NUM_NODES + LC_NODES - 1 )) \
--data-dir="${CONTAINER_NODE_DATA_DIR}" \
${BOOTSTRAP_ARG} \
${WEB3_ARG} \
"${WEB3_ARG[@]}" \
${STOP_AT_EPOCH_FLAG} \
${KEYMANAGER_FLAG} \
--keymanager-token-file="${DATA_DIR}/keymanager-token" \
@ -1064,12 +1072,14 @@ if [ "$LC_NODES" -ge "1" ]; then
LC_DATA_DIR="${DATA_DIR}/lc${NUM_LC}"
if [ ${#EL_RPC_PORTS[@]} -eq 0 ]; then # check if the array is empty
WEB3_ARG=""
WEB3_ARG=()
else
WEB3_ARG="--web3-url=http://127.0.0.1:${EL_RPC_PORTS[$(( NUM_NODES + NUM_LC ))]}"
WEB3_ARG=(
"--web3-url=http://127.0.0.1:${EL_RPC_PORTS[$(( NUM_NODES + NUM_LC ))]}"
"--jwt-secret=${EL_DATA_DIRS[$(( NUM_NODES + NUM_LC ))]}/jwtsecret"
)
fi
# TODO re-add --jwt-secret
./build/nimbus_light_client \
--log-level="${LOG_LEVEL}" \
--log-format="json" \
@ -1081,7 +1091,7 @@ if [ "$LC_NODES" -ge "1" ]; then
--max-peers=$(( NUM_NODES + LC_NODES - 1 )) \
--nat="extip:127.0.0.1" \
--trusted-block-root="${LC_TRUSTED_BLOCK_ROOT}" \
${WEB3_ARG} \
"${WEB3_ARG[@]}" \
${STOP_AT_EPOCH_FLAG} \
&> "${DATA_DIR}/log_lc${NUM_LC}.txt" &
PIDS="${PIDS},$!"

View File

@ -24,8 +24,9 @@ for GETH_NUM_NODE in $(seq 0 $(( GETH_NUM_NODES - 1 ))); do
log "Starting geth node ${GETH_NUM_NODE} on net port ${GETH_NET_PORT} HTTP port ${GETH_HTTP_PORT} WS port ${GETH_WS_PORT}"
GETHDATADIR=$(mktemp -d "${DATA_DIR}"/geth-data-XXX)
GETH_DATA_DIRS+=(${GETHDATADIR})
openssl rand -hex 32 | tr -d "\n" > "${GETHDATADIR}/jwtsecret"
${GETH_BINARY} --http --ws -http.api "engine" --datadir "${GETHDATADIR}" init "${GENESISJSON}"
${GETH_BINARY} --http --ws --http.corsdomain '*' --http.api "eth,net,engine" -ws.api "eth,net,engine" --datadir "${GETHDATADIR}" ${DISCOVER} --port ${GETH_NET_PORT} --http.port ${GETH_HTTP_PORT} --ws.port ${GETH_WS_PORT} --authrpc.port ${GETH_AUTH_RPC_PORT} --authrpc.jwtsecret /tmp/jwtsecret &> "${DATA_DIR}/geth-log${GETH_NUM_NODE}.txt" &
${GETH_BINARY} --http --ws --http.corsdomain '*' --http.api "eth,net,engine" -ws.api "eth,net,engine" --datadir "${GETHDATADIR}" ${DISCOVER} --port ${GETH_NET_PORT} --http.port ${GETH_HTTP_PORT} --ws.port ${GETH_WS_PORT} --authrpc.port ${GETH_AUTH_RPC_PORT} --authrpc.jwtsecret "${GETHDATADIR}/jwtsecret" &> "${DATA_DIR}/geth-log${GETH_NUM_NODE}.txt" &
sleep 5
NODE_ID=$(${GETH_BINARY} attach --datadir "${GETHDATADIR}" --exec admin.nodeInfo.enode)
GETH_ENODES+=("${NODE_ID}")

View File

@ -33,6 +33,7 @@ for NUM_NODE in $(seq 0 $(( NIMBUSEL_NUM_NODES - 1 ))); do
log "Starting nimbus EL node ${NUM_NODE} on net port ${NIMBUSEL_NET_PORT} HTTP port ${NIMBUSEL_HTTP_PORT} WS port ${NIMBUSEL_WS_PORT}"
NIMBUSEL_DATADIR=$(mktemp -d nimbusel-data-XXX)
NIMBUSEL_DATA_DIRS+=("${NIMBUSEL_DATADIR}")
openssl rand -hex 32 | tr -d "\n" > "${NIMBUSEL_DATADIR}/jwtsecret"
${NIMBUSEL_BINARY} --data-dir="${NIMBUSEL_DATADIR}" --custom-network="${NIMBUSEL_GENESIS}" "${NIMBUSEL_DISCOVERY}" \
--tcp-port="${NIMBUSEL_NET_PORT}" --engine-api --engine-api-port="${NIMBUSEL_AUTH_RPC_PORT}" \
--rpc --rpc-port="${NIMBUSEL_HTTP_PORT}" &> "${DATA_DIR}/nimbusel_log${NUM_NODE}.txt" &