Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
444 commits
Select commit Hold shift + click to select a range
02cdea4
AttributeError: comman -> command
isabella618033 Jan 12, 2023
713c855
don't save stake to metagraph save
camfairchild Jan 12, 2023
be40479
try fix by mocking with a constant
camfairchild Jan 12, 2023
6628468
fix unstake test
camfairchild Jan 12, 2023
e7e3ab1
use colkeypub
camfairchild Jan 13, 2023
4fc54fa
dont use remote on sub mock
camfairchild Jan 13, 2023
fb56dc7
fix unstake tests
camfairchild Jan 13, 2023
64f5152
fix cli stake tests
camfairchild Jan 13, 2023
38fd53d
remove no cache and tests
camfairchild Jan 16, 2023
dfa7246
use total stake for neuron from dict
camfairchild Jan 16, 2023
a2322ba
add netuid to test config
camfairchild Jan 16, 2023
72e3f6c
change default format to ws://
camfairchild Jan 16, 2023
e156bac
add copyright notices
camfairchild Jan 16, 2023
0a9e8e9
add unit test for from neurons
camfairchild Jan 16, 2023
99b793b
remove forward test
camfairchild Jan 16, 2023
a8db927
add netuid optional to sync
camfairchild Jan 16, 2023
558ff61
updated call in benchmark
camfairchild Jan 16, 2023
1ffd829
make mock helper
camfairchild Jan 16, 2023
68e3398
add mock call override for neurons
camfairchild Jan 16, 2023
bb24f63
use mock call instead
camfairchild Jan 16, 2023
161a714
update copyright notices
camfairchild Jan 17, 2023
a786d4f
fix ss58 byte length
camfairchild Jan 17, 2023
834d935
fix test for wandb
camfairchild Jan 17, 2023
575189a
fix test decl
camfairchild Jan 17, 2023
a420266
add ws to nobu for tests
camfairchild Jan 17, 2023
db7a10a
Fix/neuron netuid arg (#1056)
camfairchild Jan 17, 2023
cb34a70
Merge branch 'finney' into fix_stake_is_none
camfairchild Jan 17, 2023
8ff88d7
return bool
camfairchild Jan 18, 2023
0d01aaa
add test helper get mock neuron by uid
camfairchild Jan 18, 2023
e63e407
fix some subtensor tests
camfairchild Jan 18, 2023
fab3cdb
fix axon test, mock wallet
camfairchild Jan 19, 2023
92665dd
remove connect tests
camfairchild Jan 19, 2023
d46e915
use netuid
camfairchild Jan 19, 2023
0c1aec4
fix no axon info on inspect
camfairchild Jan 19, 2023
e3ba946
add error for endpoint from null neuron
camfairchild Jan 19, 2023
0f46fdc
support SubnetInfo RPC (#1049)
camfairchild Jan 19, 2023
1f2bbbc
Support delegateInfo RPC (#1059)
camfairchild Jan 19, 2023
5814a46
Merge branch 'finney' into fix_stake_is_none
camfairchild Jan 19, 2023
b35b8f8
Fix/only explorer if known network (#1037)
camfairchild Jan 19, 2023
3d5f67e
fix func call
camfairchild Jan 19, 2023
b7aaad6
oops
camfairchild Jan 20, 2023
6619218
add more mocks
camfairchild Jan 20, 2023
9861ed3
add netuid and network mock
camfairchild Jan 20, 2023
86ff8a6
patch everything
camfairchild Jan 20, 2023
66ce99c
mock payment info
camfairchild Jan 20, 2023
8b8a77f
patch query
camfairchild Jan 20, 2023
58b686b
fix mock and check patch attr
camfairchild Jan 21, 2023
ea58db0
add netuid to default test config
camfairchild Jan 23, 2023
1ffbebe
fix test
camfairchild Jan 23, 2023
878b5bb
notify user that hotkey is not registered (#1030)
camfairchild Jan 23, 2023
f15de5b
bool fix for btcli
Eugene-hu Jan 24, 2023
a004506
add call for validator permit (#1061)
camfairchild Jan 24, 2023
8fab52f
Merge branch 'finney' into fix_stake_is_none
camfairchild Jan 24, 2023
0c9327b
Remove Py 3.7 (#1067)
camfairchild Jan 24, 2023
bdb3ebc
Catch subnet doesn't exist (#1070)
camfairchild Jan 25, 2023
8d1e01f
Merge branch 'finney' into fix_stake_is_none
camfairchild Jan 26, 2023
c0b6106
Move hotkeys flag (#1071)
camfairchild Jan 26, 2023
8d3d574
[fix] rename ss58_hotkey to hotkey_ss58 (#1074)
camfairchild Jan 26, 2023
a796980
[fix] instantiate subtensor before check for netuids (#1072)
camfairchild Jan 26, 2023
f19f487
Merge branch 'finney' into fix_stake_is_none
camfairchild Jan 26, 2023
e568e93
fix f string error
camfairchild Jan 26, 2023
f4e54e9
move rao symbol to init
camfairchild Jan 26, 2023
dabbcaa
mock is_hotkey_registered_any
camfairchild Jan 26, 2023
6a73834
fix mock without mock subtensor
camfairchild Jan 26, 2023
04ef8ba
modify args for mocking
camfairchild Jan 26, 2023
2e8986d
fix test for new args
camfairchild Jan 26, 2023
147b1fa
fix f string error
camfairchild Jan 26, 2023
b51f649
Merge branch 'finney' into fix_stake_is_none
camfairchild Jan 26, 2023
3831ceb
[BIT-626] Add neuron_info fields for ValidatorTrust and WeightConsens…
opentaco Jan 26, 2023
af39613
fix type reg
camfairchild Jan 26, 2023
88ea6d8
fix type hints
camfairchild Jan 26, 2023
978d85e
Merge branch 'finney' into fix_stake_is_none
camfairchild Jan 26, 2023
8cfbf56
fix get mock neuron
camfairchild Jan 26, 2023
6530c31
fix mock_subtensor neurons
camfairchild Jan 26, 2023
d2426a2
fix neuron from json
camfairchild Jan 26, 2023
31f480c
[fix] [ci] modify cache key (#1075)
camfairchild Jan 27, 2023
5a75316
Merge branch 'finney' into fix_stake_is_none
camfairchild Jan 27, 2023
55d8684
Add init for extrinsics submod (#1077)
camfairchild Jan 31, 2023
92e3346
Fix is_registered call (#1080)
camfairchild Jan 31, 2023
c04403c
[Fix] comment out addition of new neuron fields (#1081)
camfairchild Feb 1, 2023
ceb29a2
[hotfix][3.6.3] Merging back hotfix into finney (#1065)
eduardogr Feb 2, 2023
924330e
Adding CHANGELOG and updating .circleci/config.yml
eduardogr Jan 19, 2023
b8b77b3
Server update for finney (#1053)
Eugene-hu Feb 2, 2023
d1439f6
Merge pull request #1082 from opentensor/infra/adding-changelog-and-i…
eduardogr Feb 6, 2023
31e73dc
fix bittensor dir path (#1088)
camfairchild Feb 9, 2023
eec6d88
update substrate interface version (#1087)
camfairchild Feb 9, 2023
cb85fc4
Fix/get ss58 format (#1090)
camfairchild Feb 10, 2023
315422e
Restore from json (#1092)
camfairchild Feb 14, 2023
70d3cf6
Add undelegate command (#1076)
camfairchild Feb 14, 2023
d455746
update torch version to 1.13.1 and docker to py3.10 (#1089)
camfairchild Feb 14, 2023
a02d68c
Fix pad_token not set
opentaco Feb 16, 2023
80780f6
Merge pull request #1098 from opentensor/feature/BIT-629/fix-pad-toke…
opentaco Feb 16, 2023
5b502b4
bring working with finney and mock branch
camfairchild Feb 16, 2023
0f3dcc7
Merge branch 'finney' into fix_stake_is_none
camfairchild Feb 16, 2023
3a2789a
move zombienet things
camfairchild Feb 16, 2023
a517a77
remove client tests
camfairchild Feb 16, 2023
46665f0
add unique keypairs per test
camfairchild Feb 16, 2023
a401c83
use mock chain to setup tests for stake
camfairchild Feb 16, 2023
bf01e19
use coldkeypub
camfairchild Feb 21, 2023
06965ef
use total_stake for overview
camfairchild Feb 21, 2023
5a5cd04
Merge remote-tracking branch 'origin/master' into release/3.7.0
Eugene-hu Feb 22, 2023
5c73010
[BIT-630] Add netuid to validator console status (#1102)
opentaco Feb 27, 2023
bc69c76
Merge branch 'release/3.7.0' of https://github.com/opentensor/bittens…
Eugene-hu Feb 27, 2023
fcf5b81
undelegate
Eugene-hu Feb 27, 2023
ff4af76
Dataset API cleanup (#1106)
joeylegere Mar 2, 2023
70c93e6
Release 3.7 subtensor integration (#1105)
isabella618033 Mar 7, 2023
5c39586
Release 3.7 replace paratensor (#1109)
Eugene-hu Mar 7, 2023
eb27b4e
remove zombienet use new subv3
camfairchild Mar 8, 2023
8006710
fix flags
camfairchild Mar 8, 2023
83c1930
module name to Subtensor
camfairchild Mar 8, 2023
b39c64f
change module name
camfairchild Mar 8, 2023
50fb3c1
oops SubtensorModule
camfairchild Mar 8, 2023
8cb1102
clear mock db before start of mock chain
camfairchild Mar 8, 2023
ce20998
fix rm dir
camfairchild Mar 8, 2023
f170afe
fix generate mock keypair
camfairchild Mar 8, 2023
d97b8cb
make same coldkey
camfairchild Mar 8, 2023
812080d
verify all str
camfairchild Mar 8, 2023
5b9ada3
fix coldkey keypair as same
camfairchild Mar 8, 2023
ecef5d0
fix use keyword
camfairchild Mar 8, 2023
158367e
fix own hotkey check
camfairchild Mar 8, 2023
044d779
fix delegate check
camfairchild Mar 8, 2023
b4390b9
progress fixing tests
camfairchild Mar 8, 2023
d87e9ef
merge vunes branch
unconst Mar 8, 2023
b605b02
adding --netuid to subtensor parser
isabella618033 Mar 8, 2023
1225e4c
Merge branch 'release/3.7.0' of https://github.com/opentensor/bittens…
isabella618033 Mar 8, 2023
d2a373e
overview fix
Eugene-hu Mar 8, 2023
40bfca4
default use finney for network (#1110)
camfairchild Mar 8, 2023
d37ed8c
Fix unit (#1111)
camfairchild Mar 8, 2023
159a7e1
Fix stake is none (#1112)
camfairchild Mar 8, 2023
6fdc095
fix stake output for inspect (#1113)
camfairchild Mar 8, 2023
3a159c9
Security update 3.7.0 (#1103)
Eugene-hu Mar 8, 2023
bf466a7
naka metagraph fix
isabella618033 Mar 8, 2023
44b2c73
Merge branch 'release/3.7.0' of https://github.com/opentensor/bittens…
isabella618033 Mar 8, 2023
786c19a
remove fee call (#1115)
camfairchild Mar 8, 2023
466956b
Overview and Transfer tests (#1114)
camfairchild Mar 8, 2023
1cca2a9
Fix metagraph output (#1116)
camfairchild Mar 9, 2023
7ee6bcc
Neuron metagraph fix (#1118)
isabella618033 Mar 9, 2023
6c53f38
(un)stake CLI tests (#1117)
camfairchild Mar 9, 2023
a0a8dcb
update finney endpoint (#1119)
Eugene-hu Mar 9, 2023
c407361
Add hyp params (#1121)
camfairchild Mar 9, 2023
c4d2539
validator trust (#1120)
Eugene-hu Mar 9, 2023
b62f690
fixes for overview + server
Eugene-hu Mar 10, 2023
c15a924
self subtensor
Eugene-hu Mar 10, 2023
464ae50
Add prometheus extrinsic (#1124)
isabella618033 Mar 10, 2023
3598285
Add prometheus extrinsic (#1125)
isabella618033 Mar 10, 2023
730bd1f
validator fix
isabella618033 Mar 10, 2023
ae5e68d
btcli burned_register (#1123)
camfairchild Mar 10, 2023
43aac87
[BIT-634] Remove `weight_consensus` and fully include `validator_trus…
opentaco Mar 13, 2023
8342c59
Add prometheus already served check (#1130)
isabella618033 Mar 14, 2023
165ad45
3.7 server fix (#1126)
Eugene-hu Mar 14, 2023
5455038
prometheus port check
isabella618033 Mar 14, 2023
ab68455
Use new rpc format (#1131)
camfairchild Mar 15, 2023
687407a
Revert "Use new rpc format" (#1132)
camfairchild Mar 15, 2023
77a23a6
Use new rpc format (#1133)
camfairchild Mar 16, 2023
e5ecc84
Use scalecodec for custom RPCs (#1134)
camfairchild Mar 17, 2023
a1d2de0
Fix prometheus serve (#1136)
camfairchild Mar 17, 2023
2c40f40
nit changes to loggin and config warning
unconst Mar 17, 2023
2589ac8
Merge branch 'release/3.7.0' of https://github.com/opentensor/bittens…
unconst Mar 17, 2023
e558e76
Add netuid to path (#1137)
isabella618033 Mar 17, 2023
a0231f6
Fix validator weights table metagraph_n (#1138)
opentaco Mar 17, 2023
de94734
Overview emission per block and undelegate (#1140)
isabella618033 Mar 17, 2023
f8c77ca
add burn to registry (#1141)
camfairchild Mar 17, 2023
6a0fe81
Fix scalecodec issue subnetinfo (#1143)
camfairchild Mar 17, 2023
ae2463e
More delegate info (#1142)
camfairchild Mar 17, 2023
931b9a2
Change ValidatorLogitsDivergence to u16 (#1139)
opentaco Mar 17, 2023
96e9758
Fix scaling law powers (#1145)
opentaco Mar 17, 2023
d959e35
add delegates index
unconst Mar 18, 2023
795b754
Merge branch 'release/3.7.0' of https://github.com/opentensor/bittens…
unconst Mar 18, 2023
f92f654
add delegates info.json
unconst Mar 18, 2023
02f96cb
add my delegates
unconst Mar 18, 2023
549b0c0
update with taostats info (#1154)
camfairchild Mar 19, 2023
309d430
Recycle_register (#1152)
quac88 Mar 19, 2023
b2bb00d
Revert "Recycle_register (#1152)" (#1159)
Eugene-hu Mar 19, 2023
00ab94d
Make list prettier (#1147)
camfairchild Mar 19, 2023
b265db4
Prometheus dont error when off (#1153)
camfairchild Mar 19, 2023
abeb4e7
Default to finney (#1155)
camfairchild Mar 19, 2023
5e64c52
version key fixes (#1148)
Eugene-hu Mar 19, 2023
00652fd
Undelegate fix (#1165)
isabella618033 Mar 19, 2023
9a06a97
recycle register 2 (#1164)
quac88 Mar 19, 2023
bec0081
Update delegates.json (#1156)
piotrekraw Mar 19, 2023
8c19e9e
Version 3.7 update (#1167)
Eugene-hu Mar 19, 2023
9f12134
adds total_daily_return to delegateInfo (#1151)
camfairchild Mar 19, 2023
f4081d9
add delegated rpc (#1150)
camfairchild Mar 19, 2023
2672c9f
Neuron info lite RPC (#1149)
camfairchild Mar 19, 2023
1de50fe
Update delegates.json
unconst Mar 20, 2023
ec96cc5
Add taostats.io to delegates (#1171)
mogmachine Mar 20, 2023
0520fb3
chore: update the TaoStation delegate (#1163)
filoozom Mar 20, 2023
2b3e268
Update delegates.json
unconst Mar 20, 2023
cd919c2
Update WaveTensor delegates.json (#1166)
nikogold78 Mar 20, 2023
462cdea
Update delegates.json
unconst Mar 20, 2023
ddb634b
Overview dont count stake twice (#1175)
camfairchild Mar 20, 2023
14a3833
use new rpc and catch file error (#1176)
camfairchild Mar 20, 2023
c884b40
add validator info
unconst Mar 20, 2023
8002135
add foundry digital validator (#1172)
teast21 Mar 20, 2023
c3aefa6
Update delegates.json (#1170)
wildcommunist Mar 20, 2023
32ab533
No advertising about rakebacks (#1177)
camfairchild Mar 20, 2023
50cd11c
Adding TaoStaking info to delegates (#1169)
jermaine150 Mar 20, 2023
fbbeed6
add runpod as validator (#1173)
flash-singh Mar 20, 2023
139d3ec
use neurons lite for overview (#1179)
camfairchild Mar 20, 2023
d9e6a3c
Remove weights underflow fix (#1178)
opentaco Mar 20, 2023
a037eda
Merge branch 'master' into release/3.7.0
Eugene-hu Mar 20, 2023
0d4dfcc
Update __init__.py
unconst Mar 20, 2023
8d9383c
Update __init__.py
unconst Mar 20, 2023
0fbf6e4
fix delegates
unconst Mar 20, 2023
fd3281b
remove check network
unconst Mar 20, 2023
25db052
hotkey naming on wallet regen
unconst Mar 20, 2023
0614b37
-all to my_delegates
unconst Mar 20, 2023
a8cd906
add per 1000 tao
unconst Mar 20, 2023
55fc7e0
Merge branch 'master' into release/3.7.0
unconst Mar 20, 2023
7f36516
fix per 24 hour
unconst Mar 20, 2023
820a258
Merge branch 'release/3.7.0' of https://github.com/opentensor/bittens…
unconst Mar 20, 2023
ac136ae
fix inspect
unconst Mar 21, 2023
d6b69c6
fix minor in inspect
unconst Mar 21, 2023
7b99430
Update delegates.json (#1181)
nickbeentjes Mar 21, 2023
a994a80
merge master
unconst Mar 21, 2023
202c152
fix delegates.json
unconst Mar 21, 2023
991ac20
Hotfixes 3.7.0 (#1187)
camfairchild Mar 21, 2023
939b3f7
add percentage change to list_delegates
unconst Mar 21, 2023
684b0dd
merge remote
unconst Mar 21, 2023
cf8feda
remove axon + fix emission (#1188)
Eugene-hu Mar 21, 2023
661ad4f
allow inspect to get keys from the chain and also allow unstake to ac…
unconst Mar 21, 2023
4c22afb
Merge branch 'release/3.7.0' of https://github.com/opentensor/bittens…
unconst Mar 21, 2023
4253592
Overview - only tempo once (#1191)
camfairchild Mar 21, 2023
9bda95a
Merge branch 'master' of https://github.com/opentensor/bittensor into…
unconst Mar 21, 2023
dd54f57
Request to add Lucrosus Capital to delegates.json (#1192)
LucrosusCapital Mar 21, 2023
eff4da8
Merge branch 'release/3.7.0' of https://github.com/opentensor/bittens…
unconst Mar 21, 2023
e0b52b9
Server validator hotfix (#1189)
isabella618033 Mar 21, 2023
c49244a
push vogue tensor to delegates
unconst Mar 21, 2023
8dce261
Merge branch 'release/3.7.0' of https://github.com/opentensor/bittens…
unconst Mar 21, 2023
60aefd0
fix ts to τs
unconst Mar 21, 2023
93168f7
fix inspect command (#1194)
camfairchild Mar 21, 2023
bef280c
fix finney explorer (#1200)
camfairchild Mar 21, 2023
2bf142e
3.7 version checking (#1195)
Eugene-hu Mar 21, 2023
230c6ba
No zero nominators (#1206)
camfairchild Mar 22, 2023
2f8d464
Adding Validator Info (#1183)
0xSkol Mar 22, 2023
6e8d692
Update delegates.json (#1211)
StakeTensor Mar 22, 2023
d8626c4
Update delegates.json (#1210)
StakeTensor Mar 22, 2023
edc5711
Update delegates.json (#1202)
gmarlettTS Mar 22, 2023
c527d7e
Update delegates.json (#1209)
lewbare Mar 22, 2023
eaa0a5c
Update delegates.json (#1208)
lawrenceboyd-1995 Mar 22, 2023
b2dde90
Update delegates.json (#1204)
quac88 Mar 22, 2023
adab6ec
Fix (un)stake multiple (#1214)
camfairchild Mar 22, 2023
893fa24
Check transfer fee (#1215)
camfairchild Mar 22, 2023
17ab7f6
set weights era parameter (#1219)
Eugene-hu Mar 23, 2023
1c48a50
Update delegates.json (#1218)
arguad Mar 23, 2023
d98d8ef
Update delegates.json (#1217)
TAOVali Mar 23, 2023
38d0917
Overview emission in rao (#1213)
isabella618033 Mar 23, 2023
4690ddf
Add TAO almanach (#1222)
camfairchild Mar 23, 2023
7247411
3.7 merge master (#1223)
Eugene-hu Mar 23, 2023
1ff0d21
empty commit
Eugene-hu Mar 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions bittensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def turn_console_off():
# Needs to use wss://
__bellagene_entrypoint__ = "wss://parachain.opentensor.ai:443"

__local_entrypoint__ = "ws://127.0.0.1:9945"
__local_entrypoint__ = "ws://127.0.0.1:9944"

__tao_symbol__: str = chr(0x03C4)

Expand All @@ -87,11 +87,10 @@ def turn_console_off():
# Block Explorers map network to explorer url
## Must all be polkadotjs explorer urls
__network_explorer_map__ = {
'local': "https://explorer.nakamoto.opentensor.ai/#/explorer",
'local': "https://explorer.finney.opentensor.ai/#/explorer",
'nakamoto': "https://explorer.nakamoto.opentensor.ai/#/explorer",
'endpoint': "https://explorer.nakamoto.opentensor.ai/#/",
'nobunaga': "https://staging.opentensor.ai/#/explorer",
'finney': "https://explorer.opentensor.ai/"
'endpoint': "https://explorer.finney.opentensor.ai/#/explorer",
'finney': "https://explorer.finney.opentensor.ai/#/explorer"
}

# Avoid collisions with other processes
Expand All @@ -101,9 +100,12 @@ def turn_console_off():

__mock_chain_db__ = './tmp/mock_chain_db'

# Delegate Profiles
__delegate_profiles_url__: str = 'https://raw.githubusercontent.com/opentensor/delegate_profiles/master/DELEGATES.md'

# --- Type Registry ---
__type_registry__ = {
'types': {
'Balance': 'u64', # Need to override default u128
},
}

# --- Prometheus ---
__prometheus_version__ = "0.1.0"
Expand Down Expand Up @@ -207,4 +209,4 @@ def turn_console_off():
wandb.add_defaults( defaults )
logging.add_defaults( defaults )

from substrateinterface import Keypair as Keypair
from substrateinterface import Keypair as Keypair
6 changes: 5 additions & 1 deletion bittensor/_axon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def check_config(cls, config: 'bittensor.Config' ):
bittensor.wallet.check_config( config )

@classmethod
def default_synapse_check(cls, synapse, hotkey ):
def default_synapse_check(cls, synapse, hotkey, inputs ):
""" default synapse check function
"""
if len(hotkey) == bittensor.__ss58_address_length__:
Expand Down Expand Up @@ -412,8 +412,12 @@ def parse_signature(
) -> Tuple[int, str, str, str, int]:
r"""Attempts to parse a signature from the metadata"""
signature = metadata.get("bittensor-signature")
version = metadata.get('bittensor-version')
if signature is None:
raise Exception("Request signature missing")
if int(version) < 370:
raise Exception("Incorrect Version")

for parser in [self.parse_signature_v2, self.parse_legacy_signature]:
parts = parser(signature)
if parts is not None:
Expand Down
2 changes: 1 addition & 1 deletion bittensor/_cli/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
from .list import ListCommand
from .weights import SetWeightsCommand, WeightsCommand
from .query import QueryCommand
from .misc import HelpCommand, UpdateCommand, ListSubnetsCommand
from .misc import HelpCommand, UpdateCommand, ListSubnetsCommand
198 changes: 132 additions & 66 deletions bittensor/_cli/commands/delegates.py

Large diffs are not rendered by default.

215 changes: 115 additions & 100 deletions bittensor/_cli/commands/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,137 +15,152 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

import sys
import json
import argparse
import bittensor
from tqdm import tqdm
from rich.table import Table
from rich.prompt import Prompt
from .utils import check_netuid_set
console = bittensor.__console__

import os
import bittensor
from typing import List, Tuple

def _get_coldkey_wallets_for_path( path: str ) -> List['bittensor.wallet']:
try:
wallet_names = next(os.walk(os.path.expanduser(path)))[1]
return [ bittensor.wallet( path= path, name=name ) for name in wallet_names ]
except StopIteration:
# No wallet files found.
wallets = []
return wallets

def _get_hotkey_wallets_for_wallet( wallet ) -> List['bittensor.wallet']:
hotkey_wallets = []
hotkeys_path = wallet.path + '/' + wallet.name + '/hotkeys'
try:
hotkey_files = next(os.walk(os.path.expanduser(hotkeys_path)))[2]
except StopIteration:
hotkey_files = []
for hotkey_file_name in hotkey_files:
try:
hotkey_for_name = bittensor.wallet( path = wallet.path, name = wallet.name, hotkey = hotkey_file_name )
if hotkey_for_name.hotkey_file.exists_on_device() and not hotkey_for_name.hotkey_file.is_encrypted():
hotkey_wallets.append( hotkey_for_name )
except Exception:
pass
return hotkey_wallets

class InspectCommand:
@staticmethod
def run (cli):
r""" Inspect a cold, hot pair.
"""
wallet = bittensor.wallet(config = cli.config)
if cli.config.all == True:
wallets = _get_coldkey_wallets_for_path( cli.config.wallet.path )
else:
wallets = [bittensor.wallet( config = cli.config )]
subtensor = bittensor.subtensor( config = cli.config )

if cli.config.netuid != None:
# Verify subnet exists
if not subtensor.subnet_exists( netuid = cli.config.netuid ):
bittensor.__console__.print(f"[red]Subnet {cli.config.netuid} does not exist[/red]")
sys.exit(1)


with bittensor.__console__.status(":satellite: Looking up account on: [white]{}[/white] ...".format(cli.config.subtensor.get('network', bittensor.defaults.subtensor.network))):

if cli.config.wallet.get('hotkey', bittensor.defaults.wallet.hotkey) is None:
# If no hotkey is provided, inspect just the coldkey
wallet.coldkeypub
cold_balance = wallet.get_balance( subtensor = subtensor )
bittensor.__console__.print("\n[bold white]{}[/bold white]:\n {}[bold white]{}[/bold white]\n {} {}\n".format( wallet, "coldkey:".ljust(15), wallet.coldkeypub.ss58_address, " balance:".ljust(15), cold_balance.__rich__()), highlight=True)
netuids = subtensor.get_all_subnet_netuids()

try:
package_dir = os.path.dirname(bittensor.__file__)
root_dir = os.path.dirname(package_dir)
filename = os.path.join(root_dir, 'delegates.json')
if os.path.exists(filename):
registered_delegate_info = json.load( open(filename, 'r') )
else:
wallet.hotkey
wallet.coldkeypub
registered_delegate_info = {}
except:
registered_delegate_info = {}

if cli.config.netuid != None:
# If a netuid is provided, inspect the hotkey and the neuron
dendrite = bittensor.dendrite( wallet = wallet )
neuron = subtensor.get_neuron_for_pubkey_and_subnet( hotkey_ss58 = wallet.hotkey.ss58_address, netuid = cli.config.netuid )
if neuron.is_null:
registered = '[bold white]No[/bold white]'
stake = bittensor.Balance.from_tao( 0 )
emission = bittensor.Balance.from_rao( 0 )
latency = 'N/A'
else:
endpoint = bittensor.endpoint.from_neuron( neuron )
registered = '[bold white]Yes[/bold white]'
stake = neuron.total_stake
emission = bittensor.Balance.from_rao( neuron.emission * 1000000000 )
synapses = [bittensor.synapse.TextLastHiddenState()]
_, c, t = dendrite.text( endpoints = endpoint, inputs = 'hello world', synapses=synapses)
latency = "{}".format((t[0]).tolist()[0]) if (c[0]).tolist()[0] == 1 else 'N/A'
neuron_state_dict = {}
for netuid in tqdm( netuids ):
neuron_state_dict[netuid] = subtensor.neurons_lite( netuid )

cold_balance = subtensor.get_balance( wallet.coldkeypub.ss58_address )
bittensor.__console__.print((
"\n[bold white]{}[/bold white]:\n [bold grey]{}[bold white]{}[/bold white]\n" + \
" {}[bold white]{}[/bold white]\n {}{}\n {}{}\n {}{}\n {}{}\n {}{}[/bold grey]"
)
.format(
wallet,
"coldkey:".ljust(15),
wallet.coldkeypub.ss58_address,
"hotkey:".ljust(15),
wallet.hotkey.ss58_address,
"registered:".ljust(15),
registered,
"balance:".ljust(15),
cold_balance.__rich__(),
"stake:".ljust(15),
stake.__rich__(),
"emission:".ljust(15),
emission.__rich_rao__(),
"latency:".ljust(15),
latency
), highlight=True)
table = Table(show_footer=True, pad_edge=False, box=None, expand=True)
table.add_column("[overline white]Coldkey", footer_style = "overline white", style='bold white')
table.add_column("[overline white]Balance", footer_style = "overline white", style='green')
table.add_column("[overline white]Delegate", footer_style = "overline white", style='blue')
table.add_column("[overline white]Stake", footer_style = "overline white", style='green')
table.add_column("[overline white]Emission", footer_style = "overline white", style='green')
table.add_column("[overline white]Netuid", footer_style = "overline white", style='bold white')
table.add_column("[overline white]Hotkey", footer_style = "overline white", style='yellow')
table.add_column("[overline white]Stake", footer_style = "overline white", style='green')
table.add_column("[overline white]Emission", footer_style = "overline white", style='green')
for wallet in tqdm( wallets ):
delegates: List[Tuple(bittensor.DelegateInfo, bittensor.Balance)] = subtensor.get_delegated( coldkey_ss58=wallet.coldkeypub.ss58_address )
if not wallet.coldkeypub_file.exists_on_device(): continue
cold_balance = wallet.get_balance( subtensor = subtensor )
table.add_row(
wallet.name,
str(cold_balance),
'',
'',
'',
'',
'',
'',
'',
)
for dele, staked in delegates:
if dele.hotkey_ss58 in registered_delegate_info:
delegate_name = registered_delegate_info[dele.hotkey_ss58]['name']
else:
# Otherwise, print all subnets the hotkey is registered on.
# If a netuid is provided, inspect the hotkey and the neuron
stake = subtensor.get_stake_for_coldkey_and_hotkey( hotkey_ss58 = wallet.hotkey.ss58_address, coldkey_ss58 = wallet.coldkeypub.ss58_address )
if stake == None:
# Not registered on any subnets
subnets = "[bold white][][/bold white]"
stake = bittensor.Balance.from_tao( 0 )
else:
# Registered on subnets
subnets_registered = subtensor.get_netuids_for_hotkey( hotkey_ss58 = wallet.hotkey.ss58_address )
subnets = f'[bold white]{subnets_registered}[/bold white]'

emission = bittensor.Balance.from_rao( 0 )
for netuid in subnets_registered:
neuron = subtensor.neuron_for_pubkey( hotkey_ss58 = wallet.hotkey.ss58_address, netuid = netuid )
emission += bittensor.Balance.from_rao( neuron.emission * 1000000000 )

cold_balance = subtensor.get_balance( wallet.coldkeypub.ss58_address )
bittensor.__console__.print((
"\n[bold white]{}[/bold white]:\n [bold grey]{}[bold white]{}[/bold white]\n" + \
" {}[bold white]{}[/bold white]\n {}{}\n {}{}\n {}{}\n {}{}\n {}{}[/bold grey]"
)
.format(
wallet,
"coldkey:".ljust(15),
wallet.coldkeypub.ss58_address,
"hotkey:".ljust(15),
wallet.hotkey.ss58_address,
"subnets:".ljust(15),
subnets,
"balance:".ljust(15),
cold_balance.__rich__(),
"stake:".ljust(15),
stake.__rich__(),
"emission:".ljust(15),
emission.__rich_rao__(),
), highlight=True)
delegate_name = dele.hotkey_ss58
table.add_row(
'',
'',
str(delegate_name),
str(staked),
str(dele.total_daily_return.tao * (staked.tao/dele.total_stake.tao)),
'',
'',
'',
''
)

hotkeys = _get_hotkey_wallets_for_wallet( wallet )
for netuid in netuids:
for neuron in neuron_state_dict[netuid]:
if neuron.coldkey == wallet.coldkeypub.ss58_address:
table.add_row(
'',
'',
'',
'',
'',
str( netuid ),
str( neuron.hotkey ),
str( neuron.stake ),
str( bittensor.Balance.from_tao(neuron.emission) )
)

bittensor.__console__.print(table)



@staticmethod
def check_config( config: 'bittensor.Config' ):
check_netuid_set( config, subtensor = bittensor.subtensor( config = config ),allow_none = True )
if config.wallet.get('name') == bittensor.defaults.wallet.name and not config.no_prompt:
if not config.all and config.wallet.get('name') == bittensor.defaults.wallet.name and not config.no_prompt:
wallet_name = Prompt.ask("Enter wallet name", default = bittensor.defaults.wallet.name)
config.wallet.name = str(wallet_name)

if config.wallet.get('hotkey') == bittensor.defaults.wallet.hotkey and not config.no_prompt:
hotkey = Prompt.ask("Enter hotkey name (optional)", default = None)
config.wallet.hotkey = hotkey

@staticmethod
def add_args( parser: argparse.ArgumentParser ):
inspect_parser = parser.add_parser(
'inspect',
help='''Inspect a wallet (cold, hot) pair'''
)
inspect_parser.add_argument(
'--all',
action='store_true',
help='''Check all coldkey wallets.''',
default = False
)
inspect_parser.add_argument(
'--no_prompt',
dest='no_prompt',
Expand Down
11 changes: 6 additions & 5 deletions bittensor/_cli/commands/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def run( cli ):
return

# Pull neuron info for all keys.
neurons: Dict[str, List[bittensor.NeuronInfo, bittensor.Wallet]] = {}
neurons: Dict[str, List[bittensor.NeuronInfoLite, bittensor.Wallet]] = {}
block = subtensor.block

netuids = subtensor.get_all_subnet_netuids()
Expand Down Expand Up @@ -115,6 +115,7 @@ def run( cli ):
total_neurons = 0
total_stake = 0.0
for netuid in netuids:
subnet_tempo = subtensor.tempo(netuid=netuid)
last_subnet = netuid == netuids[-1]
TABLE_DATA = []
total_rank = 0.0
Expand All @@ -126,7 +127,7 @@ def run( cli ):
total_emission = 0

for nn, hotwallet in neurons[str(netuid)]:
nn: bittensor.NeuronInfo
nn: bittensor.NeuronInfoLite
uid = nn.uid
active = nn.active
stake = nn.total_stake.tao
Expand All @@ -136,7 +137,7 @@ def run( cli ):
validator_trust = nn.validator_trust
incentive = nn.incentive
dividends = nn.dividends
emission = nn.emission / (subtensor.tempo(netuid=netuid) + 1)
emission = int(nn.emission / (subnet_tempo + 1) * 1e9)
last_update = int(block - nn.last_update)
validator_permit = nn.validator_permit
row = [
Expand All @@ -150,7 +151,7 @@ def run( cli ):
'{:.5f}'.format(consensus),
'{:.5f}'.format(incentive),
'{:.5f}'.format(dividends),
'{:.5f}'.format(emission),
'{:_}'.format(emission),
'{:.5f}'.format(validator_trust),
'*' if validator_permit else '',
str(last_update),
Expand Down Expand Up @@ -196,7 +197,7 @@ def run( cli ):
table.add_column("[overline white]CONSENSUS", '{:.5f}'.format(total_consensus), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]INCENTIVE", '{:.5f}'.format(total_incentive), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]DIVIDENDS", '{:.5f}'.format(total_dividends), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]EMISSION(\u03C4)", '\u03C4{}'.format(int(total_emission)), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]EMISSION(\u03C1)", '\u03C1{:_}'.format(total_emission), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]VTRUST", '{:.5f}'.format(total_validator_trust), footer_style="overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]VPERMIT", justify='right', no_wrap=True)
table.add_column("[overline white]UPDATED", justify='right', no_wrap=True)
Expand Down
Loading