Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull request w/ the latest developments by C4DT #375

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
5b6394c
Cleanup debugging
ineiti Sep 25, 2023
8b1299f
@PascalinDe's comments
ineiti Sep 25, 2023
71b08e7
@Pierluca's comments
ineiti Sep 27, 2023
7bfd8b5
feat: improve on debug/production deployments
PascalinDe Sep 22, 2023
81846b7
Merge pull request #1 from c4dt/docker-on-macos-windows
PascalinDe Sep 27, 2023
1b32705
Merge pull request #3 from c4dt/cleanup_debugging
lanterno Sep 27, 2023
3cb508b
chore: add Docker image building to CI
PascalinDe Sep 27, 2023
40742e9
Fixing voting
ineiti Sep 28, 2023
e84aa4b
Adds local login and script for testing
ineiti Sep 25, 2023
da31220
@pierluca's comments
ineiti Sep 27, 2023
ca3ce8d
Modify scripts for login, creating a form, and voting
ineiti Sep 26, 2023
24b4566
Merge pull request #5 from c4dt/docker-ci
PascalinDe Sep 28, 2023
94148dd
Merge pull request #6 from c4dt/fix_votes
ineiti Sep 28, 2023
9843f66
Merge pull request #4 from c4dt/local_login
ineiti Sep 28, 2023
3e7eeca
Merge pull request #2 from c4dt/run_voting_tests
ineiti Sep 28, 2023
571a94f
Fixing scripts to correctly handle the proxy database
ineiti Sep 28, 2023
ad74a7d
Yarn lockfile update for Mac
ineiti Sep 28, 2023
e97f0da
Merge pull request #10 from c4dt/yarn_lock
ineiti Sep 29, 2023
5cfa5c1
Pointing to c4dt forks of dela, dela-apps, and d-voting
ineiti Sep 29, 2023
724bf85
Merge pull request #9 from c4dt/fix_proxies
ineiti Sep 29, 2023
636d9aa
Merge pull request #8 from c4dt/move_fork
PascalinDe Sep 29, 2023
f2ac57a
Cleaning up
ineiti Sep 29, 2023
be954a9
Changes necessary for noTLS
ineiti Sep 29, 2023
19e4089
fix: removes buggy check on form ballot size.
Oct 3, 2023
2f27c4f
Merge pull request #12 from c4dt/for_notls
ineiti Oct 3, 2023
a73ff85
Merge pull request #14 from c4dt/fix/removes-check-on-ballot-size
lanterno Oct 3, 2023
68cdb33
Adding logging variables and cleaning up a throw within a catch
ineiti Oct 4, 2023
76acfb0
Only allowing dev login if REACT_APP_DEV_LOGIN === 'true'
ineiti Oct 4, 2023
6fc65fc
Merge pull request #18 from c4dt/cleanup_frontend
ineiti Oct 4, 2023
05b3556
ops: makes it easier to override app default startup commmand
Oct 2, 2023
f8ef7a1
ops: enables auto server reload for local development
Oct 2, 2023
d85c9bb
ops: adds profiles and unifies settings for all compose services
Oct 2, 2023
ecb4cd2
feat: add PR template
PascalinDe Oct 4, 2023
c2129c4
Merge branch 'dedis:main' into main
lanterno Oct 4, 2023
0c23aaa
Merge pull request #19 from c4dt/pr-template
PascalinDe Oct 4, 2023
7b4ad26
ops: disables https on the react client and standardizes start commands
Oct 4, 2023
ac41443
Merge pull request #11 from c4dt/devops/adjusts-docker-configurations…
lanterno Oct 4, 2023
2a77850
Fixing always failing test
ineiti Oct 4, 2023
948b17a
Adding a CHANGELOG.md - please use it
ineiti Oct 4, 2023
0d90cd6
Formatting and errors in comments
ineiti Oct 4, 2023
86c7c5e
Nicefying vote comments
ineiti Oct 4, 2023
61d7ac9
@Pierluca's comments
ineiti Oct 4, 2023
6149677
Merge pull request #20 from c4dt/more_cleanups
ineiti Oct 4, 2023
6d147ae
Updating to point to latest dela
ineiti Oct 4, 2023
071c9e4
Merge pull request #22 from c4dt/update_gomod
ineiti Oct 4, 2023
05b4b46
Using new package.json actions
ineiti Oct 4, 2023
2e1ff9e
refactor: remove unused build stage 'debug'
PascalinDe Oct 4, 2023
95cbebf
fix: set log level back to 'debug'
PascalinDe Oct 4, 2023
b80f59b
fix: aligned docker-compose.yml and docker-compose.debug.yml
PascalinDe Oct 4, 2023
079cdcc
Making some tests run again
ineiti Oct 4, 2023
7c789c8
feat: use --noTLS by default for production deployment (TLS terminati…
PascalinDe Oct 4, 2023
4d69872
fix: remove profiles from preproduction deployment file
PascalinDe Oct 4, 2023
6b6ddc4
Merge pull request #16 from c4dt/noTLS-docker
ineiti Oct 5, 2023
956fb29
chore: fix Docker image build CI
PascalinDe Oct 5, 2023
739a78b
Merge pull request #25 from c4dt/fix-docker-ci
PascalinDe Oct 5, 2023
28e48be
Merge pull request #23 from c4dt/follow_updates
ineiti Oct 5, 2023
7ccf3c5
If no form found, redirect to '/form/index'. Better show error from b…
ineiti Oct 4, 2023
dfe3a32
Replacing DELA_NODE_URL with the more correct DELA_PROXY_URL
ineiti Oct 5, 2023
3214f9b
Correctly call endpoints only once in case of updates to the react form
ineiti Oct 5, 2023
fd36415
Correctly add/modify/delete a proxy without returning an error
ineiti Oct 5, 2023
09e25f5
Adding possible GRPC debug levels
ineiti Oct 5, 2023
92921ba
Merge pull request #24 from c4dt/cleanups_2
ineiti Oct 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -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)
48 changes: 48 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/go_dvoting_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go_scenario_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
33 changes: 1 addition & 32 deletions .github/workflows/go_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ nodedata/

