Skip to content

Conversation

mvds00
Copy link

@mvds00 mvds00 commented Sep 7, 2025

Description of the Change

This PR implements a new, simple way of interacting with bittensor runtime data. It was pushed 8 months ago but got some renewed attention recently and is now discussed in CoR channel btcli-btsdk. An async version was added.

The core ideas are that:

  • you should need only one line to get a particular value from the runtime
  • you only need the name of the storage item
  • ideally, accessing data from the runtime looks like accessing a local object property
  • you should be able to specify the block number in that one line
  • the code should rely on on-chain metadata so that it is always up to date and backward compatible
  • error messages should be self explanatory and use metadata to give useful hints
  • __repr__() should be helpful as well
  • we should be welcoming new developers, and make life easy for them; more sophisticated/reliable/faster/better methods of accessing the same data may exist, but there should be a straightforward way that requires no explanation

The PR contains ample examples, but here are a few that highlight how the points above are met, in a python -i instance:

>>> import bittensor
>>> ck = bittensor.runtime.SubtensorModule.SubnetOwner[29]
>>> ck
'5HHHHHzgLnYRvnKkHd45cRUDMHXTSwx7MjUzxBrKbY4JfZWn'
>>> bittensor.runtime.System.Account[ck]['data']['free']
205451
>>> bittensor.runtime.SubtensorModule.TotalHotkeyAlpha(ck,29)
2235109938216
>>> bittensor.runtime.SubtensorModule.TotalHotkeyAlpha(ck,29,block=6000000)
1336928150710

Alternate Designs

No alternate designs were considered, as it can't get any simpler than this.

Possible Drawbacks

More code to maintain. The magic code mapping the metadata to magical objects isn't easy to digest.

Verification Process

N/A, this is just a first request for feedback.

Release Notes

Improved interface to allow python access to subtensor runtime variables.

Branch Acknowledgement

[ ] I am acknowledging that I am opening this branch against staging Branch is built on top of branch SDKv10

Roman and others added 30 commits August 27, 2025 14:52
@basfroman
Copy link
Collaborator

basfroman commented Sep 8, 2025

Note: related with #2601

@basfroman basfroman force-pushed the SDKv10 branch 4 times, most recently from bf733bd to 0229d35 Compare September 29, 2025 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants