0xDeCA10B/demo
Justin D. Harris 605048ad3b
demo/perceptron: Support initializing more weights. (#4)
* demo/perceptron: Support initializing more weights.
* demo/deposit cost: Get slightly most accurate deposit cost.
2019-05-27 17:50:20 -04:00
..
assets
client demo/perceptron: Support initializing more weights. (#4) 2019-05-27 17:50:20 -04:00
.dockerignore
.gitignore
.soliumignore
.soliumrc.json
Dockerfile
README.md
package.json
server.js
setup.sh
yarn.lock

README.md

Decentralized & Collaborative AI on Blockchain Demo

Build Status

A dashboard and examples for deploying updatable AI models to Ethereum.

This folder also contains Solidity examples for models, data handlers, and incentive mechanisms for deploying models that are free to use for inference as initially proposed in the paper Decentralized & Collaborative AI on Blockchain Platforms, dark theme version here.

This project is made from a React project with Truffle added. This Truffle example was used to help add Truffle.

This work in its current form is just meant as an example and proof of concept. It is not ready to be deployed for production yet.

Setup

The following steps are made for Linux and require npm. They do work in WSL.

Run

./setup.sh

Docker Setup

You can use Docker by running:

docker build -t decai .
docker run --rm -it -p 7545:7545 -v ${PWD}:/root/workspace/demo --name decai decai bash
# You may have to run `./setup.sh` in the container to ensure that everything is set up properly.

Troubleshooting Setup

If you have problems running the setup steps related to node-gyp, then you might need to set Python 2.7 to be your default. Recommendation: Set up a Python 2.7 Conda environment and activate it.

Update

To update dependencies after already setting up:

yarn global upgrade ethlint ganache-cli truffle yarn && yarn upgrade && (cd client && yarn upgrade)

Linting

Solidity Files

We use Ethlint for linting. To check the contract code run:

yarn lint

Proper linting will be enforced when making a pull request.

Deploy

Blockchain

Start the blockchain (Ganache) in one termanial. Run:

yarn blockchain

Do once:

  • Add http://localhost:7545 to MetaMask.
  • Copy the first private key output.
  • Use that private key to create a new account in MetaMask.

Server

Start the server in one terminal. Run:

yarn server

Client

Then in another terminal. Run:

yarn client

Troubleshooting Deployment

Blockchain Issues

Run yarn clean to delete your local blockchain and cached contracts. This will delete any transactions done but should make everything work again.

Errors about a contract not found at a certain address

If you get errors about calling a contract then it's probably because you restarted your blockchain (Ganache) and the contract doesn't exist anymore on the blockchain. This would happen if you restarted your computer. You have to delete the generated .json files that keep track of contract addresses:

rm -f client/{build,src}/contracts/*.json

Then you should be able to deploy normally.

You can also try to rm -rf blockchain_db to delete your blockchain and restart from scratch.

MetaMask Issues

Issues about nonce

If MetaMask gives issues about the nonce not being right for a transaction then it's probably because you restarted your blockchain but MetaMask caches some basic things on the URL and the network ID.

You can first try to reset your account in the MetaMask settings. This will clear your transaction history.

You shouldn't need to if you've been consistenly using a blockchain for just this project but you can also try changing the network ID for Ganache. This can be done in the Ganache UI or CLI (--networkId).

MetaMask Loading Issues

If MetaMask is spinning and non-responsive:

  1. Disable the extension here: chrome://extensions
  2. Re-enable the extension.
  3. Open the extension.
  4. Change the network to use. E.g. Select Main Ethereum Network.
  5. Log in to MetaMask.
  6. Change the network back to the custom one.
  7. Reject any queued transactions.

If you get the spinning issue again, then also try following the steps above with resetting your account as well as restarting the blockchain by:

  1. Stop the yarn blockchain process.
  2. Run yarn clean.
  3. Run yarn blockchain.

Testing

Run yarn test. The blockchain will be started and stopped so it's best not to have a blockchain running at the same address and port (e.g. one running through yarn blockchain).