diff --git a/core/lib/dal/src/tee_proof_generation_dal.rs b/core/lib/dal/src/tee_proof_generation_dal.rs index 6ea743afd75d..5887a0d33313 100644 --- a/core/lib/dal/src/tee_proof_generation_dal.rs +++ b/core/lib/dal/src/tee_proof_generation_dal.rs @@ -65,6 +65,11 @@ impl TeeProofGenerationDal<'_, '_> { let processing_timeout = pg_interval_from_duration(processing_timeout); let min_batch_number = i64::from(min_batch_number.0); let mut transaction = self.storage.start_transaction().await?; + + // Lock rows in the proof_generation_details table to prevent race conditions. The + // tee_proof_generation_details table may not have corresponding entries yet if this is the + // first time the query is invoked for a batch. Locking rows in proof_generation_details + // ensures that two different TEE prover instances will not try to prove the same batch. let batch_number = sqlx::query!( r#" SELECT