Skip to content

Commit

Permalink
feat(prover): Add prometheus port to witness generator config (#2385)
Browse files Browse the repository at this point in the history
## What ❔

Add prometheus port to witness generator config
  • Loading branch information
matias-gonz authored Jul 8, 2024
1 parent e5e0473 commit d0e1add
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 4 deletions.
2 changes: 2 additions & 0 deletions core/lib/config/src/configs/fri_witness_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub struct FriWitnessGeneratorConfig {

// whether to write to public GCS bucket for https://github.com/matter-labs/era-boojum-validator-cli
pub shall_save_to_public_bucket: bool,

pub prometheus_listener_port: Option<u16>,
}

#[derive(Debug)]
Expand Down
1 change: 1 addition & 0 deletions core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ impl Distribution<configs::FriWitnessGeneratorConfig> for EncodeDist {
max_attempts: self.sample(rng),
last_l1_batch_to_process: self.sample(rng),
shall_save_to_public_bucket: self.sample(rng),
prometheus_listener_port: self.sample(rng),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions core/lib/env_config/src/fri_witness_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ mod tests {
max_attempts: 4,
last_l1_batch_to_process: None,
shall_save_to_public_bucket: true,
prometheus_listener_port: Some(3333u16),
}
}

Expand All @@ -41,6 +42,7 @@ mod tests {
FRI_WITNESS_SCHEDULER_GENERATION_TIMEOUT_IN_SECS=900
FRI_WITNESS_MAX_ATTEMPTS=4
FRI_WITNESS_SHALL_SAVE_TO_PUBLIC_BUCKET=true
FRI_WITNESS_PROMETHEUS_LISTENER_PORT=3333
"#;
lock.set_env(config);

Expand Down
1 change: 1 addition & 0 deletions core/lib/protobuf_config/src/proto/config/prover.proto
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ message WitnessGenerator {
optional uint32 node_generation_timeout_in_secs = 10; // optional;
optional uint32 scheduler_generation_timeout_in_secs = 11; // optional;
optional uint32 recursion_tip_timeout_in_secs = 12; // optional;
optional uint32 prometheus_listener_port = 13; // optional;
reserved 3, 4, 6;
reserved "dump_arguments_for_blocks", "force_process_block", "blocks_proving_percentage";
}
Expand Down
6 changes: 6 additions & 0 deletions core/lib/protobuf_config/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ impl ProtoRepr for proto::WitnessGenerator {
.map(|x| x.try_into())
.transpose()
.context("scheduler_generation_timeout_in_secs")?,
prometheus_listener_port: self
.prometheus_listener_port
.map(|x| x.try_into())
.transpose()
.context("prometheus_listener_port")?,
})
}

Expand All @@ -213,6 +218,7 @@ impl ProtoRepr for proto::WitnessGenerator {
scheduler_generation_timeout_in_secs: this
.scheduler_generation_timeout_in_secs
.map(|x| x.into()),
prometheus_listener_port: this.prometheus_listener_port.map(|x| x.into()),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions etc/env/file_based/general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ witness_generator:
generation_timeout_in_secs: 900
max_attempts: 10
shall_save_to_public_bucket: true
prometheus_listener_port: 3116
witness_vector_generator:
prover_instance_wait_timeout_in_secs: 200
prover_instance_poll_time_in_milli_secs: 250
Expand Down
21 changes: 17 additions & 4 deletions prover/witness_generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,19 @@ async fn main() -> anyhow::Result<()> {
let config = general_config
.witness_generator
.context("witness generator config")?;
let prometheus_config = general_config
.prometheus_config
.context("prometheus config")?;

let prometheus_config = general_config.prometheus_config;

// If the prometheus listener port is not set in the witness generator config, use the one from the prometheus config.
let prometheus_listener_port = if let Some(port) = config.prometheus_listener_port {
port
} else {
prometheus_config
.clone()
.context("prometheus config")?
.listener_port
};

let prover_connection_pool =
ConnectionPool::<Prover>::singleton(database_secrets.prover_url()?)
.build()
Expand Down Expand Up @@ -181,13 +191,16 @@ async fn main() -> anyhow::Result<()> {
);

let prometheus_config = if use_push_gateway {
let prometheus_config = prometheus_config
.clone()
.context("prometheus config needed when use_push_gateway enabled")?;
PrometheusExporterConfig::push(
prometheus_config.gateway_endpoint(),
prometheus_config.push_interval(),
)
} else {
// `u16` cast is safe since i is in range [0, 4)
PrometheusExporterConfig::pull(prometheus_config.listener_port + i as u16)
PrometheusExporterConfig::pull(prometheus_listener_port + i as u16)
};
let prometheus_task = prometheus_config.run(stop_receiver.clone());

Expand Down

0 comments on commit d0e1add

Please sign in to comment.