Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fix inflation calculation to account for total stake #4411

Closed
joepetrowski opened this issue Dec 17, 2019 · 3 comments
Closed

Fix inflation calculation to account for total stake #4411

joepetrowski opened this issue Dec 17, 2019 · 3 comments
Assignees
Labels
I3-bug The node fails to follow expected behavior.

Comments

@joepetrowski
Copy link
Contributor

Currently (source), the staking rewards calculation calculates the total amount at stake by multiplying the SlotStake - the stake of the minimally staked validator - by the number of validators.

The actual amount at stake - if we consider any funds liable to be slashed as "at stake" - then the number of tokens at stake is higher since most validators will have more than the slot stake.

The calculation should find the sum of the amount at stake (sum of exposure.total from Stakers) and pass that to the payout function.

Related: #4407

let validator_len: BalanceOf<T> = (validators.len() as u32).into();
let total_rewarded_stake = Self::slot_stake() * validator_len;

let (total_payout, max_payout) = inflation::compute_total_payout(
	&T::RewardCurve::get(),
	total_rewarded_stake.clone(),
	T::Currency::total_issuance(),
	// Duration of era; more than u64::MAX is rewarded as u64::MAX.
	era_duration.saturated_into::<u64>(),
);
@joepetrowski joepetrowski added the I3-bug The node fails to follow expected behavior. label Dec 17, 2019
@joepetrowski
Copy link
Contributor Author

After talking with @rphmeier, we may just want to use the median amount at stake instead of the sum. Either way, we should not use the minimum as it may be highly variable era-to-era.

@rphmeier
Copy link
Contributor

The research.web3.foundation site should describe this, if it doesn't already. Least-staked is OK, but bottom-tercile is probably the ideal metric

@gui1117 gui1117 mentioned this issue Jan 9, 2020
@gui1117 gui1117 self-assigned this Jan 10, 2020
@gui1117
Copy link
Contributor

gui1117 commented Apr 17, 2020

This was fixed in lazy payouts PR

@gui1117 gui1117 closed this as completed Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I3-bug The node fails to follow expected behavior.
Projects
None yet
Development

No branches or pull requests

3 participants