Skip to content

Commit ae02978

Browse files
authored
Merge pull request #2423 from opentensor/release/8.3.1
Release/8.3.1
2 parents 3b25a0b + 82eecbc commit ae02978

File tree

10 files changed

+633
-107
lines changed

10 files changed

+633
-107
lines changed

.circleci/config.yml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -275,19 +275,6 @@ jobs:
275275
command: |
276276
[[ $(docker manifest inspect opentensorfdn/bittensor:`cat VERSION` > /dev/null 2> /dev/null ; echo $?) == 1 ]] && echo "Docker image 'opentensorfdn/bittensor:`cat VERSION`' does not exist in dockerhub"
277277
278-
release-dry-run:
279-
docker:
280-
- image: cimg/python:3.10
281-
steps:
282-
- checkout
283-
- setup_remote_docker:
284-
version: 20.10.14
285-
docker_layer_caching: true
286-
- run:
287-
name: Executing release script
288-
command: |
289-
./scripts/release/release.sh --github-token ${GH_API_ACCESS_TOKEN}
290-
291278
workflows:
292279
compatibility_checks:
293280
jobs:
@@ -339,11 +326,6 @@ workflows:
339326
branches:
340327
only:
341328
- /^(release|hotfix)/.*/
342-
- release-dry-run:
343-
filters:
344-
branches:
345-
only:
346-
- /^(release|hotfix)/.*/
347329

348330
release-requirements:
349331
jobs:
@@ -352,8 +334,3 @@ workflows:
352334
branches:
353335
only:
354336
- master
355-
- release-dry-run:
356-
filters:
357-
branches:
358-
only:
359-
- master

CHANGELOG.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,48 @@
11
# Changelog
22

3+
## 8.3.1 /2024-11-14
4+
5+
## What's Changed
6+
* Fixes broken Subtensor methods by @thewhaleking in https://github.com/opentensor/bittensor/pull/2420
7+
* [Tests] AsyncSubtensor (Part 7: The final race) by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2418
8+
9+
**Full Changelog**: https://github.com/opentensor/bittensor/compare/v8.3.0...v8.3.1
10+
11+
## 8.3.0 /2024-11-13
12+
13+
## What's Changed
14+
* Expands the type registry to include all the available options by @thewhaleking in https://github.com/opentensor/bittensor/pull/2353
15+
* add `Subtensor.register`, `Subtensor.difficulty` and related staff with tests by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2352
16+
* added to Subtensor: `burned_register`, `get_subnet_burn_cost`, `recycle` and related extrinsics by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2359
17+
* Poem "Risen from the Past". Act 3. by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2363
18+
* default port from 9946 to 9944 by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2376
19+
* remove unused prometheus extrinsic by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2378
20+
* Replace rich.console to btlogging.loggin by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2377
21+
* SDK (AsyncSubtensor) Part 1 by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2374
22+
* SDK (AsyncSubtensor) Part 2 by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2380
23+
* Handle SSL Error on Connection by @thewhaleking in https://github.com/opentensor/bittensor/pull/2384
24+
* Avoid using `prompt` in SDK by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2382
25+
* Backmerge/8.2.0 by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2389
26+
* Remove `retry` and fix tests by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2392
27+
* fix: logging weights correctly in utils/weight_utils.py by @grantdfoster in https://github.com/opentensor/bittensor/pull/2362
28+
* Add `subvortex` subnet and tests by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2395
29+
* Release/8.2.1 by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2397
30+
* [Tests] AsyncSubtensor (Part 1) by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2398
31+
* Extend period for fastblock e2e tests_incentive.py by @opendansor in https://github.com/opentensor/bittensor/pull/2400
32+
* Remove unused import by @thewhaleking in https://github.com/opentensor/bittensor/pull/2401
33+
* `Reconnection substrate...` as debug by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2403
34+
* Handles websockets v14+ in async by @thewhaleking in https://github.com/opentensor/bittensor/pull/2404
35+
* [Tests] AsyncSubtensor (Part 2) by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2407
36+
* [Tests] AsyncSubtensor (Part 3) by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2409
37+
* Handle new PasswordError from btwallet by @thewhaleking in https://github.com/opentensor/bittensor/pull/2406
38+
* [Tests] AsyncSubtensor (Part 4) by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2410
39+
* [Tests] AsyncSubtensor (Part 5) by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2411
40+
* Bringing back lost methods for setting weights by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2412
41+
* Update bt-decode requirement by @thewhaleking in https://github.com/opentensor/bittensor/pull/2413
42+
* [Tests] AsyncSubtensor (Part 6) by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2414
43+
44+
**Full Changelog**: https://github.com/opentensor/bittensor/compare/v8.2.1...v8.3.0
45+
346
## 8.2.1 /2024-11-06
447

