bittensor.core.extrinsics.async_root#

Functions#

_do_set_root_weights(subtensor, wallet, netuids, weights)

Sets the root weights on the Subnet for the given wallet hotkey account.

_get_limits(subtensor)

Retrieves the minimum allowed weights and maximum weight limit for the given subnet.

root_register_extrinsic(subtensor, wallet, netuid[, ...])

Registers the wallet to root network.

set_root_weights_extrinsic(subtensor, wallet, netuids, ...)

Sets the given weights and values on chain for wallet hotkey account.

Module Contents#

async bittensor.core.extrinsics.async_root._do_set_root_weights(subtensor, wallet, netuids, weights, version_key=0, wait_for_inclusion=False, wait_for_finalization=False)#

Sets the root weights on the Subnet for the given wallet hotkey account.

This function constructs and submits an extrinsic to set the root weights for the given wallet hotkey account. It waits for inclusion or finalization of the extrinsic based on the provided parameters.

Parameters:
  • subtensor (bittensor.core.async_subtensor.AsyncSubtensor) – The AsyncSubtensor object used to interact with the blockchain.

  • wallet (bittensor_wallet.Wallet) – The wallet containing the hotkey and coldkey for the transaction.

  • netuids (Union[NDArray[np.int64], list[int]]) – List of UIDs to set weights for.

  • weights (Union[NDArray[np.float32], list[float]]) – Corresponding weights to set for each UID.

  • version_key (int, optional) – The version key of the validator. Defaults to 0.

  • wait_for_inclusion (bool, optional) – If True, waits for the extrinsic to be included in a block. Defaults to False.

  • wait_for_finalization (bool, optional) – If True, waits for the extrinsic to be finalized on the chain. Defaults to False.

Returns:

Returns a tuple containing a boolean indicating success and a message describing the result of the operation.

Return type:

tuple

async bittensor.core.extrinsics.async_root._get_limits(subtensor)#

Retrieves the minimum allowed weights and maximum weight limit for the given subnet.

These values are fetched asynchronously using asyncio.gather to run both requests concurrently.

Parameters:

subtensor (AsyncSubtensor) – The AsyncSubtensor object used to interface with the network’s substrate node.

Returns:

A tuple containing:
  • min_allowed_weights (int): The minimum allowed weights.

  • max_weight_limit (float): The maximum weight limit, normalized to a float value.

Return type:

tuple[int, float]

async bittensor.core.extrinsics.async_root.root_register_extrinsic(subtensor, wallet, netuid, wait_for_inclusion=True, wait_for_finalization=True)#

Registers the wallet to root network.

Parameters:
  • subtensor (bittensor.core.async_subtensor.AsyncSubtensor) – The AsyncSubtensor object

  • wallet (bittensor_wallet.Wallet) – Bittensor wallet object.

  • netuid (int) – Subnet uid.

  • 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.

  • 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.

Returns:

True if extrinsic was finalized or included in the block. If we did not wait for finalization/inclusion, the response is True.

Return type:

bool

async bittensor.core.extrinsics.async_root.set_root_weights_extrinsic(subtensor, wallet, netuids, weights, version_key=0, wait_for_inclusion=False, wait_for_finalization=False)#

Sets the given weights and values on chain for wallet hotkey account.

Parameters:
  • subtensor (bittensor.core.async_subtensor.AsyncSubtensor) – The AsyncSubtensor object

  • wallet (bittensor_wallet.Wallet) – Bittensor wallet object.

  • netuids (Union[NDArray[np.int64], list[int]]) – The netuid of the subnet to set weights for.

  • weights (Union[NDArray[np.float32], list[float]]) – Weights to set. These must be float s and must correspond to the passed netuid s.

  • version_key (int) – The version key of the validator.

  • 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.

  • 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.

Returns:

True if extrinsic was finalized or included in the block. If we did not wait for finalization/inclusion, the response is True.

Return type:

bool