Phala Blockchain
Phala Network is a TEE-Blockchain hybrid architecture implementing Confidential Contract. This repo includes:
node/
: the main blockchain built on Substratephost/
: the bridge daemon to connect the blockchain and pRuntime
Overview
The blockchain is the central compoent of the system. It records commands (confidential contract invocation), serve as the pRuntime registray, runs the native token and on-chain governance modules.
pHost is a daemon program that connects the blockchain and the pRuntime. It passes the block data from the chain to pRuntime and passes pRuntime side effects back to the chain.
Related repos:
- phala-docs: The central repo for documentations.
- phala-pruntime: The cotract executor running inside TEE enclaves.
- phala-polka-apps: The Web UI and SDK to interact with confidential contract. Based on polkadot.js.
- plibra-grant-docker: The W3F M2 docker build with the blockchain, pHost and pRuntime.
File structure
.
├── LICENSE
├── README.md
├── node Blockchain node
├── pallets
│ └── phala Phala pallet
├── phost The bridge deamon "pHost"
├── pruntime pRuntime, the TEE kernel
├── ring Patched ring with wasm support
├── runtime Phala Substrate Runtime
└── scripts
├── console.sh Helper script to build & run the blockchain
└── init.sh
Docker bulid
Plase refer to plibra-grant-docker. It includes both the blockchain and pRuntime.
Native Build
Dependencies
Expand
-
Rust
curl https://sh.rustup.rs -sSf | sh
-
Substrate dependecies:
cd node sh ./scripts/init.sh
-
LLVM 10
wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh ./llvm.sh 10
Build the blockchain and bridge
Make sure you have Rust and LLVM-10 installed.
cargo build --release
The build script enforces LLVM-9 or newer is used. LLVM-9 is needed because of the wasm port of rust
crypto library, ring
. We have to compile the C code into wasm while keeping the compatibility with
the current rustc.
Run
-
Launch two local dev nodes Alice and Bob:
cd node ./scripts/console.sh start alice ./scripts/console.sh start bob
- The datadir is at
$HOME/tmp/(alice|bob)
- Can be purged by
./scripts/console.sh purge
- The WebUI can connect to Alice at port 9944.
- The datadir is at
-
Run pHost (please start pRuntime first):
cd phost ./target/release/phost
Run with tmuxp
You can launch the full stack (semi-automatically) by:
tmuxp load ./scripts/tmuxp/three-nodes.yaml
Or a 4-node testnet-poc2 setup:
CHAIN=poc2 tmuxp load ./scripts/tmuxp/four-nodes.yaml
tmuxp is a convinient tool that can bring up a tmux session with the preconfigured commands running in panes. To play with tmuxp, it also need a tmux installed.