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

Runtime API Call for Total Active Nominators (& Validators) #12935

Closed
rossbulat opened this issue Dec 15, 2022 · 1 comment
Closed

Runtime API Call for Total Active Nominators (& Validators) #12935

rossbulat opened this issue Dec 15, 2022 · 1 comment

Comments

@rossbulat
Copy link

rossbulat commented Dec 15, 2022

With the recent MinimumActiveStake being put in storage, this could be complemented with a runtime call that returns the remaining metadata dashboards need to display vital active nominator / validator stats.

Proposed runtime call:

stakingApi.totalActiveStakers()

Purpose:

Gets a count of active nominators and validators at the currently active era.

Note that the active validator count is easy to get from validatorCount, and this call could indeed hjust be used to nominators and still retain some value. For completeness though, validators are included here so devs can avoid calling validatorCount in addition to this.

Validators would be those who have been elected, and nominators are those who are backing at least one of those validators (in erasStakers). This saves application-side code from iterating through the whole of erasStakers, accumulating an active nominators list by summing their bonds, and taking the least of those bonded values to find the minimum.

This calculation instead would be done by the call.

Returns the counts of active entities:

{
   activeValidators: u32,
   activeNominators: u32,
}
@kianenigma
Copy link
Contributor

If you are sure that this will help UIs, then we can easily do it. Just note that the API should not be doing all the calculation dynamically upon receiving the call. In that case, the API call would be rather unsafe. If reasonable, we can actually keep track of this number as we are collect_exposures-ing at the end of the era.

Repository owner moved this from 📕 Backlog to ✅ Done in (Nominated) Proof of Stake Dec 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants