Skip to content

Commit e17e784

Browse files
committed
feat: Lit Action trust model, capacity auto-detect, decrypt endpoint, decentralization docs
- Custom Lit Action (non-media-decrypt.js): self-referential conditions only, on-chain access check via hasAccessByContentId(buyerAddress, kid) inside action code, Smart Account aware — trustless even with server-side executeJs() - Capacity credit auto-detection: queries Chronicle Yellowstone RLI contract for latest valid token owned by delegation wallet, handles 15-day rotation cycle - Server-side decrypt: POST /api/storage/lit/decrypt reads action code from disk, passes via code param (no IPFS gateway dependency), returns decrypted bytes - Market dApp: inline image rendering via blob URL, Decrypt & View button for non-media assets, ensureRawMetadata() fixes decrypt race condition - Creator Dashboard: 5s delay before gateway approval tx, try-catch wrapper, Fix Gateway Approval tool with auto-fill on failure - docs: DECENTRALIZATION_STATUS.md — team handover doc with architecture, scorecard, walk-away test roadmap, centralized dependency analysis - docs: SESSION_HANDOVER.md + ROADMAP.md updated with all Mar 14 work Blocked: waiting on capacity credit private key from Irzhy to test E2E decrypt Made-with: Cursor
1 parent 4527b9f commit e17e784

11 files changed

Lines changed: 1300 additions & 138 deletions

File tree

docs/core/DECENTRALIZATION_STATUS.md

Lines changed: 448 additions & 0 deletions
Large diffs are not rendered by default.

docs/core/ROADMAP.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Each **Milestone** from the DAO proposal is broken down into concrete **Work Str
1919
| [ARCHITECTURE_CONVERGENCE.md](./ARCHITECTURE_CONVERGENCE.md) | PC2 v1 → Capsule Runtime v2 technical path |
2020
| [SUPERNODE_ECONOMICS.md](./SUPERNODE_ECONOMICS.md) | dDRM Access Token model for supernode revenue |
2121
| [NETWORK_HARDENING.md](../pc2-infrastructure/NETWORK_HARDENING.md) | Supernode decentralization and self-healing |
22+
| [DECENTRALIZATION_STATUS.md](./DECENTRALIZATION_STATUS.md) | Decentralization scorecard, walk-away test roadmap |
2223
| [AGENT_HANDOVER.md](./AGENT_HANDOVER.md) | Current state, coding patterns, infrastructure |
2324
| [ARM_DEVICES.md](../deployment/ARM_DEVICES.md) | Jetson/Raspberry Pi deployment |
2425

@@ -151,11 +152,17 @@ These diagrams from Rong define the north star. Every work stream should move us
151152
- [x] Operative approval — `setApprovalForAll(gateway, true)` with ContractCreated event fallback for proxy-based channels *(implemented Mar 13)*
152153
- [x] Elacity IPFS pipeline — dual upload (local + Elacity), CIDv0 resolution, marketplace visibility confirmed *(completed Mar 14)*
153154
- [x] Metadata format — image (auto-thumbnail), authority, categories fields for GraphQL compatibility *(completed Mar 14)*
154-
- [x] Server-side Lit Protocol — encryption via pc2-node backend with capacity credits (RLI #429689) *(completed Mar 14)*
155+
- [x] Server-side Lit Protocol — encryption via pc2-node backend with capacity credits *(completed Mar 14)*
155156
- [x] Channel selection UI — user's own channels + custom address input *(completed Mar 14)*
156157
- [x] On-chain purchase verified — buyer received ACCESS_TOKEN, payment split correct *(verified Mar 14)*
157-
- [ ] Consumer decrypt endpoint — `POST /api/lit/decrypt` on pc2-node (ACCESS_TOKEN verification → Lit decrypt → AES-GCM → return bytes)
158-
- [ ] Universal asset viewer — render decrypted content by MIME type (no WASM needed for non-media)
158+
- [x] Consumer decrypt endpoint — `POST /api/storage/lit/decrypt` on pc2-node with Lit Action `executeJs()` *(implemented Mar 14)*
159+
- [x] Lit Action trust model — custom `non-media-decrypt.js` with self-referential conditions + on-chain access check in action code *(implemented Mar 14)*
160+
- [x] Smart Account awareness — passes SA address as `buyerAddress` for Universal Account buyers *(implemented Mar 14)*
161+
- [x] Capacity credit auto-detection — queries Chronicle Yellowstone for latest valid RLI token, handles 15-day rotation *(implemented Mar 14)*
162+
- [x] Inline image rendering — decrypted content rendered as blob URL in Market dApp *(implemented Mar 14)*
163+
- [x] Gateway approval hardening — 5s delay, try-catch, "Fix Gateway Approval" tool *(implemented Mar 14)*
164+
- [ ] End-to-end decrypt test with capacity credits — **BLOCKED on capacity key from Irzhy**
165+
- [ ] Universal asset viewer — render decrypted content by MIME type (images working, PDFs/audio/3D TBD)
159166

160167
**SDK Evolution (Universal Asset Protocol):**
161168
- [x] `@elacity-js/access` package — clean-room build of universal access layer using Lit Protocol SDK directly (see `docs/core/ACCESS_PACKAGE_SPEC.md`) *(implemented Mar 13 — 12 source files, 47 unit tests passing)*
@@ -268,6 +275,13 @@ These diagrams from Rong define the north star. Every work stream should move us
268275
- [x] Buyer node becomes seeder (CDN effect for encrypted content) *(completed Mar 5-6 — Bitswap-first + NAT traversal + relay)*
269276

270277
**Universal Asset Marketplace (dDRM beyond media):**
278+
- [x] Lit Action trust model — custom `non-media-decrypt.js` with self-referential conditions, on-chain access check, Smart Account aware *(completed Mar 14)*
279+
- [x] Capacity credit auto-detection — queries Chronicle Yellowstone for latest valid RLI token, handles 15-day rotation *(completed Mar 14)*
280+
- [x] Server-side decrypt endpoint — `POST /api/storage/lit/decrypt` with Lit Action `executeJs()` *(completed Mar 14)*
281+
- [x] Inline image rendering — decrypted content rendered as blob URL in Market dApp *(completed Mar 14)*
282+
- [ ] **End-to-end decrypt test with capacity credits****BLOCKED on capacity key from Irzhy**
283+
- [ ] On-chain content indexer — replace Elacity GraphQL dependency with event scanner (The Graph / custom). See [DECENTRALIZATION_STATUS.md](./DECENTRALIZATION_STATUS.md) Tier 1.1
284+
- [ ] Self-provisioned RLI tokens — each PC2 node mints own capacity credits, removes Elacity wallet dependency. See Tier 1.3
271285
- [ ] AI Model Marketplace alpha — encrypt GGUF/SafeTensors model → IPFS → ACCESS_TOKEN → decrypt on PC2 → load in Ollama
272286
- [ ] Code/Plugin Marketplace — dDRM-gated npm packages, themes, extensions
273287
- [ ] Dataset Marketplace — dDRM-gated training datasets, knowledge bases

docs/core/SESSION_HANDOVER.md

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
**Release:** v1.1.0 tagged and released on 2026-03-03 (134 commits squash-merged to main)
1111
**Launcher:** v1.1.1 released — version display, one-click updates, full networking install
1212
**DAO Proposal:** Live at https://elastos.com/proposals/69a24f49247f130078064edd
13-
**Last Commit:** `9111efd85`fix: metadata format for Elacity compatibility — image, authority, thumbnail
13+
**Last Commit:** `4527b9f1a`feat: server-side decrypt + inline image rendering in Market dApp
1414

1515
### What Just Shipped (v1.1.0 on main)
1616

@@ -235,9 +235,20 @@ Full technical spec at `docs/core/ACCESS_PACKAGE_SPEC.md`. Key decisions:
235235

236236
**Server-side Lit Protocol (Mar 13-14):**
237237
- Lit operations moved to pc2-node backend due to iframe sandbox blocking outbound Lit node connections
238-
- `POST /api/lit/encrypt` — encrypts content with Lit Protocol using server-side LitNodeClientNodeJs
239-
- Capacity Credits: RLI Token #429689 (100 req/kilosecond, valid until Apr 13) on wallet `0x0917Aa...C52D`
238+
- `POST /api/storage/lit/encrypt` — encrypts content with Lit Protocol using server-side LitNodeClientNodeJs
239+
- `POST /api/storage/lit/decrypt` — decrypts via Lit Action `executeJs()` with on-chain access verification
240+
- Capacity Credits: Auto-detected from Chronicle Yellowstone — queries RLI contract for latest non-expired token owned by capacity wallet `0x581D4bca...`
240241
- Delegation: Owner-signed `createCapacityDelegationAuthSig` on backend (not end-user signed)
242+
- **Blocking:** Waiting for private key of capacity wallet `0x581D4bca99709c1E0cB6f07c9D05719818AA6e49` from Irzhy
243+
244+
**Lit Action Trust Model (Mar 14) — KEY ARCHITECTURE:**
245+
- Custom Lit Action (`pc2-node/data/lit-actions/non-media-decrypt.js`) runs on 6+ Lit TEE nodes
246+
- **Self-referential-only conditions** at encrypt time (`:currentActionIpfsId === ourCID`)
247+
- Access check embedded in action code: `hasAccessByContentId(buyerAddress, kid)` via ethers.js on Lit nodes
248+
- `buyerAddress` passed as jsParam (not `:userAddress` which would resolve to server wallet)
249+
- Smart Account aware — passes SA address when buyer uses Universal Account
250+
- Server reads action code from disk, passes via `code` parameter (bypasses IPFS gateway fetches)
251+
- Capacity token ID auto-detected from Chronicle Yellowstone chain (handles 15-day rotation cycle)
241252

242253
**Elacity IPFS Pipeline (Mar 13-14) — KEY BREAKTHROUGH:**
243254
- Local IPFS (Helia) + Elacity IPFS (`POST /api/2.0/files/upload` with `X-Target-Flow: ipfs`) dual-upload
@@ -288,30 +299,48 @@ Full technical spec at `docs/core/ACCESS_PACKAGE_SPEC.md`. Key decisions:
288299
- [x] Paid mint on user-created channels — **VERIFIED WORKING** (channel `0xb4a1c563...`, operative `0x7D243806...`)
289300
- [x] Integration with Elacity Market dApp backend (asset visibility after mint) — **VERIFIED** (visible on base.ela.city + channel page)
290301
- [x] On-chain purchase — **VERIFIED** (buyer received ACCESS_TOKEN + resale token, payment split correct)
291-
- [ ] **Consumer decrypt flow** — buyer has ACCESS_TOKEN, needs server-side Lit decrypt endpoint on pc2-node
292-
- [ ] setApprovalForAll post-mint — code implemented, needs user wallet confirmation
302+
- [x] Consumer decrypt endpoint — `POST /api/storage/lit/decrypt` on pc2-node with Lit Action `executeJs()`
303+
- [x] Lit Action trust model — self-referential conditions, access check in action code, Smart Account aware
304+
- [x] Capacity credit auto-detection — queries Chronicle Yellowstone for latest valid RLI token
305+
- [x] Inline image rendering — decrypted content rendered as blob URL in Market dApp
306+
- [x] Gateway approval retry — 5s delay after mint, try-catch wrapper, "Fix Gateway Approval" tool in Creator
307+
- [x] Decrypt race condition fix — `ensureRawMetadata()` fetches IPFS metadata synchronously before decrypt
308+
- [ ] **End-to-end decrypt test with capacity credits** — waiting on private key from Irzhy
309+
- [ ] Fix library not showing all purchased assets (Elacity test 4 missing)
293310
- [ ] Purchase with standard wallet (MetaMask) — to isolate UA receipt parsing bug
294311

295312
**Known issues:**
296-
- Elacity frontend UA receipt parsing: `UAReceiptFetcher.enrichOperationsWithContracts` throws `TypeError: Cannot read properties of undefined (reading 'map')` after successful on-chain purchase. Bug is in Elacity's `index-BOeceeBu.js`, not in our code. Transaction completes successfully.
313+
- Elacity frontend UA receipt parsing: `UAReceiptFetcher.enrichOperationsWithContracts` throws `TypeError` after successful on-chain purchase. Bug is in Elacity's frontend, not our code.
297314
- MPD parser error for image assets: Elacity's media player tries to parse image metadata as DASH manifest. Expected for non-video content.
315+
- Lit rate limiting: without capacity credit private key, Datil network rate-limits `executeJs()` calls
298316

299317
#### Next Up — Engineering Priorities
300-
1. **Consumer decrypt endpoint**`POST /api/lit/decrypt` on pc2-node: verify ACCESS_TOKEN on-chain → Lit Protocol decrypt key → AES-GCM decrypt → return bytes. This is the critical missing piece.
301-
2. **Universal asset viewer** — render decrypted content by MIME type (images, PDFs, audio, 3D models). No WASM/SharedArrayBuffer needed.
302-
3. **AI Model Marketplace alpha** — first non-media vertical: GGUF → encrypt → IPFS → ACCESS_TOKEN → decrypt on node → Ollama
303-
4. ~~**`@elacity-js/access` package**~~ — DONE (Mar 13)
304-
5. ~~**Creator Dashboard dApp**~~ — DONE (Mar 13-14) — encrypt, IPFS upload (local + Elacity), metadata, mint, channel selection
305-
6. ~~**Contract ABIs + mint encoding**~~ — DONE (Mar 13)
306-
7. ~~**Channel creation**~~ — DONE (Mar 13)
307-
8. ~~**Elacity IPFS pipeline**~~ — DONE (Mar 14) — dual upload, CID resolution, marketplace visibility
308-
9. ~~**Marketplace metadata compatibility**~~ — DONE (Mar 14) — image, authority, categories
309-
10. ~~**On-chain purchase verification**~~ — DONE (Mar 14)
310-
11. **Create GitHub release `pc2-binaries-v1`** — run `fetch-binaries.sh all`, upload assets to release (DEFERRED)
311-
12. **Gateway "node offline" page** — replaces infinite "initializing" spinner
312-
13. **Fiat onramp** — Particle Smart Account + Stripe/Moonpay
313-
14. **App Factory** — local packaging pipeline
314-
15. **dDRM Access Token contract** — ERC-1155 tiered tokens for supernode economics (deferred to Milestone 3-4)
318+
1. **Get capacity credit private key from Irzhy** — BLOCKING. Needed for Lit Protocol production decrypt.
319+
2. **Test full E2E decrypt** — once key is configured, test encrypt → mint → buy → decrypt on PC2 node
320+
3. **Fix library showing all purchased assets** — Elacity test 4 not appearing in PC2 Market library
321+
4. **On-chain indexer prototype** — replace Elacity GraphQL dependency with event scanner (The Graph / custom)
322+
5. **Self-provisioned RLI tokens** — each node mints own capacity credits, removes Elacity wallet dependency
323+
6. **AI Model Marketplace alpha** — first non-media vertical: GGUF → encrypt → IPFS → ACCESS_TOKEN → decrypt → Ollama
324+
7. ~~**Consumer decrypt endpoint**~~ — DONE (Mar 14) — Lit Action `executeJs()` with on-chain access check
325+
8. ~~**Lit Action trust model**~~ — DONE (Mar 14) — self-ref conditions, access check in action code
326+
9. ~~**Capacity credit auto-detection**~~ — DONE (Mar 14) — Chronicle Yellowstone query, handles 15-day rotation
327+
10. ~~**Universal asset viewer (images)**~~ — DONE (Mar 14) — inline blob URL rendering in Market dApp
328+
11. ~~**`@elacity-js/access` package**~~ — DONE (Mar 13)
329+
12. ~~**Creator Dashboard dApp**~~ — DONE (Mar 13-14)
330+
13. ~~**Elacity IPFS pipeline**~~ — DONE (Mar 14)
331+
14. ~~**On-chain purchase verification**~~ — DONE (Mar 14)
332+
15. **Create GitHub release `pc2-binaries-v1`** — run `fetch-binaries.sh all`, upload assets to release (DEFERRED)
333+
16. **Gateway "node offline" page** — replaces infinite "initializing" spinner
334+
17. **Fiat onramp** — Particle Smart Account + Stripe/Moonpay
335+
18. **App Factory** — local packaging pipeline
336+
19. **dDRM Access Token contract** — ERC-1155 tiered tokens for supernode economics (deferred to Milestone 3-4)
337+
338+
#### Decentralization Analysis — DOCUMENTED (Mar 14)
339+
- [x] `docs/core/DECENTRALIZATION_STATUS.md` — comprehensive team document covering architecture, scorecard, and walk-away test roadmap
340+
- Fully decentralized: smart contracts, access verification, purchase/sale, Lit Action, encryption/decryption, AccessToken ownership
341+
- Centralized (to be replaced): Elacity GraphQL API, IPFS gateway, IPFS upload, capacity wallet, auth nonce
342+
- Walk-away test requires: on-chain indexer (Tier 1), self-sufficient IPFS (mostly done), self-provisioned RLI tokens
343+
- Protocol fees already decentralized — enforced by smart contracts, not infrastructure
315344

316345
#### Backlog — Marketing & Docs (Lower Priority)
317346
- [ ] **PC2 marketing slides for elacitylabs.com** — audit and rewrite 7 slides (benefits, features, blind spots, full copywriting)
@@ -366,7 +395,7 @@ Full technical spec at `docs/core/ACCESS_PACKAGE_SPEC.md`. Key decisions:
366395
- [Supernode Decentralization](f18dbf44-f5de-4238-8c62-499018cd4e50) — gateway v2.0, bootstrap script, dynamic discovery, relay mode, supernode dApp, community networking fix, docs update
367396
- [Network Map + Strategy](d9445cb9-12bd-437e-8d4e-ebb35ef40d64) — network map visual upgrade, universal asset strategy, app manifest spec, binary manager, handover
368397
- [3D Orb + SEO + Rebrand](6431d137-5dd9-4c8e-b042-5d8c54b908a5) — 3D orb integration, network map rebrand to "World Computer", full SEO overhaul, GA4, app icon fixes, mobile responsiveness
369-
- [dDRM Pipeline E2E](fd6755f0-d73c-4e41-8df3-0f57f15071a2)@elacity-js/access audit, Creator Dashboard, server-side Lit, Elacity IPFS pipeline, marketplace visibility, on-chain purchase verified, metadata fixes, channel creation
398+
- [dDRM Pipeline E2E](fd6755f0-d73c-4e41-8df3-0f57f15071a2)@elacity-js/access, Creator Dashboard, Lit Action trust model (Path A), capacity credit auto-detection, decrypt endpoint, decentralization analysis
370399

371400
---
372401

@@ -379,6 +408,7 @@ Full technical spec at `docs/core/ACCESS_PACKAGE_SPEC.md`. Key decisions:
379408
| **Roadmap** | `docs/core/ROADMAP.md` | All milestones with checkboxes |
380409
| **Architecture** | `docs/core/ARCHITECTURE_CONVERGENCE.md` | PC2 v1 -> capsule runtime v2 |
381410
| **Universal Asset Strategy** | `docs/core/ELACITY_UNIVERSAL_ASSET_STRATEGY.md` | Unicorn strategy, marketplace verticals, SDK evolution, revenue model |
411+
| **Decentralization Status** | `docs/core/DECENTRALIZATION_STATUS.md` | Decentralization scorecard, walk-away test roadmap, team handover |
382412
| **Access Package Spec** | `docs/core/ACCESS_PACKAGE_SPEC.md` | @elacity-js/access technical spec, API, security model, marketplace tiers |
383413
| **App Manifest Spec** | `docs/core/APP_MANIFEST_SPEC.md` | app.json schema, field reference, validation rules |
384414
| **Supernode Economics** | `docs/core/SUPERNODE_ECONOMICS.md` | dDRM Access Token model, three-tier architecture |
@@ -409,10 +439,15 @@ Full technical spec at `docs/core/ACCESS_PACKAGE_SPEC.md`. Key decisions:
409439
| `pc2-node/src/index.ts` | Periodic DHT re-announcement loop |
410440
| `deploy/ipfs-relay/` | Standalone IPFS relay deployed on supernode |
411441

442+
### Lit Action (runs on Lit TEE nodes)
443+
| File | Purpose |
444+
|------|---------|
445+
| `pc2-node/data/lit-actions/non-media-decrypt.js` | Trustless on-chain access check + threshold CEK decryption |
446+
412447
### Backend APIs
413448
| File | Purpose |
414449
|------|---------|
415-
| `pc2-node/src/api/storage.ts` | `/api/storage/ipfs/pin`IPFS pinning with CAR support |
450+
| `pc2-node/src/api/storage.ts` | Lit encrypt/decrypt, IPFS upload/pin, capacity credit auto-detection |
416451
| `pc2-node/src/api/installed-apps.ts` | App install/uninstall/list endpoints |
417452
| `pc2-node/src/services/AppInstallService.ts` | App lifecycle management service |
418453
| `pc2-node/src/static.ts` | Static serving for installed apps with wallet bridge injection |

0 commit comments

Comments
 (0)