-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Staking rate targeting and specific rewards. #2882
Conversation
@AlistairStewart could you take a look (and/or anyone else that knows how this should work) |
40922f5
to
9cbae9d
Compare
seems broadly decent to me. |
@thiolliere doesn't build? |
@AlfonsoCev could you have a quick check that these code changes look like they have the correct logic? |
@kianenigma are you happy with this? |
srml/staking/src/inflation.rs
Outdated
|
||
/// PNPoS: the target total payout to all validators (and their nominators) per era. | ||
/// | ||
/// The value take into consideration desired interest rate and inflation rate (see module doc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// The value take into consideration desired interest rate and inflation rate (see module doc) | |
/// The values taken into consideration are desired interest rate and inflation rate (see module doc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(maybe my suggestion, but the sentence is ambiguous)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I improved a bit, actually it meant that I_NPoS function is defined using some constant which are the desired interest rate on ideal inflation rate and desired inflation rate
|
||
// This is guarantee not to overflow on whatever values. | ||
// `num` must be inferior to `den` otherwise it will be reduce to `den`. | ||
fn multiply_by_rational<N>(value: N, num: u32, den: u32) -> N |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be used in the future into support. Looks like something that other modules can also use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think having just this functions as is is interesting or should we provide a structure like RationalU32 { num: u32, den: u32 }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on your recommendation I think a RationalU32
with proper Mul
impls will cover what I recommended. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't know the details of the math portion, but seems to be reasonably tested. Otherwise looks good.
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
@thiolliere Observation is on inflation.rs, on the definition of function I_full: for full generality, we should have that I_full is equal to I_left when x <= x_ideal, and equal to I_right otherwise. Right now the division is set at x=0.5, which is the current value of the parameter x_ideal, but since we defined that parameter we should use it. |
I_NPoS
The total payout is calculated using I_NPoS function defined in http://research.web3.foundation/en/latest/polkadot/Token%20Economics/#payment-details
I_NPoS is implemented using some a piecewise linear function. This piecewise linear function has been generated with a test and is tested not to differ from actual float implementation with an error of 0.2%
Staking api
add_points_to_validator
is added so ppl rewarded can call it from inherent mecanism.TODO:
related to #2781