-
Notifications
You must be signed in to change notification settings - Fork 1
Commands CheatSheet
sudo npm i -g iexeciexec wallet create mkdir ~/iexec-projects
cd ~/iexec-projects
git clone https://github.com/iExecBlockchainComputing/private-code-valorisation_tutorial.gitcd private-code-valorisation_tutorial/
iexec init --skip-walletiexec storage initiexec wallet show --chain goerliiexec wallet getRLCiexec account deposit 200iexec account show cd ~iexec-projects/private-code-valorisation_tutorial/app/~/iexec-projects/private-code-valorisation_tutorial/app/src/app.py
import os
import sys
import json
iexec_out = os.environ['IEXEC_OUT']
iexec_in = os.environ['IEXEC_IN']
sys.path.insert(0, iexec_in + '/private-code-dataset')
import private_code
private_code.main()
print("POST Private code operations")
# Declare everything is computed
with open(iexec_out + '/determinism.txt', 'w+') as fout:
fout.write("It is deterministic.")
with open(iexec_out + '/computed.json', 'w+') as f:
json.dump({ "deterministic-output-path" : iexec_out + '/determinism.txt' }, f)
print("END")
print("----------------------------")~/iexec-projects/private-code-valorisation_tutorial/app/Dockerfile
FROM sconecuratedimages/public-apps:python-3.7.3-alpine3.10-scone3.0
### install python3 dependencies you need
RUN SCONE_MODE=sim pip3 install wget
COPY ./src /app
### protect file system with Scone
COPY ./protect-fs.sh ./Dockerfile /build/
RUN sh /build/protect-fs.sh /app
ENTRYPOINT ["python", "-B", "/app/app.py"]docker login./build docker image push <username>/python-launcher-app:0.0.1iexec app init~/iexec-projects/iexec.json
{
...
"app": {
"owner": "<0x-your-wallet-address>",
"name": "My python launcher App",
"type": "DOCKER",
"multiaddr": "registry.hub.docker.com/<username>/python-launcher-app:0.0.1",
"checksum": "<0xf51494d7a...>",
"mrenclave": "<5abc...|d72c...|16e7…|python -B /app/app.py>"
}
...
}iexec app deployiexec order init --app~/iexec-projects/iexec.json
{
...
"apporder": {
"app": "0x...",
"appprice": "0",
"volume": "1000000",
"tag": ["tee"],
"datasetrestrict": "0x0000000000000000000000000000000000000000",
"workerpoolrestrict": "0x0000000000000000000000000000000000000000",
"requesterrestrict": "0x0000000000000000000000000000000000000000"
...
}iexec order sign --app && iexec order publish --appiexec dataset init --encrypteddatasets/
├── encrypted
└── original
└── private-code-dataset
└── private_code.py~/iexec-projects/private-code-valorisation_tutorial/datasets/original/private-code-dataset/private_code.py
import os
import sys
import wget
iexec_out = os.environ['IEXEC_OUT']
iexec_in = os.environ['IEXEC_IN']
def read_file(filepath):
with open(filepath, "r") as f:
f.seek(0)
return f.read()
def write_file(path, data):
with open(path, "w+") as f:
f.write(data)
def bubbleSort(arr, asc):
n = len(arr)
# Traverse through all array elements
for i in range(n):
# Last i elements are already in place
for j in range(0, n-i-1):
# traverse the array from 0 to n-i-1
# Swap if the element found is greater
# than the next element
if asc:
if arr[j] > arr[j+1] :
arr[j], arr[j+1] = arr[j+1], arr[j]
else:
if arr[j] < arr[j+1] :
arr[j], arr[j+1] = arr[j+1], arr[j]
def main():
print("------------------------")
print("STARTING private code execution")
# treat the args
# /app/app.py https://inputfile_download_link.com <asc/desc>
args = sys.argv
if len(args) <= 1:
print("Error: Missing input arguments.\nUsage:")
print(" iexec app run ... --args \"https://inputfile_download_link.com <asc/desc> \"")
sys.exit(1)
url = args[1]
print(" - Using input file from URL: "+ url)
direction_asc = True
if len(args) > 2 and args[2] == "desc":
direction_asc = False
print(" - Descending sort")
else:
print(" - Ascending sort")
# Download the input file
print("DOWNLOADING input file")
wget.download(url, iexec_in + '/inputs.csv')
# Check the input file is here
print("CHECKING Input file")
if os.path.exists(iexec_in + '/inputs.csv'):
data = read_file(iexec_in + '/inputs.csv').split(",")
print("Input file content: ", read_file(iexec_in + '/inputs.csv'))
else:
print("Cannot find input file, check that the dowload URL is correct")
sys.exit(1)
# Work on data
# print(data, "data------")
print("SORTING")
sort = [float(i) for i in data]
bubbleSort(sort, direction_asc)
#write result
print("WRITING result")
result = str(sort)
write_file(iexec_out + '/my-result.txt', result)
print("END of the private code execution")iexec dataset encrypt --algorithm scone~/iexec-projects/iexec.json
{
...
"dataset": {
"owner": "0x...",
"name": "My private code dataset",
"multiaddr": "https://github.com/iExecBlockchainComputing/private-code-valorisation_tutorial/raw/master/datasets/encrypted/dataset_privatecodedataset.zip",
"checksum": "0x21415..."
}
}sha256sum datasets/encrypted/dataset_privatecodedataset.zipiexec dataset deployiexec dataset push-secret <0x-your-dataset-address>iexec order init --dataset~/iexec-projects/iexec.json
{
...
"datasetorder": {
"dataset": "0x...",
"datasetprice": "20",
"volume": "100",
"tag": []",
"apprestrict": "0x...",
"workerpoolrestrict": "0x0000000000000000000000000000000000000000",
"requesterrestrict": "0x0000000000000000000000000000000000000000"
}
...
}A running already deployed app if needed: 0xc348738d4Aa062D06bD4A047135bd5aA861646Ad.
iexec order sign --dataset && iexec order publish --datasetinput_data.csv
1,9,0,4,3,7,2,5,8,6,12,123,14,90,18
iexec wallet createiexec result generate-keysiexec result push-secretiexec app run <0x-your-app-address> \
--dataset <0x-your-dataset-address> \
--tag tee \
--args "<input-file-URL> <asc/desc>" \
--encrypt-result \
--watchIf needed:
- A deployed app
0xc348738d4Aa062D06bD4A047135bd5aA861646Ad; - A deployed dataset
0x26e485f3F966a75a96Caadf551D5C327AB41Df46;
iexec task show <0x-your-task-id> --downloadiexec result decrypt <0x-your-task-id.zip>unzip results.zip -d my-decrypted-resultcat my-decrypted-result/my-result.txtNote:
-
This guide is based on the technical documentation available here:
docs.iex.ec Please refer to this link if you want more informations.
-
You can also check out the SDK documentation here
-
You can browse the blockchain for any information you pushed at any point using the iExec explorer website (explorer.iex.ec), just set it on the goerli testnet and enter the address you want to check (wallet, application, dataset…).