Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Staking] Runtime api if era rewards are pending to be claimed #4301

Merged
merged 8 commits into from Apr 28, 2024

Conversation

Ank4n
Copy link
Contributor

@Ank4n Ank4n commented Apr 25, 2024

closes #426.
related to #1189.

Would help offchain programs to query if there are unclaimed pages of rewards for a given era.

The logic could look like below

// loop as long as all era pages are claimed.
while (api.call.stakingApi.pendingRewards(era, validator_stash)) {
  api.tx.staking.payout_stakers(validator_stash, era)
}

@Ank4n Ank4n added T4-runtime_API This PR/Issue is related to runtime APIs. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. labels Apr 25, 2024
Copy link
Contributor

@acatangiu acatangiu left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

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

How can we do even better, you might ask?

ask @TarikGul and @rossbulat to tell you in which places in their codebase they have to re-implement some formula of some sort and expose those as APIs as well.

title: New runtime api to check if a validator has pending pages of rewards for an era.

doc:
- audience: Node Dev
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- audience: Node Dev
- audience: Node Dev | Runtime Dev

I think it is worth pursuing a new audience type here, wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added Runtime user which is defined in schema as Anyone using the runtime. This can be a token holder or a dev writing a front end for a chain.

@Ank4n Ank4n added this pull request to the merge queue Apr 28, 2024
Merged via the queue into master with commit 73b9a83 Apr 28, 2024
136 of 139 checks passed
@Ank4n Ank4n deleted the ankan/staking/runtime-api-pending-rewards branch April 28, 2024 13:03
Morganamilo pushed a commit that referenced this pull request May 2, 2024
closes #426.
related to #1189.

Would help offchain programs to query if there are unclaimed pages of
rewards for a given era.

The logic could look like below

```js
// loop as long as all era pages are claimed.
while (api.call.stakingApi.pendingRewards(era, validator_stash)) {
  api.tx.staking.payout_stakers(validator_stash, era)
}
```
@TarikGul
Copy link
Member

TarikGul commented May 8, 2024

This is awesome, I'll make sure this is supported in the API when ready. Do we know what runtime this will be apart of?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. T4-runtime_API This PR/Issue is related to runtime APIs.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Staking runtime apis to help with paged reward payouts
4 participants