diff --git a/.github/workflows/check-sdk-tests.yml b/.github/workflows/check-sdk-tests.yml index 4bcd4ff..1e2e295 100644 --- a/.github/workflows/check-sdk-tests.yml +++ b/.github/workflows/check-sdk-tests.yml @@ -229,7 +229,6 @@ jobs: git fetch origin staging python3 -m pip install --upgrade pip python3 -m pip install '.[dev]' - python3 -m pip install -r requirements/torch.txt - name: Clone async-substrate-interface repo run: git clone https://github.com/opentensor/async-substrate-interface.git diff --git a/CHANGELOG.md b/CHANGELOG.md index f1cc35d..3454ca7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 1.1.1 /2025-04-26 + +## What's Changed +* State-Safe RNG by @thewhaleking in https://github.com/opentensor/async-substrate-interface/pull/97 +* Fix tests requirements by @thewhaleking in https://github.com/opentensor/async-substrate-interface/pull/98 +* Update maintainers emails by @thewhaleking in https://github.com/opentensor/async-substrate-interface/pull/99 +* Adds additional exception for catching by @thewhaleking in https://github.com/opentensor/async-substrate-interface/pull/96 + +**Full Changelog**: https://github.com/opentensor/async-substrate-interface/compare/v1.1.0...v1.1.1 + ## 1.1.0 /2025-04-07 ## What's Changed diff --git a/async_substrate_interface/async_substrate.py b/async_substrate_interface/async_substrate.py index e8a95aa..94abf59 100644 --- a/async_substrate_interface/async_substrate.py +++ b/async_substrate_interface/async_substrate.py @@ -7,7 +7,6 @@ import asyncio import inspect import logging -import random import ssl import time from hashlib import blake2b @@ -39,6 +38,7 @@ SubstrateRequestException, ExtrinsicNotFound, BlockNotFound, + MaxRetriesExceeded, ) from async_substrate_interface.types import ( ScaleObj, @@ -48,7 +48,12 @@ SubstrateMixin, Preprocessed, ) -from async_substrate_interface.utils import hex_to_bytes, json, get_next_id +from async_substrate_interface.utils import ( + hex_to_bytes, + json, + get_next_id, + rng as random, +) from async_substrate_interface.utils.cache import async_sql_lru_cache from async_substrate_interface.utils.decoding import ( _determine_if_old_runtime_call, @@ -1910,7 +1915,7 @@ async def _make_rpc_request( logger.warning( f"Timed out waiting for RPC requests {attempt} times. Exiting." ) - raise SubstrateRequestException("Max retries reached.") + raise MaxRetriesExceeded("Max retries reached.") else: self.ws.last_received = time.time() await self.ws.connect(force=True) diff --git a/async_substrate_interface/errors.py b/async_substrate_interface/errors.py index 9de753b..98114fe 100644 --- a/async_substrate_interface/errors.py +++ b/async_substrate_interface/errors.py @@ -8,6 +8,10 @@ class SubstrateRequestException(Exception): pass +class MaxRetriesExceeded(SubstrateRequestException): + pass + + class StorageFunctionNotFound(ValueError): pass diff --git a/async_substrate_interface/sync_substrate.py b/async_substrate_interface/sync_substrate.py index f463f2f..a3a9f4d 100644 --- a/async_substrate_interface/sync_substrate.py +++ b/async_substrate_interface/sync_substrate.py @@ -1,6 +1,5 @@ import functools import logging -import random from hashlib import blake2b from typing import Optional, Union, Callable, Any @@ -21,6 +20,7 @@ ExtrinsicNotFound, SubstrateRequestException, BlockNotFound, + MaxRetriesExceeded, ) from async_substrate_interface.types import ( SubstrateMixin, @@ -30,7 +30,12 @@ Preprocessed, ScaleObj, ) -from async_substrate_interface.utils import hex_to_bytes, json, get_next_id +from async_substrate_interface.utils import ( + hex_to_bytes, + json, + get_next_id, + rng as random, +) from async_substrate_interface.utils.decoding import ( _determine_if_old_runtime_call, _bt_decode_to_dict_or_list, @@ -1611,7 +1616,7 @@ def _make_rpc_request( logger.warning( f"Timed out waiting for RPC requests {attempt} times. Exiting." ) - raise SubstrateRequestException("Max retries reached.") + raise MaxRetriesExceeded("Max retries reached.") else: return self._make_rpc_request( payloads, diff --git a/async_substrate_interface/utils/__init__.py b/async_substrate_interface/utils/__init__.py index e295e02..d0ad6eb 100644 --- a/async_substrate_interface/utils/__init__.py +++ b/async_substrate_interface/utils/__init__.py @@ -5,13 +5,15 @@ id_cycle = cycle(range(1, 999)) +rng = random.Random() + def get_next_id() -> str: """ Generates a pseudo-random ID by returning the next int of a range from 1-998 prepended with two random ascii characters. """ - random_letters = "".join(random.choices(string.ascii_letters, k=2)) + random_letters = "".join(rng.choices(string.ascii_letters, k=2)) return f"{random_letters}{next(id_cycle)}" diff --git a/pyproject.toml b/pyproject.toml index 71f0fd3..8fe5ee8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "async-substrate-interface" -version = "1.1.0" +version = "1.1.1" description = "Asyncio library for interacting with substrate. Mostly API-compatible with py-substrate-interface" readme = "README.md" license = { file = "LICENSE" } @@ -20,12 +20,12 @@ requires-python = ">=3.9,<3.14" authors = [ { name = "Opentensor Foundation" }, - { name = "BD Himes", email = "benhimes@opentensor.dev" } + { name = "BD Himes", email = "b@latent.to" } ] maintainers = [ - { name = "Opentensor Foundation", email = "benhimes@opentensor.dev" }, - { name = "BD Himes", email = "benhimes@opentensor.dev" } + { name = "Latent Holdings" }, + { name = "BD Himes", email = "b@latent.to" } ] classifiers = [