diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..e6aab2ac3 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,7 @@ +Thank you for opening a pull request with this project, please also: + +* [ ] add a brief description of your changes here +* [ ] assign a reviewer +* [ ] start in `draft` mode and `in progress` pipeline in the project (if applicable) +* [ ] once it's ready put it in the `Review` or `Ready4Merge` pipeline in the project (if applicable) and remove `draft` +* [ ] if applicable, add this PR to its related issue by one of the special keywords (https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 000000000..3c12b6d26 --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,48 @@ +name: Build docker + +on: + push: + branches: + - main + +jobs: + build-docker: + name: Build D-Voting Docker images + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + - name: Login to GHCR + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build Frontend + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfiles/Dockerfile.frontend + platforms: linux/amd64 + push: true + tags: ghcr.io/c4dt/d-voting-frontend:latest + - name: Build Backend + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfiles/Dockerfile.backend + platforms: linux/amd64 + push: true + tags: ghcr.io/c4dt/d-voting-backend:latest + - name: Build D-Voting + uses: docker/build-push-action@v2 + with: + context: . + target: build + file: Dockerfiles/Dockerfile.dela + platforms: linux/amd64 + push: true + tags: ghcr.io/c4dt/d-voting-dela:latest diff --git a/.github/workflows/go_dvoting_test.yml b/.github/workflows/go_dvoting_test.yml index 5deea0ce2..f98569577 100644 --- a/.github/workflows/go_dvoting_test.yml +++ b/.github/workflows/go_dvoting_test.yml @@ -19,7 +19,7 @@ jobs: - name: Install crypto util from Dela run: | - git clone https://github.com/dedis/dela.git + git clone https://github.com/c4dt/dela.git cd dela go install ./cli/crypto diff --git a/.github/workflows/go_scenario_test.yml b/.github/workflows/go_scenario_test.yml index 942b161d1..c2e609697 100644 --- a/.github/workflows/go_scenario_test.yml +++ b/.github/workflows/go_scenario_test.yml @@ -18,7 +18,7 @@ jobs: - name: Install crypto util from Dela run: | - git clone https://github.com/dedis/dela.git + git clone https://github.com/c4dt/dela.git cd dela go install ./cli/crypto diff --git a/.github/workflows/go_test.yml b/.github/workflows/go_test.yml index 6392aed7f..dba5a8188 100644 --- a/.github/workflows/go_test.yml +++ b/.github/workflows/go_test.yml @@ -27,35 +27,4 @@ jobs: - name: Test all, except integration, with coverage run: | - go test -json -covermode=count -coverprofile=profile.cov $(go list ./... | grep -v /integration) 2>&1 | tee report.json - - - name: Sonarcloud scan - uses: sonarsource/sonarcloud-github-action@master - with: - args: > - -Dsonar.organization=dedis - -Dsonar.projectKey=dedis_d-voting - -Dsonar.go.tests.reportPaths=report.json - -Dsonar.go.coverage.reportPaths=profile.cov - -Dsonar.coverage.exclusions=**/*_test.go,/internal/**/* - -Dsonar.issue.ignore.multicriteria=e1 - -Dsonar.issue.ignore.multicriteria.e1.ruleKey=*Naming* - -Dsonar.issue.ignore.multicriteria.e1.resourceKey=**/*_test.go - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - - name: Send coverage - uses: shogo82148/actions-goveralls@v1 - with: - path-to-profile: profile.cov - parallel: true - - # notifies that all test jobs are finished. - finish: - needs: test - runs-on: ubuntu-latest - steps: - - uses: shogo82148/actions-goveralls@v1 - with: - parallel-finished: true + go test $(go list ./... | grep -v /integration) diff --git a/.gitignore b/.gitignore index a6b66c431..361116e9b 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,9 @@ nodedata/ deb-package/dist/** +.env + +dela/ +bin/ +nodes/ +cookies.txt diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..0a1270711 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,34 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +Latest changes in each category go to the top + +## [Unreleased] + +### Added +- New debugging variables in [local_vars.sh](./scripts/local_vars.sh) +- Changelog - please use it + +### Changed +- for the Dockerfiles and docker-compose.yml, `DELA_NODE_URL` has been replaced with `DELA_PROXY_URL`, + which is the more accurate name. +- the actions in package.json for the frontend changed. Both are somewhat development mode, + as the webserver is not supposed to be used in production. + - `start`: starts in plain mode + - `start-https`: starts in HTTPS mode + +### Deprecated +### Removed +### Fixed +- Proxy editing fixed: adding, modifying, deleting now works +- When fetching form and user updates, only do it when showing the activity +- Redirection when form doesn't exist and nicer error message +- File formatting and errors in comments +- Popup when voting and some voting translation fixes +- Fixed return error when voting + +### Security +- Use `REACT_APP_RANDOMIZE_VOTE_ID === 'true'` to indicate randomizing vote ids diff --git a/Dockerfiles/Dockerfile.backend b/Dockerfiles/Dockerfile.backend index 4db0ec75e..a87b4ede3 100644 --- a/Dockerfiles/Dockerfile.backend +++ b/Dockerfiles/Dockerfile.backend @@ -3,4 +3,5 @@ FROM node:20-bookworm WORKDIR /web/backend COPY ../web/backend . RUN npm install -ENTRYPOINT ["/bin/bash", "-c", "npm start"] +ENTRYPOINT ["npm"] +CMD ["start"] diff --git a/Dockerfiles/Dockerfile.dela b/Dockerfiles/Dockerfile.dela index 27f4fc909..5535c8dbd 100644 --- a/Dockerfiles/Dockerfile.dela +++ b/Dockerfiles/Dockerfile.dela @@ -1,15 +1,17 @@ -FROM golang:1.20.6-bookworm - +FROM golang:1.20.6-bookworm AS base RUN apt-get update && apt-get install git # make sure we're using the same head as d-voting -RUN git clone -b fix-bbolt https://github.com/dedis/dela.git +RUN git clone https://github.com/c4dt/dela.git WORKDIR /go/dela/cli/crypto RUN go install WORKDIR /go/d-voting COPY . . + +FROM base AS build +COPY --from=base /go/dela . +COPY --from=base /go/d-voting . WORKDIR /go/d-voting/cli/dvoting RUN go build ENV PATH=/go/dela/cli/crypto:/go/d-voting/cli/dvoting:${PATH} -WORKDIR /go -ENTRYPOINT ["/bin/bash", "-c", "dvoting --config /data/node start --postinstall --proxyaddr :$PROXYPORT --proxykey $PROXYKEY --listen tcp://0.0.0.0:2000 --public http://$HOSTNAME:$NODEPORT --routing tree"] +ENTRYPOINT ["/bin/bash", "-c", "dvoting --config /data/node start --postinstall --proxyaddr :$PROXYPORT --proxykey $PROXYKEY --listen tcp://0.0.0.0:2000 --public $PUBLIC_URL --routing tree --noTLS"] CMD [] diff --git a/Dockerfiles/Dockerfile.dela.debug b/Dockerfiles/Dockerfile.dela.debug deleted file mode 100644 index 47cee9b89..000000000 --- a/Dockerfiles/Dockerfile.dela.debug +++ /dev/null @@ -1,18 +0,0 @@ -FROM golang:1.20.6-bookworm - -# https://blog.jetbrains.com/go/2020/05/06/debugging-a-go-application-inside-a-docker-container/ -RUN go install github.com/go-delve/delve/cmd/dlv@latest - -RUN apt-get update && apt-get install git -RUN git clone https://github.com/dedis/dela.git -RUN git clone https://github.com/dedis/d-voting.git -WORKDIR /go/dela/cli/crypto -RUN go install -WORKDIR /go/d-voting/cli/dvoting - -RUN go build -gcflags="all=-N -l" - -ENV PATH=/go/dela/cli/crypto:/go/d-voting/cli/dvoting:${PATH} -WORKDIR /go -ENTRYPOINT ["/bin/bash", "-c", "dlv --listen=:40000 --headless=true --api-version=2 --accept-multiclient exec /go/d-voting/cli/dvoting/dvoting -- --config /data/node start --postinstall --proxyaddr :$PROXYPORT --proxykey $PROXYKEY --listen tcp://0.0.0.0:2000 --public http://$HOSTNAME:2000 --routing tree"] -CMD [] diff --git a/Dockerfiles/Dockerfile.frontend b/Dockerfiles/Dockerfile.frontend index ab04b319a..77376ff36 100644 --- a/Dockerfiles/Dockerfile.frontend +++ b/Dockerfiles/Dockerfile.frontend @@ -5,4 +5,5 @@ ENV REACT_APP_NOMOCK=on WORKDIR /web/frontend COPY ../web/frontend . RUN npm install -ENTRYPOINT ["npm", "start"] +ENTRYPOINT ["npm"] +CMD ["start"] diff --git a/Makefile b/Makefile index a774d69a0..a7eb71f25 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ version=$(shell git describe --abbrev=0 --tags || echo '0.0.0') -versionFlag="github.com/dedis/d-voting.Version=$(version)" +versionFlag="github.com/c4dt/d-voting.Version=$(version)" versionFile=$(shell echo $(version) | tr . _) -timeFlag="github.com/dedis/d-voting.BuildTime=$(shell date +'%d/%m/%y_%H:%M')" +timeFlag="github.com/c4dt/d-voting.BuildTime=$(shell date +'%d/%m/%y_%H:%M')" lint: # Coding style static check. diff --git a/README.docker.md b/README.docker.md index 230fbc875..e99fef976 100644 --- a/README.docker.md +++ b/README.docker.md @@ -15,7 +15,7 @@ when running `docker compose`. The environment file needs to contain ``` -DELA_NODE_URL=http://172.19.44.254:8080 +DELA_PROXY_URL=http://172.19.44.254:8080 DATABASE_USERNAME=dvoting DATABASE_PASSWORD=XXX # choose any PostgreSQL password DATABASE_HOST=db @@ -31,31 +31,39 @@ PROXYPORT=8080 NODEPORT=2000 # DELA node port ``` +For the `PUBLIC_KEY` and `PRIVATE_KEY`, you need to run the following commands: + +```bash +cd web/backend +npm ci +npm run keygen +``` + +And then copy the two lines to the `.env` file. + There are two Docker Compose file you may use: -* `docker-compose/docker-compose.yml` for the currently released version, or +* `docker-compose/docker-compose.yml` for the preprod version, or * `docker-compose/docker-compose.debug.yml` for the development/debugging version -You can either run +You run ``` export COMPOSE_FILE= ``` -or pass the `-f/--file ` argument to choose between -the files. - -Using the currently released version will pull the images from the GitHub container registry. - -If you instead use the development/debugging version the images will be build locally and you can debug your developments. +The preprod version will create an environment without any debugging tools that's as close as possible to a real environment. +It is meant to be used to test the `main` branch before deploying it to production. Use the development/debugging version +for setting up your local development environment. Run ``` +docker compose build docker compose up ``` -(possibly with the `-f/--file` argument) to set up the environment. +to set up the environment. /!\ Any subsequent `docker compose` commands must be run with `COMPOSE_FILE` being set to the Docker Compose file that defines the current environment. diff --git a/README.md b/README.md index e94a54b3a..635f11808 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ - - + +
- + GitHub contributors - + GitHub release (latest SemVer) @@ -26,37 +26,37 @@ Blockchain - - + + - - + + - - + + - - + +
- - + + - - Go Reference + + Go Reference WEB - - + + - - + + @@ -67,7 +67,7 @@ # D-Voting **D-Voting** is an e-voting platform based on the -[Dela](https://github.com/dedis/dela) blockchain. It uses state-of-the-art +[Dela](https://github.com/c4dt/dela) blockchain. It uses state-of-the-art protocols that guarantee privacy of votes and a fully decentralized process. This project was born in early 2021 and has been iteratively implemented by EPFL students under the supervision of DEDIS members. @@ -147,7 +147,7 @@ sometimes refer to the blockchain node simply as a "node". The following component diagrams summarizes the interaction between those high-level components: -[minogrpc]: https://github.com/dedis/dela/tree/master/mino/minogrpc +[minogrpc]: https://github.com/c4dt/dela/tree/master/mino/minogrpc ![Global component diagram](http://www.plantuml.com/plantuml/proxy?src=https://raw.githubusercontent.com/dedis/d-voting/main/docs/assets/component-global.puml) @@ -390,7 +390,7 @@ results. 2: Install the `crypto` utility from Dela: ```sh -git clone https://github.com/dedis/dela.git +git clone https://github.com/c4dt/dela.git cd dela/cli/crypto go install ``` @@ -601,7 +601,7 @@ Afterwards use the following commands, replace 4 by the desired nb of nodes : ./runNode.sh -n 4 -a true -d true ./setupnNode.sh -n 4 -d true -NNODES=4 KILLNODE=true go test -v -run ^TestScenario$ github.com/dedis/d-voting/integration -count=1 +NNODES=4 KILLNODE=true go test -v -run ^TestScenario$ github.com/c4dt/d-voting/integration -count=1 ``` Here we set KILLNODE=true or false to decide whether kill and restart a node @@ -650,8 +650,8 @@ Build info can be added to the binary with the `ldflags`, at build time. Infos are stored on variables in the root `mod.go`. For example: ```sh -versionFlag="github.com/dedis/d-voting.Version=`git describe --tags`" -timeFlag="github.com/dedis/d-voting.BuildTime=`date +'%d/%m/%y_%H:%M'`" +versionFlag="github.com/c4dt/d-voting.Version=`git describe --tags`" +timeFlag="github.com/c4dt/d-voting.BuildTime=`date +'%d/%m/%y_%H:%M'`" go build -ldflags="-X $versionFlag -X $timeFlag" ./cli/dvoting ``` diff --git a/autotest.sh b/autotest.sh index b9872287b..67ef14ec1 100755 --- a/autotest.sh +++ b/autotest.sh @@ -52,7 +52,7 @@ do ./setupnNode.sh -n $N_NODE -d true sleep 3 # Start scenario test and keep logs - NNODES=$N_NODE go test -v -run ^TestScenario$ github.com/dedis/d-voting/integration -count=1 | tee ./log/log/gotest.log + NNODES=$N_NODE go test -v -run ^TestScenario$ github.com/c4dt/d-voting/integration -count=1 | tee ./log/log/gotest.log sleep 3 # Stop the test ./kill_test.sh diff --git a/cli/cosipbftcontroller/action.go b/cli/cosipbftcontroller/action.go index febe68f4b..f31027197 100644 --- a/cli/cosipbftcontroller/action.go +++ b/cli/cosipbftcontroller/action.go @@ -12,16 +12,16 @@ import ( "fmt" "strings" - "go.dedis.ch/dela" - "go.dedis.ch/dela/cli/node" - "go.dedis.ch/dela/core/ordering" - "go.dedis.ch/dela/core/ordering/cosipbft/authority" - "go.dedis.ch/dela/core/ordering/cosipbft/contracts/viewchange" - "go.dedis.ch/dela/core/txn" - "go.dedis.ch/dela/core/txn/pool" - "go.dedis.ch/dela/cosi" - "go.dedis.ch/dela/crypto" - "go.dedis.ch/dela/mino" + "github.com/c4dt/dela" + "github.com/c4dt/dela/cli/node" + "github.com/c4dt/dela/core/ordering" + "github.com/c4dt/dela/core/ordering/cosipbft/authority" + "github.com/c4dt/dela/core/ordering/cosipbft/contracts/viewchange" + "github.com/c4dt/dela/core/txn" + "github.com/c4dt/dela/core/txn/pool" + "github.com/c4dt/dela/cosi" + "github.com/c4dt/dela/crypto" + "github.com/c4dt/dela/mino" "golang.org/x/xerrors" ) diff --git a/cli/cosipbftcontroller/action_test.go b/cli/cosipbftcontroller/action_test.go index 322b89863..46a2cf396 100644 --- a/cli/cosipbftcontroller/action_test.go +++ b/cli/cosipbftcontroller/action_test.go @@ -7,19 +7,19 @@ import ( "testing" "time" - "github.com/dedis/d-voting/internal/testing/fake" + "github.com/c4dt/d-voting/internal/testing/fake" + "github.com/c4dt/dela/cli/node" + "github.com/c4dt/dela/core/access" + "github.com/c4dt/dela/core/ordering" + "github.com/c4dt/dela/core/ordering/cosipbft/authority" + "github.com/c4dt/dela/core/txn" + "github.com/c4dt/dela/core/txn/pool" + "github.com/c4dt/dela/core/txn/pool/mem" + "github.com/c4dt/dela/core/validation" + "github.com/c4dt/dela/cosi" + "github.com/c4dt/dela/crypto" + "github.com/c4dt/dela/mino" "github.com/stretchr/testify/require" - "go.dedis.ch/dela/cli/node" - "go.dedis.ch/dela/core/access" - "go.dedis.ch/dela/core/ordering" - "go.dedis.ch/dela/core/ordering/cosipbft/authority" - "go.dedis.ch/dela/core/txn" - "go.dedis.ch/dela/core/txn/pool" - "go.dedis.ch/dela/core/txn/pool/mem" - "go.dedis.ch/dela/core/validation" - "go.dedis.ch/dela/cosi" - "go.dedis.ch/dela/crypto" - "go.dedis.ch/dela/mino" ) func TestSetupAction_Execute(t *testing.T) { diff --git a/cli/cosipbftcontroller/mod.go b/cli/cosipbftcontroller/mod.go index 08ae6d413..036a4f1c4 100644 --- a/cli/cosipbftcontroller/mod.go +++ b/cli/cosipbftcontroller/mod.go @@ -8,30 +8,30 @@ import ( "path/filepath" "time" - "go.dedis.ch/dela/contracts/value" - "go.dedis.ch/dela/crypto" - - "go.dedis.ch/dela/cli" - "go.dedis.ch/dela/cli/node" - "go.dedis.ch/dela/core/access/darc" - "go.dedis.ch/dela/core/execution/native" - "go.dedis.ch/dela/core/ordering" - "go.dedis.ch/dela/core/ordering/cosipbft" - "go.dedis.ch/dela/core/ordering/cosipbft/authority" - "go.dedis.ch/dela/core/ordering/cosipbft/blockstore" - "go.dedis.ch/dela/core/ordering/cosipbft/types" - "go.dedis.ch/dela/core/store/hashtree/binprefix" - "go.dedis.ch/dela/core/store/kv" - "go.dedis.ch/dela/core/txn/pool" - poolimpl "go.dedis.ch/dela/core/txn/pool/gossip" - "go.dedis.ch/dela/core/txn/signed" - "go.dedis.ch/dela/core/validation/simple" - "go.dedis.ch/dela/cosi/threshold" - "go.dedis.ch/dela/crypto/bls" - "go.dedis.ch/dela/crypto/loader" - "go.dedis.ch/dela/mino" - "go.dedis.ch/dela/mino/gossip" - "go.dedis.ch/dela/serde/json" + "github.com/c4dt/dela/contracts/value" + "github.com/c4dt/dela/crypto" + + "github.com/c4dt/dela/cli" + "github.com/c4dt/dela/cli/node" + "github.com/c4dt/dela/core/access/darc" + "github.com/c4dt/dela/core/execution/native" + "github.com/c4dt/dela/core/ordering" + "github.com/c4dt/dela/core/ordering/cosipbft" + "github.com/c4dt/dela/core/ordering/cosipbft/authority" + "github.com/c4dt/dela/core/ordering/cosipbft/blockstore" + "github.com/c4dt/dela/core/ordering/cosipbft/types" + "github.com/c4dt/dela/core/store/hashtree/binprefix" + "github.com/c4dt/dela/core/store/kv" + "github.com/c4dt/dela/core/txn/pool" + poolimpl "github.com/c4dt/dela/core/txn/pool/gossip" + "github.com/c4dt/dela/core/txn/signed" + "github.com/c4dt/dela/core/validation/simple" + "github.com/c4dt/dela/cosi/threshold" + "github.com/c4dt/dela/crypto/bls" + "github.com/c4dt/dela/crypto/loader" + "github.com/c4dt/dela/mino" + "github.com/c4dt/dela/mino/gossip" + "github.com/c4dt/dela/serde/json" "golang.org/x/xerrors" ) diff --git a/cli/cosipbftcontroller/mod_test.go b/cli/cosipbftcontroller/mod_test.go index ac9e3525e..d3cf0cb6e 100644 --- a/cli/cosipbftcontroller/mod_test.go +++ b/cli/cosipbftcontroller/mod_test.go @@ -6,15 +6,15 @@ import ( "path/filepath" "testing" - "github.com/dedis/d-voting/services/dkg" - "go.dedis.ch/dela/core/ordering" - - "github.com/dedis/d-voting/internal/testing/fake" + "github.com/c4dt/d-voting/services/dkg" + "github.com/c4dt/dela/core/ordering" + + "github.com/c4dt/d-voting/internal/testing/fake" + "github.com/c4dt/dela/cli" + "github.com/c4dt/dela/cli/node" + "github.com/c4dt/dela/core/store/kv" + "github.com/c4dt/dela/core/txn/pool" "github.com/stretchr/testify/require" - "go.dedis.ch/dela/cli" - "go.dedis.ch/dela/cli/node" - "go.dedis.ch/dela/core/store/kv" - "go.dedis.ch/dela/core/txn/pool" ) func TestMinimal_SetCommands(t *testing.T) { diff --git a/cli/dvoting/mod.go b/cli/dvoting/mod.go index 79428ad64..57a96706b 100644 --- a/cli/dvoting/mod.go +++ b/cli/dvoting/mod.go @@ -2,28 +2,27 @@ // // Unix example: // -// # Expect GOPATH to be correctly set to have dvoting available. -// go install +// # Expect GOPATH to be correctly set to have dvoting available. +// go install // -// dvoting --config /tmp/node1 start --port 2001 & -// dvoting --config /tmp/node2 start --port 2002 & -// dvoting --config /tmp/node3 start --port 2003 & +// dvoting --config /tmp/node1 start --port 2001 & +// dvoting --config /tmp/node2 start --port 2002 & +// dvoting --config /tmp/node3 start --port 2003 & // -// # Share the different certificates among the participants. -// dvoting --config /tmp/node2 minogrpc join --address 127.0.0.1:2001\ -// $(dvoting --config /tmp/node1 minogrpc token) -// dvoting --config /tmp/node3 minogrpc join --address 127.0.0.1:2001\ -// $(dvoting --config /tmp/node1 minogrpc token) +// # Share the different certificates among the participants. +// dvoting --config /tmp/node2 minogrpc join --address 127.0.0.1:2001\ +// $(dvoting --config /tmp/node1 minogrpc token) +// dvoting --config /tmp/node3 minogrpc join --address 127.0.0.1:2001\ +// $(dvoting --config /tmp/node1 minogrpc token) // -// # Create a chain with two members. -// dvoting --config /tmp/node1 ordering setup\ -// --member $(dvoting --config /tmp/node1 ordering export)\ -// --member $(dvoting --config /tmp/node2 ordering export) -// -// # Add the third after the chain is set up. -// dvoting --config /tmp/node1 ordering roster add\ -// --member $(dvoting --config /tmp/node3 ordering export) +// # Create a chain with two members. +// dvoting --config /tmp/node1 ordering setup\ +// --member $(dvoting --config /tmp/node1 ordering export)\ +// --member $(dvoting --config /tmp/node2 ordering export) // +// # Add the third after the chain is set up. +// dvoting --config /tmp/node1 ordering roster add\ +// --member $(dvoting --config /tmp/node3 ordering export) package main import ( @@ -31,25 +30,25 @@ import ( "io" "os" - dkg "github.com/dedis/d-voting/services/dkg/pedersen/controller" - "github.com/dedis/d-voting/services/dkg/pedersen/json" - shuffle "github.com/dedis/d-voting/services/shuffle/neff/controller" + dkg "github.com/c4dt/d-voting/services/dkg/pedersen/controller" + "github.com/c4dt/d-voting/services/dkg/pedersen/json" + shuffle "github.com/c4dt/d-voting/services/shuffle/neff/controller" - cosipbft "github.com/dedis/d-voting/cli/cosipbftcontroller" - "github.com/dedis/d-voting/cli/postinstall" - evoting "github.com/dedis/d-voting/contracts/evoting/controller" - metrics "github.com/dedis/d-voting/metrics/controller" - "go.dedis.ch/dela/cli/node" - access "go.dedis.ch/dela/contracts/access/controller" - db "go.dedis.ch/dela/core/store/kv/controller" - pool "go.dedis.ch/dela/core/txn/pool/controller" - signed "go.dedis.ch/dela/core/txn/signed/controller" - mino "go.dedis.ch/dela/mino/minogrpc/controller" - proxy "go.dedis.ch/dela/mino/proxy/http/controller" + cosipbft "github.com/c4dt/d-voting/cli/cosipbftcontroller" + "github.com/c4dt/d-voting/cli/postinstall" + evoting "github.com/c4dt/d-voting/contracts/evoting/controller" + metrics "github.com/c4dt/d-voting/metrics/controller" + "github.com/c4dt/dela/cli/node" + access "github.com/c4dt/dela/contracts/access/controller" + db "github.com/c4dt/dela/core/store/kv/controller" + pool "github.com/c4dt/dela/core/txn/pool/controller" + signed "github.com/c4dt/dela/core/txn/signed/controller" + mino "github.com/c4dt/dela/mino/minogrpc/controller" + proxy "github.com/c4dt/dela/mino/proxy/http/controller" - _ "github.com/dedis/d-voting/services/shuffle/neff/json" + _ "github.com/c4dt/d-voting/services/shuffle/neff/json" - gapi "go.dedis.ch/dela-apps/gapi/controller" + gapi "github.com/c4dt/dela-apps/gapi/controller" ) func main() { diff --git a/cli/dvoting/mod_test.go b/cli/dvoting/mod_test.go index 5c1f8c2bf..50db80155 100644 --- a/cli/dvoting/mod_test.go +++ b/cli/dvoting/mod_test.go @@ -99,7 +99,7 @@ func TestDvoting_Scenario_SetupAndTransactions(t *testing.T) { // Run a few transactions. for i := 0; i < 5; i++ { err = runWithCfg(args, config{}) - require.EqualError(t, err, "command error: transaction refused: duplicate in roster: 127.0.0.1:2115") + require.EqualError(t, err, "command error: transaction refused: duplicate in roster: grpcs://127.0.0.1:2115") } // Test a timeout waiting for a transaction. @@ -155,7 +155,7 @@ func TestDvoting_Scenario_RestartNode(t *testing.T) { ) err = run(args) - require.EqualError(t, err, "command error: transaction refused: duplicate in roster: 127.0.0.1:2210") + require.EqualError(t, err, "command error: transaction refused: duplicate in roster: grpcs://127.0.0.1:2210") } // ----------------------------------------------------------------------------- diff --git a/cli/postinstall/mod.go b/cli/postinstall/mod.go index 560e57d40..66b6f0d12 100644 --- a/cli/postinstall/mod.go +++ b/cli/postinstall/mod.go @@ -5,15 +5,15 @@ import ( "path/filepath" "time" - evoting "github.com/dedis/d-voting/contracts/evoting/controller" - prom "github.com/dedis/d-voting/metrics/controller" - dkg "github.com/dedis/d-voting/services/dkg/pedersen/controller" - neff "github.com/dedis/d-voting/services/shuffle/neff/controller" - "go.dedis.ch/dela" - "go.dedis.ch/dela/cli" - "go.dedis.ch/dela/cli/node" - "go.dedis.ch/dela/mino/proxy" - "go.dedis.ch/dela/mino/proxy/http" + evoting "github.com/c4dt/d-voting/contracts/evoting/controller" + prom "github.com/c4dt/d-voting/metrics/controller" + dkg "github.com/c4dt/d-voting/services/dkg/pedersen/controller" + neff "github.com/c4dt/d-voting/services/shuffle/neff/controller" + "github.com/c4dt/dela" + "github.com/c4dt/dela/cli" + "github.com/c4dt/dela/cli/node" + "github.com/c4dt/dela/mino/proxy" + "github.com/c4dt/dela/mino/proxy/http" "golang.org/x/xerrors" ) diff --git a/contracts/evoting/controller/action.go b/contracts/evoting/controller/action.go index 71e15a659..19c537ca5 100644 --- a/contracts/evoting/controller/action.go +++ b/contracts/evoting/controller/action.go @@ -17,36 +17,36 @@ import ( "go.dedis.ch/kyber/v3/sign/schnorr" "go.dedis.ch/kyber/v3/suites" - "github.com/dedis/d-voting/contracts/evoting/types" - "github.com/dedis/d-voting/internal/testing/fake" - eproxy "github.com/dedis/d-voting/proxy" - "github.com/dedis/d-voting/proxy/txnmanager" - ptypes "github.com/dedis/d-voting/proxy/types" - "github.com/dedis/d-voting/services/dkg" - "github.com/dedis/d-voting/services/shuffle" + "github.com/c4dt/d-voting/contracts/evoting/types" + "github.com/c4dt/d-voting/internal/testing/fake" + eproxy "github.com/c4dt/d-voting/proxy" + "github.com/c4dt/d-voting/proxy/txnmanager" + ptypes "github.com/c4dt/d-voting/proxy/types" + "github.com/c4dt/d-voting/services/dkg" + "github.com/c4dt/d-voting/services/shuffle" + "github.com/c4dt/dela" + "github.com/c4dt/dela/cli/node" + "github.com/c4dt/dela/core/ordering" + "github.com/c4dt/dela/core/ordering/cosipbft/authority" + "github.com/c4dt/dela/core/ordering/cosipbft/blockstore" + "github.com/c4dt/dela/core/txn" + "github.com/c4dt/dela/core/txn/pool" + "github.com/c4dt/dela/core/txn/signed" + "github.com/c4dt/dela/core/validation" + "github.com/c4dt/dela/crypto" + "github.com/c4dt/dela/crypto/bls" + "github.com/c4dt/dela/crypto/loader" + "github.com/c4dt/dela/mino" + "github.com/c4dt/dela/mino/proxy" + "github.com/c4dt/dela/serde" + sjson "github.com/c4dt/dela/serde/json" "github.com/gorilla/mux" - "go.dedis.ch/dela" - "go.dedis.ch/dela/cli/node" - "go.dedis.ch/dela/core/ordering" - "go.dedis.ch/dela/core/ordering/cosipbft/authority" - "go.dedis.ch/dela/core/ordering/cosipbft/blockstore" - "go.dedis.ch/dela/core/txn" - "go.dedis.ch/dela/core/txn/pool" - "go.dedis.ch/dela/core/txn/signed" - "go.dedis.ch/dela/core/validation" - "go.dedis.ch/dela/crypto" - "go.dedis.ch/dela/crypto/bls" - "go.dedis.ch/dela/crypto/loader" - "go.dedis.ch/dela/mino" - "go.dedis.ch/dela/mino/proxy" - "go.dedis.ch/dela/serde" - sjson "go.dedis.ch/dela/serde/json" "golang.org/x/xerrors" ) const ( - contentType = "application/json" - formPath = "/evoting/forms" + contentType = "application/json" + formPath = "/evoting/forms" // FormPathSlash is the path to the form with a trailing slash FormPathSlash = formPath + "/" formIDPath = FormPathSlash + "{formID}" diff --git a/contracts/evoting/controller/mod.go b/contracts/evoting/controller/mod.go index 24d37b7a0..27526b5f3 100644 --- a/contracts/evoting/controller/mod.go +++ b/contracts/evoting/controller/mod.go @@ -1,11 +1,11 @@ package controller import ( - "go.dedis.ch/dela/cli" - "go.dedis.ch/dela/cli/node" - "go.dedis.ch/dela/core/access" - "go.dedis.ch/dela/core/ordering" - "go.dedis.ch/dela/core/validation" + "github.com/c4dt/dela/cli" + "github.com/c4dt/dela/cli/node" + "github.com/c4dt/dela/core/access" + "github.com/c4dt/dela/core/ordering" + "github.com/c4dt/dela/core/validation" ) // NewController returns a new controller initializer diff --git a/contracts/evoting/controller/mod_test.go b/contracts/evoting/controller/mod_test.go index d95da7b7d..85dc75ac7 100644 --- a/contracts/evoting/controller/mod_test.go +++ b/contracts/evoting/controller/mod_test.go @@ -3,8 +3,8 @@ package controller import ( "testing" + "github.com/c4dt/dela/cli/node" "github.com/stretchr/testify/require" - "go.dedis.ch/dela/cli/node" ) func TestController_OnStart(t *testing.T) { diff --git a/contracts/evoting/evoting.go b/contracts/evoting/evoting.go index 0832a3de0..3c6aee364 100644 --- a/contracts/evoting/evoting.go +++ b/contracts/evoting/evoting.go @@ -11,19 +11,19 @@ import ( "math/rand" "strings" - "go.dedis.ch/dela" + "github.com/c4dt/dela" "go.dedis.ch/kyber/v3/share" - "github.com/dedis/d-voting/contracts/evoting/types" - "go.dedis.ch/dela/core/execution" - "go.dedis.ch/dela/core/execution/native" - "go.dedis.ch/dela/core/ordering/cosipbft/authority" - "go.dedis.ch/dela/core/store" - "go.dedis.ch/dela/core/txn" - "go.dedis.ch/dela/cosi/threshold" - "go.dedis.ch/dela/crypto/bls" - "go.dedis.ch/dela/serde" + "github.com/c4dt/d-voting/contracts/evoting/types" + "github.com/c4dt/dela/core/execution" + "github.com/c4dt/dela/core/execution/native" + "github.com/c4dt/dela/core/ordering/cosipbft/authority" + "github.com/c4dt/dela/core/store" + "github.com/c4dt/dela/core/txn" + "github.com/c4dt/dela/cosi/threshold" + "github.com/c4dt/dela/crypto/bls" + "github.com/c4dt/dela/serde" "go.dedis.ch/kyber/v3/proof" "go.dedis.ch/kyber/v3/shuffle" "golang.org/x/xerrors" diff --git a/contracts/evoting/json/ciphervote.go b/contracts/evoting/json/ciphervote.go index b8c51b65d..bc9140655 100644 --- a/contracts/evoting/json/ciphervote.go +++ b/contracts/evoting/json/ciphervote.go @@ -1,8 +1,8 @@ package json import ( - "github.com/dedis/d-voting/contracts/evoting/types" - "go.dedis.ch/dela/serde" + "github.com/c4dt/d-voting/contracts/evoting/types" + "github.com/c4dt/dela/serde" "golang.org/x/xerrors" ) diff --git a/contracts/evoting/json/forms.go b/contracts/evoting/json/forms.go index 8497d4ab5..374bc86e5 100644 --- a/contracts/evoting/json/forms.go +++ b/contracts/evoting/json/forms.go @@ -3,10 +3,10 @@ package json import ( "encoding/json" - "github.com/dedis/d-voting/contracts/evoting/types" - "go.dedis.ch/dela/core/ordering/cosipbft/authority" - ctypes "go.dedis.ch/dela/core/ordering/cosipbft/types" - "go.dedis.ch/dela/serde" + "github.com/c4dt/d-voting/contracts/evoting/types" + "github.com/c4dt/dela/core/ordering/cosipbft/authority" + ctypes "github.com/c4dt/dela/core/ordering/cosipbft/types" + "github.com/c4dt/dela/serde" "go.dedis.ch/kyber/v3" "go.dedis.ch/kyber/v3/suites" "golang.org/x/xerrors" @@ -58,7 +58,7 @@ func (formFormat) Encode(ctx serde.Context, message serde.Message) ([]byte, erro formJSON := FormJSON{ Configuration: m.Configuration, - FormID: m.FormID, + FormID: m.FormID, Status: uint16(m.Status), Pubkey: pubkey, BallotSize: m.BallotSize, @@ -128,7 +128,7 @@ func (formFormat) Decode(ctx serde.Context, data []byte) (serde.Message, error) return types.Form{ Configuration: formJSON.Configuration, - FormID: formJSON.FormID, + FormID: formJSON.FormID, Status: types.Status(formJSON.Status), Pubkey: pubKey, BallotSize: formJSON.BallotSize, diff --git a/contracts/evoting/json/mod.go b/contracts/evoting/json/mod.go index ab07ec828..12e706781 100644 --- a/contracts/evoting/json/mod.go +++ b/contracts/evoting/json/mod.go @@ -1,8 +1,8 @@ package json import ( - "github.com/dedis/d-voting/contracts/evoting/types" - "go.dedis.ch/dela/serde" + "github.com/c4dt/d-voting/contracts/evoting/types" + "github.com/c4dt/dela/serde" ) // Register the JSON formats for the form, ciphervote, and transaction diff --git a/contracts/evoting/json/transaction.go b/contracts/evoting/json/transaction.go index 106ada9c7..08b084321 100644 --- a/contracts/evoting/json/transaction.go +++ b/contracts/evoting/json/transaction.go @@ -3,8 +3,8 @@ package json import ( "encoding/json" - "github.com/dedis/d-voting/contracts/evoting/types" - "go.dedis.ch/dela/serde" + "github.com/c4dt/d-voting/contracts/evoting/types" + "github.com/c4dt/dela/serde" "golang.org/x/xerrors" ) @@ -38,7 +38,7 @@ func (transactionFormat) Encode(ctx serde.Context, msg serde.Message) ([]byte, e } cv := CastVoteJSON{ - FormID: t.FormID, + FormID: t.FormID, UserID: t.UserID, Ciphervote: ballot, } @@ -47,7 +47,7 @@ func (transactionFormat) Encode(ctx serde.Context, msg serde.Message) ([]byte, e case types.CloseForm: ce := CloseFormJSON{ FormID: t.FormID, - UserID: t.UserID, + UserID: t.UserID, } m = TransactionJSON{CloseForm: &ce} @@ -64,7 +64,7 @@ func (transactionFormat) Encode(ctx serde.Context, msg serde.Message) ([]byte, e } sb := ShuffleBallotsJSON{ - FormID: t.FormID, + FormID: t.FormID, Round: t.Round, Ciphervotes: ciphervotes, RandomVector: t.RandomVector, @@ -90,25 +90,25 @@ func (transactionFormat) Encode(ctx serde.Context, msg serde.Message) ([]byte, e } rp := RegisterPubSharesJSON{ - FormID: t.FormID, - Index: t.Index, - PubShares: pubShares, - Signature: t.Signature, - PublicKey: t.PublicKey, + FormID: t.FormID, + Index: t.Index, + PubShares: pubShares, + Signature: t.Signature, + PublicKey: t.PublicKey, } m = TransactionJSON{RegisterPubShares: &rp} case types.CombineShares: db := CombineSharesJSON{ FormID: t.FormID, - UserID: t.UserID, + UserID: t.UserID, } m = TransactionJSON{CombineShares: &db} case types.CancelForm: ce := CancelFormJSON{ FormID: t.FormID, - UserID: t.UserID, + UserID: t.UserID, } m = TransactionJSON{CancelForm: &ce} @@ -159,7 +159,7 @@ func (transactionFormat) Decode(ctx serde.Context, data []byte) (serde.Message, case m.CloseForm != nil: return types.CloseForm{ FormID: m.CloseForm.FormID, - UserID: m.CloseForm.UserID, + UserID: m.CloseForm.UserID, }, nil case m.ShuffleBallots != nil: msg, err := decodeShuffleBallots(ctx, *m.ShuffleBallots) @@ -178,12 +178,12 @@ func (transactionFormat) Decode(ctx serde.Context, data []byte) (serde.Message, case m.CombineShares != nil: return types.CombineShares{ FormID: m.CombineShares.FormID, - UserID: m.CombineShares.UserID, + UserID: m.CombineShares.UserID, }, nil case m.CancelForm != nil: return types.CancelForm{ FormID: m.CancelForm.FormID, - UserID: m.CancelForm.UserID, + UserID: m.CancelForm.UserID, }, nil case m.DeleteForm != nil: return types.DeleteForm{ @@ -197,15 +197,15 @@ func (transactionFormat) Decode(ctx serde.Context, data []byte) (serde.Message, // TransactionJSON is the JSON message that wraps the different kinds of // transactions. type TransactionJSON struct { - CreateForm *CreateFormJSON `json:",omitempty"` - OpenForm *OpenFormJSON `json:",omitempty"` + CreateForm *CreateFormJSON `json:",omitempty"` + OpenForm *OpenFormJSON `json:",omitempty"` CastVote *CastVoteJSON `json:",omitempty"` - CloseForm *CloseFormJSON `json:",omitempty"` + CloseForm *CloseFormJSON `json:",omitempty"` ShuffleBallots *ShuffleBallotsJSON `json:",omitempty"` RegisterPubShares *RegisterPubSharesJSON `json:",omitempty"` CombineShares *CombineSharesJSON `json:",omitempty"` - CancelForm *CancelFormJSON `json:",omitempty"` - DeleteForm *DeleteFormJSON `json:",omitempty"` + CancelForm *CancelFormJSON `json:",omitempty"` + DeleteForm *DeleteFormJSON `json:",omitempty"` } // CreateFormJSON is the JSON representation of a CreateForm transaction @@ -221,7 +221,7 @@ type OpenFormJSON struct { // CastVoteJSON is the JSON representation of a CastVote transaction type CastVoteJSON struct { - FormID string + FormID string UserID string Ciphervote json.RawMessage } @@ -229,12 +229,12 @@ type CastVoteJSON struct { // CloseFormJSON is the JSON representation of a CloseForm transaction type CloseFormJSON struct { FormID string - UserID string + UserID string } // ShuffleBallotsJSON is the JSON representation of a ShuffleBallots transaction type ShuffleBallotsJSON struct { - FormID string + FormID string Round int Ciphervotes []json.RawMessage RandomVector types.RandomVector @@ -244,23 +244,23 @@ type ShuffleBallotsJSON struct { } type RegisterPubSharesJSON struct { - FormID string - Index int - PubShares PubsharesUnitJSON - Signature []byte - PublicKey []byte + FormID string + Index int + PubShares PubsharesUnitJSON + Signature []byte + PublicKey []byte } // CombineSharesJSON is the JSON representation of a CombineShares transaction type CombineSharesJSON struct { FormID string - UserID string + UserID string } // CancelFormJSON is the JSON representation of a CancelForm transaction type CancelFormJSON struct { FormID string - UserID string + UserID string } // DeleteFormJSON is the JSON representation of a DeleteForm transaction @@ -286,8 +286,8 @@ func decodeCastVote(ctx serde.Context, m CastVoteJSON) (serde.Message, error) { return types.CastVote{ FormID: m.FormID, - UserID: m.UserID, - Ballot: ciphervote, + UserID: m.UserID, + Ballot: ciphervote, }, nil } @@ -314,7 +314,7 @@ func decodeShuffleBallots(ctx serde.Context, m ShuffleBallotsJSON) (serde.Messag } return types.ShuffleBallots{ - FormID: m.FormID, + FormID: m.FormID, Round: m.Round, ShuffledBallots: ciphervotes, RandomVector: m.RandomVector, @@ -342,10 +342,10 @@ func decodeRegisterPubShares(m RegisterPubSharesJSON) (serde.Message, error) { } return types.RegisterPubShares{ - FormID: m.FormID, - Index: m.Index, - Pubshares: pubShares, - Signature: m.Signature, - PublicKey: m.PublicKey, + FormID: m.FormID, + Index: m.Index, + Pubshares: pubShares, + Signature: m.Signature, + PublicKey: m.PublicKey, }, nil } diff --git a/contracts/evoting/mod.go b/contracts/evoting/mod.go index 7f77b75f3..58957fb4f 100644 --- a/contracts/evoting/mod.go +++ b/contracts/evoting/mod.go @@ -1,24 +1,24 @@ package evoting import ( - dvoting "github.com/dedis/d-voting" - "github.com/dedis/d-voting/contracts/evoting/types" - "github.com/dedis/d-voting/services/dkg" + dvoting "github.com/c4dt/d-voting" + "github.com/c4dt/d-voting/contracts/evoting/types" + "github.com/c4dt/d-voting/services/dkg" + "github.com/c4dt/dela/core/access" + "github.com/c4dt/dela/core/execution" + "github.com/c4dt/dela/core/execution/native" + "github.com/c4dt/dela/core/ordering/cosipbft/authority" + "github.com/c4dt/dela/core/store" + "github.com/c4dt/dela/serde" + "github.com/c4dt/dela/serde/json" "github.com/prometheus/client_golang/prometheus" - "go.dedis.ch/dela/core/access" - "go.dedis.ch/dela/core/execution" - "go.dedis.ch/dela/core/execution/native" - "go.dedis.ch/dela/core/ordering/cosipbft/authority" - "go.dedis.ch/dela/core/store" - "go.dedis.ch/dela/serde" - "go.dedis.ch/dela/serde/json" "go.dedis.ch/kyber/v3/proof" "go.dedis.ch/kyber/v3/suites" "golang.org/x/xerrors" // Register the JSON format for the form - _ "github.com/dedis/d-voting/contracts/evoting/json" + _ "github.com/c4dt/d-voting/contracts/evoting/json" ) var ( @@ -68,7 +68,7 @@ var suite = suites.MustFind("Ed25519") const ( // ContractName is the name of the contract. - ContractName = "go.dedis.ch/dela.Evoting" + ContractName = "github.com/c4dt/dela.Evoting" // CmdArg is the argument's name to indicate the kind of command we want to // run on the contract. Should be one of the Command type. diff --git a/contracts/evoting/mod_test.go b/contracts/evoting/mod_test.go index 16e139fd5..6c5d078a3 100644 --- a/contracts/evoting/mod_test.go +++ b/contracts/evoting/mod_test.go @@ -7,23 +7,23 @@ import ( "strconv" "testing" - "github.com/dedis/d-voting/contracts/evoting/types" - "github.com/dedis/d-voting/internal/testing/fake" - "github.com/dedis/d-voting/services/dkg" + "github.com/c4dt/d-voting/contracts/evoting/types" + "github.com/c4dt/d-voting/internal/testing/fake" + "github.com/c4dt/d-voting/services/dkg" + "github.com/c4dt/dela/core/access" + "github.com/c4dt/dela/core/execution" + "github.com/c4dt/dela/core/execution/native" + "github.com/c4dt/dela/core/ordering" + "github.com/c4dt/dela/core/ordering/cosipbft/authority" + "github.com/c4dt/dela/core/store" + "github.com/c4dt/dela/core/txn" + "github.com/c4dt/dela/core/txn/signed" + "github.com/c4dt/dela/crypto" + "github.com/c4dt/dela/crypto/bls" + "github.com/c4dt/dela/serde" + sjson "github.com/c4dt/dela/serde/json" "github.com/prometheus/client_golang/prometheus/testutil" "github.com/stretchr/testify/require" - "go.dedis.ch/dela/core/access" - "go.dedis.ch/dela/core/execution" - "go.dedis.ch/dela/core/execution/native" - "go.dedis.ch/dela/core/ordering" - "go.dedis.ch/dela/core/ordering/cosipbft/authority" - "go.dedis.ch/dela/core/store" - "go.dedis.ch/dela/core/txn" - "go.dedis.ch/dela/core/txn/signed" - "go.dedis.ch/dela/crypto" - "go.dedis.ch/dela/crypto/bls" - "go.dedis.ch/dela/serde" - sjson "go.dedis.ch/dela/serde/json" "go.dedis.ch/kyber/v3" "go.dedis.ch/kyber/v3/proof" "go.dedis.ch/kyber/v3/util/random" diff --git a/contracts/evoting/types/ballots.go b/contracts/evoting/types/ballots.go index c6855251e..26fd3eed8 100644 --- a/contracts/evoting/types/ballots.go +++ b/contracts/evoting/types/ballots.go @@ -43,12 +43,6 @@ type Ballot struct { // Unmarshal decodes the given string according to the format described in // "state of smart contract.md" func (b *Ballot) Unmarshal(marshalledBallot string, form Form) error { - if len(marshalledBallot) > form.BallotSize { - b.invalidate() - return fmt.Errorf("ballot has an unexpected size %d, expected <= %d", - len(marshalledBallot), form.BallotSize) - } - lines := strings.Split(marshalledBallot, "\n") b.SelectResultIDs = make([]ID, 0) diff --git a/contracts/evoting/types/ballots_test.go b/contracts/evoting/types/ballots_test.go index 47dd9828b..fd64d16db 100644 --- a/contracts/evoting/types/ballots_test.go +++ b/contracts/evoting/types/ballots_test.go @@ -111,10 +111,6 @@ func TestBallot_Unmarshal(t *testing.T) { require.Equal(t, expected.TextResultIDs, b.TextResultIDs) require.Equal(t, expected.TextResult, b.TextResult) - // with ballot too long - err = b.Unmarshal(ballot1+"x", form) - require.EqualError(t, err, "ballot has an unexpected size 102, expected <= 101") - // with line wrongly formatted err = b.Unmarshal("x", form) require.EqualError(t, err, "a line in the ballot has length != 3: x") diff --git a/contracts/evoting/types/ciphervote.go b/contracts/evoting/types/ciphervote.go index f4279ea7e..4cef2ae11 100644 --- a/contracts/evoting/types/ciphervote.go +++ b/contracts/evoting/types/ciphervote.go @@ -4,8 +4,8 @@ import ( "fmt" "io" - "go.dedis.ch/dela/serde" - "go.dedis.ch/dela/serde/registry" + "github.com/c4dt/dela/serde" + "github.com/c4dt/dela/serde/registry" "go.dedis.ch/kyber/v3" "golang.org/x/xerrors" ) diff --git a/contracts/evoting/types/election.go b/contracts/evoting/types/election.go index de35d9630..9323ace18 100644 --- a/contracts/evoting/types/election.go +++ b/contracts/evoting/types/election.go @@ -3,10 +3,10 @@ package types import ( "io" - "go.dedis.ch/dela/core/ordering/cosipbft/authority" - ctypes "go.dedis.ch/dela/core/ordering/cosipbft/types" - "go.dedis.ch/dela/serde" - "go.dedis.ch/dela/serde/registry" + "github.com/c4dt/dela/core/ordering/cosipbft/authority" + ctypes "github.com/c4dt/dela/core/ordering/cosipbft/types" + "github.com/c4dt/dela/serde" + "github.com/c4dt/dela/serde/registry" "go.dedis.ch/kyber/v3" "go.dedis.ch/kyber/v3/suites" "golang.org/x/xerrors" diff --git a/contracts/evoting/types/transactions.go b/contracts/evoting/types/transactions.go index b13b03cbe..12d39738d 100644 --- a/contracts/evoting/types/transactions.go +++ b/contracts/evoting/types/transactions.go @@ -6,8 +6,8 @@ import ( "io" "strconv" - "go.dedis.ch/dela/serde" - "go.dedis.ch/dela/serde/registry" + "github.com/c4dt/dela/serde" + "github.com/c4dt/dela/serde/registry" "golang.org/x/xerrors" ) @@ -133,8 +133,8 @@ func (oe OpenForm) Serialize(ctx serde.Context) ([]byte, error) { type CastVote struct { // FormID is hex-encoded FormID string - UserID string - Ballot Ciphervote + UserID string + Ballot Ciphervote } // Serialize implements serde.Message @@ -155,7 +155,7 @@ func (cv CastVote) Serialize(ctx serde.Context) ([]byte, error) { type CloseForm struct { // FormID is hex-encoded FormID string - UserID string + UserID string } // Serialize implements serde.Message @@ -175,7 +175,7 @@ func (ce CloseForm) Serialize(ctx serde.Context) ([]byte, error) { // - implements serde.Message // - implements serde.Fingerprinter type ShuffleBallots struct { - FormID string + FormID string Round int ShuffledBallots []Ciphervote // RandomVector is the vector to be used to generate the proof of the next @@ -239,7 +239,7 @@ func (rp RegisterPubShares) Serialize(ctx serde.Context) ([]byte, error) { type CombineShares struct { // FormID is hex-encoded FormID string - UserID string + UserID string } // Serialize implements serde.Message @@ -260,7 +260,7 @@ func (db CombineShares) Serialize(ctx serde.Context) ([]byte, error) { type CancelForm struct { // FormID is hex-encoded FormID string - UserID string + UserID string } // Serialize implements serde.Message diff --git a/deb-package/README.md b/deb-package/README.md index ddcfa9144..ef6ec6462 100644 --- a/deb-package/README.md +++ b/deb-package/README.md @@ -170,9 +170,9 @@ To be done on each node. PK=<> # taken from the "ordering export", the part after ":" sudo dvoting --config /var/opt/dedis/dvoting/data/dela pool add \ --key $keypath \ - --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access \ + --args github.com/c4dt/dela.ContractArg --args github.com/c4dt/dela.Access \ --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000 \ - --args access:grant_contract --args go.dedis.ch/dela.Evoting \ + --args access:grant_contract --args github.com/c4dt/dela.Evoting \ --args access:grant_command --args all \ --args access:identity --args $PK \ --args access:command --args GRANT @@ -198,7 +198,7 @@ sudo apt install rubygems build-essential git ## Get the code ```sh -git clone https://github.com/dedis/d-voting.git +git clone https://github.com/c4dt/d-voting.git ``` ## Build the deb package diff --git a/deb-package/build-deb.sh b/deb-package/build-deb.sh index a374e11fa..0a61454ec 100755 --- a/deb-package/build-deb.sh +++ b/deb-package/build-deb.sh @@ -45,7 +45,7 @@ fpm \ --after-install pkg/after-install.sh \ --before-remove pkg/before-remove.sh \ --after-remove pkg/after-remove.sh \ - --url https://dedis.github.com/dedis/dvoting \ + --url https://dedis.github.com/c4dt/dvoting \ --description 'D-Voting package' \ --package dist . diff --git a/docker-compose/docker-compose.debug.yml b/docker-compose/docker-compose.debug.yml index 52078a067..66a1ea7f5 100644 --- a/docker-compose/docker-compose.debug.yml +++ b/docker-compose/docker-compose.debug.yml @@ -1,139 +1,105 @@ +version: "3.8" +x-dela: &dela + build: + dockerfile: Dockerfiles/Dockerfile.dela + context: ../ + target: build + env_file: ../.env + profiles: + - dela + - all +x-dela-env: &dela-env + PROXYKEY: ${PUBLIC_KEY} + PROXY_LOG: info + LLVL: debug + services: dela-worker-0: # inital DELA leader node - image: dela:latest - build: - dockerfile: Dockerfiles/Dockerfile.dela.debug - context: ../ + <<: *dela environment: - PROXYKEY: ${PUBLIC_KEY} - PROXYPORT: ${PROXYPORT} - PROXY_LOG: info - LLVL: debug - NODEPORT: ${NODEPORT} + <<: *dela-env + PUBLIC_URL: grpc://dela-worker-0:2000 volumes: - dela-worker-0-data:/data - hostname: dela-worker-0 ports: - 127.0.0.1:40000:40000 - security_opt: - - apparmor:unconfined - cap_add: - - SYS_PTRACE networks: d-voting: ipv4_address: 172.19.44.254 dela-worker-1: # DELA worker node - image: dela:latest - build: - dockerfile: Dockerfiles/Dockerfile.dela.debug - context: ../ - environment: - PROXYKEY: ${PUBLIC_KEY} - PROXYPORT: ${PROXYPORT} - PROXY_LOG: info - LLVL: debug - NODEPORT: ${NODEPORT} + <<: *dela volumes: - dela-worker-1-data:/data - hostname: dela-worker-1 + environment: + <<: *dela-env + PUBLIC_URL: grpc://dela-worker-1:2000 ports: - 127.0.0.1:40001:40000 - security_opt: - - apparmor:unconfined - cap_add: - - SYS_PTRACE networks: d-voting: ipv4_address: 172.19.44.253 dela-worker-2: # DELA worker node - image: dela:latest - build: - dockerfile: Dockerfiles/Dockerfile.dela.debug - context: ../ - environment: - PROXYKEY: ${PUBLIC_KEY} - PROXYPORT: ${PROXYPORT} - PROXY_LOG: info - LLVL: debug - NODEPORT: ${NODEPORT} + <<: *dela volumes: - dela-worker-2-data:/data - hostname: dela-worker-2 + environment: + <<: *dela-env + PUBLIC_URL: grpc://dela-worker-2:2000 ports: - 127.0.0.1:40002:40000 - security_opt: - - apparmor:unconfined - cap_add: - - SYS_PTRACE networks: d-voting: ipv4_address: 172.19.44.252 dela-worker-3: # DELA worker node - image: dela:latest - build: - dockerfile: Dockerfiles/Dockerfile.dela.debug - context: ../ - environment: - PROXYKEY: ${PUBLIC_KEY} - PROXYPORT: ${PROXYPORT} - PROXY_LOG: info - LLVL: debug - NODEPORT: ${NODEPORT} + <<: *dela volumes: - dela-worker-3-data:/data - hostname: dela-worker-3 + environment: + <<: *dela-env + PUBLIC_URL: grpc://dela-worker-3:2000 ports: - 127.0.0.1:40003:40000 - security_opt: - - apparmor:unconfined - cap_add: - - SYS_PTRACE networks: d-voting: ipv4_address: 172.19.44.251 frontend: # web service frontend - image: frontend:latest + image: ghcr.io/c4dt/d-voting-frontend:latest build: dockerfile: Dockerfiles/Dockerfile.frontend context: ../ ports: - 127.0.0.1:3000:3000 + command: run start volumes: - - ../web/frontend/src:/web/frontend/src - environment: - BACKEND_HOST: ${BACKEND_HOST} - BACKEND_PORT: ${BACKEND_PORT} + - ../web/frontend/src:/web/frontend/src # mount codebase for development + env_file: ../.env + profiles: + - client + - all networks: d-voting: ipv4_address: 172.19.44.2 backend: # web service backend - image: backend:latest + 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} + command: run start-dev + env_file: ../.env ports: - 127.0.0.1:5000:5000 - - 127.0.0.1:80:80 depends_on: db: condition: service_started volumes: - backend-data:/data - - ../web/backend/src:/web/backend/src + - ../web/backend/src:/web/backend/src # mount codebase for development + profiles: + - client + - all networks: d-voting: ipv4_address: 172.19.44.3 @@ -146,10 +112,36 @@ services: volumes: - postgres-data:/var/lib/postgresql/data - ../web/backend/src/migration.sql:/docker-entrypoint-initdb.d/init.sql + profiles: + - client + - all networks: d-voting: ipv4_address: 172.19.44.4 + shell: # helper container to execute scripts from within Docker network (macOS/Windows setup) + image: buildpack-deps:bookworm-curl + env_file: ../.env + profiles: + - debug + - all + networks: + d-voting: + ipv4_address: 172.19.44.5 + volumes: + - ../:/src + + firefox: # helper container to execute Firefox within Docker network (macOS/Windows setup) + image: jlesage/firefox + profiles: + - debug + - all + ports: + - 127.0.0.1:5800:5800 + networks: + d-voting: + ipv4_address: 172.19.44.6 + volumes: postgres-data: # PostgreSQL database dela-worker-0-data: diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index ad0a468b1..2e86e7634 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -1,82 +1,77 @@ +version: "3.8" +x-dela: &dela + image: ghcr.io/c4dt/d-voting-dela:latest + env_file: ../.env +x-dela-env: &dela-env + PROXYKEY: ${PUBLIC_KEY} + PROXY_LOG: info + LLVL: info + services: dela-worker-0: # inital DELA leader node - image: ghcr.io/c4dt/d-voting-dela:latest + <<: *dela + build: + dockerfile: Dockerfiles/Dockerfile.dela + context: ../ + target: build environment: - PROXYKEY: ${PUBLIC_KEY} - PROXYPORT: ${PROXYPORT} - LLVL: info - NODEPORT: ${NODEPORT} + <<: *dela-env + PUBLIC_URL: grpc://dela-worker-0:2000 volumes: - dela-worker-0-data:/data - hostname: dela-worker-0 networks: d-voting: ipv4_address: 172.19.44.254 dela-worker-1: # DELA worker node - image: ghcr.io/c4dt/d-voting-dela:latest - environment: - PROXYKEY: ${PUBLIC_KEY} - PROXYPORT: ${PROXYPORT} - LLVL: info - NODEPORT: ${NODEPORT} + <<: *dela volumes: - dela-worker-1-data:/data - hostname: dela-worker-1 + environment: + <<: *dela-env + PUBLIC_URL: grpc://dela-worker-1:2000 networks: d-voting: ipv4_address: 172.19.44.253 dela-worker-2: # DELA worker node - image: ghcr.io/c4dt/d-voting-dela:latest - environment: - PROXYKEY: ${PUBLIC_KEY} - PROXYPORT: ${PROXYPORT} - LLVL: info - NODEPORT: ${NODEPORT} + <<: *dela volumes: - dela-worker-2-data:/data - hostname: dela-worker-2 + environment: + <<: *dela-env + PUBLIC_URL: grpc://dela-worker-2:2000 networks: d-voting: ipv4_address: 172.19.44.252 dela-worker-3: # DELA worker node - image: ghcr.io/c4dt/d-voting-dela:latest - environment: - PROXYKEY: ${PUBLIC_KEY} - PROXYPORT: ${PROXYPORT} - LLVL: info - NODEPORT: ${NODEPORT} + <<: *dela volumes: - dela-worker-3-data:/data - hostname: dela-worker-3 + environment: + <<: *dela-env + PUBLIC_URL: grpc://dela-worker-3:2000 networks: d-voting: ipv4_address: 172.19.44.251 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: - BACKEND_HOST: ${BACKEND_HOST} - BACKEND_PORT: ${BACKEND_PORT} + env_file: ../.env networks: d-voting: ipv4_address: 172.19.44.2 backend: # web service backend image: ghcr.io/c4dt/d-voting-backend:latest - 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} + build: + dockerfile: Dockerfiles/Dockerfile.backend + context: ../ + env_file: ../.env ports: - 127.0.0.1:5000:5000 depends_on: @@ -95,7 +90,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/docs/coverpage.md b/docs/coverpage.md index df717a4c8..4462113e3 100644 --- a/docs/coverpage.md +++ b/docs/coverpage.md @@ -5,7 +5,7 @@

- +

- An open platform to run voting instances on a blockchain diff --git a/docs/index.html b/docs/index.html index 1fd7617bc..4a414ee1a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -13,7 +13,7 @@