diff --git a/CHANGELOG.md b/CHANGELOG.md index 742f8076b5..825016ea16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 9.0.0rc2 /2025-02-05 + +## What's Changed +* Small bug fixes and improvements by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2637 + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v9.0.0rc1...v9.0.0rc2 + ## 9.0.0rc1 /2025-02-05 ## What's Changed diff --git a/VERSION b/VERSION index 89501f34b7..2a3b85168f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -9.0.0rc1 \ No newline at end of file +9.0.0rc2 \ No newline at end of file diff --git a/bittensor/core/async_subtensor.py b/bittensor/core/async_subtensor.py index 66652fbc5f..5b0cdd2db1 100644 --- a/bittensor/core/async_subtensor.py +++ b/bittensor/core/async_subtensor.py @@ -763,7 +763,7 @@ async def get_all_subnets_info( """ result = await self.query_runtime_api( runtime_api="SubnetInfoRuntimeApi", - method="get_subnets_info", + method="get_subnets_info_v2", params=[], block=block, block_hash=block_hash, diff --git a/bittensor/core/chain_data/subnet_state.py b/bittensor/core/chain_data/subnet_state.py index 223ef84dee..f8c09f1ca5 100644 --- a/bittensor/core/chain_data/subnet_state.py +++ b/bittensor/core/chain_data/subnet_state.py @@ -5,10 +5,8 @@ from dataclasses import dataclass -from scalecodec.utils.ss58 import ss58_encode - from bittensor.core.chain_data.info_base import InfoBase -from bittensor.core.chain_data.utils import SS58_FORMAT +from bittensor.core.chain_data.utils import decode_account_id from bittensor.utils import u16_normalized_float from bittensor.utils.balance import Balance @@ -39,8 +37,8 @@ def _from_dict(cls, decoded: dict) -> "SubnetState": netuid = decoded["netuid"] return SubnetState( netuid=netuid, - hotkeys=[ss58_encode(val, SS58_FORMAT) for val in decoded["hotkeys"]], - coldkeys=[ss58_encode(val, SS58_FORMAT) for val in decoded["coldkeys"]], + hotkeys=[decode_account_id(hk) for hk in decoded.get("hotkeys", [])], + coldkeys=[decode_account_id(ck) for ck in decoded.get("coldkeys", [])], active=decoded["active"], validator_permit=decoded["validator_permit"], pruning_score=[ diff --git a/bittensor/core/settings.py b/bittensor/core/settings.py index 0fb7339b1b..1b6ddca4fe 100644 --- a/bittensor/core/settings.py +++ b/bittensor/core/settings.py @@ -1,4 +1,4 @@ -__version__ = "9.0.0rc1" +__version__ = "9.0.0rc2" import os import re diff --git a/bittensor/core/subtensor.py b/bittensor/core/subtensor.py index 100f1a26aa..efdeabda7c 100644 --- a/bittensor/core/subtensor.py +++ b/bittensor/core/subtensor.py @@ -13,17 +13,17 @@ from bittensor.core.async_subtensor import ProposalVoteData from bittensor.core.axon import Axon from bittensor.core.chain_data import ( - decode_account_id, + DelegateInfo, + DynamicInfo, MetagraphInfo, + NeuronInfo, + NeuronInfoLite, + StakeInfo, + SubnetHyperparameters, WeightCommitInfo, + SubnetInfo, + decode_account_id, ) -from bittensor.core.chain_data.delegate_info import DelegateInfo -from bittensor.core.chain_data.dynamic_info import DynamicInfo -from bittensor.core.chain_data.neuron_info import NeuronInfo -from bittensor.core.chain_data.neuron_info_lite import NeuronInfoLite -from bittensor.core.chain_data.stake_info import StakeInfo -from bittensor.core.chain_data.subnet_hyperparameters import SubnetHyperparameters -from bittensor.core.chain_data.subnet_info import SubnetInfo from bittensor.core.config import Config from bittensor.core.extrinsics.commit_reveal import commit_reveal_v3_extrinsic from bittensor.core.extrinsics.commit_weights import ( @@ -66,8 +66,7 @@ TYPE_REGISTRY, DELEGATES_DETAILS_URL, ) -from bittensor.core.types import ParamWithTypes -from bittensor.core.types import SubtensorMixin +from bittensor.core.types import ParamWithTypes, SubtensorMixin from bittensor.utils import ( torch, format_error_message, @@ -83,13 +82,13 @@ check_and_convert_to_balance, ) from bittensor.utils.btlogging import logging +from bittensor.utils.delegates_details import DelegatesDetails from bittensor.utils.weight_utils import generate_weight_hash if TYPE_CHECKING: from bittensor_wallet import Wallet from async_substrate_interface.sync_substrate import QueryMapResult from async_substrate_interface.types import ScaleObj - from bittensor.utils.delegates_details import DelegatesDetails from scalecodec.types import GenericCall @@ -1798,6 +1797,8 @@ def query_identity(self, coldkey_ss58: str, block: Optional[int] = None) -> dict params=[coldkey_ss58], block_hash=self.determine_block_hash(block), ) + if not identity_info: + return {} try: return _decode_hex_identity_dict(identity_info) except TypeError: diff --git a/tests/unit_tests/test_async_subtensor.py b/tests/unit_tests/test_async_subtensor.py index dacebd77ff..6e88196906 100644 --- a/tests/unit_tests/test_async_subtensor.py +++ b/tests/unit_tests/test_async_subtensor.py @@ -1,4 +1,3 @@ -import asyncio import unittest.mock as mock import pytest @@ -2609,3 +2608,32 @@ async def test_commit_weights_with_exception(subtensor, mocker): assert mocked_commit_weights_extrinsic.call_count == max_retries assert result is False assert "No attempt made. Perhaps it is too soon to commit weights!" in message + + +@pytest.mark.asyncio +async def test_get_all_subnets_info_success(mocker, subtensor): + """Test get_all_subnets_info returns correct data when subnet information is found.""" + # Prep + block = 123 + + mocker.patch.object(subtensor, "query_runtime_api") + mocker.patch.object( + async_subtensor.SubnetInfo, + "list_from_dicts", + ) + + # Call + await subtensor.get_all_subnets_info(block) + + # Asserts + subtensor.query_runtime_api.assert_awaited_once_with( + runtime_api="SubnetInfoRuntimeApi", + method="get_subnets_info_v2", + params=[], + block=block, + block_hash=None, + reuse_block=False, + ) + async_subtensor.SubnetInfo.list_from_dicts.assert_called_once_with( + subtensor.query_runtime_api.return_value, + )