diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index 87c11998e..0956de62c 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -7,6 +7,7 @@ import re import ssl import sys +import traceback from pathlib import Path from typing import Coroutine, Optional from dataclasses import fields @@ -840,6 +841,7 @@ async def _run(): return result except (ConnectionRefusedError, ssl.SSLError): err_console.print(f"Unable to connect to the chain: {self.subtensor}") + verbose_console.print(traceback.format_exc()) except ( ConnectionClosed, SubstrateRequestException, @@ -847,6 +849,10 @@ async def _run(): ) as e: if isinstance(e, SubstrateRequestException): err_console.print(str(e)) + verbose_console.print(traceback.format_exc()) + except Exception as e: + err_console.print(f"An unknown error has occurred: {e}") + verbose_console.print(traceback.format_exc()) finally: if initiated is False: asyncio.create_task(cmd).cancel() diff --git a/bittensor_cli/src/bittensor/async_substrate_interface.py b/bittensor_cli/src/bittensor/async_substrate_interface.py index bd6bbb987..08e0cc9ba 100644 --- a/bittensor_cli/src/bittensor/async_substrate_interface.py +++ b/bittensor_cli/src/bittensor/async_substrate_interface.py @@ -6,13 +6,14 @@ from hashlib import blake2b from typing import Optional, Any, Union, Callable, Awaitable, cast -from bt_decode import PortableRegistry, decode as decode_by_type_string, MetadataV15 from async_property import async_property +from bt_decode import PortableRegistry, decode as decode_by_type_string, MetadataV15 +from bittensor_wallet import Keypair +from packaging import version from scalecodec import GenericExtrinsic from scalecodec.base import ScaleBytes, ScaleType, RuntimeConfigurationObject from scalecodec.type_registry import load_type_registry_preset from scalecodec.types import GenericCall -from bittensor_wallet import Keypair from substrateinterface.exceptions import ( SubstrateRequestException, ExtrinsicNotFound, @@ -771,14 +772,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.txt b/requirements.txt index 2e891bcf3..fbe806998 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,7 @@ fuzzywuzzy~=0.18.0 netaddr~=1.3.0 numpy>=2.0.1 Jinja2 +packaging pycryptodome # Crypto PyYAML~=6.0.1 pytest