Skip to content

Commit

Permalink
fix: Follow up metrics fixes vol.2 (matter-labs#656)
Browse files Browse the repository at this point in the history
## What ❔

Fix oldest not generated batch query

## Why ❔

For metrics to work correctly

## Checklist

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [x] Code has been formatted via `zk fmt` and `zk lint`.
- [x] Spellcheck has been run via `cargo spellcheck
--cfg=./spellcheck/era.cfg --code 1`.
  • Loading branch information
Artemka374 authored Dec 11, 2023
1 parent 77f91fe commit 5c1aea2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
36 changes: 18 additions & 18 deletions core/lib/dal/sqlx-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2717,24 +2717,6 @@
},
"query": "UPDATE transactions\n SET in_mempool = TRUE\n FROM (\n SELECT hash FROM (\n SELECT hash\n FROM transactions\n WHERE miniblock_number IS NULL AND in_mempool = FALSE AND error IS NULL\n AND (is_priority = TRUE OR (max_fee_per_gas >= $2 and gas_per_pubdata_limit >= $3))\n AND tx_format != $4\n ORDER BY is_priority DESC, priority_op_id, received_at\n LIMIT $1\n ) as subquery1\n ORDER BY hash\n ) as subquery2\n WHERE transactions.hash = subquery2.hash\n RETURNING transactions.*"
},
"2cc57497090a97bcb453036f7b5e2139b590699aa1a2df4d6fd2b19e27e06251": {
"describe": {
"columns": [
{
"name": "l1_batch_number",
"ordinal": 0,
"type_info": "Int8"
}
],
"nullable": [
false
],
"parameters": {
"Left": []
}
},
"query": "SELECT l1_batch_number FROM proof_generation_details WHERE status <> 'generated' ORDER BY l1_batch_number ASC LIMIT 1"
},
"2e3f116ca05ae70b7c83ac550302194c91f57b69902ff8e42140fde732ae5e6a": {
"describe": {
"columns": [],
Expand Down Expand Up @@ -4853,6 +4835,24 @@
},
"query": "SELECT (SELECT l1_batch_number FROM miniblocks WHERE number = $1) as \"block_batch?\", (SELECT MAX(number) + 1 FROM l1_batches) as \"max_batch?\""
},
"5f29e71af038c974e2d83b908c5a2559ab8afbb169bc0ae9f881a6628dc087fd": {
"describe": {
"columns": [
{
"name": "l1_batch_number",
"ordinal": 0,
"type_info": "Int8"
}
],
"nullable": [
false
],
"parameters": {
"Left": []
}
},
"query": "SELECT l1_batch_number FROM proof_generation_details WHERE status NOT IN ('generated', 'skipped') ORDER BY l1_batch_number ASC LIMIT 1"
},
"5f40849646bb7436e29cda8fb87fece2a4dcb580644f45ecb82388dece04f222": {
"describe": {
"columns": [
Expand Down
4 changes: 2 additions & 2 deletions core/lib/dal/src/proof_generation_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl ProofGenerationDal<'_, '_> {
.ok_or(sqlx::Error::RowNotFound)
}

pub async fn get_oldest_unprocessed_batch(&mut self) -> Option<L1BatchNumber> {
pub async fn get_oldest_unpicked_batch(&mut self) -> Option<L1BatchNumber> {
let result: Option<L1BatchNumber> = sqlx::query!(
"SELECT l1_batch_number \
FROM proof_generation_details \
Expand All @@ -129,7 +129,7 @@ impl ProofGenerationDal<'_, '_> {
let result: Option<L1BatchNumber> = sqlx::query!(
"SELECT l1_batch_number \
FROM proof_generation_details \
WHERE status <> 'generated' \
WHERE status NOT IN ('generated', 'skipped') \
ORDER BY l1_batch_number ASC \
LIMIT 1",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,10 @@ impl PeriodicJob for FriProverStatsReporter {

if let Some(l1_batch_number) = db_conn
.proof_generation_dal()
.get_oldest_unprocessed_batch()
.get_oldest_unpicked_batch()
.await
{
metrics::gauge!(
"fri_prover.oldest_unprocessed_batch",
l1_batch_number.0 as f64
)
metrics::gauge!("fri_prover.oldest_unpicked_batch", l1_batch_number.0 as f64)
}

if let Some(l1_batch_number) = db_conn
Expand Down

0 comments on commit 5c1aea2

Please sign in to comment.