Skip to content

feat(l2): integrate TDX as a prover #2777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 140 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
eb5918f
initial tdx impl
iovoid Apr 28, 2025
2cf8063
also compile quote-gen
iovoid Apr 28, 2025
18365b5
fix unchanged name
iovoid Apr 28, 2025
3aa614e
fetch tee deps on prepare time instead of build
iovoid Apr 28, 2025
2d9639f
use non-hardened kernel
iovoid Apr 28, 2025
85280b3
tdx qemu support for tooltree
iovoid Apr 28, 2025
1dd6182
also ignore image itself
iovoid Apr 28, 2025
60959f1
use correct qemu package
iovoid Apr 28, 2025
2085c61
fix quote generation and roothash
iovoid Apr 29, 2025
9b84f83
minimize partitions, add back cc
iovoid Apr 29, 2025
f8516d6
fix esp partition
iovoid Apr 29, 2025
ab0983f
fix tmp creation
iovoid Apr 29, 2025
73ecd10
add resolv.conf
iovoid Apr 29, 2025
69f7fb1
use extra trees instead of base
iovoid Apr 29, 2025
4b457f1
use cf/google dns
iovoid Apr 29, 2025
2b2825e
Merge branch 'main' into feat/tdx
iovoid Apr 29, 2025
f924970
add systemd service
iovoid Apr 29, 2025
aa27c82
add systemd service wantedby
iovoid Apr 29, 2025
b731332
enable systmd unit
iovoid Apr 30, 2025
0a21db0
improve demo
iovoid Apr 30, 2025
15df5b6
fix service
iovoid Apr 30, 2025
d1ce4b4
clean up
iovoid Apr 30, 2025
a069ce4
Merge branch 'main' into feat/tdx
iovoid Apr 30, 2025
3ebb50b
add part of sample contract
iovoid May 5, 2025
5925d81
update contracts
iovoid May 5, 2025
2c55563
also check tcb_status
iovoid May 5, 2025
8144e72
add signature-based quote generator
iovoid May 6, 2025
6358670
add additional verifications
iovoid May 6, 2025
3ef38f5
clean up cmdline args
iovoid May 6, 2025
4a6e782
add deployment script
iovoid May 6, 2025
d49cdd4
separate deploy and deploy-all
iovoid May 6, 2025
dfef655
stop using forge
iovoid May 7, 2025
0310c52
use http for quote-gen
iovoid May 7, 2025
4f346ca
update vm definitions
iovoid May 7, 2025
70cd6ab
add quote pusher
iovoid May 7, 2025
cebd586
quickfix for duplicate field error
iovoid May 7, 2025
49ec8ec
fix Counter deploy
iovoid May 7, 2025
ba2da1a
fix schema and get
iovoid May 7, 2025
4a34e6e
fix type error
iovoid May 7, 2025
e1c2ab1
fmt
iovoid May 7, 2025
5f31bce
first update certificates if needed
iovoid May 7, 2025
632448a
add example .env
iovoid May 7, 2025
0ff873c
fix tool usage
iovoid May 7, 2025
a830d3a
refer to path explicitly
iovoid May 7, 2025
3fb9544
include instead of excluding, since excluding does not work well
iovoid May 7, 2025
44291be
init cloned repo's submodules
iovoid May 7, 2025
afa9726
hack dependency into being a workspace instead of including transitively
iovoid May 7, 2025
902a239
use clone, the submodule is configured to use ssh
iovoid May 7, 2025
ec428ff
delete cargo.toml of dep
iovoid May 7, 2025
85aa709
update tool path
iovoid May 7, 2025
5a0e32b
update .env
iovoid May 7, 2025
fee7843
update RTMR values
iovoid May 7, 2025
38cad62
fix json parsing and workspacing
iovoid May 7, 2025
e5e98f1
fix response param names
iovoid May 7, 2025
321ccbe
fix signature
iovoid May 7, 2025
1f78468
construct u256 by value, not bytes
iovoid May 7, 2025
d697835
add tests
iovoid May 7, 2025
283a5e9
fix tests
iovoid May 8, 2025
fe32e7f
remove empty .gitmodules
iovoid May 8, 2025
11013d0
add integration-test recipe
iovoid May 8, 2025
5cca63c
split away tests due to large test vectors
iovoid May 8, 2025
daca048
add some contract docs
iovoid May 8, 2025
11ceb2f
switch from cast to rex
iovoid May 8, 2025
25d0584
remove forge from dependencies
iovoid May 9, 2025
df77a2c
fmt
iovoid May 9, 2025
94079a0
fmt
iovoid May 9, 2025
80295fc
fix unused import
iovoid May 9, 2025
00521fb
fix unused import
iovoid May 9, 2025
c8de57c
disallow login to tdx guest
iovoid May 9, 2025
d55e67d
remove misc files from image
iovoid May 9, 2025
db551bf
update TDX measurements
iovoid May 9, 2025
08ee2d2
update test vector
iovoid May 9, 2025
0ba558e
update measurements
iovoid May 9, 2025
e2d7698
fmt&clippy
iovoid May 12, 2025
eba7b7f
Update docs
iovoid May 12, 2025
727d94b
Document the testing command
iovoid May 12, 2025
2bc368e
skip integration test outside correct environment
iovoid May 12, 2025
486ff88
Merge branch 'main' into feat/tdx-signature
iovoid May 13, 2025
0792fdd
Merge branch 'main' into feat/tdx-signature
iovoid May 13, 2025
73b89c8
undo workaround
iovoid May 13, 2025
15a8a9b
undo workaround
iovoid May 13, 2025
b0259ee
add TDX prover base
iovoid May 13, 2025
2eb8248
import the whole ethrex project for building
iovoid May 14, 2025
ea019dc
bring the correct deps
iovoid May 14, 2025
398c7c2
fix module name
iovoid May 14, 2025
4074bc8
guestfwd prover coordinator port
iovoid May 14, 2025
a6e8215
fix comms
iovoid May 14, 2025
b64b39c
use netcat for guestfwd
iovoid May 14, 2025
3e521b3
select netcat package
iovoid May 14, 2025
d72d1dd
drop network isolation, half-close is incompatible with qemu
iovoid May 14, 2025
3f33314
add some setup logic
iovoid May 14, 2025
821ba41
Merge branch 'main' into feat/tdx-integration
iovoid May 14, 2025
4b33a01
Merge branch 'main' into feat/tdx-integration
iovoid May 14, 2025
7207ee2
add some tdx proof sending logic
iovoid May 14, 2025
d745502
Merge branch 'main' into feat/tdx-integration
iovoid May 14, 2025
34146a9
fmt
iovoid May 14, 2025
0f43058
update contracts
iovoid May 15, 2025
1040020
fix contracts
iovoid May 15, 2025
dd13ca1
implement working dev_mode
iovoid May 15, 2025
ea15b22
fmt
iovoid May 15, 2025
e9e931c
implement deployment, ci
iovoid May 16, 2025
b7f4f8b
fmt&clippy
iovoid May 16, 2025
52dd10d
Merge branch 'main' into feat/tdx-integration
iovoid May 16, 2025
e4e6fbb
update CI workflow
iovoid May 16, 2025
f298952
fix CI folder path
iovoid May 16, 2025
2a95d58
also remove spinner fromt tdx part
iovoid May 16, 2025
294109f
remove duplicated step
iovoid May 16, 2025
5a0c544
fix sleep timer
iovoid May 16, 2025
b787e8d
fix l2 build cmd
iovoid May 16, 2025
26a5089
fmt
iovoid May 16, 2025
5b13340
use rust 1.85.0 because rex requires it
iovoid May 16, 2025
ed109eb
install solc
iovoid May 16, 2025
cc6f53c
Merge branch 'main' into feat/tdx-integration
iovoid May 16, 2025
539e7e6
merge sequencer and test steps
iovoid May 16, 2025
0075e43
killing quote-gen is not needed
iovoid May 16, 2025
b7a0bcd
deploy in dev mode
iovoid May 16, 2025
c6a0838
remove useless file
iovoid May 16, 2025
513d45e
update measurements
iovoid May 16, 2025
c293d08
fix typo in save_state
iovoid May 16, 2025
c25ec8f
only allow sequencer to update tdx key
iovoid May 19, 2025
8ceb815
Merge branch 'main' into feat/tdx-integration
iovoid May 19, 2025
f4004e2
update measurements and fix
iovoid May 19, 2025
63f047a
fix misformat
iovoid May 19, 2025
4986f93
re-silence
iovoid May 19, 2025
3ef6e33
update docs
iovoid May 19, 2025
0008e89
update measurements
iovoid May 19, 2025
264c4cf
update docs
iovoid May 19, 2025
efe724d
update docs
iovoid May 20, 2025
ed6de13
Merge branch 'main' into feat/tdx-integration
iovoid May 20, 2025
d865a5f
fix rpc_url
iovoid May 20, 2025
d080c36
fix rpc_url
iovoid May 20, 2025
7366582
fmt
iovoid May 20, 2025
a5b619f
use 0 watcher delay
iovoid May 20, 2025
8a31113
remove block production interval in tdx ci
iovoid May 20, 2025
438f818
sync quote-gen proving time with default
iovoid May 20, 2025
4f11669
Merge branch 'main' into feat/tdx-integration
iovoid May 20, 2025
19a8fa8
try adding delay to test
iovoid May 21, 2025
12136e1
move delay
iovoid May 21, 2025
5e3efa1
fix typo in variable name
iovoid May 21, 2025
8ec2923
make PROOF_COORDINATOR_ADDRESS easier to override
iovoid May 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/pr-main_l2_tdx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: L2 Prover (TDX)
on:
push:
branches: ["main"]
pull_request:
branches: ["**"]
paths:
- "crates/l2/tee/**"
- "crates/l2/contracts/**"
- "test_data/**"
- "crates/blockchain/dev/**"
- ".github/workflows/pr-main_l2_tdx.yaml"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
lint:
# "Lint" is a required check, don't change the name
name: Lint
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Add Rust Cache
uses: Swatinem/rust-cache@v2
- name: Check exec
run: |
cd crates/l2/tee/quote-gen
cargo check
- name: Clippy exec
run: |
cd crates/l2/tee/quote-gen
cargo clippy --all-targets

