diff --git a/core/lib/config/src/configs/proof_data_handler.rs b/core/lib/config/src/configs/proof_data_handler.rs index 1094b1bb180..1d8703df51a 100644 --- a/core/lib/config/src/configs/proof_data_handler.rs +++ b/core/lib/config/src/configs/proof_data_handler.rs @@ -9,6 +9,9 @@ pub struct TeeConfig { pub tee_support: bool, /// All batches before this one are considered to be processed. pub first_tee_processed_batch: L1BatchNumber, + /// Timeout in seconds for retrying TEE proof generation if it fails. Retries continue + /// indefinitely until successful. + pub tee_proof_generation_timeout_in_secs: u16, } impl Default for TeeConfig { @@ -16,6 +19,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 +33,14 @@ impl TeeConfig { pub fn default_first_tee_processed_batch() -> L1BatchNumber { L1BatchNumber(0) } + + pub fn default_tee_proof_generation_timeout_in_secs() -> u16 { + 600 + } + + pub fn tee_proof_generation_timeout(&self) -> Duration { + Duration::from_secs(self.tee_proof_generation_timeout_in_secs.into()) + } } #[derive(Debug, Deserialize, Clone, PartialEq)] diff --git a/core/lib/config/src/testonly.rs b/core/lib/config/src/testonly.rs index f8e53e33042..21ff9e2351b 100644 --- a/core/lib/config/src/testonly.rs +++ b/core/lib/config/src/testonly.rs @@ -681,6 +681,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 b5bfda4544e..47848585e76 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 a587c702633..c01e163bd77 100644 --- a/core/lib/protobuf_config/src/proof_data_handler.rs +++ b/core/lib/protobuf_config/src/proof_data_handler.rs @@ -23,6 +23,12 @@ 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_in_secs, + ), }, }) } @@ -33,6 +39,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_config.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 92ba770a756..392834d25f3 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/tee_request_processor.rs b/core/node/proof_data_handler/src/tee_request_processor.rs index 8e06d0c26bc..b265b94d4d7 100644 --- a/core/node/proof_data_handler/src/tee_request_processor.rs +++ b/core/node/proof_data_handler/src/tee_request_processor.rs @@ -164,7 +164,7 @@ impl TeeRequestProcessor { .tee_proof_generation_dal() .lock_batch_for_proving( tee_type, - self.config.proof_generation_timeout(), + self.config.tee_config.tee_proof_generation_timeout(), min_batch_number, ) .await diff --git a/core/node/proof_data_handler/src/tests.rs b/core/node/proof_data_handler/src/tests.rs index 63ea087a81c..87c6bff8a1f 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 7a1999a03c3..b56ac26fb17 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 8758d38186f..5abee904765 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