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

Compute yearly inflation on-chain allowing to change x_ideal according to number of slots.#8332

Merged
gavofyork merged 3 commits intomasterfrom
gui-on-chain-curve
Mar 19, 2021
Merged

Compute yearly inflation on-chain allowing to change x_ideal according to number of slots.#8332
gavofyork merged 3 commits intomasterfrom
gui-on-chain-curve

Conversation

@gui1117
Copy link
Copy Markdown
Contributor

@gui1117 gui1117 commented Mar 11, 2021

Related: #6469

Intruduce a new crate which expose: compute_inflation allowing to compute yearly inflation directly using current_stake_rate, ideal_stake_rate and falloff.

NOTE: we don't support falloff lower than 0.01, if we want to support it I think we can. If falloff is less than 0.01 the curve fall down very very fast, and we should probably return inflation = 0 and not compute taylor serie when stake is a bit far form ideal_stake.

@gui1117 gui1117 force-pushed the gui-on-chain-curve branch from 4508a34 to a738f2a Compare March 11, 2021 18:12
@github-actions github-actions bot added the A3-in_progress Pull request is in progress. No review needed at this stage. label Mar 11, 2021
Base automatically changed from gav-abstract-payout-curve to master March 16, 2021 12:03
@gui1117 gui1117 force-pushed the gui-on-chain-curve branch from a738f2a to 6b7107a Compare March 16, 2021 16:37
@gui1117 gui1117 force-pushed the gui-on-chain-curve branch from 6b7107a to a32903b Compare March 17, 2021 14:31
@gui1117 gui1117 added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Mar 17, 2021
@gui1117 gui1117 marked this pull request as ready for review March 17, 2021 14:34
@gui1117 gui1117 requested a review from kianenigma as a code owner March 17, 2021 14:34
@gui1117 gui1117 changed the title WIP: Compute yearly inflation on-chain allowing to change x_ideal according to number of slots. Compute yearly inflation on-chain allowing to change x_ideal according to number of slots. Mar 17, 2021

let error = (res - expect).abs();

if error > 8f64 / accuracy_f64 && error > 8.0 * f64::EPSILON {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this accuracy with EPSILON is at least needed because f64 doesn't have enough precision compare to perquintillion.

/// Compute a div b.
///
/// requires `b` to be stripped and have no leading zeros.
fn div_by_stripped(mut a: BigUint, b: &BigUint) -> BigUint {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @kianenigma I'm finally using this implementation to be able to divide by any stripped biguint.

gui1117 and others added 2 commits March 17, 2021 16:04
Co-authored-by: Gavin Wood <gavin@parity.io>
@gavofyork gavofyork merged commit b066782 into master Mar 19, 2021
@gavofyork gavofyork deleted the gui-on-chain-curve branch March 19, 2021 08:32
hirschenberger pushed a commit to hirschenberger/substrate that referenced this pull request Apr 14, 2021
…g to number of slots. (paritytech#8332)

* new crate

* Update frame/staking/reward-fn/src/lib.rs

Co-authored-by: Gavin Wood <gavin@parity.io>

* fix doc

Co-authored-by: Gavin Wood <gavin@parity.io>
@redzsina redzsina added D1-audited 👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited and removed D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited labels Apr 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D1-audited 👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants