This is my dissertation for my MSc in Computing (Artificial Intelligence & Machine Learning) at Imperial College London (2019-20).
2cp/
: This repository contains 2CP
, the software framework which implements the Crowdsource Protocol and the Consortium Protocol.
contracts/
: The solidity source code for 2CP
smart contracts.
experiments/
: It also contains the code used to run the experiments described in the project paper, and the corresponding results.
migrations/
: Deployment scripts used by Truffle. Not currently needed as 2CP automatically deploys contracts without using Truffle.
scripts/
: Miscellaneous scripts to tidy up results files, produce plots, etc.
tests/
: Unit tests for 2CP
.
Recommended:
- Anaconda (install for user)
- Visual Studio Code
It is easiest to create and use a fresh conda environment.
conda create -n proj
activate proj
VSCode should already be set up to use this proj
conda environment.
Next, use conda to install pytorch as pip is not supported. We need exactly version 1.4.0 for compatibility with PySyft.
conda install pytorch==1.4.0 torchvision -c pytorch
Use pip to install everything else.
pip install -r requirements.txt
Required to run unit tests or experiments. This is really easy with conda. From repo root:
conda develop 2cp
VSCode should already be set up correctly; see .vscode/settings.json
and .env
. (Followed these instructions)
Requirements
Requirements
- Open the Ganache app.
- Quick start or set up a new workspace.
- (Optional, to create a more realistic blockchain) In settings, under Server, turn off automine and set mining block time to 15 seconds (or set to 3 or 4 to make unit tests run more quickly). Need to do this to test behaviour when transactions aren't mined instantaneously.
Best option if not using Windows. Requires only Docker
- Build the docker image: (in repo root)
docker build -t 2cp .
- Launch the image in interactive mode:
docker run -it 2cp
- Start the ipfs daemon in the background:
ipfs daemon &
- Start the blockchain in the background:
ganache-cli --port=7545 &
- Compile the contracts:
truffle compile
(2CP deploys them automatically when it runs) - Spin up a blockchain as above.
- Start up an IPFS node by opening the IPFS desktop app.
- Run one of these commands:
- Unit tests:
pytest -s
(the-s
flag displays print statements.) - MNIST experiments:
python experiments/mnist/mnist.py --full
(without the--full
flag, will just run a quick version for debugging purposes.) - COVID experiments:
python experiments/covid/covid.py --full
Choose which experiments to run by defining changing the experiments
dictionary in the mnist.py
or covid.py
scripts.
python scripts/make_plots.py