opentensor / bittensor

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

Subtensor.get_subnets excludes subnets past netuid=100 #2208

Closed camfairchild closed 1 week ago

camfairchild commented 3 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 3 months ago

Working on this issue :)