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

fix(tee_verifier): correctly initialize storage for re-execution #3017

Merged
merged 48 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
e241949
fix(tee_verifier): correctly initialize storage for re-execution
haraldh Oct 2, 2024
fa06b18
fix: sql query
haraldh Oct 7, 2024
b615378
fix: remove obsolete `tee_type` check
haraldh Oct 7, 2024
39b4536
fix: clippy lint
haraldh Oct 7, 2024
ff3e6b2
Merge branch 'main' into tee_prover_new_2
haraldh Oct 7, 2024
5525997
Merge branch 'main' into tee_prover_new_2
haraldh Oct 7, 2024
b73e6e3
Merge branch 'main' into tee_prover_new_2
haraldh Oct 7, 2024
a96663a
fix: logic in tee_prover verify
haraldh Oct 8, 2024
d0b8e76
Merge branch 'main' into tee_prover_new_2
haraldh Oct 8, 2024
3a97168
fix: simplify SQL expression
haraldh Oct 9, 2024
77f44fd
feat(proof-data-handler): return 204 HTTP status code if no proofs ar…
pbeza Oct 8, 2024
5699299
WIP
pbeza Oct 9, 2024
70c82b6
Give up more comprehensive tests - need too complex mockups
pbeza Oct 9, 2024
e7c7840
fix: remove sort from sql query
haraldh Oct 8, 2024
f7e1caa
Merge remote-tracking branch 'origin/tee/feat/return-402-http-status-…
haraldh Oct 10, 2024
b93cf5d
Merge remote-tracking branch 'origin/main' into tee_prover_new_2
haraldh Oct 10, 2024
e6969d5
fix: remove L2ChainId from VMRunWitnessInputData
haraldh Oct 10, 2024
b07ba6b
fixup! fix: remove L2ChainId from VMRunWitnessInputData
haraldh Oct 10, 2024
ab23c8b
fixup! fixup! fix: remove L2ChainId from VMRunWitnessInputData
haraldh Oct 10, 2024
d852f31
fixup! fixup! fixup! fix: remove L2ChainId from VMRunWitnessInputData
haraldh Oct 10, 2024
3882898
Merge branch 'main' into tee_prover_new_2
haraldh Oct 10, 2024
2e043d4
Merge branch 'main' into tee_prover_new_2
haraldh Oct 10, 2024
8a7bd60
fixup! Merge remote-tracking branch 'origin/main' into tee_prover_new_2
haraldh Oct 10, 2024
8cb829e
Merge remote-tracking branch 'origin/tee_prover_new_2' into tee_prove…
haraldh Oct 10, 2024
8a59e0b
fix: don't use `Instrumented::new` when `.instrumented` can be used
haraldh Oct 10, 2024
fa42354
fix: merge extra match hand with already handled case
haraldh Oct 10, 2024
1087a8d
fix: use "500 Internal Server Error" for internal error
haraldh Oct 10, 2024
c521f52
fix: remove type annotation for readability
haraldh Oct 10, 2024
8556e52
fixup! fix: don't use `Instrumented::new` when `.instrumented` can be…
haraldh Oct 10, 2024
d908979
fixup! fix: merge extra match hand with already handled case
haraldh Oct 10, 2024
91cad42
fixup! fix(tee_verifier): correctly initialize storage for re-execution
haraldh Oct 10, 2024
76b5acf
Merge branch 'main' into tee_prover_new_2
haraldh Oct 10, 2024
fc30e5b
fix(migration): correct .down.sql script to ensure proper rollback
pbeza Oct 10, 2024
0122e62
fix: add a comment on storage in tee_verifier verify method
haraldh Oct 10, 2024
ab6e565
fix(tee-prover): simplify TeeProofGenerationDataResponse
pbeza Oct 10, 2024
e4264ee
Merge branch 'main' into tee_prover_new_2
haraldh Oct 11, 2024
3d77b90
Merge branch 'main' into tee_prover_new_2
haraldh Oct 11, 2024
e446fbd
Merge remote-tracking branch 'origin/tee/fix/simplify-TeeProofGenerat…
haraldh Oct 11, 2024
59f7756
fix: use connection_tagged()
haraldh Oct 16, 2024
01453f8
fix: error handling, if no job is available
haraldh Oct 16, 2024
bcaa6c5
fix: storage_log.kind is unused in match
haraldh Oct 16, 2024
c3d0833
Merge branch 'main' into tee_prover_new_2
haraldh Oct 16, 2024
beb3eef
fix: use NO_CONTENT instead of NOT_FOUND for no job
haraldh Oct 16, 2024
cb03ac8
fixup! fix: use NO_CONTENT instead of NOT_FOUND for no job
haraldh Oct 16, 2024
7e4c984
Merge branch 'main' into tee_prover_new_2
haraldh Oct 16, 2024
bf03aaf
Merge remote-tracking branch 'origin/main' into tee_prover_new_2
haraldh Oct 16, 2024
1d1b243
fixup! fix: use NO_CONTENT instead of NOT_FOUND for no job
haraldh Oct 17, 2024
cc8d14e
Merge branch 'main' into tee_prover_new_2
haraldh Oct 17, 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
25 changes: 4 additions & 21 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ members = [
"core/node/consensus",
"core/node/contract_verification_server",
"core/node/api_server",
"core/node/tee_verifier_input_producer",
"core/node/base_token_adjuster",
"core/node/external_proof_integration_api",
"core/node/logs_bloom_backfill",
Expand Down Expand Up @@ -309,6 +308,5 @@ zksync_node_storage_init = { version = "0.1.0", path = "core/node/node_storage_i
zksync_node_consensus = { version = "0.1.0", path = "core/node/consensus" }
zksync_contract_verification_server = { version = "0.1.0", path = "core/node/contract_verification_server" }
zksync_node_api_server = { version = "0.1.0", path = "core/node/api_server" }
zksync_tee_verifier_input_producer = { version = "0.1.0", path = "core/node/tee_verifier_input_producer" }
zksync_base_token_adjuster = { version = "0.1.0", path = "core/node/base_token_adjuster" }
zksync_logs_bloom_backfill = { version = "0.1.0", path = "core/node/logs_bloom_backfill" }
2 changes: 1 addition & 1 deletion core/bin/zksync_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct Cli {
/// Comma-separated list of components to launch.
#[arg(
long,
default_value = "api,tree,eth,state_keeper,housekeeper,tee_verifier_input_producer,commitment_generator,da_dispatcher,vm_runner_protective_reads"
haraldh marked this conversation as resolved.
Show resolved Hide resolved
default_value = "api,tree,eth,state_keeper,housekeeper,commitment_generator,da_dispatcher,vm_runner_protective_reads"
)]
components: ComponentsToRun,
/// Path to the yaml config. If set, it will be used instead of env vars.
Expand Down
13 changes: 1 addition & 12 deletions core/bin/zksync_server/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ use zksync_node_framework::{
main_batch_executor::MainBatchExecutorLayer, mempool_io::MempoolIOLayer,
output_handler::OutputHandlerLayer, RocksdbStorageOptions, StateKeeperLayer,
},
tee_verifier_input_producer::TeeVerifierInputProducerLayer,
vm_runner::{
bwip::BasicWitnessInputProducerLayer, playground::VmPlaygroundLayer,
protective_reads::ProtectiveReadsWriterLayer,
Expand Down Expand Up @@ -288,6 +287,7 @@ impl MainNodeBuilder {
self.node.add_layer(ProofDataHandlerLayer::new(
try_load_config!(self.configs.proof_data_handler_config),
self.genesis_config.l1_batch_commit_data_generator_mode,
self.genesis_config.l2_chain_id,
));
Ok(self)
}
Expand Down Expand Up @@ -493,14 +493,6 @@ impl MainNodeBuilder {
Ok(self)
}

fn add_tee_verifier_input_producer_layer(mut self) -> anyhow::Result<Self> {
self.node.add_layer(TeeVerifierInputProducerLayer::new(
self.genesis_config.l2_chain_id,
));

Ok(self)
}

fn add_da_client_layer(mut self) -> anyhow::Result<Self> {
let Some(da_client_config) = self.configs.da_client_config.clone() else {
tracing::warn!("No config for DA client, using the NoDA client");
Expand Down Expand Up @@ -727,9 +719,6 @@ impl MainNodeBuilder {
Component::EthTxManager => {
self = self.add_eth_tx_manager_layer()?;
}
Component::TeeVerifierInputProducer => {
self = self.add_tee_verifier_input_producer_layer()?;
}
Component::Housekeeper => {
self = self
.add_house_keeper_layer()?
Expand Down
36 changes: 17 additions & 19 deletions core/bin/zksync_tee_prover/src/api_client.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use reqwest::Client;
use reqwest::{Client, Response, StatusCode};
use secp256k1::{ecdsa::Signature, PublicKey};
use serde::{de::DeserializeOwned, Serialize};
use serde::Serialize;
use url::Url;
use zksync_basic_types::H256;
use zksync_prover_interface::{
api::{
RegisterTeeAttestationRequest, RegisterTeeAttestationResponse, SubmitTeeProofRequest,
SubmitTeeProofResponse, TeeProofGenerationDataRequest, TeeProofGenerationDataResponse,
},
api::{RegisterTeeAttestationRequest, SubmitTeeProofRequest, TeeProofGenerationDataRequest},
inputs::TeeVerifierInput,
outputs::L1BatchTeeProofForL1,
};
Expand All @@ -31,10 +28,9 @@ impl TeeApiClient {
}
}

async fn post<Req, Resp, S>(&self, endpoint: S, request: Req) -> Result<Resp, reqwest::Error>
async fn post<Req, S>(&self, endpoint: S, request: Req) -> Result<Response, reqwest::Error>
where
Req: Serialize + std::fmt::Debug,
Resp: DeserializeOwned,
S: AsRef<str>,
{
let url = self.api_base_url.join(endpoint.as_ref()).unwrap();
Expand All @@ -46,9 +42,7 @@ impl TeeApiClient {
.json(&request)
.send()
.await?
.error_for_status()?
.json::<Resp>()
.await
.error_for_status()
}

/// Registers the attestation quote with the TEE prover interface API, effectively proving that
Expand All @@ -63,8 +57,7 @@ impl TeeApiClient {
attestation: attestation_quote_bytes,
pubkey: public_key.serialize().to_vec(),
};
self.post::<_, RegisterTeeAttestationResponse, _>("/tee/register_attestation", request)
.await?;
self.post("/tee/register_attestation", request).await?;
tracing::info!(
"Attestation quote was successfully registered for the public key {}",
public_key
Expand All @@ -77,12 +70,17 @@ impl TeeApiClient {
pub async fn get_job(
&self,
tee_type: TeeType,
) -> Result<Option<Box<TeeVerifierInput>>, TeeProverError> {
) -> Result<Option<TeeVerifierInput>, TeeProverError> {
let request = TeeProofGenerationDataRequest { tee_type };
let response = self
.post::<_, TeeProofGenerationDataResponse, _>("/tee/proof_inputs", request)
.await?;
Ok(response.0)
let response = self.post("/tee/proof_inputs", request).await?;
match response.status() {
StatusCode::OK => Ok(Some(response.json::<TeeVerifierInput>().await?)),
StatusCode::NO_CONTENT => Ok(None),
_ => response
.json::<Option<TeeVerifierInput>>()
.await
.map_err(TeeProverError::Request),
}
}

/// Submits the successfully verified proof to the TEE prover interface API.
Expand All @@ -101,7 +99,7 @@ impl TeeApiClient {
tee_type,
}));
let observer = METRICS.proof_submitting_time.start();
self.post::<_, SubmitTeeProofResponse, _>(
self.post(
format!("/tee/submit_proofs/{batch_number}").as_str(),
request,
)
Expand Down
9 changes: 5 additions & 4 deletions core/bin/zksync_tee_prover/src/tee_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ impl TeeProver {
}

async fn step(&self, public_key: &PublicKey) -> Result<Option<L1BatchNumber>, TeeProverError> {
match self.api_client.get_job(self.config.tee_type).await? {
Some(job) => {
let (signature, batch_number, root_hash) = self.verify(*job)?;
match self.api_client.get_job(self.config.tee_type).await {
Ok(Some(job)) => {
let (signature, batch_number, root_hash) = self.verify(job)?;
self.api_client
.submit_proof(
batch_number,
Expand All @@ -104,10 +104,11 @@ impl TeeProver {
.await?;
Ok(Some(batch_number))
}
None => {
Ok(None) => {
tracing::trace!("There are currently no pending batches to be proven");
Ok(None)
}
Err(err) => Err(err),
}
}
}
Expand Down

This file was deleted.

This file was deleted.

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.

Loading
Loading