Skip to content

Commit

Permalink
Merge branch 'main' into min_update_at
Browse files Browse the repository at this point in the history
  • Loading branch information
kurotych committed Dec 12, 2024
2 parents df16f90 + c25d18b commit 7088f65
Show file tree
Hide file tree
Showing 31 changed files with 1,418 additions and 218 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 59 additions & 9 deletions coverage_point_calculator/src/hexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,18 @@ pub(crate) fn clean_covered_hexes(

// hip-131: if the radio is banned, it automatically gets an assignment_multiplier of 0.0
// hip-103: if a hex is boosted by a service provider >=1x, the oracle
// multiplier will automatically be 1x, regardless of boosted_hex_status.
let assignment_multiplier = if oracle_boosting_status == OracleBoostingStatus::Banned {
dec!(0)
} else if ranked.boosted.is_some() {
dec!(1)
} else {
ranked.assignments.boosting_multiplier()
// multiplier will automatically be 1x, regardless of boosted_hex_status.
// hip-134: qualified radios earn full Oracle Boosting rewards
let assignment_multiplier = match oracle_boosting_status {
OracleBoostingStatus::Qualified if radio_type.is_wifi() => dec!(1),
OracleBoostingStatus::Banned => dec!(0),
OracleBoostingStatus::Qualified | OracleBoostingStatus::Eligible => {
if ranked.boosted.is_some() {
dec!(1)
} else {
ranked.assignments.boosting_multiplier()
}
}
};

let base_coverage_points =
Expand Down Expand Up @@ -209,9 +214,54 @@ mod tests {
)
.unwrap();

dbg!(&covered_hexes);

assert_eq!(dec!(0), covered_hexes[0].assignment_multiplier);
assert_eq!(dec!(0), covered_hexes[1].assignment_multiplier);
}

#[rstest]
fn hip134_qualified_radio(
#[values(
OracleBoostingStatus::Qualified,
OracleBoostingStatus::Eligible,
OracleBoostingStatus::Banned
)]
boost_status: OracleBoostingStatus,
#[values(
RadioType::IndoorCbrs,
RadioType::OutdoorCbrs,
RadioType::IndoorWifi,
RadioType::OutdoorWifi
)]
radio_type: RadioType,
) {
let coverage = RankedCoverage {
hotspot_key: vec![1],
cbsd_id: None,
hex: hextree::Cell::from_raw(0x8c2681a3064edff).unwrap(),
rank: 1,
signal_level: SignalLevel::High,
assignments: HexAssignments {
footfall: Assignment::C,
landtype: Assignment::C,
urbanized: Assignment::C,
},
boosted: NonZeroU32::new(0),
};

let covered_hexes = clean_covered_hexes(
radio_type,
SpBoostedHexStatus::Eligible,
vec![coverage],
boost_status,
)
.unwrap();

// Only Qualified WIFI radios should bypass bad assignment multiplier
let expected_multiplier = match boost_status {
OracleBoostingStatus::Qualified if radio_type.is_wifi() => dec!(1),
_ => dec!(0),
};

assert_eq!(expected_multiplier, covered_hexes[0].assignment_multiplier);
}
}
28 changes: 18 additions & 10 deletions coverage_point_calculator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
//! - [CoveredHex::assignment_multiplier]
//! - [HIP-103][oracle-boosting]
//! - provider boosted hexes increase oracle boosting to 1x
//! - [HIP-134][carrier-offload]
//! - serving >25 unique connection increase oracle boosting to 1x
//!
//! - [CoveredHex::rank]
//! - [HIP-105][hex-limits]
Expand Down Expand Up @@ -44,13 +46,14 @@
//! - If a Radio is not [BoostedHexStatus::Eligible], boost values are removed before calculations.
//! - If a Hex is boosted by a Provider, the Oracle Assignment multiplier is automatically 1x.
//!
//! - [ServiceProviderBoostedRewardEligibility]
//! - [SPBoostedRewardEligibility]
//! - Radio must pass at least 1mb of data from 3 unique phones [HIP-84][provider-boosting]
//! - Service Provider can invalidate boosted rewards of a hotspot [HIP-125][provider-banning]
//!
//! - [OracleBoostingStatus]
//! - Eligible: Radio is eligible for normal oracle boosting multipliers
//! - Banned: Radio is banned according to hip-131 rules and all assignment_multipliers are 0.0
//! - Qualified: Radio serves >25 unique connections, automatic oracle boosting multiplier of 1x
//!
//! [modeled-coverage]: https://github.com/helium/HIP/blob/main/0074-mobile-poc-modeled-coverage-rewards.md#outdoor-radios
//! [provider-boosting]: https://github.com/helium/HIP/blob/main/0084-service-provider-hex-boosting.md
Expand All @@ -65,6 +68,7 @@
//! [location-gaming]: https://github.com/helium/HIP/blob/main/0119-closing-gaming-loopholes-within-the-mobile-network.md
//! [provider-banning]: https://github.com/helium/HIP/blob/main/0125-temporary-anti-gaming-measures-for-boosted-hexes.md
//! [anti-gaming]: https://github.com/helium/HIP/blob/main/0131-bridging-gap-between-verification-mappers-and-anti-gaming-measures.md
//! [carrier-offload]: https://github.com/helium/HIP/blob/main/0134-reward-mobile-carrier-offload-hotspots.md
//!
pub use crate::{
hexes::{CoveredHex, HexPoints},
Expand Down Expand Up @@ -136,10 +140,12 @@ pub struct CoveragePoints {
pub speedtest_multiplier: Decimal,
/// Input Radio Type
pub radio_type: RadioType,
/// Input ServiceProviderBoostedRewardEligibility
/// Input SPBoostedRewardEligibility
pub service_provider_boosted_reward_eligibility: SPBoostedRewardEligibility,
/// Derived Eligibility for Boosted Hex Rewards
pub boosted_hex_eligibility: SpBoostedHexStatus,
/// Derived Eligibility for Service Provider Boosted Hex Rewards
pub sp_boosted_hex_eligibility: SpBoostedHexStatus,
/// Derived Eligibility for Oracle Boosted Hex Rewards
pub oracle_boosted_hex_eligibility: OracleBoostingStatus,
/// Speedtests used in calculation
pub speedtests: Vec<Speedtest>,
/// Location Trust Scores used in calculation
Expand All @@ -157,11 +163,11 @@ impl CoveragePoints {
speedtests: Vec<Speedtest>,
location_trust_scores: Vec<LocationTrust>,
ranked_coverage: Vec<coverage_map::RankedCoverage>,
oracle_boosting_status: OracleBoostingStatus,
oracle_boost_status: OracleBoostingStatus,
) -> Result<CoveragePoints> {
let location_trust_multiplier = location::multiplier(radio_type, &location_trust_scores);

let boost_eligibility = SpBoostedHexStatus::new(
let sp_boost_eligibility = SpBoostedHexStatus::new(
radio_type,
location_trust_multiplier,
&location_trust_scores,
Expand All @@ -170,9 +176,9 @@ impl CoveragePoints {

let covered_hexes = hexes::clean_covered_hexes(
radio_type,
boost_eligibility,
sp_boost_eligibility,
ranked_coverage,
oracle_boosting_status,
oracle_boost_status,
)?;

let hex_coverage_points = hexes::calculated_coverage_points(&covered_hexes);
Expand All @@ -187,7 +193,8 @@ impl CoveragePoints {
speedtest_avg,
radio_type,
service_provider_boosted_reward_eligibility,
boosted_hex_eligibility: boost_eligibility,
sp_boosted_hex_eligibility: sp_boost_eligibility,
oracle_boosted_hex_eligibility: oracle_boost_status,
speedtests,
location_trust_scores,
covered_hexes,
Expand Down Expand Up @@ -230,7 +237,7 @@ impl CoveragePoints {
}

fn boosted_points(&self) -> Decimal {
match self.boosted_hex_eligibility {
match self.sp_boosted_hex_eligibility {
SpBoostedHexStatus::Eligible => self.coverage_points.boosted,
SpBoostedHexStatus::WifiLocationScoreBelowThreshold(_) => dec!(0),
SpBoostedHexStatus::AverageAssertedDistanceOverLimit(_) => dec!(0),
Expand All @@ -244,6 +251,7 @@ impl CoveragePoints {
pub enum OracleBoostingStatus {
Eligible,
Banned,
Qualified,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand Down
16 changes: 14 additions & 2 deletions file_store/src/cli/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::{
mobile_subscriber::{SubscriberLocationIngestReport, VerifiedSubscriberLocationIngestReport},
speedtest::{CellSpeedtest, CellSpeedtestIngestReport},
traits::{MsgDecode, TimestampDecode},
usage_counts::{HexUsageCountsIngestReport, RadioUsageCountsIngestReport},
wifi_heartbeat::WifiHeartbeatIngestReport,
FileType, Result, Settings,
};
Expand All @@ -26,8 +27,9 @@ use helium_proto::{
},
poc_mobile::{
mobile_reward_share::Reward, CellHeartbeatIngestReportV1, CellHeartbeatReqV1,
CoverageObjectV1, Heartbeat, InvalidDataTransferIngestReportV1, MobileRewardShare,
OracleBoostingReportV1, RadioRewardShare, SpeedtestAvg, SpeedtestIngestReportV1,
CoverageObjectV1, Heartbeat, HexUsageStatsIngestReportV1,
InvalidDataTransferIngestReportV1, MobileRewardShare, OracleBoostingReportV1,
RadioRewardShare, RadioUsageStatsIngestReportV1, SpeedtestAvg, SpeedtestIngestReportV1,
SpeedtestReqV1, VerifiedInvalidatedRadioThresholdIngestReportV1,
VerifiedRadioThresholdIngestReportV1,
},
Expand Down Expand Up @@ -57,6 +59,16 @@ impl Cmd {
while let Some(result) = file_stream.next().await {
let msg = result?;
match self.file_type {
FileType::HexUsageStatsIngestReport => {
let dec_msg = HexUsageStatsIngestReportV1::decode(msg)?;
let report = HexUsageCountsIngestReport::try_from(dec_msg)?;
print_json(&report)?;
}
FileType::RadioUsageStatsIngestReport => {
let dec_msg = RadioUsageStatsIngestReportV1::decode(msg)?;
let report = RadioUsageCountsIngestReport::try_from(dec_msg)?;
print_json(&report)?;
}
FileType::VerifiedRadioThresholdIngestReport => {
let dec_msg = VerifiedRadioThresholdIngestReportV1::decode(msg)?;
let report = VerifiedRadioThresholdIngestReport::try_from(dec_msg)?;
Expand Down
Loading

0 comments on commit 7088f65

Please sign in to comment.