548
## What's Changed
@@ -1143,4 +1186,4 @@ This release refactors the registration code for CPU registration to improve sol
11431186

11441187
### Synapse update
11451188

1146-
##
1189+
##

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.3.0
1+
8.3.1

bittensor/core/async_subtensor.py

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
format_error_message,
4747
decode_hex_identity_dict,
4848
validate_chain_endpoint,
49+
hex_to_bytes,
4950
)
5051
from bittensor.utils.async_substrate_interface import (
5152
AsyncSubstrateInterface,
@@ -351,12 +352,7 @@ async def get_delegates(
351352
reuse_block=reuse_block,
352353
)
353354
if hex_bytes_result is not None:
354-
try:
355-
bytes_result = bytes.fromhex(hex_bytes_result[2:])
356-
except ValueError:
357-
bytes_result = bytes.fromhex(hex_bytes_result)
358-
359-
return DelegateInfo.list_from_vec_u8(bytes_result)
355+
return DelegateInfo.list_from_vec_u8(hex_to_bytes(hex_bytes_result))
360356
else:
361357
return []
362358

@@ -392,12 +388,7 @@ async def get_stake_info_for_coldkey(
392388
if hex_bytes_result is None:
393389
return []
394390

395-
try:
396-
bytes_result = bytes.fromhex(hex_bytes_result[2:])
397-
except ValueError:
398-
bytes_result = bytes.fromhex(hex_bytes_result)
399-
400-
return StakeInfo.list_from_vec_u8(bytes_result)
391+
return StakeInfo.list_from_vec_u8(hex_to_bytes(hex_bytes_result))
401392

402393
async def get_stake_for_coldkey_and_hotkey(
403394
self, hotkey_ss58: str, coldkey_ss58: str, block_hash: Optional[str] = None
@@ -853,12 +844,7 @@ async def neurons_lite(
853844
if hex_bytes_result is None:
854845
return []
855846

856-
try:
857-
bytes_result = bytes.fromhex(hex_bytes_result[2:])
858-
except ValueError:
859-
bytes_result = bytes.fromhex(hex_bytes_result)
860-
861-
return NeuronInfoLite.list_from_vec_u8(bytes_result)
847+
return NeuronInfoLite.list_from_vec_u8(hex_to_bytes(hex_bytes_result))
862848

863849
async def neuron_for_uid(
864850
self, uid: Optional[int], netuid: int, block_hash: Optional[str] = None
@@ -1170,12 +1156,7 @@ async def get_subnet_hyperparameters(
11701156
if hex_bytes_result is None:
11711157
return []
11721158

1173-
if hex_bytes_result.startswith("0x"):
1174-
bytes_result = bytes.fromhex(hex_bytes_result[2:])
1175-
else:
1176-
bytes_result = bytes.fromhex(hex_bytes_result)
1177-
1178-
return SubnetHyperparameters.from_vec_u8(bytes_result)
1159+
return SubnetHyperparameters.from_vec_u8(hex_to_bytes(hex_bytes_result))
11791160

11801161
async def get_vote_data(
11811162
self,
@@ -1422,15 +1403,15 @@ async def register(
14221403

14231404
async def pow_register(
14241405
self: "AsyncSubtensor",
1425-
wallet: Wallet,
1426-
netuid,
1427-
processors,
1428-
update_interval,
1429-
output_in_place,
1430-
verbose,
1431-
use_cuda,
1432-
dev_id,
1433-
threads_per_block,
1406+
wallet: "Wallet",
1407+
netuid: int,
1408+
processors: int,
1409+
update_interval: int,
1410+
output_in_place: bool,
1411+
verbose: bool,
1412+
use_cuda: bool,
1413+
dev_id: Union[list[int], int],
1414+
threads_per_block: int,
14341415
):
14351416
"""Register neuron."""
14361417
return await register_extrinsic(
@@ -1481,11 +1462,9 @@ async def set_weights(
14811462
retries = 0
14821463
success = False
14831464
message = "No attempt made. Perhaps it is too soon to set weights!"
1484-
while (
1485-
await self.blocks_since_last_update(netuid, uid)
1486-
> await self.weights_rate_limit(netuid)
1487-
and retries < max_retries
1488-
):
1465+
while retries < max_retries and await self.blocks_since_last_update(
1466+
netuid, uid
1467+
) > await self.weights_rate_limit(netuid):
14891468
try:
14901469
logging.info(
14911470
f"Setting weights for subnet #<blue>{netuid}</blue>. Attempt <blue>{retries + 1} of {max_retries}</blue>."

bittensor/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1616
# DEALINGS IN THE SOFTWARE.
1717

18-
__version__ = "8.3.0"
18+
__version__ = "8.3.1"
1919

2020
import os
2121
import re

bittensor/core/subtensor.py

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@
7171
transfer_extrinsic,
7272
)
7373
from bittensor.core.metagraph import Metagraph
74-
from bittensor.utils import networking, torch, ss58_to_vec_u8, u16_normalized_float
74+
from bittensor.utils import (
75+
networking,
76+
torch,
77+
ss58_to_vec_u8,
78+
u16_normalized_float,
79+
hex_to_bytes,
80+
)
7581
from bittensor.utils.balance import Balance
7682
from bittensor.utils.btlogging import logging
7783
from bittensor.utils.registration import legacy_torch_api_compat
@@ -523,13 +529,11 @@ def query_runtime_api(
523529
return None
524530

525531
return_type = call_definition["type"]
526-
527532
as_scale_bytes = scalecodec.ScaleBytes(json_result["result"])
528533

529534
rpc_runtime_config = RuntimeConfiguration()
530535
rpc_runtime_config.update_type_registry(load_type_registry_preset("legacy"))
531536
rpc_runtime_config.update_type_registry(custom_rpc_type_registry)
532-
533537
obj = rpc_runtime_config.create_scale_object(return_type, as_scale_bytes)
534538
if obj.data.to_hex() == "0x0400": # RPC returned None result
535539
return None
@@ -1227,12 +1231,7 @@ def get_subnet_hyperparameters(
12271231
if hex_bytes_result is None:
12281232
return []
12291233

1230-
if hex_bytes_result.startswith("0x"):
1231-
bytes_result = bytes.fromhex(hex_bytes_result[2:])
1232-
else:
1233-
bytes_result = bytes.fromhex(hex_bytes_result)
1234-
1235-
return SubnetHyperparameters.from_vec_u8(bytes_result)
1234+
return SubnetHyperparameters.from_vec_u8(hex_to_bytes(hex_bytes_result))
12361235

12371236
# Community uses this method
12381237
# Returns network ImmunityPeriod hyper parameter.
@@ -1308,10 +1307,13 @@ def get_commitment(self, netuid: int, uid: int, block: Optional[int] = None) ->
13081307
hotkey = metagraph.hotkeys[uid] # type: ignore
13091308

13101309
metadata = get_metadata(self, netuid, hotkey, block)
1311-
commitment = metadata["info"]["fields"][0] # type: ignore
1312-
hex_data = commitment[list(commitment.keys())[0]][2:] # type: ignore
1310+
try:
1311+
commitment = metadata["info"]["fields"][0] # type: ignore
1312+
hex_data = commitment[list(commitment.keys())[0]][2:] # type: ignore
1313+
return bytes.fromhex(hex_data).decode()
13131314

1314-
return bytes.fromhex(hex_data).decode()
1315+
except TypeError:
1316+
return ""
13151317

13161318
# Community uses this via `bittensor.utils.weight_utils.process_weights_for_netuid` function.
13171319
def min_allowed_weights(
@@ -1367,7 +1369,7 @@ def get_prometheus_info(
13671369
Optional[bittensor.core.chain_data.prometheus_info.PrometheusInfo]: A PrometheusInfo object containing the prometheus information, or ``None`` if the prometheus information is not found.
13681370
"""
13691371
result = self.query_subtensor("Prometheus", block, [netuid, hotkey_ss58])
1370-
if result is not None and hasattr(result, "value"):
1372+
if result is not None and getattr(result, "value", None) is not None:
13711373
return PrometheusInfo(
13721374
ip=networking.int_to_ip(result.value["ip"]),
13731375
ip_type=result.value["ip_type"],
@@ -1407,17 +1409,13 @@ def get_all_subnets_info(self, block: Optional[int] = None) -> list[SubnetInfo]:
14071409
14081410
Gaining insights into the subnets' details assists in understanding the network's composition, the roles of different subnets, and their unique features.
14091411
"""
1410-
block_hash = None if block is None else self.substrate.get_block_hash(block)
1411-
1412-
json_body = self.substrate.rpc_request(
1413-
method="subnetInfo_getSubnetsInfo", # custom rpc method
1414-
params=[block_hash] if block_hash else [],
1412+
hex_bytes_result = self.query_runtime_api(
1413+
"SubnetInfoRuntimeApi", "get_subnets_info", params=[], block=block
14151414
)
1416-
1417-
if not (result := json_body.get("result", None)):
1415+
if not hex_bytes_result:
14181416
return []
1419-
1420-
return SubnetInfo.list_from_vec_u8(result)
1417+
else:
1418+
return SubnetInfo.list_from_vec_u8(hex_to_bytes(hex_bytes_result))
14211419

14221420
# Metagraph uses this method
14231421
def bonds(
@@ -1561,12 +1559,7 @@ def neurons_lite(
15611559
if hex_bytes_result is None:
15621560
return []
15631561

1564-
if hex_bytes_result.startswith("0x"):
1565-
bytes_result = bytes.fromhex(hex_bytes_result[2:])
1566-
else:
1567-
bytes_result = bytes.fromhex(hex_bytes_result)
1568-
1569-
return NeuronInfoLite.list_from_vec_u8(bytes_result) # type: ignore
1562+
return NeuronInfoLite.list_from_vec_u8(hex_to_bytes(hex_bytes_result)) # type: ignore
15701563

15711564
# Used in the `neurons` method which is used in metagraph.py
15721565
def weights(
@@ -1923,7 +1916,7 @@ def get_delegate_by_hotkey(
19231916
if not (result := json_body.get("result", None)):
19241917
return None
19251918

1926-
return DelegateInfo.from_vec_u8(result)
1919+
return DelegateInfo.from_vec_u8(bytes(result))
19271920

19281921
# Subnet 27 uses this method name
19291922
_do_serve_axon = do_serve_axon

bittensor/utils/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,14 @@ def unlock_key(wallet: "Wallet", unlock_type="coldkey") -> "UnlockStatus":
403403
except KeyFileError:
404404
err_msg = f"{unlock_type.capitalize()} keyfile is corrupt, non-writable, or non-readable, or non-existent."
405405
return UnlockStatus(False, err_msg)
406+
407+
408+
def hex_to_bytes(hex_str: str) -> bytes:
409+
"""
410+
Converts a hex-encoded string into bytes. Handles 0x-prefixed and non-prefixed hex-encoded strings.
411+
"""
412+
if hex_str.startswith("0x"):
413+
bytes_result = bytes.fromhex(hex_str[2:])
414+
else:
415+
bytes_result = bytes.fromhex(hex_str)
416+
return bytes_result

0 commit comments

Comments
 (0)