Skip to content

Feat/tee - #50

Merged
chudkowsky merged 15 commits into
mainfrom
feat/tee
Mar 25, 2026
Merged

Feat/tee#50
chudkowsky merged 15 commits into
mainfrom
feat/tee

Conversation

@chudkowsky

@chudkowsky chudkowsky commented Mar 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR introduces TEE (Trusted Execution Environment) support and restructures the binary layout to eliminate native library conflicts between STARK and TEE dependency trees.

Workspace split

`bin/saya` is dissolved. Each binary now lives in its own isolated Cargo workspace with its own lock file:

Binary Crate Purpose
`bin/persistent` `persistent` STARK-based proving via Atlantic/Piltover
`bin/persistent-tee` `persistent-tee` TEE-based proving + attestation
`bin/ops` `ops` On-chain ops (formerly `bin/core-contract`)

Why: `c-kzg` (pulled by SNOS) and `katana-tee` deps cannot coexist in a single workspace — they pull in conflicting native libraries. Separate workspaces give each binary an independent resolver.

saya-core is now pure infrastructure

All STARK-specific code (Atlantic HTTP client, mock prover, sovereign/persistent orchestrators, Piltover settlement, utils) moves from `saya-core` into `bin/persistent`. `saya-core` retains only block ingestor, storage, DA traits, and service primitives — plus a new optional `snos` feature for `SovereignPacket` impls that would otherwise violate the orphan rule.

TEE integration (`bin/persistent-tee` + `saya/core`)

New modules added:

  • `saya/core/src/orchestrator/tee.rs` — TEE orchestration loop
  • `saya/core/src/prover/tee/` — TEE prover trait impl
  • `saya/core/src/tee/` — shared TEE types
  • `saya/core/src/block_ingestor/polling.rs` — polling-based ingestor for TEE workflows
  • `bin/persistent-tee/src/attestor.rs` — remote attestation
  • `bin/persistent-tee/src/prover.rs` / `prover_impl.rs` — TEE proof generation
  • `bin/persistent-tee/src/settlement.rs` — TEE settlement flow

CLI change

`persistent persistent start` is flattened to `persistent start` by removing the `Persistent` wrapper struct.

Docker / CI fixes

  • Build both isolated workspaces (`bin/persistent`, `bin/ops`) with separate `--manifest-path` invocations
  • Generate `layout_bridge.json` inside the build stage (eliminates dependency on a pre-populated `programs/` directory that is gitignored and absent in CI)
  • Create cairo-lang venv from `requirements.txt`; switch to `openssl-dev` + `openssl-libs-static` for musl static linking
  • Bump `rust-toolchain.toml` to 1.89 (required by transitive dojo-utils deps)
  • `compose.yml` uses `${SAYA_IMAGE:-ghcr.io/dojoengine/saya:feat-tee}` — image managed via compose, e2e CI no longer builds from source
  • e2e CI toolchain bumped to 1.89, `build-image` job removed

Compose / e2e fixes

  • Updated piltover contract address and `sn_msg` messaging contract address after class hash change
  • Added `sleep 2` between `sozo declare` and `sozo deploy` in `appc_msg_sn_deploy` to avoid nonce race
  • Lowered `--settlement-contract-deployed-block` default from 4 → 1 to avoid `ContractNotFound` panic in `katana_init` when parallel services produce nondeterministic block ordering
  • `compose_up()` in e2e test helper now calls `compose_down()` first for a clean slate

Testing

  • All 17 unit tests pass (`cargo test --workspace --all-features --exclude saya-e2e`)
  • `e2e-settlement`: `test_program_info_and_fact_registry`, `test_settlement_advances_after_genesis` — pass
  • `e2e-messaging`: `test_l2_to_l3_message`, `test_l3_to_l2_message` — pass

chudkowsky and others added 11 commits March 20, 2026 21:09
…sistent, persistent-tee)

