bittensor.core.extrinsics.asyncex.weights#

This module provides sync functionality for working with weights in the Bittensor network.

Functions#

commit_weights_extrinsic(subtensor, wallet, netuid, ...)

Commits a hash of the neuron's weights to the Bittensor blockchain using the provided wallet.

reveal_weights_extrinsic(subtensor, wallet, netuid, ...)

Reveals the weights for a specific subnet on the Bittensor blockchain using the provided wallet.

set_weights_extrinsic(subtensor, wallet, netuid, uids, ...)

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

sign_and_send_with_nonce(subtensor, call, wallet, ...)

Signs an extrinsic call with the wallet hotkey, adding an optional era for period

Module Contents#

async bittensor.core.extrinsics.asyncex.weights.commit_weights_extrinsic(subtensor, wallet, netuid, commit_hash, wait_for_inclusion=False, wait_for_finalization=False)#

Commits a hash of the neuron’s weights to the Bittensor blockchain using the provided wallet. This function is a wrapper around the do_commit_weights method.

Parameters:
  • subtensor (bittensor.core.async_subtensor.AsyncSubtensor) – The subtensor instance used for blockchain interaction.

  • wallet (bittensor_wallet.Wallet) – The wallet associated with the neuron committing the weights.

  • netuid (int) – The unique identifier of the subnet.

  • commit_hash (str) – The hash of the neuron’s weights to be committed.

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

Returns:

True if the weight commitment is successful, False otherwise. And msg, a string value describing the success or potential error.

Return type:

tuple[bool, str]

This function provides a user-friendly interface for committing weights to the Bittensor blockchain, ensuring proper

error handling and user interaction when required.

async bittensor.core.extrinsics.asyncex.weights.reveal_weights_extrinsic(subtensor, wallet, netuid, uids, weights, salt, version_key, wait_for_inclusion=False, wait_for_finalization=False)#

Reveals the weights for a specific subnet on the Bittensor blockchain using the provided wallet. This function is a wrapper around the _do_reveal_weights method.

Parameters:
  • subtensor (bittensor.core.async_subtensor.AsyncSubtensor) – The subtensor instance used for blockchain interaction.

  • wallet (bittensor_wallet.Wallet) – The wallet associated with the neuron revealing the weights.

  • netuid (int) – The unique identifier of the subnet.

  • uids (list[int]) – List of neuron UIDs for which weights are being revealed.

  • weights (list[int]) – List of weight values corresponding to each UID.

  • salt (list[int]) – List of salt values corresponding to the hash function.

  • version_key (int) – Version key for compatibility with the network.

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

Returns:

True if the weight revelation is successful, False otherwise. And msg, a string value

describing the success or potential error.

Return type:

tuple[bool, str]

This function provides a user-friendly interface for revealing weights on the Bittensor blockchain, ensuring proper

error handling and user interaction when required.

async bittensor.core.extrinsics.asyncex.weights.set_weights_extrinsic(subtensor, wallet, netuid, uids, 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) – Bittensor subtensor object.

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

  • netuid (int) – The netuid of the subnet to set weights for.

  • uids (Union[NDArray[np.int64], torch.LongTensor, list]) – The uint64 uids of destination neurons.

  • weights (Union[NDArray[np.float32], torch.FloatTensor, list]) – The weights to set. These must be float s and correspond to the passed uid 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:

Flag is True if extrinsic was finalized or included in the block. If we did not wait for

finalization / inclusion, the response is True.

Return type:

success (bool)

async bittensor.core.extrinsics.asyncex.weights.sign_and_send_with_nonce(subtensor, call, wallet, wait_for_inclusion, wait_for_finalization, period=None)#

Signs an extrinsic call with the wallet hotkey, adding an optional era for period

Parameters: