Support for running a local simulation with arbitrary number of validators

This commit is contained in:
Zahary Karadjov 2019-03-29 00:36:39 +02:00 committed by zah
parent 226a390c66
commit c32a833bf7
2 changed files with 9 additions and 12 deletions

View File

@ -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 \

View File

@ -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"