2022-06-27 08:34:12 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
SCRIPTS_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
2022-06-27 08:34:12 +00:00
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
source "${SCRIPTS_DIR}/geth_binaries.sh"
|
|
|
|
source "${SCRIPTS_DIR}/geth_vars.sh"
|
2022-06-27 08:34:12 +00:00
|
|
|
|
|
|
|
#These are used in the caller script
|
|
|
|
GETH_ENODES=()
|
|
|
|
|
|
|
|
log "Using ${GETH_BINARY}"
|
|
|
|
|
2023-03-01 16:27:55 +00:00
|
|
|
for GETH_NODE_IDX in $(seq 0 $GETH_LAST_NODE_IDX); do
|
2023-02-23 02:10:07 +00:00
|
|
|
mkdir -p "${GETH_DATA_DIRS[GETH_NODE_IDX]}"
|
|
|
|
set -x
|
|
|
|
${GETH_BINARY} version
|
|
|
|
${GETH_BINARY} --datadir "${GETH_DATA_DIRS[GETH_NODE_IDX]}" init "${EXECUTION_GENESIS_JSON}"
|
|
|
|
${GETH_BINARY} \
|
|
|
|
--syncmode full \
|
|
|
|
--datadir "${GETH_DATA_DIRS[GETH_NODE_IDX]}" \
|
|
|
|
${DISCOVER} \
|
|
|
|
--http \
|
|
|
|
--http.port ${GETH_RPC_PORTS[GETH_NODE_IDX]} \
|
|
|
|
--port ${GETH_NET_PORTS[GETH_NODE_IDX]} \
|
|
|
|
--authrpc.port ${GETH_AUTH_RPC_PORTS[GETH_NODE_IDX]} \
|
2023-03-01 16:27:55 +00:00
|
|
|
--authrpc.jwtsecret "${JWT_FILE}" \
|
|
|
|
&> "${DATA_DIR}/geth-log${GETH_NODE_IDX}.txt" &
|
|
|
|
set +x
|
2023-02-23 02:10:07 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
for GETH_NODE_IDX in $(seq 0 $GETH_LAST_NODE_IDX); do
|
|
|
|
GETH_RETRY=0
|
|
|
|
while :; do
|
|
|
|
if [[ -S "${GETH_DATA_DIRS[GETH_NODE_IDX]}/geth.ipc" ]]; then
|
|
|
|
echo "Geth ${GETH_NODE_IDX} started in $(( GETH_RETRY * 100 ))ms"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
if (( ++GETH_RETRY >= 300 )); then
|
|
|
|
echo "Geth ${GETH_NODE_IDX} failed to start"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
sleep 0.1
|
|
|
|
done
|
|
|
|
NODE_ID=$(${GETH_BINARY} attach --datadir "${GETH_DATA_DIRS[GETH_NODE_IDX]}" --exec admin.nodeInfo.enode)
|
|
|
|
GETH_ENODES+=("${NODE_ID}")
|
2022-06-27 08:34:12 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
#Add all nodes as peers
|
|
|
|
for dir in "${GETH_DATA_DIRS[@]}"
|
|
|
|
do
|
2023-02-23 02:10:07 +00:00
|
|
|
for enode in "${GETH_ENODES[@]}"
|
|
|
|
do
|
|
|
|
${GETH_BINARY} attach --datadir "${dir}" --exec "admin.addPeer(${enode})" &
|
|
|
|
done
|
2022-06-27 08:34:12 +00:00
|
|
|
done
|
|
|
|
|
2023-02-23 02:10:07 +00:00
|
|
|
log "GETH RPC Ports: ${GETH_AUTH_RPC_PORTS[*]}"
|