From 8c69a3c15cd556384d0309e951f0a9b164dd36cb Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Fri, 1 Dec 2023 06:12:37 +0000 Subject: [PATCH 01/11] revert subtensor local to finney --- bittensor/subtensor.py | 13 +++++++---- .../test_subtensor_integration.py | 23 ++++--------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/bittensor/subtensor.py b/bittensor/subtensor.py index 20dc254599..772aa7bbff 100644 --- a/bittensor/subtensor.py +++ b/bittensor/subtensor.py @@ -109,8 +109,8 @@ class subtensor: investments. Attributes: - network (str): The name of the Bittensor network (e.g., 'finney', 'local') the instance is - connected to, determining the blockchain interaction context. + network (str): The name of the Bittensor network (e.g., 'finney', 'test', 'archive', 'local') the instance + is connected to, determining the blockchain interaction context. chain_endpoint (str): The blockchain node endpoint URL, enabling direct communication with the Bittensor blockchain for transaction processing and data retrieval. @@ -154,18 +154,20 @@ def help(cls): def add_args(cls, parser: argparse.ArgumentParser, prefix: str = None): prefix_str = "" if prefix == None else prefix + "." try: - default_network = os.getenv("BT_SUBTENSOR_NETWORK") or "local" + default_network = os.getenv("BT_SUBTENSOR_NETWORK") or "finney" default_chain_endpoint = ( os.getenv("BT_SUBTENSOR_CHAIN_ENDPOINT") - or bittensor.__local_entrypoint__ + or bittensor.__finney_entrypoint__ ) parser.add_argument( "--" + prefix_str + "subtensor.network", default=default_network, type=str, help="""The subtensor network flag. The likely choices are: - -- local (local running network) -- finney (main network) + -- test (test network) + -- archive (archive network +300 blocks) + -- local (local running network) If this option is set it overloads subtensor.chain_endpoint with an entry point node from that network. """, @@ -195,6 +197,7 @@ def determine_chain_endpoint_and_network(network: str): Args: network (str): The network flag. The likely choices are: -- finney (main network) + -- archive (archive network +300 blocks) -- local (local running network) -- test (test network) chain_endpoint (str): The chain endpoint flag. If set, overrides the network argument. diff --git a/tests/integration_tests/test_subtensor_integration.py b/tests/integration_tests/test_subtensor_integration.py index a01ee90ddd..ab00e903e5 100644 --- a/tests/integration_tests/test_subtensor_integration.py +++ b/tests/integration_tests/test_subtensor_integration.py @@ -587,25 +587,10 @@ class ExitEarly(Exception): msg="only tries to submit once, then exits", ) - @staticmethod - def is_port_open(host, port): - """Check if a port is open on a given host.""" - with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - return s.connect_ex((host, port)) == 0 - - def test_defaults_to_local(self): - port = int( - bittensor.__local_entrypoint__.split(":")[-1] - ) # Default port for local subtensor - if self.is_port_open("127.0.0.1", port): - # If service is running, check default values - sub = bittensor.subtensor() - self.assertEqual(sub.network, "local") - self.assertEqual(sub.chain_endpoint, bittensor.__local_entrypoint__) - else: - # If service is not running, expect a ConnectionRefusedError - with self.assertRaises(ConnectionRefusedError): - bittensor.subtensor() + def test_defaults_to_finney(self): + sub = bittensor.subtensor() + assert sub.network == "finney" + assert sub.chain_endpoint == bittensor.__finney_entrypoint__ if __name__ == "__main__": From 85178b9d206692bfdfa9c46dae3aac8aeb2847c2 Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Fri, 1 Dec 2023 07:40:44 +0000 Subject: [PATCH 02/11] hotfix patch version --- VERSION | 2 +- bittensor/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 19b860c187..306894a15e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.4.0 +6.4.1 \ No newline at end of file diff --git a/bittensor/__init__.py b/bittensor/__init__.py index 72fd3a0654..196f632ce4 100644 --- a/bittensor/__init__.py +++ b/bittensor/__init__.py @@ -27,7 +27,7 @@ nest_asyncio.apply() # Bittensor code and protocol version. -__version__ = "6.4.0" +__version__ = "6.4.1" version_split = __version__.split(".") __version_as_int__ = ( (100 * int(version_split[0])) From fbd5c90d8cd826f5b965648c0b9764184687a870 Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Fri, 1 Dec 2023 07:44:03 +0000 Subject: [PATCH 03/11] run changelog script --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6935553b55..6a6d08c1b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## 6.4.1 / 2023-12-01 + +## What's Changed +* Release/6.1.0 by @ifrit98 in https://github.com/opentensor/bittensor/pull/1550 +* Release/6.2.0 by @ifrit98 in https://github.com/opentensor/bittensor/pull/1567 +* Release/6.3.0 by @ifrit98 in https://github.com/opentensor/bittensor/pull/1582 +* Release/6.4.0 by @ifrit98 in https://github.com/opentensor/bittensor/pull/1599 + + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.0.1...v6.4.1 + + ## 6.4.0 / 2023-11-29 ## What's Changed From 86c0c3ccfcd91d0e3ff87f53bdc3e9c5e68661da Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Fri, 1 Dec 2023 11:09:06 -0500 Subject: [PATCH 04/11] add helpful messages to signal the coming change and fallback to finney if local fails --- bittensor/subtensor.py | 63 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/bittensor/subtensor.py b/bittensor/subtensor.py index 772aa7bbff..f432b170cb 100644 --- a/bittensor/subtensor.py +++ b/bittensor/subtensor.py @@ -302,6 +302,13 @@ def __init__( """ Initializes a Subtensor interface for interacting with the Bittensor blockchain. + NOTE: Currently subtensor defaults to the finney network. This will change in a future release. + + We strongly encourage users to run their own local subtensor node whenever possible. This increases + decentralization and resilience of the network. In a future release, local subtensor will become the + default and the fallback to finney removed. Please plan ahead for this change. We will provide detailed + instructions on how to run a local subtensor node in the documentation in a subsequent release. + Args: network (str, optional): The network name to connect to (e.g., 'finney', 'local'). Defaults to the main Bittensor network if not specified. @@ -323,6 +330,21 @@ def __init__( # Setup config.subtensor.network and config.subtensor.chain_endpoint self.chain_endpoint, self.network = subtensor.setup_config(network, config) + if ( + self.network == "finney" + or self.chain_endpoint == bittensor.__finney_entrypoint__ + ): + bittensor.logging.info( + f"You are connecting to {self.network} network with endpoint {self.chain_endpoint}." + ) + bittensor.logging.warning( + "We strongly encourage running a local subtensor node whenever possible. " + "This increases decentralization and resilience of the network." + ) + bittensor.logging.warning( + "In a future release, local subtensor will become the default and the fallback to finney removed." + ) + # Returns a mocked connection with a background chain connection. self.config.subtensor._mock = ( _mock @@ -333,12 +355,41 @@ def __init__( config.subtensor._mock = True return bittensor.subtensor_mock.MockSubtensor() - # Set up params. - self.substrate = SubstrateInterface( - ss58_format=bittensor.__ss58_format__, - use_remote_preset=True, - url=self.chain_endpoint, - type_registry=bittensor.__type_registry__, + # Attempt to connect to chosen endpoint. Fallback to finney if local unavailable. + try: + # Set up params. + self.substrate = SubstrateInterface( + ss58_format=bittensor.__ss58_format__, + use_remote_preset=True, + url=self.chain_endpoint, + type_registry=bittensor.__type_registry__, + ) + except ConnectionRefusedError as e: + bittensor.logging.error( + f"Could not connect to {self.network} network with {self.chain_endpoint} chain endpoint." + ) + bittensor.logging.warning( + f"You can check if you have connectivity by runing this command: nc -vz localhost {self.chain_endpoint.split(':')[2]}" + ) + bittensor.logging.warning( + f"Falling back to finney at {bittensor.__finney_entrypoint__}" + ) + bittensor.logging.warning( + f"Note: This will become an error in a future release by removing the fallback to finney." + ) + + self.substrate = SubstrateInterface( + ss58_format=bittensor.__ss58_format__, + use_remote_preset=True, + url=bittensor.__finney_entrypoint__, + type_registry=bittensor.__type_registry__, + ) + self.network = "finney" + self.chain_endpoint = bittensor.__finney_entrypoint__ + # TODO (edu/phil): Advise to run local subtensor and point to dev docs. + + bittensor.logging.info( + f"Connected to {self.network} network and {self.chain_endpoint}." ) def __str__(self) -> str: From 3e47889f7f2b903d65fcc6dee5787b1bb9a0e1c2 Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Fri, 1 Dec 2023 11:47:35 -0500 Subject: [PATCH 05/11] add btcli subtensor check command for quick info on network health --- bittensor/cli.py | 10 ++++ bittensor/commands/__init__.py | 1 + bittensor/commands/subtensor.py | 96 +++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 bittensor/commands/subtensor.py diff --git a/bittensor/cli.py b/bittensor/cli.py index fae049c34d..e99bd300f9 100644 --- a/bittensor/cli.py +++ b/bittensor/cli.py @@ -42,6 +42,8 @@ "wallets": "wallet", "stakes": "stake", "sudos": "sudo", + "subtensor": "subtensor", + "sub": "subtensor", } COMMANDS = { "subnets": { @@ -131,6 +133,14 @@ "faucet": RunFaucetCommand, }, }, + "subtensor": { + "name": "subtensor", + "aliases": ["sub"], + "help": "Commands for checking the connectivity status of Bittensor network endpoints.", + "commands": { + "check": CheckEndpointCommand, + }, + }, } diff --git a/bittensor/commands/__init__.py b/bittensor/commands/__init__.py index 71cecd4244..4146babc17 100644 --- a/bittensor/commands/__init__.py +++ b/bittensor/commands/__init__.py @@ -118,3 +118,4 @@ RootSetSlashCommand, ) from .identity import GetIdentityCommand, SetIdentityCommand +from .subtensor import CheckEndpointCommand diff --git a/bittensor/commands/subtensor.py b/bittensor/commands/subtensor.py new file mode 100644 index 0000000000..f1a5745604 --- /dev/null +++ b/bittensor/commands/subtensor.py @@ -0,0 +1,96 @@ +from rich.console import Console +from rich.table import Table +import requests +import bittensor +import argparse +import subprocess +import re + + +class CheckEndpointCommand: + """ + CheckEndpointCommand checks the network connectivity status of predefined Bittensor network endpoints. + + This command is used to diagnose connection issues and ensure that the specified endpoints are reachable + over the network. It uses the `nc` (netcat) command-line utility to perform a simple test on each endpoint. + + The command aggregates and displays the results in a table format using the `rich` library, providing + a clear and color-coded status for each endpoint. The table includes the network name, endpoint URL, + connectivity status, and any messages returned by the `nc` command. + + Usage: + This class is intended to be used as a command within the Bittensor CLI. It can be invoked by + running the CLI with the `check` command: + + ``` + btcli subtensor check + ``` + ┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ + ┃ Network ┃ Endpoint ┃ Status ┃ Message ┃ + ┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ + │ local │ ws://127.0.0.1:9944 │ Failed │ nc: connectx to 127.0.0.1 port 9944 (tcp) failed: Connection refused │ + │ finney │ wss://entrypoint-finney.opentensor.ai:443 │ Success │ Connection to entrypoint-finney.opentensor.ai port 443 succeeded! │ + │ test │ wss://test.finney.opentensor.ai:443/ │ Success │ Connection to test.finney.opentensor.ai port 443 succeeded! │ + │ archive │ wss://archive.chain.opentensor.ai:443/ │ Success │ Connection to archive.chain.opentensor.ai port 443 succeeded! │ + └──────────────┴───────────────────────────────────────────┴─────────┴──────────────────────────────────────────────────────────────────────┘ + + Note: + This command assumes that the `nc` command is available in the system's environment where the CLI + is executed. It also assumes that the endpoints defined in the `endpoints` dictionary are in the + correct format and the `rich` library is available for displaying the output table. + """ + + @staticmethod + def run(cli): + console = bittensor.__console__ + + endpoints = { + "local": bittensor.__local_entrypoint__, + "finney": bittensor.__finney_entrypoint__, + "test": bittensor.__finney_test_entrypoint__, + "archive": bittensor.__archive_entrypoint__, + } + + table = Table(show_header=True, header_style="bold magenta") + table.add_column("Network", style="dim", width=12) + table.add_column("Endpoint") + table.add_column("Status") + table.add_column("Message") + + # Regular expression to extract hostname and port from URL + url_pattern = re.compile(r"(?:wss?://)?([^:/]+)(?::(\d+))?") + + # Iterate over the endpoints and check connectivity + for network, url in endpoints.items(): + match = url_pattern.match(url) + if match: + host, port = match.groups() + port = port or ( + "443" if url.startswith("wss://") else "80" + ) # Default ports for wss and ws respectively + result = subprocess.run( + ["nc", "-vz", host, port], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if result.returncode == 0: + status = "[green]Success[/green]" + else: + status = f"[red]Failed[/red]" + else: + status = "[red]Error: Invalid URL[/red]" + table.add_row(network, url, status, result.stdout.strip()) + + console.print(table) + + @staticmethod + def add_args(parser: argparse.ArgumentParser): + check_parser = parser.add_parser( + "check", help="Check connectivity with Bittensor network endpoints." + ) + # No additional arguments needed for this command. + + @staticmethod + def check_config(config: argparse.Namespace): + pass From 17b0ee22012e6bf72bc47dd1d56fd7409d1ae190 Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Fri, 1 Dec 2023 11:52:36 -0500 Subject: [PATCH 06/11] correct changelog --- CHANGELOG.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a6d08c1b1..9683a86df2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,9 @@ ## 6.4.1 / 2023-12-01 ## What's Changed -* Release/6.1.0 by @ifrit98 in https://github.com/opentensor/bittensor/pull/1550 -* Release/6.2.0 by @ifrit98 in https://github.com/opentensor/bittensor/pull/1567 -* Release/6.3.0 by @ifrit98 in https://github.com/opentensor/bittensor/pull/1582 -* Release/6.4.0 by @ifrit98 in https://github.com/opentensor/bittensor/pull/1599 - +* add btcli subtensor check command for quick info on network health in https://github.com/opentensor/bittensor/pull/1600/commits/3e47889f7f2b903d65fcc6dee5787b1bb9a0e1c2 +* add helpful messages to signal coming changes & fallback to finney in https://github.com/opentensor/bittensor/pull/1600/commits/86c0c3ccfcd91d0e3ff87f53bdc3e9c5e68661da +* revert default subtensor network to finney in https://github.com/opentensor/bittensor/pull/1600/commits/8c69a3c15cd556384d0309e951f0a9b164dd36cb **Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.0.1...v6.4.1 From 68d5dbffe71f07bd8d39e4a2142529a3bc0a3990 Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Fri, 1 Dec 2023 11:59:50 -0500 Subject: [PATCH 07/11] add endpoint arg for custom endpoints --- bittensor/commands/subtensor.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bittensor/commands/subtensor.py b/bittensor/commands/subtensor.py index f1a5745604..e324309b4b 100644 --- a/bittensor/commands/subtensor.py +++ b/bittensor/commands/subtensor.py @@ -51,6 +51,9 @@ def run(cli): "archive": bittensor.__archive_entrypoint__, } + if cli.config.endpoint: + endpoints.update({"custom": cli.config.endpoint}) + table = Table(show_header=True, header_style="bold magenta") table.add_column("Network", style="dim", width=12) table.add_column("Endpoint") @@ -89,8 +92,15 @@ def add_args(parser: argparse.ArgumentParser): check_parser = parser.add_parser( "check", help="Check connectivity with Bittensor network endpoints." ) - # No additional arguments needed for this command. + check_parser.add_argument( + "--endpoint", + type=str, + help="Endpoint to check connectivity with.", + ) @staticmethod def check_config(config: argparse.Namespace): - pass + if config.endpoint: + # If endpoint is specified, check that it is a valid URL + if not re.match(r"(?:wss?://)?[^:/]+(?::\d+)?", config.endpoint): + raise ValueError("Invalid endpoint URL") From f941b1f7282a4a6fbd615ae029117a58b286fc2b Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Fri, 1 Dec 2023 12:07:49 -0500 Subject: [PATCH 08/11] Revert "add btcli subtensor check command for quick info on network health" This reverts commit 3e47889f7f2b903d65fcc6dee5787b1bb9a0e1c2. --- bittensor/cli.py | 10 ---------- bittensor/commands/__init__.py | 1 - 2 files changed, 11 deletions(-) diff --git a/bittensor/cli.py b/bittensor/cli.py index e99bd300f9..fae049c34d 100644 --- a/bittensor/cli.py +++ b/bittensor/cli.py @@ -42,8 +42,6 @@ "wallets": "wallet", "stakes": "stake", "sudos": "sudo", - "subtensor": "subtensor", - "sub": "subtensor", } COMMANDS = { "subnets": { @@ -133,14 +131,6 @@ "faucet": RunFaucetCommand, }, }, - "subtensor": { - "name": "subtensor", - "aliases": ["sub"], - "help": "Commands for checking the connectivity status of Bittensor network endpoints.", - "commands": { - "check": CheckEndpointCommand, - }, - }, } diff --git a/bittensor/commands/__init__.py b/bittensor/commands/__init__.py index 4146babc17..71cecd4244 100644 --- a/bittensor/commands/__init__.py +++ b/bittensor/commands/__init__.py @@ -118,4 +118,3 @@ RootSetSlashCommand, ) from .identity import GetIdentityCommand, SetIdentityCommand -from .subtensor import CheckEndpointCommand From b5067a3967d83d8a47a4fb9e3baf9b488c4d2168 Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Fri, 1 Dec 2023 12:09:59 -0500 Subject: [PATCH 09/11] delete subtensor check command file --- bittensor/commands/subtensor.py | 106 -------------------------------- 1 file changed, 106 deletions(-) delete mode 100644 bittensor/commands/subtensor.py diff --git a/bittensor/commands/subtensor.py b/bittensor/commands/subtensor.py deleted file mode 100644 index e324309b4b..0000000000 --- a/bittensor/commands/subtensor.py +++ /dev/null @@ -1,106 +0,0 @@ -from rich.console import Console -from rich.table import Table -import requests -import bittensor -import argparse -import subprocess -import re - - -class CheckEndpointCommand: - """ - CheckEndpointCommand checks the network connectivity status of predefined Bittensor network endpoints. - - This command is used to diagnose connection issues and ensure that the specified endpoints are reachable - over the network. It uses the `nc` (netcat) command-line utility to perform a simple test on each endpoint. - - The command aggregates and displays the results in a table format using the `rich` library, providing - a clear and color-coded status for each endpoint. The table includes the network name, endpoint URL, - connectivity status, and any messages returned by the `nc` command. - - Usage: - This class is intended to be used as a command within the Bittensor CLI. It can be invoked by - running the CLI with the `check` command: - - ``` - btcli subtensor check - ``` - ┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ - ┃ Network ┃ Endpoint ┃ Status ┃ Message ┃ - ┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ - │ local │ ws://127.0.0.1:9944 │ Failed │ nc: connectx to 127.0.0.1 port 9944 (tcp) failed: Connection refused │ - │ finney │ wss://entrypoint-finney.opentensor.ai:443 │ Success │ Connection to entrypoint-finney.opentensor.ai port 443 succeeded! │ - │ test │ wss://test.finney.opentensor.ai:443/ │ Success │ Connection to test.finney.opentensor.ai port 443 succeeded! │ - │ archive │ wss://archive.chain.opentensor.ai:443/ │ Success │ Connection to archive.chain.opentensor.ai port 443 succeeded! │ - └──────────────┴───────────────────────────────────────────┴─────────┴──────────────────────────────────────────────────────────────────────┘ - - Note: - This command assumes that the `nc` command is available in the system's environment where the CLI - is executed. It also assumes that the endpoints defined in the `endpoints` dictionary are in the - correct format and the `rich` library is available for displaying the output table. - """ - - @staticmethod - def run(cli): - console = bittensor.__console__ - - endpoints = { - "local": bittensor.__local_entrypoint__, - "finney": bittensor.__finney_entrypoint__, - "test": bittensor.__finney_test_entrypoint__, - "archive": bittensor.__archive_entrypoint__, - } - - if cli.config.endpoint: - endpoints.update({"custom": cli.config.endpoint}) - - table = Table(show_header=True, header_style="bold magenta") - table.add_column("Network", style="dim", width=12) - table.add_column("Endpoint") - table.add_column("Status") - table.add_column("Message") - - # Regular expression to extract hostname and port from URL - url_pattern = re.compile(r"(?:wss?://)?([^:/]+)(?::(\d+))?") - - # Iterate over the endpoints and check connectivity - for network, url in endpoints.items(): - match = url_pattern.match(url) - if match: - host, port = match.groups() - port = port or ( - "443" if url.startswith("wss://") else "80" - ) # Default ports for wss and ws respectively - result = subprocess.run( - ["nc", "-vz", host, port], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if result.returncode == 0: - status = "[green]Success[/green]" - else: - status = f"[red]Failed[/red]" - else: - status = "[red]Error: Invalid URL[/red]" - table.add_row(network, url, status, result.stdout.strip()) - - console.print(table) - - @staticmethod - def add_args(parser: argparse.ArgumentParser): - check_parser = parser.add_parser( - "check", help="Check connectivity with Bittensor network endpoints." - ) - check_parser.add_argument( - "--endpoint", - type=str, - help="Endpoint to check connectivity with.", - ) - - @staticmethod - def check_config(config: argparse.Namespace): - if config.endpoint: - # If endpoint is specified, check that it is a valid URL - if not re.match(r"(?:wss?://)?[^:/]+(?::\d+)?", config.endpoint): - raise ValueError("Invalid endpoint URL") From 2e98c11760964633e80730e3fe0edc9781d8c994 Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Fri, 1 Dec 2023 12:10:27 -0500 Subject: [PATCH 10/11] update changelog again --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9683a86df2..162c4d4518 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,6 @@ ## 6.4.1 / 2023-12-01 ## What's Changed -* add btcli subtensor check command for quick info on network health in https://github.com/opentensor/bittensor/pull/1600/commits/3e47889f7f2b903d65fcc6dee5787b1bb9a0e1c2 * add helpful messages to signal coming changes & fallback to finney in https://github.com/opentensor/bittensor/pull/1600/commits/86c0c3ccfcd91d0e3ff87f53bdc3e9c5e68661da * revert default subtensor network to finney in https://github.com/opentensor/bittensor/pull/1600/commits/8c69a3c15cd556384d0309e951f0a9b164dd36cb From 81b51d3d7ab164b2583bbb20fb36c1311a69e0ce Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Fri, 1 Dec 2023 13:48:02 -0500 Subject: [PATCH 11/11] remove fallback to finney --- CHANGELOG.md | 2 +- bittensor/subtensor.py | 23 +++++------------------ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 162c4d4518..4992a86911 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 6.4.1 / 2023-12-01 ## What's Changed -* add helpful messages to signal coming changes & fallback to finney in https://github.com/opentensor/bittensor/pull/1600/commits/86c0c3ccfcd91d0e3ff87f53bdc3e9c5e68661da +* add helpful messages to signal coming changes in https://github.com/opentensor/bittensor/pull/1600/commits/86c0c3ccfcd91d0e3ff87f53bdc3e9c5e68661da * revert default subtensor network to finney in https://github.com/opentensor/bittensor/pull/1600/commits/8c69a3c15cd556384d0309e951f0a9b164dd36cb **Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.0.1...v6.4.1 diff --git a/bittensor/subtensor.py b/bittensor/subtensor.py index f432b170cb..52ae1b482c 100644 --- a/bittensor/subtensor.py +++ b/bittensor/subtensor.py @@ -342,7 +342,8 @@ def __init__( "This increases decentralization and resilience of the network." ) bittensor.logging.warning( - "In a future release, local subtensor will become the default and the fallback to finney removed." + "In a future release, local subtensor will become the default endpoint. " + "To get ahead of this change, please run a local subtensor node and point to it." ) # Returns a mocked connection with a background chain connection. @@ -366,26 +367,12 @@ def __init__( ) except ConnectionRefusedError as e: bittensor.logging.error( - f"Could not connect to {self.network} network with {self.chain_endpoint} chain endpoint." + f"Could not connect to {self.network} network with {self.chain_endpoint} chain endpoint. Exiting..." ) - bittensor.logging.warning( + bittensor.logging.info( f"You can check if you have connectivity by runing this command: nc -vz localhost {self.chain_endpoint.split(':')[2]}" ) - bittensor.logging.warning( - f"Falling back to finney at {bittensor.__finney_entrypoint__}" - ) - bittensor.logging.warning( - f"Note: This will become an error in a future release by removing the fallback to finney." - ) - - self.substrate = SubstrateInterface( - ss58_format=bittensor.__ss58_format__, - use_remote_preset=True, - url=bittensor.__finney_entrypoint__, - type_registry=bittensor.__type_registry__, - ) - self.network = "finney" - self.chain_endpoint = bittensor.__finney_entrypoint__ + exit(1) # TODO (edu/phil): Advise to run local subtensor and point to dev docs. bittensor.logging.info(