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

Renaming memcoin to dvoting #355

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Memcoin (CLI+HTTP) Test
name: Dvoting (CLI+HTTP) Test

on:
push:
Expand Down Expand Up @@ -29,17 +29,17 @@ jobs:
- name: Create a private key
run: crypto bls signer new --save private.key

- name: Install memcoin
- name: Install dvoting
run: make build

- name: Start 3 nodes
run: |
./memcoin --config /tmp/node1 start --port 2001 &
./memcoin --config /tmp/node2 start --port 2002 &
./memcoin --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 &

- name: Run the setup
run: ./setup.sh

- name: Run the scenario test
run: ./memcoin --config /tmp/node1 e-voting scenarioTest
run: ./dvoting --config /tmp/node1 e-voting scenarioTest
2 changes: 1 addition & 1 deletion .github/workflows/go_scenario_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Create a private key
run: crypto bls signer new --save private.key

- name: Install memcoin
- name: Install dvoting
run: make build

- name: Start and setup 5 nodes
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
types: [published]

jobs:
memcoin:
name: release memcoin and .deb
dvoting:
name: release dvoting and .deb
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
uses: softprops/action-gh-release@v1
with:
files: |
memcoin-*
dvoting-*
deb-package/dist/*

backend:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ private.key
web/app/node_modules
.idea

memcoin*
dvoting*

*.log

Expand Down
6 changes: 3 additions & 3 deletions Dockerfiles/Dockerfile.dela
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ 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/memcoin
WORKDIR /go/d-voting/cli/dvoting
RUN go build
ENV PATH=/go/dela/cli/crypto:/go/d-voting/cli/memcoin:${PATH}
ENV PATH=/go/dela/cli/crypto:/go/d-voting/cli/dvoting:${PATH}
WORKDIR /go
ENTRYPOINT ["/bin/bash", "-c", "memcoin --config /data/node start --postinstall --proxyaddr :$PROXYPORT --proxykey $PROXYKEY --listen tcp://0.0.0.0:2000 --public http://$HOSTNAME:2000 --routing tree"]
ENTRYPOINT ["/bin/bash", "-c", "dvoting --config /data/node start --postinstall --proxyaddr :$PROXYPORT --proxykey $PROXYKEY --listen tcp://0.0.0.0:2000 --public http://$HOSTNAME:2000 --routing tree"]
CMD []
6 changes: 3 additions & 3 deletions Dockerfiles/Dockerfile.dela.debug
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ 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/memcoin
WORKDIR /go/d-voting/cli/dvoting

RUN go build -gcflags="all=-N -l"

ENV PATH=/go/dela/cli/crypto:/go/d-voting/cli/memcoin:${PATH}
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/memcoin/memcoin -- --config /data/node start --postinstall --proxyaddr :$PROXYPORT --proxykey $PROXYKEY --listen tcp://0.0.0.0:2000 --public http://$HOSTNAME:2000 --routing tree"]
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 []
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ test_integration:
go test ./integration

build:
go build -ldflags="-X $(versionFlag) -X $(timeFlag)" -o memcoin ./cli/memcoin
GOOS=linux GOARCH=amd64 go build -ldflags="-X $(versionFlag) -X $(timeFlag)" -o memcoin-linux-amd64-$(versionFile) ./cli/memcoin
GOOS=darwin GOARCH=amd64 go build -ldflags="-X $(versionFlag) -X $(timeFlag)" -o memcoin-darwin-amd64-$(versionFile) ./cli/memcoin
GOOS=windows GOARCH=amd64 go build -ldflags="-X $(versionFlag) -X $(timeFlag)" -o memcoin-windows-amd64-$(versionFile) ./cli/memcoin
go build -ldflags="-X $(versionFlag) -X $(timeFlag)" -o dvoting ./cli/dvoting
GOOS=linux GOARCH=amd64 go build -ldflags="-X $(versionFlag) -X $(timeFlag)" -o dvoting-linux-amd64-$(versionFile) ./cli/dvoting
GOOS=darwin GOARCH=amd64 go build -ldflags="-X $(versionFlag) -X $(timeFlag)" -o dvoting-darwin-amd64-$(versionFile) ./cli/dvoting
GOOS=windows GOARCH=amd64 go build -ldflags="-X $(versionFlag) -X $(timeFlag)" -o dvoting-windows-amd64-$(versionFile) ./cli/dvoting

deb: build
cd deb-package; ./build-deb.sh; cd ..
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<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>
<a href="https://github.com/dedis/d-voting/actions/workflows/go_memcoin_test.yml">
<img src="https://github.com/dedis/d-voting/actions/workflows/go_memcoin_test.yml/badge.svg">
<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>
<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">
Expand Down Expand Up @@ -277,7 +277,7 @@ results.
.
├── cli
│ ├── cosipbftcontroller Custom initialization of the blockchain node
│ ├── <b>memcoin</b> Build the node CLI
│ ├── <b>dvoting</b> Build the node CLI
│ └── postinstall Custom node CLI setup
├── <b>contracts</b>
│ └── <b>evoting</b> D-Voting smart contract
Expand Down Expand Up @@ -505,13 +505,13 @@ In three different terminal sessions, from the root folder:
```sh
pk=adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3

LLVL=info memcoin --config /tmp/node1 start --postinstall \
LLVL=info dvoting --config /tmp/node1 start --postinstall \
--promaddr :9100 --proxyaddr :9080 --proxykey $pk --listen tcp://0.0.0.0:2001 --public //localhost:2001

LLVL=info memcoin --config /tmp/node2 start --postinstall \
LLVL=info dvoting --config /tmp/node2 start --postinstall \
--promaddr :9101 --proxyaddr :9081 --proxykey $pk --listen tcp://0.0.0.0:2002 --public //localhost:2002

LLVL=info memcoin --config /tmp/node3 start --postinstall \
LLVL=info dvoting --config /tmp/node3 start --postinstall \
--promaddr :9102 --proxyaddr :9082 --proxykey $pk --listen tcp://0.0.0.0:2003 --public //localhost:2003
```

Expand Down Expand Up @@ -569,7 +569,7 @@ you can run a test scenario:

```sh
sk=28912721dfd507e198b31602fb67824856eb5a674c021d49fdccbe52f0234409
LLVL=info memcoin --config /tmp/node1 e-voting scenarioTest --secretkey $sk
LLVL=info dvoting --config /tmp/node1 e-voting scenarioTest --secretkey $sk
```

You can also run scenario_test.go, by running in the integration folder this
Expand Down Expand Up @@ -643,7 +643,7 @@ A d-Voting node exposes Prometheus metrics. You can start an HTTP server that
serves those metrics with:

```sh
./memcoin --config /tmp/node1 metrics start --addr 127.0.0.1:9100 --path /metrics
./dvoting --config /tmp/node1 metrics start --addr 127.0.0.1:9100 --path /metrics
```

Build info can be added to the binary with the `ldflags`, at build time. Infos
Expand All @@ -653,7 +653,7 @@ are stored on variables in the root `mod.go`. For example:
versionFlag="github.com/dedis/d-voting.Version=`git describe --tags`"
timeFlag="github.com/dedis/d-voting.BuildTime=`date +'%d/%m/%y_%H:%M'`"

go build -ldflags="-X $versionFlag -X $timeFlag" ./cli/memcoin
go build -ldflags="-X $versionFlag -X $timeFlag" ./cli/dvoting
```

Note that `make build` will do that for you.
Expand Down
28 changes: 14 additions & 14 deletions cli/memcoin/mod.go → cli/dvoting/mod.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
// Package main implements a ledger based on in-memory components.
// Package main implements the dvoting backend
//
// Unix example:
//
// # Expect GOPATH to be correctly set to have memcoin available.
// # Expect GOPATH to be correctly set to have dvoting available.
// go install
//
// memcoin --config /tmp/node1 start --port 2001 &
// memcoin --config /tmp/node2 start --port 2002 &
// memcoin --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.
// memcoin --config /tmp/node2 minogrpc join --address 127.0.0.1:2001\
// $(memcoin --config /tmp/node1 minogrpc token)
// memcoin --config /tmp/node3 minogrpc join --address 127.0.0.1:2001\
// $(memcoin --config /tmp/node1 minogrpc token)
// 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.
// memcoin --config /tmp/node1 ordering setup\
// --member $(memcoin --config /tmp/node1 ordering export)\
// --member $(memcoin --config /tmp/node2 ordering export)
// 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.
// memcoin --config /tmp/node1 ordering roster add\
// --member $(memcoin --config /tmp/node3 ordering export)
// dvoting --config /tmp/node1 ordering roster add\
// --member $(dvoting --config /tmp/node3 ordering export)
//
package main

Expand Down
10 changes: 5 additions & 5 deletions cli/memcoin/mod_test.go → cli/dvoting/mod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ import (
"github.com/stretchr/testify/require"
)

func TestMemcoin_Main(t *testing.T) {
func TestDvoting_Main(t *testing.T) {
main()
}

// This test creates a chain with initially 3 nodes. It then adds node 4 and 5
// in two blocks. Node 4 does not share its certificate which means others won't
// be able to communicate, but the chain should proceed because of the
// threshold.
func TestMemcoin_Scenario_SetupAndTransactions(t *testing.T) {
dir, err := os.MkdirTemp(os.TempDir(), "memcoin1")
func TestDvoting_Scenario_SetupAndTransactions(t *testing.T) {
dir, err := os.MkdirTemp(os.TempDir(), "dvoting1")
require.NoError(t, err)

defer os.RemoveAll(dir)
Expand Down Expand Up @@ -116,8 +116,8 @@ func TestMemcoin_Scenario_SetupAndTransactions(t *testing.T) {
// finally restarts both of them to make sure the chain can proceed after the
// restart. It basically tests if the components are correctly loaded from the
// persisten storage.
func TestMemcoin_Scenario_RestartNode(t *testing.T) {
dir, err := os.MkdirTemp(os.TempDir(), "memcoin2")
func TestDvoting_Scenario_RestartNode(t *testing.T) {
dir, err := os.MkdirTemp(os.TempDir(), "dvoting2")
require.NoError(t, err)

defer os.RemoveAll(dir)
Expand Down
4 changes: 2 additions & 2 deletions contracts/evoting/controller/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (m controller) SetCommands(builder node.Builder) {
cmd := builder.SetCommand("e-voting")
cmd.SetDescription("interact with the evoting service")

// memcoin --config /tmp/node1 e-voting \
// dvoting --config /tmp/node1 e-voting \
// registerHandlers --signer private.key
sub := cmd.SetSubCommand("registerHandlers")
sub.SetDescription("register the e-voting handlers on the default proxy")
Expand All @@ -38,7 +38,7 @@ func (m controller) SetCommands(builder node.Builder) {
)
sub.SetAction(builder.MakeAction(&RegisterAction{}))

// memcoin --config /tmp/node1 e-voting scenarioTest
// dvoting --config /tmp/node1 e-voting scenarioTest
sub = cmd.SetSubCommand("scenarioTest")
sub.SetDescription("evoting scenario test")
sub.SetFlags(
Expand Down
12 changes: 6 additions & 6 deletions deb-package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Check how a node is started in `pkg/opt/dedis/dvoting/bin/start-voting`. For
example:

```sh
LLVL=info ./memcoin-darwin-amd64-v0_4_5-alpha \
LLVL=info ./dvoting-darwin-amd64-v0_4_5-alpha \
--config /tmp/node8 \
start \
--postinstall \
Expand Down Expand Up @@ -115,7 +115,7 @@ credentials.
Get the token and certificate (24h * 30 = 720):

```sh
sudo memcoin --config /var/opt/dedis/dvoting/data/dela minogrpc token \
sudo dvoting --config /var/opt/dedis/dvoting/data/dela minogrpc token \
--expiration 720h
```

Expand All @@ -133,7 +133,7 @@ that the certificates are stored in the DB, which means that this operation must
be re-done in case the DB is reset.

```sh
sudo memcoin --config /var/opt/dedis/dvoting/data/dela minogrpc join \
sudo dvoting --config /var/opt/dedis/dvoting/data/dela minogrpc join \
--address <MASTER NODE ADDRESS> --token <TOKEN> --cert-hash <CERT HASH>
```

Expand All @@ -144,7 +144,7 @@ Example of `<MASTER NODE ADDRESS>`: `'//172.16.253.150:9000'`
First get the address of all nodes by running:

```sh
sudo memcoin --config /var/opt/dedis/dvoting/data/dela ordering export
sudo dvoting --config /var/opt/dedis/dvoting/data/dela ordering export
```

This will yield a base64 encoded string `<ADDRESS>:<PUB KEY>`.
Expand All @@ -156,7 +156,7 @@ From the first node.
Include ALL nodes, the first and all other nodes.

```sh
sudo memcoin --config /var/opt/dedis/dvoting/data/dela ordering setup \
sudo dvoting --config /var/opt/dedis/dvoting/data/dela ordering setup \
--member <RESULT FROM ordering export>\
--member <...>
...
Expand All @@ -168,7 +168,7 @@ To be done on each node.

```sh
PK=<> # taken from the "ordering export", the part after ":"
sudo memcoin --config /var/opt/dedis/dvoting/data/dela pool add \
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 access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000 \
Expand Down
2 changes: 1 addition & 1 deletion deb-package/build-deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mkdir -p $INSTALL_DIR
GITVERSION=$(git describe --abbrev=0 --tags || echo '0.0.0')
VERSION=${GITVERSION:1}

cp ../memcoin $INSTALL_DIR/
cp ../dvoting $INSTALL_DIR/

# add config files
cp -a pkg/etc deb
Expand Down
2 changes: 1 addition & 1 deletion deb-package/pkg/after-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ DVOTING_SERVICE=dvoting.service
enable_service ${DVOTING_SERVICE}
systemctl start ${DVOTING_SERVICE}

ln -s /opt/dedis/dvoting/bin/memcoin /usr/bin/memcoin
ln -s /opt/dedis/dvoting/bin/dvoting /usr/bin/dvoting
2 changes: 1 addition & 1 deletion deb-package/pkg/before-remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# stop service
systemctl stop dvoting.service

rm -f /usr/bin/memcoin
rm -f /usr/bin/dvoting
2 changes: 1 addition & 1 deletion deb-package/pkg/opt/dedis/dvoting/config/config.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# This file should not be updated unless for very specific use cases.
# For user configuration see /etc/dedis/dvoting
#
export dela_bin="/opt/dedis/dvoting/bin/memcoin"
export dela_bin="/opt/dedis/dvoting/bin/dvoting"
export dela_data="/var/opt/dedis/dvoting/data/dela"
2 changes: 1 addition & 1 deletion integration/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func restartNode(nodeNub int, t *testing.T) {
err = cmd.Run()
require.NoError(t, err)

cmd = exec.Command("bash", "-c", fmt.Sprintf("docker exec -d node%v memcoin --config /tmp/node%v start --postinstall --promaddr :9100 --proxyaddr :9080 --proxykey adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 --listen tcp://0.0.0.0:2001 --public //172.18.0.%v:2001", nodeNub, nodeNub, nodeNub+1))
cmd = exec.Command("bash", "-c", fmt.Sprintf("docker exec -d node%v dvoting --config /tmp/node%v start --postinstall --promaddr :9100 --proxyaddr :9080 --proxykey adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 --listen tcp://0.0.0.0:2001 --public //172.18.0.%v:2001", nodeNub, nodeNub, nodeNub+1))
err = cmd.Run()
require.NoError(t, err)
}
Expand Down
Loading