Skip to content
Pau edited this page May 15, 2020 · 6 revisions

Developer starting guide

Unlike most of the standard platform projects, Vocdoni is a p2p based ecosystem. So it is mainly build on top of components that do not require a centralized trusted management. This characteristic makes Vocdoni a quite complex project in comparison with standard client/server infrastructures, but in the other side gives flexibility, scalability and trust-less third party contribution.

distributed backend

A good starting point for understanding the global architecture of Vocdoni is the technical overview v1.

dvotenode

The dvotenode is the Vocdoni's backend. It makes use of IPFS, Ethereum, libp2p and Tendermint. Currently supports three main operation modes:

  • miner: connects only to the Tendermint blockchain (Vochain)
  • oracle: uses Tendermint and Ethereum to bridge information from both blockchains
  • gateway: uses all the Vocdoni open stack

For launching the dvotenode go >1.14 is required (dockers are also available). See the README file for more details

The basic steps are:

  1. Clone the repository git clone git@gitlab.com:vocdoni/go-dvote.git

  2. Execute the dvotenode go run cmd/dvotenode/dvotenode.go

The dvotenode will automatically connect to the development network in gateway mode and start synchronizing everything necessary. Once all init tasks are done, the dvote API will be available on ws://127.0.0.1:9090/dvote

You can use the testclient for querying the API:

echo '{method:"getGatewayInfo"}' | go run cmd/testclient/testclient.go -host=ws://127.0.0.1:9090/dvote

testsuit

Docker-compose can be used to launch a full local development environment.

Clone the repository git clone git@gitlab.com:vocdoni/go-dvote.git.

Navigate to dockerfiles/testsuite cd dockerfiles/testsuite

Build and execute the compose file: docker-compose build docker-compose up

A new, from scratch, Vochain will be initialized together with an Oracle and a Gateway node.

Once you see some blocks mined, you can run your tests:

[vochain info] height:4 mempool:0 peers:4 processTree:0 voteTree:0 blockTime:{}

There is a program ready to launch a full voting test using the local Gateway provided by the docker-compose testsuit:

go run cmd/vochaintest/vochaintest.go --oracleKey=6aae1d165dd9776c580b8fdaf8622e39c5f943c715e20690080bbfce2c760223 --electionSize=500

Once your tests are done, you can remove all data and files executing docker-compose down -v

dvote-js

Dvote-js is the Javascript framework used on the WEB client side.

There is a benchmark npm program able to simulate a complete election using dvote-js.

git clone https://gitlab.com/vocdoni/dvote-js.git && cd dvote-js
npm install && npm run build
cd benchmark
cp config.template.yaml config.yaml
## edit config.yaml
npm install && npm run dev

Example of config.yaml

readExistingAccounts: false       # if set, will use the wallets from the JSON file instead of creating them
readExistingProcess: false        # if set, will read the voteMetadata from the JSON instead of creating a new one
stopOnError: false

accountListFilePath: "./cached-accounts.json"
processInfoFilePath: "./cached-process-info.json"

mnemonic: "perfect kite link property simple nine welcome spring enforce universe barely cargo"
ethPath: "m/44'/60'/0'/0/13"
ethNetworkId: "goerli"

bootnodesUrlRw: "https://bootnodes.vocdoni.net/gateways.dev.json"     # Bootnode used by default
dvoteGatewayUri:                                   # If set, overrides bootnodesUrlRw
dvoteGatewayPublicKey:                             # If set, overrides bootnodesUrlRw

registryApiPrefix: "https://registry.dev.vocdoni.net"
censusManagerApiPrefix: "https://census-manager.dev.vocdoni.net"
entityManagerUriPrefix: "https://entities.dev.vocdoni.net"

numAccounts: 1000
maxConcurrency: 100

encryptedVote: true
votesPattern: "all-1"   #  Vote the first option on all questions
#votesPattern: "all-1"  #  Vote the second option on all questions
#votesPattern: "all-2"  #  Vote the third option on all questions
#votesPattern: "all-even"      #  Vote 0 on even voters and 1 on odd voters
#votesPattern: "incremental"   #  Vote 0 on question 0, 1 on question 1, 2 on question 2, etc
Clone this wiki locally