diff --git a/Makefile b/Makefile index 1f6d2d5..ac51a3e 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ CURTIME := $(shell date +%s) # current system time in UNIX launch: @rm -rf output.txt @./scripts/generate_config.sh ${NODES} - ./scripts/launch_with_X_nodes.sh ${NODES} ${F} ${CURTIME} & + ./scripts/launch_with_X_nodes.sh ${NODES} ${F} ${CURTIME} # launch-default launches a protocol with 1 leader and 9 followers # sets F to 8 (hence, 8 Byzantine nodes can be tolerated) diff --git a/README.md b/README.md index cfbea18..785013f 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,13 @@ where `X` is a number of nodes and `Y` is a number of Byzantine nodes a protocol (in other words, a number of stages a protocol will execute). Note: available values for `Y`: [0; X-2]. + Reason: there should be at least 2 honest nodes in the system. +Note#2: available values for `X`: 3+. + +Reason: there should be at least 3 nodes in the consensus instance (otherwise, it's trivial). + ### Default way To run a protocol in default mode, execute: diff --git a/scripts/launch_with_X_nodes.sh b/scripts/launch_with_X_nodes.sh index ab7b8f2..af97966 100755 --- a/scripts/launch_with_X_nodes.sh +++ b/scripts/launch_with_X_nodes.sh @@ -4,6 +4,18 @@ num_of_nodes=$1 F=$2 curtime=$3 +upperbound_F=$(($num_of_nodes - 2)) + +if [ $num_of_nodes -lt 3 ]; then + echo -e "\033[31mERROR:\033[0m Number of nodes should be at least 3: got $num_of_nodes, expected 3 or more" >&2 + exit 1 +fi + +if [ $F -gt $upperbound_F ]; then + echo -e "\033[31mERROR:\033[0m F should not be set to more than number of nodes - 2: got $F, expected $upperbound_F or less" >&2 + exit 1 +fi + cargo run $(pwd)/config.txt 0 $F $curtime & # launch leader for ((i=1; i<$num_of_nodes; i++))