diff --git a/bittensor/utils/async_substrate_interface.py b/bittensor/utils/async_substrate_interface.py index de0547e7b..46fcc9347 100644 --- a/bittensor/utils/async_substrate_interface.py +++ b/bittensor/utils/async_substrate_interface.py @@ -6,10 +6,10 @@ from hashlib import blake2b from typing import Optional, Any, Union, Callable, Awaitable, cast -import websockets from async_property import async_property from bittensor_wallet import Keypair from bt_decode import PortableRegistry, decode as decode_by_type_string, MetadataV15 +from packaging import version from scalecodec import GenericExtrinsic from scalecodec.base import ScaleBytes, ScaleType, RuntimeConfigurationObject from scalecodec.type_registry import load_type_registry_preset @@ -20,6 +20,7 @@ BlockNotFound, ) from substrateinterface.storage import StorageKey +import websockets ResultHandler = Callable[[dict, Any], Awaitable[tuple[dict, bool]]] @@ -768,14 +769,13 @@ def __init__( """ self.chain_endpoint = chain_endpoint self.__chain = chain_name - self.ws = Websocket( - chain_endpoint, - options={ - "max_size": 2**32, - "read_limit": 2**16, - "write_limit": 2**16, - }, - ) + options = { + "max_size": 2**32, + "write_limit": 2**16, + } + if version.parse(websockets.__version__) < version.parse("14.0"): + options.update({"read_limit": 2**16}) + self.ws = Websocket(chain_endpoint, options=options) self._lock = asyncio.Lock() self.last_block_hash: Optional[str] = None self.config = { diff --git a/requirements/prod.txt b/requirements/prod.txt index bb8e24394..7ba565211 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -24,4 +24,5 @@ python-Levenshtein scalecodec==1.2.11 substrate-interface~=1.7.9 uvicorn +websockets>12.0 bittensor-wallet>=2.0.2