You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: validity/src/db/client.rs
+185-1Lines changed: 185 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -294,6 +294,45 @@ impl DriverDBClient {
294
294
Ok(requests)
295
295
}
296
296
297
+
/// Fetch the maximum `l1_head_block_number` across the consecutive complete range proofs that
298
+
/// will be aggregated over `[start_block, end_block]`.
299
+
///
300
+
/// This is the L1 head the aggregation guest must anchor to: the guest walks headers back from
301
+
/// the checkpointed head and requires every range proof's `l1Head` to appear in that chain, so
302
+
/// the checkpoint must be at or after this block. Returns `None` if no matching range proof has
303
+
/// an `l1_head_block_number` recorded (e.g. proofs predating that column).
304
+
///
305
+
/// The WHERE clause must stay in sync with [`Self::get_consecutive_complete_range_proofs`] so
306
+
/// the MAX is taken over exactly the set of range proofs the aggregation will consume.
307
+
///
308
+
/// [UPSTREAM #923] Backported from succinctlabs/op-succinct#923 (in upstream v3.10.0), keeping
309
+
/// upstream's name and body so a future sync can drop this copy cleanly. The one deviation:
310
+
/// upstream's WHERE also carries `invalidated_at IS NULL`, a column added by #951 which this
311
+
/// baseline does not have. Drop that deviation if #951 is ever backported.
312
+
pubasyncfnget_max_l1_head_block_number_for_range(
313
+
&self,
314
+
start_block:i64,
315
+
end_block:i64,
316
+
commitment:&CommitmentConfig,
317
+
l1_chain_id:i64,
318
+
l2_chain_id:i64,
319
+
) -> Result<Option<i64>,Error>{
320
+
let result = sqlx::query_scalar::<_,Option<i64>>(
321
+
"SELECT MAX(l1_head_block_number) FROM requests WHERE range_vkey_commitment = $1 AND rollup_config_hash = $2 AND status = $3 AND req_type = $4 AND start_block >= $5 AND end_block <= $6 AND l1_chain_id = $7 AND l2_chain_id = $8",
322
+
)
323
+
.bind(&commitment.range_vkey_commitment[..])
324
+
.bind(&commitment.rollup_config_hash[..])
325
+
.bind(RequestStatus::Completeasi16)
326
+
.bind(RequestType::Rangeasi16)
327
+
.bind(start_block)
328
+
.bind(end_block)
329
+
.bind(l1_chain_id)
330
+
.bind(l2_chain_id)
331
+
.fetch_one(&self.pool)
332
+
.await?;
333
+
Ok(result)
334
+
}
335
+
297
336
/// Fetch the checkpointed block hash and number for an aggregation request with the same start
0 commit comments