bittensor 6.4.0__tar.gz → 6.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. {bittensor-6.4.0/bittensor.egg-info → bittensor-6.4.2}/PKG-INFO +9 -8
  2. {bittensor-6.4.0 → bittensor-6.4.2}/README.md +9 -8
  3. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/__init__.py +11 -4
  4. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/chain_data.py +6 -0
  5. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/network.py +0 -1
  6. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/overview.py +2 -2
  7. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/stake.py +1 -1
  8. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/extrinsics/network.py +2 -2
  9. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/extrinsics/transfer.py +10 -3
  10. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/subtensor.py +58 -11
  11. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/utils/__init__.py +22 -16
  12. {bittensor-6.4.0 → bittensor-6.4.2/bittensor.egg-info}/PKG-INFO +9 -8
  13. {bittensor-6.4.0 → bittensor-6.4.2}/tests/integration_tests/test_subtensor_integration.py +4 -19
  14. {bittensor-6.4.0 → bittensor-6.4.2}/tests/unit_tests/utils/test_utils.py +38 -30
  15. {bittensor-6.4.0 → bittensor-6.4.2}/LICENSE +0 -0
  16. {bittensor-6.4.0 → bittensor-6.4.2}/bin/btcli +0 -0
  17. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/axon.py +0 -0
  18. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/btlogging.py +0 -0
  19. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/cli.py +0 -0
  20. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/__init__.py +0 -0
  21. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/delegates.py +0 -0
  22. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/identity.py +0 -0
  23. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/inspect.py +0 -0
  24. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/list.py +0 -0
  25. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/metagraph.py +0 -0
  26. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/misc.py +0 -0
  27. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/register.py +0 -0
  28. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/root.py +0 -0
  29. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/senate.py +0 -0
  30. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/transfer.py +0 -0
  31. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/unstake.py +0 -0
  32. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/utils.py +0 -0
  33. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/commands/wallets.py +0 -0
  34. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/config.py +0 -0
  35. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/dendrite.py +0 -0
  36. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/errors.py +0 -0
  37. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/extrinsics/__init__.py +0 -0
  38. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/extrinsics/delegation.py +0 -0
  39. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/extrinsics/log_utilities.py +0 -0
  40. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/extrinsics/prometheus.py +0 -0
  41. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/extrinsics/registration.py +0 -0
  42. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/extrinsics/root.py +0 -0
  43. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/extrinsics/senate.py +0 -0
  44. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/extrinsics/serving.py +0 -0
  45. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/extrinsics/set_weights.py +0 -0
  46. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/extrinsics/staking.py +0 -0
  47. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/extrinsics/unstaking.py +0 -0
  48. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/keyfile.py +0 -0
  49. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/metagraph.py +0 -0
  50. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/mock/__init__.py +0 -0
  51. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/mock/keyfile_mock.py +0 -0
  52. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/mock/subtensor_mock.py +0 -0
  53. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/mock/wallet_mock.py +0 -0
  54. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/stream.py +0 -0
  55. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/synapse.py +0 -0
  56. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/tensor.py +0 -0
  57. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/threadpool.py +0 -0
  58. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/types.py +0 -0
  59. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/utils/_register_cuda.py +0 -0
  60. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/utils/balance.py +0 -0
  61. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/utils/formatting.py +0 -0
  62. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/utils/networking.py +0 -0
  63. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/utils/registration.py +0 -0
  64. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/utils/stats.py +0 -0
  65. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/utils/test_utils.py +0 -0
  66. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/utils/wallet_utils.py +0 -0
  67. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/utils/weight_utils.py +0 -0
  68. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor/wallet.py +0 -0
  69. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor.egg-info/SOURCES.txt +0 -0
  70. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor.egg-info/dependency_links.txt +0 -0
  71. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor.egg-info/requires.txt +0 -0
  72. {bittensor-6.4.0 → bittensor-6.4.2}/bittensor.egg-info/top_level.txt +0 -0
  73. {bittensor-6.4.0 → bittensor-6.4.2}/setup.cfg +0 -0
  74. {bittensor-6.4.0 → bittensor-6.4.2}/setup.py +0 -0
  75. {bittensor-6.4.0 → bittensor-6.4.2}/tests/__init__.py +0 -0
  76. {bittensor-6.4.0 → bittensor-6.4.2}/tests/helpers/__init__.py +0 -0
  77. {bittensor-6.4.0 → bittensor-6.4.2}/tests/helpers/helpers.py +0 -0
  78. {bittensor-6.4.0 → bittensor-6.4.2}/tests/integration_tests/__init__.py +0 -0
  79. {bittensor-6.4.0 → bittensor-6.4.2}/tests/integration_tests/test_cli.py +0 -0
  80. {bittensor-6.4.0 → bittensor-6.4.2}/tests/integration_tests/test_cli_no_network.py +0 -0
  81. {bittensor-6.4.0 → bittensor-6.4.2}/tests/integration_tests/test_metagraph_integration.py +0 -0
  82. {bittensor-6.4.0 → bittensor-6.4.2}/tests/unit_tests/__init__.py +0 -0
  83. {bittensor-6.4.0 → bittensor-6.4.2}/tests/unit_tests/test_axon.py +0 -0
  84. {bittensor-6.4.0 → bittensor-6.4.2}/tests/unit_tests/test_dendrite.py +0 -0
  85. {bittensor-6.4.0 → bittensor-6.4.2}/tests/unit_tests/test_keyfile.py +0 -0
  86. {bittensor-6.4.0 → bittensor-6.4.2}/tests/unit_tests/test_metagraph.py +0 -0
  87. {bittensor-6.4.0 → bittensor-6.4.2}/tests/unit_tests/test_subtensor.py +0 -0
  88. {bittensor-6.4.0 → bittensor-6.4.2}/tests/unit_tests/test_synapse.py +0 -0
  89. {bittensor-6.4.0 → bittensor-6.4.2}/tests/unit_tests/test_tensor.py +0 -0
  90. {bittensor-6.4.0 → bittensor-6.4.2}/tests/unit_tests/test_wallet.py +0 -0
  91. {bittensor-6.4.0 → bittensor-6.4.2}/tests/unit_tests/utils/__init__.py +0 -0
  92. {bittensor-6.4.0 → bittensor-6.4.2}/tests/unit_tests/utils/test_balance.py +0 -0
  93. {bittensor-6.4.0 → bittensor-6.4.2}/tests/unit_tests/utils/test_networking.py +0 -0
  94. {bittensor-6.4.0 → bittensor-6.4.2}/tests/unit_tests/utils/test_weight_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bittensor
