Skip to content

Commit

Permalink
Fix Service Provider rewards math (#887)
Browse files Browse the repository at this point in the history
* more accurately name our rounding routine

* remove math from test code

Break out calculating rewards for a single service provider.
This means in a test when we only care about a single sp, we can find
that record and get all of the rewards from it without having to do any
math. So the math can not differ from prod.

* Add real world tests from a failed run

* rename variable now that we're dealing with bones through the pipeline

Previously, half the values were representing DC, and the other half
Bones. You cannot take percentages of one unit from another unit when
they are scaled differently.

Early on, we convert dc -> bones, then calculate percentages based off
those numbers. dc_perc has been renamed to data_perc because it is the
percentage of rewards that is allocated because of data transfer.

Rounding now uses the floor function provided by rust_decimal.

* remove unused function

we no longer need to know the rewards_per_share, because we are not
doinga  share type algorithm for computing rewards. We get percentages
of a whole, which has the same effect as multipling shares by a fraction
of reward units.

* now is not the time to change how the rounding is done

* use correct variable for max amount of bones allocated for reward period
  • Loading branch information
michaeldjeffrey authored Nov 1, 2024
1 parent 47d72cb commit 870a040
Show file tree
Hide file tree
Showing 2 changed files with 167 additions and 82 deletions.
2 changes: 1 addition & 1 deletion mobile_verifier/src/reward_shares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2275,7 +2275,7 @@ mod test {
// force the service provider to have spend more DC than total rewardable
ServiceProviderDCSessions::from([(sp1, total_rewards_value_in_dc * dec!(2.0))]),
ServiceProviderPromotions::default(),
total_rewards_value_in_dc,
total_sp_rewards_in_bones,
mobile_bone_price,
epoch.clone(),
);
Expand Down
Loading

0 comments on commit 870a040

Please sign in to comment.