bittensor.core.extrinsics.asyncex.weights#
This module provides sync functionality for working with weights in the Bittensor network.
Functions#
|
Commits a hash of the neuron's weights to the Bittensor blockchain using the provided wallet. |
|
Reveals the weights for a specific subnet on the Bittensor blockchain using the provided wallet. |
|
Sets the given weights and values on chain for wallet hotkey account. |
|
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:
- 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 valuedescribing the success or potential error.
- Return type:
- 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 passeduid
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 returnsFalse
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 returnsFalse
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
.
- Flag is
- 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:
subtensor (bittensor.core.async_subtensor.AsyncSubtensor)
call (scalecodec.types.GenericCall)
wallet (bittensor_wallet.Wallet)
wait_for_inclusion (bool)
wait_for_finalization (bool)
period (Optional[int])