diff --git a/core/lib/config/src/configs/fri_witness_generator.rs b/core/lib/config/src/configs/fri_witness_generator.rs index c69d04367cf8..281159271dd0 100644 --- a/core/lib/config/src/configs/fri_witness_generator.rs +++ b/core/lib/config/src/configs/fri_witness_generator.rs @@ -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, } #[derive(Debug)] diff --git a/core/lib/config/src/testonly.rs b/core/lib/config/src/testonly.rs index 42f24fb2d467..939b24ea8c76 100644 --- a/core/lib/config/src/testonly.rs +++ b/core/lib/config/src/testonly.rs @@ -560,6 +560,7 @@ impl Distribution 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), } } } diff --git a/core/lib/env_config/src/fri_witness_generator.rs b/core/lib/env_config/src/fri_witness_generator.rs index 9780e6aec682..5853a0178308 100644 --- a/core/lib/env_config/src/fri_witness_generator.rs +++ b/core/lib/env_config/src/fri_witness_generator.rs @@ -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), } } @@ -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); diff --git a/core/lib/protobuf_config/src/proto/config/prover.proto b/core/lib/protobuf_config/src/proto/config/prover.proto index 1eaf8637522a..c50ebdde4eef 100644 --- a/core/lib/protobuf_config/src/proto/config/prover.proto +++ b/core/lib/protobuf_config/src/proto/config/prover.proto @@ -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"; } diff --git a/core/lib/protobuf_config/src/prover.rs b/core/lib/protobuf_config/src/prover.rs index 9a41e433433c..50782ab8e968 100644 --- a/core/lib/protobuf_config/src/prover.rs +++ b/core/lib/protobuf_config/src/prover.rs @@ -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")?, }) } @@ -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()), } } } diff --git a/etc/env/file_based/general.yaml b/etc/env/file_based/general.yaml index fbd7c816b1bb..4911f0aa6105 100644 --- a/etc/env/file_based/general.yaml +++ b/etc/env/file_based/general.yaml @@ -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 diff --git a/prover/witness_generator/src/main.rs b/prover/witness_generator/src/main.rs index f26d445999db..9f1c8d72cd1b 100644 --- a/prover/witness_generator/src/main.rs +++ b/prover/witness_generator/src/main.rs @@ -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::::singleton(database_secrets.prover_url()?) .build() @@ -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());