Skip to content

Conversation

@thewhaleking
Copy link
Contributor

@thewhaleking thewhaleking commented Nov 10, 2025

Resolves the metagraph portion of #3138

Demonstrated with:

import asyncio
from bittensor.core.async_subtensor import AsyncSubtensor
from bittensor.core.subtensor import Subtensor
from bittensor.core.settings import ARCHIVE_ENTRYPOINT

async def main():
    async with AsyncSubtensor(ARCHIVE_ENTRYPOINT) as subtensor:
        print(await subtensor.metagraph(netuid=0, block=6500000))
        print(await subtensor.metagraph(netuid=0, block=5500000))
        print(await subtensor.metagraph(netuid=0))


def main_sync():
    with Subtensor(ARCHIVE_ENTRYPOINT) as subtensor:
        print(subtensor.metagraph(netuid=0, block=6500000))
        print(subtensor.metagraph(netuid=0, block=5500000))
        print(subtensor.metagraph(netuid=0))

if __name__ == '__main__':
    asyncio.run(main())
    main_sync()

What this does not cover:

Legacy (think 2023) Runtime API methods were defined through dicts. This is still an issue that needs resolved upstream in async-substrate-interface. However, once that is resolved, no additional work will need done here, but until then the legacy runtime call will not work.

@thewhaleking thewhaleking linked an issue Nov 10, 2025 that may be closed by this pull request
@thewhaleking thewhaleking changed the title [WIP] Adds block backwards compatibility for fetching metagraph. Adds block backwards compatibility for fetching metagraph. Nov 10, 2025
@thewhaleking thewhaleking added the SDKv10 Use this label for issues and feature requests relevant to Bittensor SDK v10. label Nov 10, 2025
@thewhaleking thewhaleking requested a review from a team November 10, 2025 18:31
@basfroman basfroman changed the title Adds block backwards compatibility for fetching metagraph. [v10] Adds block backwards compatibility for fetching metagraph. Nov 10, 2025
Copy link
Collaborator

@basfroman basfroman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work on adding backwards compatibility for metagraph!

Current approach:
If we're only targeting get_metagraph_info, the current solution is fine. However, if we plan to apply this pattern to other methods, we should consider a more scalable approach.

I consider these options:

  1. RuntimeAPIVersionAdapter (or something like this) in SDK (short-term)
  • create a centralized adapter with method mapping and fallback logic.
  • avoids duplicating logic in each method.
  • can be implemented quickly without changing dependencies.
  1. Move logic to ASI (preferred long-term)
  • SDK (or any other clients) shouldn't need to worry about which method to use.
  • the low-level library should handle version detection and return the right data for a given block.
  • better separation of concerns: SDK focuses on business logic, version handling belongs in the substrate layer.
  • reusable for other clients.

@thewhaleking
Copy link
Contributor Author

  1. Move logic to ASI (preferred long-term)
  • SDK (or any other clients) shouldn't need to worry about which method to use.
  • the low-level library should handle version detection and return the right data for a given block.
  • better separation of concerns: SDK focuses on business logic, version handling belongs in the substrate layer.
  • reusable for other clients.

The logic cannot live in ASI. ASI is a general-purpose Substrate library, and thus does have any concept of which methods retrieve which data.

@thewhaleking thewhaleking force-pushed the fix/thewhaleking/metagraph-backwards-compatibility branch from dc6ef7c to 652ec0c Compare November 12, 2025 11:37
@thewhaleking thewhaleking requested review from a team and basfroman November 12, 2025 12:24
@thewhaleking
Copy link
Contributor Author

The failing tests are failing upstream. Seems a new devnet-ready release broke them.

Copy link
Collaborator

@basfroman basfroman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Please resolve the conflicts and let's merge it.

@basfroman
Copy link
Collaborator

The failing tests are failing upstream. Seems a new devnet-ready release broke them.

Yes, tomorrow in the next PR these tests will be fixed.

…tibility

# Conflicts:
#	bittensor/core/async_subtensor.py
#	bittensor/core/subtensor.py
@thewhaleking thewhaleking merged commit 563a8e1 into SDKv10 Nov 18, 2025
151 checks passed
@basfroman basfroman deleted the fix/thewhaleking/metagraph-backwards-compatibility branch November 18, 2025 12:41
@basfroman basfroman mentioned this pull request Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

SDKv10 Use this label for issues and feature requests relevant to Bittensor SDK v10.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Needed: Compatibility for older blocks

3 participants