Skip to content

Commit a3eb464

Browse files
authored
Merge branch 'main' into feature/add-bridge-page
2 parents bd67205 + 8892b56 commit a3eb464

26 files changed

+2139
-149
lines changed

.vitepress/sidebar.ts

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -352,15 +352,14 @@ export function getSidebar() {
352352
{ text: '❓ What Is an iApp?', link: '/build-iapp/what-is-iapp' },
353353
{
354354
text: '📖 Guides',
355-
link: '/build-iapp/guides',
356355
items: [
357356
{
358-
text: 'Manage Your iApps',
359-
link: '/build-iapp/guides/manage-iapps',
357+
text: 'Build and Deploy your iApps',
358+
link: '/build-iapp/guides/build-&-deploy-iapp',
360359
},
361360
{
362-
text: 'Orders (how they work, how to manage them)',
363-
link: '/build-iapp/guides/orders',
361+
text: 'Manage your iApps',
362+
link: '/build-iapp/guides/manage-iapp',
364363
},
365364
{
366365
text: 'Inputs and Outputs (types, differences, formats)',
@@ -378,20 +377,11 @@ export function getSidebar() {
378377
text: 'How to Get and Decrypt Results',
379378
link: '/build-iapp/guides/how-to-get-and-decrypt-results',
380379
},
381-
{
382-
text: 'AI Frameworks',
383-
link: '/build-iapp/guides/ai-frameworks',
384-
},
385-
{
386-
text: 'Other Emerging Trends',
387-
link: '/build-iapp/guides/other-emerging-trends',
388-
},
389380
],
390381
},
391382
{
392383
text: '🤖 iApp Generator',
393384
link: '/build-iapp/iapp-generator',
394-
collapsed: true,
395385
items: [
396386
{
397387
text: 'Getting Started',
@@ -401,20 +391,8 @@ export function getSidebar() {
401391
text: 'Building Your iApp',
402392
link: '/build-iapp/iapp-generator/building-your-iexec-app',
403393
},
404-
{
405-
text: 'References',
406-
link: '/build-iapp/iapp-generator/references',
407-
},
408-
{
409-
text: 'Advanced Creation',
410-
link: '/build-iapp/iapp-generator/advanced-creation',
411-
},
412394
],
413395
},
414-
{
415-
text: '🔧 Protocol-Level Guides',
416-
link: '/build-iapp/iapp-generator/protocol-level-guides',
417-
},
418396
],
419397
},
420398
],

src/build-iapp/guides/ai-frameworks.md

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
title: Build and Deploy an iApp?
3+
description:
4+
How to build an confidential iexec application and deploy it on iexec protocol
5+
---
6+
7+
## iApp Generator: Your Development Tool
8+
9+
Bootstrap TEE-compatible applications in minutes without any hardcoding skills,
10+
iApp Generator handles all the low-level complexity for you.
11+
12+
- **Access to TEEs easily** - No need to dive into low-level requirements, build
13+
iApps that connect to TEEs in minutes.
14+
- **Check and deploy iApps quickly** - iApp Generator checks that your iApp
15+
complies with the iExec Framework and streamlines its deployment.
16+
- **Select your project mode & language** - Get started with either a basic or
17+
advanced setup, depending on your experience with the iExec framework. You can
18+
use Python or JavaScript—whichever you prefer!
19+
20+
```bash
21+
# Create your iApp (Python or Node.js supported)
22+
iapp init my-privacy-app
23+
cd my-privacy-app
24+
25+
# Develop and test locally (simulates TEE environment)
26+
iapp test
27+
# Deploy to the network
28+
iapp deploy
29+
```
30+
31+
<div class="bg-gradient-to-r from-blue-400/10 to-blue-400/5 rounded-[6px] p-4 border-l-4 border-blue-600 mb-6">
32+
<p class="m-0! text-sm"><strong>Note:</strong> iApp Generator currently supports Python and Node.js, but iApps can be built in any language that runs in Docker.</p>
33+
</div>
34+
35+
## Real Examples
36+
37+
Here are some real-world examples of iApps to help you understand how they work
38+
in practice.
39+
40+
**Email Notification iApp**
41+
42+
This iApp lets you send updates to your contacts without ever seeing their email
43+
addresses, privacy is preserved by design.
44+
45+
::: code-group
46+
47+
```python [Python]
48+
# User runs: "Send updates to my contacts about my project"
49+
contacts = load_protecteddata() # User's protected contact list
50+
for contact in contacts:
51+
send_email(contact, project_update_message)
52+
# → Emails sent directly, you never see the addresses
53+
```
54+
55+
```js [Node.js]
56+
/* User runs: "Send updates to my contacts about my project" */
57+
const contacts = loadProtectedData(); // User's protected contact list
58+
contacts.forEach((contact) => {
59+
sendEmail(contact, projectUpdateMessage);
60+
});
61+
// → Emails sent directly, you never see the addresses
62+
```
63+
64+
:::
65+
66+
**Oracle Update iApp**
67+
68+
This iApp securely updates a price oracle using private trading data, ensuring
69+
sensitive information stays confidential.
70+
71+
::: code-group
72+
73+
```python [Python]
74+
# User runs: "Update price oracle with my private trading data"
75+
trading_data = load_protecteddata() # User's protected trading history
76+
average_price = calculate_weighted_average(trading_data)
77+
update_oracle_contract(average_price)
78+
# → Oracle updated with real data, trading history stays private
79+
```
80+
81+
```js [Node.js]
82+
/* User runs: "Update price oracle with my private trading data" */
83+
const tradingData = loadProtectedData(); // User's protected trading history
84+
const averagePrice = calculateWeightedAverage(tradingData);
85+
updateOracleContract(averagePrice);
86+
// → Oracle updated with real data, trading history stays private
87+
```
88+
89+
:::
90+
91+
**Automated Transactions iApp**
92+
93+
This iApp automates monthly payments using protected payment details, so
94+
financial information remains private.
95+
96+
::: code-group
97+
98+
```python [Python]
99+
# User runs: "Automate payments every month"
100+
payment_info = load_protecteddata() # User's payment details
101+
for month in range(12):
102+
process_payment(payment_info)
103+
# → Payments processed, payment details stay private
104+
```
105+
106+
```js [Node.js]
107+
/* User runs: "Automate payments every month" */
108+
const paymentInfo = loadProtectedData(); // User's payment details
109+
for (let month = 0; month < 12; month++) {
110+
processPayment(paymentInfo);
111+
}
112+
// → Payments processed, payment details stay private
113+
```
114+
115+
:::
Lines changed: 169 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,175 @@
11
---
22
title: Debugging Your iApp
3-
description: Debugging Your iApp
3+
description:
4+
Troubleshoot and optimize your iApp execution in the TEE environment
45
---
56

6-
# Debugging Your iApp
7+
# 🐛 Debugging Your iApp
78

8-
This page is under development.
9+
**When your iApp doesn't work as expected, debugging in the TEE environment
10+
requires specific techniques.** This guide helps you identify issues and
11+
optimize your iApp's performance.
912

