Skip to content
Merged
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
1 change: 0 additions & 1 deletion .github/workflows/check-sdk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 8 additions & 3 deletions async_substrate_interface/async_substrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import asyncio
import inspect
import logging
import random
import ssl
import time
from hashlib import blake2b
Expand Down Expand Up @@ -39,6 +38,7 @@
SubstrateRequestException,
ExtrinsicNotFound,
BlockNotFound,
MaxRetriesExceeded,
)
from async_substrate_interface.types import (
ScaleObj,
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions async_substrate_interface/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class SubstrateRequestException(Exception):
pass


class MaxRetriesExceeded(SubstrateRequestException):
pass


class StorageFunctionNotFound(ValueError):
pass

Expand Down
11 changes: 8 additions & 3 deletions async_substrate_interface/sync_substrate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import functools
import logging
import random
from hashlib import blake2b
from typing import Optional, Union, Callable, Any

Expand All @@ -21,6 +20,7 @@
ExtrinsicNotFound,
SubstrateRequestException,
BlockNotFound,
MaxRetriesExceeded,
)
from async_substrate_interface.types import (
SubstrateMixin,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion async_substrate_interface/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"


Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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" }
Expand All @@ -20,12 +20,12 @@ requires-python = ">=3.9,<3.14"

authors = [
{ name = "Opentensor Foundation" },
{ name = "BD Himes", email = "[email protected]" }
{ name = "BD Himes", email = "[email protected]" }
]

maintainers = [
{ name = "Opentensor Foundation", email = "[email protected]" },
{ name = "BD Himes", email = "[email protected]" }
{ name = "Latent Holdings" },
{ name = "BD Himes", email = "[email protected]" }
]

classifiers = [
Expand Down
Loading