diff --git a/.github/workflows/go_integration_tests.yml b/.github/workflows/go_integration_tests.yml index 5263de3cc..5b0cfc9dd 100644 --- a/.github/workflows/go_integration_tests.yml +++ b/.github/workflows/go_integration_tests.yml @@ -7,7 +7,6 @@ on: branches: [main] jobs: - if: false integration: name: Integration test runs-on: ubuntu-latest diff --git a/docker-compose/docker-compose.dev.yml b/docker-compose/docker-compose.dev.yml deleted file mode 100644 index aa3c953ff..000000000 --- a/docker-compose/docker-compose.dev.yml +++ /dev/null @@ -1,107 +0,0 @@ -services: - - dela-worker-0: # initial DELA leader node - image: ghcr.io/c4dt/d-voting-dela:latest - build: - dockerfile: Dockerfiles/Dockerfile.dela.localhost - context: ../ - ports: - - "2000-2007:2000-2007" - - "3000:3000" - - "6000:6000" - environment: - PROXYKEY: ${PUBLIC_KEY} - LLVL: info - NODEPORT: 2000 - PROXYPORT: 2001 - HOSTNAME: localhost - volumes: - - dela-worker-0-data:/data - - dela-worker-1: # DELA worker node - image: ghcr.io/c4dt/d-voting-dela:latest - environment: - PROXYKEY: ${PUBLIC_KEY} - LLVL: info - NODEPORT: 2002 - PROXYPORT: 2003 - HOSTNAME: localhost - network_mode: "service:dela-worker-0" - volumes: - - dela-worker-1-data:/data - - dela-worker-2: # DELA worker node - image: ghcr.io/c4dt/d-voting-dela:latest - environment: - PROXYKEY: ${PUBLIC_KEY} - LLVL: info - NODEPORT: 2004 - PROXYPORT: 2005 - HOSTNAME: localhost - network_mode: "service:dela-worker-0" - volumes: - - dela-worker-2-data:/data - - dela-worker-3: # DELA worker node - image: ghcr.io/c4dt/d-voting-dela:latest - environment: - PROXYKEY: ${PUBLIC_KEY} - LLVL: info - NODEPORT: 2006 - PROXYPORT: 2007 - HOSTNAME: localhost - network_mode: "service:dela-worker-0" - volumes: - - dela-worker-3-data:/data - - frontend: # web service frontend - image: ghcr.io/c4dt/d-voting-frontend:latest - build: - dockerfile: Dockerfiles/Dockerfile.frontend - context: ../ - environment: - BACKEND_HOST: ${BACKEND_HOST} - BACKEND_PORT: ${BACKEND_PORT} - network_mode: "service:dela-worker-0" - - backend: # web service backend - image: ghcr.io/c4dt/d-voting-backend:latest - build: - dockerfile: Dockerfiles/Dockerfile.backend - context: ../ - environment: - DATABASE_USERNAME: ${DATABASE_USERNAME} - DATABASE_PASSWORD: ${DATABASE_PASSWORD} - DATABASE_HOST: ${DATABASE_HOST} - DATABASE_PORT: ${DATABASE_PORT} - DB_PATH: /data/${DB_PATH} - FRONT_END_URL: ${FRONT_END_URL} - DELA_NODE_URL: ${DELA_NODE_URL} - SESSION_SECRET: ${SESSION_SECRET} - PUBLIC_KEY: ${PUBLIC_KEY} - PRIVATE_KEY: ${PRIVATE_KEY} - PORT: ${BACKEND_PORT} - network_mode: "service:dela-worker-0" - depends_on: - db: - condition: service_started - volumes: - - backend-data:/data - - db: # PostgreSQL database - image: postgres:15 - environment: - POSTGRES_USER: ${DATABASE_USERNAME} - POSTGRES_PASSWORD: ${DATABASE_PASSWORD} - volumes: - - postgres-data:/var/lib/postgresql/data - - ../web/backend/src/migration.sql:/docker-entrypoint-initdb.d/init.sql - -volumes: - postgres-data: # PostgreSQL database - dela-worker-0-data: - dela-worker-1-data: - dela-worker-2-data: - dela-worker-3-data: - dela-worker-4-data: - backend-data: diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index 304fe3e09..ad0a468b1 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -1,10 +1,7 @@ services: - dela-worker-0: # initial DELA leader node + dela-worker-0: # inital DELA leader node image: ghcr.io/c4dt/d-voting-dela:latest - build: - dockerfile: Dockerfiles/Dockerfile.dela - context: ../ environment: PROXYKEY: ${PUBLIC_KEY} PROXYPORT: ${PROXYPORT} @@ -16,7 +13,6 @@ services: networks: d-voting: ipv4_address: 172.19.44.254 - dela-worker-1: # DELA worker node image: ghcr.io/c4dt/d-voting-dela:latest environment: @@ -59,9 +55,6 @@ services: frontend: # web service frontend image: ghcr.io/c4dt/d-voting-frontend:latest - build: - dockerfile: Dockerfiles/Dockerfile.frontend - context: ../ ports: - 127.0.0.1:3000:3000 environment: @@ -73,9 +66,6 @@ services: backend: # web service backend image: ghcr.io/c4dt/d-voting-backend:latest - build: - dockerfile: Dockerfiles/Dockerfile.backend - context: ../ environment: DATABASE_USERNAME: ${DATABASE_USERNAME} DATABASE_PASSWORD: ${DATABASE_PASSWORD} @@ -105,7 +95,7 @@ services: POSTGRES_PASSWORD: ${DATABASE_PASSWORD} volumes: - postgres-data:/var/lib/postgresql/data - - ../web/backend/src/migration.sql:/docker-entrypoint-initdb.d/init.sql + - ./web/backend/src/migration.sql:/docker-entrypoint-initdb.d/init.sql networks: d-voting: ipv4_address: 172.19.44.4 diff --git a/scripts/init_dela.sh b/scripts/init_dela.sh index 4e3f8527c..542ca3059 100755 --- a/scripts/init_dela.sh +++ b/scripts/init_dela.sh @@ -1,25 +1,22 @@ -#!/bin/bash -e +#!/bin/bash MEMBERS=""; -export COMPOSE_FILE=${1:-../docker-compose/docker-compose.dev.yml} -if ! [[ -f ../docker-compose/.env ]]; then - ln -s ../.env ../docker-compose/.env -fi -echo "Share the certificate" + +# share the certificate for container in dela-worker-1 dela-worker-2 dela-worker-3; do TOKEN_ARGS=$(docker compose exec dela-worker-0 /bin/bash -c 'LLVL=error dvoting --config /data/node minogrpc token'); - docker compose exec "$container" dvoting --config /data/node minogrpc join --address //localhost:2000 $TOKEN_ARGS; + docker compose exec "$container" dvoting --config /data/node minogrpc join --address //dela-worker-0:2000 $TOKEN_ARGS; done -echo "Create a new chain with the nodes" +# create a new chain with the nodes for container in dela-worker-0 dela-worker-1 dela-worker-2 dela-worker-3; do # add node to the chain MEMBERS="$MEMBERS --member $(docker compose exec $container /bin/bash -c 'LLVL=error dvoting --config /data/node ordering export')"; done docker compose exec dela-worker-0 dvoting --config /data/node ordering setup $MEMBERS; -echo "Authorize the signer to handle the access contract on each node" +# authorize the signer to handle the access contract on each node for signer in dela-worker-0 dela-worker-1 dela-worker-2 dela-worker-3; do IDENTITY=$(docker compose exec "$signer" crypto bls signer read --path /data/node/private.key --format BASE64_PUBKEY); for node in dela-worker-0 dela-worker-1 dela-worker-2 dela-worker-3; do @@ -27,7 +24,7 @@ for signer in dela-worker-0 dela-worker-1 dela-worker-2 dela-worker-3; do done done -echo "Update the access contract" +# update the access contract for container in dela-worker-0 dela-worker-1 dela-worker-2 dela-worker-3; do IDENTITY=$(docker compose exec "$container" crypto bls signer read --path /data/node/private.key --format BASE64_PUBKEY); docker compose exec dela-worker-0 dvoting --config /data/node pool add\ @@ -45,5 +42,3 @@ for container in dela-worker-0 dela-worker-1 dela-worker-2 dela-worker-3; do --args access:command\ --args GRANT done - -echo "Successfully done" \ No newline at end of file diff --git a/scripts/setup_admin.sh b/scripts/setup_admin.sh deleted file mode 100755 index e5ef6ec49..000000000 --- a/scripts/setup_admin.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -export COMPOSE_FILE=${2:-../docker-compose/docker-compose.dev.yml} - -docker compose exec backend npx cli addAdmin --sciper $1 -docker compose stop backend -docker compose rm backend -docker compose up backend diff --git a/scripts/setup_forms.sh b/scripts/setup_forms.sh deleted file mode 100755 index 10088ac27..000000000 --- a/scripts/setup_forms.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -if [ -z "$COOKIE" ]; then - echo "'COOKIE' variable not set"; - exit 1; -fi - -FRONTEND_URL=https://127.0.0.1:3000 - -echo "add form"; -RESP=$(curl -k "$FRONTEND_URL/api/evoting/forms" -X POST -H 'Content-Type: application/json' -H "Cookie: connect.sid=$COOKIE" --data-raw '{"Configuration":{"MainTitle":"{\"en\":\"Colours\",\"fr\":\"\",\"de\":\"\"}","Scaffold":[{"ID":"5DRhKsY2","Title":"Colours","TitleFr":"","TitleDe":"","Order":["d0mSUfpv"],"Ranks":[],"Selects":[{"ID":"d0mSUfpv","Title":"{\"en\":\"RGB\",\"fr\":\"\",\"de\":\"\"}","TitleDe":"","TitleFr":"","MaxN":1,"MinN":1,"Choices":["{\"en\":\"Red\"}","{\"en\":\"Green\"}","{\"en\":\"Blue\"}"],"ChoicesMap":{},"Hint":"{\"en\":\"\",\"fr\":\"\",\"de\":\"\"}","HintFr":"","HintDe":""}],"Texts":[],"Subjects":[]}]}}'); -FORMID=$(echo "$RESP" | jq -r .FormID); -#TOKEN=$(echo "$RESP" | jq -r .Token); -echo "add permissions"; -curl -k "$FRONTEND_URL/api/evoting/authorizations" -X PUT -H 'Content-Type: application/json' -H "Cookie: connect.sid=$COOKIE" --data "$(jq -cn --arg FormID $FORMID '$ARGS.named')" -m 1; - -echo "initialize nodes"; -curl -k "$FRONTEND_URL/api/evoting/services/dkg/actors" -X POST -H 'Content-Type: application/json' -H "Cookie: connect.sid=$COOKIE" --data "$(jq -cn --arg FormID $FORMID --arg Proxy http://localhost:2001 '$ARGS.named')"; -curl -k "$FRONTEND_URL/api/evoting/services/dkg/actors" -X POST -H 'Content-Type: application/json' -H "Cookie: connect.sid=$COOKIE" --data "$(jq -cn --arg FormID $FORMID --arg Proxy http://localhost:2003 '$ARGS.named')"; -curl -k "$FRONTEND_URL/api/evoting/services/dkg/actors" -X POST -H 'Content-Type: application/json' -H "Cookie: connect.sid=$COOKIE" --data "$(jq -cn --arg FormID $FORMID --arg Proxy http://localhost:2005 '$ARGS.named')"; -curl -k "$FRONTEND_URL/api/evoting/services/dkg/actors" -X POST -H 'Content-Type: application/json' -H "Cookie: connect.sid=$COOKIE" --data "$(jq -cn --arg FormID $FORMID --arg Proxy http://localhost:2007 '$ARGS.named')"; - -echo "set node up"; -curl -k "$FRONTEND_URL/api/evoting/services/dkg/actors/$FORMID" -X PUT -H 'Content-Type: application/json' -H "Cookie: connect.sid=$COOKIE" --data-raw '{"Action":"setup","Proxy":"http://localhost:2001"}'; - -echo "open election"; -sleep 8; -curl -k "$FRONTEND_URL/api/evoting/forms/$FORMID" -X PUT -H "Cookie: connect.sid=$COOKIE" -H 'Content-Type: application/json' --data-raw '{"Action":"open"}' -if [ -z $1 ]; then - echo "$FORMID has been set up"; - exit 0; -fi - -echo "cast $1 votes"; -for i in $(seq 1 $1); do - echo "cast vote #$i"; - curl -sk "$FRONTEND_URL/api/evoting/forms/$FORMID/vote" -X POST -H 'Content-Type: Application/json' -H "Origin: $FRONTEND_URL" -H "Cookie: connect.sid=$COOKIE" --data-raw '{"Ballot":[{"K":[54,152,33,11,201,233,212,157,204,176,136,138,54,213,239,198,79,55,71,26,91,244,98,215,208,239,48,253,195,53,192,94],"C":[105,121,87,164,68,242,166,194,222,179,253,231,213,63,34,66,212,41,214,175,178,83,229,156,255,38,55,234,168,222,81,185]}],"UserID":null}' > /dev/null; - sleep 1; -done diff --git a/scripts/setup_proxies.sh b/scripts/setup_proxies.sh deleted file mode 100755 index 2643ef20a..000000000 --- a/scripts/setup_proxies.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -if [ -z "$COOKIE" ]; then - echo "'COOKIE' variable is not set"; - exit 1; -fi - -echo "add proxies"; -curl -sk 'https://127.0.0.1:3000/api/proxies/' -X POST -H 'Content-Type: application/json' -H "Cookie: connect.sid=$COOKIE; redirect=/" --data-raw '{"NodeAddr":"localhost:2000","Proxy":"http://localhost:2001"}'; -curl -sk 'https://127.0.0.1:3000/api/proxies/' -X POST -H 'Content-Type: application/json' -H "Cookie: connect.sid=$COOKIE; redirect=/" --data-raw '{"NodeAddr":"localhost:2002","Proxy":"http://localhost:2003"}'; -curl -sk 'https://127.0.0.1:3000/api/proxies/' -X POST -H 'Content-Type: application/json' -H "Cookie: connect.sid=$COOKIE; redirect=/" --data-raw '{"NodeAddr":"localhost:2004","Proxy":"http://localhost:2005"}'; -curl -sk 'https://127.0.0.1:3000/api/proxies/' -X POST -H 'Content-Type: application/json' -H "Cookie: connect.sid=$COOKIE; redirect=/" --data-raw '{"NodeAddr":"localhost:2006","Proxy":"http://localhost:2007"}'; diff --git a/web/backend/readme.md b/web/backend/README.md similarity index 100% rename from web/backend/readme.md rename to web/backend/README.md