deb-package/dist/**

.env

dela/
bin/
nodes/
cookies.txt
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion Dockerfiles/Dockerfile.backend
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
12 changes: 7 additions & 5 deletions Dockerfiles/Dockerfile.dela
Original file line number Diff line number Diff line change
@@ -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 []
18 changes: 0 additions & 18 deletions Dockerfiles/Dockerfile.dela.debug

This file was deleted.

3 changes: 2 additions & 1 deletion Dockerfiles/Dockerfile.frontend
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
28 changes: 18 additions & 10 deletions README.docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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=<path to Docker Compose file>
```

or pass the `-f/--file <path to Docker Compose 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.
Expand Down
52 changes: 26 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,51 @@
<a href="https://sonarcloud.io/summary/new_code?id=dedis_d-voting">
<img src="https://sonarcloud.io/api/project_badges/measure?project=dedis_d-voting&metric=alert_status">
</a>
<a href="https://github.com/dedis/d-voting/actions/workflows/go_release.yml">
<img src="https://github.com/dedis/d-voting/actions/workflows/go_release.yml/badge.svg">
<a href="https://github.com/c4dt/d-voting/actions/workflows/go_release.yml">
<img src="https://github.com/c4dt/d-voting/actions/workflows/go_release.yml/badge.svg">
</a><br/>
<a href="https://github.com/dedis/d-voting/graphs/contributors">
<a href="https://github.com/c4dt/d-voting/graphs/contributors">
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/dedis/d-voting">
</a>
<a href="https://github.com/dedis/d-voting/releases">
<a href="https://github.com/c4dt/d-voting/releases">
<img alt="GitHub release (latest SemVer)" src="https://img.shields.io/github/v/release/dedis/d-voting">
</a>
</td>
</tr>
<tr>
<td>Blockchain</td>
<td>
<a href="https://github.com/dedis/d-voting/actions/workflows/go_test.yml">
<img src="https://github.com/dedis/d-voting/actions/workflows/go_test.yml/badge.svg">
<a href="https://github.com/c4dt/d-voting/actions/workflows/go_test.yml">
<img src="https://github.com/c4dt/d-voting/actions/workflows/go_test.yml/badge.svg">
</a>
<a href="https://github.com/dedis/d-voting/actions/workflows/go_dvoting_test.yml">
<img src="https://github.com/dedis/d-voting/actions/workflows/go_dvoting_test.yml/badge.svg">
<a href="https://github.com/c4dt/d-voting/actions/workflows/go_dvoting_test.yml">
<img src="https://github.com/c4dt/d-voting/actions/workflows/go_dvoting_test.yml/badge.svg">
</a>
<a href="https://github.com/dedis/d-voting/actions/workflows/go_scenario_test.yml">
<img src="https://github.com/dedis/d-voting/actions/workflows/go_scenario_test.yml/badge.svg">
<a href="https://github.com/c4dt/d-voting/actions/workflows/go_scenario_test.yml">
<img src="https://github.com/c4dt/d-voting/actions/workflows/go_scenario_test.yml/badge.svg">
</a>
<a href="https://github.com/dedis/d-voting/actions/workflows/go_integration_tests.yml">
<img src="https://github.com/dedis/d-voting/actions/workflows/go_integration_tests.yml/badge.svg">
<a href="https://github.com/c4dt/d-voting/actions/workflows/go_integration_tests.yml">
<img src="https://github.com/c4dt/d-voting/actions/workflows/go_integration_tests.yml/badge.svg">
</a><br/>
<a href="https://coveralls.io/github/dedis/d-voting?branch=main">
<img src="https://coveralls.io/repos/github/dedis/d-voting/badge.svg?branch=main">
</a>
<a href="https://goreportcard.com/report/github.com/dedis/d-voting">
<img src="https://goreportcard.com/badge/github.com/dedis/d-voting">
<a href="https://goreportcard.com/report/github.com/c4dt/d-voting">
<img src="https://goreportcard.com/badge/github.com/c4dt/d-voting">
</a>
<a href="https://pkg.go.dev/github.com/dedis/d-voting">
<img src="https://pkg.go.dev/badge/github.com/dedis/d-voting.svg" alt="Go Reference">
<a href="https://pkg.go.dev/github.com/c4dt/d-voting">
<img src="https://pkg.go.dev/badge/github.com/c4dt/d-voting.svg" alt="Go Reference">
</a>
</td>
<tr>
<tr>
<td>WEB</td>
<td>
<a href="https://github.com/dedis/d-voting/actions/workflows/web_frontend_lint.yml">
<img src="https://github.com/dedis/d-voting/actions/workflows/web_frontend_lint.yml/badge.svg">
<a href="https://github.com/c4dt/d-voting/actions/workflows/web_frontend_lint.yml">
<img src="https://github.com/c4dt/d-voting/actions/workflows/web_frontend_lint.yml/badge.svg">
</a>
<a href="https://github.com/dedis/d-voting/actions/workflows/web_backend_lint.yml">
<img src="https://github.com/dedis/d-voting/actions/workflows/web_backend_lint.yml/badge.svg">
<a href="https://github.com/c4dt/d-voting/actions/workflows/web_backend_lint.yml">
<img src="https://github.com/c4dt/d-voting/actions/workflows/web_backend_lint.yml/badge.svg">
</a>
</td>
</tr>
Expand All @@ -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.
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
```
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
```
Expand Down
Loading