3
- Version: 6.4.0
3
+ Version: 6.4.2
4
4
  Summary: bittensor
5
5
  Home-page: https://github.com/opentensor/bittensor
6
6
  Author: bittensor.com
@@ -228,7 +228,7 @@ positional arguments:
228
228
  lock_cost Return the lock cost to register a subnet.
229
229
  create Create a new bittensor subnetwork on this chain.
230
230
  register Register a wallet to a network.
231
- register Register a wallet to a network using PoW.
231
+ pow_register Register a wallet to a network using PoW.
232
232
  hyperparameters View subnet hyperparameters.
233
233
 
234
234
  options:
@@ -309,28 +309,28 @@ Axon: Serves Synapse protocols with custom blacklist, priority and verify functi
309
309
  ```python
310
310
  import bittensor
311
311
 
312
- class MySyanpse( bittensor.Synapse ):
312
+ class MySynapse( bittensor.Synapse ):
313
313
  input: int = 1
314
314
  output: int = None
315
315
 
316
316
  # Define a custom request forwarding function
317
- def forward( synapse: MySyanpse ) -> MySyanpse:
317
+ def forward( synapse: MySynapse ) -> MySynapse:
318
318
  # Apply custom logic to synapse and return it
319
319
  synapse.output = 2
320
320
  return synapse
321
321
 
322
322
  # Define a custom request verification function
323
- def verify_my_synapse( synapse: MySyanpse ):
323
+ def verify_my_synapse( synapse: MySynapse ):
324
324
  # Apply custom verification logic to synapse
325
325
  # Optionally raise Exception
326
326
 
327
327
  # Define a custom request blacklist function
328
- def blacklist_my_synapse( synapse: MySyanpse ) -> bool:
328
+ def blacklist_my_synapse( synapse: MySynapse ) -> bool:
329
329
  # Apply custom blacklist
330
330
  # return False ( if non blacklisted ) or True ( if blacklisted )
331
331
 
332
332
  # Define a custom request priority function
333
- def prioritize_my_synape( synapse: MySyanpse ) -> float:
333
+ def prioritize_my_synape( synapse: MySynapse ) -> float:
334
334
  # Apply custom priority
335
335
  return 1.0
336
336
 
@@ -348,6 +348,7 @@ my_axon.attach(
348
348
 
349
349
  Dendrite: Inheriting from PyTorch's Module class, represents the abstracted implementation of a network client module designed
350
350
  to send requests to those endpoints to receive inputs.
351
+
351
352
  Example:
352
353
  ```python
353
354
  dendrite_obj = dendrite( wallet = bittensor.wallet() )
@@ -367,7 +368,7 @@ Use the `root` subcommand to access setting weights on the network across subnet
367
368
  ```bash
368
369
  btcli root weights --wallet.name <coldname> --wallet.hotkey <hotname>
369
370
  Enter netuids (e.g. 0, 1, 2 ...):
370
- # Here enter your selected netuids to wet weights on
371
+ # Here enter your selected netuids to set weights on
371
372
  1, 2
372
373
 
373
374
  >Enter weights (e.g. 0.09, 0.09, 0.09 ...):
@@ -201,7 +201,7 @@ positional arguments:
201
201
  lock_cost Return the lock cost to register a subnet.
202
202
  create Create a new bittensor subnetwork on this chain.
203
203
  register Register a wallet to a network.
204
- register Register a wallet to a network using PoW.
204
+ pow_register Register a wallet to a network using PoW.
205
205
  hyperparameters View subnet hyperparameters.
206
206
 
207
207
  options:
@@ -282,28 +282,28 @@ Axon: Serves Synapse protocols with custom blacklist, priority and verify functi
282
282
  ```python
283
283
  import bittensor
284
284
 
285
- class MySyanpse( bittensor.Synapse ):
285
+ class MySynapse( bittensor.Synapse ):
286
286
  input: int = 1
287
287
  output: int = None
288
288
 
289
289
  # Define a custom request forwarding function
290
- def forward( synapse: MySyanpse ) -> MySyanpse:
290
+ def forward( synapse: MySynapse ) -> MySynapse:
291
291
  # Apply custom logic to synapse and return it
292
292
  synapse.output = 2
293
293
  return synapse
294
294
 
295
295
  # Define a custom request verification function
296
- def verify_my_synapse( synapse: MySyanpse ):
296
+ def verify_my_synapse( synapse: MySynapse ):
297
297
  # Apply custom verification logic to synapse
298
298
  # Optionally raise Exception
299
299
 
300
300
  # Define a custom request blacklist function
301
- def blacklist_my_synapse( synapse: MySyanpse ) -> bool:
301
+ def blacklist_my_synapse( synapse: MySynapse ) -> bool:
302
302
  # Apply custom blacklist
303
303
  # return False ( if non blacklisted ) or True ( if blacklisted )
304
304
 
305
305
  # Define a custom request priority function
306
- def prioritize_my_synape( synapse: MySyanpse ) -> float:
306
+ def prioritize_my_synape( synapse: MySynapse ) -> float:
307
307
  # Apply custom priority
308
308
  return 1.0
309
309
 
@@ -321,6 +321,7 @@ my_axon.attach(
321
321
 
322
322
  Dendrite: Inheriting from PyTorch's Module class, represents the abstracted implementation of a network client module designed
323
323
  to send requests to those endpoints to receive inputs.
324
+
324
325
  Example:
325
326
  ```python
326
327
  dendrite_obj = dendrite( wallet = bittensor.wallet() )
@@ -340,7 +341,7 @@ Use the `root` subcommand to access setting weights on the network across subnet
340
341
  ```bash
341
342
  btcli root weights --wallet.name <coldname> --wallet.hotkey <hotname>
342
343
  Enter netuids (e.g. 0, 1, 2 ...):
343
- # Here enter your selected netuids to wet weights on
344
+ # Here enter your selected netuids to set weights on
344
345
  1, 2
345
346
 
346
347
  >Enter weights (e.g. 0.09, 0.09, 0.09 ...):
@@ -377,4 +378,4 @@ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I
377
378
 
378
379
 
379
380
  ## Acknowledgments
380
- **learning-at-home/hivemind**
381
+ **learning-at-home/hivemind**
@@ -27,7 +27,7 @@ import nest_asyncio
27
27
  nest_asyncio.apply()
28
28
 
29
29
  # Bittensor code and protocol version.
30
- __version__ = "6.4.0"
30
+ __version__ = "6.4.2"
31
31
  version_split = __version__.split(".")
32
32
  __version_as_int__ = (
33
33
  (100 * int(version_split[0]))
@@ -107,9 +107,16 @@ __rao_symbol__: str = chr(0x03C1)
107
107
  # Block Explorers map network to explorer url
108
108
  ## Must all be polkadotjs explorer urls
109
109
  __network_explorer_map__ = {
110
- "local": "https://explorer.finney.opentensor.ai/#/explorer",
111
- "endpoint": "https://explorer.finney.opentensor.ai/#/explorer",
112
- "finney": "https://explorer.finney.opentensor.ai/#/explorer",
110
+ "opentensor": {
111
+ "local": "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fentrypoint-finney.opentensor.ai%3A443#/explorer",
112
+ "endpoint": "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fentrypoint-finney.opentensor.ai%3A443#/explorer",
113
+ "finney": "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fentrypoint-finney.opentensor.ai%3A443#/explorer",
114
+ },
115
+ "taostats": {
116
+ "local": "https://x.taostats.io",
117
+ "endpoint": "https://x.taostats.io",
118
+ "finney": "https://x.taostats.io",
119
+ },
113
120
  }
114
121
 
115
122
  # --- Type Registry ---
@@ -174,6 +174,8 @@ custom_rpc_type_registry = {
174
174
  ["max_burn", "Compact<u64>"],
175
175
  ["bonds_moving_avg", "Compact<u64>"],
176
176
  ["max_regs_per_block", "Compact<u16>"],
177
+ ["serving_rate_limit", "Compact<u64>"],
178
+ ["max_validators", "Compact<u16>"],
177
179
  ],
178
180
  },
179
181
  }
