forked from integritee-network/worker
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* increase sleep time for demo * connect-four demo with 2 workers start workers with python script: python local-setup/launch.py local-setup/simple-config.json start demo-script in cli/: ./demo_connect_four_two_workers.sh -p 9985 -A 2090 -B 3090 -m file Cherry-pick: 00f336e Co-authored-by: Gaudenz Kessler <[email protected]>
- Loading branch information
1 parent
9a18b38
commit 086760e
Showing
3 changed files
with
184 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
#!/bin/bash | ||
|
||
# setup: | ||
# build ajuna node with skip-ias-check | ||
# cargo build --release --features skip-ias-check | ||
# | ||
# run ajuna node | ||
# target/release/ajuna --dev --tmp --ws-port <NODEPORT> --port 30385 --rpc-port <RPCPORT> | ||
# | ||
# run worker | ||
# rm light_client_db.bin | ||
# rm -r shards | ||
# rm -r sidechain_db | ||
# export RUST_LOG=integritee_service=info,ita_stf=debug | ||
# integritee-service init_shard | ||
# integritee-service shielding-key | ||
# integritee-service signing-key | ||
# integritee-service -P <WORKERPORT> -p <NODEPORT> -r 3485 run --dev --skip-ra | ||
# | ||
# then run this script | ||
|
||
# usage: | ||
# export RUST_LOG=integritee-cli=info,ita_stf=info | ||
# demo_connect_four.sh -p <NODEPORT> -A <WORKER1PORT> -B <WORKER2PORT> -m <FILENAME> | ||
# | ||
# if -m <FILENAME> is set, the mrenclave will be read from file <FILENAME> | ||
|
||
while getopts ":m:p:A:B:" opt; do | ||
case $opt in | ||
m) | ||
READMRENCLAVE=$OPTARG | ||
;; | ||
p) | ||
NPORT=$OPTARG | ||
;; | ||
A) | ||
WORKER1PORT=$OPTARG | ||
;; | ||
B) | ||
WORKER2PORT=$OPTARG | ||
;; | ||
esac | ||
done | ||
|
||
# using default port if none given as arguments | ||
NPORT=${NPORT:-9944} | ||
WORKER1PORT=${WORKER1PORT:-2000} | ||
WORKER2PORT=${WORKER2PORT:-3000} | ||
|
||
echo "Using node-port ${NPORT}" | ||
echo "Using trusted-worker-1-port ${WORKER1PORT}" | ||
echo "Using trusted-worker-2-port ${WORKER2PORT}" | ||
|
||
BALANCE=1000 | ||
|
||
CLIENTWORKER1="./../bin/integritee-cli -p ${NPORT} -P ${WORKER1PORT}" | ||
CLIENTWORKER2="./../bin/integritee-cli -p ${NPORT} -P ${WORKER2PORT}" | ||
|
||
if [ "$READMRENCLAVE" = "file" ] | ||
then | ||
read MRENCLAVE <<< $(cat ~/mrenclave.b58) | ||
echo "Reading MRENCLAVE from file: ${MRENCLAVE}" | ||
else | ||
# this will always take the first MRENCLAVE found in the registry !! | ||
read MRENCLAVE <<< $($CLIENT list-workers | awk '/ MRENCLAVE: / { print $2; exit }') | ||
echo "Reading MRENCLAVE from worker list: ${MRENCLAVE}" | ||
fi | ||
[[ -z $MRENCLAVE ]] && { echo "MRENCLAVE is empty. cannot continue" ; exit 1; } | ||
|
||
echo "" | ||
echo "* Create account for Alice" | ||
ACCOUNTALICE=//Alice | ||
echo " Alice's account = ${ACCOUNTALICE}" | ||
echo "" | ||
|
||
echo "* Create account for Bob" | ||
ACCOUNTBOB=//Bob | ||
echo " Bob's account = ${ACCOUNTBOB}" | ||
echo "" | ||
|
||
echo "* Issue ${BALANCE} tokens to Alice's account via Worker 1" | ||
${CLIENTWORKER1} trusted set-balance ${ACCOUNTALICE} ${BALANCE} --mrenclave=${MRENCLAVE} --direct | ||
echo "" | ||
sleep 1 | ||
|
||
echo "* Issue ${BALANCE} tokens to Bob's account via Worker 2" | ||
${CLIENTWORKER2} trusted set-balance ${ACCOUNTBOB} ${BALANCE} --mrenclave=${MRENCLAVE} --direct | ||
echo "" | ||
sleep 1 | ||
|
||
echo "Queue Game for Alice (Player 1)" | ||
${CLIENTWORKER1} queue-game ${ACCOUNTALICE} | ||
echo "" | ||
sleep 1 | ||
|
||
echo "Queue Game for Bob (Player 2)" | ||
${CLIENTWORKER2} queue-game ${ACCOUNTBOB} | ||
echo "" | ||
sleep 1 | ||
|
||
echo "waiting" | ||
sleep 45 | ||
|
||
echo "Turn for Alice (Player 1 via Worker 1)" | ||
${CLIENTWORKER1} trusted play-turn ${ACCOUNTALICE} 3 --direct --mrenclave=${MRENCLAVE} | ||
echo "" | ||
sleep 1 | ||
|
||
echo "Turn for Bob (Player 2 via Worker 2)" | ||
${CLIENTWORKER2} trusted play-turn ${ACCOUNTBOB} 4 --direct --mrenclave=${MRENCLAVE} | ||
echo "" | ||
sleep 1 | ||
|
||
echo "Turn for Alice (Player 1 via Worker 1)" | ||
${CLIENTWORKER1} trusted play-turn ${ACCOUNTALICE} 2 --direct --mrenclave=${MRENCLAVE} | ||
echo "" | ||
sleep 1 | ||
|
||
echo "Turn for Bob (Player 2 via Worker 2)" | ||
${CLIENTWORKER2} trusted play-turn ${ACCOUNTBOB} 3 --direct --mrenclave=${MRENCLAVE} | ||
echo "" | ||
sleep 1 | ||
|
||
echo "waiting" | ||
sleep 5 | ||
|
||
echo "Board after 2 turns (queried by Bob via Worker 2)" | ||
${CLIENTWORKER2} trusted get-board ${ACCOUNTBOB} --direct --mrenclave=${MRENCLAVE} | ||
echo "" | ||
sleep 1 | ||
|
||
|
||
echo "Turn for Alice (Player 1 via Worker 1)" | ||
${CLIENTWORKER1} trusted play-turn ${ACCOUNTALICE} 2 --direct --mrenclave=${MRENCLAVE} | ||
echo "" | ||
sleep 1 | ||
|
||
echo "Turn for Bob (Player 2 via Worker 2)" | ||
${CLIENTWORKER2} trusted play-turn ${ACCOUNTBOB} 5 --direct --mrenclave=${MRENCLAVE} | ||
echo "" | ||
sleep 1 | ||
|
||
echo "Turn for Alice (Player 1 via Worker 1)" | ||
${CLIENTWORKER1} trusted play-turn ${ACCOUNTALICE} 2 --direct --mrenclave=${MRENCLAVE} | ||
echo "" | ||
sleep 1 | ||
|
||
echo "Turn for Bob (Player 2 via Worker 2)" | ||
${CLIENTWORKER2} trusted play-turn ${ACCOUNTBOB} 1 --direct --mrenclave=${MRENCLAVE} | ||
echo "" | ||
sleep 1 | ||
|
||
echo "waiting" | ||
sleep 5 | ||
|
||
echo "Board after 4 turns (queried by Alice via Worker 1)" | ||
${CLIENTWORKER1} trusted get-board ${ACCOUNTALICE} --direct --mrenclave=${MRENCLAVE} | ||
echo "" | ||
sleep 1 | ||
|
||
echo "Turn for Alice (Player 1 via Worker 1)" | ||
${CLIENTWORKER1} trusted play-turn ${ACCOUNTALICE} 2 --direct --mrenclave=${MRENCLAVE} | ||
echo "" | ||
sleep 1 | ||
|
||
echo "waiting" | ||
sleep 5 | ||
|
||
echo "Board after end of game (queried by Alice via Worker 1)" | ||
${CLIENTWORKER2} trusted get-board ${ACCOUNTBOB} --direct --mrenclave=${MRENCLAVE} | ||
echo "" | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters