Skip to content

Commit

Permalink
Merge pull request #2423 from opentensor/release/8.3.1
Browse files Browse the repository at this point in the history
Release/8.3.1
  • Loading branch information
roman-opentensor authored Nov 14, 2024
2 parents 3b25a0b + 82eecbc commit ae02978
Show file tree
Hide file tree
Showing 10 changed files with 633 additions and 107 deletions.
23 changes: 0 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,19 +275,6 @@ jobs:
command: |
[[ $(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"
release-dry-run:
docker:
- image: cimg/python:3.10
steps:
- checkout
- setup_remote_docker:
version: 20.10.14
docker_layer_caching: true
- run:
name: Executing release script
command: |
./scripts/release/release.sh --github-token ${GH_API_ACCESS_TOKEN}
workflows:
compatibility_checks:
jobs:
Expand Down Expand Up @@ -339,11 +326,6 @@ workflows:
branches:
only:
- /^(release|hotfix)/.*/
- release-dry-run:
filters:
branches:
only:
- /^(release|hotfix)/.*/

release-requirements:
jobs:
Expand All @@ -352,8 +334,3 @@ workflows:
branches:
only:
- master
- release-dry-run:
filters:
branches:
only:
- master
45 changes: 44 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
# Changelog

## 8.3.1 /2024-11-14

## What's Changed
* Fixes broken Subtensor methods by @thewhaleking in https://github.com/opentensor/bittensor/pull/2420
* [Tests] AsyncSubtensor (Part 7: The final race) by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2418

**Full Changelog**: https://github.com/opentensor/bittensor/compare/v8.3.0...v8.3.1

## 8.3.0 /2024-11-13

## What's Changed
* Expands the type registry to include all the available options by @thewhaleking in https://github.com/opentensor/bittensor/pull/2353
* add `Subtensor.register`, `Subtensor.difficulty` and related staff with tests by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2352
* added to Subtensor: `burned_register`, `get_subnet_burn_cost`, `recycle` and related extrinsics by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2359
* Poem "Risen from the Past". Act 3. by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2363
* default port from 9946 to 9944 by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2376
* remove unused prometheus extrinsic by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2378
* Replace rich.console to btlogging.loggin by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2377
* SDK (AsyncSubtensor) Part 1 by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2374
* SDK (AsyncSubtensor) Part 2 by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2380
* Handle SSL Error on Connection by @thewhaleking in https://github.com/opentensor/bittensor/pull/2384
* Avoid using `prompt` in SDK by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2382
* Backmerge/8.2.0 by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2389
* Remove `retry` and fix tests by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2392
* fix: logging weights correctly in utils/weight_utils.py by @grantdfoster in https://github.com/opentensor/bittensor/pull/2362
* Add `subvortex` subnet and tests by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2395
* Release/8.2.1 by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2397
* [Tests] AsyncSubtensor (Part 1) by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2398
* Extend period for fastblock e2e tests_incentive.py by @opendansor in https://github.com/opentensor/bittensor/pull/2400
* Remove unused import by @thewhaleking in https://github.com/opentensor/bittensor/pull/2401
* `Reconnection substrate...` as debug by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2403
* Handles websockets v14+ in async by @thewhaleking in https://github.com/opentensor/bittensor/pull/2404
* [Tests] AsyncSubtensor (Part 2) by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2407
* [Tests] AsyncSubtensor (Part 3) by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2409
* Handle new PasswordError from btwallet by @thewhaleking in https://github.com/opentensor/bittensor/pull/2406
* [Tests] AsyncSubtensor (Part 4) by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2410
* [Tests] AsyncSubtensor (Part 5) by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2411
* Bringing back lost methods for setting weights by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2412
* Update bt-decode requirement by @thewhaleking in https://github.com/opentensor/bittensor/pull/2413
* [Tests] AsyncSubtensor (Part 6) by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2414

**Full Changelog**: https://github.com/opentensor/bittensor/compare/v8.2.1...v8.3.0

## 8.2.1 /2024-11-06

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

### Synapse update

##
##
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.3.0
8.3.1
55 changes: 17 additions & 38 deletions bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
format_error_message,
decode_hex_identity_dict,
validate_chain_endpoint,
hex_to_bytes,
)
from bittensor.utils.async_substrate_interface import (
AsyncSubstrateInterface,
Expand Down Expand Up @@ -351,12 +352,7 @@ async def get_delegates(
reuse_block=reuse_block,
)
if hex_bytes_result is not None:
try:
bytes_result = bytes.fromhex(hex_bytes_result[2:])
except ValueError:
bytes_result = bytes.fromhex(hex_bytes_result)

return DelegateInfo.list_from_vec_u8(bytes_result)
return DelegateInfo.list_from_vec_u8(hex_to_bytes(hex_bytes_result))
else:
return []

Expand Down Expand Up @@ -392,12 +388,7 @@ async def get_stake_info_for_coldkey(
if hex_bytes_result is None:
return []

try:
bytes_result = bytes.fromhex(hex_bytes_result[2:])
except ValueError:
bytes_result = bytes.fromhex(hex_bytes_result)

return StakeInfo.list_from_vec_u8(bytes_result)
return StakeInfo.list_from_vec_u8(hex_to_bytes(hex_bytes_result))

async def get_stake_for_coldkey_and_hotkey(
self, hotkey_ss58: str, coldkey_ss58: str, block_hash: Optional[str] = None
Expand Down Expand Up @@ -853,12 +844,7 @@ async def neurons_lite(
if hex_bytes_result is None:
return []

try:
bytes_result = bytes.fromhex(hex_bytes_result[2:])
except ValueError:
bytes_result = bytes.fromhex(hex_bytes_result)

return NeuronInfoLite.list_from_vec_u8(bytes_result)
return NeuronInfoLite.list_from_vec_u8(hex_to_bytes(hex_bytes_result))

async def neuron_for_uid(
self, uid: Optional[int], netuid: int, block_hash: Optional[str] = None
Expand Down Expand Up @@ -1170,12 +1156,7 @@ async def get_subnet_hyperparameters(
if hex_bytes_result is None:
return []

if hex_bytes_result.startswith("0x"):
bytes_result = bytes.fromhex(hex_bytes_result[2:])
else:
bytes_result = bytes.fromhex(hex_bytes_result)

return SubnetHyperparameters.from_vec_u8(bytes_result)
return SubnetHyperparameters.from_vec_u8(hex_to_bytes(hex_bytes_result))

async def get_vote_data(
self,
Expand Down Expand Up @@ -1422,15 +1403,15 @@ async def register(

async def pow_register(
self: "AsyncSubtensor",
wallet: Wallet,
netuid,
processors,
update_interval,
output_in_place,
verbose,
use_cuda,
dev_id,
threads_per_block,
wallet: "Wallet",
netuid: int,
processors: int,
update_interval: int,
output_in_place: bool,
verbose: bool,
use_cuda: bool,
dev_id: Union[list[int], int],
threads_per_block: int,
):
"""Register neuron."""
return await register_extrinsic(
Expand Down Expand Up @@ -1481,11 +1462,9 @@ async def set_weights(
retries = 0
success = False
message = "No attempt made. Perhaps it is too soon to set weights!"
while (
await self.blocks_since_last_update(netuid, uid)
> await self.weights_rate_limit(netuid)
and retries < max_retries
):
while retries < max_retries and await self.blocks_since_last_update(
netuid, uid
) > await self.weights_rate_limit(netuid):
try:
logging.info(
f"Setting weights for subnet #<blue>{netuid}</blue>. Attempt <blue>{retries + 1} of {max_retries}</blue>."
Expand Down
2 changes: 1 addition & 1 deletion bittensor/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

__version__ = "8.3.0"
__version__ = "8.3.1"

import os
import re
Expand Down
51 changes: 22 additions & 29 deletions bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@
transfer_extrinsic,
)
from bittensor.core.metagraph import Metagraph
from bittensor.utils import networking, torch, ss58_to_vec_u8, u16_normalized_float
from bittensor.utils import (
networking,
torch,
ss58_to_vec_u8,
u16_normalized_float,
hex_to_bytes,
)
from bittensor.utils.balance import Balance
from bittensor.utils.btlogging import logging
from bittensor.utils.registration import legacy_torch_api_compat
Expand Down Expand Up @@ -523,13 +529,11 @@ def query_runtime_api(
return None

return_type = call_definition["type"]

as_scale_bytes = scalecodec.ScaleBytes(json_result["result"])

rpc_runtime_config = RuntimeConfiguration()
rpc_runtime_config.update_type_registry(load_type_registry_preset("legacy"))
rpc_runtime_config.update_type_registry(custom_rpc_type_registry)

obj = rpc_runtime_config.create_scale_object(return_type, as_scale_bytes)
if obj.data.to_hex() == "0x0400": # RPC returned None result
return None
Expand Down Expand Up @@ -1227,12 +1231,7 @@ def get_subnet_hyperparameters(
if hex_bytes_result is None:
return []

if hex_bytes_result.startswith("0x"):
bytes_result = bytes.fromhex(hex_bytes_result[2:])
else:
bytes_result = bytes.fromhex(hex_bytes_result)

return SubnetHyperparameters.from_vec_u8(bytes_result)
return SubnetHyperparameters.from_vec_u8(hex_to_bytes(hex_bytes_result))

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

metadata = get_metadata(self, netuid, hotkey, block)
commitment = metadata["info"]["fields"][0] # type: ignore
hex_data = commitment[list(commitment.keys())[0]][2:] # type: ignore
try:
commitment = metadata["info"]["fields"][0] # type: ignore
hex_data = commitment[list(commitment.keys())[0]][2:] # type: ignore
return bytes.fromhex(hex_data).decode()

return bytes.fromhex(hex_data).decode()
except TypeError:
return ""

# Community uses this via `bittensor.utils.weight_utils.process_weights_for_netuid` function.
def min_allowed_weights(
Expand Down Expand Up @@ -1367,7 +1369,7 @@ def get_prometheus_info(
Optional[bittensor.core.chain_data.prometheus_info.PrometheusInfo]: A PrometheusInfo object containing the prometheus information, or ``None`` if the prometheus information is not found.
"""
result = self.query_subtensor("Prometheus", block, [netuid, hotkey_ss58])
if result is not None and hasattr(result, "value"):
if result is not None and getattr(result, "value", None) is not None:
return PrometheusInfo(
ip=networking.int_to_ip(result.value["ip"]),
ip_type=result.value["ip_type"],
Expand Down Expand Up @@ -1407,17 +1409,13 @@ def get_all_subnets_info(self, block: Optional[int] = None) -> list[SubnetInfo]:
Gaining insights into the subnets' details assists in understanding the network's composition, the roles of different subnets, and their unique features.
"""
block_hash = None if block is None else self.substrate.get_block_hash(block)

json_body = self.substrate.rpc_request(
method="subnetInfo_getSubnetsInfo", # custom rpc method
params=[block_hash] if block_hash else [],
hex_bytes_result = self.query_runtime_api(
"SubnetInfoRuntimeApi", "get_subnets_info", params=[], block=block
)

if not (result := json_body.get("result", None)):
if not hex_bytes_result:
return []

return SubnetInfo.list_from_vec_u8(result)
else:
return SubnetInfo.list_from_vec_u8(hex_to_bytes(hex_bytes_result))

# Metagraph uses this method
def bonds(
Expand Down Expand Up @@ -1561,12 +1559,7 @@ def neurons_lite(
if hex_bytes_result is None:
return []

if hex_bytes_result.startswith("0x"):
bytes_result = bytes.fromhex(hex_bytes_result[2:])
else:
bytes_result = bytes.fromhex(hex_bytes_result)

return NeuronInfoLite.list_from_vec_u8(bytes_result) # type: ignore
return NeuronInfoLite.list_from_vec_u8(hex_to_bytes(hex_bytes_result)) # type: ignore

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

return DelegateInfo.from_vec_u8(result)
return DelegateInfo.from_vec_u8(bytes(result))

# Subnet 27 uses this method name
_do_serve_axon = do_serve_axon
11 changes: 11 additions & 0 deletions bittensor/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,14 @@ def unlock_key(wallet: "Wallet", unlock_type="coldkey") -> "UnlockStatus":
except KeyFileError:
err_msg = f"{unlock_type.capitalize()} keyfile is corrupt, non-writable, or non-readable, or non-existent."
return UnlockStatus(False, err_msg)


def hex_to_bytes(hex_str: str) -> bytes:
"""
Converts a hex-encoded string into bytes. Handles 0x-prefixed and non-prefixed hex-encoded strings.
"""
if hex_str.startswith("0x"):
bytes_result = bytes.fromhex(hex_str[2:])
else:
bytes_result = bytes.fromhex(hex_str)
return bytes_result
Loading

0 comments on commit ae02978

Please sign in to comment.