Skip to content

Commit 16c73f2

Browse files
committed
docs: update and enhance the iApp deployment and execution sections in the advanced guide
1 parent c7f1762 commit 16c73f2

File tree

2 files changed

+149
-286
lines changed

2 files changed

+149
-286
lines changed

src/guides/build-iapp/advanced/build-your-first-sgx-iapp.md

Lines changed: 149 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ chmod +x sconify.sh
4949

5050
### Write the iApp logic
5151

52-
The following examples only feature Javascript and Python use cases for
53-
simplicity concerns but remember that you can run on iExec anything which is
54-
Dockerizable.
52+
Develop your code logic like the content below.The following examples only
53+
feature Javascript and Python use cases for simplicity concerns but remember
54+
that you can run on iExec anything which is Dockerizable.
5555

5656
**Copy the following content** in `src/` .
5757

@@ -334,13 +334,7 @@ docker push <docker-hub-user>/tee-scone-hello-world:1.0.0
334334

335335
Congratulations, you just built your Scone TEE application.
336336

337-
## Test your iApp on iExec
338-
339-
At this stage, your application is ready to be tested on iExec. The process is
340-
similar to testing any type of application on the platform, with these minor
341-
exceptions:
342-
343-
### Deploy the TEE iApp on iExec
337+
## Deploy the iApp
344338

345339
TEE applications require some additional information to be filled in during
346340
deployment.
@@ -375,10 +369,6 @@ Edit `iexec.json` and fill in the standard keys and the `mrenclave` object:
375369

376370
::: info
377371

378-
See
379-
[Create your identity on the blockchain](./quick-start.md#create-your-identity-on-the-blockchain)
380-
to retrieve `<your-wallet-address>` value.
381-
382372
Run your TEE image with `SCONE_HASH=1` to get the enclave fingerprint
383373
(mrenclave):
384374

@@ -394,9 +384,52 @@ Deploy the iApp with the standard command:
394384
iexec app deploy --chain {{chainName}}
395385
```
396386

397-
### Run the TEE iApp
387+
You can check your deployed apps with their index, let's check your last
388+
deployed app:
389+
390+
```bash twoslash
391+
iexec app show --chain arbitrum-mainnet
392+
```
393+
394+
## Run the iApp
395+
396+
iExec allows you to run applications on a decentralized infrastructure with
397+
payment in **RLC** tokens.
398+
399+
::: info
400+
401+
To run an application you must have enough RLC staked on your iExec account to
402+
pay for the computing resources.
403+
404+
Your iExec account is managed by smart contracts \(and not owned by iExec\).
405+
406+
When you request an execution the price for the task is locked from your
407+
account's stake then transferred to accounts of the workers contributing to the
408+
task \(read more about [Proof of Contribution](/protocol/proof-of-contribution)
409+
protocol\).
410+
411+
At any time you can:
412+
413+
- view your balance
414+
415+
```bash twoslash
416+
iexec account show --chain arbitrum-mainnet
417+
```
418+
419+
- deposit RLC from your wallet to your iExec Account
420+
421+
```bash twoslash
422+
iexec account deposit --chain arbitrum-mainnet <amount>
423+
```
424+
425+
- withdraw RLC from your iExec account to your wallet \(only stake can be
426+
withdrawn\)
398427

399-
Specify the tag `--tag tee,scone` in `iexec app run` command to run a tee iApp.
428+
```bash twoslash
429+
iexec account withdraw --chain arbitrum-mainnet <amount>
430+
```
431+
432+
:::
400433

401434
One last thing, in order to run a **TEE** iApp you will also need to select a
402435
workerpool, use the iexec workerpool `{{workerpoolAddress}}`.
@@ -407,13 +440,111 @@ You are now ready to run the iApp
407440
iexec app run --chain {{chainName}} --tag tee,scone --workerpool {{workerpoolAddress}} --watch
408441
```
409442

443+
The execution of tasks on the iExec network is asynchronous by design.
444+
445+
```mermaid
446+
graph TD
447+
Requester["Requester (or anyone)"] --> |"1 . Match compatible orders \n(request, application, dataset & workerpool orders) \n & Wait result" | Blockchain
448+
Blockchain --> |2 . Notify new deal with tasks to compute| Scheduler
449+
Worker --> |3 . Request new task to compute| Scheduler
450+
Worker --> |4 . Run application| Application[Application image]
451+
Worker --> |5.a. Push result| ResultStorage["Result Storage"]
452+
Worker --> |5.b. Commit result proof| Blockchain
453+
Workerpool --> |6 . Publish result link or callback| Blockchain
454+
455+
subgraph Workerpool
456+
Scheduler
457+
Worker
458+
Application
459+
end
460+
```
461+
462+
Guaranties about completion times (fast/slow) are available in the
463+
[category section](/protocol/pay-per-task):
464+
465+
- maximum deal/task time
466+
- maximum computing time
467+
468+
Once the task is completed copy the taskid from `iexec app run` output \(taskid
469+
is a 32Bytes hexadecimal string\).
470+
471+
Download the result of your task
472+
473+
```bash twoslash
474+
iexec task show --chain arbitrum-mainnet <taskid> --download my-result
475+
```
476+
477+
You can get your taskid with the command:
478+
479+
```bash twoslash
480+
iexec deal show --chain arbitrum-mainnet <dealid>
481+
```
482+
410483
::: info
411484

412-
Remember, you can access task and iApp logs by following the instructions on
413-
page [Debug your tasks](/guides/build-iapp/debugging).
485+
A task result is a zip file containing the output files of the application.
414486

415487
:::
416488

489+
[iexechub/python-hello-world](https://hub.docker.com/repository/docker/iexechub/python-hello-world)
490+
produce an text file in `result.txt`.
491+
492+
Let's discover the result of the computation.
493+
494+
```bash
495+
unzip my-result.zip -d my-result
496+
cat my-result/result.txt
497+
```
498+
499+
Congratulations! You successfully executed your application on iExec!
500+
501+
## Publish your app on the iExec Marketplace
502+
503+
Your application is deployed on iExec and you completed an execution on iExec.
504+
For now, only you can request an execution of your application. The next step is
505+
to publish it on the iExec Marketplace, making it available for anyone to use.
506+
507+
As the owner of this application, you can define the conditions under which it
508+
can be used
509+
510+
::: info
511+
512+
iExec uses orders signed by the resource owner's wallet to ensure resources
513+
governance.
514+
515+
The conditions to use an app are defined in the **apporder**.
516+
517+
:::
518+
519+
Publish a new apporder for your application.
520+
521+
```bash twoslash
522+
iexec app publish --chain arbitrum-mainnet
523+
```
524+
525+
::: info
526+
527+
`iexec app publish` command allows to define custom access rules to the app
528+
\(run `iexec app publish --help` to discover all the possibilities\).
529+
530+
You will learn more about orders management later, keep the apporder default
531+
values for now.
532+
533+
:::
534+
535+
Your application is now available for everyone on iExec marketplace on the
536+
conditions defined in apporder.
537+
538+
You can check the published apporders for your app
539+
540+
```bash twoslash
541+
iexec orderbook app --chain arbitrum-mainnet <your app address>
542+
```
543+
544+
Congratulation you just created a decentralized application! Anyone can now
545+
trigger an execution of your application on the iExec decentralized
546+
infrastructure.
547+
417548
## Next step?
418549

419550
In this tutorial, you learned how to leverage your application with the power of

0 commit comments

Comments
 (0)