diff --git a/Cargo.lock b/Cargo.lock index 69dd263bc..39e95b2ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4597,6 +4597,7 @@ dependencies = [ "hextree", "http 0.2.11", "http-serde", + "humantime-serde", "lazy_static", "metrics", "metrics-exporter-prometheus", diff --git a/boost_manager/src/settings.rs b/boost_manager/src/settings.rs index 486ecf827..809457d6b 100644 --- a/boost_manager/src/settings.rs +++ b/boost_manager/src/settings.rs @@ -58,11 +58,11 @@ fn default_activation_check_interval() -> Duration { humantime::parse_duration("15 minutes").unwrap() } -pub fn default_start_after() -> DateTime { +fn default_start_after() -> DateTime { DateTime::UNIX_EPOCH } -pub fn default_log() -> String { +fn default_log() -> String { "boost_manager=info".to_string() } diff --git a/denylist/src/settings.rs b/denylist/src/settings.rs index 1c46da190..8873606a4 100644 --- a/denylist/src/settings.rs +++ b/denylist/src/settings.rs @@ -23,11 +23,11 @@ pub struct Settings { pub sign_keys: Vec, } -pub fn default_log() -> String { +fn default_log() -> String { "denylist=debug".to_string() } -pub fn default_denylist_url() -> String { +fn default_denylist_url() -> String { "https://api.github.com/repos/helium/denylist/releases/latest".to_string() } diff --git a/ingest/src/settings.rs b/ingest/src/settings.rs index 59cde6922..a4c5f1274 100644 --- a/ingest/src/settings.rs +++ b/ingest/src/settings.rs @@ -40,23 +40,23 @@ pub struct Settings { pub metrics: poc_metrics::Settings, } -pub fn default_session_key_timeout() -> Duration { +fn default_session_key_timeout() -> Duration { humantime::parse_duration("30 minutes").unwrap() } -pub fn default_session_key_offer_timeout() -> Duration { +fn default_session_key_offer_timeout() -> Duration { humantime::parse_duration("5 seconds").unwrap() } -pub fn default_listen_addr() -> SocketAddr { +fn default_listen_addr() -> SocketAddr { "0.0.0.0:9081".parse().unwrap() } -pub fn default_log() -> String { +fn default_log() -> String { "ingest=debug,poc_store=info".to_string() } -pub fn default_sink() -> String { +fn default_sink() -> String { "/var/data/ingest".to_string() } diff --git a/iot_config/src/client/settings.rs b/iot_config/src/client/settings.rs index 28efa9ba3..fc9e50c46 100644 --- a/iot_config/src/client/settings.rs +++ b/iot_config/src/client/settings.rs @@ -21,15 +21,15 @@ pub struct Settings { pub batch_size: u32, } -pub fn default_connect_timeout() -> u64 { +fn default_connect_timeout() -> u64 { 5 } -pub fn default_rpc_timeout() -> u64 { +fn default_rpc_timeout() -> u64 { 5 } -pub fn default_batch_size() -> u32 { +fn default_batch_size() -> u32 { 1000 } diff --git a/iot_config/src/settings.rs b/iot_config/src/settings.rs index 656f4a4dc..95938cafa 100644 --- a/iot_config/src/settings.rs +++ b/iot_config/src/settings.rs @@ -27,15 +27,15 @@ pub struct Settings { pub metrics: poc_metrics::Settings, } -pub fn default_log() -> String { +fn default_log() -> String { "iot_config=debug".to_string() } -pub fn default_listen_addr() -> SocketAddr { +fn default_listen_addr() -> SocketAddr { "0.0.0.0:8080".parse().unwrap() } -pub fn default_deleted_entry_retention() -> Duration { +fn default_deleted_entry_retention() -> Duration { humantime::parse_duration("48 hours").unwrap() } diff --git a/iot_packet_verifier/src/settings.rs b/iot_packet_verifier/src/settings.rs index 37554beab..b30f253b9 100644 --- a/iot_packet_verifier/src/settings.rs +++ b/iot_packet_verifier/src/settings.rs @@ -36,23 +36,23 @@ pub struct Settings { pub monitor_funds_period: Duration, } -pub fn default_start_after() -> DateTime { +fn default_start_after() -> DateTime { DateTime::UNIX_EPOCH } -pub fn default_burn_period() -> Duration { +fn default_burn_period() -> Duration { humantime::parse_duration("1 minute").unwrap() } -pub fn default_log() -> String { +fn default_log() -> String { "iot_packet_verifier=debug".to_string() } -pub fn default_minimum_allowed_balance() -> u64 { +fn default_minimum_allowed_balance() -> u64 { 3_500_000 } -pub fn default_monitor_funds_period() -> Duration { +fn default_monitor_funds_period() -> Duration { humantime::parse_duration("30 minutes").unwrap() } diff --git a/iot_verifier/src/settings.rs b/iot_verifier/src/settings.rs index 1abf3e13e..a1aae945a 100644 --- a/iot_verifier/src/settings.rs +++ b/iot_verifier/src/settings.rs @@ -53,10 +53,6 @@ pub struct Settings { /// beaconing bucket sizes #[serde(with = "humantime_serde", default = "default_beacon_interval")] pub beacon_interval: Duration, - // FIXME: unused - /// Trigger interval for generating a transmit scaling map - #[serde(with = "humantime_serde", default = "default_transmit_scale_interval")] - pub transmit_scale_interval: Duration, // roll up time defined in the ingestors ( in seconds ) // ie the time after which they will write out files to s3 // this will be used when padding out the witness @@ -72,10 +68,6 @@ pub struct Settings { /// cadence for how often to look for poc reports from s3 buckets #[serde(with = "humantime_serde", default = "default_poc_loader_poll_time")] pub poc_loader_poll_time: Duration, - // FIXME: unused - /// the lifespan of a piece of entropy - #[serde(with = "humantime_serde", default = "default_entropy_lifespan ")] - pub entropy_lifespan: Duration, /// max window age for the poc report loader ( in seconds ) /// the starting point of the window will never be older than now - max age #[serde( @@ -125,10 +117,6 @@ fn default_entropy_interval() -> Duration { humantime::parse_duration("5 minutes").unwrap() } -fn default_entropy_lifespan() -> Duration { - humantime::parse_duration("5 minutes").unwrap() -} - fn default_poc_loader_window_width() -> Duration { humantime::parse_duration("5 minutes").unwrap() } @@ -151,10 +139,6 @@ fn default_beacon_interval() -> Duration { humantime::parse_duration("6 hours").unwrap() } -fn default_transmit_scale_interval() -> Duration { - humantime::parse_duration("30 minutes").unwrap() -} - fn default_log() -> String { "iot_verifier=debug,poc_store=info".to_string() } @@ -230,7 +214,6 @@ impl Settings { } pub fn beacon_interval(&self) -> anyhow::Result { - // FIXME: // validate the beacon_interval value is a factor of 24, if not bail out if (24 * 60 * 60) % self.beacon_interval.as_secs() != 0 { bail!("beacon interval is not a factor of 24") diff --git a/mobile_config/Cargo.toml b/mobile_config/Cargo.toml index a686c6744..87b55125c 100644 --- a/mobile_config/Cargo.toml +++ b/mobile_config/Cargo.toml @@ -44,6 +44,7 @@ triggered = { workspace = true } task-manager = { path = "../task_manager" } solana-sdk = { workspace = true } custom-tracing = { path = "../custom_tracing", features = ["grpc"] } +humantime-serde = { workspace = true } [dev-dependencies] rand = { workspace = true } diff --git a/mobile_config/src/client/authorization_client.rs b/mobile_config/src/client/authorization_client.rs index 37a99d2f4..8a4144a0e 100644 --- a/mobile_config/src/client/authorization_client.rs +++ b/mobile_config/src/client/authorization_client.rs @@ -43,7 +43,7 @@ impl AuthorizationClient { client: settings.connect_authorization_client(), signing_key: settings.signing_keypair()?, config_pubkey: settings.config_pubkey()?, - cache_ttl: settings.cache_ttl(), + cache_ttl: settings.cache_ttl, cache, }) } diff --git a/mobile_config/src/client/carrier_service_client.rs b/mobile_config/src/client/carrier_service_client.rs index 672612595..3a55ad4dd 100644 --- a/mobile_config/src/client/carrier_service_client.rs +++ b/mobile_config/src/client/carrier_service_client.rs @@ -77,7 +77,7 @@ impl CarrierServiceClient { client: settings.connect_carrier_service_client(), signing_key: settings.signing_keypair()?, config_pubkey: settings.config_pubkey()?, - cache_ttl: settings.cache_ttl(), + cache_ttl: settings.cache_ttl, cache, }) } diff --git a/mobile_config/src/client/entity_client.rs b/mobile_config/src/client/entity_client.rs index dccfd411e..510a882c2 100644 --- a/mobile_config/src/client/entity_client.rs +++ b/mobile_config/src/client/entity_client.rs @@ -74,7 +74,7 @@ impl EntityClient { client: settings.connect_entity_client(), signing_key: settings.signing_keypair()?, config_pubkey: settings.config_pubkey()?, - cache_ttl: settings.cache_ttl(), + cache_ttl: settings.cache_ttl, cache, }) } diff --git a/mobile_config/src/client/gateway_client.rs b/mobile_config/src/client/gateway_client.rs index b27900962..69ab7f128 100644 --- a/mobile_config/src/client/gateway_client.rs +++ b/mobile_config/src/client/gateway_client.rs @@ -35,7 +35,7 @@ impl GatewayClient { signing_key: settings.signing_keypair()?, config_pubkey: settings.config_pubkey()?, batch_size: settings.batch_size, - cache_ttl: settings.cache_ttl(), + cache_ttl: settings.cache_ttl, cache, }) } diff --git a/mobile_config/src/client/settings.rs b/mobile_config/src/client/settings.rs index ff73f8dff..902381fd3 100644 --- a/mobile_config/src/client/settings.rs +++ b/mobile_config/src/client/settings.rs @@ -1,4 +1,5 @@ use helium_proto::services::{mobile_config, Channel, Endpoint}; +use humantime_serde::re::humantime; use serde::Deserialize; use std::{str::FromStr, sync::Arc, time::Duration}; @@ -12,39 +13,39 @@ pub struct Settings { /// B58 encoded public key of the mobile config server for verification pub config_pubkey: String, /// Connect timeout for the mobile config client in seconds. Default 5 - #[serde(default = "default_connect_timeout")] - pub connect_timeout: u64, + #[serde(with = "humantime_serde", default = "default_connect_timeout")] + pub connect_timeout: Duration, /// RPC timeout for mobile config client in seconds. Default 5 - #[serde(default = "default_rpc_timeout")] - pub rpc_timeout: u64, + #[serde(with = "humantime_serde", default = "default_rpc_timeout")] + pub rpc_timeout: Duration, /// Batch size for hotspot metadata stream results. Default 100 #[serde(default = "default_batch_size")] pub batch_size: u32, /// Batch size for hex boosting stream results. Default 100 #[serde(default = "default_hex_boosting_batch_size")] pub hex_boosting_batch_size: u32, - #[serde(default = "default_cache_ttl_in_secs")] - pub cache_ttl_in_secs: u64, + #[serde(with = "humantime_serde", default = "default_cache_ttl_in_secs")] + pub cache_ttl: Duration, } -pub fn default_connect_timeout() -> u64 { - 5 +fn default_connect_timeout() -> Duration { + humantime::parse_duration("5 seconds").unwrap() } -pub fn default_rpc_timeout() -> u64 { - 5 +fn default_rpc_timeout() -> Duration { + humantime::parse_duration("5 seconds").unwrap() } -pub fn default_batch_size() -> u32 { +fn default_batch_size() -> u32 { 100 } -pub fn default_hex_boosting_batch_size() -> u32 { +fn default_hex_boosting_batch_size() -> u32 { 100 } -pub fn default_cache_ttl_in_secs() -> u64 { - 60 * 60 +fn default_cache_ttl_in_secs() -> Duration { + humantime::parse_duration("1 hour").unwrap() } impl Settings { @@ -83,15 +84,11 @@ impl Settings { pub fn config_pubkey(&self) -> Result { helium_crypto::PublicKey::from_str(&self.config_pubkey) } - - pub fn cache_ttl(&self) -> std::time::Duration { - std::time::Duration::from_secs(self.cache_ttl_in_secs) - } } fn connect_channel(settings: &Settings) -> Channel { Endpoint::from(settings.url.clone()) - .connect_timeout(Duration::from_secs(settings.connect_timeout)) - .timeout(Duration::from_secs(settings.rpc_timeout)) + .connect_timeout(settings.connect_timeout) + .timeout(settings.rpc_timeout) .connect_lazy() } diff --git a/mobile_config/src/settings.rs b/mobile_config/src/settings.rs index 71028a5aa..10a20f479 100644 --- a/mobile_config/src/settings.rs +++ b/mobile_config/src/settings.rs @@ -27,11 +27,11 @@ pub struct Settings { pub metrics: poc_metrics::Settings, } -pub fn default_log() -> String { +fn default_log() -> String { "mobile_config=debug".to_string() } -pub fn default_listen_addr() -> SocketAddr { +fn default_listen_addr() -> SocketAddr { "0.0.0.0:8080".parse().unwrap() } diff --git a/poc_entropy/src/settings.rs b/poc_entropy/src/settings.rs index 35f6e6bf9..126553c5a 100644 --- a/poc_entropy/src/settings.rs +++ b/poc_entropy/src/settings.rs @@ -24,15 +24,15 @@ pub struct Settings { pub metrics: poc_metrics::Settings, } -pub fn default_log() -> String { +fn default_log() -> String { "poc_entropy=debug,poc_store=info".to_string() } -pub fn default_cache() -> String { +fn default_cache() -> String { "/var/data/entropy".to_string() } -pub fn default_listen_addr() -> String { +fn default_listen_addr() -> String { "0.0.0.0:8080".to_string() } diff --git a/price/src/settings.rs b/price/src/settings.rs index 42225aab7..8077ee5d2 100644 --- a/price/src/settings.rs +++ b/price/src/settings.rs @@ -83,7 +83,7 @@ fn default_stale_price_duration() -> Duration { humantime::parse_duration("12 hours").unwrap() } -pub fn default_cache() -> String { +fn default_cache() -> String { "/var/data/price".to_string() }