Skip to content

Instantly share code, notes, and snippets.

@cowboy-bebug
Last active August 2, 2022 01:40
Show Gist options
  • Save cowboy-bebug/1ae6e58ed1c914c1f12bd723f3a8736a to your computer and use it in GitHub Desktop.
Save cowboy-bebug/1ae6e58ed1c914c1f12bd723f3a8736a to your computer and use it in GitHub Desktop.
Build and run Ajuna node and worker locally

Build and Run Ajuna and worker

Building

Clone the projects and mount them in a container:

git clone -b polkadot-v0.9.20-dev [email protected]:ajuna-network/Ajuna.git Ajuna
git clone [email protected]:ajuna-network/worker.git worker
cd worker && git checkout 0c40097 && cd ..

docker run -it \
  -v $(pwd)/worker:/root/work \
  -v $(pwd)/Ajuna:/root/Ajuna \
  integritee/integritee-dev:0.1.9

Build inside the container and exit:

# build enclave
cd /root/work && CARGO_NET_GIT_FETCH_WITH_CLI=true SGX_MODE=SW make

# build ajuna node
cd /root/Ajuna && cargo build-ajuna-solo --features skip-ias-check

# when finished
exit

Running

Run compose with optinal logging (open http://localhost in your browser for app):

docker-compose up -d
docker logs ajuna-network-worker-1 -f

Bash into the worker container to start sending trusted calls:

docker exec -it ajuna-network-worker-1 /bin/bash

From the worker container:

# run the whole demo script
cd /root/worker/cli && ./demo_connect_four.sh -u ws://ajuna-node

# or test calls individually
export CLIENT="/root/worker/bin/integritee-cli -u ws://ajuna-node"
export MRENCLAVE=$($CLIENT list-workers | awk '/  MRENCLAVE: / { print $2; exit }')
${CLIENT} trusted --mrenclave ${MRENCLAVE} --direct set-balance //Alice 1000
${CLIENT} trusted --mrenclave ${MRENCLAVE} --direct set-balance //Bob   1000
${CLIENT} queue-game //Alice
${CLIENT} queue-game //Bob
${CLIENT} trusted --mrenclave ${MRENCLAVE} --direct drop-bomb //Alice 1 1
${CLIENT} trusted --mrenclave ${MRENCLAVE} --direct get-board //Alice
version: "3"
services:
ajuna-node:
image: integritee/integritee-dev:0.1.9
volumes:
- ./Ajuna:/root/Ajuna
command: /root/Ajuna/target/release/ajuna-solo --dev --tmp --ws-external
ports:
- 9933:9933
- 9944:9944
worker:
image: integritee/integritee-dev:0.1.9
volumes:
- ./worker:/root/worker
command:
- /bin/bash
- -c
- |
cd /root/worker/bin
rm -rf shards sidechain_db light_client_db.bin
./integritee-service init-shard
./integritee-service shielding-key
./integritee-service signing-key
RUST_LOG=error,itc_parentchain_block_importer=debug ./integritee-service --ws-external -u ws://ajuna-node run --dev --skip-ra
ports:
- 2000:2000 # trusted worker port
- 3443:3443 # mutual remote attestation port
depends_on:
- ajuna-node
polkadot-ui:
image: jacogr/polkadot-js-apps:latest
links:
- ajuna-node
environment:
- WS_URL=ws://localhost:9944
ports:
- 80:80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment