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

Staking Reward Rate Runtime API #13416

Closed
wants to merge 40 commits into from
Closed

Conversation

rossbulat
Copy link

@rossbulat rossbulat commented Feb 19, 2023

Addresses paritytech/polkadot-sdk#427.

  • Update inflation calculation.
  • Abstract curve calculations & test reward rates with various staked_percent values.
  • Update companion.

polkadot companion: paritytech/polkadot#6764

Copy link
Author

@rossbulat rossbulat left a comment

Choose a reason for hiding this comment

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

@gpestana I've left comments where I've added the inflation API.

bin/node/runtime/src/lib.rs Outdated Show resolved Hide resolved
frame/staking/Cargo.toml Show resolved Hide resolved
frame/staking/src/pallet/impls.rs Outdated Show resolved Hide resolved
@rossbulat
Copy link
Author

Also a part of #13069

bin/node/runtime/src/lib.rs Outdated Show resolved Hide resolved
@rossbulat rossbulat added the A0-please_review Pull request needs code review. label Feb 20, 2023
@rossbulat rossbulat added C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit B1-note_worthy Changes should be noted in the release notes T1-runtime This PR/Issue is related to the topic “runtime”. labels Feb 22, 2023
@command-bot command-bot bot deleted a comment from paritytech-processbot bot Feb 22, 2023
@command-bot command-bot bot deleted a comment from paritytech-processbot bot Feb 22, 2023
@rossbulat rossbulat reopened this May 14, 2023
@stale stale bot removed the A3-stale label May 14, 2023
@rossbulat
Copy link
Author

bot rebase

@paritytech-processbot
Copy link

Rebased

@rossbulat rossbulat changed the title Inflation Rate Runtime API Staking Reward Rate Runtime API May 14, 2023
@rossbulat
Copy link
Author

bot rebase

@paritytech-processbot
Copy link

Rebased

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable
Logs: https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/2834439

@@ -974,6 +974,46 @@ impl<T: Config> Pallet<T> {
}

impl<T: Config> Pallet<T> {
/// Returns the current staking reward rate.
pub fn api_reward_rate(
Copy link
Contributor

@gui1117 gui1117 Jun 9, 2023

Choose a reason for hiding this comment

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

Staking is currently unaware of the reward rate, this implementation makes assumption on the implementation of Config trait.

The payout is abstracted through associated type Config::EraPayout which bounds the trait EraPayout
Either some assumption should be enforced on the implementation of EraPayout on the rate can be retrieved by calling the payout for an era of one year payout(current_total_staked, current_total_issuance, one_year).
This doesn't look so good, but could be fine.

Better would be to:

  • either add a method to EraPayout trait to be able to retrieve the reward rate
  • or expose the rate from the node.

Copy link
Author

Choose a reason for hiding this comment

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

Indeed. The calculations currently in place were based on an outdated calculation of PJS. We can simply refer to era payout to determine the inflation on a per-era basis.

@stale
Copy link

stale bot commented Jul 11, 2023

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A3-stale label Jul 11, 2023
@stale stale bot closed this Jul 25, 2023
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. A3-stale B1-note_worthy Changes should be noted in the release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit T1-runtime This PR/Issue is related to the topic “runtime”.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants