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 a given wallet hotkey account. |
Module Contents#
- async bittensor.core.extrinsics.asyncex.weights.commit_weights_extrinsic(subtensor, wallet, netuid, commit_hash, wait_for_inclusion=False, wait_for_finalization=False, period=None)[source]#
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.
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 weight commitment is successful, False otherwise. msg is 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, period=None)[source]#
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.
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 weight commitment is successful, False otherwise. msg is a string value describing 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, period=8)[source]#
Sets the given weights and values on chain for a given 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.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 weight commitment is successful, False otherwise. msg is a string value describing the success or potential error.
- Return type: