Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(prover): Add prometheus port to witness generator config #2385

Merged
merged 12 commits into from
Jul 8, 2024
Merged
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 @@ -559,6 +559,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
10 changes: 9 additions & 1 deletion prover/witness_generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ async fn main() -> anyhow::Result<()> {
let prometheus_config = general_config
.prometheus_config
.context("prometheus config")?;
Deniallugo marked this conversation as resolved.
Show resolved Hide resolved

// 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.listener_port
};

let postgres_config = general_config.postgres_config.context("postgres config")?;
let connection_pool = ConnectionPool::<Core>::builder(
database_secrets.master_url()?,
Expand Down Expand Up @@ -196,7 +204,7 @@ async fn main() -> anyhow::Result<()> {
)
} 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
Loading