Skip to content

Commit

Permalink
fixup! feat: remove TEE from tree
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasknauth committed Aug 9, 2024
1 parent 19e0de8 commit 3a1fa96
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions core/lib/dal/src/tee_verifier_input_producer_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,41 +76,42 @@ impl TeeVerifierInputProducerDal<'_, '_> {
pub async fn get_new_l1_batches(
&mut self,
) -> DalResult<Option<(L1BatchNumber, L1BatchNumber)>> {
// COALESCE(1, ...) covers the case where the table is initially empty. NB: We start from batch 1, since genesis batch 0 has no proof.
let row_low = sqlx::query!(
// Since we depend on Merkle paths, we use the proof_generation_details table to inform us of newly available to-be-proven batches.
let row_high = sqlx::query!(
r#"
SELECT
COALESCE(1, MAX(l1_batch_number) + 1) AS "number"
MAX(l1_batch_number) AS "number"
FROM
tee_verifier_input_producer_jobs
proof_generation_details
"#
)
.instrument("get_latest_tee_job_l1_batch_number")
.instrument("get_sealed_l1_batch_number")
.report_latency()
.fetch_one(self.storage)
.await?;
.await?
.number
.unwrap();

// Since we depend on Merkle paths, we use the proof_generation_details table to inform us of newly available to-be-proven batches.
let row_high = sqlx::query!(
let row_low = sqlx::query!(
r#"
SELECT
MAX(l1_batch_number) AS "number"
MAX(l1_batch_number) + 1 AS "number"
FROM
proof_generation_details
tee_verifier_input_producer_jobs
"#
)
.instrument("get_sealed_l1_batch_number")
.instrument("get_latest_tee_job_l1_batch_number")
.report_latency()
.fetch_one(self.storage)
.await?;
.await?
.number
// If the table is empty, we start with the most recent batch.
.unwrap_or(row_high);

match (row_low.number, row_high.number) {
(Some(low), Some(high)) => Ok(Some((
L1BatchNumber(low as u32),
L1BatchNumber(high as u32),
))),
_ => Ok(None),
}
Ok(Some((
L1BatchNumber(row_low as u32),
L1BatchNumber(row_high as u32),
)))
}

pub async fn get_next_tee_verifier_input_producer_job(
Expand Down

0 comments on commit 3a1fa96

Please sign in to comment.