bittensor 10.3.1__tar.gz → 10.3.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 (148) hide show
  1. {bittensor-10.3.1 → bittensor-10.3.2}/PKG-INFO +2 -2
  2. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/async_subtensor.py +13 -2
  3. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/axon.py +15 -5
  4. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/config.py +4 -8
  5. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/errors.py +53 -0
  6. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/coldkey_swap.py +7 -0
  7. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/sudo.py +8 -1
  8. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/settings.py +10 -0
  9. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/subtensor.py +5 -2
  10. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/btlogging/loggingmachine.py +3 -1
  11. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor.egg-info/PKG-INFO +2 -2
  12. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor.egg-info/requires.txt +1 -1
  13. {bittensor-10.3.1 → bittensor-10.3.2}/pyproject.toml +2 -2
  14. {bittensor-10.3.1 → bittensor-10.3.2}/LICENSE +0 -0
  15. {bittensor-10.3.1 → bittensor-10.3.2}/README.md +0 -0
  16. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/__init__.py +0 -0
  17. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/__main__.py +0 -0
  18. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/__init__.py +0 -0
  19. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/__init__.py +0 -0
  20. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/axon_info.py +0 -0
  21. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/chain_identity.py +0 -0
  22. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/coldkey_swap.py +0 -0
  23. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/crowdloan_info.py +0 -0
  24. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/delegate_info.py +0 -0
  25. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/delegate_info_lite.py +0 -0
  26. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/dynamic_info.py +0 -0
  27. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/info_base.py +0 -0
  28. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/ip_info.py +0 -0
  29. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/metagraph_info.py +0 -0
  30. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/neuron_info.py +0 -0
  31. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/neuron_info_lite.py +0 -0
  32. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/prometheus_info.py +0 -0
  33. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/proposal_vote_data.py +0 -0
  34. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/proxy.py +0 -0
  35. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/root_claim.py +0 -0
  36. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/scheduled_coldkey_swap_info.py +0 -0
  37. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/sim_swap.py +0 -0
  38. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/stake_info.py +0 -0
  39. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/subnet_hyperparameters.py +0 -0
  40. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/subnet_identity.py +0 -0
  41. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/subnet_info.py +0 -0
  42. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/subnet_state.py +0 -0
  43. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/utils.py +0 -0
  44. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/chain_data/weight_commit_info.py +0 -0
  45. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/dendrite.py +0 -0
  46. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/__init__.py +0 -0
  47. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/__init__.py +0 -0
  48. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/children.py +0 -0
  49. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/crowdloan.py +0 -0
  50. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/liquidity.py +0 -0
  51. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/mev_shield.py +0 -0
  52. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/move_stake.py +0 -0
  53. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/proxy.py +0 -0
  54. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/registration.py +0 -0
  55. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/root.py +0 -0
  56. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/serving.py +0 -0
  57. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/staking.py +0 -0
  58. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/start_call.py +0 -0
  59. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/take.py +0 -0
  60. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/transfer.py +0 -0
  61. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/unstaking.py +0 -0
  62. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/utils.py +0 -0
  63. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/asyncex/weights.py +0 -0
  64. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/children.py +0 -0
  65. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/coldkey_swap.py +0 -0
  66. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/crowdloan.py +0 -0
  67. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/liquidity.py +0 -0
  68. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/mev_shield.py +0 -0
  69. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/move_stake.py +0 -0
  70. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/pallets/__init__.py +0 -0
  71. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/pallets/admin_utils.py +0 -0
  72. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/pallets/balances.py +0 -0
  73. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/pallets/base.py +0 -0
  74. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/pallets/commitments.py +0 -0
  75. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/pallets/crowdloan.py +0 -0
  76. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/pallets/mev_shield.py +0 -0
  77. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/pallets/proxy.py +0 -0
  78. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/pallets/subtensor_module.py +0 -0
  79. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/pallets/sudo.py +0 -0
  80. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/pallets/swap.py +0 -0
  81. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/proxy.py +0 -0
  82. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/registration.py +0 -0
  83. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/root.py +0 -0
  84. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/serving.py +0 -0
  85. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/staking.py +0 -0
  86. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/start_call.py +0 -0
  87. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/sudo.py +0 -0
  88. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/take.py +0 -0
  89. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/transfer.py +0 -0
  90. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/unstaking.py +0 -0
  91. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/utils.py +0 -0
  92. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/extrinsics/weights.py +0 -0
  93. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/metagraph.py +0 -0
  94. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/stream.py +0 -0
  95. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/synapse.py +0 -0
  96. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/tensor.py +0 -0
  97. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/threadpool.py +0 -0
  98. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/core/types.py +0 -0
  99. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/__init__.py +0 -0
  100. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/dev_framework/__init__.py +0 -0
  101. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/dev_framework/calls/__init__.py +0 -0
  102. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/dev_framework/calls/non_sudo_calls.py +0 -0
  103. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/dev_framework/calls/pallets.py +0 -0
  104. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/dev_framework/calls/sudo_calls.py +0 -0
  105. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/dev_framework/subnet.py +0 -0
  106. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/dev_framework/utils.py +0 -0
  107. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/__init__.py +0 -0
  108. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/chain.py +0 -0
  109. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/commitments.py +0 -0
  110. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/crowdloans.py +0 -0
  111. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/delegates.py +0 -0
  112. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/extrinsics.py +0 -0
  113. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/metagraphs.py +0 -0
  114. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/mev_shield.py +0 -0
  115. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/neurons.py +0 -0
  116. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/proxy.py +0 -0
  117. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/queries.py +0 -0
  118. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/staking.py +0 -0
  119. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/subnets.py +0 -0
  120. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/utils.py +0 -0
  121. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/subtensor_api/wallets.py +0 -0
  122. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/extras/timelock.py +0 -0
  123. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/py.typed +0 -0
  124. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/__init__.py +0 -0
  125. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/axon_utils.py +0 -0
  126. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/balance.py +0 -0
  127. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/btlogging/__init__.py +0 -0
  128. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/btlogging/console.py +0 -0
  129. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/btlogging/defines.py +0 -0
  130. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/btlogging/format.py +0 -0
  131. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/btlogging/helpers.py +0 -0
  132. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/btlogging/levels.py +0 -0
  133. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/certifi.sh +0 -0
  134. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/easy_imports.py +0 -0
  135. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/formatting.py +0 -0
  136. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/liquidity.py +0 -0
  137. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/mock/__init__.py +0 -0
  138. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/mock/subtensor_mock.py +0 -0
  139. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/networking.py +0 -0
  140. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/registration/__init__.py +0 -0
  141. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/registration/torch_utils.py +0 -0
  142. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/subnets.py +0 -0
  143. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/version.py +0 -0
  144. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor/utils/weight_utils.py +0 -0
  145. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor.egg-info/SOURCES.txt +0 -0
  146. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor.egg-info/dependency_links.txt +0 -0
  147. {bittensor-10.3.1 → bittensor-10.3.2}/bittensor.egg-info/top_level.txt +0 -0
  148. {bittensor-10.3.1 → bittensor-10.3.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bittensor
3
- Version: 10.3.1
3
+ Version: 10.3.2
4
4
  Summary: Bittensor SDK
5
5
  Author: bittensor.com
6
6
  License: The MIT License (MIT)
@@ -45,7 +45,7 @@ Requires-Dist: cyscale<1.0.0,>=0.3.3
45
45
  Requires-Dist: uvicorn
46
46
  Requires-Dist: bittensor-drand<2.0.0,>=1.3.0
47
47
  Requires-Dist: bittensor-wallet==4.0.1
48
- Requires-Dist: async-substrate-interface<3.0.0,>=2.0.3
48
+ Requires-Dist: async-substrate-interface<3.0.0,>=2.0.4
49
49
  Provides-Extra: dev
50
50
  Requires-Dist: pytest==9.0.3; extra == "dev"
51
51
  Requires-Dist: pytest-asyncio==1.3.0; extra == "dev"
@@ -48,7 +48,11 @@ from bittensor.core.chain_data.utils import (
48
48
  decode_revealed_commitment_with_hotkey,
49
49
  )
50
50
  from bittensor.core.config import Config
51
- from bittensor.core.errors import ChainError, SubstrateRequestException
51
+ from bittensor.core.errors import (
52
+ ChainError,
53
+ SubstrateRequestException,
54
+ chain_error_from_substrate_exception,
55
+ )
52
56
  from bittensor.core.extrinsics.asyncex.children import (
53
57
  root_set_pending_childkey_cooldown_extrinsic,
54
58
  set_children_extrinsic,
@@ -6145,8 +6149,15 @@ class AsyncSubtensor(SubtensorMixin):
6145
6149
  return extrinsic_response
6146
6150
 
6147
6151
  except SubstrateRequestException as error:
6152
+ # The extrinsic was rejected before inclusion (pool validation, dropped,
6153
+ # invalid, etc.), so the nonce was not consumed on-chain. Clear the cached
6154
+ # next-index so the next call refetches the true on-chain value.
6155
+ self.substrate.clear_nonce_cache_for_account(signing_keypair.ss58_address)
6156
+ typed = chain_error_from_substrate_exception(error)
6157
+ if typed is not None:
6158
+ error = typed
6148
6159
  if raise_error:
6149
- raise
6160
+ raise error from None
6150
6161
 
6151
6162
  extrinsic_response.success = False
6152
6163
  extrinsic_response.message = format_error_message(error)
@@ -15,6 +15,7 @@ from inspect import signature, Signature, Parameter
15
15
  from typing import Any, Awaitable, Callable, Optional, Tuple
16
16
 
17
17
  from async_substrate_interface.utils import json
18
+ from pydantic import ValidationError
18
19
  import uvicorn
19
20
  from bittensor_wallet import Wallet, Keypair
20
21
  from fastapi import APIRouter, Depends, FastAPI
@@ -1233,13 +1234,17 @@ class AxonMiddleware(BaseHTTPMiddleware):
1233
1234
  This method sets the foundation for the subsequent steps in the request handling process,
1234
1235
  ensuring that all necessary information is encapsulated within the Synapse object.
1235
1236
  """
1236
- # Extracts the request name from the URL path.
1237
+ # Extracts the request name from the URL path. `split("/")[1]` can
1238
+ # only realistically fail with `IndexError` (empty path) or
1239
+ # `AttributeError` (malformed/mocked request without a `url`); a bare
1240
+ # `except Exception` here would swallow `MemoryError`, real bugs from
1241
+ # `starlette`, etc., and relabel them as malformed-request errors.
1237
1242
  try:
1238
1243
  request_name = request.url.path.split("/")[1]
1239
- except Exception:
1244
+ except (IndexError, AttributeError) as e:
1240
1245
  raise InvalidRequestNameError(
1241
1246
  f"Improperly formatted request. Could not parser request {request.url.path}."
1242
- )
1247
+ ) from e
1243
1248
 
1244
1249
  # Creates a synapse instance from the headers using the appropriate forward class type
1245
1250
  # based on the request name obtained from the URL path.
@@ -1249,12 +1254,17 @@ class AxonMiddleware(BaseHTTPMiddleware):
1249
1254
  f"Synapse name '{request_name}' not found. Available synapses {list(self.axon.forward_class_types.keys())}"
1250
1255
  )
1251
1256
 
1257
+ # `from_headers` constructs a pydantic model from header inputs; the
1258
+ # realistic failure modes are `ValidationError` (field-level),
1259
+ # `TypeError` (bad kwarg types), and `ValueError` (custom validators).
1260
+ # Narrowing keeps unrelated infrastructure failures visible instead of
1261
+ # relabeling them as malformed-request errors.
1252
1262
  try:
1253
1263
  synapse = request_synapse.from_headers(request.headers) # type: ignore
1254
- except Exception:
1264
+ except (ValidationError, TypeError, ValueError) as e:
1255
1265
  raise SynapseParsingError(
1256
1266
  f"Improperly formatted request. Could not parse headers {request.headers} into synapse of type {request_name}."
1257
- )
1267
+ ) from e
1258
1268
  synapse.name = request_name
1259
1269
 
1260
1270
  # Fills the local axon information into the synapse.
@@ -21,9 +21,11 @@ import os
21
21
  import sys
22
22
  from copy import deepcopy
23
23
  from typing import Any, Optional
24
- from bittensor.core.settings import DEFAULTS
24
+
25
25
  import yaml
26
26
 
27
+ from bittensor.core.settings import DEFAULTS, no_parse_cli
28
+
27
29
 
28
30
  class DefaultMunch(dict):
29
31
  """
@@ -130,12 +132,6 @@ class Config(DefaultMunch):
130
132
  strict: bool = False,
131
133
  default: Any = DEFAULTS,
132
134
  ) -> None:
133
- no_parse_cli = os.getenv("BT_NO_PARSE_CLI_ARGS", "").lower() in (
134
- "1",
135
- "true",
136
- "yes",
137
- "on",
138
- )
139
135
 
140
136
  # Fallback to defaults if not provided
141
137
  default = deepcopy(default or DEFAULTS)
@@ -153,7 +149,7 @@ class Config(DefaultMunch):
153
149
  self.__is_set = {}
154
150
 
155
151
  # If CLI parsing disabled, stop here
156
- if no_parse_cli or parser is None:
152
+ if no_parse_cli() or parser is None:
157
153
  return
158
154
 
159
155
  self._add_default_arguments(parser)
@@ -1,3 +1,4 @@
1
+ import ast
1
2
  from typing import Optional, TYPE_CHECKING
2
3
 
3
4
  from async_substrate_interface.errors import (
@@ -58,6 +59,7 @@ __all__ = [
58
59
  "UnknownSynapseError",
59
60
  "UnstakeError",
60
61
  "SHIELD_VALIDATION_ERRORS",
62
+ "chain_error_from_substrate_exception",
61
63
  "map_shield_error",
62
64
  ]
63
65
 
@@ -278,6 +280,57 @@ SHIELD_VALIDATION_ERRORS = {
278
280
  }
279
281
 
280
282
 
283
+ _CUSTOM_ERROR_CODE_TO_EXCEPTION: dict[int, type["ChainError"]] = {
284
+ 3: SubnetNotExists,
285
+ 4: HotKeyAccountNotExists,
286
+ 6: TxRateLimitExceeded,
287
+ 25: NonAssociatedColdKey,
288
+ }
289
+
290
+
291
+ def _extract_custom_error_code(error: Exception) -> Optional[int]:
292
+ """Walk a SubstrateRequestException's args looking for a transaction-pool
293
+ validity error like ``{'error': {'code': 1010, ..., 'data': 'Custom error: N'}}``
294
+ and return ``N``. Returns ``None`` if the shape doesn't match."""
295
+ for arg in getattr(error, "args", ()):
296
+ parsed = arg
297
+ if isinstance(parsed, str):
298
+ try:
299
+ parsed = ast.literal_eval(parsed)
300
+ except (ValueError, SyntaxError, MemoryError, RecursionError, TypeError):
301
+ continue
302
+ if not isinstance(parsed, dict):
303
+ continue
304
+ inner = parsed.get("error", parsed)
305
+ if not isinstance(inner, dict):
306
+ continue
307
+ data = inner.get("data")
308
+ if isinstance(data, str) and data.startswith("Custom error:"):
309
+ try:
310
+ return int(data.split(":", 1)[1].strip())
311
+ except ValueError:
312
+ continue
313
+ return None
314
+
315
+
316
+ def chain_error_from_substrate_exception(
317
+ error: SubstrateRequestException,
318
+ ) -> Optional["ChainError"]:
319
+ """Translate a transaction-pool validation error into a typed
320
+ :class:`ChainError`. Returns ``None`` when the exception doesn't carry a
321
+ recognised ``Custom error: N`` code from subtensor's
322
+ ``CustomTransactionError`` enum, so callers can keep the original."""
323
+ if isinstance(error, ChainError):
324
+ return None
325
+ code = _extract_custom_error_code(error)
326
+ if code is None:
327
+ return None
328
+ exc_cls = _CUSTOM_ERROR_CODE_TO_EXCEPTION.get(code)
329
+ if exc_cls is None:
330
+ return None
331
+ return exc_cls(*error.args)
332
+
333
+
281
334
  def map_shield_error(raw_message: str) -> str:
282
335
  """Map a raw shield validation error to a human-readable description.
283
336
 
@@ -392,6 +392,13 @@ async def swap_coldkey_announced_extrinsic(
392
392
  )
393
393
 
394
394
  if response.success:
395
+ # The swap may reap the old coldkey's account on chain (resetting its
396
+ # nonce). Drop the in-process nonce cache entry so the next extrinsic
397
+ # signed by this ss58 re-fetches from the chain instead of incrementing
398
+ # a stale value.
399
+ subtensor.substrate.clear_nonce_cache_for_account(
400
+ wallet.coldkeypub.ss58_address
401
+ )
395
402
  logging.debug("[green]Coldkey swap executed successfully.[/green]")
396
403
  else:
397
404
  logging.error(f"[red]{response.message}[/red]")
@@ -93,7 +93,7 @@ async def swap_coldkey_extrinsic(
93
93
  Notes:
94
94
  - This function can only called by root.
95
95
  """
96
- return await sudo_call_extrinsic(
96
+ response = await sudo_call_extrinsic(
97
97
  subtensor=subtensor,
98
98
  wallet=wallet,
99
99
  call_module="SubtensorModule",
@@ -108,6 +108,13 @@ async def swap_coldkey_extrinsic(
108
108
  wait_for_inclusion=wait_for_inclusion,
109
109
  wait_for_finalization=wait_for_finalization,
110
110
  )
111
+ if response.success:
112
+ # The swap may reap the old coldkey's account on chain (resetting its
113
+ # nonce). Drop the in-process nonce cache entry so the next extrinsic
114
+ # signed by this ss58 re-fetches from the chain instead of incrementing
115
+ # a stale value.
116
+ subtensor.substrate.clear_nonce_cache_for_account(old_coldkey_ss58)
117
+ return response
111
118
 
112
119
 
113
120
  async def sudo_set_admin_freeze_window_extrinsic(
@@ -166,3 +166,13 @@ version_as_int: int = sum(
166
166
  e * (_version_int_base**i) for i, e in enumerate(reversed(_version_info))
167
167
  )
168
168
  assert version_as_int < 2**31 # fits in int32
169
+
170
+
171
+ # used for backwards compatibility in config.py and loggingmachine.py
172
+ def no_parse_cli():
173
+ return not os.getenv("BT_NO_PARSE_CLI_ARGS", "true").lower() in (
174
+ "0",
175
+ "false",
176
+ "no",
177
+ "off",
178
+ )
@@ -48,7 +48,7 @@ from bittensor.core.chain_data.utils import (
48
48
  decode_revealed_commitment_with_hotkey,
49
49
  )
50
50
  from bittensor.core.config import Config
51
- from bittensor.core.errors import ChainError
51
+ from bittensor.core.errors import ChainError, chain_error_from_substrate_exception
52
52
  from bittensor.core.extrinsics.children import (
53
53
  root_set_pending_childkey_cooldown_extrinsic,
54
54
  set_children_extrinsic,
@@ -5012,8 +5012,11 @@ class Subtensor(SubtensorMixin):
5012
5012
  return extrinsic_response
5013
5013
 
5014
5014
  except SubstrateRequestException as error:
5015
+ typed = chain_error_from_substrate_exception(error)
5016
+ if typed is not None:
5017
+ error = typed
5015
5018
  if raise_error:
5016
- raise
5019
+ raise error from None
5017
5020
 
5018
5021
  extrinsic_response.success = False
5019
5022
  extrinsic_response.message = format_error_message(error)
@@ -17,7 +17,7 @@ from typing import NamedTuple, Union
17
17
  from statemachine import State, StateMachine
18
18
 
19
19
  from bittensor.core.config import Config
20
- from bittensor.core.settings import DEFAULTS
20
+ from bittensor.core.settings import DEFAULTS, no_parse_cli
21
21
  from bittensor.utils.btlogging.console import BittensorConsole
22
22
  from .defines import (
23
23
  BITTENSOR_LOGGER_NAME,
@@ -686,6 +686,8 @@ class LoggingMachine(StateMachine, Logger):
686
686
  Return:
687
687
  Configuration object with settings from command-line arguments.
688
688
  """
689
+ if no_parse_cli():
690
+ return Config()
689
691
  parser = argparse.ArgumentParser()
690
692
  cls.add_args(parser)
691
693
  return Config(parser)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bittensor
3
- Version: 10.3.1
3
+ Version: 10.3.2
4
4
  Summary: Bittensor SDK
5
5
  Author: bittensor.com
6
6
  License: The MIT License (MIT)
@@ -45,7 +45,7 @@ Requires-Dist: cyscale<1.0.0,>=0.3.3
45
45
  Requires-Dist: uvicorn
46
46
  Requires-Dist: bittensor-drand<2.0.0,>=1.3.0
47
47
  Requires-Dist: bittensor-wallet==4.0.1
48
- Requires-Dist: async-substrate-interface<3.0.0,>=2.0.3
48
+ Requires-Dist: async-substrate-interface<3.0.0,>=2.0.4
49
49
  Provides-Extra: dev
50
50
  Requires-Dist: pytest==9.0.3; extra == "dev"
51
51
  Requires-Dist: pytest-asyncio==1.3.0; extra == "dev"
@@ -18,7 +18,7 @@ cyscale<1.0.0,>=0.3.3
18
18
  uvicorn
19
19
  bittensor-drand<2.0.0,>=1.3.0
20
20
  bittensor-wallet==4.0.1
21
- async-substrate-interface<3.0.0,>=2.0.3
21
+ async-substrate-interface<3.0.0,>=2.0.4
22
22
 
23
23
  [cli]
24
24
  bittensor-cli>=9.21.1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "bittensor"
7
- version = "10.3.1"
7
+ version = "10.3.2"
8
8
  description = "Bittensor SDK"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -33,7 +33,7 @@ dependencies = [
33
33
  "uvicorn",
34
34
  "bittensor-drand>=1.3.0,<2.0.0",
35
35
  "bittensor-wallet==4.0.1",
36
- "async-substrate-interface>=2.0.3,<3.0.0",
36
+ "async-substrate-interface>=2.0.4,<3.0.0",
37
37
  ]
38
38
 
39
39
  [project.optional-dependencies]
File without changes
File without changes
File without changes