Skip to content

Commit 7c90221

Browse files
committed
initial example with light client
1 parent a4047a6 commit 7c90221

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*~

lightclient/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
TEE Coprocessors in Dstack
2+
=====
3+
4+
Minimal docker file for using the Helios light client to provide a trustworthy view of the blockchain.
5+
6+
You can run this locally - it will output an empty attestation if it's not in a TEE. To run this on Dstack, you can simply copy paste the docker-compose.yml and specify your ETH_RPC_URL parameter.
7+
8+
The provided docker compose uses holesky. Helios currently supports other Eth testnetworks as well as opstack.
9+
10+
This relies on an untrusted RPC, so you need to provide your own `ETH_RPC_URL`. The free trial at quicknode.com works fine.
11+
12+
Run with:
13+
```bash
14+
docker compose build
15+
docker compose run --rm -e ETH_RPC_URL=${ETH_RPC_URL} tapp
16+
```
17+
18+
Expected output:
19+
```
20+
+] Creating 1/1
21+
✔ Network lightclient_default Created 0.1s
22+
2024-12-17T21:52:56.084201Z INFO helios::rpc: rpc server started at 127.0.0.1:8545
23+
2024-12-17T21:52:57.858077Z INFO helios::consensus: sync committee updated
24+
2024-12-17T21:52:57.941169Z INFO helios::consensus: sync committee updated
25+
2024-12-17T21:52:58.420835Z INFO helios::consensus: finalized slot slot=3214080 confidence=92.38% age=00:00:16:58
26+
2024-12-17T21:52:58.420854Z INFO helios::consensus: updated head slot=3214163 confidence=92.38% age=00:00:00:22
27+
2024-12-17T21:52:58.420859Z INFO helios::consensus: consensus client in sync with checkpoint: 0x9260657ed4167f2bbe57317978ff181b6b96c1065ecf9340bba05ba3578128fe
28+
29+
30+
baseFeePerGas 8
31+
difficulty 0
32+
extraData 0x444556434f4e20505245434f4e4653
33+
gasLimit 30000000
34+
...
35+
0x5adfa31d8bcaae1b27bf8c6d2d6eb0108f3dc8ec35dc8ffaa5b8326e3eab475b
36+
0x58025835a1943c458e444fbd39d7f776132cd82892b9f2f17218de5b29aa8b8e
37+
]
38+
ATTEST=...
39+
```
40+
41+
Acknowledgments
42+
###
43+
Thanks [@fucory](https://x.com/fucory) and [@kassandraETH](https://x.com/kassandraETH) for the suggestions

lightclient/docker-compose.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
version: "3.9"
2+
services:
3+
tapp:
4+
configs:
5+
- source: run.sh
6+
target: /root/run.sh
7+
volumes:
8+
- /var/run/tappd.sock:/var/run/tappd.sock
9+
build:
10+
dockerfile_inline: |
11+
FROM ubuntu:22.04
12+
RUN apt-get update && apt install -y curl wget
13+
WORKDIR /root
14+
15+
# Foundry
16+
RUN wget https://github.com/foundry-rs/foundry/releases/download/nightly-c3069a50ba18cccfc4e7d5de9b9b388811d9cc7b/foundry_nightly_linux_amd64.tar.gz
17+
RUN tar -xzf ./foundry_nightly_linux_amd64.tar.gz -C /usr/local/bin
18+
19+
# Helios
20+
RUN curl -L 'https://github.com/a16z/helios/releases/download/0.7.0/helios_linux_amd64.tar.gz' | tar -xzC .
21+
22+
CMD [ "bash", "/root/run.sh" ]
23+
24+
configs:
25+
run.sh:
26+
content: |
27+
# First run Helios in the background
28+
# Provide a reasonable checkpoint.
29+
(
30+
/root/helios ethereum --network=holesky --checkpoint 0x9260657ed4167f2bbe57317978ff181b6b96c1065ecf9340bba05ba3578128fe \
31+
--consensus-rpc http://testing.holesky.beacon-api.nimbus.team --execution-rpc $${ETH_RPC_URL}
32+
) &
33+
34+
# Let it sync #TODO do this smarter
35+
sleep 5
36+
37+
# Then run some queries. This would be a good place to run an api server.
38+
# Cast <-> Helios <-> Untrusted RPCs
39+
cast block --rpc-url=localhost:8545 | tee response.txt
40+
41+
# Fetch the quote
42+
HASH=$$(sha256sum response.txt)
43+
PAYLOAD="{\"report_data\": \"$$(echo -n $$HASH | od -A n -t x1 | tr -d ' \n')\"}"
44+
ATTEST=$$(curl -X POST --unix-socket /var/run/tappd.sock -d "$$PAYLOAD" http://localhost/prpc/Tappd.TdxQuote?json)
45+
# TODO: Fallback to the dummy remote attestation
46+
47+
echo ATTEST=$${ATTEST} >> response.txt
48+
cat response.txt

0 commit comments

Comments
 (0)