Cannot get correct information for Bittensor validator
Describe the bug
I try to get info about validator. Most of the fields get correct info, but not all of them.
I use get_delegate_by_hotkey method for which return_per_1000 and total_daily_return options return either 0 values or incorrect ones.
I tried to use get_delegates method as well, but it look like there is an issue with code in your library around decoded = bt_decode.DelegateInfo.decode_vec(vec_u8) in core/chain_data/delegate_info.py
So both methods either don't work or return incorrect info. Please fix or provide any other way. Thanks in advance!
To Reproduce
WAY 1:
import bittensor as bt
sub=bt.subtensor()
v=sub.get_delegate_by_hotkey(hotkey_ss58='VAL_HOTKEY')
v.total_daily_return
## τ0.000000000
v.return_per_1000
## τ0.000000000
WAY 2:
from bittensor.core.chain_data import DelegateInfo
import bittensor as bt
sub=bt.subtensor()
delegates: List[DelegateInfo] = sub.get_delegates()
>>>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/anton/bt/bt_prod/lib/python3.10/site-packages/bittensor/utils/networking.py", line 198, in wrapper
return func(self, *args, **kwargs)
File "/home/anton/bt/bt_prod/lib/python3.10/site-packages/bittensor/core/subtensor.py", line 1670, in get_delegates
return DelegateInfo.list_from_vec_u8(result)
File "/home/anton/bt/bt_prod/lib/python3.10/site-packages/bittensor/core/chain_data/delegate_info.py", line 65, in list_from_vec_u8
decoded = bt_decode.DelegateInfo.decode_vec(vec_u8)
TypeError: argument 'encoded': 'list' object cannot be converted to 'PyBytes'
Expected behavior
I get correct values for validator daily return and return per 1000 TAO.
Screenshots
No response
Environment
Bittensor python package 8.5.1
Additional context
No response
I found one more issue. registrations value is also incorrect.
Please check that both get_delegate_by_hotkey.registrations and get_netuids_for_hotkey provide incorrect info about SNs 54 and 55. Checking with is_hotkey_registered_on_subnet function.
>>> import bittensor as bt
>>> sub=bt.subtensor()
>>> v=sub.get_delegate_by_hotkey(hotkey_ss58='5HRB5xi9W1yEdJGEWPsgtH71mPjAvN2Z9HxNvRMMcK5kXuW2')
>>> v.registrations
[15, 16, 37, 49, 54, 55, 56, 57, 60, 61, 62]
>>> sub.get_netuids_for_hotkey(hotkey_ss58='5HRB5xi9W1yEdJGEWPsgtH71mPjAvN2Z9HxNvRMMcK5kXuW2')
[15, 16, 37, 49, 54, 55, 56, 57, 60, 61, 62]
>>> sub.is_hotkey_registered_on_subnet(hotkey_ss58='5HRB5xi9W1yEdJGEWPsgtH71mPjAvN2Z9HxNvRMMcK5kXuW2',netuid=54)
False
>>> sub.is_hotkey_registered_on_subnet(hotkey_ss58='5HRB5xi9W1yEdJGEWPsgtH71mPjAvN2Z9HxNvRMMcK5kXuW2',netuid=55)
False
>>> sub.is_hotkey_registered_on_subnet(hotkey_ss58='5HRB5xi9W1yEdJGEWPsgtH71mPjAvN2Z9HxNvRMMcK5kXuW2',netuid=56)
True
So I'm confused why hotkey is shown as registered when it doesn't have hotkey registered.
Hey there @antonr-p2p, It looks like WAY 2 is resolved in staging. I am looking into the values of WAY 1, and your third example to see what's going on with them.
For the return_per_1000 issue: https://github.com/opentensor/subtensor/issues/1151
Thanks @thewhaleking for working on this!
@thewhaleking is it fixes already?
Cameron thinks the on-chain formula for the per_1000 may be incorrect, as its values are about 10^6 of what they should be
Cameron thinks the on-chain formula for the per_1000 may be incorrect, as its values are about 10^6 of what they should be
Yes. Turns out the metric is basically meaningless right now.
It takes total_daily_return and divides it by the root stake (stake on subnet 0).
Also, total_daily_return is the unconverted sum of Alpha emissions (including miner emissions) on every subnet that the Delegate has a registration on.
This makes both metrics meaningless. They should be deprecated