diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index 143189d17..47f831f14 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -4067,7 +4067,8 @@ def stake_swap( """ self.verbosity_handler(quiet, verbose, json_output) console.print( - "[dim]This command moves stake from one subnet to another subnet while keeping the same coldkey-hotkey pair.[/dim]" + "[dim]This command moves stake from one subnet to another subnet while keeping " + "the same coldkey-hotkey pair.[/dim]" ) wallet = self.wallet_ask( @@ -4222,7 +4223,8 @@ def stake_set_children( proportions = list_prompt( proportions, float, - "Enter comma-separated proportions equal to the number of children (sum not exceeding a total of 1.0)", + "Enter comma-separated proportions equal to the number of children " + "(sum not exceeding a total of 1.0)", ) if len(proportions) != len(children): @@ -4340,7 +4342,8 @@ def stake_childkey_take( None, "--take", "-t", - help="Use to set the take value for your child hotkey. When not used, the command will fetch the current take value.", + help="Use to set the take value for your child hotkey. When not used, the command will fetch the current " + "take value.", prompt=False, ), wait_for_inclusion: bool = Options.wait_for_inclusion, diff --git a/bittensor_cli/src/bittensor/chain_data.py b/bittensor_cli/src/bittensor/chain_data.py index ddbbc7249..1b9d87093 100644 --- a/bittensor_cli/src/bittensor/chain_data.py +++ b/bittensor_cli/src/bittensor/chain_data.py @@ -749,7 +749,9 @@ def tao_to_alpha_with_slippage( self, tao: Balance ) -> tuple[Balance, Balance, float]: """ - Returns an estimate of how much Alpha would a staker receive if they stake their tao using the current pool state. + Returns an estimate of how much Alpha would a staker receive if they stake their tao using the current pool + state. + Args: tao: Amount of TAO to stake. Returns: @@ -792,7 +794,9 @@ def alpha_to_tao_with_slippage( self, alpha: Balance ) -> tuple[Balance, Balance, float]: """ - Returns an estimate of how much TAO would a staker receive if they unstake their alpha using the current pool state. + Returns an estimate of how much TAO would a staker receive if they unstake their alpha using the current pool + state. + Args: alpha: Amount of Alpha to stake. Returns: diff --git a/bittensor_cli/src/bittensor/extrinsics/registration.py b/bittensor_cli/src/bittensor/extrinsics/registration.py index bcd809bdd..0eaa27606 100644 --- a/bittensor_cli/src/bittensor/extrinsics/registration.py +++ b/bittensor_cli/src/bittensor/extrinsics/registration.py @@ -524,9 +524,11 @@ async def get_neuron_for_pubkey_and_subnet(): if prompt: if not Confirm.ask( f"Continue Registration?\n" - f" hotkey [{COLOR_PALETTE['GENERAL']['HOTKEY']}]({wallet.hotkey_str})[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]:\t[{COLOR_PALETTE['GENERAL']['HOTKEY']}]{wallet.hotkey.ss58_address}[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]\n" - f" coldkey [{COLOR_PALETTE['GENERAL']['COLDKEY']}]({wallet.name})[/{COLOR_PALETTE['GENERAL']['COLDKEY']}]:\t[{COLOR_PALETTE['GENERAL']['COLDKEY']}]{wallet.coldkeypub.ss58_address}[/{COLOR_PALETTE['GENERAL']['COLDKEY']}]\n" - f" network:\t\t[{COLOR_PALETTE['GENERAL']['LINKS']}]{subtensor.network}[/{COLOR_PALETTE['GENERAL']['LINKS']}]\n" + f" hotkey [{COLOR_PALETTE.G.HK}]({wallet.hotkey_str})[/{COLOR_PALETTE.G.HK}]:" + f"\t[{COLOR_PALETTE.G.HK}]{wallet.hotkey.ss58_address}[/{COLOR_PALETTE.G.HK}]\n" + f" coldkey [{COLOR_PALETTE.G.CK}]({wallet.name})[/{COLOR_PALETTE.G.CK}]:" + f"\t[{COLOR_PALETTE.G.CK}]{wallet.coldkeypub.ss58_address}[/{COLOR_PALETTE.G.CK}]\n" + f" network:\t\t[{COLOR_PALETTE.G.LINKS}]{subtensor.network}[/{COLOR_PALETTE.G.LINKS}]\n" ): return False @@ -611,7 +613,6 @@ async def get_neuron_for_pubkey_and_subnet(): if not wait_for_finalization and not wait_for_inclusion: success, err_msg = True, "" else: - await response.process_events() success = await response.is_success if not success: success, err_msg = ( @@ -689,6 +690,7 @@ async def burned_register_extrinsic( `False` if the extrinsic fails to enter the block within the timeout. :param wait_for_finalization: If set, waits for the extrinsic to be finalized on the chain before returning `True`, or returns `False` if the extrinsic fails to be finalized within the timeout. + :param era: the period (in blocks) for which the transaction should remain valid. :param prompt: If `True`, the call waits for confirmation from the user before proceeding. :return: Flag is `True` if extrinsic was finalized or included in the block. If we did not wait for @@ -735,10 +737,10 @@ async def burned_register_extrinsic( if not neuron.is_null: console.print( ":white_heavy_check_mark: [dark_sea_green3]Already Registered[/dark_sea_green3]:\n" - f"uid: [{COLOR_PALETTE['GENERAL']['NETUID_EXTRA']}]{neuron.uid}[/{COLOR_PALETTE['GENERAL']['NETUID_EXTRA']}]\n" - f"netuid: [{COLOR_PALETTE['GENERAL']['NETUID']}]{neuron.netuid}[/{COLOR_PALETTE['GENERAL']['NETUID']}]\n" - f"hotkey: [{COLOR_PALETTE['GENERAL']['HOTKEY']}]{neuron.hotkey}[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]\n" - f"coldkey: [{COLOR_PALETTE['GENERAL']['COLDKEY']}]{neuron.coldkey}[/{COLOR_PALETTE['GENERAL']['COLDKEY']}]" + f"uid: [{COLOR_PALETTE.G.NETUID_EXTRA}]{neuron.uid}[/{COLOR_PALETTE.G.NETUID_EXTRA}]\n" + f"netuid: [{COLOR_PALETTE.G.NETUID}]{neuron.netuid}[/{COLOR_PALETTE.G.NETUID}]\n" + f"hotkey: [{COLOR_PALETTE.G.HK}]{neuron.hotkey}[/{COLOR_PALETTE.G.HK}]\n" + f"coldkey: [{COLOR_PALETTE.G.CK}]{neuron.coldkey}[/{COLOR_PALETTE.G.CK}]" ) return True @@ -781,7 +783,8 @@ async def burned_register_extrinsic( console.print( "Balance:\n" - f" [blue]{old_balance}[/blue] :arrow_right: [{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]{new_balance}[/{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]" + f" [blue]{old_balance}[/blue] :arrow_right: " + f"[{COLOR_PALETTE.S.STAKE_AMOUNT}]{new_balance}[/{COLOR_PALETTE.S.STAKE_AMOUNT}]" ) if len(netuids_for_hotkey) > 0: @@ -914,7 +917,6 @@ async def run_faucet_extrinsic( ) # process if registration successful, try again if pow is still valid - await response.process_events() if not await response.is_success: err_console.print( f":cross_mark: [red]Failed[/red]: " @@ -1757,7 +1759,8 @@ async def swap_hotkey_extrinsic( ) if not len(netuids_registered) > 0: err_console.print( - f"Destination hotkey [dark_orange]{new_wallet.hotkey.ss58_address}[/dark_orange] is not registered. Please register and try again" + f"Destination hotkey [dark_orange]{new_wallet.hotkey.ss58_address}[/dark_orange] is not registered. " + f"Please register and try again" ) return False @@ -1774,7 +1777,8 @@ async def swap_hotkey_extrinsic( ): return False print_verbose( - f"Swapping {wallet.name}'s hotkey ({wallet.hotkey.ss58_address}) with {new_wallet.name}s hotkey ({new_wallet.hotkey.ss58_address})" + f"Swapping {wallet.name}'s hotkey ({wallet.hotkey.ss58_address}) with " + f"{new_wallet.name}s hotkey ({new_wallet.hotkey.ss58_address})" ) with console.status(":satellite: Swapping hotkeys...", spinner="aesthetic"): call = await subtensor.substrate.compose_call( diff --git a/bittensor_cli/src/bittensor/extrinsics/root.py b/bittensor_cli/src/bittensor/extrinsics/root.py index 29b9e510c..6b91d4699 100644 --- a/bittensor_cli/src/bittensor/extrinsics/root.py +++ b/bittensor_cli/src/bittensor/extrinsics/root.py @@ -410,7 +410,6 @@ async def _do_set_weights(): if not wait_for_finalization and not wait_for_inclusion: return True, "Not waiting for finalization or inclusion." - await response.process_events() if await response.is_success: return True, "Successfully set weights." else: diff --git a/bittensor_cli/src/bittensor/extrinsics/transfer.py b/bittensor_cli/src/bittensor/extrinsics/transfer.py index 0deefc467..3796353e6 100644 --- a/bittensor_cli/src/bittensor/extrinsics/transfer.py +++ b/bittensor_cli/src/bittensor/extrinsics/transfer.py @@ -37,6 +37,7 @@ async def transfer_extrinsic( :param wallet: Bittensor wallet object to make transfer from. :param destination: Destination public key address (ss58_address or ed25519) of recipient. :param amount: Amount to stake as Bittensor balance. + :param era: Length (in blocks) for which the transaction should be valid. :param transfer_all: Whether to transfer all funds from this wallet to the destination address. :param wait_for_inclusion: If set, waits for the extrinsic to enter a block before returning `True`, or returns `False` if the extrinsic fails to enter the block within the timeout. @@ -97,7 +98,6 @@ async def do_transfer() -> tuple[bool, str, str]: return True, "", "" # Otherwise continue with finalization. - await response.process_events() if await response.is_success: block_hash_ = response.block_hash return True, block_hash_, "" @@ -156,7 +156,8 @@ async def do_transfer() -> tuple[bool, str, str]: if not Confirm.ask( "Do you want to transfer:[bold white]\n" f" amount: [bright_cyan]{amount}[/bright_cyan]\n" - f" from: [light_goldenrod2]{wallet.name}[/light_goldenrod2] : [bright_magenta]{wallet.coldkey.ss58_address}\n[/bright_magenta]" + f" from: [light_goldenrod2]{wallet.name}[/light_goldenrod2] : " + f"[bright_magenta]{wallet.coldkey.ss58_address}\n[/bright_magenta]" f" to: [bright_magenta]{destination}[/bright_magenta]\n for fee: [bright_cyan]{fee}[/bright_cyan]" ): return False diff --git a/bittensor_cli/src/bittensor/subtensor_interface.py b/bittensor_cli/src/bittensor/subtensor_interface.py index ecd58f7c7..7f21f90d4 100644 --- a/bittensor_cli/src/bittensor/subtensor_interface.py +++ b/bittensor_cli/src/bittensor/subtensor_interface.py @@ -1057,6 +1057,7 @@ async def sign_and_send_extrinsic( :param wallet: the wallet whose coldkey will be used to sign the extrinsic :param wait_for_inclusion: whether to wait until the extrinsic call is included on the chain :param wait_for_finalization: whether to wait until the extrinsic call is finalized on the chain + :param era: The length (in blocks) for which a transaction should be valid. :return: (success, error message) """ @@ -1075,7 +1076,6 @@ async def sign_and_send_extrinsic( # We only wait here if we expect finalization. if not wait_for_finalization and not wait_for_inclusion: return True, "" - await response.process_events() if await response.is_success: return True, "" else: @@ -1372,11 +1372,11 @@ async def get_stake_for_coldkeys( This function is useful for analyzing the stake distribution and delegation patterns of multiple accounts simultaneously, offering a broader perspective on network participation and investment strategies. """ - BATCH_SIZE = 60 + batch_size = 60 tasks = [] - for i in range(0, len(coldkey_ss58_list), BATCH_SIZE): - ss58_chunk = coldkey_ss58_list[i : i + BATCH_SIZE] + for i in range(0, len(coldkey_ss58_list), batch_size): + ss58_chunk = coldkey_ss58_list[i : i + batch_size] tasks.append( self.query_runtime_api( runtime_api="StakeInfoRuntimeApi", diff --git a/bittensor_cli/src/bittensor/utils.py b/bittensor_cli/src/bittensor/utils.py index aedfe2ef3..b24cea568 100644 --- a/bittensor_cli/src/bittensor/utils.py +++ b/bittensor_cli/src/bittensor/utils.py @@ -1053,6 +1053,7 @@ def get_effective_network(config, network: Optional[list[str]]) -> str: the configuration, and the default. """ if network: + network_ = "" for item in network: if item.startswith("ws"): network_ = item @@ -1309,7 +1310,8 @@ def print_linux_dependency_message(): "\tAdd this into the file and save: [green]deb http://archive.ubuntu.com/ubuntu jammy main universe[/green]" ) console.print( - "\tUpdate the repository and install the webkit dependency: [green]sudo apt update && sudo apt install libwebkit2gtk-4.0-dev[/green]" + "\tUpdate the repository and install the webkit dependency: [green]sudo apt update && sudo apt install " + "libwebkit2gtk-4.0-dev[/green]" ) console.print("\nFedora / CentOS / AlmaLinux:") console.print("[green]sudo dnf install gtk3-devel webkit2gtk3-devel[/green]\n\n") diff --git a/bittensor_cli/src/commands/stake/remove.py b/bittensor_cli/src/commands/stake/remove.py index 9130e6c52..657722327 100644 --- a/bittensor_cli/src/commands/stake/remove.py +++ b/bittensor_cli/src/commands/stake/remove.py @@ -798,7 +798,6 @@ async def _unstake_all_extrinsic( wait_for_inclusion=True, wait_for_finalization=False, ) - await response.process_events() if not await response.is_success: err_out( diff --git a/bittensor_cli/src/commands/subnets/subnets.py b/bittensor_cli/src/commands/subnets/subnets.py index a856304c2..b9d323083 100644 --- a/bittensor_cli/src/commands/subnets/subnets.py +++ b/bittensor_cli/src/commands/subnets/subnets.py @@ -178,7 +178,6 @@ async def _find_event_attributes_in_extrinsic_receipt( if not wait_for_finalization and not wait_for_inclusion: return True - await response.process_events() if not await response.is_success: err_console.print( f":cross_mark: [red]Failed[/red]: {format_error_message(await response.error_message)}" diff --git a/bittensor_cli/src/commands/weights.py b/bittensor_cli/src/commands/weights.py index 29337be42..2c40a0018 100644 --- a/bittensor_cli/src/commands/weights.py +++ b/bittensor_cli/src/commands/weights.py @@ -260,7 +260,6 @@ async def _do_set_weights(): if not self.wait_for_finalization and not self.wait_for_inclusion: return True, "Not waiting for finalization or inclusion." - await response.process_events() if await response.is_success: return True, "Successfully set weights." else: @@ -316,7 +315,6 @@ async def reveal_weights_extrinsic( success, error_message = True, "" else: - await response.process_events() if await response.is_success: success, error_message = True, "" else: @@ -354,7 +352,6 @@ async def do_commit_weights(self, commit_hash): if not self.wait_for_finalization and not self.wait_for_inclusion: return True, None - await response.process_events() if await response.is_success: return True, None else: diff --git a/tests/e2e_tests/utils.py b/tests/e2e_tests/utils.py index 665a4fa2f..9379b962e 100644 --- a/tests/e2e_tests/utils.py +++ b/tests/e2e_tests/utils.py @@ -297,5 +297,4 @@ async def call_add_proposal( wait_for_finalization=True, ) - await response.process_events() return await response.is_success