Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
03dc18b
Use uv for gh actions
thewhaleking Dec 1, 2024
f977d58
Change to pyproject.toml
thewhaleking Dec 2, 2024
25767c2
Merge branch 'staging' into feat/thewhaleking/pyproject-toml
basfroman Jan 9, 2025
eeb2b0e
tests: more e2e tests
zyzniewski-reef Feb 17, 2025
c827cc0
Merge branch 'staging' into tests/zyzniewski/more_e2e_tests
zyzniewski-reef Feb 18, 2025
42bbd9f
Merge branch 'staging' into tests/zyzniewski/more_e2e_tests
basfroman Feb 18, 2025
e4a033a
Merge branch 'staging' into tests/zyzniewski/more_e2e_tests
zyzniewski-reef Feb 19, 2025
5f7fa75
Merge branch 'staging' into tests/zyzniewski/more_e2e_tests
thewhaleking Feb 19, 2025
b592860
Merge branch 'staging' into tests/zyzniewski/more_e2e_tests
zyzniewski-reef Feb 21, 2025
e28bcfc
Merge branch 'staging' into tests/zyzniewski/more_e2e_tests
basfroman Feb 21, 2025
0a4138a
Merge branch 'staging' into tests/zyzniewski/more_e2e_tests
zyzniewski-reef Feb 22, 2025
31aa6b3
tests: fix test_delegate
zyzniewski-reef Feb 22, 2025
5fb5825
tests: move e2e test_blocks
zyzniewski-reef Feb 25, 2025
2dd9b7b
tests: check for get_hotkey_owner is None
zyzniewski-reef Feb 25, 2025
d0b0cfc
Merge branch 'staging' into tests/zyzniewski/more_e2e_tests
zyzniewski-reef Feb 25, 2025
302d52d
tests: more Subtensor unnitests
zyzniewski-reef Feb 27, 2025
2a6f62a
improve `wait_for_node_start` until 20 mins
Feb 28, 2025
5dc537f
Merge branch 'staging' into feat/roman/wait_for_node_start-to-20-mins
ibraheem-abe Feb 28, 2025
f2a963b
Merge pull request #2714 from opentensor/feat/roman/wait_for_node_sta…
basfroman Feb 28, 2025
d6f747f
tests: e2e DelegateTxRateLimitExceeded
zyzniewski-reef Mar 3, 2025
bba291c
Merge branch 'staging' into tests/zyzniewski/more_e2e_tests
zyzniewski-reef Mar 3, 2025
5fec342
Merge pull request #2678 from opentensor/tests/zyzniewski/more_e2e_tests
zyzniewski-reef Mar 3, 2025
b51210a
Merge branch 'staging' into tests/zyzniewski/more_subtensor_unittests
ibraheem-abe Mar 3, 2025
8e7489c
fix(2715): use ChainIdentity for identities
zyzniewski-reef Mar 4, 2025
1a4ba77
Merge pull request #2718 from opentensor/fix/2715-use_ChainIdentity_f…
zyzniewski-reef Mar 5, 2025
ec34bba
remove unused code
zyzniewski-reef Mar 5, 2025
d0495cb
rename test_subtensor_new to _extended
zyzniewski-reef Mar 5, 2025
ca5d2c2
Merge branch 'staging' into tests/zyzniewski/more_subtensor_unittests
zyzniewski-reef Mar 5, 2025
d190533
tests: fix ChainIdentityV2 tests
zyzniewski-reef Mar 5, 2025
75007c4
Uses `block` in `Metagraph._get_all_stakes_from_chain`
thewhaleking Mar 5, 2025
9364417
Merge branch 'staging' into fix/thewhaleking/metagraph-use-block-corr…
ibraheem-abe Mar 5, 2025
a65dad8
Merge pull request #2719 from opentensor/fix/thewhaleking/metagraph-u…
thewhaleking Mar 5, 2025
a9edb1c
Merge branch 'staging' into feat/thewhaleking/pyproject-toml
thewhaleking Mar 5, 2025
a64b51b
Merge remote-tracking branch 'origin/staging' into feat/thewhaleking/…
thewhaleking Mar 5, 2025
ae293de
Updated pyproject to work correctly now.
thewhaleking Mar 5, 2025
fb189e9
Merge remote-tracking branch 'origin/feat/thewhaleking/pyproject-toml…
thewhaleking Mar 5, 2025
4511cd2
Update async-substrate-interface requirement
thewhaleking Mar 5, 2025
b764a73
Fixes integration tests to work with 1.0.4
thewhaleking Mar 5, 2025
1b9f108
Removes everything we don't need
thewhaleking Mar 5, 2025
5aede4e
Bumps async-substrate-interface version
thewhaleking Mar 5, 2025
9fcc90e
Trigger no-op
thewhaleking Mar 5, 2025
d24ac43
Trigger no-op
thewhaleking Mar 5, 2025
5951f87
Naming
thewhaleking Mar 5, 2025
44760b1
Include torch in dev requirements.
thewhaleking Mar 5, 2025
4c64977
Merge branch 'staging' into tests/zyzniewski/more_subtensor_unittests
ibraheem-abe Mar 5, 2025
1df1569
Merge pull request #2720 from opentensor/fix/thewhaleking/integration…
ibraheem-abe Mar 5, 2025
875c83c
Merge branch 'staging' into tests/zyzniewski/more_subtensor_unittests
ibraheem-abe Mar 5, 2025
9dcec39
Merge branch 'master' into backmerge-main-staging-904
ibraheem-abe Mar 5, 2025
7252fbf
Merge branch 'staging' into feat/thewhaleking/pyproject-toml
ibraheem-abe Mar 5, 2025
78a5152
Merge pull request #2721 from opentensor/backmerge-main-staging-904
ibraheem-abe Mar 6, 2025
7481717
Updates test_incentive
ibraheem-abe Mar 6, 2025
447ced6
tests: skip e2e test_children
zyzniewski-reef Mar 6, 2025
4f82168
Merge pull request #2723 from opentensor/tests/skip_e2e_test_children
zyzniewski-reef Mar 6, 2025
e343a72
Merge branch 'staging' into tests/zyzniewski/more_subtensor_unittests
zyzniewski-reef Mar 6, 2025
193063b
Merge branch 'staging' into fix/test-incentive
thewhaleking Mar 6, 2025
1b7b69a
Merge branch 'feat/thewhaleking/pyproject-toml' into feat/thewhalekin…
thewhaleking Mar 6, 2025
ea913ce
Merge pull request #2713 from opentensor/tests/zyzniewski/more_subten…
zyzniewski-reef Mar 6, 2025
85d6024
Merge branch 'staging' into feat/thewhaleking/pyproject-toml
thewhaleking Mar 6, 2025
a61a2e1
Merge branch 'feat/thewhaleking/pyproject-toml' into feat/thewhalekin…
thewhaleking Mar 6, 2025
ef7da10
Merge pull request #2504 from opentensor/feat/thewhaleking/pyproject-…
thewhaleking Mar 6, 2025
e4ff2c1
Merge branch 'staging' into feat/thewhaleking/use-uv-gh-actions
thewhaleking Mar 6, 2025
f079819
Merge branch 'staging' into fix/test-incentive
ibraheem-abe Mar 6, 2025
90107ee
Merge pull request #2722 from opentensor/fix/test-incentive
ibraheem-abe Mar 6, 2025
bd43bce
Merge branch 'staging' into feat/thewhaleking/use-uv-gh-actions
thewhaleking Mar 6, 2025
ed43f5a
Merge pull request #2503 from opentensor/feat/thewhaleking/use-uv-gh-…
thewhaleking Mar 6, 2025
a285319
Bumps async substrate
ibraheem-abe Mar 6, 2025
088e274
Merge pull request #2725 from opentensor/bump/async-substrate-interface
ibraheem-abe Mar 6, 2025
0a475a7
Bumps version and changelog - 9.0.4
ibraheem-abe Mar 6, 2025
de613ef
Merge branch 'staging' into changelog/904
ibraheem-abe Mar 6, 2025
6a8f904
Updates release workflow
ibraheem-abe Mar 6, 2025
8922cb5
Merge pull request #2726 from opentensor/changelog/904
ibraheem-abe Mar 6, 2025
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
16 changes: 10 additions & 6 deletions .github/workflows/e2e-subtensor-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
test-files: ${{ steps.get-tests.outputs.test-files }}
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Find test files
id: get-tests
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
TARGET: ${{ matrix.rust-target }}
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
uses: actions/checkout@v2
uses: actions/checkout@v4

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

