diff --git a/mobile_verifier/src/cli/reward_from_db.rs b/mobile_verifier/src/cli/reward_from_db.rs index 8a9557cf0..d0f9dfa60 100644 --- a/mobile_verifier/src/cli/reward_from_db.rs +++ b/mobile_verifier/src/cli/reward_from_db.rs @@ -49,6 +49,7 @@ impl Cmd { &speedtest_averages, &BoostedHexes::default(), &BoostedHexEligibility::default(), + &BannedRadios::default(), &epoch, ) .await?; @@ -59,7 +60,6 @@ impl Cmd { .into_rewards( DataTransferAndPocAllocatedRewardBuckets::new(&epoch), &epoch, - BannedRadios::default(), ) .ok_or(anyhow::anyhow!("no rewardable events"))? .1; diff --git a/mobile_verifier/src/reward_shares.rs b/mobile_verifier/src/reward_shares.rs index 2231abedf..9c322894f 100644 --- a/mobile_verifier/src/reward_shares.rs +++ b/mobile_verifier/src/reward_shares.rs @@ -522,6 +522,7 @@ struct RadioInfo { trust_scores: Vec, sp_boosted_reward_eligibility: SPBoostedRewardEligibility, speedtests: Vec, + oracle_boosting_status: OracleBoostingStatus, } #[derive(Debug)] @@ -537,6 +538,7 @@ impl CoverageShares { speedtest_averages: &SpeedtestAverages, boosted_hexes: &BoostedHexes, boosted_hex_eligibility: &BoostedHexEligibility, + banned_radios: &BannedRadios, reward_period: &Range>, ) -> anyhow::Result { let mut radio_infos: HashMap = HashMap::new(); @@ -607,6 +609,12 @@ impl CoverageShares { }) .collect(); + let oracle_boosting_status = if banned_radios.contains(&pubkey, cbsd_id.as_deref()) { + OracleBoostingStatus::Banned + } else { + OracleBoostingStatus::Eligible + }; + let sp_boosted_reward_eligibility = boosted_hex_eligibility.eligibility(pubkey, cbsd_id); @@ -628,6 +636,7 @@ impl CoverageShares { trust_scores, sp_boosted_reward_eligibility, speedtests, + oracle_boosting_status, }, ); } @@ -672,7 +681,6 @@ impl CoverageShares { self, reward_shares: DataTransferAndPocAllocatedRewardBuckets, epoch: &'_ Range>, - banned_radios: BannedRadios, ) -> Option<( CalculatedPocRewardShares, impl Iterator + '_, @@ -686,14 +694,7 @@ impl CoverageShares { let mut processed_radios = vec![]; for (radio_id, radio_info) in self.radio_infos.iter() { - let (pubkey, cbsd_id) = radio_id; - let oracle_boosting_status = if banned_radios.contains(pubkey, cbsd_id.as_deref()) { - OracleBoostingStatus::Banned - } else { - OracleBoostingStatus::Eligible - }; - - let points = match self.coverage_points(radio_id, oracle_boosting_status) { + let points = match self.coverage_points(radio_id, radio_info.oracle_boosting_status) { Ok(points) => points, Err(err) => { tracing::error!( @@ -1317,11 +1318,12 @@ mod test { &speedtest_avgs, &BoostedHexes::default(), &BoostedHexEligibility::default(), + &BannedRadios::default(), &epoch, ) .await .unwrap() - .into_rewards(reward_shares, &epoch, BannedRadios::default()) + .into_rewards(reward_shares, &epoch) .unwrap() .1 .next() @@ -1719,11 +1721,12 @@ mod test { &speedtest_avgs, &BoostedHexes::default(), &BoostedHexEligibility::default(), + &BannedRadios::default(), &epoch, ) .await .unwrap() - .into_rewards(reward_shares, &epoch, BannedRadios::default()) + .into_rewards(reward_shares, &epoch) .unwrap() .1 { @@ -1899,11 +1902,12 @@ mod test { &speedtest_avgs, &BoostedHexes::default(), &BoostedHexEligibility::default(), + &BannedRadios::default(), &epoch, ) .await .unwrap() - .into_rewards(reward_shares, &epoch, BannedRadios::default()) + .into_rewards(reward_shares, &epoch) .unwrap() .1 { @@ -2032,11 +2036,12 @@ mod test { &speedtest_avgs, &BoostedHexes::default(), &BoostedHexEligibility::default(), + &BannedRadios::default(), &epoch, ) .await .unwrap() - .into_rewards(reward_shares, &epoch, BannedRadios::default()) + .into_rewards(reward_shares, &epoch) .unwrap() .1 { @@ -2166,11 +2171,12 @@ mod test { &speedtest_avgs, &BoostedHexes::default(), &BoostedHexEligibility::default(), + &BannedRadios::default(), &epoch, ) .await .unwrap() - .into_rewards(reward_shares, &epoch, BannedRadios::default()) + .into_rewards(reward_shares, &epoch) .unwrap() .1 { @@ -2280,6 +2286,7 @@ mod test { timestamp: now, }, ], + oracle_boosting_status: OracleBoostingStatus::Eligible, }, ); radio_infos.insert( @@ -2300,6 +2307,7 @@ mod test { }, sp_boosted_reward_eligibility: SPBoostedRewardEligibility::Eligible, speedtests: vec![], + oracle_boosting_status: OracleBoostingStatus::Eligible, }, ); @@ -2312,7 +2320,7 @@ mod test { // gw2 does not have enough speedtests for a mulitplier let expected_hotspot = gw1; for (_reward_amount, _mobile_reward_v1, mobile_reward_v2) in coverage_shares - .into_rewards(reward_shares, &epoch, BannedRadios::default()) + .into_rewards(reward_shares, &epoch) .expect("rewards output") .1 { @@ -2337,7 +2345,7 @@ mod test { let reward_shares = DataTransferAndPocAllocatedRewardBuckets::new_poc_only(&epoch); assert!(coverage_shares - .into_rewards(reward_shares, &epoch, BannedRadios::default()) + .into_rewards(reward_shares, &epoch) .is_none()); } diff --git a/mobile_verifier/src/rewarder.rs b/mobile_verifier/src/rewarder.rs index 534ac51af..eee7d5da2 100644 --- a/mobile_verifier/src/rewarder.rs +++ b/mobile_verifier/src/rewarder.rs @@ -434,28 +434,29 @@ async fn reward_poc( .await?, ); + let poc_banned_radios = sp_boosted_rewards_bans::db::get_banned_radios( + pool, + SpBoostedRewardsBannedRadioBanType::Poc, + reward_period.end, + ) + .await?; + let coverage_shares = CoverageShares::new( pool, heartbeats, &speedtest_averages, &boosted_hexes, &boosted_hex_eligibility, + &poc_banned_radios, reward_period, ) .await?; - let poc_banned_radios = sp_boosted_rewards_bans::db::get_banned_radios( - pool, - SpBoostedRewardsBannedRadioBanType::Poc, - reward_period.end, - ) - .await?; - let total_poc_rewards = reward_shares.total_poc(); let (unallocated_poc_amount, calculated_poc_rewards_per_share) = if let Some((calculated_poc_rewards_per_share, mobile_reward_shares)) = - coverage_shares.into_rewards(reward_shares, reward_period, poc_banned_radios) + coverage_shares.into_rewards(reward_shares, reward_period) { // handle poc reward outputs let mut allocated_poc_rewards = 0_u64; diff --git a/mobile_verifier/tests/integrations/boosting_oracles.rs b/mobile_verifier/tests/integrations/boosting_oracles.rs index d5d00d844..f9f03e351 100644 --- a/mobile_verifier/tests/integrations/boosting_oracles.rs +++ b/mobile_verifier/tests/integrations/boosting_oracles.rs @@ -21,6 +21,7 @@ use mobile_verifier::{ reward_shares::CoverageShares, rewarder::boosted_hex_eligibility::BoostedHexEligibility, seniority::{Seniority, SeniorityUpdate}, + sp_boosted_rewards_bans::BannedRadios, speedtests::Speedtest, speedtests_average::{SpeedtestAverage, SpeedtestAverages}, GatewayResolution, GatewayResolver, @@ -402,6 +403,7 @@ async fn test_footfall_and_urbanization_and_landtype(pool: PgPool) -> anyhow::Re &speedtest_avgs, &BoostedHexes::default(), &BoostedHexEligibility::default(), + &BannedRadios::default(), &epoch, ) .await diff --git a/mobile_verifier/tests/integrations/modeled_coverage.rs b/mobile_verifier/tests/integrations/modeled_coverage.rs index b9f20f800..bb9c406f9 100644 --- a/mobile_verifier/tests/integrations/modeled_coverage.rs +++ b/mobile_verifier/tests/integrations/modeled_coverage.rs @@ -24,6 +24,7 @@ use mobile_verifier::{ reward_shares::CoverageShares, rewarder::boosted_hex_eligibility::BoostedHexEligibility, seniority::{Seniority, SeniorityUpdate}, + sp_boosted_rewards_bans::BannedRadios, speedtests::Speedtest, speedtests_average::{SpeedtestAverage, SpeedtestAverages}, GatewayResolution, GatewayResolver, IsAuthorized, @@ -497,6 +498,7 @@ async fn scenario_one(pool: PgPool) -> anyhow::Result<()> { &speedtest_avgs, &BoostedHexes::default(), &BoostedHexEligibility::default(), + &BannedRadios::default(), &reward_period, ) .await?; @@ -599,6 +601,7 @@ async fn scenario_two(pool: PgPool) -> anyhow::Result<()> { &speedtest_avgs, &BoostedHexes::default(), &BoostedHexEligibility::default(), + &BannedRadios::default(), &reward_period, ) .await?; @@ -887,6 +890,7 @@ async fn scenario_three(pool: PgPool) -> anyhow::Result<()> { &speedtest_avgs, &boosted_hexes, &BoostedHexEligibility::default(), + &BannedRadios::default(), &reward_period, ) .await?; @@ -976,6 +980,7 @@ async fn scenario_four(pool: PgPool) -> anyhow::Result<()> { &speedtest_avgs, &BoostedHexes::default(), &BoostedHexEligibility::default(), + &BannedRadios::default(), &reward_period, ) .await?; @@ -1077,6 +1082,7 @@ async fn scenario_five(pool: PgPool) -> anyhow::Result<()> { &speedtest_avgs, &BoostedHexes::default(), &BoostedHexEligibility::default(), + &BannedRadios::default(), &reward_period, ) .await?; @@ -1326,6 +1332,7 @@ async fn scenario_six(pool: PgPool) -> anyhow::Result<()> { &speedtest_avgs, &BoostedHexes::default(), &BoostedHexEligibility::default(), + &BannedRadios::default(), &reward_period, ) .await?;