Skip to content

ResilientApp/ResVote

Repository files navigation

resVote

Random vote generator based on property-based testing

Python

We recommend using conda to manage python environment.

conda create -n "resdb" python=3.10.0 ipython
conda activate resdb
pip install -r requirements.txt

Get ResilientDB Dependencies

To save some time, we also provide a docker image that has all the dependencies installed.

docker pull yfhecs/rsdb
docker run -d -p 18000:18000 --name resdb yfhecs/rsdb

If you choose to use docker, you can skip the following steps. Please wait a few minutes for the docker container to start. You can check if it is ready by the follow command:

❯ curl -X POST -d '{"id":"key1","value":"value1"}' localhost:18000/v1/transactions/commit
id: key1

❯ curl 127.0.0.1:18000/v1/transactions/key1
{"id":"key1","value":"value1"}

You can also find the related dockerfile in the ./docker directory.

ResilientDB

The following commands will clone and build ResilientDB, and then starts 4 replicas and 1 client. Each replica instantiates a key-value store.

git clone https://github.com/apache/incubator-resilientdb.git resilientdb
cd resilientdb
./INSTALL.sh
./service/tools/kv/server_tools/start_kv_service.sh

Graph QL

git clone https://github.com/apache/incubator-resilientdb-graphql.git resilientdb-graphql
cd resilientdb-graphql
sh ./INSTALL.sh
pip install -r requirements.txt

Running Crow service (HTTP endpoints)

bazel build service/http_server/crow_service_main
bazel-bin/service/http_server/crow_service_main service/tools/config/interface/client.config service/http_server/server_config.config

Test if SDK and service are working

python test_driver.py 

resVote Server

source ./env.sh
python app/serve.py

resVote TUI Client

source ./env.sh
python app/tui.py

resVote React Frontend

To run

  1. start the express server with node expressMiddleware/express.js
  2. cd into resVote2.0 (cd resVote2.0) and run npm start
  • Note: Make sure you have resVault set up on chrome. Currently I have mongo synced to main-net for resDB so connect to it.

DO NOT RUN sync.js

  • I don't know whether or not this will cause duplicates in mongoDB

Notes

  • To sync your mongoDB, change the mongoURI in expressMiddleware/express.js and resVote2.0/src/mongoDB/sync.js
    • Run sync.js to populate the transactions into your DB
    • Then run express.js to field requests from resVote2.0/src/mongoDB/mongoAPI.js