Tracking current "AlphaHeld" is cumbersome
Tracking current amount of alpha that is held by all the wallets is cumbersome. The only way to do this is to sum(TotalHotkeyAlpha[_, netuid]) for a given netuid. This is a data heavy map and in order to calculate this sum you have put some "stress" on the node to fetch all 50k+ values.
There are two solutions to this problem and I'd love to see them both! 🥺
Intermediate Solution
Add alphaHeld field to the Metagraph which would be sum(TotalHotkeyAlpha[_, netuid]) (This solution doesn't really "fix" the issue but makes it less cumbersome to fetch)
Actual Long Term Solution
Structure of TotalHotkeyAlpha should be changed from DMAP ( hot, netuid ) --> alpha to DMAP ( netuid, hot ) --> alpha.
This way external systems could more easily calculate alphaHeld via partial queries, i.e., sum(TotalHotkeyAlpha[netuid, _]), which would reduce the number of requests to a node.
I've verified that this change won't break anything on the Subtensor side on version v3.2.8-320.
One more rationale for this change is that when subnets limit will grow to a bigger number, e.g., 1k, the total number of values needed to be fetched to calculate alphaHeld would grow from 50k to 500k+ which would increase fetching time of all TotalHotkeyAlpha values to more than 10 minutes with a local node.
May I tackle this one?
@plind-junior Personally, I'd love to see this done but not sure how feasible it is because:
- The intermediate solution would add extra time to each metagraph request,
- The long term solution is rather a breaking change and might break a lot of indexers.
If you want to tackle this, I think it'd be best to first discuss it with others in #gc channel on CoR Discord. If you make a post there about it, I'd be happy to tag a few ppl that should be involved in the discussion!