@@ -963,6 +965,8 @@ class SubnetHyperparameters:
963
965
  max_burn: int
964
966
  bonds_moving_avg: int
965
967
  max_regs_per_block: int
968
+ serving_rate_limit: int
969
+ max_validators: int
966
970
 
967
971
  @classmethod
968
972
  def from_vec_u8(cls, vec_u8: List[int]) -> Optional["SubnetHyperparameters"]:
@@ -1013,6 +1017,8 @@ class SubnetHyperparameters:
1013
1017
  max_burn=decoded["max_burn"],
1014
1018
  bonds_moving_avg=decoded["bonds_moving_avg"],
1015
1019
  max_regs_per_block=decoded["max_regs_per_block"],
1020
+ max_validators=decoded["max_validators"],
1021
+ serving_rate_limit=decoded["serving_rate_limit"],
1016
1022
  )
1017
1023
 
1018
1024
  def to_parameter_dict(self) -> "torch.nn.ParameterDict":
@@ -249,7 +249,6 @@ HYPERPARAMS = {
249
249
  "immunity_period": "sudo_set_immunity_period",
250
250
  "min_allowed_weights": "sudo_set_min_allowed_weights",
251
251
  "activity_cutoff": "sudo_set_activity_cutoff",
252
- "max_validators": "sudo_set_max_allowed_validators",
253
252
  }
254
253
 
255
254
 
@@ -558,7 +558,7 @@ class OverviewCommand:
558
558
  result: List["bittensor.NeuronInfoLite"] = []
559
559
 
560
560
  try:
561
- subtensor = bittensor.subtensor(config=subtensor_config)
561
+ subtensor = bittensor.subtensor(config=subtensor_config, log_verbose=False)
562
562
 
