From 20db6ce3680381adccc3ad0dacaad3aa21d41ee6 Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Wed, 5 Feb 2025 13:46:59 -0800 Subject: [PATCH 1/2] Updates identity, sn identity, and other chain stuff --- bittensor_cli/cli.py | 31 ++++++++++-- bittensor_cli/src/__init__.py | 2 +- bittensor_cli/src/bittensor/chain_data.py | 12 ++++- .../src/bittensor/subtensor_interface.py | 4 +- bittensor_cli/src/bittensor/utils.py | 47 ++++++++++++++++--- bittensor_cli/src/commands/subnets/subnets.py | 18 ++++++- bittensor_cli/src/commands/wallets.py | 10 ++-- bittensor_cli/src/commands/weights.py | 2 +- 8 files changed, 104 insertions(+), 22 deletions(-) diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index 074ad8743..bea9f0cc8 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -2340,7 +2340,7 @@ def wallet_set_id( "--image", help="The image URL for the identity.", ), - discord_handle: str = typer.Option( + discord: str = typer.Option( "", "--discord", help="The Discord handle for the identity.", @@ -2350,11 +2350,16 @@ def wallet_set_id( "--description", help="The description for the identity.", ), - additional_info: str = typer.Option( + additional: str = typer.Option( "", "--additional", help="Additional details for the identity.", ), + github_repo: str = typer.Option( + "", + "--github", + help="The GitHub repository for the identity.", + ), quiet: bool = Options.quiet, verbose: bool = Options.verbose, prompt: bool = Options.prompt, @@ -2407,9 +2412,10 @@ def wallet_set_id( name, web_url, image_url, - discord_handle, + discord, description, - additional_info, + additional, + github_repo, ) return self._run_command( @@ -2422,6 +2428,7 @@ def wallet_set_id( identity["discord"], identity["description"], identity["additional"], + identity["github_repo"], prompt, ) ) @@ -4103,6 +4110,18 @@ def subnets_create( "--email", help="Contact email for subnet", ), + subnet_url: Optional[str] = typer.Option( + None, "--subnet-url", "--url", help="Subnet URL" + ), + discord: Optional[str] = typer.Option( + None, "--discord-handle", "--discord", help="Discord handle" + ), + description: Optional[str] = typer.Option( + None, "--description", help="Description" + ), + additional_info: Optional[str] = typer.Option( + None, "--additional-info", help="Additional information" + ), prompt: bool = Options.prompt, quiet: bool = Options.quiet, verbose: bool = Options.verbose, @@ -4130,6 +4149,10 @@ def subnets_create( subnet_name=subnet_name, github_repo=github_repo, subnet_contact=subnet_contact, + subnet_url=subnet_url, + discord=discord, + description=description, + additional=additional_info, ) success = self._run_command( subnets.create(wallet, self.initialize_chain(network), identity, prompt), diff --git a/bittensor_cli/src/__init__.py b/bittensor_cli/src/__init__.py index 6d3b805c3..92a00caa8 100644 --- a/bittensor_cli/src/__init__.py +++ b/bittensor_cli/src/__init__.py @@ -646,7 +646,7 @@ class WalletValidationTypes(Enum): "kappa": "sudo_set_kappa", "difficulty": "sudo_set_difficulty", "bonds_moving_avg": "sudo_set_bonds_moving_average", - "commit_reveal_period": "sudo_set_commit_reveal_weights_interval", + "commit_reveal_period": "sudo_set_commit_reveal_period", "commit_reveal_weights_enabled": "sudo_set_commit_reveal_weights_enabled", "alpha_values": "sudo_set_alpha_values", "liquid_alpha_enabled": "sudo_set_liquid_alpha_enabled", diff --git a/bittensor_cli/src/bittensor/chain_data.py b/bittensor_cli/src/bittensor/chain_data.py index 68c7c9035..3b5a4c89a 100644 --- a/bittensor_cli/src/bittensor/chain_data.py +++ b/bittensor_cli/src/bittensor/chain_data.py @@ -179,7 +179,7 @@ def _fix_decoded( max_validators=decoded.get("max_validators"), adjustment_alpha=decoded.get("adjustment_alpha"), difficulty=decoded.get("difficulty"), - commit_reveal_period=decoded.get("commit_reveal_weights_interval"), + commit_reveal_period=decoded.get("commit_reveal_period"), commit_reveal_weights_enabled=decoded.get("commit_reveal_weights_enabled"), alpha_high=decoded.get("alpha_high"), alpha_low=decoded.get("alpha_low"), @@ -574,7 +574,7 @@ def _fix_decoded(cls, decoded: "SubnetInfo") -> "SubnetInfo": str(int(netuid)): u16_normalized_float(int(req)) for (netuid, req) in decoded.get("network_connect") }, - emission_value=decoded.get("emission_values"), + emission_value=decoded.get("emission_value"), burn=Balance.from_rao(decoded.get("burn")), owner_ss58=decode_account_id(decoded.get("owner")), ) @@ -587,6 +587,10 @@ class SubnetIdentity(InfoBase): subnet_name: str github_repo: str subnet_contact: str + subnet_url: str + discord: str + description: str + additional: str @classmethod def _fix_decoded(cls, decoded: dict) -> "SubnetIdentity": @@ -594,6 +598,10 @@ def _fix_decoded(cls, decoded: dict) -> "SubnetIdentity": subnet_name=bytes(decoded["subnet_name"]).decode(), github_repo=bytes(decoded["github_repo"]).decode(), subnet_contact=bytes(decoded["subnet_contact"]).decode(), + subnet_url=bytes(decoded["subnet_url"]).decode(), + discord=bytes(decoded["discord"]).decode(), + description=bytes(decoded["description"]).decode(), + additional=bytes(decoded["additional"]).decode(), ) diff --git a/bittensor_cli/src/bittensor/subtensor_interface.py b/bittensor_cli/src/bittensor/subtensor_interface.py index 5b0d6c9ac..8c464062b 100644 --- a/bittensor_cli/src/bittensor/subtensor_interface.py +++ b/bittensor_cli/src/bittensor/subtensor_interface.py @@ -839,7 +839,7 @@ async def query_all_identities( identities = await self.substrate.query_map( module="SubtensorModule", - storage_function="Identities", + storage_function="IdentitiesV2", block_hash=block_hash, reuse_block_hash=reuse_block, ) @@ -877,7 +877,7 @@ async def query_identity( """ identity_info = await self.query( module="SubtensorModule", - storage_function="Identities", + storage_function="IdentitiesV2", params=[key], block_hash=block_hash, reuse_block_hash=reuse_block, diff --git a/bittensor_cli/src/bittensor/utils.py b/bittensor_cli/src/bittensor/utils.py index 5e8091a79..11dbdeab5 100644 --- a/bittensor_cli/src/bittensor/utils.py +++ b/bittensor_cli/src/bittensor/utils.py @@ -1039,9 +1039,10 @@ def prompt_for_identity( name: Optional[str], web_url: Optional[str], image_url: Optional[str], - discord_handle: Optional[str], + discord: Optional[str], description: Optional[str], - additional_info: Optional[str], + additional: Optional[str], + github_repo: Optional[str], ): """ Prompts the user for identity fields with validation. @@ -1053,9 +1054,10 @@ def prompt_for_identity( ("name", "[blue]Display name[/blue]", name), ("url", "[blue]Web URL[/blue]", web_url), ("image", "[blue]Image URL[/blue]", image_url), - ("discord", "[blue]Discord handle[/blue]", discord_handle), + ("discord", "[blue]Discord handle[/blue]", discord), ("description", "[blue]Description[/blue]", description), - ("additional", "[blue]Additional information[/blue]", additional_info), + ("additional", "[blue]Additional information[/blue]", additional), + ("github_repo", "[blue]GitHub repository URL[/blue]", github_repo), ] text_rejection = partial( @@ -1069,9 +1071,10 @@ def prompt_for_identity( name, web_url, image_url, - discord_handle, + discord, description, - additional_info, + additional, + github_repo, ] ): console.print( @@ -1096,6 +1099,10 @@ def prompt_for_subnet_identity( subnet_name: Optional[str], github_repo: Optional[str], subnet_contact: Optional[str], + subnet_url: Optional[str], + discord: Optional[str], + description: Optional[str], + additional: Optional[str], ): """ Prompts the user for required subnet identity fields with validation. @@ -1133,6 +1140,34 @@ def prompt_for_subnet_identity( lambda x: x and not is_valid_contact(x), "[red]Error:[/red] Please enter a valid email address.", ), + ( + "subnet_url", + "[blue]Subnet URL [dim](optional)[/blue]", + subnet_url, + lambda x: x and sys.getsizeof(x) > 113, + "[red]Error:[/red] Please enter a valid URL.", + ), + ( + "discord", + "[blue]Discord handle [dim](optional)[/blue]", + discord, + lambda x: x and sys.getsizeof(x) > 113, + "[red]Error:[/red] Please enter a valid Discord handle.", + ), + ( + "description", + "[blue]Description [dim](optional)[/blue]", + description, + lambda x: x and sys.getsizeof(x) > 113, + "[red]Error:[/red] Description must be <= 64 raw bytes.", + ), + ( + "additional", + "[blue]Additional information [dim](optional)[/blue]", + additional, + lambda x: x and sys.getsizeof(x) > 113, + "[red]Error:[/red] Additional information must be <= 64 raw bytes.", + ), ] for key, prompt, value, rejection_func, rejection_msg in fields: diff --git a/bittensor_cli/src/commands/subnets/subnets.py b/bittensor_cli/src/commands/subnets/subnets.py index b68f9892a..c7a8f7bcf 100644 --- a/bittensor_cli/src/commands/subnets/subnets.py +++ b/bittensor_cli/src/commands/subnets/subnets.py @@ -122,6 +122,18 @@ async def _find_event_attributes_in_extrinsic_receipt( "subnet_contact": subnet_identity["subnet_contact"].encode() if subnet_identity.get("subnet_contact") else b"", + "subnet_url": subnet_identity["subnet_url"].encode() + if subnet_identity.get("subnet_url") + else b"", + "discord": subnet_identity["discord"].encode() + if subnet_identity.get("discord") + else b"", + "description": subnet_identity["description"].encode() + if subnet_identity.get("description") + else b"", + "additional": subnet_identity["additional"].encode() + if subnet_identity.get("additional") + else b"", } for field, value in identity_data.items(): max_size = 64 # bytes @@ -1391,9 +1403,10 @@ async def create( name=None, web_url=None, image_url=None, - discord_handle=None, + discord=None, description=None, - additional_info=None, + additional=None, + github_repo=None, ) await set_id( @@ -1405,6 +1418,7 @@ async def create( identity["discord"], identity["description"], identity["additional"], + identity["github_repo"], prompt, ) diff --git a/bittensor_cli/src/commands/wallets.py b/bittensor_cli/src/commands/wallets.py index 5d9217d52..4d0b339b5 100644 --- a/bittensor_cli/src/commands/wallets.py +++ b/bittensor_cli/src/commands/wallets.py @@ -1296,9 +1296,10 @@ async def set_id( name: str, web_url: str, image_url: str, - discord_handle: str, + discord: str, description: str, - additional_info: str, + additional: str, + github_repo: str, prompt: bool, ): """Create a new or update existing identity on-chain.""" @@ -1307,9 +1308,10 @@ async def set_id( "name": name.encode(), "url": web_url.encode(), "image": image_url.encode(), - "discord": discord_handle.encode(), + "discord": discord.encode(), "description": description.encode(), - "additional": additional_info.encode(), + "additional": additional.encode(), + "github_repo": github_repo.encode(), } for field, value in identity_data.items(): diff --git a/bittensor_cli/src/commands/weights.py b/bittensor_cli/src/commands/weights.py index caf5e72f7..df3815827 100644 --- a/bittensor_cli/src/commands/weights.py +++ b/bittensor_cli/src/commands/weights.py @@ -148,7 +148,7 @@ async def _commit_reveal( ) -> tuple[bool, str]: interval = int( await self.subtensor.get_hyperparameter( - param_name="get_commit_reveal_weights_interval", + param_name="get_commit_reveal_period", netuid=self.netuid, reuse_block=False, ) From 596301f2bc046064dc8c0f8a565858c7ee3f5213 Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Wed, 5 Feb 2025 13:58:55 -0800 Subject: [PATCH 2/2] Updates sudo for cr interval setting --- bittensor_cli/src/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor_cli/src/__init__.py b/bittensor_cli/src/__init__.py index 92a00caa8..6d3b805c3 100644 --- a/bittensor_cli/src/__init__.py +++ b/bittensor_cli/src/__init__.py @@ -646,7 +646,7 @@ class WalletValidationTypes(Enum): "kappa": "sudo_set_kappa", "difficulty": "sudo_set_difficulty", "bonds_moving_avg": "sudo_set_bonds_moving_average", - "commit_reveal_period": "sudo_set_commit_reveal_period", + "commit_reveal_period": "sudo_set_commit_reveal_weights_interval", "commit_reveal_weights_enabled": "sudo_set_commit_reveal_weights_enabled", "alpha_values": "sudo_set_alpha_values", "liquid_alpha_enabled": "sudo_set_liquid_alpha_enabled",