-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
…ce API (#1993) ## What ❔ This PR introduces three new endpoints to the prover interface API: 1. `/tee/proof_inputs` - for fetching input data for the TEE verifier. It is intended for TEE workers to obtain a batch to process. 2. `/tee/submit_proofs/<l1_batch_number>` - for submitting TEE proof. 3. `/tee/register_attestation` - for registering TEE attestation. The first two introduced API endpoints correspond to the existing, analogous `/proof_generation_data` and `/submit_proof/<l1_batch_number>` endpoints used for the ZK proofs. The state of batches (e.g., _proven_, _taken_, etc.) is tracked in the database. The `TeeVerifierInputProducer` generates serialized TEE prover inputs, which are then stored in the object store. To run the unit tests, you need to use the following command: `zk test rust --package zksync_proof_data_handler --lib tests`. Running `cargo test` directly fails because the `zk` command sets up an additional database for testing purposes. To test it manually, run the ZK server with the command: ``` zk server --components proof_data_handler --use-node-framework ``` and then send an HTTP request: - to get TEE verifier input data: ``` curl -X POST -H "Content-Type: application/json" --data-raw "{}" -vvv http://127.0.0.1:3320/tee/proof_inputs ``` To inspect the database for the TEE verifier input data jobs, run: ``` $ PGPASSWORD='notsecurepassword' psql -h 127.0.0.1 -p 5432 -U postgres # \c zksync_local # SELECT * FROM tee_verifier_input_producer_jobs; ``` - register TEE attestation: ``` curl -X POST -H "Content-Type: application/json" --data-raw '{ "attestation": [ 4, 3, 2, 1, 0 ], "pubkey": [ 5, 6, 7, 8, 9 ] }' -vvv http://127.0.0.1:3320/tee/register_attestation ``` To inspect the database for the TEE attestations, run: ``` $ PGPASSWORD='notsecurepassword' psql -h 127.0.0.1 -p 5432 -U postgres # \c zksync_local # SELECT * FROM tee_attestations; ``` - to submit TEE proof: ``` curl -X POST -H "Content-Type: application/json" --data-raw '{ "signature": [ 0, 1, 2, 3, 4 ], "pubkey": [ 5, 6, 7, 8, 9 ], "proof": [ 10, 11, 12, 13, 14 ] }' -vvv http://127.0.0.1:3320/tee/submit_proofs/1 ``` To inspect the database for the TEE proofs, run: ``` $ PGPASSWORD='notsecurepassword' psql -h 127.0.0.1 -p 5432 -U postgres # \c zksync_local # SELECT * FROM tee_proof_generation_details; ``` ## Why ❔ This PR contributes to the effort outlined in the docs: - https://www.notion.so/matterlabs/2FA-for-zk-rollups-with-TEEs-a2266138bd554fda8846e898fef75131?pvs=4 - https://www.notion.so/matterlabs/Proof-2F-verification-with-SGX-5fca2c619dd147938971cc00ae53e2b0?pvs=4 ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zk fmt` and `zk lint`. - [x] Spellcheck has been run via `zk spellcheck`.
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
DROP TABLE IF EXISTS tee_attestations; | ||
DROP TABLE IF EXISTS tee_proof_generation_details; | ||
|
||
DROP INDEX IF EXISTS idx_tee_proof_generation_details_status_prover_taken_at; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
CREATE TABLE IF NOT EXISTS tee_attestations | ||
( | ||
pubkey BYTEA PRIMARY KEY, | ||
attestation BYTEA | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS tee_proof_generation_details | ||
( | ||
l1_batch_number BIGINT PRIMARY KEY REFERENCES tee_verifier_input_producer_jobs (l1_batch_number) ON DELETE CASCADE, | ||
status TEXT NOT NULL, | ||
signature BYTEA, | ||
pubkey BYTEA REFERENCES tee_attestations (pubkey) ON DELETE SET NULL, | ||
proof BYTEA, | ||
tee_type TEXT, | ||
created_at TIMESTAMP NOT NULL, | ||
updated_at TIMESTAMP NOT NULL, | ||
prover_taken_at TIMESTAMP | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS idx_tee_proof_generation_details_status_prover_taken_at | ||
ON tee_proof_generation_details (prover_taken_at) | ||
WHERE status = 'picked_by_prover'; |