woshidama323 / MODICUM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MODICUM demo

Tested on Ubuntu 22.04 & 23.04

Have docker, ngrok and node.js >= v16 installed:

snap install ngrok
sudo apt install docker.io curl python3-pip python3-virtualenv python3-dev libssl-dev
cd ~
curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh
sudo bash /tmp/nodesource_setup.sh
sudo apt install nodejs

setup block explorer

Login to https://app.tryethernal.com/settings?tab=workspace go to settings and click "RESET WORKSPACE" at the bottom.

Open a new terminal window:

ngrok http 10000

Copy the https url from ngrok and paste it as the RPC Server field in ethereal (in settings) then click "Update".

Then in another terminal we run the hardhat node:

git clone git@github.com:bacalhau-project/MODICUM.git
cd MODICUM
cd src/js
npm install --force
export ETHERNAL_EMAIL=kaiyadavenport@gmail.com
export ETHERNAL_PASSWORD=XXX
npx hardhat node --port 10000

Visit https://app.tryethernal.com/blocks in the browser.

IMPORTANT: each time you restart the demo - click "RESET WORKSPACE" at the bottom of the settings page on ethereal.

various system tasks

Then create a virtualenv:

cd src/python/
python3 -m virtualenv venv
. venv/bin/activate
pip3 install -e .

fill in .env file

We'll copy the .env file sample and then fill in the details for your one. Note the .env file is in .gitignore because it will contain private keys...

cp src/python/.env.sample src/python/.env

Then we create a new ssh keypair:

ssh-keygen -f ~/.ssh/modicum-demo

Hit enter three times to use the defaults

Now we adjust the values on the src/python/.env file paying note to the following:

  • DIR = /home/YOURUSERNAME (pointing to the parent directory of where you checked out MODICUM)
  • pubkey = the public key we just generated
  • sshkey = the path to the private key we just generated

If you are deploying to a real blockchain and have your private key, also fill in the PRIVATE_KEY_0 (and optionally, RPC_TOKEN to send a Bearer token to the RPC endpoint if your provider requires it)

influx DB

Then we setup influxDB - in another pane (install docker and sudo adduser $USER docker and log out and log in again):

docker run -d \
  --name influx \
  -p 8086:8086 \
  influxdb:1.8.10

Now we need to setup the database:

docker exec -ti influx influx
create database collectd;
show databases;
exit

env and virtualenv files

From now on, activate the virtual env and source the environment variables in any new panes where you run a python process, like this:

cd src/python
. ./venv/bin/activate
source .env

compile contracts

Then we source the file and compile the contracts:

cd src/python/
source .env
echo $CONTRACTSRC
docker run -it --rm\
		--name solcTest \
		--mount type=bind,source="${CONTRACTSRC}",target=/solidity/input \
		--mount type=bind,source="${CONTRACTSRC}/output",target=/solidity/output \
		ethereum/solc:0.4.25 \
		--overwrite --bin --bin-runtime --ast --abi --asm -o /solidity/output /solidity/input/Modicum.sol

Ignore the warnings.

run services

Now we start the various processes (each in it's own pane):

  • IMPORTANT: don't forget to activate the virtualenv in each pane! . venv/bin/activate inside src/python
  • IMPORTANT: don't forget to source .env in each pane!
  • IMPORTANT: run these in this exact order!
modicum runAsCM
modicum runAsSolver
sudo -E $(which modicum) runAsDir

(sudo because it will do a bunch of stuff like creating users :-O)

modicum runAsMediator

NOTE: replace this path with the absolute path on your system

modicum startRP --path $(realpath $PWD/../..)/0_experiments/demo/ --index 1

edit 0_experiments/demo/player0 to update the paths

modicum startJC --playerpath $(realpath $PWD/../..)/0_experiments/demo/ --index 0

Keep an eye out on the startRP pane - the bacalhau job ID will get printed there with a link to it on the dashboard.

About

License:GNU General Public License v3.0


Languages

Language:C 22.3%Language:HTML 21.7%Language:Roff 17.9%Language:C++ 17.5%Language:Shell 9.1%Language:Makefile 4.5%Language:Python 3.8%Language:Assembly 1.4%Language:TeX 1.0%Language:Solidity 0.5%Language:CSS 0.2%Language:M4 0.1%Language:ANTLR 0.1%Language:Perl 0.0%Language:SWIG 0.0%Language:JavaScript 0.0%Language:Dockerfile 0.0%