Skip to content

Commit 2cec83f

Browse files
Artemka374EmilLuta
andauthored
feat(prover): Add endpoint to PJM to get queue reports (matter-labs#2918)
## What ❔ Add `/queue_report` endpoint, which will get the data about queue and send it. ## Why ❔ To work with new autoscaler ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] 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. - [ ] Code has been formatted via `zk fmt` and `zk lint`. --------- Co-authored-by: EmilLuta <EmilLuta@users.noreply.github.com>
1 parent 633bca4 commit 2cec83f

File tree

18 files changed

+334
-13
lines changed

18 files changed

+334
-13
lines changed

core/lib/basic_types/src/prover_dal.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
use std::{net::IpAddr, ops::Add, str::FromStr};
33

44
use chrono::{DateTime, Duration, NaiveDateTime, NaiveTime, Utc};
5+
use serde::{Deserialize, Serialize};
56
use strum::{Display, EnumString};
67

78
use crate::{
@@ -27,7 +28,7 @@ pub struct ExtendedJobCountStatistics {
2728
pub successful: usize,
2829
}
2930

30-
#[derive(Debug, Clone, Copy, Default)]
31+
#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)]
3132
pub struct JobCountStatistics {
3233
pub queued: usize,
3334
pub in_progress: usize,

core/lib/config/src/configs/prover_job_monitor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ pub struct ProverJobMonitorConfig {
6161
/// The interval between runs for Witness Job Queuer.
6262
#[serde(default = "ProverJobMonitorConfig::default_witness_job_queuer_run_interval_ms")]
6363
pub witness_job_queuer_run_interval_ms: u64,
64+
/// HTTP port of the ProverJobMonitor to send requests to.
65+
pub http_port: u16,
6466
}
6567

6668
impl ProverJobMonitorConfig {

core/lib/config/src/testonly.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,7 @@ impl Distribution<configs::prover_job_monitor::ProverJobMonitorConfig> for Encod
11131113
prover_queue_reporter_run_interval_ms: self.sample(rng),
11141114
witness_generator_queue_reporter_run_interval_ms: self.sample(rng),
11151115
witness_job_queuer_run_interval_ms: self.sample(rng),
1116+
http_port: self.sample(rng),
11161117
}
11171118
}
11181119
}

core/lib/env_config/src/prover_job_monitor.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ mod tests {
3131
prover_queue_reporter_run_interval_ms: 10000,
3232
witness_generator_queue_reporter_run_interval_ms: 10000,
3333
witness_job_queuer_run_interval_ms: 10000,
34+
http_port: 3074,
3435
}
3536
}
3637

@@ -55,6 +56,7 @@ mod tests {
5556
fn from_env_with_default() {
5657
let config = r#"
5758
PROVER_JOB_MONITOR_PROMETHEUS_PORT=3317
59+
PROVER_JOB_MONITOR_HTTP_PORT=3074
5860
PROVER_JOB_MONITOR_MAX_DB_CONNECTIONS=9
5961
"#;
6062
let mut lock = MUTEX.lock();
@@ -80,6 +82,7 @@ mod tests {
8082
PROVER_JOB_MONITOR_PROVER_QUEUE_REPORTER_RUN_INTERVAL_MS=10001
8183
PROVER_JOB_MONITOR_WITNESS_GENERATOR_QUEUE_REPORTER_RUN_INTERVAL_MS=10001
8284
PROVER_JOB_MONITOR_WITNESS_JOB_QUEUER_RUN_INTERVAL_MS=10001
85+
PROVER_JOB_MONITOR_HTTP_PORT=3074
8386
"#;
8487
let mut lock = MUTEX.lock();
8588
lock.set_env(config);

core/lib/protobuf_config/src/proto/config/prover_job_monitor.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ message ProverJobMonitor {
1717
optional uint64 prover_queue_reporter_run_interval_ms = 12; // optional; ms
1818
optional uint64 witness_generator_queue_reporter_run_interval_ms = 13; // optional; ms
1919
optional uint64 witness_job_queuer_run_interval_ms = 14; // optional; ms
20+
optional uint32 http_port = 15; // required; u32
2021
}

core/lib/protobuf_config/src/prover_job_monitor.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ impl ProtoRepr for proto::ProverJobMonitor {
9595
.or_else(|| Some(Self::Type::default_witness_job_queuer_run_interval_ms())),
9696
)
9797
.context("witness_job_queuer_run_interval_ms")?,
98+
http_port: required(&self.http_port)
99+
.and_then(|x| Ok((*x).try_into()?))
100+
.context("http_port")?,
98101
})
99102
}
100103

@@ -126,6 +129,7 @@ impl ProtoRepr for proto::ProverJobMonitor {
126129
this.witness_generator_queue_reporter_run_interval_ms,
127130
),
128131
witness_job_queuer_run_interval_ms: Some(this.witness_job_queuer_run_interval_ms),
132+
http_port: Some(this.http_port.into()),
129133
}
130134
}
131135
}

etc/env/base/prover_job_monitor.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ proof_compressor_queue_reporter_run_interval_ms = 10000
1313
prover_queue_reporter_run_interval_ms = 10000
1414
witness_generator_queue_reporter_run_interval_ms = 10000
1515
witness_job_queuer_run_interval_ms = 10000
16+
http_port = 3074

etc/env/file_based/general.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ prover_job_monitor:
287287
prover_queue_reporter_run_interval_ms: 10000
288288
witness_generator_queue_reporter_run_interval_ms: 10000
289289
witness_job_queuer_run_interval_ms: 10000
290+
http_port: 3074
290291

291292

292293
base_token_adjuster:

prover/Cargo.lock

Lines changed: 25 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prover/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ categories = ["cryptography"]
1919
[workspace.dependencies]
2020
# Common dependencies
2121
anyhow = "1.0"
22+
axum = "0.7.5"
2223
async-trait = "0.1"
2324
bincode = "1"
2425
chrono = "0.4.38"

0 commit comments

Comments
 (0)