diff --git a/Makefile b/Makefile index 5c3c14dfb..74798e999 100644 --- a/Makefile +++ b/Makefile @@ -45,13 +45,13 @@ clean-testnet0: rm -rf ~/.cache/nimbus/BeaconNode/testnet0 testnet0: | build deps - ../../env.sh scripts/connect_to_testnet.sh testnet0 + ../../env.sh scripts/build_testnet_node.sh testnet0 clean-testnet1: rm -rf ~/.cache/nimbus/BeaconNode/testnet1 testnet1: | build deps - ../../env.sh scripts/connect_to_testnet.sh testnet1 + ../../env.sh scripts/build_testnet_node.sh testnet1 clean: rm -rf build/* nimcache diff --git a/beacon_chain/conf.nim b/beacon_chain/conf.nim index ff3252f60..9722b06d3 100644 --- a/beacon_chain/conf.nim +++ b/beacon_chain/conf.nim @@ -7,7 +7,7 @@ export defs const - defaultPort* = 9000 + DEFAULT_NETWORK* {.strdefine.} = "testnet0" type ValidatorKeyPath* = TypedInputFile[ValidatorPrivKey, Txt, "privkey"] @@ -28,7 +28,7 @@ type "Possible values: testnet0, testnet1, mainnet, custom-network.json" longform: "network" shortform: "n" - defaultValue: "testnet0".}: string + defaultValue: DEFAULT_NETWORK .}: string dataDir* {. desc: "The directory where nimbus will store all blockchain data." @@ -52,11 +52,11 @@ type tcpPort* {. desc: "TCP listening port" - defaultValue: defaultPort .}: int + defaultValue: defaultPort(config) .}: int udpPort* {. desc: "UDP listening port", - defaultValue: defaultPort .}: int + defaultValue: defaultPort(config) .}: int nat* {. desc: "Specify method to use for determining public address. Must be one of: any, extip:" @@ -102,7 +102,7 @@ type bootstrapPort* {. desc: "The TCP/UDP port that will be used by the bootstrap node" - defaultValue: defaultPort .}: int + defaultValue: defaultPort(config) .}: int genesisOffset* {. desc: "Seconds from now to add to genesis time" @@ -123,6 +123,10 @@ type of updateTestnet: discard +proc defaultPort*(config: BeaconNodeConf): int = + if config.network == "testnet1": 9100 + else: 9000 + proc defaultDataDir*(conf: BeaconNodeConf): string = let dataDir = when defined(windows): "AppData" / "Roaming" / "Nimbus" diff --git a/scripts/connect_to_testnet.sh b/scripts/build_testnet_node.sh similarity index 68% rename from scripts/connect_to_testnet.sh rename to scripts/build_testnet_node.sh index b8acf4158..48e1fc714 100755 --- a/scripts/connect_to_testnet.sh +++ b/scripts/build_testnet_node.sh @@ -12,7 +12,7 @@ source "$NETWORK_NAME.env" cd .. -NIM_FLAGS="-d:release --lineTrace:on -d:chronicles_log_level=DEBUG -d:SECONDS_PER_SLOT=$SECONDS_PER_SLOT -d:SHARD_COUNT=$SHARD_COUNT -d:SLOTS_PER_EPOCH=$SLOTS_PER_EPOCH --hints:off --verbosity:0" +NIM_FLAGS="-d:release --lineTrace:on -d:chronicles_log_level=DEBUG -d:SECONDS_PER_SLOT=$SECONDS_PER_SLOT -d:SHARD_COUNT=$SHARD_COUNT -d:SLOTS_PER_EPOCH=$SLOTS_PER_EPOCH -d:DEFAULT_NETWORK=$NETWORK_NAME --hints:off --verbosity:0" BEACON_NODE_BIN="build/${NETWORK_NAME}_node" @@ -24,5 +24,8 @@ if [ ! -d ~/.cache/nimbus/BeaconNode/${NETWORK_NAME}/validators ]; then $BEACON_NODE_BIN --network=$NETWORK_NAME importValidator fi -$BEACON_NODE_BIN --network=$NETWORK_NAME --tcpPort:$BOOTSTRAP_PORT --udpPort:$BOOTSTRAP_PORT +echo +echo "A binary for connecting to $NETWORK_NAME was placed in '$BEACON_NODE_BIN'" +echo "To sync with the network, launch it with default parameters" +echo