test:
# "Test" is a required check, don't change the name
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Rust toolchain install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.85.0

- name: Install solc
uses: pontem-network/get-solc@master
with:
version: v0.8.29

- name: Set up Rust cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"

- name: Build prover
run: |
cd crates/l2/tee/quote-gen
cargo build --release

- name: Build test
run: |
cargo test l2 --no-run --release

- name: Build L2
run: |
cargo build --release --bin ethrex --features l2,rollup_storage_libmdbx,metrics

- name: Install rex
run: |
cd /tmp
git clone https://github.com/lambdaclass/rex
cd rex
cargo build --release
cp target/release/rex /usr/local/bin

- name: Run L1 and deploy
run: |
cd crates/l2
touch .env
make init-local-l1;
ETHREX_DEPLOYER_DEPLOY_RICH=true \
ETHREX_DEPLOYER_TDX_DEPLOY_VERIFIER=true \
ETHREX_TDX_DEV_MODE=true \
make deploy-l1

- name: Start Sequencer and test
run: |
cd crates/l2
ETHREX_PROOF_COORDINATOR_DEV_MODE=false \
ETHREX_WATCHER_BLOCK_DELAY=0 \
make init-l2 &
sleep 30
ETHREX_TDX_DEV_MODE=true tee/quote-gen/target/release/quote-gen &
PROPOSER_COINBASE_ADDRESS=0x0007a881CD95B1484fca47615B64803dad620C8d cargo test l2 --release -- --nocapture --test-threads=1

