diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index 1b652449c..9e0afa84b 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -814,7 +814,6 @@ proc start(node: BeaconNode, headState: BeaconState) = int64(node.blockPool.finalizedHead.slot.toBeaconTime()) - int64(node.beaconClock.now()), stateSlot = shortLog(headState.slot), - SHARD_COUNT, SLOTS_PER_EPOCH, SECONDS_PER_SLOT, SPEC_VERSION, diff --git a/beacon_chain/version.nim b/beacon_chain/version.nim index 8a5103c30..42a901953 100644 --- a/beacon_chain/version.nim +++ b/beacon_chain/version.nim @@ -5,12 +5,12 @@ type rlpxBackend const - network_type {.strdefine.} = "libp2p_daemon" + NETWORK_TYPE {.strdefine.} = "libp2p_daemon" - networkBackend* = when network_type == "rlpx": rlpxBackend - elif network_type == "libp2p": libp2pBackend - elif network_type == "libp2p_daemon": libp2pDaemonBackend - else: {.fatal: "The 'network_type' should be either 'libp2p', 'libp2p_daemon' or 'rlpx'" .} + networkBackend* = when NETWORK_TYPE == "rlpx": rlpxBackend + elif NETWORK_TYPE == "libp2p": libp2pBackend + elif NETWORK_TYPE == "libp2p_daemon": libp2pDaemonBackend + else: {.fatal: "The 'NETWORK_TYPE' should be either 'libp2p', 'libp2p_daemon' or 'rlpx'" .} const copyrights* = "Copyright (c) 2019 Status Research & Development GmbH" @@ -35,5 +35,5 @@ const $versionMajor & "." & $versionMinor & "." & $versionBuild fullVersionStr* = - versionAsStr & " (" & gitRevision & ", " & network_type & ")" + versionAsStr & " (" & gitRevision & ", " & NETWORK_TYPE & ")" diff --git a/docker/Dockerfile b/docker/Dockerfile index 93aae721d..a56da257e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -28,7 +28,7 @@ ARG NETWORK_TYPE RUN cd nim-beacon-chain \ && set -a \ - && . scripts/${NETWORK}.env \ + && . scripts/load-testnet-nim-flags.sh scripts/${NETWORK}.env \ && ./env.sh nim \ -o:/usr/bin/beacon_node \ -d:release \ @@ -38,10 +38,7 @@ RUN cd nim-beacon-chain \ --verbosity:0 \ --hints:off \ --warnings:off \ - -d:"network_type=${NETWORK_TYPE}" \ - -d:"SHARD_COUNT=${SHARD_COUNT}" \ - -d:"SLOTS_PER_EPOCH=${SLOTS_PER_EPOCH}" \ - -d:"SECONDS_PER_SLOT=${SECONDS_PER_SLOT}" \ + ${TESTNET_NIM_FLAGS} \ -d:"chronicles_log_level=DEBUG" \ -d:"testnet_servers_image" \ c beacon_chain/beacon_node.nim diff --git a/scripts/load-testnet-nim-flags.sh b/scripts/load-testnet-nim-flags.sh new file mode 100644 index 000000000..aef3e6bb8 --- /dev/null +++ b/scripts/load-testnet-nim-flags.sh @@ -0,0 +1,21 @@ +set -a +source $1 +set +a + +TESTNET_NIM_FLAGS="" + +testnet_env () { + eval "TESTNET_FLAG_VALUE=\$$1" + if [[ ! -z "$TESTNET_FLAG_VALUE" ]]; then + TESTNET_NIM_FLAGS+=" -d:$1=$TESTNET_FLAG_VALUE" + fi +} + +testnet_env CONST_PRESET +testnet_env NETWORK_TYPE +testnet_env SLOTS_PER_EPOCH +testnet_env SLOTS_PER_EPOCH +testnet_env MAX_COMMITTEES_PER_SLOT + +export TESTNET_NIM_FLAGS + diff --git a/scripts/reset_testnet.sh b/scripts/reset_testnet.sh index 783df0ea8..7df5e455d 100755 --- a/scripts/reset_testnet.sh +++ b/scripts/reset_testnet.sh @@ -5,7 +5,7 @@ set -eu cd $(dirname "$0") NETWORK_NAME=$1 -source "$NETWORK_NAME.env" +source load-testnet-nim-flags.sh $NETWORK_NAME.env cd .. diff --git a/scripts/testnet0.env b/scripts/testnet0.env index dc4ea8760..f031f87bc 100644 --- a/scripts/testnet0.env +++ b/scripts/testnet0.env @@ -1,8 +1,5 @@ CONST_PRESET=minimal NETWORK_TYPE=libp2p_daemon -SHARD_COUNT=8 -SLOTS_PER_EPOCH=8 -SECONDS_PER_SLOT=6 QUICKSTART_VALIDATORS=8 RANDOM_VALIDATORS=120 BOOTSTRAP_PORT=9000 diff --git a/scripts/testnet1.env b/scripts/testnet1.env index 1dd241944..70c619bca 100644 --- a/scripts/testnet1.env +++ b/scripts/testnet1.env @@ -1,8 +1,8 @@ CONST_PRESET=minimal NETWORK_TYPE=libp2p_daemon -SHARD_COUNT=16 SLOTS_PER_EPOCH=16 SECONDS_PER_SLOT=16 +MAX_COMMITTEES_PER_SLOT=8 QUICKSTART_VALIDATORS=40 RANDOM_VALIDATORS=960 BOOTSTRAP_PORT=9100 diff --git a/tests/simulation/start.sh b/tests/simulation/start.sh index 5e7e08bbf..6a16f50bb 100755 --- a/tests/simulation/start.sh +++ b/tests/simulation/start.sh @@ -16,7 +16,7 @@ cd "$GIT_ROOT" NIMFLAGS="-d:chronicles_log_level=DEBUG --hints:off --warnings:off --verbosity:0 --opt:speed --debuginfo" -# Run with "SHARD_COUNT=4 ./start.sh" to change these +# Run with "SLOTS_PER_EPOCH=8 ./start.sh" to change these DEFS="" DEFS+="-d:MAX_COMMITTEES_PER_SLOT=${MAX_COMMITTEES_PER_SLOT:-1} " # Spec default: 64