Skip to content
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

feat(tee): introduce get_tee_proofs RPC method for TEE proofs #2474

Merged
merged 30 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f4b0580
feat(tee): add tee/get_proof endpoint to TEE Prover Gateway
pbeza Jul 24, 2024
402efe7
Get rid of .unwrap() in TEE proof generation DAL
pbeza Jul 25, 2024
3e3ef00
Fix a typo in the proof_data_handler endpoint
pbeza Jul 25, 2024
1d51ee0
Merge remote-tracking branch 'origin/main' into tee/attestation_fetcher
pbeza Jul 25, 2024
45cd290
Add unit test
pbeza Jul 26, 2024
7f4b859
Merge remote-tracking branch 'origin/main' into tee/attestation_fetcher
pbeza Jul 26, 2024
cea2cf9
Restructure db tables for TEE proof generation
pbeza Jul 29, 2024
90f4a07
One proof instance per batch number per TEE type
pbeza Jul 31, 2024
96142e8
Merge remote-tracking branch 'origin/main' into tee/attestation_fetcher
pbeza Jul 31, 2024
f9e9cdb
Fix SQL query (identified by unit test)
pbeza Aug 1, 2024
cb69c23
Merge remote-tracking branch 'origin/main' into tee/attestation_fetcher
pbeza Aug 1, 2024
ab382d1
Simplify code
pbeza Aug 1, 2024
4c95d0b
Update docs (Mermaid diagram)
pbeza Aug 1, 2024
8e3ac82
Merge remote-tracking branch 'origin/main' into tee/attestation_fetcher
pbeza Aug 5, 2024
aa9d363
Fix docs
pbeza Aug 5, 2024
50a65c9
fixup! Fix docs
pbeza Aug 5, 2024
6e5d39f
Fix db migrations
pbeza Aug 5, 2024
ab300c9
fixup! Fix db migrations
pbeza Aug 5, 2024
962007f
fixup! Fix db migrations
pbeza Aug 6, 2024
e2b3dce
Merge remote-tracking branch 'origin/main' into tee/attestation_fetcher
pbeza Aug 6, 2024
bd6d373
Merge remote-tracking branch 'origin/main' into tee/attestation_fetcher
pbeza Aug 7, 2024
328e9a1
Address @perekopskiy's code review comments
pbeza Aug 7, 2024
51e59a4
fixup! Address @perekopskiy's code review comments
pbeza Aug 7, 2024
cf27ac6
Merge remote-tracking branch 'origin/main' into tee/attestation_fetcher
pbeza Aug 7, 2024
5a063b9
Merge remote-tracking branch 'origin/main' into tee/attestation_fetcher
pbeza Aug 8, 2024
3caf0f1
Merge remote-tracking branch 'origin/main' into tee/attestation_fetcher
pbeza Aug 8, 2024
3aa30b2
Code review fix: idempotent SQL queries
pbeza Aug 8, 2024
787bc8d
fixup! Code review fix: idempotent SQL queries
pbeza Aug 8, 2024
caea7a5
Code review fix: single migration file
pbeza Aug 8, 2024
22b4dd3
Update docs
pbeza Aug 8, 2024
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
7 changes: 5 additions & 2 deletions core/bin/zksync_tee_prover/src/api_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ impl TeeApiClient {

/// Fetches the next job for the TEE prover to process, verifying and signing it if the
/// verification is successful.
pub async fn get_job(&self) -> Result<Option<Box<TeeVerifierInput>>, TeeProverError> {
let request = TeeProofGenerationDataRequest {};
pub async fn get_job(
&self,
tee_type: TeeType,
) -> Result<Option<Box<TeeVerifierInput>>, TeeProverError> {
let request = TeeProofGenerationDataRequest { tee_type };
let response = self
.post::<_, TeeProofGenerationDataResponse, _>("/tee/proof_inputs", request)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion core/bin/zksync_tee_prover/src/tee_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl TeeProver {
}

async fn step(&self) -> Result<Option<L1BatchNumber>, TeeProverError> {
match self.api_client.get_job().await? {
match self.api_client.get_job(self.tee_type).await? {
Some(job) => {
let (signature, batch_number, root_hash) = self.verify(*job)?;
self.api_client
Expand Down

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

This file was deleted.

This file was deleted.

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.

This file was deleted.

19 changes: 19 additions & 0 deletions core/lib/dal/doc/TeeProofGenerationDal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# TeeProofGenerationDal

## Table Name

`tee_proofs`

## `status` Diagram

```mermaid
---
title: Status Diagram
---
stateDiagram-v2
[*] --> ready_to_be_proven : insert_tee_proof_generation_job
ready_to_be_proven --> picked_by_prover : get_next_batch_to_be_proven
picked_by_prover --> generated : save_proof_artifacts_metadata
generated --> [*]

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE tee_verifier_input_producer_jobs ADD COLUMN picked_by TEXT;

ALTER TABLE tee_proof_generation_details DROP CONSTRAINT tee_proof_generation_details_pkey;
ALTER TABLE tee_proof_generation_details ALTER COLUMN tee_type DROP NOT NULL;
ALTER TABLE tee_proof_generation_details ADD PRIMARY KEY (l1_batch_number);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ALTER TABLE tee_verifier_input_producer_jobs DROP COLUMN picked_by;

ALTER TABLE tee_proof_generation_details DROP CONSTRAINT tee_proof_generation_details_pkey;
UPDATE tee_proof_generation_details SET tee_type = 'sgx' WHERE tee_type IS NULL;
ALTER TABLE tee_proof_generation_details ALTER COLUMN tee_type SET NOT NULL;
ALTER TABLE tee_proof_generation_details ALTER COLUMN l1_batch_number SET NOT NULL;
ALTER TABLE tee_proof_generation_details ADD PRIMARY KEY (l1_batch_number, tee_type);
1 change: 1 addition & 0 deletions core/lib/dal/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub mod storage_log;
pub mod storage_oracle_info;
pub mod storage_protocol_version;
pub mod storage_sync;
pub mod storage_tee_proof;
pub mod storage_transaction;
pub mod storage_verification_request;
pub mod storage_witness_job_info;
Expand Down
10 changes: 10 additions & 0 deletions core/lib/dal/src/models/storage_tee_proof.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use chrono::NaiveDateTime;

#[derive(Debug, Clone, sqlx::FromRow)]
pub struct StorageTeeProof {
pub pubkey: Option<Vec<u8>>,
pub signature: Option<Vec<u8>>,
pub proof: Option<Vec<u8>>,
pub updated_at: NaiveDateTime,
pub attestation: Option<Vec<u8>>,
}
Loading
Loading