- name: Install uv
uses: astral-sh/setup-uv@v4

- name: install dependencies
run: uv sync --all-extras --dev

- name: Run tests
run: |
python3 -m pip install -e .[dev] pytest
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" pytest ${{ matrix.test-file }} -s
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" uv run pytest ${{ matrix.test-file }} -s

- name: Retry failed tests
if: failure()
run: |
sleep 10
python3 -m pip install -e .[dev] pytest
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" pytest ${{ matrix.test-file }} -s
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" uv run pytest ${{ matrix.test-file }} -s
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build wheel twine
pip install setuptools wheel twine build toml

- name: Build package
run: python setup.py sdist bdist_wheel
run: python -m build --sdist --wheel --outdir dist/

- name: Check if package version already exists
run: |
PACKAGE_NAME=$(python setup.py --name)
PACKAGE_NAME=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['name'])")
PACKAGE_VERSION=${{ github.event.inputs.version }}
if twine check dist/*; then
if pip install $PACKAGE_NAME==$PACKAGE_VERSION; then
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 9.0.4 /2025-03-06

## What's Changed
* Release/9.0.3 by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2712
* improve `wait_for_node_start` until 20 mins by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2714
* More E2E tests by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2678
* fix(2715): use ChainIdentity for identities by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2718
* Metagraph use block correctly in `_get_all_stakes_from_chain` by @thewhaleking in https://github.com/opentensor/bittensor/pull/2719
* Integration tests for async-substrate-interface 1.0.4 compatibility by @thewhaleking in https://github.com/opentensor/bittensor/pull/2720
* Backmerge main staging 904 by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2721
* Skip E2E test_children by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2723
* More Subtensor unnitests by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2713
* Change to pyproject.toml by @thewhaleking in https://github.com/opentensor/bittensor/pull/2504
* Updates test_incentive by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2722
* Use uv for gh actions by @thewhaleking in https://github.com/opentensor/bittensor/pull/2503
* Bumps async substrate interface by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2725

**Full Changelog**: https://github.com/opentensor/bittensor/compare/v9.0.3...v9.0.4

## 9.0.3 /2025-02-26

## 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.3
9.0.4
92 changes: 26 additions & 66 deletions bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from functools import partial
from typing import Optional, Any, Union, Iterable, TYPE_CHECKING

import aiohttp
import asyncstdlib as a
import numpy as np
import scalecodec
Expand All @@ -28,6 +27,7 @@
decode_account_id,
DynamicInfo,
)
from bittensor.core.chain_data.chain_identity import ChainIdentity
from bittensor.core.chain_data.delegate_info import DelegatedInfo
from bittensor.core.chain_data.utils import decode_metadata
from bittensor.core.config import Config
Expand Down Expand Up @@ -68,15 +68,14 @@
reveal_weights_extrinsic,
)
from bittensor.core.metagraph import AsyncMetagraph
from bittensor.core.settings import version_as_int, TYPE_REGISTRY, DELEGATES_DETAILS_URL
from bittensor.core.settings import version_as_int, TYPE_REGISTRY
from bittensor.core.types import ParamWithTypes, SubtensorMixin
from bittensor.utils import (
Certificate,
decode_hex_identity_dict,
format_error_message,
torch,
u16_normalized_float,
_decode_hex_identity_dict,
Certificate,
u64_normalized_float,
)
from bittensor.utils.balance import (
Expand All @@ -85,7 +84,6 @@
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:
Expand Down Expand Up @@ -1079,75 +1077,33 @@ async def get_delegate_identities(
block: Optional[int] = None,
block_hash: Optional[str] = None,
reuse_block: bool = False,
) -> dict[str, "DelegatesDetails"]:
) -> dict[str, ChainIdentity]:
"""
Fetches delegates identities from the chain and GitHub. Preference is given to chain data, and missing info is
filled-in by the info from GitHub. At some point, we want to totally move away from fetching this info from
GitHub, but chain data is still limited in that regard.
Fetches delegates identities from the chain.

Arguments:
block (Optional[int]): The blockchain block number for the query.
block_hash (str): the hash of the blockchain block for the query
reuse_block (bool): Whether to reuse the last-used blockchain block hash.

Returns:
Dict {ss58: DelegatesDetails, ...}
Dict {ss58: ChainIdentity, ...}

"""
block_hash = await self.determine_block_hash(block, block_hash, reuse_block)
timeout = aiohttp.ClientTimeout(10.0)
async with aiohttp.ClientSession(timeout=timeout) as session:
identities_info, response = await asyncio.gather(
self.substrate.query_map(
module="Registry",
storage_function="IdentityOf",
block_hash=block_hash,
reuse_block_hash=reuse_block,
),
session.get(DELEGATES_DETAILS_URL),
)

all_delegates_details = {}
async for ss58_address, identity in identities_info:
all_delegates_details.update(
{
decode_account_id(
ss58_address[0]
): DelegatesDetails.from_chain_data(
decode_hex_identity_dict(identity.value["info"])
)
}
)

if response.ok:
all_delegates: dict[str, Any] = await response.json(content_type=None)

for delegate_hotkey, delegate_details in all_delegates.items():
delegate_info = all_delegates_details.setdefault(
delegate_hotkey,
DelegatesDetails(
display=delegate_details.get("name", ""),
web=delegate_details.get("url", ""),
additional=delegate_details.get("description", ""),
pgp_fingerprint=delegate_details.get("fingerprint", ""),
),
)
delegate_info.display = (
delegate_info.display or delegate_details.get("name", "")
)
delegate_info.web = delegate_info.web or delegate_details.get(
"url", ""
)
delegate_info.additional = (
delegate_info.additional
or delegate_details.get("description", "")
)
delegate_info.pgp_fingerprint = (
delegate_info.pgp_fingerprint
or delegate_details.get("fingerprint", "")
)
identities = await self.substrate.query_map(
module="SubtensorModule",
storage_function="IdentitiesV2",
block_hash=block_hash,
reuse_block_hash=reuse_block,
)

return all_delegates_details
return {
decode_account_id(ss58_address[0]): ChainIdentity.from_dict(
decode_hex_identity_dict(identity.value),
)
async for ss58_address, identity in identities
}

async def get_delegate_take(
self,
Expand Down Expand Up @@ -2424,7 +2380,7 @@ async def query_identity(
block: Optional[int] = None,
block_hash: Optional[str] = None,
reuse_block: bool = False,
) -> dict:
) -> Optional[ChainIdentity]:
"""
Queries the identity of a neuron on the Bittensor blockchain using the given key. This function retrieves
detailed identity information about a specific neuron, which is a crucial aspect of the network's
Expand Down Expand Up @@ -2455,12 +2411,16 @@ async def query_identity(
block_hash=block_hash,
reuse_block_hash=reuse_block,
)

if not identity_info:
return {}
return None

try:
return _decode_hex_identity_dict(identity_info)
return ChainIdentity.from_dict(
decode_hex_identity_dict(identity_info),
)
except TypeError:
return {}
return None

async def recycle(
self,
Expand Down
10 changes: 6 additions & 4 deletions bittensor/core/metagraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ async def sync(
await self._set_weights_and_bonds(subtensor=subtensor)

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

# apply MetagraphInfo data to instance
await self._apply_metagraph_info()
Expand Down Expand Up @@ -1566,13 +1566,14 @@ async def _process_root_weights(
)
return tensor_param

async def _get_all_stakes_from_chain(self):
async def _get_all_stakes_from_chain(self, block: int):
"""Fills in the stake associated attributes of a class instance from a chain response."""
try:
result = await self.subtensor.query_runtime_api(
runtime_api="SubnetInfoRuntimeApi",
method="get_subnet_state",
params=[self.netuid],
block=block,
)

if result is None:
Expand Down Expand Up @@ -1713,7 +1714,7 @@ def sync(
self._set_weights_and_bonds(subtensor=subtensor)

# Fills in the stake associated attributes of a class instance from a chain response.
self._get_all_stakes_from_chain()
self._get_all_stakes_from_chain(block=block)

# apply MetagraphInfo data to instance
self._apply_metagraph_info()
Expand Down Expand Up @@ -1873,13 +1874,14 @@ def _process_root_weights(
)
return tensor_param

def _get_all_stakes_from_chain(self):
def _get_all_stakes_from_chain(self, block: int):
"""Fills in the stake associated attributes of a class instance from a chain response."""
try:
result = self.subtensor.query_runtime_api(
runtime_api="SubnetInfoRuntimeApi",
method="get_subnet_state",
params=[self.netuid],
block=block,
)

if result is None:
Expand Down
5 changes: 1 addition & 4 deletions bittensor/core/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "9.0.3"
__version__ = "9.0.4"

import os
import re
Expand Down Expand Up @@ -72,9 +72,6 @@
# Wallet ss58 address length
SS58_ADDRESS_LENGTH = 48

# Raw GitHub url for delegates registry file
DELEGATES_DETAILS_URL = "https://raw.githubusercontent.com/opentensor/bittensor-delegates/main/public/delegates.json"

# Block Explorers map network to explorer url
# Must all be polkadotjs explorer urls
NETWORK_EXPLORER_MAP = {
Expand Down
Loading
Loading