Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change mobile verifier to no longer require valid POC to earn data transfer rewards #645

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 2 additions & 32 deletions mobile_verifier/src/reward_shares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ impl TransferRewards {
pub async fn from_transfer_sessions(
mobile_bone_price: Decimal,
transfer_sessions: HotspotMap,
hotspots: &PocShares,
epoch: &Range<DateTime<Utc>>,
) -> Self {
let mut reward_sum = Decimal::ZERO;
let rewards = transfer_sessions
.into_iter()
.filter(|(pub_key, _)| hotspots.is_valid(pub_key))
// Calculate rewards per hotspot
.map(|(pub_key, dc_amount)| {
let bones = dc_to_mobile_bones(Decimal::from(dc_amount), mobile_bone_price);
Expand Down Expand Up @@ -240,14 +238,6 @@ impl PocShares {
Ok(poc_shares)
}

pub fn is_valid(&self, hotspot: &PublicKeyBinary) -> bool {
if let Some(shares) = self.hotspot_shares.get(hotspot) {
!shares.total_shares().is_zero()
} else {
false
}
}

pub fn total_shares(&self) -> Decimal {
self.hotspot_shares
.values()
Expand Down Expand Up @@ -335,12 +325,6 @@ mod test {
use prost::Message;
use std::collections::HashMap;

fn valid_shares() -> RadioShares {
let mut radio_shares: HashMap<Option<String>, Decimal> = Default::default();
radio_shares.insert(Some(String::new()), Decimal::ONE);
RadioShares { radio_shares }
}

#[test]
fn bytes_to_bones() {
assert_eq!(
Expand Down Expand Up @@ -435,10 +419,6 @@ mod test {
data_transfer_session.num_dcs as u64,
);

let mut hotspot_shares = HashMap::default();
hotspot_shares.insert(owner.clone(), valid_shares());
let poc_shares = PocShares { hotspot_shares };

let now = Utc::now();
let epoch = (now - Duration::hours(1))..now;
let total_rewards = get_scheduled_tokens_for_poc_and_dc(epoch.end - epoch.start);
Expand All @@ -450,13 +430,8 @@ mod test {
dec!(49_180_327)
);

let data_transfer_rewards = TransferRewards::from_transfer_sessions(
dec!(1.0),
data_transfer_map,
&poc_shares,
&epoch,
)
.await;
let data_transfer_rewards =
TransferRewards::from_transfer_sessions(dec!(1.0), data_transfer_map, &epoch).await;

assert_eq!(data_transfer_rewards.reward(&owner), dec!(0.00002));
assert_eq!(data_transfer_rewards.reward_scale(), dec!(1.0));
Expand Down Expand Up @@ -499,14 +474,9 @@ mod test {
let now = Utc::now();
let epoch = (now - Duration::hours(24))..now;

let mut hotspot_shares = HashMap::default();
hotspot_shares.insert(owner.clone(), valid_shares());
let poc_shares = PocShares { hotspot_shares };

let data_transfer_rewards = TransferRewards::from_transfer_sessions(
dec!(1.0),
aggregated_data_transfer_sessions,
&poc_shares,
&epoch,
)
.await;
Expand Down
1 change: 0 additions & 1 deletion mobile_verifier/src/rewarder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ impl Rewarder {
let transfer_rewards = TransferRewards::from_transfer_sessions(
mobile_bone_price,
data_session::aggregate_hotspot_data_sessions_to_dc(&self.pool, reward_period).await?,
&poc_rewards,
reward_period,
)
.await;
Expand Down