Get validators efficiently
I propose that we add a convenience function to return subnet validators, so that all miners of all service-based subnets can efficiently get the information they need about the validators in one go, without getting data for the other miners (nearly a thousand on sn1) unnecessarily.
I suggest to add it as a feature of the selective metagraph fetcher, which already is quite nice, flexible and efficient.
The new boolean flag only_validators would:
- check how many validators a subnet can have (it's a hyperparameter currently set to 64 on all subnets, but that might change in the future)
- check how much effective stake is required for a validator to be able to set weights (currently it's 1k alpha on mainnet, 10 alpha on testnet, but this can change)
- get a list of uids which meet the minimum stake requirement and have vpermit set to
true - sort it by stake
- leave only as many as the hyperparameter specifies that this subnet supports
- return the sorted result
Bittensor can survive without this, but clients will need to do this work on their side and either they won't do it properly and we'll have bugs or they will do it well and we'll have extra load on subtensors that can be avoided.
Note for implementation: vpermits are only given out to at most k Validators, so you don't need to pull the hyperparameter.
That is true if we assume that the value of that hyperparameter has not changed since vpermits were last updated (since last epoch), which I think is a safe assumption.
The solution is like:
- add a new bool parameter named only_validators to get_selective_metagraph function.
- based on the validator staking threshold and the top_k validator permit to filter Uids
- sort the Uids according to staking amount, then return the list. ignoring all other metagraph data items
🤔 if a validator has vpermit, but doesn't have minimum stake then it's not really a validator. If we ignore that, then some subnets will be exploitable, especially those that have a fixed effort of sampling - attacker will be able to reduce the cost of attack by moving stake. Lets check all 3 conditions.
From the comments to the PR #1614, I found out the solution is not ideal. At first, the new parameter will change the old interface. we need to consider the interface version and compatible with old one. secondly, validators list is very different with other metagraph data fetch. A different solution could be adding a new RPC like get_validators_on_subnet, what do you think? @ppolewicz
Confirmed in the weekly meeting. we can ignore the compatibility issue since no too many teams use it now. I will continue with current solution, and the code review process.
🤔 if a validator has vpermit, but doesn't have minimum stake then it's not really a validator. If we ignore that, then some subnets will be exploitable, especially those that have a fixed effort of sampling - attacker will be able to reduce the cost of attack by moving stake. Lets check all 3 conditions.
With #1629, we'll be able to ensure that any validator that has a vpermit MUST also have minimum stake, eliminating one source of concern here.
this was deployed a long time ago