Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions .vitepress/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,39 +361,28 @@ export function getSidebar() {
},
{
text: '📖  Guides',
link: '/build_iapp/guides',
collapsed: true,
items: [
{
text: 'Manage Your iApps',
link: '/build_iapp/iapp-generator/manage-iapps',
},
{
text: 'Orders (how they work, how to manage them)',
text: 'App Access Control and Pricing',
link: '/build_iapp/guides/orders',
},
{
text: 'Inputs and Outputs (types, differences, formats)',
text: 'Inputs and Outputs',
link: '/build_iapp/guides/inputs-and-outputs',
},
{
text: 'Debugging Your iApp',
link: '/build_iapp/guides/debugging-your-iapp',
},
{
text: 'Using TDX (Trusted Execution) [EXPERIMENTAL]',
link: '/build_iapp/guides/using-tdx-experimental',
},
{
text: 'How to Get and Decrypt Results',
link: '/build_iapp/guides/how-to-get-and-decrypt-results',
},
{
text: 'AI Frameworks',
link: '/build_iapp/iapp-generator/ai-frameworks',
},
{
text: 'Other Emerging Trends',
link: '/build_iapp/guides/other-emerging-trends',
text: 'Using TDX (Experimental)',
link: '/build_iapp/guides/using-tdx-experimental',
},
],
},
Expand Down
156 changes: 156 additions & 0 deletions build_iapp/guides.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
title: iApp Building Guides
description:
Step-by-step guides for building, deploying, and managing your privacy-first
iApps
---

# 📖 iApp Building Guides

**Master iApp development from code to production** with these comprehensive
step-by-step guides. Each guide focuses on a specific aspect of building
privacy-preserving applications with iExec.

## Essential Guides

### 💰 [App Access Control and Pricing](/build_iapp/guides/orders)

**Control who can use your iApp and monetize it.** Learn how to create app
orders to make your iApp accessible while defining pricing and access
restrictions.

- Create and manage app orders with iExec SDK
- Configure pricing, volume limits, and restrictions
- Understand TEE requirements and workerpool restrictions
- Common monetization patterns and use cases

---

### 📥📤 [Inputs and Outputs](/build_iapp/guides/inputs-and-outputs)

**Handle data flow in your iApp's TEE environment.** Master the different input
types and learn how to generate proper outputs that users can retrieve.

- 4 input types: Args, Input Files, Requester Secrets, Protected Data
- Access methods via environment variables and file system
- TEE memory constraints and best practices
- Output structure with mandatory `computed.json`

---

### 🐛 [Debugging Your iApp](/build_iapp/guides/debugging-your-iapp)

**Troubleshoot and optimize your iApp execution in the TEE environment.** Master
debugging techniques and best practices for reliable iApp development.

- Task execution lifecycle and monitoring
- iExec Explorer and CLI debugging tools
- Common issues: timeouts, memory limits, input/output problems
- Best practices: input validation, error handling, performance optimization

---

### 📦 [How to Get and Decrypt Results](/build_iapp/guides/how-to-get-and-decrypt-results)

**Download and decrypt iApp execution results from completed tasks.** Learn the
complete workflow for retrieving and using iApp outputs.

- Deal → Task → Result structure and accessibility
- Download methods: iExec CLI and DataProtector SDK
- Automatic vs manual decryption workflows
- Integration patterns for React and Node.js applications

---

### 🛡️ [Using TDX (Experimental)](/build_iapp/guides/using-tdx-experimental)

**Enable Intel TDX for enhanced TEE security - experimental feature only.**
Understand how to activate TDX and when to use it.

- How to enable TDX in iApp Generator deployment and execution
- SGX vs TDX differences and compatibility requirements
- Protected data compatibility considerations
- Production warnings and experimental limitations

## Quick Navigation

::: tip What You'll Learn These guides cover the complete journey from iApp
development to production deployment, user access management, and result
handling. :::

### By Development Stage

- **🚀 Just built your iApp?** →
[App Access Control and Pricing](/build_iapp/guides/orders)
- **🔧 Handling data flow?** →
[Inputs and Outputs](/build_iapp/guides/inputs-and-outputs)
- **🐛 Having issues?** →
[Debugging Your iApp](/build_iapp/guides/debugging-your-iapp)
- **📦 Need results?** →
[How to Get and Decrypt Results](/build_iapp/guides/how-to-get-and-decrypt-results)

### By User Type

**iApp Developer**: You build the privacy-preserving application
→ [Inputs and Outputs](/build_iapp/guides/inputs-and-outputs) +
[Debugging](/build_iapp/guides/debugging-your-iapp)

**App Owner**: You deploy and monetize the iApp
→ [App Access Control and Pricing](/build_iapp/guides/orders)

**End User Guide**: Your users need to retrieve results
→ [How to Get and Decrypt Results](/build_iapp/guides/how-to-get-and-decrypt-results)

## Development Workflow

### 1. **Build Your iApp**

Start with [iApp Generator](/build_iapp/iapp-generator) to create your
privacy-preserving application.

### 2. **Handle Data Flow**

Use the [Inputs and Outputs](/build_iapp/guides/inputs-and-outputs) guide to
properly access different input types and generate results.

### 3. **Debug and Test**

Follow the [Debugging](/build_iapp/guides/debugging-your-iapp) guide to
troubleshoot issues and optimize performance.

### 4. **Control Access**

Implement [App Access Control and Pricing](/build_iapp/guides/orders) to make
your iApp accessible with proper monetization.

### 5. **User Experience**

Implement [Result Retrieval](/build_iapp/guides/how-to-get-and-decrypt-results)
to provide users with seamless access to iApp outputs.

## Additional Resources

### 📚 **iApp Generator**

- [What Is an iApp?](/build_iapp/iapp-generator/what-is-iapp) - Core concepts
and overview
- [Getting Started](/build_iapp/iapp-generator/getting-started) - Your first
iApp in 15 minutes
- [Building Your iApp](/build_iapp/iapp-generator/building-your-iexec-app) -
Complete development guide

### 🎯 **Real Examples**

- [Hello World Tutorial](/overview/helloWorld) - End-to-end iApp development
- [AI Use Cases](/overview/use-cases/ai) - AI-powered privacy applications

### 🔧 **Advanced Topics**

- [SDK Deep Dive](/deep_dive/sdk) - Advanced SDK concepts and usage
- [Workers & Workerpools](/deep_dive/workers) - Understanding the execution
infrastructure

---

**Ready to build privacy-first applications?** Pick the guide that matches your
current development stage and start building! 🚀
168 changes: 164 additions & 4 deletions build_iapp/guides/debugging-your-iapp.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,170 @@
---
title: Debugging Your iApp
description: Déboguer votre iApp
description:
Troubleshoot and optimize your iApp execution in the TEE environment
---

# Debugging Your iApp
# 🐛 Debugging Your iApp

Cette page est en cours de développement.
**When your iApp doesn't work as expected, debugging in the TEE environment
requires specific techniques.** This guide helps you identify issues and
optimize your iApp's performance.

<!-- TODO: Ajouter le guide de débogage -->
## Task Execution Lifecycle

Understanding how your task progresses through the iExec network:

### Key Stages

1. **Deal Creation** - Orders matched, funds locked
2. **Task Initialization** - Workers selected for execution
3. **iApp Execution** - Your code runs inside TEE
4. **Result Processing** - Results encrypted and uploaded
5. **Task Completion** - Results available for download

**Most failures happen during stages 2-4**

## Monitoring Your Tasks

### iExec Explorer

Track your tasks at [explorer.iex.ec](https://explorer.iex.ec):

- Search by `taskId` or deal ID
- Check status: `PENDING` → `ACTIVE` → `COMPLETED/FAILED`
- View error messages if execution fails

### Status in Code

```typescript
const response = await dataProtectorCore.processProtectedData({
protectedData: '0x123abc...',
app: '0x456def...',
onStatusUpdate: ({ title, isDone }) => {
console.log(`Status: ${title} - Done: ${isDone}`);
},
});
```

## Debug Commands

### Local Testing

```bash
# Test your iApp locally
iapp test --args "model=bert threshold=0.8"
iapp test --secrets "key1=value1,key2=value2"

# Mock protected data for testing
iapp mock protectedData
iapp test --protectedData "mock_name"
```

### Remote Debugging

```bash
# Deploy and run
iapp deploy
iapp run <iapp-address>

# Debug failed executions
iapp debug <taskId>
```

### Task Information

```bash
# View task details
iexec task show <taskId>

# Download results (if completed)
iexec task show <taskId> --download
```

## Common Issues

### ⏱️ **Task Timeout**

- **Cause**: Code takes too long to execute
- **Solution**: Optimize algorithms, reduce input sizes, use appropriate task
category

### 💾 **Memory Issues**

- **Cause**: Loading large files, memory leaks, TEE constraints
- **Solution**: Process data in chunks, use streaming, optimize memory usage

### 📁 **Input/Output Problems**

- **Cause**: Wrong file paths, missing `computed.json`
- **Solution**: Always create `computed.json`, verify environment variables

```python
# Always create computed.json
import json, os
computed = {"deterministic-output-path": f"{os.environ['IEXEC_OUT']}/result.json"}
with open(f"{os.environ['IEXEC_OUT']}/computed.json", 'w') as f:
json.dump(computed, f)
```

## Best Practices

### 🔍 **Input Validation**

```python
import os, sys

# Check required environment variables
if not os.environ.get('IEXEC_IN') or not os.environ.get('IEXEC_OUT'):
print("ERROR: Missing IEXEC_IN or IEXEC_OUT")
sys.exit(1)

# Validate arguments
if len(sys.argv) < 2:
print("ERROR: Missing required arguments")
sys.exit(1)
```

### 📝 **Clear Error Messages**

```python
try:
# Your processing logic
result = process_data(data)
except Exception as e:
print(f"ERROR: Processing failed: {str(e)}")
sys.exit(1)
```

### 🔒 **Safe File Operations**

```python
import os, json

# Always ensure output directory exists
iexec_out = os.environ['IEXEC_OUT']
os.makedirs(iexec_out, exist_ok=True)

# Write results safely
try:
with open(f"{iexec_out}/result.json", 'w') as f:
json.dump(result_data, f)
except Exception as e:
print(f"ERROR: Failed to write results: {e}")
sys.exit(1)
```

## What's Next?

Continue improving your iApps:

- **[Inputs and Outputs](/build_iapp/guides/inputs-and-outputs)** - Handle data
in TEE
- **[How to Get and Decrypt Results](/build_iapp/guides/how-to-get-and-decrypt-results)** -
Retrieve results

---

**TL;DR**: Use Explorer to track tasks → Test locally with `iapp test` → Debug
remote issues with `iapp debug` → Always validate inputs and create
`computed.json`! 🚀
Loading
Loading