mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-02 13:23:13 +00:00
Centralize cfgsync port/KZG defaults in Rust
This commit is contained in:
parent
78f38f4ca0
commit
ff63bc0132
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1007,6 +1007,7 @@ dependencies = [
|
||||
"serde_yaml",
|
||||
"subnetworks-assignations",
|
||||
"testing-framework-config",
|
||||
"testing-framework-core",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
pub mod constants;
|
||||
pub mod nodes;
|
||||
pub mod scenario;
|
||||
pub mod topology;
|
||||
|
||||
@ -7,7 +7,10 @@ use nomos_utils::bounded_duration::{MinimalBoundedDuration, SECOND};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::serde_as;
|
||||
|
||||
use crate::topology::{GeneratedTopology, configs::wallet::WalletConfig};
|
||||
use crate::{
|
||||
constants::kzg_container_path,
|
||||
topology::{GeneratedTopology, configs::wallet::WalletConfig},
|
||||
};
|
||||
|
||||
#[serde_as]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@ -92,7 +95,7 @@ pub fn apply_topology_overrides(
|
||||
cfg.global_params_path = if use_kzg_mount {
|
||||
// Compose mounts the bundle at /kzgrs_test_params; the proving key lives under
|
||||
// pol/.
|
||||
"/kzgrs_test_params/kzgrs_test_params".into()
|
||||
kzg_container_path()
|
||||
} else {
|
||||
da.global_params_path.clone()
|
||||
};
|
||||
|
||||
@ -10,6 +10,7 @@ use serde::Serialize;
|
||||
use tera::Context as TeraContext;
|
||||
use testing_framework_core::{
|
||||
adjust_timeout,
|
||||
constants::{DEFAULT_CFGSYNC_PORT, kzg_container_path},
|
||||
topology::{GeneratedNodeConfig, GeneratedTopology},
|
||||
};
|
||||
use tokio::{process::Command, time::timeout};
|
||||
@ -115,8 +116,6 @@ pub enum TemplateError {
|
||||
/// Errors building a compose descriptor from the topology.
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum DescriptorBuildError {
|
||||
#[error("cfgsync port is not configured for compose descriptor")]
|
||||
MissingCfgsyncPort,
|
||||
#[error("prometheus port is not configured for compose descriptor")]
|
||||
MissingPrometheusPort,
|
||||
}
|
||||
@ -189,9 +188,7 @@ impl<'a> ComposeDescriptorBuilder<'a> {
|
||||
|
||||
/// Finish building the descriptor, erroring if required fields are missing.
|
||||
pub fn build(self) -> Result<ComposeDescriptor, DescriptorBuildError> {
|
||||
let cfgsync_port = self
|
||||
.cfgsync_port
|
||||
.ok_or(DescriptorBuildError::MissingCfgsyncPort)?;
|
||||
let cfgsync_port = self.cfgsync_port.unwrap_or(DEFAULT_CFGSYNC_PORT);
|
||||
let prometheus_host_port = self
|
||||
.prometheus_port
|
||||
.ok_or(DescriptorBuildError::MissingPrometheusPort)?;
|
||||
@ -526,8 +523,8 @@ fn base_environment(cfgsync_port: u16) -> Vec<EnvEntry> {
|
||||
let rust_log = std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_string());
|
||||
let nomos_log_level = std::env::var("NOMOS_LOG_LEVEL").unwrap_or_else(|_| "info".to_string());
|
||||
let time_backend = std::env::var("NOMOS_TIME_BACKEND").unwrap_or_else(|_| "monotonic".into());
|
||||
let kzg_path = std::env::var("NOMOS_KZGRS_PARAMS_PATH")
|
||||
.unwrap_or_else(|_| String::from("/kzgrs_test_params/kzgrs_test_params"));
|
||||
let kzg_path =
|
||||
std::env::var("NOMOS_KZGRS_PARAMS_PATH").unwrap_or_else(|_| kzg_container_path());
|
||||
vec![
|
||||
EnvEntry::new("POL_PROOF_DEV_MODE", pol_mode),
|
||||
EnvEntry::new("RUST_LOG", rust_log),
|
||||
@ -622,7 +619,7 @@ mod tests {
|
||||
fn descriptor_matches_topology_counts() {
|
||||
let topology = TopologyBuilder::new(TopologyConfig::with_node_numbers(2, 1)).build();
|
||||
let descriptor = ComposeDescriptor::builder(&topology)
|
||||
.with_cfgsync_port(4400)
|
||||
.with_cfgsync_port(DEFAULT_CFGSYNC_PORT)
|
||||
.with_prometheus_port(9090)
|
||||
.build()
|
||||
.expect("descriptor");
|
||||
|
||||
@ -8,6 +8,7 @@ use anyhow::{Context as _, Result as AnyResult};
|
||||
use serde::Serialize;
|
||||
use tempfile::TempDir;
|
||||
use testing_framework_core::{
|
||||
constants::cfgsync_port,
|
||||
scenario::cfgsync::{apply_topology_overrides, load_cfgsync_template, render_cfgsync_yaml},
|
||||
topology::GeneratedTopology,
|
||||
};
|
||||
@ -27,7 +28,9 @@ pub struct RunnerAssets {
|
||||
_tempdir: TempDir,
|
||||
}
|
||||
|
||||
pub const CFGSYNC_PORT: u16 = 4400;
|
||||
pub fn cfgsync_port_value() -> u16 {
|
||||
cfgsync_port()
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
/// Failures preparing Helm assets and rendered cfgsync configuration.
|
||||
|
||||
@ -3,7 +3,7 @@ use std::{io, process::Stdio};
|
||||
use thiserror::Error;
|
||||
use tokio::process::Command;
|
||||
|
||||
use crate::assets::{CFGSYNC_PORT, RunnerAssets, workspace_root};
|
||||
use crate::assets::{RunnerAssets, cfgsync_port_value, workspace_root};
|
||||
|
||||
/// Errors returned from Helm invocations.
|
||||
#[derive(Debug, Error)]
|
||||
@ -54,7 +54,7 @@ pub async fn install_release(
|
||||
.arg("--set")
|
||||
.arg(format!("executors.count={executors}"))
|
||||
.arg("--set")
|
||||
.arg(format!("cfgsync.port={CFGSYNC_PORT}"))
|
||||
.arg(format!("cfgsync.port={}", cfgsync_port_value()))
|
||||
.arg("--set")
|
||||
.arg(format!("kzg.hostPath={}", assets.kzg_path.display()))
|
||||
.arg("--set")
|
||||
|
||||
@ -34,5 +34,6 @@ serde_with = { workspace = true }
|
||||
serde_yaml = "0.9"
|
||||
subnetworks-assignations = { workspace = true }
|
||||
testing-framework-config = { workspace = true }
|
||||
testing-framework-core = { path = "../../core" }
|
||||
tokio = { default-features = false, features = ["macros", "net", "rt-multi-thread"], version = "1" }
|
||||
tracing = { workspace = true }
|
||||
|
||||
@ -15,6 +15,7 @@ use nomos_libp2p::PeerId;
|
||||
use nomos_node::Config as ValidatorConfig;
|
||||
use serde::{Serialize, de::DeserializeOwned};
|
||||
use subnetworks_assignations::{MembershipCreator, MembershipHandler, SubnetworkId};
|
||||
use testing_framework_core::constants::cfgsync_port as default_cfgsync_port;
|
||||
|
||||
fn parse_ip(ip_str: &str) -> Ipv4Addr {
|
||||
ip_str.parse().unwrap_or_else(|_| {
|
||||
@ -83,8 +84,8 @@ where
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let config_file_path = env::var("CFG_FILE_PATH").unwrap_or_else(|_| "config.yaml".to_owned());
|
||||
let server_addr =
|
||||
env::var("CFG_SERVER_ADDR").unwrap_or_else(|_| "http://127.0.0.1:4400".to_owned());
|
||||
let server_addr = env::var("CFG_SERVER_ADDR")
|
||||
.unwrap_or_else(|_| format!("http://127.0.0.1:{}", default_cfgsync_port()));
|
||||
let ip = parse_ip(&env::var("CFG_HOST_IP").unwrap_or_else(|_| "127.0.0.1".to_owned()));
|
||||
let identifier =
|
||||
env::var("CFG_HOST_IDENTIFIER").unwrap_or_else(|_| "unidentified-node".to_owned());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user