Reword the Tmux setup to handle all simulation scenarios in more visible way
This commit is contained in:
parent
e9d68e2f7b
commit
1def383ad1
2
Makefile
2
Makefile
|
@ -136,7 +136,7 @@ clean_eth2_network_simulation_files:
|
|||
rm -rf tests/simulation/{data,validators}
|
||||
|
||||
eth2_network_simulation: | build deps clean_eth2_network_simulation_files
|
||||
+ GIT_ROOT="$$PWD" NIMFLAGS="$(NIMFLAGS)" LOG_LEVEL="$(LOG_LEVEL)" tests/simulation/start.sh
|
||||
+ GIT_ROOT="$$PWD" NIMFLAGS="$(NIMFLAGS)" LOG_LEVEL="$(LOG_LEVEL)" tests/simulation/start-in-tmux.sh
|
||||
|
||||
clean-testnet0:
|
||||
rm -rf build/data/testnet0*
|
||||
|
|
|
@ -31,7 +31,7 @@ import
|
|||
|
||||
const
|
||||
genesisFile* = "genesis.ssz"
|
||||
timeToInitNetworkingBeforeGenesis = chronos.seconds(10)
|
||||
timeToInitNetworkingBeforeGenesis = chronos.seconds(30)
|
||||
hasPrompt = not defined(withoutPrompt)
|
||||
|
||||
type
|
||||
|
@ -95,12 +95,14 @@ proc getStateFromSnapshot(conf: BeaconNodeConf): NilableBeaconStateRef =
|
|||
genesisPath, dataDir = conf.dataDir.string
|
||||
writeGenesisFile = true
|
||||
genesisPath = snapshotPath
|
||||
else:
|
||||
try:
|
||||
snapshotContents = readFile(genesisPath)
|
||||
elif fileExists(genesisPath):
|
||||
try: snapshotContents = readFile(genesisPath)
|
||||
except CatchableError as err:
|
||||
error "Failed to read genesis file", err = err.msg
|
||||
quit 1
|
||||
else:
|
||||
# No snapshot was provided. We should wait for genesis.
|
||||
return nil
|
||||
|
||||
result = try:
|
||||
newClone(SSZ.decode(snapshotContents, BeaconState))
|
||||
|
|
|
@ -243,7 +243,7 @@ type
|
|||
name: "keyfile" }: seq[ValidatorKeyPath]
|
||||
|
||||
of deposits:
|
||||
case depositsCmd*: DepositsCmd
|
||||
case depositsCmd* {.command.}: DepositsCmd
|
||||
of create:
|
||||
totalDeposits* {.
|
||||
defaultValue: 1
|
||||
|
@ -253,7 +253,7 @@ type
|
|||
outValidatorsDir* {.
|
||||
defaultValue: "validators"
|
||||
desc: "Output folder for validator keystores and deposits."
|
||||
name: "out-validators-dir" }: string
|
||||
name: "out-deposits-dir" }: string
|
||||
|
||||
outSecretsDir* {.
|
||||
defaultValue: "secrets"
|
||||
|
@ -277,7 +277,7 @@ type
|
|||
depositsDir* {.
|
||||
defaultValue: "validators"
|
||||
desc: "A folder with validator metadata created by the `deposits create` command."
|
||||
name: "out-validators-dir" }: string
|
||||
name: "deposits-dir" }: string
|
||||
|
||||
minDelay* {.
|
||||
defaultValue: 0.0
|
||||
|
|
|
@ -176,12 +176,14 @@ proc sendDeposits*(deposits: seq[Deposit],
|
|||
let depositContract = web3.contractSender(DepositContract, contractAddress)
|
||||
|
||||
for i, dp in deposits:
|
||||
discard await depositContract.deposit(
|
||||
let status = await depositContract.deposit(
|
||||
Bytes48(dp.data.pubKey.toRaw()),
|
||||
Bytes32(dp.data.withdrawal_credentials.data),
|
||||
Bytes96(dp.data.signature.toRaw()),
|
||||
FixedBytes[32](hash_tree_root(dp.data).data)).send(value = 32.u256.ethToWei, gasPrice = 1)
|
||||
|
||||
info "Deposit sent", status = $status
|
||||
|
||||
if delayGenerator != nil:
|
||||
await sleepAsync(delayGenerator())
|
||||
|
||||
|
|
|
@ -538,41 +538,42 @@ proc run(m: MainchainMonitor, delayBeforeStart: Duration) {.async.} =
|
|||
defer: await close(dataProvider)
|
||||
|
||||
let processFut = m.processDeposits(dataProvider)
|
||||
defer: await processFut
|
||||
try:
|
||||
dataProvider.onDisconnect do:
|
||||
error "Eth1 data provider disconnected",
|
||||
provider = m.dataProviderFactory.desc
|
||||
processFut.cancel()
|
||||
|
||||
dataProvider.onDisconnect do:
|
||||
error "Eth1 data provider disconnected",
|
||||
provider = m.dataProviderFactory.desc
|
||||
processFut.cancel()
|
||||
let startBlkNum = await dataProvider.getBlockNumber(m.startBlock)
|
||||
notice "Monitoring eth1 deposits",
|
||||
fromBlock = startBlkNum.uint64,
|
||||
contract = $m.depositContractAddress,
|
||||
url = m.dataProviderFactory.desc
|
||||
|
||||
let startBlkNum = await dataProvider.getBlockNumber(m.startBlock)
|
||||
notice "Monitoring eth1 deposits",
|
||||
fromBlock = startBlkNum.uint64,
|
||||
contract = $m.depositContractAddress,
|
||||
url = m.dataProviderFactory.desc
|
||||
await dataProvider.onDepositEvent(Eth1BlockNumber(startBlkNum)) do (
|
||||
pubkey: Bytes48,
|
||||
withdrawalCredentials: Bytes32,
|
||||
amount: Bytes8,
|
||||
signature: Bytes96, merkleTreeIndex: Bytes8, j: JsonNode)
|
||||
{.raises: [Defect], gcsafe.}:
|
||||
try:
|
||||
let
|
||||
blockHash = BlockHash.fromHex(j["blockHash"].getStr())
|
||||
eventType = if j.hasKey("removed"): RemovedEvent
|
||||
else: NewEvent
|
||||
|
||||
await dataProvider.onDepositEvent(Eth1BlockNumber(startBlkNum)) do (
|
||||
pubkey: Bytes48,
|
||||
withdrawalCredentials: Bytes32,
|
||||
amount: Bytes8,
|
||||
signature: Bytes96, merkleTreeIndex: Bytes8, j: JsonNode)
|
||||
{.raises: [Defect], gcsafe.}:
|
||||
try:
|
||||
let
|
||||
blockHash = BlockHash.fromHex(j["blockHash"].getStr())
|
||||
eventType = if j.hasKey("removed"): RemovedEvent
|
||||
else: NewEvent
|
||||
m.depositQueue.addLastNoWait((blockHash, eventType))
|
||||
|
||||
m.depositQueue.addLastNoWait((blockHash, eventType))
|
||||
|
||||
except CatchableError as exc:
|
||||
warn "Received invalid deposit", err = exc.msg, j
|
||||
except Exception as err:
|
||||
# chronos still raises exceptions which inherit directly from Exception
|
||||
if err[] of Defect:
|
||||
raise (ref Defect)(err)
|
||||
else:
|
||||
warn "Received invalid deposit", err = err.msg, j
|
||||
except CatchableError as exc:
|
||||
warn "Received invalid deposit", err = exc.msg, j
|
||||
except Exception as err:
|
||||
# chronos still raises exceptions which inherit directly from Exception
|
||||
if err[] of Defect:
|
||||
raise (ref Defect)(err)
|
||||
else:
|
||||
warn "Received invalid deposit", err = err.msg, j
|
||||
finally:
|
||||
await processFut
|
||||
|
||||
proc start(m: MainchainMonitor, delayBeforeStart: Duration) =
|
||||
if m.runFut.isNil:
|
||||
|
|
|
@ -147,7 +147,7 @@ cli do (skipGoerliKey {.
|
|||
mode = Verbose
|
||||
exec replace(&"""{beaconNodeBinary} deposits create
|
||||
--count=1
|
||||
--out-validators-dir="{validatorsDir}"
|
||||
--out-deposits-dir="{validatorsDir}"
|
||||
--out-secrets-dir="{secretsDir}"
|
||||
--deposit-private-key={privKey}
|
||||
--web3-url={web3Url}
|
||||
|
|
|
@ -140,7 +140,7 @@ $MAKE LOG_LEVEL="${LOG_LEVEL}" NIMFLAGS="-d:insecure -d:testnet_servers_image ${
|
|||
|
||||
./build/beacon_node deposits create \
|
||||
--count=${TOTAL_VALIDATORS} \
|
||||
--out-validators-dir="${DEPOSITS_DIR}" \
|
||||
--out-deposits-dir="${DEPOSITS_DIR}" \
|
||||
--out-secrets-dir="${SECRETS_DIR}" \
|
||||
--dont-send
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ make build
|
|||
|
||||
../build/beacon_node deposits create \
|
||||
--count=$TOTAL_VALIDATORS \
|
||||
--out-validators-dir="$DEPOSITS_DIR_ABS" \
|
||||
--out-deposits-dir="$DEPOSITS_DIR_ABS" \
|
||||
--out-secrets-dir="$SECRETS_DIR_ABS" \
|
||||
--dont-send
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ else
|
|||
ADDITIONAL_BEACON_NODE_ARGS=""
|
||||
fi
|
||||
|
||||
BOOTSTRAP_ARG=""
|
||||
|
||||
if [[ ! -z "$1" ]]; then
|
||||
BOOTSTRAP_NODE_ID=$1
|
||||
BOOTSTRAP_ADDRESS_FILE="${SIMULATION_DIR}/node-${BOOTSTRAP_NODE_ID}/beacon_node.address"
|
||||
|
@ -25,6 +27,10 @@ else
|
|||
BOOTSTRAP_ADDRESS_FILE=$NETWORK_BOOTSTRAP_FILE
|
||||
fi
|
||||
|
||||
if [[ "$NODE_ID" != "$MASTER_NODE" ]]; then
|
||||
BOOTSTRAP_ARG="--bootstrap-file=$BOOTSTRAP_ADDRESS_FILE"
|
||||
fi
|
||||
|
||||
# set up the environment
|
||||
# shellcheck source=/dev/null
|
||||
source "${SIM_ROOT}/../../env.sh"
|
||||
|
@ -75,12 +81,17 @@ if [ -f "${SNAPSHOT_FILE}" ]; then
|
|||
SNAPSHOT_ARG="--state-snapshot=${SNAPSHOT_FILE}"
|
||||
fi
|
||||
|
||||
DEPOSIT_CONTRACT_ARGS=""
|
||||
if [ -f "${DEPOSIT_CONTRACT_FILE}" ]; then
|
||||
DEPOSIT_CONTRACT_ARGS="--deposit-contract=$(cat $DEPOSIT_CONTRACT_FILE) $WEB3_ARG"
|
||||
fi
|
||||
|
||||
cd "$NODE_DATA_DIR"
|
||||
|
||||
# if you want tracing messages, add "--log-level=TRACE" below
|
||||
$BEACON_NODE_BIN \
|
||||
--log-level=${LOG_LEVEL:-DEBUG} \
|
||||
--bootstrap-file=$BOOTSTRAP_ADDRESS_FILE \
|
||||
$BOOTSTRAP_ARG \
|
||||
--data-dir=$NODE_DATA_DIR \
|
||||
--secrets-dir=$NODE_SECRETS_DIR \
|
||||
--node-name=$NODE_ID \
|
||||
|
@ -88,8 +99,7 @@ $BEACON_NODE_BIN \
|
|||
--udp-port=$PORT \
|
||||
$SNAPSHOT_ARG \
|
||||
$NAT_ARG \
|
||||
$WEB3_ARG \
|
||||
--deposit-contract=$DEPOSIT_CONTRACT_ADDRESS \
|
||||
$DEPOSIT_CONTRACT_ARGS \
|
||||
--rpc \
|
||||
--rpc-address="127.0.0.1" \
|
||||
--rpc-port="$(( $BASE_RPC_PORT + $NODE_ID ))" \
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
TMUX_CMD="${TMUX_CMD:-tmux}"
|
||||
USE_TMUX="${USE_TMUX:-no}"
|
||||
type "$TMUX_CMD" &>/dev/null || { echo "${TMUX_CMD}" is missing; USE_TMUX="no"; }
|
||||
|
||||
if [[ "$USE_TMUX" != "no" ]]; then
|
||||
TMUX_SESSION_NAME="${TMUX_SESSION_NAME:-nbc-sim}"
|
||||
|
||||
export USE_TMUX=yes
|
||||
export TMUX_CMD
|
||||
export TMUX_SESSION_NAME
|
||||
|
||||
$TMUX_CMD new-session -s "${TMUX_SESSION_NAME}" -d
|
||||
|
||||
# maybe these should be moved to a user config file
|
||||
$TMUX_CMD set-option -t "${TMUX_SESSION_NAME}" history-limit 999999
|
||||
$TMUX_CMD set-option -t "${TMUX_SESSION_NAME}" remain-on-exit on
|
||||
$TMUX_CMD set -t "${TMUX_SESSION_NAME}" mouse on
|
||||
|
||||
# We create a new window, so the above settings can take place
|
||||
$TMUX_CMD new-window -d -t "${TMUX_SESSION_NAME}" -n "sim"
|
||||
$TMUX_CMD kill-pane -t "${TMUX_SESSION_NAME}:0"
|
||||
|
||||
trap 'tmux kill-session -t "${TMUX_SESSION_NAME}"' SIGINT EXIT
|
||||
|
||||
$TMUX_CMD new-window -t "${TMUX_SESSION_NAME}" -n "start-script" "$PWD/start.sh"
|
||||
$TMUX_CMD select-window -t "${TMUX_SESSION_NAME}:start-script"
|
||||
|
||||
#$TMUX_CMD send-keys -t "${TMUX_SESSION_NAME}:0" "$PWD/start.sh" Enter
|
||||
#$TMUX_CMD select-window -t "${TMUX_SESSION_NAME}:0"
|
||||
# $TMUX_CMD attach-session -t "${TMUX_SESSION_NAME}"
|
||||
|
||||
$TMUX_CMD attach-session -t "${TMUX_SESSION_NAME}"
|
||||
else
|
||||
./start.sh
|
||||
fi
|
||||
|
|
@ -3,29 +3,39 @@
|
|||
set -eo pipefail
|
||||
|
||||
# To allow overriding the program names
|
||||
MULTITAIL="${MULTITAIL:-multitail}"
|
||||
TMUX="${TMUX:-tmux}"
|
||||
GANACHE="${GANACHE:-ganache-cli}"
|
||||
PROMETHEUS="${PROMETHEUS:-prometheus}"
|
||||
CTAIL="${CTAIL:-ctail}"
|
||||
MULTITAIL_CMD="${MULTITAIL_CMD:-multitail}"
|
||||
GANACHE_CMD="${GANACHE_CMD:-ganache-cli}"
|
||||
PROMETHEUS_CMD="${PROMETHEUS_CMD:-prometheus}"
|
||||
CTAIL_CMD="${CTAIL_CMD:-ctail}"
|
||||
|
||||
# Using tmux or multitail is an opt-in
|
||||
USE_MULTITAIL="${USE_MULTITAIL:-no}"
|
||||
type "$MULTITAIL" &>/dev/null || { echo "${MULTITAIL}" is missing; USE_MULTITAIL="no"; }
|
||||
|
||||
USE_TMUX="${USE_TMUX:-no}"
|
||||
type "$TMUX" &>/dev/null || { echo "${TMUX}" is missing; USE_TMUX="no"; }
|
||||
TMUX_SESSION_NAME="${TMUX_SESSION_NAME:-nbc-sim}"
|
||||
|
||||
WAIT_GENESIS="${WAIT_GENESIS:-no}"
|
||||
|
||||
USE_MULTITAIL="${USE_MULTITAIL:-no}"
|
||||
if [[ "$USE_MULTITAIL" != "no" ]]; then
|
||||
type "$MULTITAIL" &>/dev/null || { echo "${MULTITAIL}" is missing; USE_MULTITAIL="no"; }
|
||||
fi
|
||||
|
||||
USE_TMUX="${USE_TMUX:-yes}"
|
||||
if [[ "$USE_TMUX" == "yes" ]]; then
|
||||
type "$TMUX" &>/dev/null || { echo "${TMUX}" is missing; USE_TMUX="no"; }
|
||||
fi
|
||||
|
||||
USE_GANACHE="${USE_GANACHE:-yes}"
|
||||
type "$GANACHE" &>/dev/null || { echo $GANACHE is missing; USE_GANACHE="no"; WAIT_GENESIS="no"; }
|
||||
if [[ "$USE_GANACHE" == "yes" ]]; then
|
||||
type "$GANACHE" &>/dev/null || { echo $GANACHE is missing; USE_GANACHE="no"; }
|
||||
fi
|
||||
|
||||
USE_PROMETHEUS="${USE_PROMETHEUS:-yes}"
|
||||
type "$PROMETHEUS" &>/dev/null || { echo $PROMETHEUS is missing; USE_PROMETHEUS="no"; }
|
||||
if [[ "$USE_PROMETHEUS" == "yes" ]]; then
|
||||
type "$PROMETHEUS" &>/dev/null || { echo $PROMETHEUS is missing; USE_PROMETHEUS="no"; }
|
||||
fi
|
||||
|
||||
USE_CTAIL="${USE_CTAIL:-yes}"
|
||||
type "$CTAIL" &>/dev/null || { echo $CTAIL is missing; USE_CTAIL="no"; }
|
||||
if [[ "$USE_CTAIL" == "yes" ]]; then
|
||||
type "$CTAIL_CMD" &>/dev/null || { echo $CTAIL_CMD is missing; USE_CTAIL="no"; }
|
||||
fi
|
||||
|
||||
# Read in variables
|
||||
# shellcheck source=/dev/null
|
||||
|
@ -53,31 +63,6 @@ else
|
|||
MAKE="make"
|
||||
fi
|
||||
|
||||
TMUX_SESSION_NAME="${TMUX_SESSION_NAME:-nbc-sim}"
|
||||
|
||||
WAIT_GENESIS="${WAIT_GENESIS:-no}"
|
||||
|
||||
# Using tmux or multitail is an opt-in
|
||||
USE_MULTITAIL="${USE_MULTITAIL:-no}"
|
||||
if [[ "$USE_MULTITAIL" != "no" ]]; then
|
||||
type "$MULTITAIL" &>/dev/null || { echo "${MULTITAIL}" is missing; USE_MULTITAIL="no"; }
|
||||
fi
|
||||
|
||||
USE_TMUX="${USE_TMUX:-yes}"
|
||||
if [[ "$USE_TMUX" == "yes" ]]; then
|
||||
type "$TMUX" &>/dev/null || { echo "${TMUX}" is missing; USE_TMUX="no"; }
|
||||
fi
|
||||
|
||||
USE_GANACHE="${USE_GANACHE:-yes}"
|
||||
if [[ "$USE_GANACHE" == "yes" ]]; then
|
||||
type "$GANACHE" &>/dev/null || { echo $GANACHE is missing; USE_GANACHE="no"; }
|
||||
fi
|
||||
|
||||
USE_PROMETHEUS="${USE_PROMETHEUS:-yes}"
|
||||
if [[ "$USE_PROMETHEUS" == "yes" ]]; then
|
||||
type "$PROMETHEUS" &>/dev/null || { echo $PROMETHEUS is missing; USE_PROMETHEUS="no"; }
|
||||
fi
|
||||
|
||||
mkdir -p "${METRICS_DIR}"
|
||||
./scripts/make_prometheus_config.sh \
|
||||
--nodes ${TOTAL_NODES} \
|
||||
|
@ -86,43 +71,29 @@ mkdir -p "${METRICS_DIR}"
|
|||
|
||||
COMMANDS=()
|
||||
|
||||
if [[ "$USE_TMUX" != "no" ]]; then
|
||||
$TMUX new-session -s "${TMUX_SESSION_NAME}" -d
|
||||
|
||||
# maybe these should be moved to a user config file
|
||||
$TMUX set-option -t "${TMUX_SESSION_NAME}" history-limit 999999
|
||||
$TMUX set-option -t "${TMUX_SESSION_NAME}" remain-on-exit on
|
||||
$TMUX set -t "${TMUX_SESSION_NAME}" mouse on
|
||||
|
||||
# We create a new window, so the above settings can take place
|
||||
$TMUX new-window -d -t "${TMUX_SESSION_NAME}" -n "sim"
|
||||
|
||||
trap 'tmux kill-session -t "${TMUX_SESSION_NAME}"' SIGINT EXIT
|
||||
fi
|
||||
|
||||
if [[ "$USE_GANACHE" != "no" ]]; then
|
||||
if [[ "$USE_TMUX" != "no" ]]; then
|
||||
$TMUX new-window -d -t $TMUX_SESSION_NAME -n "$GANACHE" "$GANACHE"
|
||||
if [[ "$USE_GANACHE" == "yes" ]]; then
|
||||
if [[ "$USE_TMUX" == "yes" ]]; then
|
||||
$TMUX_CMD new-window -d -t $TMUX_SESSION_NAME -n "$GANACHE_CMD" "$GANACHE_CMD -e 100000"
|
||||
else
|
||||
echo NOTICE: $GANACHE will be started automatically only with USE_TMUX=1
|
||||
echo NOTICE: $GANACHE_CMD will be started automatically only with USE_TMUX=1
|
||||
USE_GANACHE="no"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$USE_PROMETHEUS" != "no" ]]; then
|
||||
if [[ "$USE_TMUX" != "no" ]]; then
|
||||
if [[ "$USE_PROMETHEUS" == "yes" ]]; then
|
||||
if [[ "$USE_TMUX" == "yes" ]]; then
|
||||
rm -rf "${METRICS_DIR}/data"
|
||||
mkdir -p "${METRICS_DIR}/data"
|
||||
# TODO: Prometheus is not shut down properly on tmux kill-session
|
||||
killall prometheus
|
||||
PROMETHEUS_FLAGS="--config.file=./prometheus.yml --storage.tsdb.path=./data"
|
||||
$TMUX new-window -d -t $TMUX_SESSION_NAME -n "$PROMETHEUS" "cd '$METRICS_DIR' && $PROMETHEUS $PROMETHEUS_FLAGS"
|
||||
$TMUX_CMD new-window -d -t $TMUX_SESSION_NAME -n "$PROMETHEUS_CMD" "cd '$METRICS_DIR' && $PROMETHEUS_CMD $PROMETHEUS_FLAGS"
|
||||
else
|
||||
echo NOTICE: $PROMETHEUS will be started automatically only with USE_TMUX=1
|
||||
echo NOTICE: $PROMETHEUS_CMD will be started automatically only with USE_TMUX=1
|
||||
USE_PROMETHEUS="no"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$USE_TMUX" != "no" ]]; then
|
||||
$TMUX select-window -t "${TMUX_SESSION_NAME}:sim"
|
||||
fi
|
||||
|
||||
$MAKE -j3 --no-print-directory NIMFLAGS="$CUSTOM_NIMFLAGS $DEFS" LOG_LEVEL="${LOG_LEVEL:-DEBUG}" beacon_node validator_client
|
||||
|
||||
count_files () {
|
||||
|
@ -138,22 +109,41 @@ if [[ $EXISTING_VALIDATORS -lt $NUM_VALIDATORS ]]; then
|
|||
$BEACON_NODE_BIN deposits create \
|
||||
--count="${NUM_VALIDATORS}" \
|
||||
--non-interactive \
|
||||
--out-validators-dir="$VALIDATORS_DIR" \
|
||||
--out-deposits-dir="$VALIDATORS_DIR" \
|
||||
--out-secrets-dir="$SECRETS_DIR" \
|
||||
--dont-send
|
||||
|
||||
echo "All deposits prepared"
|
||||
fi
|
||||
|
||||
if [ ! -f "${SNAPSHOT_FILE}" ]; then
|
||||
if [[ "${WAIT_GENESIS}" != "yes" ]]; then
|
||||
echo Creating testnet genesis...
|
||||
$BEACON_NODE_BIN \
|
||||
--data-dir="${SIMULATION_DIR}/node-$MASTER_NODE" \
|
||||
createTestnet \
|
||||
--validators-dir="${VALIDATORS_DIR}" \
|
||||
--total-validators="${NUM_VALIDATORS}" \
|
||||
--output-genesis="${SNAPSHOT_FILE}" \
|
||||
--output-bootstrap-file="${NETWORK_BOOTSTRAP_FILE}" \
|
||||
--bootstrap-address=127.0.0.1 \
|
||||
--bootstrap-port=$(( BASE_P2P_PORT + MASTER_NODE )) \
|
||||
--genesis-offset=45 # Delay in seconds
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$USE_TMUX" == "yes" ]]; then
|
||||
$TMUX_CMD select-window -t "${TMUX_SESSION_NAME}:sim"
|
||||
fi
|
||||
|
||||
function run_cmd {
|
||||
i=$1
|
||||
CMD=$2
|
||||
bin_name=$3
|
||||
if [[ "$USE_TMUX" != "no" ]]; then
|
||||
if [[ "$USE_TMUX" == "yes" ]]; then
|
||||
echo "Starting node $i..."
|
||||
echo $TMUX split-window -t "${TMUX_SESSION_NAME}" "$CMD"
|
||||
$TMUX split-window -t "${TMUX_SESSION_NAME}" "$CMD"
|
||||
$TMUX select-layout -t "${TMUX_SESSION_NAME}" tiled
|
||||
$TMUX_CMD split-window -t "${TMUX_SESSION_NAME}" "$CMD"
|
||||
$TMUX_CMD select-layout -t "${TMUX_SESSION_NAME}:sim" tiled
|
||||
elif [[ "$USE_MULTITAIL" != "no" ]]; then
|
||||
if [[ "$i" == "$MASTER_NODE" ]]; then
|
||||
SLEEP="0"
|
||||
|
@ -167,47 +157,24 @@ function run_cmd {
|
|||
fi
|
||||
}
|
||||
|
||||
if [ "$WEB3_ARG" != "" ]; then
|
||||
if [ "$USE_GANACHE" != "no" ]; then
|
||||
make deposit_contract
|
||||
echo Deploying the validator deposit contract...
|
||||
echo $DEPLOY_DEPOSIT_CONTRACT_BIN deploy $WEB3_ARG
|
||||
DEPOSIT_CONTRACT_ADDRESS=$($DEPLOY_DEPOSIT_CONTRACT_BIN deploy $WEB3_ARG)
|
||||
echo Contract deployed at $DEPOSIT_CONTRACT_ADDRESS
|
||||
export DEPOSIT_CONTRACT_ADDRESS
|
||||
|
||||
if [[ "$WAIT_GENESIS" != "no" ]]; then
|
||||
echo "(deposit maker)" "$BEACON_NODE_BIN deposits send \
|
||||
--non-interactive \
|
||||
--validators-dir='$VALIDATORS_DIR' \
|
||||
--min-delay=1 --max-delay=5 \
|
||||
$WEB3_ARG \
|
||||
--deposit-contract=${DEPOSIT_CONTRACT_ADDRESS}"
|
||||
echo $DEPOSIT_CONTRACT_ADDRESS > $DEPOSIT_CONTRACT_FILE
|
||||
|
||||
if [[ "$WAIT_GENESIS" == "yes" ]]; then
|
||||
run_cmd "(deposit maker)" "$BEACON_NODE_BIN deposits send \
|
||||
--non-interactive \
|
||||
--validators-dir='$VALIDATORS_DIR' \
|
||||
--deposits-dir='$VALIDATORS_DIR' \
|
||||
--min-delay=1 --max-delay=5 \
|
||||
$WEB3_ARG \
|
||||
--deposit-contract=${DEPOSIT_CONTRACT_ADDRESS}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f "${SNAPSHOT_FILE}" ]; then
|
||||
if [[ "${WAIT_GENESIS}" == "no" ]]; then
|
||||
echo Creating testnet genesis...
|
||||
$BEACON_NODE_BIN \
|
||||
--data-dir="${SIMULATION_DIR}/node-$MASTER_NODE" \
|
||||
createTestnet \
|
||||
--validators-dir="${VALIDATORS_DIR}" \
|
||||
--total-validators="${NUM_VALIDATORS}" \
|
||||
--output-genesis="${SNAPSHOT_FILE}" \
|
||||
--output-bootstrap-file="${NETWORK_BOOTSTRAP_FILE}" \
|
||||
--bootstrap-address=127.0.0.1 \
|
||||
--bootstrap-port=$(( BASE_P2P_PORT + MASTER_NODE )) \
|
||||
--genesis-offset=15 # Delay in seconds
|
||||
fi
|
||||
fi
|
||||
|
||||
# Delete any leftover address files from a previous session
|
||||
if [ -f "${MASTER_NODE_ADDRESS_FILE}" ]; then
|
||||
rm "${MASTER_NODE_ADDRESS_FILE}"
|
||||
|
@ -216,7 +183,7 @@ fi
|
|||
# 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.
|
||||
if [[ "$USE_MULTITAIL" == "no" && "$USE_TMUX" == "no" ]]; then
|
||||
if [[ "$USE_MULTITAIL" == "no" && "$USE_TMUX" != "yes" ]]; then
|
||||
trap 'pkill -P $$ beacon_node' SIGINT EXIT
|
||||
fi
|
||||
|
||||
|
@ -243,24 +210,21 @@ for i in $(seq $MASTER_NODE -1 $TOTAL_USER_NODES); do
|
|||
done
|
||||
|
||||
if [[ "$USE_CTAIL" != "no" ]]; then
|
||||
if [[ "$USE_TMUX" != "no" ]]; then
|
||||
$TMUX new-window -d -t $TMUX_SESSION_NAME -n "$CTAIL" "$CTAIL tail -q -n +1 -f ${SIMULATION_DIR}/node-*/beacon_node.log"
|
||||
if [[ "$USE_TMUX" == "yes" ]]; then
|
||||
$TMUX_CMD new-window -d -t $TMUX_SESSION_NAME -n "$CTAIL_CMD" "$CTAIL_CMD tail -q -n +1 -f ${SIMULATION_DIR}/node-*/beacon_node.log"
|
||||
else
|
||||
echo NOTICE: $CTAIL will be started automatically only with USE_TMUX=1
|
||||
echo NOTICE: $CTAIL_CMD will be started automatically only with USE_TMUX=1
|
||||
USE_CTAIL="no"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$USE_TMUX" != "no" ]]; then
|
||||
if [[ "$USE_TMUX" == "yes" ]]; then
|
||||
# kill the console window in the pane where the simulation is running
|
||||
$TMUX kill-pane -t $TMUX_SESSION_NAME:sim.0
|
||||
# kill the original console window
|
||||
# (this one doesn't have the right history-limit)
|
||||
$TMUX kill-pane -t $TMUX_SESSION_NAME:0.0
|
||||
$TMUX select-layout -t "${TMUX_SESSION_NAME}" tiled
|
||||
$TMUX attach-session -t "${TMUX_SESSION_NAME}" -d
|
||||
$TMUX_CMD kill-pane -t $TMUX_SESSION_NAME:sim.0
|
||||
$TMUX_CMD select-window -t "${TMUX_SESSION_NAME}:sim"
|
||||
$TMUX_CMD select-layout tiled
|
||||
elif [[ "$USE_MULTITAIL" != "no" ]]; then
|
||||
eval $MULTITAIL -s 3 -M 0 -x \"Nimbus beacon chain\" "${COMMANDS[@]}"
|
||||
eval $MULTITAIL_CMD -s 3 -M 0 -x \"Nimbus beacon chain\" "${COMMANDS[@]}"
|
||||
else
|
||||
wait # Stop when all nodes have gone down
|
||||
fi
|
||||
|
|
|
@ -31,18 +31,15 @@ VALIDATORS_DIR="${SIM_ROOT}/validators"
|
|||
SECRETS_DIR="${SIM_ROOT}/secrets"
|
||||
SNAPSHOT_FILE="${SIMULATION_DIR}/state_snapshot.ssz"
|
||||
NETWORK_BOOTSTRAP_FILE="${SIMULATION_DIR}/bootstrap_nodes.txt"
|
||||
DEPOSIT_CONTRACT_FILE="${SIMULATION_DIR}/deposit_contract.txt"
|
||||
BEACON_NODE_BIN="${GIT_ROOT}/build/beacon_node"
|
||||
VALIDATOR_CLIENT_BIN="${GIT_ROOT}/build/validator_client"
|
||||
DEPLOY_DEPOSIT_CONTRACT_BIN="${GIT_ROOT}/build/deposit_contract"
|
||||
MASTER_NODE_ADDRESS_FILE="${SIMULATION_DIR}/node-${MASTER_NODE}/beacon_node.address"
|
||||
|
||||
WEB3_ARG="--web3-url=ws://localhost:8545"
|
||||
|
||||
BASE_P2P_PORT=30000
|
||||
BASE_RPC_PORT=7000
|
||||
BASE_METRICS_PORT=8008
|
||||
|
||||
if [[ "$USE_GANACHE" == "yes" ]]; then
|
||||
WEB3_ARG=--web3-url=ws://localhost:8545
|
||||
else
|
||||
WEB3_ARG=""
|
||||
DEPOSIT_CONTRACT_ADDRESS="0x"
|
||||
fi
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 26667818be48d428892b26be9535c1f0a98d1510
|
||||
Subproject commit aac25d1610a8fc15ae90fdd2a0b38ed60ea412fb
|
Loading…
Reference in New Issue