10-
<!-- TODO: Add the debugging guide -->
13+
## Task Execution Lifecycle
14+
15+
Understanding how your task progresses through the iExec network:
16+
17+
### Key Stages
18+
19+
1. **Deal Creation** - Orders matched, funds locked
20+
2. **Task Initialization** - Workers selected for execution
21+
3. **iApp Execution** - Your code runs inside TEE
22+
4. **Result Processing** - Results encrypted and uploaded
23+
5. **Task Completion** - Results available for download
24+
25+
**Most failures happen during stages 2-4**
26+
27+
## Monitoring Your Tasks
28+
29+
### iExec Explorer
30+
31+
Track your tasks at [explorer.iex.ec](https://explorer.iex.ec):
32+
33+
- Search by `taskId` or deal ID
34+
- Check status: `PENDING``ACTIVE``COMPLETED/FAILED`
35+
- View error messages if execution fails
36+
37+
### Status in Code
38+
39+
```ts twoslash
40+
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
41+
42+
const web3Provider = getWeb3Provider('PRIVATE_KEY');
43+
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
44+
// ---cut---
45+
const response = await dataProtectorCore.processProtectedData({
46+
protectedData: '0x123abc...',
47+
app: '0x456def...',
48+
onStatusUpdate: ({ title, isDone }) => {
49+
console.log(`Status: ${title} - Done: ${isDone}`);
50+
},
51+
});
52+
```
53+
54+
## Debug Commands
55+
56+
### Local Testing
57+
58+
```bash
59+
# Test your iApp locally
60+
iapp test --args "model=bert threshold=0.8"
61+
iapp test --secrets "key1=value1,key2=value2"
62+
63+
# Mock protected data for testing
64+
iapp mock protectedData
65+
iapp test --protectedData "mock_name"
66+
```
67+
68+
### Remote Debugging
69+
70+
```bash
71+
# Deploy and run
72+
iapp deploy
73+
iapp run <iapp-address>
74+
75+
# Debug failed executions
76+
iapp debug <taskId>
77+
```
78+
79+
### Task Information
80+
81+
```bash
82+
# View task details
83+
iexec task show <taskId>
84+
85+
# Download results (if completed)
86+
iexec task show <taskId> --download
87+
```
88+
89+
## Common Issues
90+
91+
### ⏱️ **Task Timeout**
92+
93+
- **Cause**: Code takes too long to execute
94+
- **Solution**: Optimize algorithms, reduce input sizes, use appropriate task
95+
category
96+
97+
### 💾 **Memory Issues**
98+
99+
- **Cause**: Loading large files, memory leaks, TEE constraints
100+
- **Solution**: Process data in chunks, use streaming, optimize memory usage
101+
102+
### 📁 **Input/Output Problems**
103+
104+
- **Cause**: Wrong file paths, missing `computed.json`
105+
- **Solution**: Always create `computed.json`, verify environment variables
106+
107+
```python
108+
# Always create computed.json
109+
import json, os
110+
computed = {"deterministic-output-path": f"{os.environ['IEXEC_OUT']}/result.json"}
111+
with open(f"{os.environ['IEXEC_OUT']}/computed.json", 'w') as f:
112+
json.dump(computed, f)
113+
```
114+
115+
### ⚠️ **Dataset type unmatching**
116+
117+
- **Cause**: The dataset type specified in the frontend (protectData) does not
118+
match with the dataset type specified in the iApp
119+
- **Solution**: Check both dataset types
120+
121+
## Best Practices
122+
123+
### 🔍 **Input Validation**
124+
125+
```python
126+
import os, sys
127+
128+
# Check required environment variables
129+
if not os.environ.get('IEXEC_IN') or not os.environ.get('IEXEC_OUT'):
130+
print("ERROR: Missing IEXEC_IN or IEXEC_OUT")
131+
sys.exit(1)
132+
133+
# Validate arguments
134+
if len(sys.argv) < 2:
135+
print("ERROR: Missing required arguments")
136+
sys.exit(1)
137+
```
138+
139+
### 📝 **Clear Error Messages**
140+
141+
```python
142+
try:
143+
# Your processing logic
144+
result = process_data(data)
145+
except Exception as e:
146+
print(f"ERROR: Processing failed: {str(e)}")
147+
sys.exit(1)
148+
```
149+
150+
### 🔒 **Safe File Operations**
151+
152+
```python
153+
import os, json
154+
155+
# Always ensure output directory exists
156+
iexec_out = os.environ['IEXEC_OUT']
157+
os.makedirs(iexec_out, exist_ok=True)
158+
159+
# Write results safely
160+
try:
161+
with open(f"{iexec_out}/result.json", 'w') as f:
162+
json.dump(result_data, f)
163+
except Exception as e:
164+
print(f"ERROR: Failed to write results: {e}")
165+
sys.exit(1)
166+
```
167+
168+
## What's Next?
169+
170+
Continue improving your iApps:
171+
172+
- **[Inputs and Outputs](/build_iapp/guides/inputs-and-outputs)** - Handle data
173+
in TEE
174+
- **[How to Get and Decrypt Results](/build_iapp/guides/how-to-get-and-decrypt-results)** -
175+
Retrieve results

0 commit comments

Comments
 (0)