diff --git a/boost_manager/tests/integrations/activator_tests.rs b/boost_manager/tests/integrations/activator_tests.rs index ae842fc70..0212fcc26 100644 --- a/boost_manager/tests/integrations/activator_tests.rs +++ b/boost_manager/tests/integrations/activator_tests.rs @@ -1,6 +1,8 @@ use boost_manager::{activator, db, OnChainStatus}; use chrono::{DateTime, Duration as ChronoDuration, Duration, Timelike, Utc}; -use mobile_config::boosted_hex_info::{BoostedHex, BoostedHexInfo, BoostedHexes}; +use mobile_config::boosted_hex_info::{ + BoostedHex, BoostedHexDeviceType, BoostedHexInfo, BoostedHexes, +}; use solana_sdk::pubkey::Pubkey; use sqlx::PgPool; use std::{num::NonZeroU32, str::FromStr}; @@ -50,6 +52,7 @@ impl TestContext { boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { location: 0x8a1fb49642dffff_u64.try_into().expect("valid h3 cell"), @@ -60,6 +63,7 @@ impl TestContext { boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { // hotspot 3's location @@ -71,6 +75,7 @@ impl TestContext { boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, ]; Ok(Self { diff --git a/boost_manager/tests/integrations/watcher_tests.rs b/boost_manager/tests/integrations/watcher_tests.rs index 64f42c0a4..78d180eca 100644 --- a/boost_manager/tests/integrations/watcher_tests.rs +++ b/boost_manager/tests/integrations/watcher_tests.rs @@ -2,7 +2,10 @@ use crate::common::{self, MockFileSinkReceiver, MockHexBoostingClient}; use boost_manager::watcher::{self, Watcher}; use chrono::{Duration as ChronoDuration, Duration, Utc}; use helium_proto::BoostedHexInfoV1 as BoostedHexInfoProto; -use mobile_config::boosted_hex_info::BoostedHexInfo; +use mobile_config::{ + boosted_hex_info::{BoostedHexDeviceType, BoostedHexInfo, BoostedHexInfoStream}, + client::{hex_boosting_client::HexBoostingInfoResolver, ClientError}, +}; use solana_sdk::pubkey::Pubkey; use sqlx::PgPool; use std::{num::NonZeroU32, str::FromStr}; @@ -45,6 +48,7 @@ async fn test_boosted_hex_updates_to_filestore(pool: PgPool) -> anyhow::Result<( boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { location: 0x8a1fb49642dffff_u64.try_into().expect("valid h3 cell"), @@ -55,6 +59,7 @@ async fn test_boosted_hex_updates_to_filestore(pool: PgPool) -> anyhow::Result<( boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, ]; diff --git a/mobile_config/src/boosted_hex_info.rs b/mobile_config/src/boosted_hex_info.rs index df2082192..a6db29f35 100644 --- a/mobile_config/src/boosted_hex_info.rs +++ b/mobile_config/src/boosted_hex_info.rs @@ -3,6 +3,7 @@ use chrono::{DateTime, Duration, Utc}; use file_store::traits::TimestampDecode; use futures::stream::{BoxStream, StreamExt}; use helium_proto::services::poc_mobile::BoostedHex as BoostedHexProto; +use helium_proto::BoostedHexDeviceTypeV1 as BoostedHexDeviceTypeProto; use helium_proto::BoostedHexInfoV1 as BoostedHexInfoProto; use hextree::Cell; use solana_sdk::pubkey::Pubkey; @@ -24,12 +25,14 @@ pub struct BoostedHexInfo { pub boosted_hex_pubkey: Pubkey, pub boost_config_pubkey: Pubkey, pub version: u32, + pub device_type: BoostedHexDeviceType, } impl TryFrom for BoostedHexInfo { type Error = anyhow::Error; fn try_from(v: BoostedHexInfoProto) -> anyhow::Result { let period_length = Duration::seconds(v.period_length as i64); + let device_type = v.device_type(); let multipliers = v .multipliers .into_iter() @@ -49,6 +52,7 @@ impl TryFrom for BoostedHexInfo { boosted_hex_pubkey, boost_config_pubkey, version: v.version, + device_type: device_type.into(), }) } } @@ -73,6 +77,7 @@ impl TryFrom for BoostedHexInfoProto { boosted_hex_pubkey: v.boosted_hex_pubkey.to_bytes().into(), boost_config_pubkey: v.boost_config_pubkey.to_bytes().into(), version: v.version, + device_type: v.device_type.into(), }) } } @@ -102,6 +107,53 @@ impl BoostedHexInfo { } } +#[derive(Debug, Clone)] +pub enum BoostedHexDeviceType { + All, + CbrsIndoor, + CbrsOutdoor, + WifiIndoor, + WifiOutdoor, +} + +impl From for BoostedHexDeviceType { + fn from(device_type_proto: BoostedHexDeviceTypeProto) -> Self { + match device_type_proto { + BoostedHexDeviceTypeProto::All => Self::All, + BoostedHexDeviceTypeProto::CbrsIndoor => Self::CbrsIndoor, + BoostedHexDeviceTypeProto::CbrsOutdoor => Self::CbrsOutdoor, + BoostedHexDeviceTypeProto::WifiIndoor => Self::WifiIndoor, + BoostedHexDeviceTypeProto::WifiOutdoor => Self::WifiOutdoor, + } + } +} + +impl From for BoostedHexDeviceTypeProto { + fn from(device_type: BoostedHexDeviceType) -> Self { + match device_type { + BoostedHexDeviceType::All => Self::All, + BoostedHexDeviceType::CbrsIndoor => Self::CbrsIndoor, + BoostedHexDeviceType::CbrsOutdoor => Self::CbrsOutdoor, + BoostedHexDeviceType::WifiIndoor => Self::WifiIndoor, + BoostedHexDeviceType::WifiOutdoor => Self::WifiOutdoor, + } + } +} + +impl From for i32 { + fn from(device_type: BoostedHexDeviceType) -> Self { + BoostedHexDeviceTypeProto::from(device_type) as i32 + } +} + +impl TryFrom for BoostedHexDeviceType { + type Error = helium_proto::DecodeError; + + fn try_from(db_value: i32) -> Result { + Ok(BoostedHexDeviceTypeProto::try_from(db_value)?.into()) + } +} + #[derive(Debug, Clone, Default)] pub struct BoostedHexes { hexes: HashMap, @@ -280,6 +332,12 @@ pub(crate) mod db { let location = Cell::try_from(row.get::("location")) .map_err(|e| sqlx::Error::Decode(Box::new(e)))?; + let device_type = match row.get::, &str>("device_type") { + None => super::BoostedHexDeviceType::All, + Some(val) => super::BoostedHexDeviceType::try_from(val) + .map_err(|e| sqlx::Error::Decode(Box::new(e)))?, + }; + Ok(Self { location, start_ts, @@ -289,6 +347,7 @@ pub(crate) mod db { boosted_hex_pubkey, boost_config_pubkey, version, + device_type, }) } } @@ -337,6 +396,7 @@ mod tests { .to_bytes() .to_vec(), version: 1, + device_type: BoostedHexDeviceTypeProto::All.into(), }; let msg = BoostedHexInfo::try_from(proto)?; @@ -378,6 +438,7 @@ mod tests { .to_bytes() .to_vec(), version: 1, + device_type: BoostedHexDeviceTypeProto::All.into(), }; let msg = BoostedHexInfo::try_from(proto)?; @@ -413,6 +474,7 @@ mod tests { boosted_hex_pubkey: BOOST_HEX_PUBKEY.as_bytes().to_vec(), boost_config_pubkey: BOOST_HEX_CONFIG_PUBKEY.as_bytes().to_vec(), version: 1, + device_type: BoostedHexDeviceTypeProto::All.into(), }; assert_eq!( "multipliers cannot contain values of 0", diff --git a/mobile_verifier/tests/integrations/hex_boosting.rs b/mobile_verifier/tests/integrations/hex_boosting.rs index ae11f4363..bfbe42343 100644 --- a/mobile_verifier/tests/integrations/hex_boosting.rs +++ b/mobile_verifier/tests/integrations/hex_boosting.rs @@ -14,7 +14,10 @@ use helium_proto::services::{ }, }; use hextree::Cell; -use mobile_config::boosted_hex_info::BoostedHexInfo; +use mobile_config::{ + boosted_hex_info::{BoostedHexDeviceType, BoostedHexInfo, BoostedHexInfoStream}, + client::{hex_boosting_client::HexBoostingInfoResolver, ClientError}, +}; use mobile_verifier::{ cell_type::CellType, coverage::CoverageObject, @@ -106,6 +109,7 @@ async fn test_poc_with_boosted_hexes(pool: PgPool) -> anyhow::Result<()> { boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { // hotspot 2's location @@ -117,6 +121,7 @@ async fn test_poc_with_boosted_hexes(pool: PgPool) -> anyhow::Result<()> { boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { // hotspot 3's location @@ -128,6 +133,7 @@ async fn test_poc_with_boosted_hexes(pool: PgPool) -> anyhow::Result<()> { boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, ]; @@ -294,6 +300,7 @@ async fn test_poc_boosted_hexes_thresholds_not_met(pool: PgPool) -> anyhow::Resu boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { // hotspot 2's location @@ -305,6 +312,7 @@ async fn test_poc_boosted_hexes_thresholds_not_met(pool: PgPool) -> anyhow::Resu boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { // hotspot 3's location @@ -316,6 +324,7 @@ async fn test_poc_boosted_hexes_thresholds_not_met(pool: PgPool) -> anyhow::Resu boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, ]; @@ -442,6 +451,7 @@ async fn test_poc_with_multi_coverage_boosted_hexes(pool: PgPool) -> anyhow::Res boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { // hotspot 1's second covered location @@ -453,6 +463,7 @@ async fn test_poc_with_multi_coverage_boosted_hexes(pool: PgPool) -> anyhow::Res boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { // hotspot 2's location @@ -464,6 +475,7 @@ async fn test_poc_with_multi_coverage_boosted_hexes(pool: PgPool) -> anyhow::Res boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { // hotspot 3's location @@ -475,6 +487,7 @@ async fn test_poc_with_multi_coverage_boosted_hexes(pool: PgPool) -> anyhow::Res boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, ]; @@ -643,6 +656,7 @@ async fn test_expired_boosted_hex(pool: PgPool) -> anyhow::Result<()> { boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { location: Cell::from_raw(0x8a1fb49642dffff_u64)?, @@ -653,6 +667,7 @@ async fn test_expired_boosted_hex(pool: PgPool) -> anyhow::Result<()> { boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, ]; @@ -771,6 +786,7 @@ async fn test_reduced_location_score_with_boosted_hexes(pool: PgPool) -> anyhow: boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { // hotspot 3's location @@ -782,6 +798,7 @@ async fn test_reduced_location_score_with_boosted_hexes(pool: PgPool) -> anyhow: boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, ]; @@ -1134,6 +1151,7 @@ async fn test_poc_with_cbrs_and_multi_coverage_boosted_hexes(pool: PgPool) -> an boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { // hotspot 1's second covered location @@ -1145,6 +1163,7 @@ async fn test_poc_with_cbrs_and_multi_coverage_boosted_hexes(pool: PgPool) -> an boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { // hotspot 2's location @@ -1156,6 +1175,7 @@ async fn test_poc_with_cbrs_and_multi_coverage_boosted_hexes(pool: PgPool) -> an boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, BoostedHexInfo { // hotspot 3's location @@ -1167,6 +1187,7 @@ async fn test_poc_with_cbrs_and_multi_coverage_boosted_hexes(pool: PgPool) -> an boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }, ]; diff --git a/mobile_verifier/tests/integrations/modeled_coverage.rs b/mobile_verifier/tests/integrations/modeled_coverage.rs index c5ae9e4f0..c4f846fd7 100644 --- a/mobile_verifier/tests/integrations/modeled_coverage.rs +++ b/mobile_verifier/tests/integrations/modeled_coverage.rs @@ -13,7 +13,7 @@ use helium_proto::services::{ poc_mobile::{CoverageObjectValidity, LocationSource, SignalLevel}, }; use hextree::Cell; -use mobile_config::boosted_hex_info::{BoostedHexInfo, BoostedHexes}; +use mobile_config::boosted_hex_info::{BoostedHexDeviceType, BoostedHexInfo, BoostedHexes}; use mobile_verifier::{ coverage::{CoverageClaimTimeCache, CoverageObject, CoverageObjectCache}, @@ -850,6 +850,7 @@ async fn scenario_three(pool: PgPool) -> anyhow::Result<()> { boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }); boosted_hexes.insert(BoostedHexInfo { location: Cell::from_raw(0x8a1fb49642dffff)?, @@ -860,6 +861,7 @@ async fn scenario_three(pool: PgPool) -> anyhow::Result<()> { boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }); boosted_hexes.insert(BoostedHexInfo { // hotspot 1's location @@ -871,6 +873,7 @@ async fn scenario_three(pool: PgPool) -> anyhow::Result<()> { boosted_hex_pubkey: Pubkey::from_str(BOOST_HEX_PUBKEY).unwrap(), boost_config_pubkey: Pubkey::from_str(BOOST_CONFIG_PUBKEY).unwrap(), version: 0, + device_type: BoostedHexDeviceType::All, }); let reward_period = start..end;