Skip to content

Commit

Permalink
rebase artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
andymck committed Dec 16, 2024
1 parent 8f5843b commit 3e74afd
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 56 deletions.
53 changes: 18 additions & 35 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ sqlx = { git = "https://github.com/launchbadge/sqlx.git", rev = "42dd78fe931df65
# Patching for beacon must point directly to the crate, it will not look in the
# repo for sibling crates.
#
# [patch.'https://github.com/helium/proto']
# helium-proto = { path = "../../proto" }
[patch.'https://github.com/helium/proto']
helium-proto = { path = "../../proto" }
# beacon = { path = "../../proto" }
1 change: 0 additions & 1 deletion iot_verifier/src/reward_share.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ impl GatewayShares {
start_period: reward_period.start.encode_timestamp(),
end_period: reward_period.end.encode_timestamp(),
reward: Some(ProtoReward::GatewayReward(gateway_reward)),
epoch: 0, // placeholder, todo: remove
},
)
})
Expand Down
2 changes: 0 additions & 2 deletions iot_verifier/src/rewarder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ pub async fn reward_operational(
start_period: reward_period.start.encode_timestamp(),
end_period: reward_period.end.encode_timestamp(),
reward: Some(ProtoReward::OperationalReward(op_fund_reward)),
epoch: 0, // placeholder, todo: remove
},
[],
)
Expand Down Expand Up @@ -368,7 +367,6 @@ async fn write_unallocated_reward(
reward_type: unallocated_type as i32,
amount: unallocated_amount,
})),
epoch: 0, // placeholder, todo: remove
};
rewards_sink.write(unallocated_reward, []).await?.await??;
};
Expand Down
4 changes: 3 additions & 1 deletion mobile_verifier/src/reward_shares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2232,8 +2232,10 @@ mod test {
let mut owner_rewards = HashMap::<PublicKeyBinary, u64>::new();
let duration = Duration::hours(1);
let epoch = (now - duration)..now;
let rewards_info = default_rewards_info(3_424_657_534_247, Duration::hours(1));

let reward_shares = DataTransferAndPocAllocatedRewardBuckets::new_poc_only(&epoch);
let reward_shares =
DataTransferAndPocAllocatedRewardBuckets::new_poc_only(rewards_info.epoch_emissions);
let unique_connection_counts = HashMap::from([(gw1.clone(), 42)]);
for (_reward_amount, _mobile_reward_v1, mobile_reward_v2) in CoverageShares::new(
&hex_coverage,
Expand Down
4 changes: 2 additions & 2 deletions mobile_verifier/src/rewarder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
sp_boosted_rewards_bans, speedtests,
speedtests_average::SpeedtestAverages,
subscriber_location, subscriber_verified_mapping_event, telemetry, unique_connections,
Settings, MOBILE_SUB_DAO_ONCHAIN_ADDRESS, PriceInfo
PriceInfo, Settings, MOBILE_SUB_DAO_ONCHAIN_ADDRESS,
};
use anyhow::bail;
use chrono::{DateTime, TimeZone, Utc};
Expand Down Expand Up @@ -474,7 +474,7 @@ async fn reward_poc(
)
.await?;

let unique_connections = unique_connections::db::get(pool, reward_period).await?;
let unique_connections = unique_connections::db::get(pool, &reward_info.epoch_period).await?;

let coverage_shares = CoverageShares::new(
pool,
Expand Down
32 changes: 19 additions & 13 deletions mobile_verifier/tests/integrations/rewarder_poc_dc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::ops::Range;
use crate::common::{
self, default_rewards_info, MockFileSinkReceiver, MockHexBoostingClient, RadioRewardV2Ext,
};
use chrono::{DateTime, Duration as ChronoDuration, Utc};
use chrono::{DateTime, Duration as ChronoDuration, Duration, Utc};
use file_store::{
coverage::{CoverageObject as FSCoverageObject, KeyType, RadioHexSignalLevel},
speedtest::CellSpeedtest,
Expand Down Expand Up @@ -150,42 +150,48 @@ async fn test_qualified_wifi_poc_rewards(pool: PgPool) -> anyhow::Result<()> {

let (mobile_rewards_client, mut mobile_rewards) = common::create_file_sink();
let (speedtest_avg_client, _speedtest_avg_server) = common::create_file_sink();
let now = Utc::now();
let epoch = (now - ChronoDuration::hours(24))..now;

let reward_info = default_rewards_info(82_191_780_821_917, Duration::hours(24));

let pubkey: PublicKeyBinary = HOTSPOT_3.to_string().parse().unwrap(); // wifi hotspot

// seed all the things
let mut txn = pool.clone().begin().await?;
seed_heartbeats(epoch.start, &mut txn).await?;
seed_speedtests(epoch.end, &mut txn).await?;
seed_data_sessions(epoch.start, &mut txn).await?;
seed_heartbeats(reward_info.epoch_period.start, &mut txn).await?;
seed_speedtests(reward_info.epoch_period.end, &mut txn).await?;
seed_data_sessions(reward_info.epoch_period.start, &mut txn).await?;
txn.commit().await?;
update_assignments_bad(&pool).await?;

// Run rewards with no unique connections, no poc rewards, expect unallocated
let boosted_hexes = vec![];
let hex_boosting_client = MockHexBoostingClient::new(boosted_hexes);

let price_info = PriceInfo::new(10000000000000000, 8);
assert_eq!(price_info.price_per_token, dec!(100000000));
assert_eq!(price_info.price_per_bone, dec!(1));

let (_, _rewards) = tokio::join!(
rewarder::reward_poc_and_dc(
&pool,
&hex_boosting_client,
&mobile_rewards_client,
&speedtest_avg_client,
&epoch,
dec!(0.0001)
&reward_info,
price_info.clone()
),
// expecting NO poc rewards, expecting unallocated
receive_expected_rewards_with_counts(&mut mobile_rewards, 3, 0, true)
);

// seed single unique conections report within epoch
let mut txn = pool.begin().await?;
seed_unique_connections(&mut txn, &[(pubkey.clone(), 42)], &epoch).await?;
seed_unique_connections(&mut txn, &[(pubkey.clone(), 42)], &reward_info.epoch_period).await?;
txn.commit().await?;

// SP ban radio, unique connections should supersede banning
let mut txn = pool.begin().await?;
ban_wifi_radio_for_epoch(&mut txn, pubkey.clone(), &epoch).await?;
ban_wifi_radio_for_epoch(&mut txn, pubkey.clone(), &reward_info.epoch_period).await?;
txn.commit().await?;

let (_, rewards) = tokio::join!(
Expand All @@ -195,8 +201,8 @@ async fn test_qualified_wifi_poc_rewards(pool: PgPool) -> anyhow::Result<()> {
&hex_boosting_client,
&mobile_rewards_client,
&speedtest_avg_client,
&epoch,
dec!(0.0001)
&reward_info,
price_info
),
// expecting single radio with poc rewards, no unallocated
receive_expected_rewards_with_counts(&mut mobile_rewards, 3, 1, false)
Expand All @@ -209,7 +215,7 @@ async fn test_qualified_wifi_poc_rewards(pool: PgPool) -> anyhow::Result<()> {
let dc_sum: u64 = dc_rewards.iter().map(|r| r.dc_transfer_reward).sum();
let total = poc_sum + dc_sum;

let expected_sum = reward_shares::get_scheduled_tokens_for_poc(epoch.end - epoch.start)
let expected_sum = reward_shares::get_scheduled_tokens_for_poc(reward_info.epoch_emissions)
.to_u64()
.unwrap();
assert_eq!(expected_sum, total);
Expand Down

0 comments on commit 3e74afd

Please sign in to comment.