This repository contains the off-chain operator blueprint implementation for the Phala Cloud Actively Validated Service (AVS) built on EigenLayer.
The Phala Cloud AVS aims to provide a decentralized cloud computing network where:
- Providers (Operators) run TEE-secured (Trusted Execution Environment, e.g., Intel TDX) compute nodes and register with the AVS.
- Stakers delegate PHA tokens (or potentially other LSTs via EigenLayer restaking) to operators.
- Operators are rewarded for maintaining Service Level Agreements (SLA), primarily liveness and availability, verified through TEE attestations and potentially on-chain challenges.
- Users can deploy workloads onto the provider network.
- Rewards (from a Phala Reward Pool) and potential slashing are managed through the EigenLayer framework and custom AVS smart contracts.
This specific blueprint focuses on the off-chain operator software that interacts with the EigenLayer contracts, the Phala AVS contracts, and the TEE environment to fulfill the operator's responsibilities.
It utilizes the Blueprint SDK to structure the off-chain service, leveraging Eigenlayer-specific components.
- Off-Chain Operator Service (Rust):
phala-tee-cloud-avs-lib
: Core logic including context management, job handlers (SLA checks, challenge responses), TEE interaction, and EVM communication.phala-tee-cloud-avs-bin
: Binary entrypoint that configures and runs the Blueprint service usingBlueprintRunner
.- Uses
alloy-rs
for EVM interactions andtokio
for asynchronous operations.
- On-Chain Contracts (Solidity):
contracts/
: Contains the Solidity smart contracts for the Phala AVS, including:PhalaServiceManager.sol
: Manages operator registration (via TEE attestations), handles reward proposals from the Tokenomic Manager, and interacts with the SLA Oracle.PhalaSlaOracle.sol
: Manages SLA challenges and operator responses, reporting failures to the Service Manager.
- Built using Foundry.
- EigenLayer Integration: Leverages EigenLayer's core contracts for staking, delegation, and reward coordination.
Before you can build and run this project, ensure you have the following installed:
- Rust (including
cargo
) - Foundry (including
forge
) - Docker (Potentially needed for TEE simulation/testing, depending on implementation)
-
Clone the repository:
git clone <repository-url> cd <repository-name>
-
Install Foundry dependencies:
forge soldeer update -d
-
Build the contracts:
forge build
-
Build the Rust blueprint service:
cargo build --release
- Contracts: Use
forge
commands (build
,test
,script
,deploy
) to manage the Solidity contracts. - Blueprint Service:
- Configure necessary environment variables (RPC endpoints, keystore paths, contract addresses, etc.). Refer to
BlueprintEnvironment
usage inmain.rs
. - Run the operator service:
cargo run --release --bin phala-tee-cloud-avs-bin
- Configure necessary environment variables (RPC endpoints, keystore paths, contract addresses, etc.). Refer to
- Testing:
- Run contract tests:
forge test
- Run Rust integration/e2e tests:
cargo test
(Note: E2E tests require Anvil and contract deployments, seetests/e2e.rs
)
- Run contract tests:
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.