From c32a833bf7dff80b876ee1bcf4699b6723794e91 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 29 Mar 2019 00:36:39 +0200 Subject: [PATCH] Support for running a local simulation with arbitrary number of validators --- tests/simulation/run_node.sh | 17 +++++++---------- tests/simulation/start.sh | 4 ++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/tests/simulation/run_node.sh b/tests/simulation/run_node.sh index f2bf1f10c..8de368289 100755 --- a/tests/simulation/run_node.sh +++ b/tests/simulation/run_node.sh @@ -15,20 +15,17 @@ if [ "${NAT:-}" == "1" ]; then NAT_FLAG="--nat:extip:$(curl -s ifconfig.me)" fi +FIRST_VALIDATOR_IDX=$(printf '%07d' $(( (NUM_VALIDATORS / ($NUM_NODES + 1)) * $1 ))) +LAST_VALIDATOR_IDX=$(printf '%07d' $(( (NUM_VALIDATORS / ($NUM_NODES + 1)) * ($1 + 1) - 1 ))) + +mkdir -p $DATA_DIR/validators +rm -f $DATA_DIR/validators/* +eval cp ${VALIDATORS_DIR}/v{$FIRST_VALIDATOR_IDX..$LAST_VALIDATOR_IDX}.privkey $DATA_DIR/validators + $BEACON_NODE_BIN \ --network:$NETWORK_METADATA_FILE \ --dataDir:$DATA_DIR \ --nodename:${1} \ - --validator:${V_PREFIX}0.privkey \ - --validator:${V_PREFIX}1.privkey \ - --validator:${V_PREFIX}2.privkey \ - --validator:${V_PREFIX}3.privkey \ - --validator:${V_PREFIX}4.privkey \ - --validator:${V_PREFIX}5.privkey \ - --validator:${V_PREFIX}6.privkey \ - --validator:${V_PREFIX}7.privkey \ - --validator:${V_PREFIX}8.privkey \ - --validator:${V_PREFIX}9.privkey \ --tcpPort:$PORT \ --udpPort:$PORT \ $NAT_FLAG \ diff --git a/tests/simulation/start.sh b/tests/simulation/start.sh index 9be7bae38..9795bd089 100755 --- a/tests/simulation/start.sh +++ b/tests/simulation/start.sh @@ -7,8 +7,8 @@ set -eu # Set a default value for the env vars usually supplied by nimbus Makefile -NUM_VALIDATORS=${VALIDATORS:-100} -NUM_NODES=${NODES:-9} +export NUM_VALIDATORS=${VALIDATORS:-100} +export NUM_NODES=${NODES:-9} cd "$SIM_ROOT" mkdir -p "$SIMULATION_DIR"