subtensor icon indicating copy to clipboard operation
subtensor copied to clipboard

Get validators efficiently

Open ppolewicz opened this issue 8 months ago • 7 comments

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.

ppolewicz avatar May 04 '25 21:05 ppolewicz

Note for implementation: vpermits are only given out to at most k Validators, so you don't need to pull the hyperparameter.

camfairchild avatar May 06 '25 11:05 camfairchild

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.

ppolewicz avatar May 06 '25 22:05 ppolewicz

The solution is like:

  1. add a new bool parameter named only_validators to get_selective_metagraph function.
  2. based on the validator staking threshold and the top_k validator permit to filter Uids
  3. sort the Uids according to staking amount, then return the list. ignoring all other metagraph data items

open-junius avatar May 07 '25 09:05 open-junius

🤔 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.

ppolewicz avatar May 07 '25 11:05 ppolewicz

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

open-junius avatar May 12 '25 14:05 open-junius

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.

open-junius avatar May 12 '25 15:05 open-junius

🤔 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.

keithtensor avatar May 13 '25 10:05 keithtensor

this was deployed a long time ago

ppolewicz avatar Sep 23 '25 15:09 ppolewicz