Resolves c-kzg native library link conflict between snos and tee deps by
giving each binary its own Cargo workspace and lock file. Moves SnosPieGenerator
out of saya-core into bin/persistent. Sets up bin/persistent-tee skeleton with
katana-tee deps and alloy v1.0.41 patches. Switches compose files to build from
source instead of pinned images.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…n/persistent

saya-core is now pure infrastructure (block ingestor, storage, DA traits,
service primitives). All STARK-specific code (Atlantic HTTP client, mock
prover, sovereign/persistent orchestrators, Piltover STARK settlement, utils)
moves to bin/persistent where it belongs.

- Add optional `snos` feature to saya-core for SovereignPacket and
  impl DataAvailabilityPayload for SnosProof<StarkProof> (orphan rule)
- bin/persistent adds swiftness/integrity/reqwest/piltover/zip as direct deps
- bin/persistent-tee no longer pulls in swiftness via saya-core, fixing the
  size-of v0.1.5 compile error on stable 1.91

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…r builds

- Rename bin/core-contract to bin/ops (crate name: ops) for clearer semantics
- Flatten `persistent persistent start` → `persistent start` by removing the
  Persistent wrapper struct and promoting Start to a top-level subcommand
- Dockerfile: build both isolated workspaces (bin/persistent, bin/ops) with
  separate --manifest-path invocations; create cairo-lang venv from
  requirements.txt to satisfy apollo_starknet_os_program build dep; switch
  to openssl-dev + openssl-libs-static for musl static linking; add
  python3-dev and gmp-dev for fastecdsa C extension
- rust-toolchain.toml: bump to 1.89 (required by dojo-utils transitive deps)
- requirements.txt: remove backports.asyncio.runner (incompatible with Python 3.12+)
- compose.yml / compose.e2e.yml / compose.l2.yml: update binary invocations
  (ops, persistent), healthcheck process name, and RUST_LOG module filters
- saya/core storage.rs: fix starknet_types_core::felt::Felt import path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Introduce TEE (Trusted Execution Environment) integration for the persistent-tee binary and saya-core:
- Add attestor, prover, prover_impl, settlement, and tee modules to persistent-tee
- Add TEE orchestrator, prover, and core tee modules to saya-core
- Extend block ingestor with polling support for TEE workflows
- Wire up TEE components in main entry point and lib exports

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
COPY ./programs /programs was broken on CI because programs/ is
gitignored and was never present in the checkout. Previously this
was a non-issue since compose.yml used a pre-built image; the local
build requirement was introduced on this branch.

Generate layout_bridge.json directly in the build stage using the
already-installed cairo-lang venv, eliminating the dependency on a
pre-populated programs/ directory. Also remove the unused SNOS_PROGRAM
env var since snos is no longer provided explicitly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Build with: docker build -t ghcr.io/dojoengine/saya:feat-tee .
Push with:  docker push ghcr.io/dojoengine/saya:feat-tee

Override with SAYA_IMAGE env var if needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add missing image to saya service in compose.yml
- Switch compose.e2e.yml from build-from-source to image reference
  so SAYA_IMAGE env var works end-to-end in CI
- Bump CI toolchain from 1.87 to 1.89 (matches rust-toolchain.toml)
- Update DEFAULT_PILTOVER_CLASS_HASH in ops constants
- Rename core-contract → ops in bin/ops/Cargo.lock
- Add cainome/piltover/sha3 deps to persistent-tee; move sha3 out of saya-core

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@chudkowsky
chudkowsky marked this pull request as ready for review March 25, 2026 13:35
chudkowsky and others added 4 commits March 25, 2026 14:44
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Prevents katana_init exit 101 caused by stale shared volume with
existing katana_config from a previous run.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…efault

- appc_msg_sn_deploy: add sleep 2 between declare and deploy to avoid
  nonce-not-updated race (same fix already present in sn_msg_deploy)
- katana_init: lower --settlement-contract-deployed-block default from 4
  to 1 to avoid ContractNotFound when deploy lands at a different block
  due to parallel service timing nondeterminism

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@chudkowsky
chudkowsky merged commit c7495d3 into main Mar 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant