diff --git a/CHANGELOG.md b/CHANGELOG.md index b61cbdff07..7cb2964f6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,183 @@ # Changelog +## 7.2.0 / 2024-06-12 + +## What's Changed +* less verbose handled synapse exceptions by @mjurbanski-reef in https://github.com/opentensor/bittensor/pull/1928 +* Clean up the imports in commands/stake.py by @thewhaleking in https://github.com/opentensor/bittensor/pull/1951 +* Fix E2E test for Commit/Reveal with Salt flag by @opendansor in https://github.com/opentensor/bittensor/pull/1952 +* `bittensor.chain_data.py` module refactoring. by @RomanCh-OT in https://github.com/opentensor/bittensor/pull/1955 +* ci: e2e tests by @orriin in https://github.com/opentensor/bittensor/pull/1915 +* Dependency cleanup by @mjurbanski-reef in https://github.com/opentensor/bittensor/pull/1967 +* replace `black` with `ruff` by @mjurbanski-reef in https://github.com/opentensor/bittensor/pull/1968 +* post-black to ruff migration cleanup by @mjurbanski-reef in https://github.com/opentensor/bittensor/pull/1979 +* Revert Axon IP decoding changes by @camfairchild in https://github.com/opentensor/bittensor/pull/1981 +* A wrapper for presenting extrinsics errors in a human-readable form. by @RomanCh-OT in https://github.com/opentensor/bittensor/pull/1980 +* Feat: Added normalized hyperparams by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1891 +* deprecate nest_asyncio use by @mjurbanski-reef in https://github.com/opentensor/bittensor/pull/1974 +* Add e2e test for axon by @opendansor in https://github.com/opentensor/bittensor/pull/1984 +* Dendrite E2E test by @opendansor in https://github.com/opentensor/bittensor/pull/1988 +* fix __version_as_int__ for >10 minor/patch release vers (resolves #1982) by @mjurbanski-reef in https://github.com/opentensor/bittensor/pull/1993 +* Test Incentive E2E by @opendansor in https://github.com/opentensor/bittensor/pull/2002 +* Add E2E faucet test by @opendansor in https://github.com/opentensor/bittensor/pull/1987 +* Allow unstake below network min by @camfairchild in https://github.com/opentensor/bittensor/pull/2016 + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v7.1.1...v7.2.0 + + +## 7.1.1 / 2024-06-11 + +## What's Changed +* commit_reveal_weights_enabled argument parsing hotfix by @camfairchild in https://github.com/opentensor/bittensor/pull/2003 + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v7.1.0...v7.1.1 + +## 7.1.0 / 2024-06-05 + +## What's Changed +* Added _do_set_root_weights by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1838 +* Release/7.0.1 by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1963 + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v7.0.1...v7.1.0 + +## 7.0.1 / 2024-05-31 + +## What's Changed +* Release/7.0.0 by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1899 +* Fix return of ip version. by @opendansor in https://github.com/opentensor/bittensor/pull/1961 +* Fix trigger use_torch() by @renesweet24 https://github.com/opentensor/bittensor/pull/1960 + +## New Contributors +* @renesweet24 made their first contribution in https://github.com/opentensor/bittensor/pull/1960 + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v7.0.0...v7.0.1 + + +## 7.0.0 / 2024-05-29 + +## What's Changed +* replace torch with numpy by @andreea-popescu-reef in https://github.com/opentensor/bittensor/pull/1777 +* Fix broken link in contrib/RELEASE_GUIDELINES #1821 by @thewhaleking in https://github.com/opentensor/bittensor/pull/1823 +* Tests: Added coverage for set_weights by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1825 +* Remove irrelevant call to get_delegates method. by @RomanCh-OT in https://github.com/opentensor/bittensor/pull/1826 +* Support for string mnemonic thru cli when regenerating coldkeys by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1815 +* Logging: Added _primary_loggers by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1797 +* Add in check for minimum stake for unstaking by @thewhaleking in https://github.com/opentensor/bittensor/pull/1832 +* Cache get_decoder_class by @thewhaleking in https://github.com/opentensor/bittensor/pull/1834 +* Warmfix/change decoder cacheing by @thewhaleking in https://github.com/opentensor/bittensor/pull/1842 +* Fix typo in warmfix by @thewhaleking in https://github.com/opentensor/bittensor/pull/1844 +* Add the command btcli root list_delegates_lite to handle the Delegate… by @RomanCh-OT in https://github.com/opentensor/bittensor/pull/1840 +* Change: console.error => console.print by @thewhaleking in https://github.com/opentensor/bittensor/pull/1849 +* Small fix with receiving delegates based on a 4-hour archive block by @RomanCh-OT in https://github.com/opentensor/bittensor/pull/1854 +* Replace torch with numpy by @sepehr-opentensor in https://github.com/opentensor/bittensor/pull/1786 +* Versioning: Enforcement for eth-utils by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1852 +* Versioning: Dependencies for FastAPI for Apple M's by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1855 +* Retrieving error types from the metadata of the Substrate palette SubtensorModule for the btcli console (logic) by @RomanCh-OT in https://github.com/opentensor/bittensor/pull/1862 +* Add version check caching, fix version comparison by @olzhasar-reef in https://github.com/opentensor/bittensor/pull/1835 +* Tests: Added coverage for root.py by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1877 +* Tests: Added coverage for network.py by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1879 +* Tests: extends coverage for overview cmd part 1 by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1873 +* Tests: Added coverage for Unstaking by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1878 +* Tests: Added coverage for staking by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1837 +* Tests: Added coverage for Delegation by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1874 +* Updated error message and a test typo. by @thewhaleking in https://github.com/opentensor/bittensor/pull/1871 +* fix: deprecated usage of `Balances::transfer` method by @orriin in https://github.com/opentensor/bittensor/pull/1886 +* Fix Type Annotation by @opendansor in https://github.com/opentensor/bittensor/pull/1895 +* Docstrings updates for list delegate lite feature by @rajkaramchedu in https://github.com/opentensor/bittensor/pull/1890 +* Add Pre-commit Checker in scripts. Helps reduce CI calls. by @RomanCh-OT in https://github.com/opentensor/bittensor/pull/1893 +* fix get_coldkey_password_from_environment resolving wrong password by @mjurbanski-reef in https://github.com/opentensor/bittensor/pull/1843 +* Drop python 3.8 support by @mjurbanski-reef in https://github.com/opentensor/bittensor/pull/1892 +* feat: Refactor phase 2 overview cmd & add test cov. Adds factories by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1887 +* Add setting delegate take by @gztensor in https://github.com/opentensor/bittensor/pull/1903 +* E2E Test Patterns by @orriin in https://github.com/opentensor/bittensor/pull/1885 +* chore: correct method types by @distributedstatemachine in https://github.com/opentensor/bittensor/pull/1907 +* bittensor.btlogging refactoring by @RomanCh-OT in https://github.com/opentensor/bittensor/pull/1896 +* Part 1 for refactoring bittensor/subtensor.py by @RomanCh-OT in https://github.com/opentensor/bittensor/pull/1911 +* Update: Pydantic V2 by @opendansor in https://github.com/opentensor/bittensor/pull/1889 +* Add back compatibility with torch by @thewhaleking in https://github.com/opentensor/bittensor/pull/1904 +* Release/6.12.2 by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1910 +* Chore: Updated dev requirements by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1946 + +## New Contributors +* @andreea-popescu-reef made their first contribution in https://github.com/opentensor/bittensor/pull/1777 +* @thewhaleking made their first contribution in https://github.com/opentensor/bittensor/pull/1823 +* @RomanCh-OT made their first contribution in https://github.com/opentensor/bittensor/pull/1826 +* @olzhasar-reef made their first contribution in https://github.com/opentensor/bittensor/pull/1835 +* @orriin made their first contribution in https://github.com/opentensor/bittensor/pull/1886 +* @opendansor made their first contribution in https://github.com/opentensor/bittensor/pull/1895 + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.12.2...v7.0.0 + +## 6.12.2 / 2024-05-20 + +## What's Changed +* Add setting delegate take +* fix: deprecated transfer method usage + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.12.1...54eee604c00ac4f04a31d5d7bc663124731a34d8 + + +## 6.12.1 / 2024-05-17 + +## What's Changed +* Hotfix if the subnet UID is not in the Subnets + + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.12.0...fd2442db8bb8aad55ced2ac3b748b04ebdc73292 + + + +## 6.12.0 / 2024-04-29 + +## What's Changed +* Tests: Axon to_string patch import by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1785 +* Tests: Extends coverage on Serving extrinsics methods by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1783 +* Fix: CVE-2024-24762 FastAPI by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1800 +* Fix: CVE-2024-26130 | vulnerability cryptography by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1801 +* fix PR templates by @mjurbanski-reef in https://github.com/opentensor/bittensor/pull/1778 +* Fix: SNYK-PYTHON-CERTIFI-5805047 | Vulnerability Certifi by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1816 +* Tests: Extends test coverage on Registration methods by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1814 +* Fix: Wallet overwrite functionality by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1802 + + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.11.0...v6.12.0 + +## 6.11.0 / 2024-04-11 + +## What's Changed +* Tests: Adds coverage to subtensor help method & determine_chain_endpoint_and_network by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1761 +* [bug fix] Fix import json by @camfairchild in https://github.com/opentensor/bittensor/pull/1759 +* Remove context management for substrate in subtensor by @sepehr-opentensor in https://github.com/opentensor/bittensor/pull/1766 +* Tests: Extends coverage on axon methods by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1769 +* Revert nonce implementation fix by @ifrit98 in https://github.com/opentensor/bittensor/pull/1774 +* remove tests from package distribution by @mjurbanski-reef in https://github.com/opentensor/bittensor/pull/1779 +* Tests: Extends test coverage on Senate methods by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1781 + +## New Contributors +* @mjurbanski-reef made their first contribution in https://github.com/opentensor/bittensor/pull/1779 +* @ibraheem-opentensor made their first contribution in https://github.com/opentensor/bittensor/pull/1781 + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.10.1...v6.11.0 +## 6.10.1 / 2024-04-05 +## What's Changed +* Revert nonce implementation fix #1774: Breaking change needs to telegraphed in next release. + +## 6.10.0 / 2024-03-25 + +## What's Changed +* handle req args by parsing and raising by @ifrit98 in https://github.com/opentensor/bittensor/pull/1733 +* Replace wildcard imports with specific imports by @brueningf in https://github.com/opentensor/bittensor/pull/1724 +* Logging Refactor by @sepehr-opentensor in https://github.com/opentensor/bittensor/pull/1751 +* Update DEBUGGING.md by @e-gons in https://github.com/opentensor/bittensor/pull/1755 +* fix: nonce implementation by @GentikSolm in https://github.com/opentensor/bittensor/pull/1754 + +## New Contributors +* @sepehr-opentensor made their first contribution in https://github.com/opentensor/bittensor/pull/1751 +* @e-gons made their first contribution in https://github.com/opentensor/bittensor/pull/1755 +* @GentikSolm made their first contribution in https://github.com/opentensor/bittensor/pull/1754 + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.9.3...v6.10.0 + ## 6.9.3 / 2024-03-12 ## What's Changed @@ -39,8 +217,8 @@ * Expands type checking to subtensor by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1731 * Feature: Synapse passing type check by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1725 * bump req for security vulnerability in crpytography by @ifrit98 in https://github.com/opentensor/bittensor/pull/1718 -* Fix: proper association with wallet dir and coldkey addr #1739 by @gus-opentensor & @sepehr-opentensor -* Fixed event lookup on new network added #1741 by @shibshib +* Fix: proper association with wallet dir and coldkey addr #1739 by @gus-opentensor & @sepehr-opentensor +* Fixed event lookup on new network added #1741 by @shibshib **Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.8.2...v6.9.0 @@ -72,11 +250,11 @@ * logging off switch by @ifrit98 in https://github.com/opentensor/bittensor/pull/1704 * Extrinsic update by @ifrit98 in https://github.com/opentensor/bittensor/pull/1703 * Bittensor shared request layer by @ifrit98 in https://github.com/opentensor/bittensor/pull/1698 -* Add no_prompt argument to help printout in https://github.com/opentensor/bittensor/pull/1707 -* Adds mypi typechecking to circleci by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1705 +* Add no_prompt argument to help printout in https://github.com/opentensor/bittensor/pull/1707 +* Adds mypi typechecking to circleci by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1705 * Remove set weights ttl now that we have a better extrinsic method by @ifrit98 -* Bug fix in overview command for dereg stake with outdated `stake_info` object fields by @ifrit98 in https://github.com/opentensor/bittensor/pull/1712 -* Moves mock wallet creation to temp dir by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1711 +* Bug fix in overview command for dereg stake with outdated `stake_info` object fields by @ifrit98 in https://github.com/opentensor/bittensor/pull/1712 +* Moves mock wallet creation to temp dir by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1711 **Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.7.2...v6.8.0 @@ -639,7 +817,7 @@ - allow set synapse All using flag - add test - use dot get - + - [Feature] Mark registration threads as daemons (https://github.com/opentensor/bittensor/pull/998) - make solver processes daemons @@ -689,9 +867,9 @@ ## 3.4.0 / 2022-10-13 ## What's Changed -* Parameters update by @Eugene-hu #936 -* Bittensor Generate by @unconst #941 -* Prometheus by @unconst #928 +* Parameters update by @Eugene-hu #936 +* Bittensor Generate by @unconst #941 +* Prometheus by @unconst #928 * [Tooling][Release] Adding release script by @eduardogr in https://github.com/opentensor/bittensor/pull/948 @@ -750,7 +928,7 @@ ## 3.3.0 / 2022-08-16 ### CUDA registration -This release adds the ability to complete the registration using a CUDA-capable device. +This release adds the ability to complete the registration using a CUDA-capable device. See https://github.com/opentensor/cubit/releases/tag/v1.0.5 for the required `cubit` v1.0.5 release Also a few bug fixes for the CLI @@ -783,5 +961,5 @@ This release refactors the registration code for CPU registration to improve sol ### Synapse update -## +## diff --git a/VERSION b/VERSION index 66ce77b7ea..4b49d9bb63 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.0.0 +7.2.0 \ No newline at end of file diff --git a/bittensor/__init__.py b/bittensor/__init__.py index f9200a271c..7cb37ef0d0 100644 --- a/bittensor/__init__.py +++ b/bittensor/__init__.py @@ -40,7 +40,7 @@ # Bittensor code and protocol version. -__version__ = "7.0.0" +__version__ = "7.2.0" _version_split = __version__.split(".") __version_info__ = tuple(int(part) for part in _version_split) @@ -304,7 +304,6 @@ def debug(on: bool = True): NeuronInfoLite, PrometheusInfo, DelegateInfo, - DelegateInfoLite, StakeInfo, SubnetInfo, SubnetHyperparameters, diff --git a/bittensor/axon.py b/bittensor/axon.py index 948d65e31f..ca06335307 100644 --- a/bittensor/axon.py +++ b/bittensor/axon.py @@ -896,7 +896,6 @@ async def default_verify(self, synapse: bittensor.Synapse): # If we don't have a nonce stored, ensure that the nonce falls within # a reasonable delta. - # Updated nonce using NTP implementated at v7.2 if ( synapse.dendrite.version is not None and synapse.dendrite.version >= V_7_2_0 diff --git a/bittensor/cli.py b/bittensor/cli.py index 931c5d8d14..2322475734 100644 --- a/bittensor/cli.py +++ b/bittensor/cli.py @@ -29,7 +29,6 @@ InspectCommand, ListCommand, ListDelegatesCommand, - ListDelegatesLiteCommand, MetagraphCommand, MyDelegatesCommand, NewColdkeyCommand, @@ -133,7 +132,6 @@ "undelegate": DelegateUnstakeCommand, "my_delegates": MyDelegatesCommand, "list_delegates": ListDelegatesCommand, - "list_delegates_lite": ListDelegatesLiteCommand, "nominate": NominateCommand, }, }, diff --git a/bittensor/commands/__init__.py b/bittensor/commands/__init__.py index 2ccea346a4..497fe4252b 100644 --- a/bittensor/commands/__init__.py +++ b/bittensor/commands/__init__.py @@ -74,7 +74,6 @@ from .delegates import ( NominateCommand, ListDelegatesCommand, - ListDelegatesLiteCommand, DelegateStakeCommand, DelegateUnstakeCommand, MyDelegatesCommand, diff --git a/bittensor/commands/delegates.py b/bittensor/commands/delegates.py index 344b2bfcea..4d03b289e4 100644 --- a/bittensor/commands/delegates.py +++ b/bittensor/commands/delegates.py @@ -604,84 +604,9 @@ def check_config(config: "bittensor.config"): config.unstake_all = True -class ListDelegatesLiteCommand: - """ - Displays a formatted table of Bittensor network delegates, providing a lite overview of delegate statistics and information. For a more detailed view, use the :func:`ListDelegatesCommand` class. - - This table helps users make informed decisions on which delegates to allocate their TAO stake. - - Optional Arguments: - - ``wallet.name``: The name of the wallet to use for the command. - - ``subtensor.network``: The name of the network to use for the command. - - The table columns include: - - - INDEX: The delegate's index in the sorted list. - - DELEGATE: The name of the delegate. - - SS58: The delegate's unique SS58 address (truncated for display). - - NOMINATORS: The count of nominators backing the delegate. - - VPERMIT: Indicates the subnets for which the delegate has validator permits. - - TAKE: The percentage of the delegate's earnings taken by the network. - - DELEGATE/(24h): The total earnings of the delegate in the last 24 hours. - - DESCRIPTION: A brief description of the delegate's purpose and operations. - - Sorting is done based on the ``TOTAL STAKE`` column in descending order. Changes in stake are highlighted as follows: Increases are indicated in green and decreases are indicated in red. Entries with no previous data are marked with ``NA``. Each delegate's name is a hyperlink to their respective URL, if available. - - Example usage:: - - btcli root list_delegates_lite - btcli root list_delegates_lite --wallet.name my_wallet - btcli root list_delegates_lite --subtensor.network finney # can also be `test` or `local` - - Note: - This function is part of the Bittensor CLI tools and is intended for use within a console application. It prints directly to the console and does not return any value. - """ - - @staticmethod - def run(cli: "bittensor.cli"): - r""" - List all delegates on the network. - """ - try: - cli.config.subtensor.network = "archive" - cli.config.subtensor.chain_endpoint = ( - "wss://archive.chain.opentensor.ai:443" - ) - subtensor: "bittensor.subtensor" = bittensor.subtensor( - config=cli.config, log_verbose=False - ) - ListDelegatesLiteCommand._run(cli, subtensor) - finally: - if "subtensor" in locals(): - subtensor.close() - bittensor.logging.debug("closing subtensor connection") - - @staticmethod - def _run(cli: "bittensor.cli", subtensor: "bittensor.subtensor"): - r""" - List all delegates on the network. - """ - with bittensor.__console__.status(":satellite: Loading delegates..."): - delegates: list[bittensor.DelegateInfoLite] = subtensor.get_delegates_lite() - - show_delegates_lite(delegates, width=cli.config.get("width", None)) - - @staticmethod - def add_args(parser: argparse.ArgumentParser): - list_delegates_parser = parser.add_parser( - "list_delegates_lite", - help="""List all delegates on the network (lite version).""", - ) - bittensor.subtensor.add_args(list_delegates_parser) - - @staticmethod - def check_config(config: "bittensor.config"): - pass - - class ListDelegatesCommand: """ - Displays a formatted table of Bittensor network delegates, providing a comprehensive overview of delegate statistics and information. Use the :func:`ListDelegatesLiteCommand` class for a lighter version of this class. + Displays a formatted table of Bittensor network delegates, providing a comprehensive overview of delegate statistics and information. This table helps users make informed decisions on which delegates to allocate their TAO stake. diff --git a/bittensor/commands/network.py b/bittensor/commands/network.py index 441239f308..0843b71c70 100644 --- a/bittensor/commands/network.py +++ b/bittensor/commands/network.py @@ -387,8 +387,13 @@ def _run( if ( cli.config.param == "network_registration_allowed" or cli.config.param == "network_pow_registration_allowed" + or cli.config.param == "commit_reveal_weights_enabled" ): - cli.config.value = True if cli.config.value.lower() == "true" else False + cli.config.value = ( + True + if (cli.config.value.lower() == "true" or cli.config.value == "1") + else False + ) subtensor.set_hyperparameter( wallet, diff --git a/bittensor/extrinsics/commit_weights.py b/bittensor/extrinsics/commit_weights.py index fd617f3e3a..a9192952ef 100644 --- a/bittensor/extrinsics/commit_weights.py +++ b/bittensor/extrinsics/commit_weights.py @@ -23,6 +23,7 @@ from rich.prompt import Confirm import bittensor + from bittensor.utils import format_error_message diff --git a/bittensor/extrinsics/registration.py b/bittensor/extrinsics/registration.py index 93002c2ad4..e82add8383 100644 --- a/bittensor/extrinsics/registration.py +++ b/bittensor/extrinsics/registration.py @@ -23,6 +23,7 @@ import bittensor from bittensor.utils import format_error_message + from bittensor.utils.registration import ( POWSolution, create_pow, diff --git a/bittensor/extrinsics/root.py b/bittensor/extrinsics/root.py index 2e1e4d3dab..8a7e9e3863 100644 --- a/bittensor/extrinsics/root.py +++ b/bittensor/extrinsics/root.py @@ -61,13 +61,13 @@ def root_register_extrinsic( ) if is_registered: bittensor.__console__.print( - f":white_heavy_check_mark: [green]Already registered on root network.[/green]" + ":white_heavy_check_mark: [green]Already registered on root network.[/green]" ) return True if prompt: # Prompt user for confirmation. - if not Confirm.ask(f"Register to root network?"): + if not Confirm.ask("Register to root network?"): return False with bittensor.__console__.status(":satellite: Registering to root network..."): @@ -130,6 +130,9 @@ def set_root_weights_extrinsic( success (bool): Flag is ``true`` if extrinsic was finalized or uncluded in the block. If we did not wait for finalization / inclusion, the response is ``true``. """ + + wallet.coldkey # unlock coldkey + # First convert types. if isinstance(netuids, list): netuids = np.array(netuids, dtype=np.int64) @@ -177,7 +180,7 @@ def set_root_weights_extrinsic( weight_uids, weight_vals = weight_utils.convert_weights_and_uids_for_emit( netuids, weights ) - success, error_message = subtensor._do_set_weights( + success, error_message = subtensor._do_set_root_weights( wallet=wallet, netuid=0, uids=weight_uids, diff --git a/bittensor/subtensor.py b/bittensor/subtensor.py index a8c4f2bd30..0fffa1cc7e 100644 --- a/bittensor/subtensor.py +++ b/bittensor/subtensor.py @@ -43,9 +43,9 @@ from bittensor.btlogging import logging as _logger from bittensor.utils import torch, weight_utils, format_error_message from .chain_data import ( + DelegateInfoLite, NeuronInfo, DelegateInfo, - DelegateInfoLite, PrometheusInfo, SubnetInfo, SubnetHyperparameters, @@ -614,7 +614,6 @@ def set_take( ) -> bool: """ Set delegate hotkey take - Args: wallet (bittensor.wallet): The wallet containing the hotkey to be nominated. delegate_ss58 (str, optional): Hotkey @@ -1082,6 +1081,7 @@ def reveal_weights( This function allows neurons to reveal their previously committed weight distribution, ensuring transparency and accountability within the Bittensor network. """ + retries = 0 success = False message = "No attempt made. Perhaps it is too soon to reveal weights!" @@ -2659,6 +2659,73 @@ def root_set_weights( prompt=prompt, ) + def _do_set_root_weights( + self, + wallet: "bittensor.wallet", + uids: List[int], + vals: List[int], + netuid: int = 0, + version_key: int = bittensor.__version_as_int__, + wait_for_inclusion: bool = False, + wait_for_finalization: bool = False, + ) -> Tuple[bool, Optional[str]]: # (success, error_message) + """ + Internal method to send a transaction to the Bittensor blockchain, setting weights + for specified neurons on root. This method constructs and submits the transaction, handling + retries and blockchain communication. + + Args: + wallet (bittensor.wallet): The wallet associated with the neuron setting the weights. + uids (List[int]): List of neuron UIDs for which weights are being set. + vals (List[int]): List of weight values corresponding to each UID. + netuid (int): Unique identifier for the network. + version_key (int, optional): Version key for compatibility with the network. + wait_for_inclusion (bool, optional): Waits for the transaction to be included in a block. + wait_for_finalization (bool, optional): Waits for the transaction to be finalized on the blockchain. + + Returns: + Tuple[bool, Optional[str]]: A tuple containing a success flag and an optional error message. + + This method is vital for the dynamic weighting mechanism in Bittensor, where neurons adjust their + trust in other neurons based on observed performance and contributions on the root network. + """ + + @retry(delay=2, tries=3, backoff=2, max_delay=4, logger=_logger) + def make_substrate_call_with_retry(): + call = self.substrate.compose_call( + call_module="SubtensorModule", + call_function="set_root_weights", + call_params={ + "dests": uids, + "weights": vals, + "netuid": netuid, + "version_key": version_key, + "hotkey": wallet.hotkey.ss58_address, + }, + ) + # Period dictates how long the extrinsic will stay as part of waiting pool + extrinsic = self.substrate.create_signed_extrinsic( + call=call, + keypair=wallet.coldkey, + era={"period": 5}, + ) + response = self.substrate.submit_extrinsic( + extrinsic, + wait_for_inclusion=wait_for_inclusion, + wait_for_finalization=wait_for_finalization, + ) + # We only wait here if we expect finalization. + if not wait_for_finalization and not wait_for_inclusion: + return True, "Not waiting for finalziation or inclusion." + + response.process_events() + if response.is_success: + return True, "Successfully set weights." + else: + return False, response.error_message + + return make_substrate_call_with_retry() + ################## # Registry Calls # ################## @@ -4325,8 +4392,6 @@ def get_delegates(self, block: Optional[int] = None) -> List[DelegateInfo]: Analyzing the delegate population offers insights into the network's governance dynamics and the distribution of trust and responsibility among participating neurons. - For a lighter version of this function, see :func:`get_delegates_lite`. - Args: block (Optional[int], optional): The blockchain block number for the query. diff --git a/bittensor/synapse.py b/bittensor/synapse.py index 53c53f0083..80053f7065 100644 --- a/bittensor/synapse.py +++ b/bittensor/synapse.py @@ -120,7 +120,7 @@ class TerminalInfo(BaseModel): ip (str): IP address of the terminal, crucial for network routing and data transmission. port (int): Network port used by the terminal, key for establishing network connections. version (int): Bittensor version running on the terminal, ensuring compatibility between different nodes in the network. - nonce (int): Unix timestamp that linearly increases for each request, ensuring requests cannot be duplicated or repeated + nonce (int): Unique, monotonically increasing number for each terminal, aiding in identifying and ordering network interactions. uuid (str): Unique identifier for the terminal, fundamental for network security and identification. hotkey (str): Encoded hotkey string of the terminal wallet, important for transaction and identity verification in the network. signature (str): Digital signature verifying the tuple of nonce, axon_hotkey, dendrite_hotkey, and uuid, critical for ensuring data authenticity and security. diff --git a/bittensor/utils/weight_utils.py b/bittensor/utils/weight_utils.py index 42f0a88380..de26d98c02 100644 --- a/bittensor/utils/weight_utils.py +++ b/bittensor/utils/weight_utils.py @@ -20,6 +20,7 @@ # DEALINGS IN THE SOFTWARE. import hashlib +import logging from typing import Tuple, List, Union import numpy as np @@ -140,11 +141,14 @@ def convert_root_weight_uids_and_vals_to_tensor( for uid_j, wij in list(zip(uids, weights)): if uid_j in subnets: index_s = subnets.index(uid_j) + row_weights[index_s] = float( + wij + ) # assumes max-upscaled values (w_max = U16_MAX). else: - raise Exception("Incorrect Subnet {uid_j} in {subnets}") - row_weights[index_s] = float( - wij - ) # assumes max-upscaled values (w_max = U16_MAX). + logging.warning( + f"Incorrect Subnet uid {uid_j} in Subnets {subnets}. The subnet is unavailable at the moment." + ) + continue row_sum = row_weights.sum() if row_sum > 0: row_weights /= row_sum # normalize @@ -252,7 +256,7 @@ def process_weights_for_netuid( metagraph = subtensor.metagraph(netuid) # Cast weights to floats. - if not use_torch(): + if use_torch(): if not isinstance(weights, torch.FloatTensor): weights = weights.type(torch.float32) else: diff --git a/tests/e2e_tests/subcommands/delegation/__init__.py b/tests/e2e_tests/subcommands/delegation/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/e2e_tests/subcommands/weights/test_commit_weights.py b/tests/e2e_tests/subcommands/weights/test_commit_weights.py index d11f3454f9..d35266a6e2 100644 --- a/tests/e2e_tests/subcommands/weights/test_commit_weights.py +++ b/tests/e2e_tests/subcommands/weights/test_commit_weights.py @@ -14,6 +14,7 @@ ) from tests.e2e_tests.utils import setup_wallet + """ Test the Commit/Reveal weights mechanism. @@ -30,6 +31,7 @@ def test_commit_and_reveal_weights(local_chain): # Register root as Alice keypair, exec_command, wallet_path = setup_wallet("//Alice", True) + exec_command(RegisterSubnetworkCommand, ["s", "create"]) # define values diff --git a/tests/integration_tests/test_cli_no_network.py b/tests/integration_tests/test_cli_no_network.py index 1ef6657f61..cd9f89ee6a 100644 --- a/tests/integration_tests/test_cli_no_network.py +++ b/tests/integration_tests/test_cli_no_network.py @@ -1333,6 +1333,122 @@ def test_vote_command_prompt_proposal_hash(self, _): # NO prompt happened mock_ask_prompt.assert_not_called() + @patch("bittensor.wallet", new_callable=return_mock_wallet_factory) + def test_commit_reveal_weights_enabled_parse_boolean_argument(self, mock_sub, __): + param = "commit_reveal_weights_enabled" + + def _test_value_parsing(parsed_value: bool, modified: str): + cli = bittensor.cli( + args=[ + "sudo", + "set", + "--netuid", + "1", + "--param", + param, + "--value", + modified, + "--wallet.name", + "mock", + ] + ) + cli.run() + + _, kwargs = mock_sub.call_args + passed_config = kwargs["config"] + self.assertEqual(passed_config.param, param, msg="Incorrect param") + self.assertEqual( + passed_config.value, + parsed_value, + msg=f"Boolean argument not correctly for {modified}", + ) + + for boolean_value in [True, False, 1, 0]: + as_str = str(boolean_value) + + _test_value_parsing(boolean_value, as_str) + _test_value_parsing(boolean_value, as_str.capitalize()) + _test_value_parsing(boolean_value, as_str.upper()) + _test_value_parsing(boolean_value, as_str.lower()) + + @patch("bittensor.wallet", new_callable=return_mock_wallet_factory) + def test_network_registration_allowed_parse_boolean_argument(self, mock_sub, __): + param = "network_registration_allowed" + + def _test_value_parsing(parsed_value: bool, modified: str): + cli = bittensor.cli( + args=[ + "sudo", + "set", + "--netuid", + "1", + "--param", + param, + "--value", + modified, + "--wallet.name", + "mock", + ] + ) + cli.run() + + _, kwargs = mock_sub.call_args + passed_config = kwargs["config"] + self.assertEqual(passed_config.param, param, msg="Incorrect param") + self.assertEqual( + passed_config.value, + parsed_value, + msg=f"Boolean argument not correctly for {modified}", + ) + + for boolean_value in [True, False, 1, 0]: + as_str = str(boolean_value) + + _test_value_parsing(boolean_value, as_str) + _test_value_parsing(boolean_value, as_str.capitalize()) + _test_value_parsing(boolean_value, as_str.upper()) + _test_value_parsing(boolean_value, as_str.lower()) + + @patch("bittensor.wallet", new_callable=return_mock_wallet_factory) + def test_network_pow_registration_allowed_parse_boolean_argument( + self, mock_sub, __ + ): + param = "network_pow_registration_allowed" + + def _test_value_parsing(parsed_value: bool, modified: str): + cli = bittensor.cli( + args=[ + "sudo", + "set", + "--netuid", + "1", + "--param", + param, + "--value", + modified, + "--wallet.name", + "mock", + ] + ) + cli.run() + + _, kwargs = mock_sub.call_args + passed_config = kwargs["config"] + self.assertEqual(passed_config.param, param, msg="Incorrect param") + self.assertEqual( + passed_config.value, + parsed_value, + msg=f"Boolean argument not correctly for {modified}", + ) + + for boolean_value in [True, False, 1, 0]: + as_str = str(boolean_value) + + _test_value_parsing(boolean_value, as_str) + _test_value_parsing(boolean_value, as_str.capitalize()) + _test_value_parsing(boolean_value, as_str.upper()) + _test_value_parsing(boolean_value, as_str.lower()) + if __name__ == "__main__": unittest.main() diff --git a/tests/unit_tests/extrinsics/test_root.py b/tests/unit_tests/extrinsics/test_root.py index d3ae2c3973..b801f7b4e1 100644 --- a/tests/unit_tests/extrinsics/test_root.py +++ b/tests/unit_tests/extrinsics/test_root.py @@ -186,7 +186,9 @@ def test_set_root_weights_extrinsic( ): # Arrange with patch.object( - mock_subtensor, "_do_set_weights", return_value=(expected_success, "Mock error") + mock_subtensor, + "_do_set_root_weights", + return_value=(expected_success, "Mock error"), ), patch.object( mock_subtensor, "min_allowed_weights", return_value=0 ), patch.object(mock_subtensor, "max_weight_limit", return_value=1), patch( diff --git a/tests/unit_tests/test_axon.py b/tests/unit_tests/test_axon.py index 36d0ba2d00..cfb46c32c2 100644 --- a/tests/unit_tests/test_axon.py +++ b/tests/unit_tests/test_axon.py @@ -17,15 +17,18 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. + # Standard Lib import re from dataclasses import dataclass + from typing import Any from unittest import IsolatedAsyncioTestCase from unittest.mock import AsyncMock, MagicMock, patch # Third Party import netaddr + import pytest from starlette.requests import Request from fastapi.testclient import TestClient diff --git a/tests/unit_tests/test_subtensor.py b/tests/unit_tests/test_subtensor.py index 4f4ef29077..c3a295d078 100644 --- a/tests/unit_tests/test_subtensor.py +++ b/tests/unit_tests/test_subtensor.py @@ -313,8 +313,13 @@ def test_get_error_info_by_index_known_error(subtensor): assert description == "Description one" -def test_get_error_info_by_index_unknown_error(subtensor): - mock_logger = mock.patch.object(_logger, "warning").start() +@pytest.fixture +def mock_logger(): + with mock.patch.object(_logger, "warning") as mock_warning: + yield mock_warning + + +def test_get_error_info_by_index_unknown_error(subtensor, mock_logger): fake_index = 999 name, description = subtensor.get_error_info_by_index(fake_index) assert name == "Unknown Error" diff --git a/tests/unit_tests/utils/test_utils.py b/tests/unit_tests/utils/test_utils.py index b03ab6e99c..3c077aba78 100644 --- a/tests/unit_tests/utils/test_utils.py +++ b/tests/unit_tests/utils/test_utils.py @@ -17,6 +17,8 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +import logging + import numpy as np import bittensor.utils.weight_utils as weight_utils import pytest @@ -230,19 +232,38 @@ def test_convert_root_weight_uids_and_vals_to_tensor_edge_cases( @pytest.mark.parametrize( "test_id, n, uids, weights, subnets, exception", [ - ("error-1", 3, [1, 3], [100, 200], [1, 2], Exception), # uid not in subnets - ("error-2", 3, [1, 2, 3], [100, 200], [1], Exception), # More uids than subnets + # uid not in subnets + ( + "error-1", + 3, + [1, 3], + [100, 200], + [1, 2], + "The subnet is unavailable at the moment.", + ), + # More uids than subnets + ( + "error-2", + 3, + [1, 2, 3], + [100, 200], + [1], + "The subnet is unavailable at the moment.", + ), ], ) def test_convert_root_weight_uids_and_vals_to_tensor_error_cases( - test_id, n, uids, weights, subnets, exception + test_id, n, uids, weights, subnets, exception, caplog ): - # Act and Assert - with pytest.raises(exception): + with caplog.at_level(logging.WARNING): weight_utils.convert_root_weight_uids_and_vals_to_tensor( n, uids, weights, subnets ) - print(f"Failed {test_id}") + + assert any( + exception in record.message and record.levelname == "WARNING" + for record in caplog.records + ) @pytest.mark.parametrize( diff --git a/tests/unit_tests/utils/test_weight_utils.py b/tests/unit_tests/utils/test_weight_utils.py index edf334db50..66f3c8127a 100644 --- a/tests/unit_tests/utils/test_weight_utils.py +++ b/tests/unit_tests/utils/test_weight_utils.py @@ -17,6 +17,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +import logging import numpy as np import bittensor.utils.weight_utils as weight_utils import pytest @@ -384,19 +385,38 @@ def test_convert_root_weight_uids_and_vals_to_tensor_edge_cases( @pytest.mark.parametrize( "test_id, n, uids, weights, subnets, exception", [ - ("error-1", 3, [1, 3], [100, 200], [1, 2], Exception), # uid not in subnets - ("error-2", 3, [1, 2, 3], [100, 200], [1], Exception), # More uids than subnets + # uid not in subnets + ( + "error-1", + 3, + [1, 3], + [100, 200], + [1, 2], + "The subnet is unavailable at the moment.", + ), + # More uids than subnets + ( + "error-2", + 3, + [1, 2, 3], + [100, 200], + [1], + "The subnet is unavailable at the moment.", + ), ], ) def test_convert_root_weight_uids_and_vals_to_tensor_error_cases( - test_id, n, uids, weights, subnets, exception + test_id, n, uids, weights, subnets, exception, caplog ): - # Act and Assert - with pytest.raises(exception): + with caplog.at_level(logging.WARNING): weight_utils.convert_root_weight_uids_and_vals_to_tensor( n, uids, weights, subnets ) - print(f"Failed {test_id}") + + assert any( + exception in record.message and record.levelname == "WARNING" + for record in caplog.records + ) @pytest.mark.parametrize(