Skip to content

Commit 843177d

Browse files
committed
feat(l2): integrate TDX as a prover (#2777)
**Motivation** In #2677 an example of a TDX-based prover was made. This uses the example code to add a prover. **Description** TDX is added as another prover, and made to use the same API
1 parent ac8eb45 commit 843177d

39 files changed

+2981
-1519
lines changed

.github/workflows/pr-main_l2_tdx.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: L2 Prover (TDX)
2+
on:
3+
push:
4+
branches: ["main"]
5+
pull_request:
6+
branches: ["**"]
7+
paths:
8+
- "crates/l2/tee/**"
9+
- "crates/l2/contracts/**"
10+
- "test_data/**"
11+
- "crates/blockchain/dev/**"
12+
- ".github/workflows/pr-main_l2_tdx.yaml"
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
lint:
20+
# "Lint" is a required check, don't change the name
21+
name: Lint
22+
runs-on: ubuntu-latest
23+
strategy:
24+
fail-fast: true
25+
steps:
26+
- name: Checkout sources
27+
uses: actions/checkout@v4
28+
- name: Add Rust Cache
29+
uses: Swatinem/rust-cache@v2
30+
- name: Check exec
31+
run: |
32+
cd crates/l2/tee/quote-gen
33+
cargo check
34+
- name: Clippy exec
35+
run: |
36+
cd crates/l2/tee/quote-gen
37+
cargo clippy --all-targets
38+
39+
test:
40+
# "Test" is a required check, don't change the name
41+
name: Test
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout sources
45+
uses: actions/checkout@v4
46+
47+
- name: Rust toolchain install
48+
uses: dtolnay/rust-toolchain@stable
49+
with:
50+
toolchain: 1.85.0
51+
52+
- name: Install solc
53+
uses: pontem-network/get-solc@master
54+
with:
55+
version: v0.8.29
56+
57+
- name: Set up Rust cache
58+
uses: Swatinem/rust-cache@v2
59+
with:
60+
cache-on-failure: "true"
61+
62+
- name: Build prover
63+
run: |
64+
cd crates/l2/tee/quote-gen
65+
cargo build --release
66+
67+
- name: Build test
68+
run: |
69+
cargo test l2 --no-run --release
70+
71+
- name: Build L2
72+
run: |
73+
cargo build --release --bin ethrex --features l2,rollup_storage_libmdbx,metrics
74+
75+
- name: Install rex
76+
run: |
77+
cd /tmp
78+
git clone https://github.com/lambdaclass/rex
79+
cd rex
80+
cargo build --release
81+
cp target/release/rex /usr/local/bin
82+
83+
- name: Run L1 and deploy
84+
run: |
85+
cd crates/l2
86+
touch .env
87+
make init-local-l1;
88+
ETHREX_DEPLOYER_DEPLOY_RICH=true \
89+
ETHREX_DEPLOYER_TDX_DEPLOY_VERIFIER=true \
90+
ETHREX_TDX_DEV_MODE=true \
91+
make deploy-l1
92+
93+
- name: Start Sequencer and test
94+
run: |
95+
cd crates/l2
96+
ETHREX_PROOF_COORDINATOR_DEV_MODE=false \
97+
ETHREX_WATCHER_BLOCK_DELAY=0 \
98+
make init-l2 &
99+
sleep 30
100+
ETHREX_TDX_DEV_MODE=true tee/quote-gen/target/release/quote-gen &
101+
PROPOSER_COINBASE_ADDRESS=0x0007a881CD95B1484fca47615B64803dad620C8d cargo test l2 --release -- --nocapture --test-threads=1
102+

Cargo.lock

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ members = [
1818
"crates/l2/prover/bench",
1919
"crates/l2/sdk",
2020
"crates/l2/storage",
21-
"crates/l2/tee/quote-pusher",
2221
"crates/networking/p2p",
2322
"crates/networking/rpc",
2423
"crates/storage",

crates/l2/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
store/
44

55
solc_out
6+
7+
# qpl-tool temp files
8+
out/

crates/l2/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ init-testnet: update-system-contracts deploy-l1-testnet init-l2
2020
down: down-local-l1 down-l2 down-metrics## 🛑 Shuts down the localnet
2121

2222
clean: clean-contract-deps ## 🧹 Cleans the localnet
23+
rm -rf out/
2324

2425
restart: restart-local-l1 deploy-l1 purge_prover_state restart-l2 ## 🔄 Restarts the localnet
2526

@@ -63,7 +64,7 @@ L2_PORT=1729
6364
L1_AUTH_PORT=8551
6465
L1_RPC_ADDRESS=0.0.0.0
6566
L2_RPC_ADDRESS=0.0.0.0
66-
PROOF_COORINATOR_ADDRESS=127.0.0.1
67+
PROOF_COORDINATOR_ADDRESS?=127.0.0.1
6768

6869
# Matches the ports used by the blockchain/metrics dir
6970
L2_PROMETHEUS_METRICS_PORT = 3702
@@ -107,6 +108,7 @@ rm-db-l1: ## 🛑 Removes the DB used by the L1
107108
clean-contract-deps: ## 🧹 Cleans the dependencies for the L1 contracts.
108109
rm -rf contracts/solc_out
109110
rm -rf contracts/lib
111+
cd tee/contracts; make clean
110112

111113
restart-contract-deps: clean-contract-deps ## 🔄 Restarts the dependencies for the L1 contracts.
112114

@@ -119,6 +121,7 @@ deploy-l1: ## 📜 Deploys the L1 contracts
119121
--sp1.verifier-address 0x00000000000000000000000000000000000000aa \
120122
--pico.verifier-address 0x00000000000000000000000000000000000000aa \
121123
--risc0.verifier-address 0x00000000000000000000000000000000000000aa \
124+
--tdx.verifier-address 0x00000000000000000000000000000000000000aa \
122125
--on-chain-proposer-owner 0x03d0a0aee676cc45bf7032649e0871927c947c8e \
123126
--bridge-owner 0x03d0a0aee676cc45bf7032649e0871927c947c8e \
124127
--deposit-rich
@@ -147,6 +150,7 @@ init-l2-no-metrics: ## 🚀 Initializes an L2 Lambda ethrex Client
147150
FEATURES="metrics,based"; \
148151
echo "Running ethrex L2 with based"; \
149152
fi; \
153+
export $(shell cat .env | xargs); \
150154
cargo run --release --manifest-path ../../Cargo.toml --bin ethrex --features $$FEATURES -- \
151155
l2 init \
152156
--watcher.block-delay 0 \
@@ -159,7 +163,7 @@ init-l2-no-metrics: ## 🚀 Initializes an L2 Lambda ethrex Client
159163
--datadir ${ethrex_L2_DEV_LIBMDBX} \
160164
--bridge-address ${BRIDGE_ADDRESS} \
161165
--on-chain-proposer-address ${ON_CHAIN_PROPOSER_ADDRESS} \
162-
--proof-coordinator-listen-ip ${PROOF_COORINATOR_ADDRESS}
166+
--proof-coordinator-listen-ip ${PROOF_COORDINATOR_ADDRESS}
163167

164168
init-metrics: ## 🚀 Initializes Grafana and Prometheus with containers
165169
docker compose -f ${ethrex_METRICS_DOCKER_COMPOSE_PATH} -f ${ethrex_METRICS_OVERRIDES_L2_DOCKER_COMPOSE_PATH} up -d

crates/l2/contracts/bin/deployer/cli.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,26 @@ pub struct DeployerOptions {
194194
help = "If set to true, it will deploy the contract and override the address above with the deployed one.",
195195
)]
196196
pub sp1_deploy_verifier: bool,
197+
#[arg(
198+
long = "tdx.verifier-address",
199+
value_name = "ADDRESS",
200+
env = "ETHREX_DEPLOYER_TDX_CONTRACT_VERIFIER",
201+
required_if_eq("tdx_deploy_verifier", "false"),
202+
help_heading = "Deployer options",
203+
help = "If set to 0xAA skip proof verification -> Only use in dev mode."
204+
)]
205+
pub tdx_verifier_address: Option<Address>,
206+
#[arg(
207+
long = "tdx.deploy-verifier",
208+
default_value = "false",
209+
value_name = "BOOLEAN",
210+
action = ArgAction::SetTrue,
211+
env = "ETHREX_DEPLOYER_TDX_DEPLOY_VERIFIER",
212+
required_unless_present = "tdx_verifier_address",
213+
help_heading = "Deployer options",
214+
help = "If set to true, it will deploy the contract and override the address above with the deployed one.",
215+
)]
216+
pub tdx_deploy_verifier: bool,
197217
#[arg(
198218
long,
199219
default_value = "false",
@@ -290,6 +310,11 @@ impl Default for DeployerOptions {
290310
0x00, 0x00, 0x00, 0x00, 0x00, 0xaa,
291311
])),
292312
sp1_deploy_verifier: false,
313+
tdx_verifier_address: Some(H160([
314+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
315+
0x00, 0x00, 0x00, 0x00, 0x00, 0xaa,
316+
])),
317+
tdx_deploy_verifier: false,
293318
randomize_contract_deployment: false,
294319
validium: false,
295320
// 0x03d0a0aee676cc45bf7032649e0871927c947c8e

0 commit comments

Comments
 (0)