Skip to content

Commit

Permalink
coverage_points() -> coverage_points_v1() to call out location differ…
Browse files Browse the repository at this point in the history
…ence

coverage points including the location trust multiplier, but not the
speedtest multiplier has been a source of confusion. Shortly, that will
no longer be the case.

This method has been renamed to raise an eyebrow as to why it needs a v1
specifier.
  • Loading branch information
michaeldjeffrey committed Jul 3, 2024
1 parent 2b021e0 commit 406cd4e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
40 changes: 25 additions & 15 deletions coverage_point_calculator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,17 @@ impl CoveragePoints {
/// Accumulated points related only to coverage.
/// (Hex * Rank * Assignment) * Location Trust
/// Used for reporting.
pub fn coverage_points(&self) -> Decimal {
///
/// NOTE:
/// Coverage Points includes Location Trust multiplier. In a future version,
/// coverage points will refer only to points received by covering a hex,
/// and multipliers like location trust will be applied later to reach a
/// value referred to as "shares".
///
/// Ref:
/// https://github.com/helium/proto/blob/master/src/service/poc_mobile.proto
/// `message radio_reward`
pub fn coverage_points_v1(&self) -> Decimal {
let total_coverage_points = self.coverage_points.base + self.boosted_points();
total_coverage_points * self.location_trust_multiplier
}
Expand Down Expand Up @@ -349,7 +359,7 @@ mod tests {

// A Hex with the worst possible oracle boosting assignment.
// The boosting assignment multiplier will be 1x when the hex is provider boosted.
assert_eq!(expected_points, wifi.coverage_points());
assert_eq!(expected_points, wifi.coverage_points_v1());
}

#[test]
Expand Down Expand Up @@ -380,12 +390,12 @@ mod tests {
// Radio meeting the threshold is eligible for boosted hexes.
// Boosted hex provides radio with more than base_points.
let verified_wifi = calculate_wifi(RadioThreshold::Verified);
assert_eq!(base_points * dec!(5), verified_wifi.coverage_points());
assert_eq!(base_points * dec!(5), verified_wifi.coverage_points_v1());

// Radio not meeting the threshold is not eligible for boosted hexes.
// Boost from hex is not applied, radio receives base points.
let unverified_wifi = calculate_wifi(RadioThreshold::Unverified);
assert_eq!(base_points, unverified_wifi.coverage_points());
assert_eq!(base_points, unverified_wifi.coverage_points_v1());
}

#[test]
Expand Down Expand Up @@ -417,13 +427,13 @@ mod tests {
// Boosted hex provides radio with more than base_points.
let trusted_wifi = calculate_wifi(location_trust_with_scores(&[dec!(1), dec!(1)]));
assert!(trusted_wifi.location_trust_multiplier > dec!(0.75));
assert!(trusted_wifi.coverage_points() > base_points);
assert!(trusted_wifi.coverage_points_v1() > base_points);

// Radio with poor trust score is not eligible for boosted hexes.
// Boost from hex is not applied, and points are further lowered by poor trust score.
let untrusted_wifi = calculate_wifi(location_trust_with_scores(&[dec!(0.1), dec!(0.2)]));
assert!(untrusted_wifi.location_trust_multiplier < dec!(0.75));
assert!(untrusted_wifi.coverage_points() < base_points);
assert!(untrusted_wifi.coverage_points_v1() < base_points);
}

#[test]
Expand Down Expand Up @@ -561,7 +571,7 @@ mod tests {
)
.expect("indoor cbrs");

assert_eq!(dec!(1073), indoor_cbrs.coverage_points());
assert_eq!(dec!(1073), indoor_cbrs.coverage_points_v1());
}

#[rstest]
Expand Down Expand Up @@ -591,7 +601,7 @@ mod tests {
)
.expect("outdoor wifi");

assert_eq!(expected_points, outdoor_wifi.coverage_points());
assert_eq!(expected_points, outdoor_wifi.coverage_points_v1());
}

#[rstest]
Expand Down Expand Up @@ -640,7 +650,7 @@ mod tests {
)
.expect("indoor wifi");

assert_eq!(expected_points, indoor_wifi.coverage_points());
assert_eq!(expected_points, indoor_wifi.coverage_points_v1());
}

#[test]
Expand All @@ -665,7 +675,7 @@ mod tests {

// Location trust scores is 1/4
// (0.1 + 0.2 + 0.3 + 0.4) / 4
assert_eq!(dec!(100), indoor_wifi.coverage_points());
assert_eq!(dec!(100), indoor_wifi.coverage_points_v1());
}

#[test]
Expand Down Expand Up @@ -701,7 +711,7 @@ mod tests {

// The hex with a low signal_level is boosted to the same level as a
// signal_level of High.
assert_eq!(dec!(800), indoor_wifi.coverage_points());
assert_eq!(dec!(800), indoor_wifi.coverage_points_v1());
}

#[rstest]
Expand Down Expand Up @@ -730,7 +740,7 @@ mod tests {
)
.expect("outdoor cbrs");

assert_eq!(expected, outdoor_cbrs.coverage_points());
assert_eq!(expected, outdoor_cbrs.coverage_points_v1());
}

#[rstest]
Expand All @@ -757,7 +767,7 @@ mod tests {
)
.expect("indoor cbrs");

assert_eq!(expected, indoor_cbrs.coverage_points());
assert_eq!(expected, indoor_cbrs.coverage_points_v1());
}

#[rstest]
Expand Down Expand Up @@ -786,7 +796,7 @@ mod tests {
)
.expect("indoor cbrs");

assert_eq!(expected, outdoor_wifi.coverage_points());
assert_eq!(expected, outdoor_wifi.coverage_points_v1());
}

#[rstest]
Expand All @@ -813,7 +823,7 @@ mod tests {
)
.expect("indoor wifi");

assert_eq!(expected, indoor_wifi.coverage_points());
assert_eq!(expected, indoor_wifi.coverage_points_v1());
}

fn hex_location() -> hextree::Cell {
Expand Down
4 changes: 2 additions & 2 deletions coverage_point_calculator/tests/coverage_point_calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn base_radio_coverage_points() {

assert_eq!(
expcted_base_coverage_point,
coverage_points.coverage_points()
coverage_points.coverage_points_v1()
);
}
}
Expand Down Expand Up @@ -120,7 +120,7 @@ fn radios_with_coverage() {
)
.unwrap();

assert_eq!(dec!(400), coverage_points.coverage_points());
assert_eq!(dec!(400), coverage_points.coverage_points_v1());
}
}

Expand Down
2 changes: 1 addition & 1 deletion mobile_verifier/src/reward_shares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ pub fn coverage_point_to_mobile_reward_share(
let speedtest_multiplier = to_proto_value(coverage_points.speedtest_multiplier);

let coverage_points = coverage_points
.coverage_points()
.coverage_points_v1()
.to_u64()
.unwrap_or_default();

Expand Down

0 comments on commit 406cd4e

Please sign in to comment.