From 3f5b4732ed574b78f9fb08171aba520e26d15988 Mon Sep 17 00:00:00 2001 From: A Date: Fri, 4 Nov 2022 09:59:09 +0100 Subject: [PATCH 01/13] Script to run the whole system in 1 command --- runSystems.sh | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100755 runSystems.sh diff --git a/runSystems.sh b/runSystems.sh new file mode 100755 index 000000000..901a6f855 --- /dev/null +++ b/runSystems.sh @@ -0,0 +1,156 @@ +#!/bin/bash + +# This script is creating n dela voting nodes needed to run +# an evoting system. User can pass number of nodes, window attach mode useful for autotest, +# and docker usage. + +set -e + +# by default run on local +DOCKER=false +ATTACH=true + +POSITIONAL_ARGS=() + +while [[ $# -gt 0 ]]; do + case $1 in + -h|--help) + echo "This script is creating n dela voting nodes" + echo "Options:" + echo "-h | --help program help (this file)" + echo "-n | --node number of d-voting nodes" + echo "-a | --attach attach tmux window to current shell true/false, by default true" + echo "-d | --docker launch nodes on docker containers true/false, by default false" + exit 0 + ;; + -n|--node) + N_NODE="$2" + shift # past argument + shift # past value + ;; + -a|--attach) + ATTACH="$2" + shift # past argument + shift # past value + ;; + -d|--docker) + DOCKER="$2" + shift # past argument + shift # past value + ;; + -*|--*) + echo "Unknown option $1" + exit 1 + ;; + *) + POSITIONAL_ARGS+=("$1") # save positional arg + shift # past argument + ;; + esac +done + +set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters + +set -o errexit + +command -v tmux >/dev/null 2>&1 || { echo >&2 "tmux is not on your PATH!"; exit 1; } + + +pk=adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 + + +# Launch session +s="d-voting-test" + +# check if session already exists, if so run the kill_test.sh script +if tmux has-session -t $s 2>/dev/null; then + echo "Session $s already exists, killing it" + ./kill_test.sh +fi + + + +tmux new-session -d -s $s + +# Checks that we can afford to have at least one Byzantine node and keep the +# system working, which is not possible with less than 4 nodes. +if [ $N_NODE -le 3 ]; then + echo "Warning: the number of nodes is less or equal than 3, it will not be resiliant if one node is down" +fi + + +# Clean logs +rm -rf ./log/log +mkdir -p ./log/log + +crypto bls signer new --save private.key --force + +if [ "$DOCKER" == false ]; then + go build -o memcoin ./cli/memcoin +else + # Clean created containers and tmp dir + if [[ $(docker ps -a -q --filter ancestor=node) ]]; then + docker rm -f $(docker ps -a -q --filter ancestor=node) + fi + + rm -rf ./nodedata + mkdir nodedata + + # Create docker network (only run once) + docker network create --driver bridge evoting-net || true + +fi + +from=1 +to=$N_NODE +while [ $from -le $to ] +do + +echo $from +tmux new-window -t $s +window=$from + +if [ "$DOCKER" == false ]; then + tmux send-keys -t $s:$window "PROXY_LOG=info LLVL=info ./memcoin \ + --config /tmp/node$from \ + start \ + --postinstall \ + --promaddr :$((9099 + $from)) \ + --proxyaddr :$((9079 + $from)) \ + --proxykey $pk \ + --listen tcp://0.0.0.0:$((2000 + $from)) \ + --routing tree \ + --public //localhost:$((2000 + $from))| tee ./log/log/node$from.log" C-m +else + docker run -d -it --env LLVL=info --name node$from --network evoting-net -v "$(pwd)"/nodedata:/tmp --publish $(( 9079+$from )):9080 node + tmux send-keys -t $s:$window "docker exec node$from memcoin --config /tmp/node$from start --postinstall \ + --promaddr :9100 --proxyaddr :9080 --proxykey $pk --listen tcp://0.0.0.0:2001 --public //$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' node$from):2001 | tee ./log/log/node$from.log" C-m +fi + +((from++)) +done + +# window for the backend +tmux new-window -t $s + +window=$from +tmux send-keys -t $s:$window "cd web/backend && npm start" C-m + + +# window for the frontend +((from++)) +tmux new-window -t $s +window=$from +tmux send-keys -t $s:$window "cd web/frontend && REACT_APP_PROXY=http://localhost:9081 REACT_APP_NOMOCK=on npm start" C-m + +sleep 4 + +tmux send-keys -t $s:$((0)) "./setupnNode.sh -n $N_NODE" C-m + +if [ "$ATTACH" == true ]; then + tmux a +fi + + + + From b4dff34235e4d8953d1f7d9f07175890109c3b01 Mon Sep 17 00:00:00 2001 From: A Date: Thu, 10 Nov 2022 11:22:16 +0100 Subject: [PATCH 02/13] Removed runNode.sh and setupnNode.sh since they are now replaced by runSystems --- runNode.sh | 138 --------------------- runSystems.sh | 326 +++++++++++++++++++++++++++++++++++--------------- setupnNode.sh | 190 ----------------------------- 3 files changed, 231 insertions(+), 423 deletions(-) delete mode 100755 runNode.sh delete mode 100755 setupnNode.sh diff --git a/runNode.sh b/runNode.sh deleted file mode 100755 index 2b87a41f8..000000000 --- a/runNode.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash - -# This script is creating n dela voting nodes needed to run -# an evoting system. User can pass number of nodes, window attach mode useful for autotest, -# and docker usage. - -set -e - -# by default run on local -DOCKER=false -ATTACH=true - -POSITIONAL_ARGS=() - -while [[ $# -gt 0 ]]; do - case $1 in - -h|--help) - echo "This script is creating n dela voting nodes" - echo "Options:" - echo "-h | --help program help (this file)" - echo "-n | --node number of d-voting nodes" - echo "-a | --attach attach tmux window to current shell true/false, by default true" - echo "-d | --docker launch nodes on docker containers true/false, by default false" - exit 0 - ;; - -n|--node) - N_NODE="$2" - shift # past argument - shift # past value - ;; - -a|--attach) - ATTACH="$2" - shift # past argument - shift # past value - ;; - -d|--docker) - DOCKER="$2" - shift # past argument - shift # past value - ;; - -*|--*) - echo "Unknown option $1" - exit 1 - ;; - *) - POSITIONAL_ARGS+=("$1") # save positional arg - shift # past argument - ;; - esac -done - -set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters - -set -o errexit - -command -v tmux >/dev/null 2>&1 || { echo >&2 "tmux is not on your PATH!"; exit 1; } - - -pk=adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 - - -# Launch session -s="d-voting-test" - -# check if session already exists, if so run the kill_test.sh script -if tmux has-session -t $s 2>/dev/null; then - echo "Session $s already exists, killing it" - ./kill_test.sh -fi - - - -tmux new-session -d -s $s - -# Checks that we can afford to have at least one Byzantine node and keep the -# system working, which is not possible with less than 4 nodes. -if [ $N_NODE -le 3 ]; then - echo "Warning: the number of nodes is less or equal than 3, it will not be resiliant if one node is down" -fi - - -# Clean logs -rm -rf ./log/log -mkdir -p ./log/log - -crypto bls signer new --save private.key --force - -if [ "$DOCKER" == false ]; then - go build -o memcoin ./cli/memcoin -else - # Clean created containers and tmp dir - if [[ $(docker ps -a -q --filter ancestor=node) ]]; then - docker rm -f $(docker ps -a -q --filter ancestor=node) - fi - - rm -rf ./nodedata - mkdir nodedata - - # Create docker network (only run once) - docker network create --driver bridge evoting-net || true - -fi - -from=1 -to=$N_NODE -while [ $from -le $to ] -do - -echo $from -tmux new-window -t $s -window=$from - -if [ "$DOCKER" == false ]; then - tmux send-keys -t $s:$window "PROXY_LOG=info LLVL=info ./memcoin \ - --config /tmp/node$from \ - start \ - --postinstall \ - --promaddr :$((9099 + $from)) \ - --proxyaddr :$((9079 + $from)) \ - --proxykey $pk \ - --listen tcp://0.0.0.0:$((2000 + $from)) \ - --routing tree \ - --public //localhost:$((2000 + $from))| tee ./log/log/node$from.log" C-m -else - docker run -d -it --env LLVL=info --name node$from --network evoting-net -v "$(pwd)"/nodedata:/tmp --publish $(( 9079+$from )):9080 node - tmux send-keys -t $s:$window "docker exec node$from memcoin --config /tmp/node$from start --postinstall \ - --promaddr :9100 --proxyaddr :9080 --proxykey $pk --listen tcp://0.0.0.0:2001 --public //$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' node$from):2001 | tee ./log/log/node$from.log" C-m -fi - -((from++)) -done - -tmux new-window -t $s - - -if [ "$ATTACH" == true ]; then - tmux a -fi diff --git a/runSystems.sh b/runSystems.sh index 901a6f855..f1ba0669d 100755 --- a/runSystems.sh +++ b/runSystems.sh @@ -6,46 +6,71 @@ set -e +#TODO: add option to say if we want to run, setup or both # by default run on local DOCKER=false ATTACH=true +RUN=true +SETUP=true +FRONTEND=true +BACKEND=true POSITIONAL_ARGS=() while [[ $# -gt 0 ]]; do case $1 in - -h|--help) - echo "This script is creating n dela voting nodes" - echo "Options:" - echo "-h | --help program help (this file)" - echo "-n | --node number of d-voting nodes" - echo "-a | --attach attach tmux window to current shell true/false, by default true" - echo "-d | --docker launch nodes on docker containers true/false, by default false" - exit 0 - ;; - -n|--node) - N_NODE="$2" - shift # past argument - shift # past value - ;; - -a|--attach) - ATTACH="$2" - shift # past argument - shift # past value - ;; - -d|--docker) - DOCKER="$2" - shift # past argument - shift # past value - ;; - -*|--*) - echo "Unknown option $1" - exit 1 - ;; - *) - POSITIONAL_ARGS+=("$1") # save positional arg - shift # past argument - ;; + -h | --help) + echo "This script is creating n dela voting nodes" + echo "Options:" + echo "-h | --help program help (this file)" + echo "-n | --node number of d-voting nodes" + echo "-a | --attach attach tmux window to current shell true/false, by default true" + echo "-d | --docker launch nodes on docker containers true/false, by default false" + exit 0 + ;; + -r | --run) + RUN="$2" + shift # past argument + shift # past value + ;; + -s | --setup) + SETUP="$2" + shift # past argument + shift # past value + ;; + -f | --frontend) + FRONTEND="$2" + shift # past argument + shift # past value + ;; + -b | --backend) + BACKEND="$2" + shift # past argument + shift # past value + ;; + -n | --node) + N_NODE="$2" + shift # past argument + shift # past value + ;; + -a | --attach) + ATTACH="$2" + shift # past argument + shift # past value + ;; + -d | --docker) + DOCKER="$2" + shift # past argument + shift # past value + ;; + -* | --*) + echo "Unknown option $1" + exit 1 + ;; + *) + POSITIONAL_ARGS+=("$1") # save positional arg + shift # past argument + ;; esac done @@ -53,104 +78,215 @@ set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters set -o errexit -command -v tmux >/dev/null 2>&1 || { echo >&2 "tmux is not on your PATH!"; exit 1; } - +command -v tmux >/dev/null 2>&1 || { + echo >&2 "tmux is not on your PATH!" + exit 1 +} pk=adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 - # Launch session s="d-voting-test" +from=0 +if [ "$RUN" == true ]; then + # check if session already exists, if so run the kill_test.sh script + if tmux has-session -t $s 2>/dev/null; then + echo "Session $s already exists, killing it" + ./kill_test.sh + fi -# check if session already exists, if so run the kill_test.sh script -if tmux has-session -t $s 2>/dev/null; then - echo "Session $s already exists, killing it" - ./kill_test.sh -fi - - - -tmux new-session -d -s $s - -# Checks that we can afford to have at least one Byzantine node and keep the -# system working, which is not possible with less than 4 nodes. -if [ $N_NODE -le 3 ]; then - echo "Warning: the number of nodes is less or equal than 3, it will not be resiliant if one node is down" -fi + tmux new-session -d -s $s + # Checks that we can afford to have at least one Byzantine node and keep the + # system working, which is not possible with less than 4 nodes. + if [ $N_NODE -le 3 ]; then + echo "Warning: the number of nodes is less or equal than 3, it will not be resiliant if one node is down" + fi -# Clean logs -rm -rf ./log/log -mkdir -p ./log/log + # Clean logs + rm -rf ./log/log + mkdir -p ./log/log -crypto bls signer new --save private.key --force + crypto bls signer new --save private.key --force -if [ "$DOCKER" == false ]; then + if [ "$DOCKER" == false ]; then go build -o memcoin ./cli/memcoin -else + else # Clean created containers and tmp dir if [[ $(docker ps -a -q --filter ancestor=node) ]]; then - docker rm -f $(docker ps -a -q --filter ancestor=node) + docker rm -f $(docker ps -a -q --filter ancestor=node) fi - rm -rf ./nodedata + rm -rf ./nodedata mkdir nodedata # Create docker network (only run once) docker network create --driver bridge evoting-net || true -fi + fi + + from=1 + to=$N_NODE + while [ $from -le $to ]; do + + echo $from + tmux new-window -t $s + window=$from + + if [ "$DOCKER" == false ]; then + tmux send-keys -t $s:$window "PROXY_LOG=info LLVL=info ./memcoin \ + --config /tmp/node$from \ + start \ + --postinstall \ + --promaddr :$((9099 + $from)) \ + --proxyaddr :$((9079 + $from)) \ + --proxykey $pk \ + --listen tcp://0.0.0.0:$((2000 + $from)) \ + --routing tree \ + --public //localhost:$((2000 + $from))| tee ./log/log/node$from.log" C-m + else + docker run -d -it --env LLVL=info --name node$from --network evoting-net -v "$(pwd)"/nodedata:/tmp --publish $((9079 + $from)):9080 node + tmux send-keys -t $s:$window "docker exec node$from memcoin --config /tmp/node$from start --postinstall \ + --promaddr :9100 --proxyaddr :9080 --proxykey $pk --listen tcp://0.0.0.0:2001 --public //$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' node$from):2001 | tee ./log/log/node$from.log" C-m + fi + + ((from++)) + done -from=1 -to=$N_NODE -while [ $from -le $to ] -do +fi -echo $from -tmux new-window -t $s window=$from +if [ "$BACKEND" == true ]; then + if tmux has-session -t $s 2>/dev/null; then + # window for the backend + tmux new-window -t $s -if [ "$DOCKER" == false ]; then - tmux send-keys -t $s:$window "PROXY_LOG=info LLVL=info ./memcoin \ - --config /tmp/node$from \ - start \ - --postinstall \ - --promaddr :$((9099 + $from)) \ - --proxyaddr :$((9079 + $from)) \ - --proxykey $pk \ - --listen tcp://0.0.0.0:$((2000 + $from)) \ - --routing tree \ - --public //localhost:$((2000 + $from))| tee ./log/log/node$from.log" C-m -else - docker run -d -it --env LLVL=info --name node$from --network evoting-net -v "$(pwd)"/nodedata:/tmp --publish $(( 9079+$from )):9080 node - tmux send-keys -t $s:$window "docker exec node$from memcoin --config /tmp/node$from start --postinstall \ - --promaddr :9100 --proxyaddr :9080 --proxykey $pk --listen tcp://0.0.0.0:2001 --public //$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' node$from):2001 | tee ./log/log/node$from.log" C-m + tmux send-keys -t $s:$window "cd web/backend && PORT=4000 npm start" C-m + fi +fi +window=$((from + 1)) +# window for the frontend +if [ "$FRONTEND" == true ]; then + if tmux has-session -t $s 2>/dev/null; then + tmux new-window -t $s + + tmux send-keys -t $s:$window "cd web/frontend && REACT_APP_PROXY=http://localhost:9081 REACT_APP_NOMOCK=on npm start" C-m + fi fi ((from++)) -done -# window for the backend -tmux new-window -t $s +# Setup +if [ "$SETUP" == true ]; then + if [ "$RUN" == true ]; then + sleep 8 + fi + if tmux has-session -t $s 2>/dev/null; then + # window for the setup + tmux send-keys -t $s:$((0)) "./setupnNode.sh -n $N_NODE" C-m + GREEN='\033[0;32m' + NC='\033[0m' # No Color -window=$from -tmux send-keys -t $s:$window "cd web/backend && npm start" C-m + if [ "$DOCKER" == false ]; then + echo "${GREEN}[1/4]${NC} connect nodes" + from=2 + to=$N_NODE + while [ $from -le $to ]; do + ./memcoin --config /tmp/node$from minogrpc join \ + --address //localhost:2001 $(./memcoin --config /tmp/node1 minogrpc token) -# window for the frontend -((from++)) -tmux new-window -t $s -window=$from -tmux send-keys -t $s:$window "cd web/frontend && REACT_APP_PROXY=http://localhost:9081 REACT_APP_NOMOCK=on npm start" C-m + ((from++)) + done -sleep 4 + echo "${GREEN}[2/4]${NC} create a chain" -tmux send-keys -t $s:$((0)) "./setupnNode.sh -n $N_NODE" C-m + ARRAY="" + from=1 + to=$N_NODE + while [ $from -le $to ]; do + ARRAY+="--member " + ARRAY+="$(./memcoin --config /tmp/node$from ordering export) " -if [ "$ATTACH" == true ]; then - tmux a -fi + ((from++)) + done + + ./memcoin --config /tmp/node1 ordering setup $ARRAY + echo "${GREEN}[3/4]${NC} setup access rights on each node" + from=1 + while [ $from -le $to ]; do + ./memcoin --config /tmp/node$from access add \ + --identity $(crypto bls signer read --path private.key --format BASE64_PUBKEY) + ((from++)) + done + + echo "${GREEN}[4/4]${NC} grant access on the chain" + + ./memcoin --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $(crypto bls signer read --path private.key --format BASE64_PUBKEY) \ + --args access:command --args GRANT + + from=1 + + while [ $from -le $to ]; do + + ./memcoin --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $(crypto bls signer read --path /tmp/node$from/private.key --format BASE64_PUBKEY) \ + --args access:command --args GRANT + + ((from++)) + done + else + echo "${GREEN}[1/4]${NC} connect nodes" + conn_token=$(docker exec node1 memcoin --config /tmp/node1 minogrpc token) + vals=($(seq 2 1 $N_NODE)) + + for i in "${vals[@]}"; do + docker exec node$i memcoin --config /tmp/node$i minogrpc join \ + --address //$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' node1):2001 $conn_token + + done + + echo "${GREEN}[2/4]${NC} create a chain" + vals=($(seq 1 1 $N_NODE)) + ARRAY="" + for i in "${vals[@]}"; do + ARRAY+="--member " + ARRAY+="$(docker exec node$i memcoin --config /tmp/node$i ordering export) " + echo "Node$i addr is:" + echo $(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' node$i) + done + + docker exec node1 memcoin --config /tmp/node1 ordering setup $ARRAY + + echo "${GREEN}[3/4]${NC} setup access rights on each node" + access_token=$(docker exec node1 crypto bls signer read --path private.key --format BASE64_PUBKEY) + + for i in "${vals[@]}"; do + docker exec node$i memcoin --config /tmp/node$i access add \ + --identity $access_token + sleep 1 + done + + echo "${GREEN}[4/4]${NC} grant access on the chain" + + docker exec node1 memcoin --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $access_token --args access:command --args GRANT + + sleep 1 + + for i in "${vals[@]}"; do + access_token_tmp=$(docker exec node$i crypto bls signer read --path /tmp/node$i/private.key --format BASE64_PUBKEY) + docker exec node1 memcoin --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $access_token_tmp --args access:command --args GRANT + sleep 1 + done + fi + fi +fi + +#tmux send-keys -t $s:$((0)) "./setupnNode.sh -n $N_NODE" C-m + +if [ "$ATTACH" == true ]; then + tmux a +fi diff --git a/setupnNode.sh b/setupnNode.sh deleted file mode 100755 index a492b346b..000000000 --- a/setupnNode.sh +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/env bash - -# This script is creating a new chain and setting up the services needed to run -# an evoting system. It ends by starting the http server needed by the frontend -# to communicate with the blockchain. This operation is blocking. It is expected -# that the "memcoin" binary is at the root. You can build it with: -# go build ./cli/memcoin - -# by default run on local -DOCKER=false - -POSITIONAL_ARGS=() - -while [[ $# -gt 0 ]]; do - case $1 in - -h|--help) - echo "This script is setting n dela voting nodes and granting access on block chain" - echo "Options:" - echo "-h | --help program help (this file)" - echo "-n | --node number of d-voting nodes" - echo "-d | --docker launch nodes on docker containers true/false, by default false" - exit 0 - ;; - -n|--node) - N_NODE="$2" - shift # past argument - shift # past value - ;; - -d|--docker) - DOCKER="$2" - shift # past argument - shift # past value - ;; - -*|--*) - echo "Unknown option $1" - exit 1 - ;; - *) - POSITIONAL_ARGS+=("$1") # save positional arg - shift # past argument - ;; - esac -done - -set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters - -set -e - -GREEN='\033[0;32m' -NC='\033[0m' # No Color - -if [ "$DOCKER" == false ]; then - echo "${GREEN}[1/4]${NC} connect nodes" - - from=2 - to=$N_NODE - while [ $from -le $to ] - do - ./memcoin --config /tmp/node$from minogrpc join \ - --address //localhost:2001 $(./memcoin --config /tmp/node1 minogrpc token) - - ((from++)) - done - - echo "${GREEN}[2/4]${NC} create a chain" - - ARRAY="" - from=1 - to=$N_NODE - while [ $from -le $to ] - do - ARRAY+="--member " - ARRAY+="$(./memcoin --config /tmp/node$from ordering export) " - - ((from++)) - done - - ./memcoin --config /tmp/node1 ordering setup $ARRAY - - - echo "${GREEN}[3/4]${NC} setup access rights on each node" - - from=1 - - while [ $from -le $to ] - do - ./memcoin --config /tmp/node$from access add \ - --identity $(crypto bls signer read --path private.key --format BASE64_PUBKEY) - - ((from++)) - done - - - echo "${GREEN}[4/4]${NC} grant access on the chain" - - ./memcoin --config /tmp/node1 pool add\ - --key private.key\ - --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access\ - --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000\ - --args access:grant_contract --args go.dedis.ch/dela.Evoting\ - --args access:grant_command --args all\ - --args access:identity --args $(crypto bls signer read --path private.key --format BASE64_PUBKEY)\ - --args access:command --args GRANT - - - from=1 - - while [ $from -le $to ] - do - - ./memcoin --config /tmp/node1 pool add\ - --key private.key\ - --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access\ - --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000\ - --args access:grant_contract --args go.dedis.ch/dela.Evoting\ - --args access:grant_command --args all\ - --args access:identity --args $(crypto bls signer read --path /tmp/node$from/private.key --format BASE64_PUBKEY)\ - --args access:command --args GRANT - - - ((from++)) - done -else - echo "${GREEN}[1/4]${NC} connect nodes" - conn_token=$(docker exec node1 memcoin --config /tmp/node1 minogrpc token) - vals=($(seq 2 1 $N_NODE)) - - for i in "${vals[@]}" - do - docker exec node$i memcoin --config /tmp/node$i minogrpc join \ - --address //$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' node1):2001 $conn_token - - done - - - echo "${GREEN}[2/4]${NC} create a chain" - vals=($(seq 1 1 $N_NODE)) - ARRAY="" - for i in "${vals[@]}" - do - ARRAY+="--member " - ARRAY+="$(docker exec node$i memcoin --config /tmp/node$i ordering export) " - echo "Node$i addr is:" - echo $(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' node$i) - done - - - docker exec node1 memcoin --config /tmp/node1 ordering setup $ARRAY - - - echo "${GREEN}[3/4]${NC} setup access rights on each node" - access_token=$(docker exec node1 crypto bls signer read --path private.key --format BASE64_PUBKEY) - - for i in "${vals[@]}" - do - docker exec node$i memcoin --config /tmp/node$i access add \ - --identity $access_token - sleep 1 - done - - - - echo "${GREEN}[4/4]${NC} grant access on the chain" - - - docker exec node1 memcoin --config /tmp/node1 pool add\ - --key private.key\ - --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access\ - --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000\ - --args access:grant_contract --args go.dedis.ch/dela.Evoting\ - --args access:grant_command --args all\ - --args access:identity --args $access_token\ - --args access:command --args GRANT - - sleep 1 - - for i in "${vals[@]}" - do - access_token_tmp=$(docker exec node$i crypto bls signer read --path /tmp/node$i/private.key --format BASE64_PUBKEY) - docker exec node1 memcoin --config /tmp/node1 pool add\ - --key private.key\ - --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access\ - --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000\ - --args access:grant_contract --args go.dedis.ch/dela.Evoting\ - --args access:grant_command --args all\ - --args access:identity --args $access_token_tmp\ - --args access:command --args GRANT - sleep 1 - done -fi \ No newline at end of file From a0a37e01ac3bb890e475b4d002ce77ee0975e19c Mon Sep 17 00:00:00 2001 From: A Date: Thu, 10 Nov 2022 11:29:28 +0100 Subject: [PATCH 03/13] Change the senario test to use the good script --- .github/workflows/go_scenario_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go_scenario_test.yml b/.github/workflows/go_scenario_test.yml index 5d763271a..18107c3fe 100644 --- a/.github/workflows/go_scenario_test.yml +++ b/.github/workflows/go_scenario_test.yml @@ -39,7 +39,7 @@ jobs: ./memcoin --config /tmp/node3 start --postinstall --promaddr :9102 --proxyaddr :9082 --proxykey adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 --listen tcp://0.0.0.0:2003 --public //localhost:2003 --routing tree & - name: Run the setup - run: ./setupnNode.sh -n 3 -d false + run: ./runSystems -n 3 -d false -r false -b false -f false - name: Run the scenario Test run: go test -timeout 7m -run TestScenario ./integration/... From d6d4b7aa0a8a2ee239037ff941ad13610e92e54e Mon Sep 17 00:00:00 2001 From: A Date: Thu, 10 Nov 2022 11:39:43 +0100 Subject: [PATCH 04/13] fixed typo in go_scenario_test.yml --- .github/workflows/go_scenario_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go_scenario_test.yml b/.github/workflows/go_scenario_test.yml index 18107c3fe..0b650eb67 100644 --- a/.github/workflows/go_scenario_test.yml +++ b/.github/workflows/go_scenario_test.yml @@ -39,7 +39,7 @@ jobs: ./memcoin --config /tmp/node3 start --postinstall --promaddr :9102 --proxyaddr :9082 --proxykey adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 --listen tcp://0.0.0.0:2003 --public //localhost:2003 --routing tree & - name: Run the setup - run: ./runSystems -n 3 -d false -r false -b false -f false + run: ./runSystems.sh -n 3 -d false -r false -b false -f false - name: Run the scenario Test run: go test -timeout 7m -run TestScenario ./integration/... From abcacead6f9683da38da089fbf724d869c028bd7 Mon Sep 17 00:00:00 2001 From: A Date: Sun, 13 Nov 2022 12:00:15 +0100 Subject: [PATCH 05/13] help run systems --- runSystems.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runSystems.sh b/runSystems.sh index f1ba0669d..5299ada02 100755 --- a/runSystems.sh +++ b/runSystems.sh @@ -26,6 +26,10 @@ while [[ $# -gt 0 ]]; do echo "-n | --node number of d-voting nodes" echo "-a | --attach attach tmux window to current shell true/false, by default true" echo "-d | --docker launch nodes on docker containers true/false, by default false" + echo "-r | --run run the nodes true/false, by default true" + echo "-s | --setup setup the nodes true/false, by default true" + echo "-f | --frontend setup the frontend true/false, by default true" + echo "-b | --backend setup the backend true/false, by default true" exit 0 ;; -r | --run) From 163795279663f287483b58a1a9180535db17fcb3 Mon Sep 17 00:00:00 2001 From: A Date: Mon, 14 Nov 2022 08:50:54 +0100 Subject: [PATCH 06/13] updeted scenario test to use new script --- .github/workflows/go_scenario_test.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/go_scenario_test.yml b/.github/workflows/go_scenario_test.yml index 0b650eb67..060b9d397 100644 --- a/.github/workflows/go_scenario_test.yml +++ b/.github/workflows/go_scenario_test.yml @@ -32,14 +32,8 @@ jobs: - name: Install memcoin run: make build - - name: Start 3 nodes - run: | - ./memcoin --config /tmp/node1 start --postinstall --promaddr :9100 --proxyaddr :9080 --proxykey adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 --listen tcp://0.0.0.0:2001 --public //localhost:2001 --routing tree & - ./memcoin --config /tmp/node2 start --postinstall --promaddr :9101 --proxyaddr :9081 --proxykey adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 --listen tcp://0.0.0.0:2002 --public //localhost:2002 --routing tree & - ./memcoin --config /tmp/node3 start --postinstall --promaddr :9102 --proxyaddr :9082 --proxykey adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 --listen tcp://0.0.0.0:2003 --public //localhost:2003 --routing tree & - - - name: Run the setup - run: ./runSystems.sh -n 3 -d false -r false -b false -f false + - name: Start and setup 3 nodes + run: ./runSystems.sh -n 3 -d false --backend false --frontend false - name: Run the scenario Test run: go test -timeout 7m -run TestScenario ./integration/... From 3d168df6e7fddbb2bc54d1f615fd740c7cab09a2 Mon Sep 17 00:00:00 2001 From: A Date: Mon, 14 Nov 2022 09:00:49 +0100 Subject: [PATCH 07/13] fix for scenario test --- .github/workflows/go_scenario_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go_scenario_test.yml b/.github/workflows/go_scenario_test.yml index 060b9d397..e1fdd58e8 100644 --- a/.github/workflows/go_scenario_test.yml +++ b/.github/workflows/go_scenario_test.yml @@ -33,7 +33,7 @@ jobs: run: make build - name: Start and setup 3 nodes - run: ./runSystems.sh -n 3 -d false --backend false --frontend false + run: ./runSystems.sh -n 3 -d false --backend false --frontend false -a false - name: Run the scenario Test run: go test -timeout 7m -run TestScenario ./integration/... From 862a0db459eae0fe536a00133f41dcf9dd689dc6 Mon Sep 17 00:00:00 2001 From: A Date: Mon, 14 Nov 2022 10:03:13 +0100 Subject: [PATCH 08/13] fixed runSystems and kill_test --- kill_test.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ runSystems.sh | 34 ++++++++++++++++++++++------------ 2 files changed, 72 insertions(+), 12 deletions(-) diff --git a/kill_test.sh b/kill_test.sh index 270f13b7d..d8560e1e8 100755 --- a/kill_test.sh +++ b/kill_test.sh @@ -2,5 +2,55 @@ # This script kills the tmux session started in start_test.sh and # removes all the data pertaining to the test. +FRONTEND=true +BACKEND=true + +while [[ $# -gt 0 ]]; do + case $1 in + -h | --help) + echo "This script is creating n dela voting nodes" + echo "Options:" + echo "-h | --help program help (this file)" + echo "-f | --frontend setup the frontend true/false, by default true" + echo "-b | --backend setup the backend true/false, by default true" + exit 0 + ;; + -f | --frontend) + FRONTEND="$2" + shift # past argument + shift # past value + ;; + -b | --backend) + BACKEND="$2" + shift # past argument + shift # past value + ;; + -* | --*) + echo "Unknown option $1" + exit 1 + ;; + *) + POSITIONAL_ARGS+=("$1") # save positional arg + shift # past argument + ;; + esac +done + +set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters + +set -o errexit + +command -v tmux >/dev/null 2>&1 || { + echo >&2 "tmux is not on your PATH!" + exit 1 +} + +if [ "$FRONTEND" = true ]; then + tmux send-keys -t $s:{end} C-c + tmux kill-window -t $s:{end} +fi +if [ "$BACKEND" = true ]; then + tmux send-keys -t $s:{end} C-c +fi rm -rf /tmp/node* && tmux kill-session -t d-voting-test diff --git a/runSystems.sh b/runSystems.sh index 5299ada02..2fa9dd34a 100755 --- a/runSystems.sh +++ b/runSystems.sh @@ -6,10 +6,10 @@ set -e -#TODO: add option to say if we want to run, setup or both # by default run on local DOCKER=false ATTACH=true +# by default run and setup everything RUN=true SETUP=true FRONTEND=true @@ -93,6 +93,12 @@ pk=adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 s="d-voting-test" from=0 if [ "$RUN" == true ]; then + + if [ -z "$N_NODE" ]; then + echo "Please specify the number of nodes" + exit 1 + fi + # check if session already exists, if so run the kill_test.sh script if tmux has-session -t $s 2>/dev/null; then echo "Session $s already exists, killing it" @@ -159,22 +165,25 @@ if [ "$RUN" == true ]; then fi -window=$from if [ "$BACKEND" == true ]; then if tmux has-session -t $s 2>/dev/null; then # window for the backend - tmux new-window -t $s - - tmux send-keys -t $s:$window "cd web/backend && PORT=4000 npm start" C-m + tmux new-window -t $s -n "backend" + tmux send-keys -t $s:{end} "cd web/backend && PORT=4000 npm start" C-m + else + #run it in the current shell + cd web/backend && PORT=4000 npm start fi fi -window=$((from + 1)) + # window for the frontend if [ "$FRONTEND" == true ]; then if tmux has-session -t $s 2>/dev/null; then - tmux new-window -t $s - - tmux send-keys -t $s:$window "cd web/frontend && REACT_APP_PROXY=http://localhost:9081 REACT_APP_NOMOCK=on npm start" C-m + tmux new-window -t $s -n "frontend" + tmux send-keys -t $s:{end} "cd web/frontend && REACT_APP_PROXY=http://localhost:9081 REACT_APP_NOMOCK=on npm start" C-m + else + #run it in the current shell + cd web/frontend && REACT_APP_PROXY=http://localhost:9081 REACT_APP_NOMOCK=on npm start fi fi @@ -182,12 +191,15 @@ fi # Setup if [ "$SETUP" == true ]; then + if [ -z "$N_NODE" ]; then + echo "Please specify the number of nodes" + exit 1 + fi if [ "$RUN" == true ]; then sleep 8 fi if tmux has-session -t $s 2>/dev/null; then # window for the setup - tmux send-keys -t $s:$((0)) "./setupnNode.sh -n $N_NODE" C-m GREEN='\033[0;32m' NC='\033[0m' # No Color @@ -289,8 +301,6 @@ if [ "$SETUP" == true ]; then fi fi -#tmux send-keys -t $s:$((0)) "./setupnNode.sh -n $N_NODE" C-m - if [ "$ATTACH" == true ]; then tmux a fi From e50619838f30db6b0db8c71f774ca50d57456437 Mon Sep 17 00:00:00 2001 From: A Date: Mon, 14 Nov 2022 10:12:24 +0100 Subject: [PATCH 09/13] runSystems reset backend port --- runSystems.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runSystems.sh b/runSystems.sh index 2fa9dd34a..01eeff2a2 100755 --- a/runSystems.sh +++ b/runSystems.sh @@ -169,10 +169,10 @@ if [ "$BACKEND" == true ]; then if tmux has-session -t $s 2>/dev/null; then # window for the backend tmux new-window -t $s -n "backend" - tmux send-keys -t $s:{end} "cd web/backend && PORT=4000 npm start" C-m + tmux send-keys -t $s:{end} "cd web/backend && npm start" C-m else #run it in the current shell - cd web/backend && PORT=4000 npm start + cd web/backend && npm start fi fi From d71d98cded5bf122d1a3f07e317396b6fc450e07 Mon Sep 17 00:00:00 2001 From: A Date: Mon, 21 Nov 2022 08:35:34 +0100 Subject: [PATCH 10/13] fixed details in scripts --- .github/workflows/go_scenario_test.yml | 2 +- kill_test.sh | 4 +- runSystems.sh | 51 +++++++++++++++++--------- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/.github/workflows/go_scenario_test.yml b/.github/workflows/go_scenario_test.yml index e1fdd58e8..0de07a799 100644 --- a/.github/workflows/go_scenario_test.yml +++ b/.github/workflows/go_scenario_test.yml @@ -33,7 +33,7 @@ jobs: run: make build - name: Start and setup 3 nodes - run: ./runSystems.sh -n 3 -d false --backend false --frontend false -a false + run: ./runSystems.sh -n 3 --docker false --backend false --frontend false --attach false - name: Run the scenario Test run: go test -timeout 7m -run TestScenario ./integration/... diff --git a/kill_test.sh b/kill_test.sh index d8560e1e8..acd8604ab 100755 --- a/kill_test.sh +++ b/kill_test.sh @@ -11,8 +11,8 @@ while [[ $# -gt 0 ]]; do echo "This script is creating n dela voting nodes" echo "Options:" echo "-h | --help program help (this file)" - echo "-f | --frontend setup the frontend true/false, by default true" - echo "-b | --backend setup the backend true/false, by default true" + echo "-f | --frontend kill the frontend true/false, by default true" + echo "-b | --backend kill the backend true/false, by default true" exit 0 ;; -f | --frontend) diff --git a/runSystems.sh b/runSystems.sh index 01eeff2a2..823f9ad04 100755 --- a/runSystems.sh +++ b/runSystems.sh @@ -14,6 +14,7 @@ RUN=true SETUP=true FRONTEND=true BACKEND=true +N_NODE=0 POSITIONAL_ARGS=() @@ -94,8 +95,13 @@ s="d-voting-test" from=0 if [ "$RUN" == true ]; then - if [ -z "$N_NODE" ]; then - echo "Please specify the number of nodes" + #check that N_NODE is between 1 and 20 + if [ "$N_NODE" -lt 1 ]; then + echo "N_NODE must be greater than 0" + exit 1 + fi + if [ "$N_NODE" -gt 20 ]; then + echo "N_NODE must be less than 20" exit 1 fi @@ -109,13 +115,13 @@ if [ "$RUN" == true ]; then # Checks that we can afford to have at least one Byzantine node and keep the # system working, which is not possible with less than 4 nodes. - if [ $N_NODE -le 3 ]; then - echo "Warning: the number of nodes is less or equal than 3, it will not be resiliant if one node is down" + if [ $N_NODE -lt 4 ]; then + echo "Warning: the number of nodes is less than 4, it will not be resilient if one node is down" fi # Clean logs - rm -rf ./log/log - mkdir -p ./log/log + rm -rf ./log + mkdir -p ./log crypto bls signer new --save private.key --force @@ -142,10 +148,11 @@ if [ "$RUN" == true ]; then echo $from tmux new-window -t $s window=$from + node_name="node$from" if [ "$DOCKER" == false ]; then tmux send-keys -t $s:$window "PROXY_LOG=info LLVL=info ./memcoin \ - --config /tmp/node$from \ + --config /tmp/$node_name \ start \ --postinstall \ --promaddr :$((9099 + $from)) \ @@ -153,11 +160,11 @@ if [ "$RUN" == true ]; then --proxykey $pk \ --listen tcp://0.0.0.0:$((2000 + $from)) \ --routing tree \ - --public //localhost:$((2000 + $from))| tee ./log/log/node$from.log" C-m + --public //localhost:$((2000 + $from))| tee ./log/$node_name.log" C-m else - docker run -d -it --env LLVL=info --name node$from --network evoting-net -v "$(pwd)"/nodedata:/tmp --publish $((9079 + $from)):9080 node - tmux send-keys -t $s:$window "docker exec node$from memcoin --config /tmp/node$from start --postinstall \ - --promaddr :9100 --proxyaddr :9080 --proxykey $pk --listen tcp://0.0.0.0:2001 --public //$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' node$from):2001 | tee ./log/log/node$from.log" C-m + docker run -d -it --env LLVL=info --name $node_name --network evoting-net -v "$(pwd)"/nodedata:/tmp --publish $((9079 + $from)):9080 node + tmux send-keys -t $s:$window "docker exec $node_name memcoin --config /tmp/$node_name start --postinstall \ + --promaddr :9100 --proxyaddr :9080 --proxykey $pk --listen tcp://0.0.0.0:2001 --public //$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $node_name):2001 | tee ./log/$node_name.log" C-m fi ((from++)) @@ -191,13 +198,22 @@ fi # Setup if [ "$SETUP" == true ]; then - if [ -z "$N_NODE" ]; then - echo "Please specify the number of nodes" + + #check that N_NODE is between 1 and 20 + if [ "$N_NODE" -lt 1 ]; then + echo "N_NODE must be greater than 0" exit 1 fi + if [ "$N_NODE" -gt 20 ]; then + echo "N_NODE must be less than 20" + exit 1 + fi + + #If we runned the system as well, we should wait for it to be ready if [ "$RUN" == true ]; then sleep 8 fi + if tmux has-session -t $s 2>/dev/null; then # window for the setup GREEN='\033[0;32m' @@ -209,7 +225,7 @@ if [ "$SETUP" == true ]; then from=2 to=$N_NODE while [ $from -le $to ]; do - ./memcoin --config /tmp/node$from minogrpc join \ + ./memcoin --config /tmp/$node_name minogrpc join \ --address //localhost:2001 $(./memcoin --config /tmp/node1 minogrpc token) ((from++)) @@ -221,8 +237,9 @@ if [ "$SETUP" == true ]; then from=1 to=$N_NODE while [ $from -le $to ]; do + node_name="node$from" ARRAY+="--member " - ARRAY+="$(./memcoin --config /tmp/node$from ordering export) " + ARRAY+="$(./memcoin --config /tmp/$node_name ordering export) " ((from++)) done @@ -234,7 +251,7 @@ if [ "$SETUP" == true ]; then from=1 while [ $from -le $to ]; do - ./memcoin --config /tmp/node$from access add \ + ./memcoin --config /tmp/$node_name access add \ --identity $(crypto bls signer read --path private.key --format BASE64_PUBKEY) ((from++)) @@ -249,7 +266,7 @@ if [ "$SETUP" == true ]; then while [ $from -le $to ]; do - ./memcoin --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $(crypto bls signer read --path /tmp/node$from/private.key --format BASE64_PUBKEY) \ + ./memcoin --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $(crypto bls signer read --path /tmp/$node_name/private.key --format BASE64_PUBKEY) \ --args access:command --args GRANT ((from++)) From b2d50cee47aa1c10324f3fd778686f248c1d58dc Mon Sep 17 00:00:00 2001 From: A Date: Mon, 21 Nov 2022 09:22:39 +0100 Subject: [PATCH 11/13] fixed error runSystems --- runSystems.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runSystems.sh b/runSystems.sh index 823f9ad04..8d64a9730 100755 --- a/runSystems.sh +++ b/runSystems.sh @@ -225,6 +225,7 @@ if [ "$SETUP" == true ]; then from=2 to=$N_NODE while [ $from -le $to ]; do + node_name="node$from" ./memcoin --config /tmp/$node_name minogrpc join \ --address //localhost:2001 $(./memcoin --config /tmp/node1 minogrpc token) @@ -237,7 +238,7 @@ if [ "$SETUP" == true ]; then from=1 to=$N_NODE while [ $from -le $to ]; do - node_name="node$from" + node_name="node$from" ARRAY+="--member " ARRAY+="$(./memcoin --config /tmp/$node_name ordering export) " @@ -251,6 +252,7 @@ if [ "$SETUP" == true ]; then from=1 while [ $from -le $to ]; do + node_name="node$from" ./memcoin --config /tmp/$node_name access add \ --identity $(crypto bls signer read --path private.key --format BASE64_PUBKEY) @@ -266,6 +268,7 @@ if [ "$SETUP" == true ]; then while [ $from -le $to ]; do + node_name="node$from" ./memcoin --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $(crypto bls signer read --path /tmp/$node_name/private.key --format BASE64_PUBKEY) \ --args access:command --args GRANT From 62434ba04c3eddfdf1ad6969abeb0228e66f297f Mon Sep 17 00:00:00 2001 From: A Date: Mon, 21 Nov 2022 13:19:36 +0100 Subject: [PATCH 12/13] stardted changing readMe.md --- README.md | 68 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index e9c64268c..6b2d22f39 100644 --- a/README.md +++ b/README.md @@ -375,7 +375,7 @@ added to you path (like with `export PATH=$PATH:/Users/david/go/bin`). 3: [Install tmux](https://github.com/tmux/tmux/wiki/Installing) -# Setup a simple system with 3 nodes +# Setup a simple system with 5 nodes (Linux and MacOS) If you are using Windows and cannot use tmux, you need to do the actions of the scripts in point _1_ and _2_ manually: open 3 terminal sessions and run the @@ -383,10 +383,22 @@ commands from the section _Run the nodes_ below (1 command LLVL=info memcoin etc per terminal and then launch the setup script in another terminal). You can then follow the instructions below starting from point _3_. -1: Run 3 nodes +1: Only for the first time +```sh +cd web/backend +npm install +cp config.env.template config.env +cd ../frontend +npm install +cd ../.. +``` + +1: Then run the following script to start and setup the nodes and the web server: + + ```sh -./runNode.sh -n 3 +./runSystems.sh -n 5 ``` This will run 4 terminal sessions. You can navigate by hitting @@ -401,30 +413,7 @@ From the first terminal sessions, run: ./setupnNode.sh -n 3 ``` -3: Launch the web backend - -From a new terminal session, run: -```sh -cd web/backend -# if this is the first time, run `npm install` and `cp config.env.template config.env` first -npm start -``` - -4: Launch the web frontend - -From a new terminal session, run: - -```sh -cd web/frontend -# if this is the first time, run `npm install` first -REACT_APP_PROXY=http://localhost:9081 REACT_APP_NOMOCK=on npm start -``` - -Note that you need to be on EPFL's network to login with Tequila. Additionally, -once logged with Tequila, update the redirect URL and replace -`dvoting-dev.dedis.ch` with `localhost`. Once logged, you can create an -form. 5: Stop nodes @@ -465,7 +454,7 @@ with target: 'http://localhost:4000', ``` -# Run the nodes +# Setup a simple system with 5 nodes (Windows) In three different terminal sessions, from the root folder: @@ -502,6 +491,31 @@ remove the old state: rm -rf /tmp/node{1,2,3} ``` +3: Launch the web backend + +From a new terminal session, run: + +```sh +cd web/backend +# if this is the first time, run `npm install` and `cp config.env.template config.env` first +npm start +``` + +4: Launch the web frontend + +From a new terminal session, run: + +```sh +cd web/frontend +# if this is the first time, run `npm install` first +REACT_APP_PROXY=http://localhost:9081 REACT_APP_NOMOCK=on npm start +``` + +Note that you need to be on EPFL's network to login with Tequila. Additionally, +once logged with Tequila, update the redirect URL and replace +`dvoting-dev.dedis.ch` with `localhost`. Once logged, you can create an +form. + # Testing ## Automate the previous setup using `tmux` From 217fa6025335a904c2ee5154c3711f481dc6d082 Mon Sep 17 00:00:00 2001 From: A Date: Mon, 21 Nov 2022 16:39:21 +0100 Subject: [PATCH 13/13] Updated ReadMe.md --- README.md | 83 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 6b2d22f39..09037126d 100644 --- a/README.md +++ b/README.md @@ -355,6 +355,27 @@ results. Report, Presentation + + + Fall 2022 + Students: Amine Benaziz, Albert Troussard
Supervisor: Noémien Kocher, Pierluca Borso
Assistant: Emilien Duc + + + + + + Fall 2022 + Students: Ahmed Elalamy, Ghita Tagemouati, Khadija Tagemouati
Supervisor: Noémien Kocher + + + + + + Fall 2022 + Students: Chen Chang Lew
Supervisor: Noémien Kocher, Pierluca Borso + + + @@ -377,11 +398,8 @@ added to you path (like with `export PATH=$PATH:/Users/david/go/bin`). # Setup a simple system with 5 nodes (Linux and MacOS) -If you are using Windows and cannot use tmux, you need to do the actions of the -scripts in point _1_ and _2_ manually: open 3 terminal sessions and run the -commands from the section _Run the nodes_ below (1 command LLVL=info memcoin etc. -per terminal and then launch the setup script in another terminal). You can then -follow the instructions below starting from point _3_. +If you are using Windows and cannot use tmux, you need to follow the instructions in [this](#Setup-a-simple-system-with-5-nodes-(Windows)) + section. 1: Only for the first time ```sh @@ -393,7 +411,7 @@ npm install cd ../.. ``` -1: Then run the following script to start and setup the nodes and the web server: +2: Then run the following script to start and setup the nodes and the web server: @@ -401,48 +419,47 @@ cd ../.. ./runSystems.sh -n 5 ``` -This will run 4 terminal sessions. You can navigate by hitting +This will run 8 terminal sessions. You can navigate by hitting CTRL+B and then S. Use the arrows to select a window. -2: Launch the setup - -From the first terminal sessions, run: - -```sh -./setupnNode.sh -n 3 -``` +3: Stop nodes +If you want to stop the system, you can use the following command: +(If you forgot, this will be done automatically when you start a new system) -5: Stop nodes ```sh ./kill_test.sh ``` -6: Troubleshoot +4: Troubleshoot If while running ```sh -npm start +./runSystems.sh -n 5 ``` -in the web backend folder, you get this error: +You get this error: ```sh Error: listen EADDRINUSE: address already in use :::5000 ``` -then run this instead: +then in the file runSystems.sh, replace the line: ```sh -PORT=4000 npm start +tmux send-keys -t $s:{end} "cd web/backend && npm start" C-m +``` +with +```sh +tmux send-keys -t $s:{end} "cd web/backend && PORT=4000 npm start" C-m #or any other available port ``` -and in the web/frontend/src/setupProxy.js file, change : +And in the web/frontend/src/setupProxy.js file, change : ```sh target: 'http://localhost:5000', @@ -454,7 +471,7 @@ with target: 'http://localhost:4000', ``` -# Setup a simple system with 5 nodes (Windows) +# Setup a simple system with 3 nodes (Windows) In three different terminal sessions, from the root folder: @@ -518,22 +535,9 @@ form. # Testing -## Automate the previous setup using `tmux` - -If you have `tmux` installed, you can start a `tmux` session that will -execute the above setup by running in the project root `./runNode.sh -n 3`. -This command takes as argument the number of nodes. -Once the session is started, you can move around the panes with -`Ctrl+B` followed by arrow keys or by `N`. You can also have an overview of the -windows with `Ctrl+B` followed by `S`. - -To end the session, run `./kill_test.sh`, -which will kill each window then the `tmux` session (which you can do manually -with `Ctrl+D`), then delete the node data (i.e. the files `/tmp/node{1,2,3}`). - ## Run the scenario test -If nodes are running and `setup.sh` or `./setupnNode.sh -n 3` has been called, +If nodes are running and `setup.sh` or `./runSystem.sh -n 3 --backend false --frontend false` (for this test you don't want the user interface so the web components are not needed) has been called, you can run a test scenario: ```sh @@ -554,7 +558,10 @@ Public key: `adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3` Secret key: `28912721dfd507e198b31602fb67824856eb5a674c021d49fdccbe52f0234409` -## Run the scenario test with docker + + # Use the frontend See README in `web/`.