Skip to content

Commit 7b14db2

Browse files
Merge pull request #2727 from opentensor/release/9.0.4
Release/9.0.4
2 parents 648f11a + 8922cb5 commit 7b14db2

30 files changed

+2960
-418
lines changed

.github/workflows/e2e-subtensor-tests.yaml

+10-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
test-files: ${{ steps.get-tests.outputs.test-files }}
3434
steps:
3535
- name: Check-out repository under $GITHUB_WORKSPACE
36-
uses: actions/checkout@v2
36+
uses: actions/checkout@v4
3737

3838
- name: Find test files
3939
id: get-tests
@@ -66,7 +66,7 @@ jobs:
6666
TARGET: ${{ matrix.rust-target }}
6767
steps:
6868
- name: Check-out repository under $GITHUB_WORKSPACE
69-
uses: actions/checkout@v2
69+
uses: actions/checkout@v4
7070

7171
- name: Install dependencies
7272
run: |
@@ -92,14 +92,18 @@ jobs:
9292
working-directory: ${{ github.workspace }}/subtensor
9393
run: git checkout devnet-ready
9494

95+
- name: Install uv
96+
uses: astral-sh/setup-uv@v4
97+
98+
- name: install dependencies
99+
run: uv sync --all-extras --dev
100+
95101
- name: Run tests
96102
run: |
97-
python3 -m pip install -e .[dev] pytest
98-
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" pytest ${{ matrix.test-file }} -s
103+
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" uv run pytest ${{ matrix.test-file }} -s
99104
100105
- name: Retry failed tests
101106
if: failure()
102107
run: |
103108
sleep 10
104-
python3 -m pip install -e .[dev] pytest
105-
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" pytest ${{ matrix.test-file }} -s
109+
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" uv run pytest ${{ matrix.test-file }} -s

.github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ jobs:
2323
- name: Install dependencies
2424
run: |
2525
python -m pip install --upgrade pip
26-
pip install build wheel twine
26+
pip install setuptools wheel twine build toml
2727
2828
- name: Build package
29-
run: python setup.py sdist bdist_wheel
29+
run: python -m build --sdist --wheel --outdir dist/
3030

3131
- name: Check if package version already exists
3232
run: |
33-
PACKAGE_NAME=$(python setup.py --name)
33+
PACKAGE_NAME=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['name'])")
3434
PACKAGE_VERSION=${{ github.event.inputs.version }}
3535
if twine check dist/*; then
3636
if pip install $PACKAGE_NAME==$PACKAGE_VERSION; then

CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Changelog
22

3+
## 9.0.4 /2025-03-06
4+
5+
## What's Changed
6+
* Release/9.0.3 by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2712
7+
* improve `wait_for_node_start` until 20 mins by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2714
8+
* More E2E tests by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2678
9+
* fix(2715): use ChainIdentity for identities by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2718
10+
* Metagraph use block correctly in `_get_all_stakes_from_chain` by @thewhaleking in https://github.com/opentensor/bittensor/pull/2719
11+
* Integration tests for async-substrate-interface 1.0.4 compatibility by @thewhaleking in https://github.com/opentensor/bittensor/pull/2720
12+
* Backmerge main staging 904 by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2721
13+
* Skip E2E test_children by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2723
14+
* More Subtensor unnitests by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2713
15+
* Change to pyproject.toml by @thewhaleking in https://github.com/opentensor/bittensor/pull/2504
16+
* Updates test_incentive by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2722
17+
* Use uv for gh actions by @thewhaleking in https://github.com/opentensor/bittensor/pull/2503
18+
* Bumps async substrate interface by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2725
19+
20+
**Full Changelog**: https://github.com/opentensor/bittensor/compare/v9.0.3...v9.0.4
21+
322
## 9.0.3 /2025-02-26
423

524
## What's Changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9.0.3
1+
9.0.4

bittensor/core/async_subtensor.py

+26-66
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from functools import partial
66
from typing import Optional, Any, Union, Iterable, TYPE_CHECKING
77

8-
import aiohttp
98
import asyncstdlib as a
109
import numpy as np
1110
import scalecodec
@@ -28,6 +27,7 @@
2827
decode_account_id,
2928
DynamicInfo,
3029
)
30+
from bittensor.core.chain_data.chain_identity import ChainIdentity
3131
from bittensor.core.chain_data.delegate_info import DelegatedInfo
3232
from bittensor.core.chain_data.utils import decode_metadata
3333
from bittensor.core.config import Config
@@ -68,15 +68,14 @@
6868
reveal_weights_extrinsic,
6969
)
7070
from bittensor.core.metagraph import AsyncMetagraph
71-
from bittensor.core.settings import version_as_int, TYPE_REGISTRY, DELEGATES_DETAILS_URL
71+
from bittensor.core.settings import version_as_int, TYPE_REGISTRY
7272
from bittensor.core.types import ParamWithTypes, SubtensorMixin
7373
from bittensor.utils import (
74+
Certificate,
7475
decode_hex_identity_dict,
7576
format_error_message,
7677
torch,
7778
u16_normalized_float,
78-
_decode_hex_identity_dict,
79-
Certificate,
8079
u64_normalized_float,
8180
)
8281
from bittensor.utils.balance import (
@@ -85,7 +84,6 @@
8584
check_and_convert_to_balance,
8685
)
8786
from bittensor.utils.btlogging import logging
88-
from bittensor.utils.delegates_details import DelegatesDetails
8987
from bittensor.utils.weight_utils import generate_weight_hash
9088

9189
if TYPE_CHECKING:
@@ -1079,75 +1077,33 @@ async def get_delegate_identities(
10791077
block: Optional[int] = None,
10801078
block_hash: Optional[str] = None,
10811079
reuse_block: bool = False,
1082-
) -> dict[str, "DelegatesDetails"]:
1080+
) -> dict[str, ChainIdentity]:
10831081
"""
1084-
Fetches delegates identities from the chain and GitHub. Preference is given to chain data, and missing info is
1085-
filled-in by the info from GitHub. At some point, we want to totally move away from fetching this info from
1086-
GitHub, but chain data is still limited in that regard.
1082+
Fetches delegates identities from the chain.
10871083
10881084
Arguments:
10891085
block (Optional[int]): The blockchain block number for the query.
10901086
block_hash (str): the hash of the blockchain block for the query
10911087
reuse_block (bool): Whether to reuse the last-used blockchain block hash.
10921088
10931089
Returns:
1094-
Dict {ss58: DelegatesDetails, ...}
1090+
Dict {ss58: ChainIdentity, ...}
10951091
10961092
"""
10971093
block_hash = await self.determine_block_hash(block, block_hash, reuse_block)
1098-
timeout = aiohttp.ClientTimeout(10.0)
1099-
async with aiohttp.ClientSession(timeout=timeout) as session:
1100-
identities_info, response = await asyncio.gather(
1101-
self.substrate.query_map(
1102-
module="Registry",
1103-
storage_function="IdentityOf",
1104-
block_hash=block_hash,
1105-
reuse_block_hash=reuse_block,
1106-
),
1107-
session.get(DELEGATES_DETAILS_URL),
1108-
)
1109-
1110-
all_delegates_details = {}
1111-
async for ss58_address, identity in identities_info:
1112-
all_delegates_details.update(
1113-
{
1114-
decode_account_id(
1115-
ss58_address[0]
1116-
): DelegatesDetails.from_chain_data(
1117-
decode_hex_identity_dict(identity.value["info"])
1118-
)
1119-
}
1120-
)
1121-
1122-
if response.ok:
1123-
all_delegates: dict[str, Any] = await response.json(content_type=None)
1124-
1125-
for delegate_hotkey, delegate_details in all_delegates.items():
1126-
delegate_info = all_delegates_details.setdefault(
1127-
delegate_hotkey,
1128-
DelegatesDetails(
1129-
display=delegate_details.get("name", ""),
1130-
web=delegate_details.get("url", ""),
1131-
additional=delegate_details.get("description", ""),
1132-
pgp_fingerprint=delegate_details.get("fingerprint", ""),
1133-
),
1134-
)
1135-
delegate_info.display = (
1136-
delegate_info.display or delegate_details.get("name", "")
1137-
)
1138-
delegate_info.web = delegate_info.web or delegate_details.get(
1139-
"url", ""
1140-
)
1141-
delegate_info.additional = (
1142-
delegate_info.additional
1143-
or delegate_details.get("description", "")
1144-
)
1145-
delegate_info.pgp_fingerprint = (
1146-
delegate_info.pgp_fingerprint
1147-
or delegate_details.get("fingerprint", "")
1148-
)
1094+
identities = await self.substrate.query_map(
1095+
module="SubtensorModule",
1096+
storage_function="IdentitiesV2",
1097+
block_hash=block_hash,
1098+
reuse_block_hash=reuse_block,
1099+
)
11491100

1150-
return all_delegates_details
1101+
return {
1102+
decode_account_id(ss58_address[0]): ChainIdentity.from_dict(
1103+
decode_hex_identity_dict(identity.value),
1104+
)
1105+
async for ss58_address, identity in identities
1106+
}
11511107

11521108
async def get_delegate_take(
11531109
self,
@@ -2424,7 +2380,7 @@ async def query_identity(
24242380
block: Optional[int] = None,
24252381
block_hash: Optional[str] = None,
24262382
reuse_block: bool = False,
2427-
) -> dict:
2383+
) -> Optional[ChainIdentity]:
24282384
"""
24292385
Queries the identity of a neuron on the Bittensor blockchain using the given key. This function retrieves
24302386
detailed identity information about a specific neuron, which is a crucial aspect of the network's
@@ -2455,12 +2411,16 @@ async def query_identity(
24552411
block_hash=block_hash,
24562412
reuse_block_hash=reuse_block,
24572413
)
2414+
24582415
if not identity_info:
2459-
return {}
2416+
return None
2417+
24602418
try:
2461-
return _decode_hex_identity_dict(identity_info)
2419+
return ChainIdentity.from_dict(
2420+
decode_hex_identity_dict(identity_info),
2421+
)
24622422
except TypeError:
2463-
return {}
2423+
return None
24642424

24652425
async def recycle(
24662426
self,

bittensor/core/metagraph.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ async def sync(
14001400
await self._set_weights_and_bonds(subtensor=subtensor)
14011401

14021402
# Fills in the stake associated attributes of a class instance from a chain response.
1403-
await self._get_all_stakes_from_chain()
1403+
await self._get_all_stakes_from_chain(block=block)
14041404

14051405
# apply MetagraphInfo data to instance
14061406
await self._apply_metagraph_info()
@@ -1566,13 +1566,14 @@ async def _process_root_weights(
15661566
)
15671567
return tensor_param
15681568

1569-
async def _get_all_stakes_from_chain(self):
1569+
async def _get_all_stakes_from_chain(self, block: int):
15701570
"""Fills in the stake associated attributes of a class instance from a chain response."""
15711571
try:
15721572
result = await self.subtensor.query_runtime_api(
15731573
runtime_api="SubnetInfoRuntimeApi",
15741574
method="get_subnet_state",
15751575
params=[self.netuid],
1576+
block=block,
15761577
)
15771578

15781579
if result is None:
@@ -1713,7 +1714,7 @@ def sync(
17131714
self._set_weights_and_bonds(subtensor=subtensor)
17141715

17151716
# Fills in the stake associated attributes of a class instance from a chain response.
1716-
self._get_all_stakes_from_chain()
1717+
self._get_all_stakes_from_chain(block=block)
17171718

17181719
# apply MetagraphInfo data to instance
17191720
self._apply_metagraph_info()
@@ -1873,13 +1874,14 @@ def _process_root_weights(
18731874
)
18741875
return tensor_param
18751876

1876-
def _get_all_stakes_from_chain(self):
1877+
def _get_all_stakes_from_chain(self, block: int):
18771878
"""Fills in the stake associated attributes of a class instance from a chain response."""
18781879
try:
18791880
result = self.subtensor.query_runtime_api(
18801881
runtime_api="SubnetInfoRuntimeApi",
18811882
method="get_subnet_state",
18821883
params=[self.netuid],
1884+
block=block,
18831885
)
18841886

18851887
if result is None:

bittensor/core/settings.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "9.0.3"
1+
__version__ = "9.0.4"
22

33
import os
44
import re
@@ -72,9 +72,6 @@
7272
# Wallet ss58 address length
7373
SS58_ADDRESS_LENGTH = 48
7474

75-
# Raw GitHub url for delegates registry file
76-
DELEGATES_DETAILS_URL = "https://raw.githubusercontent.com/opentensor/bittensor-delegates/main/public/delegates.json"
77-
7875
# Block Explorers map network to explorer url
7976
# Must all be polkadotjs explorer urls
8077
NETWORK_EXPLORER_MAP = {

0 commit comments

Comments
 (0)