diff --git a/crates/apollo_config/src/converters.rs b/crates/apollo_config/src/converters.rs index 647eee76cc3..413b730cf2e 100644 --- a/crates/apollo_config/src/converters.rs +++ b/crates/apollo_config/src/converters.rs @@ -328,58 +328,6 @@ where .collect() } -/// Serializes an optional list into a comma-separated string. -/// Returns `None` if the input is `None`. -pub fn serialize_optional_comma_separated(list: &Option>) -> Option -where - T: ToString, -{ - match list { - None => None, - Some(list) => Some(list.iter().map(|item| item.to_string()).collect::>().join(",")), - } -} - -/// Serializes an optional list into a comma-separated string, for use as -/// `#[serde(serialize_with)]`. Counterpart of `deserialize_comma_separated_str`: `None` and -/// `Some(empty)` both serialize to the empty string, which that deserializer reads back as `None`. -pub fn serialize_optional_comma_separated_str( - list: &Option>, - se: S, -) -> Result -where - S: Serializer, - T: ToString, -{ - se.serialize_str(&serialize_optional_comma_separated(list).unwrap_or_default()) -} - -/// Deserializes an optional comma-separated list of values implementing `FromStr` into -/// `Option>`. Returns `None` for empty or missing strings. -pub fn deserialize_comma_separated_str<'de, D, T>(de: D) -> Result>, D::Error> -where - D: Deserializer<'de>, - T: FromStr, - ::Err: std::fmt::Display, -{ - let raw = String::deserialize(de).unwrap_or_default(); - if raw.trim().is_empty() { - return Ok(None); - } - - let mut output: Vec = Vec::new(); - for part in raw.split(',').filter(|s| !s.is_empty()) { - let value = T::from_str(part) - .map_err(|e| D::Error::custom(format!("Invalid value '{part}': {e}")))?; - output.push(value); - } - - if output.is_empty() { - return Ok(None); - } - Ok(Some(output)) -} - /// Deserializes a sensitive `Vec` from hex string structure. pub fn deserialize_optional_sensitive_vec_u8<'de, D>( de: D, diff --git a/crates/apollo_config/src/converters_test.rs b/crates/apollo_config/src/converters_test.rs index 85b95ab8f70..11cf78a4985 100644 --- a/crates/apollo_config/src/converters_test.rs +++ b/crates/apollo_config/src/converters_test.rs @@ -3,14 +3,12 @@ use std::time::Duration; use serde::{Deserialize, Serialize}; use super::{ - deserialize_comma_separated_str, deserialize_float_seconds_to_duration, deserialize_milliseconds_to_duration, deserialize_seconds_to_duration, serialize_duration_as_float_seconds, serialize_duration_as_milliseconds, serialize_duration_as_seconds, - serialize_optional_comma_separated_str, }; // These wrappers mirror the `#[serde(deserialize_with = ..., serialize_with = ...)]` pairings used @@ -45,17 +43,6 @@ struct FloatSecondsWrapper { duration: Duration, } -// `deserialize_comma_separated_str`/`serialize_optional_comma_separated_str` are generic over any -// `T: FromStr + ToString`; `u64` exercises the same code path without pulling in `starknet_api`. -#[derive(Debug, PartialEq, Serialize, Deserialize)] -struct CommaSeparatedWrapper { - #[serde( - deserialize_with = "deserialize_comma_separated_str", - serialize_with = "serialize_optional_comma_separated_str" - )] - list: Option>, -} - fn assert_round_trips(value: T) where T: Serialize + serde::de::DeserializeOwned + PartialEq + std::fmt::Debug, @@ -85,10 +72,3 @@ fn float_seconds_duration_round_trips() { // representable to avoid float rounding noise in the equality assertion. assert_round_trips(FloatSecondsWrapper { duration: Duration::from_secs_f64(1.5) }); } - -#[test] -fn comma_separated_list_round_trips() { - // `None` (the default) and a populated list. - assert_round_trips(CommaSeparatedWrapper { list: None }); - assert_round_trips(CommaSeparatedWrapper { list: Some(vec![1, 22, 333]) }); -} diff --git a/crates/apollo_network/src/lib.rs b/crates/apollo_network/src/lib.rs index a6d50f20ed1..67308fed471 100644 --- a/crates/apollo_network/src/lib.rs +++ b/crates/apollo_network/src/lib.rs @@ -223,11 +223,9 @@ use std::collections::HashSet; use std::time::Duration; use apollo_config::converters::{ - deserialize_comma_separated_str, deserialize_optional_sensitive_vec_u8, deserialize_seconds_to_duration, serialize_duration_as_seconds, - serialize_optional_comma_separated_str, }; use apollo_config::secrets::Sensitive; use apollo_config::validators::validate_optional_sensitive_vec_u256; @@ -321,10 +319,6 @@ pub struct NetworkConfig { /// Bootstrap peer multiaddresses for initial connectivity. Each must include a valid peer ID. /// Format: `/ip4/1.2.3.4/tcp/10000/p2p/`. Default: None - #[serde( - deserialize_with = "deserialize_comma_separated_str", - serialize_with = "serialize_optional_comma_separated_str" - )] #[validate(custom(function = "validate_bootstrap_peer_multiaddr_list"))] pub bootstrap_peer_multiaddr: Option>, diff --git a/crates/apollo_node_config/src/config_serde_symmetry_test.rs b/crates/apollo_node_config/src/config_serde_symmetry_test.rs index cd7bd21cad0..45b28aa6db8 100644 --- a/crates/apollo_node_config/src/config_serde_symmetry_test.rs +++ b/crates/apollo_node_config/src/config_serde_symmetry_test.rs @@ -130,7 +130,7 @@ fn consensus_manager_config_round_trips() { fn network_config_round_trips() { // Covers apollo_network directly: NetworkConfig::{session_timeout, idle_connection_timeout, // prune_dead_connections_ping_interval, prune_dead_connections_ping_timeout (seconds), - // bootstrap_peer_multiaddr (comma-separated list)}, and (via sub-structs) + // bootstrap_peer_multiaddr (native JSON array)}, and (via sub-structs) // DiscoveryConfig::heartbeat_interval, RetryConfig::{max_delay_seconds, // new_connection_stabilization_millis}, PeerManagerConfig::{malicious_timeout_seconds, // unstable_timeout_millis}. diff --git a/deployments/monitoring/local/docker-compose.yml b/deployments/monitoring/local/docker-compose.yml index ff984436de8..a2ac00423ad 100644 --- a/deployments/monitoring/local/docker-compose.yml +++ b/deployments/monitoring/local/docker-compose.yml @@ -130,7 +130,7 @@ services: jq '.components.l1_gas_price_scraper.execution_mode = "Disabled"' "$$cfg" | sponge "$$cfg" if [ "$$N_NODES" -gt 1 ]; then for key in consensus_manager_config.network_config.bootstrap_peer_multiaddr mempool_p2p_config.network_config.bootstrap_peer_multiaddr state_sync_config.static_config.network_config.bootstrap_peer_multiaddr; do - jq --arg k "$$key" '($$k / ".") as $$p | if getpath($$p) == null then . else setpath($$p; getpath($$p) | split(",") | to_entries | map(.key as $$j | .value | sub("/ip4/[0-9.]+/"; "/dns4/sequencer-node-\($$j)/")) | join(",")) end' "$$cfg" | sponge "$$cfg" + jq --arg k "$$key" '($$k / ".") as $$p | if getpath($$p) == null then . else setpath($$p; getpath($$p) | to_entries | map(.key as $$j | .value | sub("/ip4/[0-9.]+/"; "/dns4/sequencer-node-\($$j)/"))) end' "$$cfg" | sponge "$$cfg" done fi done diff --git a/deployments/sequencer/configs/jsonnet/lib/applicative_config/utils.libsonnet b/deployments/sequencer/configs/jsonnet/lib/applicative_config/utils.libsonnet index b768497491f..4fec84405c0 100644 --- a/deployments/sequencer/configs/jsonnet/lib/applicative_config/utils.libsonnet +++ b/deployments/sequencer/configs/jsonnet/lib/applicative_config/utils.libsonnet @@ -1,6 +1,6 @@ { advertisedMultiaddr(bootstrap_peer_multiaddr, node_index, nodes_at_same_cluster):: if !nodes_at_same_cluster && bootstrap_peer_multiaddr != null - then std.split(bootstrap_peer_multiaddr, ',')[node_index] + then bootstrap_peer_multiaddr[node_index] else null, }