opentensor / bittensor

Internet-scale Neural Networks
https://www.bittensor.com/
MIT License
889 stars 307 forks source link

Subtensor.get_subnets excludes subnets past netuid=100 #2208

Open camfairchild opened 2 months ago

camfairchild commented 2 months ago

Describe the bug

The subtensor.get_subnets function returns at most 100 subnets, regardless of the true subnet count.

To Reproduce

import bittensor

sub = bittensor.subtensor("wss://test.chain.opentensor.ai:443")
subnets = sub.get_subnets()
n_subnets = sub.get_total_subnets()
len(subnets) == n_subnets
# False

Expected behavior

import bittensor

sub = bittensor.subtensor("wss://test.chain.opentensor.ai:443")
subnets = sub.get_subnets()
n_subnets = sub.get_total_subnets()
len(subnets) == n_subnets
# True

Screenshots

No response

Environment

Bittensor 7.3.0

Additional context

This seems to happen because the function uses the subtensor.query_map_subtensor("NetworksAdded", block) which only pulls map entries a page at a time, with the default page size of 100.

We should expect it to pull all pages for this function.

This potentially affects other functions that use the maps in the same way.

niljub commented 1 month ago

Working on this issue :)