From 43af654d4de89c1d2f92c71a15d20e0e6e914ba1 Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Tue, 12 Nov 2024 10:39:26 +0200 Subject: [PATCH 1/5] Bump websockets version. --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 2e891bcf..01b6f37f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,6 +15,6 @@ rich~=13.7 scalecodec==1.2.11 substrate-interface~=1.7.9 typer~=0.12 -websockets>=12.0 +websockets>=13.0 bittensor-wallet>=2.0.2 bt-decode==0.2.0a0 \ No newline at end of file From 8a5fb9c741d41c258eecfa0963069e99286c44a3 Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Tue, 12 Nov 2024 10:45:56 +0200 Subject: [PATCH 2/5] Bump websockets version. --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 01b6f37f..7c36e926 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,6 +15,6 @@ rich~=13.7 scalecodec==1.2.11 substrate-interface~=1.7.9 typer~=0.12 -websockets>=13.0 +websockets>=13.1 bittensor-wallet>=2.0.2 bt-decode==0.2.0a0 \ No newline at end of file From 1acb46ead54260a46c61f08ed93fc036aa1ebf9b Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Tue, 12 Nov 2024 14:02:07 +0200 Subject: [PATCH 3/5] Bump websockets version. --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7c36e926..d48e7148 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,6 +15,6 @@ rich~=13.7 scalecodec==1.2.11 substrate-interface~=1.7.9 typer~=0.12 -websockets>=13.1 +websockets>=12.0,<14.0 bittensor-wallet>=2.0.2 bt-decode==0.2.0a0 \ No newline at end of file From 54e6a90a8d89e4baa9cc5f4859db4495a408ba27 Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Tue, 12 Nov 2024 16:43:40 +0200 Subject: [PATCH 4/5] Add the ability to verbosely show error tracebacks. --- bittensor_cli/cli.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index 87c11998..0956de62 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() From fb659bcc426fed1eb8fe5dca9846a8304bd457d9 Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Tue, 12 Nov 2024 17:02:35 +0200 Subject: [PATCH 5/5] Handle websockets>=14.0 rather than requiring it to be less than it. --- .../bittensor/async_substrate_interface.py | 20 +++++++++---------- requirements.txt | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/bittensor_cli/src/bittensor/async_substrate_interface.py b/bittensor_cli/src/bittensor/async_substrate_interface.py index bd6bbb98..08e0cc9b 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 d48e7148..fbe80699 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 @@ -15,6 +16,6 @@ rich~=13.7 scalecodec==1.2.11 substrate-interface~=1.7.9 typer~=0.12 -websockets>=12.0,<14.0 +websockets>=12.0 bittensor-wallet>=2.0.2 bt-decode==0.2.0a0 \ No newline at end of file