-
Notifications
You must be signed in to change notification settings - Fork 2.7k
staking: Flexible generation of reward curve and associated tweaks #8327
Conversation
|
cc @kianenigma |
| /// Just the `Currency::Balance` type; we have this item to allow us to constrain it to | ||
| /// `From<u64>`. | ||
| type CurrencyBalance: | ||
| sp_runtime::traits::AtLeast32BitUnsigned + codec::FullCodec + Copy | ||
| + MaybeSerializeDeserialize + sp_std::fmt::Debug + Default + From<u64>; |
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 only alternative that I can think of is to add a where <T::Currency as _>::Balance: From<u64> to most functions of this pallet, and while this is not pretty either, I guess it has less footprint than sprinkling wheres.
| distribution: vec![ | ||
| (10u32, Perbill::from_fraction(0.5)), | ||
| (20, Perbill::from_fraction(0.5)), | ||
| (10u32, Perbill::from_float(0.5)), |
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.
Would be good to ensure new names are consistent with FixedPointNumber. I think the only one needing revision os this ^^, it is still called from_fraction there. Can also be a follow up.
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.
kianenigma
left a comment
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.
Some naming and doc notes worth fixing here and there, but nothing major.
Co-authored-by: Kian Paimani <[email protected]>
Co-authored-by: Kian Paimani <[email protected]>
Co-authored-by: Kian Paimani <[email protected]>
…strate into gav-abstract-payout-curve
shawntabrizi
left a comment
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.
lgtm
| distribution: vec![ | ||
| (10u32, Perbill::from_fraction(0.5)), | ||
| (20, Perbill::from_fraction(0.5)), | ||
| (10u32, Perbill::from_float(0.5)), |
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.
| } | ||
| } | ||
|
|
||
| pub struct ConvertCurve<T>(sp_std::marker::PhantomData<T>); |
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.
probably could use a description
|
bot merge |
|
Trying merge. |
…aritytech#8327) * Initial abstraction * Alter rest of APIs * Fixes * Some extra getters in Gilt pallet. * Refactor Gilt to avoid u128 conversions * Simplify and improve pow in per_things * Add scalar division to per_things * Renaming from_fraction -> from_float, drop _approximation * Fixes * Fixes * Fixes * Fixes * Make stuff build * Fixes * Fixes * Fixes * Fixes * Update .gitignore Co-authored-by: Kian Paimani <[email protected]> * Update frame/gilt/src/lib.rs Co-authored-by: Kian Paimani <[email protected]> * Update frame/gilt/src/mock.rs Co-authored-by: Kian Paimani <[email protected]> * Fixes * Fixes * Fixes Co-authored-by: Shawn Tabrizi <[email protected]> Co-authored-by: Kian Paimani <[email protected]>
Breaks the API, sadly, but it's easy to fix your impl. Just change the line:
into:
Also tweaks to
per_things.rs:from_rational_approximationbecomesfrom_rationalfrom_fractionbecomesfrom_floatpowopstraitsmulis correctly characterised as non-overflowingAlso some minor refactoring to the Gilt pallet to avoid collapsing into
u128.Polkadot companion: paritytech/polkadot#2610