Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/9.0.0rc2 #2638

Draft
wants to merge 6 commits into
base: release/9.0.0rc1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.0.0rc1
9.0.0rc2
2 changes: 1 addition & 1 deletion bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 3 additions & 5 deletions bittensor/core/chain_data/subnet_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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=[
Expand Down
2 changes: 1 addition & 1 deletion bittensor/core/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "9.0.0rc1"
__version__ = "9.0.0rc2"

import os
import re
Expand Down
23 changes: 12 additions & 11 deletions bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand All @@ -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


Expand Down Expand Up @@ -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:
Expand Down
30 changes: 29 additions & 1 deletion tests/unit_tests/test_async_subtensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import unittest.mock as mock

import pytest
Expand Down Expand Up @@ -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,
)
Loading