diff --git a/bittensor/core/async_subtensor.py b/bittensor/core/async_subtensor.py index c4503b4142..77ec7afd47 100644 --- a/bittensor/core/async_subtensor.py +++ b/bittensor/core/async_subtensor.py @@ -126,7 +126,8 @@ def __init__( network: The network name or type to connect to. config: Configuration object for the AsyncSubtensor instance. log_verbose: Enables or disables verbose logging. - fallback_endpoints: List of fallback endpoints to use if default or provided network is not available. Defaults to `None`. + fallback_endpoints: List of fallback endpoints to use if default or provided network is not available. + Defaults to `None`. retry_forever: Whether to retry forever on connection errors. Defaults to `False`. _mock: Whether this is a mock instance. Mainly just for use in testing. @@ -293,7 +294,8 @@ def _get_substrate( """Creates the Substrate instance based on provided arguments. Arguments: - fallback_endpoints: List of fallback endpoints to use if default or provided network is not available. Defaults to `None`. + fallback_endpoints: List of fallback endpoints to use if default or provided network is not available. + Defaults to `None`. retry_forever: Whether to retry forever on connection errors. Defaults to `False`. _mock: Whether this is a mock instance. Mainly just for use in testing. @@ -712,9 +714,9 @@ async def commit( wallet (bittensor_wallet.Wallet): The wallet associated with the neuron committing the data. netuid (int): The unique identifier of the subnetwork. data (str): The data to be committed to the network. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Return: bool: `True` if the commit was successful, `False` otherwise. @@ -725,6 +727,7 @@ async def commit( netuid=netuid, data_type=f"Raw{len(data)}", data=data.encode(), + period=period, ) set_commitment = commit @@ -1266,7 +1269,8 @@ async def get_all_revealed_commitments( reuse_block (bool): Whether to reuse the last-used block hash. Returns: - result (dict): A dictionary of all revealed commitments in view {ss58_address: (reveal block, commitment message)}. + result (dict): A dictionary of all revealed commitments in view + {ss58_address: (reveal block, commitment message)}. Example of result: { @@ -3006,12 +3010,12 @@ async def set_reveal_commitment( wallet (bittensor_wallet.Wallet): The wallet associated with the neuron committing the data. netuid (int): The unique identifier of the subnetwork. data (str): The data to be committed to the network. - blocks_until_reveal (int): The number of blocks from now after which the data will be revealed. Defaults to `360`. - The number of blocks in one epoch. + blocks_until_reveal (int): The number of blocks from now after which the data will be revealed. + Defaults to `360` (the number of blocks in one epoch). block_time (Union[int, float]): The number of seconds between each block. Defaults to `12`. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: bool: `True` if the commitment was successful, `False` otherwise. @@ -3030,7 +3034,7 @@ async def set_reveal_commitment( subtensor=self, wallet=wallet, netuid=netuid, - data_type=f"TimelockEncrypted", + data_type="TimelockEncrypted", data=data_, period=period, ), reveal_round @@ -3385,9 +3389,9 @@ async def sign_and_send_extrinsic( wait_for_finalization (bool): whether to wait until the extrinsic call is finalized on the chain sign_with: the wallet's keypair to use for the signing. Options are "coldkey", "hotkey", "coldkeypub" use_nonce: unique identifier for the transaction related with hot/coldkey. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. nonce_key: the type on nonce to use. Options are "hotkey" or "coldkey". nonce_key: the type on nonce to use. Options are "hotkey", "coldkey", or "coldkeypub". raise_error: raises a relevant exception rather than returning `False` if unsuccessful. @@ -3460,8 +3464,9 @@ async def add_stake( period: Optional[int] = None, ) -> bool: """ - Adds a stake from the specified wallet to the neuron identified by the SS58 address of its hotkey in specified subnet. - Staking is a fundamental process in the Bittensor network that enables neurons to participate actively and earn incentives. + Adds a stake from the specified wallet to the neuron identified by the SS58 address of its hotkey in specified + subnet. Staking is a fundamental process in the Bittensor network that enables neurons to participate + actively and earn incentives. Args: wallet: The wallet to be used for staking. @@ -3560,9 +3565,9 @@ async def burned_register( `False`. wait_for_finalization (bool, optional): Waits for the transaction to be finalized on the blockchain. Defaults to `True`. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: bool: ``True`` if the registration is successful, False otherwise. @@ -3615,9 +3620,9 @@ async def commit_weights( wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. Default is ``False``. max_retries (int): The number of maximum attempts to commit weights. Default is ``5``. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: tuple[bool, str]: @@ -3690,9 +3695,9 @@ async def move_stake( amount (Balance): Amount of stake to move. wait_for_inclusion (bool): Waits for the transaction to be included in a block. wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: success (bool): True if the stake movement was successful. @@ -3748,9 +3753,9 @@ async def register( num_processes (Optional[int]): The number of processes to use to register. Default to `None`. update_interval (Optional[int]): The number of nonces to solve between updates. Default to `None`. log_verbose (bool): If ``true``, the registration process will log more information. Default to `False`. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: bool: ``True`` if the registration is successful, False otherwise. @@ -3787,13 +3792,13 @@ async def register_subnet( Args: wallet (bittensor_wallet.Wallet): The wallet to be used for subnet registration. - wait_for_inclusion (bool): 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. Default is False. + wait_for_inclusion (bool): 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. Default is `False`. wait_for_finalization (bool): 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. Default is True. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: bool: True if the subnet registration was successful, False otherwise. @@ -3836,9 +3841,9 @@ async def reveal_weights( wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. Default is ``False``. max_retries (int): The number of maximum attempts to reveal weights. Default is ``5``. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: tuple[bool, str]: ``True`` if the weight revelation is successful, False otherwise. And `msg`, a string @@ -3891,9 +3896,9 @@ async def root_register( wait_for_inclusion (bool): Waits for the transaction to be included in a block. Default is ``False``. wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. Default is ``False``. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: `True` if registration was successful, otherwise `False`. @@ -3929,9 +3934,9 @@ async def root_set_weights( ``False``. wait_for_finalization (bool, optional): Waits for the transaction to be finalized on the blockchain. Defaults to ``False``. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: `True` if the setting of weights is successful, `False` otherwise. @@ -3972,9 +3977,9 @@ async def set_children( wait_for_inclusion (bool): Waits for the transaction to be included in a block. wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. raise_error: Raises a relevant exception rather than returning `False` if unsuccessful. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: tuple[bool, str]: A tuple where the first element is a boolean indicating success or failure of the @@ -4045,9 +4050,9 @@ async def set_delegate_take( wait_for_inclusion (bool): Waits for the transaction to be included in a block. wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. raise_error: Raises a relevant exception rather than returning `False` if unsuccessful. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: tuple[bool, str]: A tuple where the first element is a boolean indicating success or failure of the @@ -4058,7 +4063,8 @@ async def set_delegate_take( DelegateTakeTooLow: Delegate take is too low. DelegateTxRateLimitExceeded: A transactor exceeded the rate limit for delegate transaction. HotKeyAccountNotExists: The hotkey does not exist. - NonAssociatedColdKey: Request to stake, unstake, or subscribe is made by a coldkey that is not associated with the hotkey account. + NonAssociatedColdKey: Request to stake, unstake, or subscribe is made by a coldkey that is not associated + with the hotkey account. bittensor_wallet.errors.PasswordError: Decryption failed or wrong password for decryption provided. bittensor_wallet.errors.KeyFileError: Failed to decode keyfile data. @@ -4123,11 +4129,13 @@ async def set_subnet_identity( netuid (int): The unique ID of the network on which the operation takes place. subnet_identity (SubnetIdentity): The identity data of the subnet including attributes like name, GitHub repository, contact, URL, discord, description, and any additional metadata. - wait_for_inclusion (bool): Indicates if the function should wait for the transaction to be included in the block. - wait_for_finalization (bool): Indicates if the function should wait for the transaction to reach finalization. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + wait_for_inclusion (bool): Indicates if the function should wait for the transaction to be included in the + block. + wait_for_finalization (bool): Indicates if the function should wait for the transaction to reach + finalization. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: tuple[bool, str]: A tuple where the first element is a boolean indicating success or failure of the @@ -4163,7 +4171,7 @@ async def set_weights( period: Optional[int] = 8, ): """ - Sets the inter-neuronal weights for the specified neuron. This process involves specifying the influence or + Sets the interneuronal weights for the specified neuron. This process involves specifying the influence or trust a neuron places on other neurons in the network, which is a fundamental aspect of Bittensor's decentralized learning architecture. @@ -4181,9 +4189,9 @@ async def set_weights( ``False``. max_retries (int): The number of maximum attempts to set weights. Default is ``5``. block_time (float): The number of seconds for block duration. Default is 12.0 seconds. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. Default is 16. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Default is 8. Returns: tuple[bool, str]: ``True`` if the setting of weights is successful, False otherwise. And `msg`, a string @@ -4289,9 +4297,9 @@ async def serve_axon( ``True``. certificate (bittensor.utils.Certificate): Certificate to use for TLS. If ``None``, no TLS will be used. Defaults to ``None``. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: bool: ``True`` if the Axon serve registration is successful, False otherwise. @@ -4318,17 +4326,19 @@ async def start_call( period: Optional[int] = None, ) -> tuple[bool, str]: """ - Submits a start_call extrinsic to the blockchain, to trigger the start call process for a subnet (used to start a - new subnet's emission mechanism). + Submits a start_call extrinsic to the blockchain, to trigger the start call process for a subnet (used to start + a new subnet's emission mechanism). Args: wallet (Wallet): The wallet used to sign the extrinsic (must be unlocked). netuid (int): The UID of the target subnet for which the call is being initiated. - wait_for_inclusion (bool, optional): Whether to wait for the extrinsic to be included in a block. Defaults to True. - wait_for_finalization (bool, optional): Whether to wait for finalization of the extrinsic. Defaults to False. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + wait_for_inclusion (bool, optional): Whether to wait for the extrinsic to be included in a block. + Defaults to `True`. + wait_for_finalization (bool, optional): Whether to wait for finalization of the extrinsic. + Defaults to `False`. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: Tuple[bool, str]: @@ -4379,9 +4389,9 @@ async def swap_stake( rate_tolerance (float): The maximum allowed increase in the price ratio between subnets (origin_price/destination_price). For example, 0.005 = 0.5% maximum increase. Only used when safe_staking is True. Default is 0.005. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: success (bool): True if the extrinsic was successful. @@ -4432,9 +4442,9 @@ async def transfer( wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. Default is ``False``. keep_alive (bool): Flag to keep the connection alive. Default is ``True``. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: `True` if the transferring was successful, otherwise `False`. """ @@ -4475,9 +4485,9 @@ async def transfer_stake( amount (Balance): Amount to transfer. wait_for_inclusion (bool): If true, waits for inclusion before returning. wait_for_finalization (bool): If true, waits for finalization before returning. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: success (bool): True if the transfer was successful. @@ -4529,10 +4539,10 @@ async def unstake( exceed the threshold. Default is False. rate_tolerance (float): The maximum allowed price change ratio when unstaking. For example, 0.005 = 0.5% maximum price decrease. Only used when safe_staking is True. Default is 0.005. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. - unstake_all: If true, unstakes all tokens. Default is ``False``. If `True` amount is ignored. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. + unstake_all: If `True`, unstakes all tokens and `amount` is ignored. Default is `False` Returns: bool: ``True`` if the unstaking process is successful, False otherwise. @@ -4580,9 +4590,9 @@ async def unstake_multiple( unstakes all available stakes. wait_for_inclusion (bool): Waits for the transaction to be included in a block. wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. unstake_all: If true, unstakes all tokens. Default is ``False``. If `True` amounts are ignored. Returns: diff --git a/bittensor/core/subtensor.py b/bittensor/core/subtensor.py index bb0806159d..a612793f5a 100644 --- a/bittensor/core/subtensor.py +++ b/bittensor/core/subtensor.py @@ -128,7 +128,8 @@ def __init__( network: The network name or type to connect to. config: Configuration object for the AsyncSubtensor instance. log_verbose: Enables or disables verbose logging. - fallback_endpoints: List of fallback endpoints to use if default or provided network is not available. Defaults to `None`. + fallback_endpoints: List of fallback endpoints to use if default or provided network is not available. + Defaults to `None`. retry_forever: Whether to retry forever on connection errors. Defaults to `False`. _mock: Whether this is a mock instance. Mainly just for use in testing. @@ -176,7 +177,8 @@ def _get_substrate( """Creates the Substrate instance based on provided arguments. Arguments: - fallback_endpoints: List of fallback chains endpoints to use if main network isn't available. Defaults to `None`. + fallback_endpoints: List of fallback chains endpoints to use if main network isn't available. + Defaults to `None`. retry_forever: Whether to retry forever on connection errors. Defaults to `False`. _mock: Whether this is a mock instance. Mainly just for use in testing. @@ -975,7 +977,8 @@ def get_all_revealed_commitments( block (Optional[int]): The block number to retrieve the commitment from. Default is ``None``. Returns: - result (dict): A dictionary of all revealed commitments in view {ss58_address: (reveal block, commitment message)}. + result (dict): A dictionary of all revealed commitments in view + {ss58_address: (reveal block, commitment message)}. Example of result: { @@ -2359,7 +2362,7 @@ def set_reveal_commitment( subtensor=self, wallet=wallet, netuid=netuid, - data_type=f"TimelockEncrypted", + data_type="TimelockEncrypted", data=data_, period=period, ), reveal_round @@ -2622,9 +2625,9 @@ def sign_and_send_extrinsic( wait_for_finalization (bool): whether to wait until the extrinsic call is finalized on the chain sign_with (str): the wallet's keypair to use for the signing. Options are "coldkey", "hotkey", "coldkeypub" use_nonce (bool): unique identifier for the transaction related with hot/coldkey. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. nonce_key: the type on nonce to use. Options are "hotkey" or "coldkey". raise_error: raises the relevant exception rather than returning `False` if unsuccessful. @@ -2663,7 +2666,7 @@ def sign_and_send_extrinsic( ) # We only wait here if we expect finalization. if not wait_for_finalization and not wait_for_inclusion: - message = f"Not waiting for finalization or inclusion." + message = "Not waiting for finalization or inclusion." logging.debug(f"{message}. Extrinsic: {extrinsic}") return True, message @@ -2697,8 +2700,9 @@ def add_stake( period: Optional[int] = None, ) -> bool: """ - Adds a stake from the specified wallet to the neuron identified by the SS58 address of its hotkey in specified subnet. - Staking is a fundamental process in the Bittensor network that enables neurons to participate actively and earn incentives. + Adds a stake from the specified wallet to the neuron identified by the SS58 address of its hotkey in specified + subnet. Staking is a fundamental process in the Bittensor network that enables neurons to participate + actively and earn incentives. Args: wallet: The wallet to be used for staking. @@ -2763,9 +2767,9 @@ def add_stake_multiple( amounts (list[Balance]): Corresponding amounts of TAO to stake for each hotkey. wait_for_inclusion (bool): Waits for the transaction to be included in a block. wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: bool: ``True`` if the staking is successful for all specified neurons, False otherwise. @@ -2803,9 +2807,9 @@ def burned_register( `False`. wait_for_finalization (bool, optional): Waits for the transaction to be finalized on the blockchain. Defaults to `True`. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: bool: ``True`` if the registration is successful, False otherwise. @@ -2858,9 +2862,9 @@ def commit_weights( wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. Default is ``False``. max_retries (int): The number of maximum attempts to commit weights. Default is ``5``. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: tuple[bool, str]: @@ -2933,9 +2937,9 @@ def move_stake( amount (Balance): Amount of stake to move. wait_for_inclusion (bool): Waits for the transaction to be included in a block. wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: success (bool): True if the stake movement was successful. @@ -2991,9 +2995,9 @@ def register( num_processes (Optional[int]): The number of processes to use to register. Default to `None`. update_interval (Optional[int]): The number of nonces to solve between updates. Default to `None`. log_verbose (bool): If ``true``, the registration process will log more information. Default to `False`. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: bool: ``True`` if the registration is successful, False otherwise. @@ -3030,13 +3034,13 @@ def register_subnet( Args: wallet (bittensor_wallet.Wallet): The wallet to be used for subnet registration. - wait_for_inclusion (bool): 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. Default is False. + wait_for_inclusion (bool): 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. Default is `False`. wait_for_finalization (bool): 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. Default is True. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + `True`, or returns `False` if the extrinsic fails to be finalized within the timeout. Default is `True`. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: bool: True if the subnet registration was successful, False otherwise. @@ -3078,9 +3082,9 @@ def reveal_weights( wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. Default is ``False``. max_retries (int): The number of maximum attempts to reveal weights. Default is ``5``. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: tuple[bool, str]: ``True`` if the weight revelation is successful, False otherwise. And `msg`, a string @@ -3130,9 +3134,9 @@ def root_register( wait_for_inclusion (bool): Waits for the transaction to be included in a block. Default is ``False``. wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. Default is ``False``. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: `True` if registration was successful, otherwise `False`. @@ -3168,9 +3172,9 @@ def root_set_weights( ``False``. wait_for_finalization (bool, optional): Waits for the transaction to be finalized on the blockchain. Defaults to ``False``. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: `True` if the setting of weights is successful, `False` otherwise. @@ -3210,9 +3214,9 @@ def set_children( wait_for_inclusion (bool): Waits for the transaction to be included in a block. wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. raise_error: Raises a relevant exception rather than returning `False` if unsuccessful. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: tuple[bool, str]: A tuple where the first element is a boolean indicating success or failure of the @@ -3283,9 +3287,9 @@ def set_delegate_take( wait_for_inclusion (bool): Waits for the transaction to be included in a block. wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. raise_error: Raises a relevant exception rather than returning `False` if unsuccessful. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: tuple[bool, str]: A tuple where the first element is a boolean indicating success or failure of the @@ -3296,7 +3300,8 @@ def set_delegate_take( DelegateTakeTooLow: Delegate take is too low. DelegateTxRateLimitExceeded: A transactor exceeded the rate limit for delegate transaction. HotKeyAccountNotExists: The hotkey does not exist. - NonAssociatedColdKey: Request to stake, unstake, or subscribe is made by a coldkey that is not associated with the hotkey account. + NonAssociatedColdKey: Request to stake, unstake, or subscribe is made by a coldkey that is not associated + with the hotkey account. bittensor_wallet.errors.PasswordError: Decryption failed or wrong password for decryption provided. bittensor_wallet.errors.KeyFileError: Failed to decode keyfile data. @@ -3361,11 +3366,13 @@ def set_subnet_identity( netuid (int): The unique ID of the network on which the operation takes place. subnet_identity (SubnetIdentity): The identity data of the subnet including attributes like name, GitHub repository, contact, URL, discord, description, and any additional metadata. - wait_for_inclusion (bool): Indicates if the function should wait for the transaction to be included in the block. - wait_for_finalization (bool): Indicates if the function should wait for the transaction to reach finalization. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + wait_for_inclusion (bool): Indicates if the function should wait for the transaction to be included in the + block. + wait_for_finalization (bool): Indicates if the function should wait for the transaction to reach + finalization. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: tuple[bool, str]: A tuple where the first element is a boolean indicating success or failure of the @@ -3401,7 +3408,7 @@ def set_weights( period: Optional[int] = 8, ) -> tuple[bool, str]: """ - Sets the inter-neuronal weights for the specified neuron. This process involves specifying the influence or + Sets the interneuronal weights for the specified neuron. This process involves specifying the influence or trust a neuron places on other neurons in the network, which is a fundamental aspect of Bittensor's decentralized learning architecture. @@ -3410,18 +3417,19 @@ def set_weights( netuid: The unique identifier of the subnet. uids: The list of neuron UIDs that the weights are being set for. weights: The corresponding weights to be set for each UID. - version_key: Version key for compatibility with the network. Default is int representation of a Bittensor version. + version_key: Version key for compatibility with the network. Default is int representation of a Bittensor + version. wait_for_inclusion: Waits for the transaction to be included in a block. Default is ``False``. wait_for_finalization: Waits for the transaction to be finalized on the blockchain. Default is ``False``. max_retries: The number of maximum attempts to set weights. Default is ``5``. block_time: The number of seconds for block duration. Default is 12.0 seconds. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. Default is 16. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Default is 8. Returns: tuple: - ``True`` if the setting of weights is successful, False otherwise. + `True` if the setting of weights is successful, `False` otherwise. `msg` is a string value describing the success or potential error. This function is crucial in shaping the network's collective intelligence, where each neuron's learning and @@ -3513,9 +3521,9 @@ def serve_axon( ``True``. certificate (bittensor.utils.Certificate): Certificate to use for TLS. If ``None``, no TLS will be used. Defaults to ``None``. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: bool: ``True`` if the Axon serve registration is successful, False otherwise. @@ -3542,17 +3550,19 @@ def start_call( period: Optional[int] = None, ) -> tuple[bool, str]: """ - Submits a start_call extrinsic to the blockchain, to trigger the start call process for a subnet (used to start a - new subnet's emission mechanism). + Submits a start_call extrinsic to the blockchain, to trigger the start call process for a subnet (used to start + a new subnet's emission mechanism). Args: wallet (Wallet): The wallet used to sign the extrinsic (must be unlocked). netuid (int): The UID of the target subnet for which the call is being initiated. - wait_for_inclusion (bool, optional): Whether to wait for the extrinsic to be included in a block. Defaults to True. - wait_for_finalization (bool, optional): Whether to wait for finalization of the extrinsic. Defaults to False. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + wait_for_inclusion (bool, optional): Whether to wait for the extrinsic to be included in a block. + Defaults to `True`. + wait_for_finalization (bool, optional): Whether to wait for finalization of the extrinsic. + Defaults to `False`. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: Tuple[bool, str]: @@ -3603,9 +3613,9 @@ def swap_stake( rate_tolerance (float): The maximum allowed increase in the price ratio between subnets (origin_price/destination_price). For example, 0.005 = 0.5% maximum increase. Only used when safe_staking is True. Default is 0.005. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: success (bool): True if the extrinsic was successful. @@ -3656,9 +3666,9 @@ def transfer( wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. Default is ``False``. keep_alive (bool): Flag to keep the connection alive. Default is ``True``. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: `True` if the transferring was successful, otherwise `False`. @@ -3700,9 +3710,9 @@ def transfer_stake( amount (Union[Balance, float, int]): Amount to transfer. wait_for_inclusion (bool): If true, waits for inclusion before returning. wait_for_finalization (bool): If true, waits for finalization before returning. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. Returns: success (bool): True if the transfer was successful. @@ -3754,10 +3764,10 @@ def unstake( exceed the tolerance. Default is False. rate_tolerance (float): The maximum allowed price change ratio when unstaking. For example, 0.005 = 0.5% maximum price decrease. Only used when safe_staking is True. Default is 0.005. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. - unstake_all: If true, unstakes all tokens. Default is ``False``. If `True` amount is ignored. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. + unstake_all: If `True`, unstakes all tokens, and `amount` is ignored. Default is `False`. Returns: bool: ``True`` if the unstaking process is successful, False otherwise. @@ -3806,10 +3816,10 @@ def unstake_multiple( unstakes all available stakes. wait_for_inclusion (bool): Waits for the transaction to be included in a block. wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain. - period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted. If - the transaction is not included in a block within that number of blocks, it will expire and be rejected. - You can think of it as an expiration date for the transaction. - unstake_all: If true, unstakes all tokens. Default is ``False``. If `True` amounts are ignored. + period (Optional[int]): The number of blocks during which the transaction will remain valid after it's + submitted. If the transaction is not included in a block within that number of blocks, it will expire + and be rejected. You can think of it as an expiration date for the transaction. + unstake_all: If `True`, unstakes all tokens, and `amounts` is ignored. Default is `False`. Returns: bool: ``True`` if the batch unstaking is successful, False otherwise.