16 changes: 0 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ members = [
"crates/l2/prover/bench",
"crates/l2/sdk",
"crates/l2/storage",
"crates/l2/tee/quote-pusher",
"crates/networking/p2p",
"crates/networking/rpc",
"crates/storage",
Expand Down
3 changes: 3 additions & 0 deletions crates/l2/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
store/

solc_out

# qpl-tool temp files
out/
8 changes: 6 additions & 2 deletions crates/l2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ init-testnet: update-system-contracts deploy-l1-testnet init-l2
down: down-local-l1 down-l2 down-metrics## 🛑 Shuts down the localnet

clean: clean-contract-deps ## 🧹 Cleans the localnet
rm -rf out/

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

Expand Down Expand Up @@ -63,7 +64,7 @@ L2_PORT=1729
L1_AUTH_PORT=8551
L1_RPC_ADDRESS=0.0.0.0
L2_RPC_ADDRESS=0.0.0.0
PROOF_COORINATOR_ADDRESS=127.0.0.1
PROOF_COORDINATOR_ADDRESS?=127.0.0.1

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

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

Expand All @@ -119,6 +121,7 @@ deploy-l1: ## 📜 Deploys the L1 contracts
--sp1.verifier-address 0x00000000000000000000000000000000000000aa \
--pico.verifier-address 0x00000000000000000000000000000000000000aa \
--risc0.verifier-address 0x00000000000000000000000000000000000000aa \
--tdx.verifier-address 0x00000000000000000000000000000000000000aa \
--on-chain-proposer-owner 0x03d0a0aee676cc45bf7032649e0871927c947c8e \
--bridge-owner 0x03d0a0aee676cc45bf7032649e0871927c947c8e \
--deposit-rich
Expand Down Expand Up @@ -147,6 +150,7 @@ init-l2-no-metrics: ## 🚀 Initializes an L2 Lambda ethrex Client
FEATURES="metrics,based"; \
echo "Running ethrex L2 with based"; \
fi; \
export $(shell cat .env | xargs); \
cargo run --release --manifest-path ../../Cargo.toml --bin ethrex --features $$FEATURES -- \
l2 init \
--watcher.block-delay 0 \
Expand All @@ -159,7 +163,7 @@ init-l2-no-metrics: ## 🚀 Initializes an L2 Lambda ethrex Client
--datadir ${ethrex_L2_DEV_LIBMDBX} \
--bridge-address ${BRIDGE_ADDRESS} \
--on-chain-proposer-address ${ON_CHAIN_PROPOSER_ADDRESS} \
--proof-coordinator-listen-ip ${PROOF_COORINATOR_ADDRESS}
--proof-coordinator-listen-ip ${PROOF_COORDINATOR_ADDRESS}

init-metrics: ## 🚀 Initializes Grafana and Prometheus with containers
docker compose -f ${ethrex_METRICS_DOCKER_COMPOSE_PATH} -f ${ethrex_METRICS_OVERRIDES_L2_DOCKER_COMPOSE_PATH} up -d
Expand Down
25 changes: 25 additions & 0 deletions crates/l2/contracts/bin/deployer/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,26 @@ pub struct DeployerOptions {
help = "If set to true, it will deploy the contract and override the address above with the deployed one.",
)]
pub sp1_deploy_verifier: bool,
#[arg(
long = "tdx.verifier-address",
value_name = "ADDRESS",
env = "ETHREX_DEPLOYER_TDX_CONTRACT_VERIFIER",
required_if_eq("tdx_deploy_verifier", "false"),
help_heading = "Deployer options",
help = "If set to 0xAA skip proof verification -> Only use in dev mode."
)]
pub tdx_verifier_address: Option<Address>,
#[arg(
long = "tdx.deploy-verifier",
default_value = "false",
value_name = "BOOLEAN",
action = ArgAction::SetTrue,
env = "ETHREX_DEPLOYER_TDX_DEPLOY_VERIFIER",
required_unless_present = "tdx_verifier_address",
help_heading = "Deployer options",
help = "If set to true, it will deploy the contract and override the address above with the deployed one.",
)]
pub tdx_deploy_verifier: bool,
#[arg(
long,
default_value = "false",
Expand Down Expand Up @@ -290,6 +310,11 @@ impl Default for DeployerOptions {
0x00, 0x00, 0x00, 0x00, 0x00, 0xaa,
])),
sp1_deploy_verifier: false,
tdx_verifier_address: Some(H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xaa,
])),
tdx_deploy_verifier: false,
randomize_contract_deployment: false,
validium: false,
// 0x03d0a0aee676cc45bf7032649e0871927c947c8e
Expand Down
Loading
Loading