From 6fbc5033e602f781be34f4e4aaa63c2276735b9e Mon Sep 17 00:00:00 2001 From: Patrick Beza Date: Thu, 24 Oct 2024 17:03:46 +0200 Subject: [PATCH] feat(proof-data-handler): add tee_proof_generation_timeout_in_secs param Add `tee_proof_generation_timeout_in_secs` parameter to the `proof-data-handler` configuration to not share the same `proof_generation_timeout_in_secs` timeout with the prover. --- core/lib/config/src/configs/proof_data_handler.rs | 8 ++++++++ core/lib/config/src/testonly.rs | 1 + core/lib/env_config/src/proof_data_handler.rs | 2 ++ core/lib/protobuf_config/src/proof_data_handler.rs | 7 +++++++ core/lib/protobuf_config/src/proto/config/prover.proto | 1 + core/node/proof_data_handler/src/tests.rs | 2 ++ etc/env/base/proof_data_handler.toml | 1 + etc/env/file_based/general.yaml | 1 + 8 files changed, 23 insertions(+) diff --git a/core/lib/config/src/configs/proof_data_handler.rs b/core/lib/config/src/configs/proof_data_handler.rs index 1094b1bb1801..ec94b76b9de2 100644 --- a/core/lib/config/src/configs/proof_data_handler.rs +++ b/core/lib/config/src/configs/proof_data_handler.rs @@ -9,6 +9,8 @@ pub struct TeeConfig { pub tee_support: bool, /// All batches before this one are considered to be processed. pub first_tee_processed_batch: L1BatchNumber, + /// Timeout for proof generation in TEE in seconds. + pub tee_proof_generation_timeout_in_secs: u16, } impl Default for TeeConfig { @@ -16,6 +18,8 @@ impl Default for TeeConfig { TeeConfig { tee_support: Self::default_tee_support(), first_tee_processed_batch: Self::default_first_tee_processed_batch(), + tee_proof_generation_timeout_in_secs: + Self::default_tee_proof_generation_timeout_in_secs(), } } } @@ -28,6 +32,10 @@ impl TeeConfig { pub fn default_first_tee_processed_batch() -> L1BatchNumber { L1BatchNumber(0) } + + pub fn default_tee_proof_generation_timeout_in_secs() -> u16 { + 600 + } } #[derive(Debug, Deserialize, Clone, PartialEq)] diff --git a/core/lib/config/src/testonly.rs b/core/lib/config/src/testonly.rs index 3bf4609bb700..8dc76e9b5a98 100644 --- a/core/lib/config/src/testonly.rs +++ b/core/lib/config/src/testonly.rs @@ -680,6 +680,7 @@ impl Distribution for EncodeDist { tee_config: configs::TeeConfig { tee_support: self.sample(rng), first_tee_processed_batch: L1BatchNumber(rng.gen()), + tee_proof_generation_timeout_in_secs: self.sample(rng), }, } } diff --git a/core/lib/env_config/src/proof_data_handler.rs b/core/lib/env_config/src/proof_data_handler.rs index b5bfda4544e7..47848585e769 100644 --- a/core/lib/env_config/src/proof_data_handler.rs +++ b/core/lib/env_config/src/proof_data_handler.rs @@ -28,6 +28,7 @@ mod tests { tee_config: TeeConfig { tee_support: true, first_tee_processed_batch: L1BatchNumber(1337), + tee_proof_generation_timeout_in_secs: 600, }, } } @@ -39,6 +40,7 @@ mod tests { PROOF_DATA_HANDLER_HTTP_PORT="3320" PROOF_DATA_HANDLER_TEE_SUPPORT="true" PROOF_DATA_HANDLER_FIRST_TEE_PROCESSED_BATCH="1337" + PROOF_DATA_HANDLER_TEE_PROOF_GENERATION_TIMEOUT_IN_SECS="600" "#; let mut lock = MUTEX.lock(); lock.set_env(config); diff --git a/core/lib/protobuf_config/src/proof_data_handler.rs b/core/lib/protobuf_config/src/proof_data_handler.rs index a587c702633f..c4bf62cb4ecb 100644 --- a/core/lib/protobuf_config/src/proof_data_handler.rs +++ b/core/lib/protobuf_config/src/proof_data_handler.rs @@ -23,6 +23,10 @@ impl ProtoRepr for proto::ProofDataHandler { .first_tee_processed_batch .map(|x| L1BatchNumber(x as u32)) .unwrap_or_else(configs::TeeConfig::default_first_tee_processed_batch), + tee_proof_generation_timeout_in_secs: self + .tee_proof_generation_timeout_in_secs + .map(|x| x as u16) + .unwrap_or_else(configs::TeeConfig::default_tee_proof_generation_timeout), }, }) } @@ -33,6 +37,9 @@ impl ProtoRepr for proto::ProofDataHandler { proof_generation_timeout_in_secs: Some(this.proof_generation_timeout_in_secs.into()), tee_support: Some(this.tee_config.tee_support), first_tee_processed_batch: Some(this.tee_config.first_tee_processed_batch.0 as u64), + tee_proof_generation_timeout_in_secs: Some( + this.tee_proof_generation_timeout_in_secs.into(), + ), } } } diff --git a/core/lib/protobuf_config/src/proto/config/prover.proto b/core/lib/protobuf_config/src/proto/config/prover.proto index 92ba770a7560..392834d25f3d 100644 --- a/core/lib/protobuf_config/src/proto/config/prover.proto +++ b/core/lib/protobuf_config/src/proto/config/prover.proto @@ -109,4 +109,5 @@ message ProofDataHandler { optional uint32 proof_generation_timeout_in_secs = 2; // required; s optional bool tee_support = 3; // optional optional uint64 first_tee_processed_batch = 4; // optional + optional uint32 tee_proof_generation_timeout_in_secs = 5; // optional } diff --git a/core/node/proof_data_handler/src/tests.rs b/core/node/proof_data_handler/src/tests.rs index 63ea087a81c4..87c6bff8a1f4 100644 --- a/core/node/proof_data_handler/src/tests.rs +++ b/core/node/proof_data_handler/src/tests.rs @@ -28,6 +28,7 @@ async fn request_tee_proof_inputs() { tee_config: TeeConfig { tee_support: true, first_tee_processed_batch: L1BatchNumber(0), + tee_proof_generation_timeout_in_secs: 600, }, }, L1BatchCommitmentMode::Rollup, @@ -86,6 +87,7 @@ async fn submit_tee_proof() { tee_config: TeeConfig { tee_support: true, first_tee_processed_batch: L1BatchNumber(0), + tee_proof_generation_timeout_in_secs: 600, }, }, L1BatchCommitmentMode::Rollup, diff --git a/etc/env/base/proof_data_handler.toml b/etc/env/base/proof_data_handler.toml index 7a1999a03c31..b56ac26fb177 100644 --- a/etc/env/base/proof_data_handler.toml +++ b/etc/env/base/proof_data_handler.toml @@ -1,4 +1,5 @@ [proof_data_handler] http_port = 3320 proof_generation_timeout_in_secs = 18000 +tee_proof_generation_timeout_in_secs = 600 tee_support = true diff --git a/etc/env/file_based/general.yaml b/etc/env/file_based/general.yaml index 587ba4614a59..d4db378a5da4 100644 --- a/etc/env/file_based/general.yaml +++ b/etc/env/file_based/general.yaml @@ -169,6 +169,7 @@ witness_vector_generator: data_handler: http_port: 3320 proof_generation_timeout_in_secs: 18000 + tee_proof_generation_timeout_in_secs: 600 tee_support: true prover_gateway: api_url: http://127.0.0.1:3320