-
Notifications
You must be signed in to change notification settings - Fork 443
Description
Describe the bug
Hello, I'm currently implementing Bittensor and ran with the TypeError specified in the title:
TypeError: AsyncSubstrateInterface.get_block_number() missing 1 required positional argument: 'block_hash'
To Reproduce
- Install bittensor sdk on your python project
- Run the next snippet
import asyncio
import bittensor
async def main():
subtensor = bittensor.async_subtensor()
current_block = await subtensor.get_current_block()
print(current_block)
if __name__ == "__main__":
asyncio.run(main())- Error happens
File "/project/sandbox.py", line 6, in main
current_block = await subtensor.get_current_block()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/project/.venv/lib/python3.12/site-packages/bittensor/core/async_subtensor.py", line 239, in get_current_block
return await self.substrate.get_block_number()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: AsyncSubstrateInterface.get_block_number() missing 1 required positional argument: 'block_hash'
Expected behavior
As the get_current_block method indicates, I need to access the current block number in the Bittensor blockchain.
I expect to call to the get_current_block method at the AsyncSubtensor class, and receive a number (block_number) in return.
Screenshots
No response
Environment
Mac OS 14.6.1
Additional context
This is happening because AsyncSubtensor.get_current_block calls AsyncSubstrateInterface.get_block_number without any parameters. Since this method expects an optional parameter (block_hash: Optional[str]), it raises a TypeError because no default value of None is given.