563
563
  all_neurons: List["bittensor.NeuronInfoLite"] = subtensor.neurons_lite(
564
564
  netuid=netuid
@@ -587,7 +587,7 @@ class OverviewCommand:
587
587
  result: List[Tuple[str, "bittensor.Balance"]] = []
588
588
 
589
589
  try:
590
- subtensor = bittensor.subtensor(config=subtensor_config)
590
+ subtensor = bittensor.subtensor(config=subtensor_config, log_verbose=False)
591
591
 
592
592
  # Pull all stake for our coldkey
593
593
  all_stake_info_for_coldkey = subtensor.get_stake_info_for_coldkey(
@@ -375,7 +375,7 @@ class StakeShow:
375
375
  Returns:
376
376
  A dictionary mapping SS58 addresses to their respective stake account details.
377
377
  """
378
- subtensor = bittensor.subtensor(config=cli.config)
378
+ subtensor = bittensor.subtensor(config=cli.config, log_verbose=False)
379
379
 
380
380
  wallet_stake_accounts = {}
381
381
 
@@ -159,7 +159,7 @@ def set_hyperparameter_extrinsic(
159
159
  ):
160
160
  with subtensor.substrate as substrate:
161
161
  extrinsic_params = substrate.get_metadata_call_function(
162
- "SubtensorModule", extrinsic
162
+ "AdminUtils", extrinsic
163
163
  )
164
164
  value_argument = extrinsic_params["fields"][
165
165
  len(extrinsic_params["fields"]) - 1
@@ -167,7 +167,7 @@ def set_hyperparameter_extrinsic(
167
167
 
168
168
  # create extrinsic call
169
169
  call = substrate.compose_call(
170
- call_module="SubtensorModule",
170
+ call_module="AdminUtils",
171
171
  call_function=extrinsic,
172
172
  call_params={"netuid": netuid, str(value_argument["name"]): value},
173
173
  )
@@ -129,12 +129,19 @@ def transfer_extrinsic(
129
129
  "[green]Block Hash: {}[/green]".format(block_hash)
130
130
  )
131
131
 
132
- explorer_url = bittensor.utils.get_explorer_url_for_network(
132
+ explorer_urls = bittensor.utils.get_explorer_url_for_network(
133
133
  subtensor.network, block_hash, bittensor.__network_explorer_map__
134
134
  )
135
- if explorer_url is not None:
135
+ if explorer_urls != {}:
136
136
  bittensor.__console__.print(
137
- "[green]Explorer Link: {}[/green]".format(explorer_url)
137
+ "[green]Opentensor Explorer Link: {}[/green]".format(
138
+ explorer_urls.get("opentensor")
139
+ )
140
+ )
141
+ bittensor.__console__.print(
142
+ "[green]Taostats Explorer Link: {}[/green]".format(
143
+ explorer_urls.get("taostats")
144
+ )
138
145
  )
139
146
  else:
140
147
  bittensor.__console__.print(
@@ -109,8 +109,8 @@ class subtensor:
109
109
  investments.
110
110
 
111
111
  Attributes:
112
- network (str): The name of the Bittensor network (e.g., 'finney', 'local') the instance is
113
- connected to, determining the blockchain interaction context.
112
+ network (str): The name of the Bittensor network (e.g., 'finney', 'test', 'archive', 'local') the instance
113
+ is connected to, determining the blockchain interaction context.
114
114
  chain_endpoint (str): The blockchain node endpoint URL, enabling direct communication
115
115
  with the Bittensor blockchain for transaction processing and data retrieval.
116
116
 
@@ -154,18 +154,20 @@ class subtensor:
154
154
  def add_args(cls, parser: argparse.ArgumentParser, prefix: str = None):
155
155
  prefix_str = "" if prefix == None else prefix + "."
156
156
  try:
157
- default_network = os.getenv("BT_SUBTENSOR_NETWORK") or "local"
157
+ default_network = os.getenv("BT_SUBTENSOR_NETWORK") or "finney"
158
158
  default_chain_endpoint = (
159
159
  os.getenv("BT_SUBTENSOR_CHAIN_ENDPOINT")
160
- or bittensor.__local_entrypoint__
160
+ or bittensor.__finney_entrypoint__
161
161
  )
162
162
  parser.add_argument(
163
163
  "--" + prefix_str + "subtensor.network",
164
164
  default=default_network,
165
165
  type=str,
166
166
  help="""The subtensor network flag. The likely choices are:
167
- -- local (local running network)
168
167
  -- finney (main network)
168
+ -- test (test network)
169
+ -- archive (archive network +300 blocks)
170
+ -- local (local running network)
169
171
  If this option is set it overloads subtensor.chain_endpoint with
170
172
  an entry point node from that network.
171
173
  """,
@@ -195,6 +197,7 @@ class subtensor:
195
197
  Args:
196
198
  network (str): The network flag. The likely choices are:
197
199
  -- finney (main network)
200
+ -- archive (archive network +300 blocks)
198
201
  -- local (local running network)
199
202
  -- test (test network)
200
203
  chain_endpoint (str): The chain endpoint flag. If set, overrides the network argument.
@@ -295,10 +298,18 @@ class subtensor:
295
298
  network: str = None,
296
299
  config: "bittensor.config" = None,
297
300
  _mock: bool = False,
301
+ log_verbose: bool = True,
298
302
  ) -> None:
299
303
  """
300
304
  Initializes a Subtensor interface for interacting with the Bittensor blockchain.
301
305
 
306
+ NOTE: Currently subtensor defaults to the finney network. This will change in a future release.
307
+
308
+ We strongly encourage users to run their own local subtensor node whenever possible. This increases
309
+ decentralization and resilience of the network. In a future release, local subtensor will become the
310
+ default and the fallback to finney removed. Please plan ahead for this change. We will provide detailed
311
+ instructions on how to run a local subtensor node in the documentation in a subsequent release.
312
+
302
313
  Args:
303
314
  network (str, optional): The network name to connect to (e.g., 'finney', 'local').
304
315
  Defaults to the main Bittensor network if not specified.
@@ -320,6 +331,22 @@ class subtensor:
320
331
  # Setup config.subtensor.network and config.subtensor.chain_endpoint
321
332
  self.chain_endpoint, self.network = subtensor.setup_config(network, config)
322
333
 
334
+ if (
335
+ self.network == "finney"
336
+ or self.chain_endpoint == bittensor.__finney_entrypoint__
337
+ ) and log_verbose:
338
+ bittensor.logging.info(
339
+ f"You are connecting to {self.network} network with endpoint {self.chain_endpoint}."
340
+ )
341
+ bittensor.logging.warning(
342
+ "We strongly encourage running a local subtensor node whenever possible. "
343
+ "This increases decentralization and resilience of the network."
344
+ )
345
+ bittensor.logging.warning(
346
+ "In a future release, local subtensor will become the default endpoint. "
347
+ "To get ahead of this change, please run a local subtensor node and point to it."
348
+ )
349
+
323
350
  # Returns a mocked connection with a background chain connection.
324
351
  self.config.subtensor._mock = (
325
352
  _mock
@@ -330,12 +357,32 @@ class subtensor:
330
357
  config.subtensor._mock = True
331
358
  return bittensor.subtensor_mock.MockSubtensor()
332
359
 
333
- # Set up params.
334
- self.substrate = SubstrateInterface(
335
- ss58_format=bittensor.__ss58_format__,
336
- use_remote_preset=True,
337
- url=self.chain_endpoint,
338
- type_registry=bittensor.__type_registry__,
360
+ # Attempt to connect to chosen endpoint. Fallback to finney if local unavailable.
361
+ try:
362
+ # Set up params.
363
+ self.substrate = SubstrateInterface(
364
+ ss58_format=bittensor.__ss58_format__,
365
+ use_remote_preset=True,
366
+ url=self.chain_endpoint,
367
+ type_registry=bittensor.__type_registry__,
368
+ )
369
+ except ConnectionRefusedError as e:
370
+ bittensor.logging.error(
371
+ f"Could not connect to {self.network} network with {self.chain_endpoint} chain endpoint. Exiting..."
372
+ )
373
+ bittensor.logging.info(
374
+ f"You can check if you have connectivity by runing this command: nc -vz localhost {self.chain_endpoint.split(':')[2]}"
375
+ )
376
+ exit(1)
377
+ # TODO (edu/phil): Advise to run local subtensor and point to dev docs.
378
+
379
+ try:
380
+ self.substrate.websocket.settimeout(600)
381
+ except:
382
+ bittensor.logging.warning("Could not set websocket timeout.")
383
+
384
+ bittensor.logging.info(
385
+ f"Connected to {self.network} network and {self.chain_endpoint}."
339
386
  )
340
387
 
341
388
  def __str__(self) -> str:
@@ -123,8 +123,8 @@ def strtobool(val: str) -> Union[bool, Literal["==SUPRESS=="]]:
123
123
 
124
124
 
125
125
  def get_explorer_root_url_by_network_from_map(
126
- network: str, network_map: Dict[str, str]
127
- ) -> Optional[str]:
126
+ network: str, network_map: Dict[str, Dict[str, str]]
127
+ ) -> Optional[Dict[str, str]]:
128
128
  r"""
129
129
  Returns the explorer root url for the given network name from the given network map.
130
130
 
@@ -136,42 +136,48 @@ def get_explorer_root_url_by_network_from_map(
136
136
  The explorer url for the given network.
137
137
  Or None if the network is not in the network map.
138
138
  """
139
- explorer_url: Optional[str] = None
140
- if network in network_map:
141
- explorer_url = network_map[network]
139
+ explorer_urls: Optional[Dict[str, str]] = {}
140
+ for entity_nm, entity_network_map in network_map.items():
141
+ if network in entity_network_map:
142
+ explorer_urls[entity_nm] = entity_network_map[network]
142
143
 
143
- return explorer_url
144
+ return explorer_urls
144
145
 
145
146
 
146
147
  def get_explorer_url_for_network(
147
148
  network: str, block_hash: str, network_map: Dict[str, str]
148
- ) -> Optional[str]:
149
+ ) -> Optional[List[str]]:
149
150
  r"""
150
151
  Returns the explorer url for the given block hash and network.
151
152
 
152
153
  Args:
153
154
  network(str): The network to get the explorer url for.
154
155
  block_hash(str): The block hash to get the explorer url for.
155
- network_map(Dict[str, str]): The network map to get the explorer url from.
156
+ network_map(Dict[str, Dict[str, str]]): The network maps to get the explorer urls from.
156
157
 
157
158
  Returns:
158
159
  The explorer url for the given block hash and network.
159
160
  Or None if the network is not known.
160
161
  """
161
162
 
162
- explorer_url: Optional[str] = None
163
+ explorer_urls: Optional[Dict[str, str]] = {}
163
164
  # Will be None if the network is not known. i.e. not in network_map
164
- explorer_root_url: Optional[str] = get_explorer_root_url_by_network_from_map(
165
- network, network_map
166
- )
165
+ explorer_root_urls: Optional[
166
+ Dict[str, str]
167
+ ] = get_explorer_root_url_by_network_from_map(network, network_map)
167
168
 
168
- if explorer_root_url is not None:
169
+ if explorer_root_urls != {}:
169
170
  # We are on a known network.
170
- explorer_url = "{root_url}/query/{block_hash}".format(
171
- root_url=explorer_root_url, block_hash=block_hash
171
+ explorer_opentensor_url = "{root_url}/query/{block_hash}".format(
172
+ root_url=explorer_root_urls.get("opentensor"), block_hash=block_hash
173
+ )
174
+ explorer_taostats_url = "{root_url}/search?query={block_hash}".format(
175
+ root_url=explorer_root_urls.get("taostats"), block_hash=block_hash
172
176
  )
177
+ explorer_urls["opentensor"] = explorer_opentensor_url
178
+ explorer_urls["taostats"] = explorer_taostats_url
173
179
 
174
- return explorer_url
180
+ return explorer_urls
175
181
 
176
182
 
177
183
  def ss58_address_to_bytes(ss58_address: str) -> bytes:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bittensor
3
- Version: 6.4.0
3
+ Version: 6.4.2
4
4
  Summary: bittensor
5
5
  Home-page: https://github.com/opentensor/bittensor
6
6
  Author: bittensor.com
@@ -228,7 +228,7 @@ positional arguments:
228
228
  lock_cost Return the lock cost to register a subnet.
229
229
  create Create a new bittensor subnetwork on this chain.
230
230
  register Register a wallet to a network.
231
- register Register a wallet to a network using PoW.
231
+ pow_register Register a wallet to a network using PoW.
232
232
  hyperparameters View subnet hyperparameters.
233
233
 
234
234
  options:
@@ -309,28 +309,28 @@ Axon: Serves Synapse protocols with custom blacklist, priority and verify functi
309
309
  ```python
310
310
  import bittensor
311
311
 
312
- class MySyanpse( bittensor.Synapse ):
312
+ class MySynapse( bittensor.Synapse ):
313
313
  input: int = 1
314
314
  output: int = None
315
315
 
316
316
  # Define a custom request forwarding function
317
- def forward( synapse: MySyanpse ) -> MySyanpse:
317
+ def forward( synapse: MySynapse ) -> MySynapse:
318
318
  # Apply custom logic to synapse and return it
319
319
  synapse.output = 2
320
320
  return synapse
321
321
 
322
322
  # Define a custom request verification function
323
- def verify_my_synapse( synapse: MySyanpse ):
323
+ def verify_my_synapse( synapse: MySynapse ):
324
324
  # Apply custom verification logic to synapse
325
325
  # Optionally raise Exception
326
326
 
327
327
  # Define a custom request blacklist function
328
- def blacklist_my_synapse( synapse: MySyanpse ) -> bool:
328
+ def blacklist_my_synapse( synapse: MySynapse ) -> bool:
329
329
  # Apply custom blacklist
330
330
  # return False ( if non blacklisted ) or True ( if blacklisted )
331
331
 
332
332
  # Define a custom request priority function
333
- def prioritize_my_synape( synapse: MySyanpse ) -> float:
333
+ def prioritize_my_synape( synapse: MySynapse ) -> float:
334
334
  # Apply custom priority
335
335
  return 1.0
336
336
 
@@ -348,6 +348,7 @@ my_axon.attach(
348
348
 
349
349
  Dendrite: Inheriting from PyTorch's Module class, represents the abstracted implementation of a network client module designed
350
350
  to send requests to those endpoints to receive inputs.
351
+
351
352
  Example:
352
353
  ```python
353
354
  dendrite_obj = dendrite( wallet = bittensor.wallet() )
@@ -367,7 +368,7 @@ Use the `root` subcommand to access setting weights on the network across subnet
367
368
  ```bash
368
369
  btcli root weights --wallet.name <coldname> --wallet.hotkey <hotname>
369
370
  Enter netuids (e.g. 0, 1, 2 ...):
370
- # Here enter your selected netuids to wet weights on
371
+ # Here enter your selected netuids to set weights on
371
372
  1, 2
372
373
 
373
374
  >Enter weights (e.g. 0.09, 0.09, 0.09 ...):
@@ -587,25 +587,10 @@ class TestSubtensor(unittest.TestCase):
587
587
  msg="only tries to submit once, then exits",
588
588
  )
589
589
 
590
- @staticmethod
591
- def is_port_open(host, port):
592
- """Check if a port is open on a given host."""
593
- with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
594
- return s.connect_ex((host, port)) == 0
595
-
596
- def test_defaults_to_local(self):
597
- port = int(
598
- bittensor.__local_entrypoint__.split(":")[-1]
599
- ) # Default port for local subtensor
600
- if self.is_port_open("127.0.0.1", port):
601
- # If service is running, check default values
602
- sub = bittensor.subtensor()
603
- self.assertEqual(sub.network, "local")
604
- self.assertEqual(sub.chain_endpoint, bittensor.__local_entrypoint__)
605
- else:
606
- # If service is not running, expect a ConnectionRefusedError
607
- with self.assertRaises(ConnectionRefusedError):
608
- bittensor.subtensor()
590
+ def test_defaults_to_finney(self):
591
+ sub = bittensor.subtensor()
592
+ assert sub.network == "finney"
593
+ assert sub.chain_endpoint == bittensor.__finney_entrypoint__
609
594
 
610
595
 
611
596
  if __name__ == "__main__":
@@ -700,63 +700,71 @@ class TestCUDASolverRun(unittest.TestCase):
700
700
 
701
701
  @ddt
702
702
  class TestExplorerURL(unittest.TestCase):
703
- network_map: Dict[str, str] = {
704
- "nakamoto": "https://polkadot.js.org/apps/?rpc=wss://archivelb.nakamoto.opentensor.ai:9943#/explorer",
705
- "example": "https://polkadot.js.org/apps/?rpc=wss://example.example.com#/explorer",
706
- "nobunaga": "https://polkadot.js.org/apps/?rpc=wss://nobunaga.bittensor.com:9943#/explorer",
707
- # "bad": None # no explorer for this network
708
- }
709
-
710
703
  @data(
711
704
  (
712
- "nobunaga",
713
- "https://polkadot.js.org/apps/?rpc=wss://nobunaga.bittensor.com:9943#/explorer",
705
+ "local",
706
+ {
707
+ "opentensor": "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fentrypoint-finney.opentensor.ai%3A443#/explorer",
708
+ "taostats": "https://x.taostats.io",
709
+ },
714
710
  ),
715
711
  (
716
- "nakamoto",
717
- "https://polkadot.js.org/apps/?rpc=wss://archivelb.nakamoto.opentensor.ai:9943#/explorer",
712
+ "endpoint",
713
+ {
714
+ "opentensor": "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fentrypoint-finney.opentensor.ai%3A443#/explorer",
715
+ "taostats": "https://x.taostats.io",
716
+ },
718
717
  ),
719
718
  (
720
- "example",
721
- "https://polkadot.js.org/apps/?rpc=wss://example.example.com#/explorer",
719
+ "finney",
720
+ {
721
+ "opentensor": "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fentrypoint-finney.opentensor.ai%3A443#/explorer",
722
+ "taostats": "https://x.taostats.io",
723
+ },
722
724
  ),
723
- ("bad", None),
724
- ("", None),
725
- ("networknamewithoutexplorer", None),
725
+ ("bad", {}),
726
+ ("", {}),
727
+ ("unknown", {}),
726
728
  )
727
729
  @unpack
728
730
  def test_get_explorer_root_url_by_network_from_map(
729
- self, network: str, expected: str
730
- ) -> str:
731
+ self, network: str, expected: dict
732
+ ) -> None:
731
733
  self.assertEqual(
732
734
  bittensor.utils.get_explorer_root_url_by_network_from_map(
733
- network, self.network_map
735
+ network, bittensor.__network_explorer_map__
734
736
  ),
735
737
  expected,
736
738
  )
737
739
 
738
740
  @data(
739
741
  (
740
- "nobunaga",
742
+ "local",
741
743
  "0x123",
742
- "https://polkadot.js.org/apps/?rpc=wss://nobunaga.bittensor.com:9943#/explorer/query/0x123",
744
+ {
745
+ "opentensor": "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fentrypoint-finney.opentensor.ai%3A443#/explorer/query/0x123",
746
+ "taostats": "https://x.taostats.io/search?query=0x123",
747
+ },
743
748
  ),
744
749
  (
745
- "example",
746
- "0x123",
747
- "https://polkadot.js.org/apps/?rpc=wss://example.example.com#/explorer/query/0x123",
750
+ "endpoint",
751
+ "0x456",
752
+ {
753
+ "opentensor": "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fentrypoint-finney.opentensor.ai%3A443#/explorer/query/0x456",
754
+ "taostats": "https://x.taostats.io/search?query=0x456",
755
+ },
748
756
  ),
749
- ("bad", "0x123", None),
750
- ("", "0x123", None),
751
- ("networknamewithoutexplorer", "0x123", None),
757
+ ("bad", "0x789", {}),
758
+ ("", "0xabc", {}),
759
+ ("unknown", "0xdef", {}),
752
760
  )
753
761
  @unpack
754
762
  def test_get_explorer_url_for_network_by_network_and_block_hash(
755
- self, network: str, block_hash: str, expected: str
756
- ) -> str:
763
+ self, network: str, block_hash: str, expected: dict
764
+ ) -> None:
757
765
  self.assertEqual(
758
766
  bittensor.utils.get_explorer_url_for_network(
759
- network, block_hash, self.network_map
767
+ network, block_hash, bittensor.__network_explorer_map__
760
768
  ),
761
769
  expected,
762
770
  )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes