Skip to content

Commit 536315f

Browse files
committed
Updates the readme file
1 parent 941a492 commit 536315f

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

README.md

+27-11
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,36 @@ def get_encrypted_commit(
1212
uids: Union[NDArray[np.int64], "torch.LongTensor"],
1313
weights: Union[NDArray[np.float32], "torch.FloatTensor"],
1414
version_key: int,
15-
subnet_reveal_period_epochs: int = 1,
16-
block_time: int = 12,
17-
tempo: int = 360
15+
tempo: int,
16+
current_block: int,
17+
netuid: int,
18+
subnet_reveal_period_epochs: int,
19+
block_time: int = 12
1820
) -> tuple[bytes, int]:
1921
"""Returns encrypted commit and target round for `commit_crv3_weights` extrinsic.
2022
2123
Arguments:
2224
uids: The uids to commit.
2325
weights: The weights associated with the uids.
2426
version_key: The version key to use for committing and revealing. Default is `bittensor.core.settings.version_as_int`.
25-
subnet_reveal_period_epochs: Number of epochs after which the revive will be performed. Corresponds to hyperparameter 'commit_reveal_weights_interval' of the subnet. In epochs.
26-
block_time: Amount if seconds in one block. In seconds.
27-
tempo: Amount of blocks in one Epoch.
28-
27+
tempo: Number of blocks in one epoch.
28+
current_block: The current block number in the network.
29+
netuid: The network unique identifier (NetUID) for the subnet.
30+
subnet_reveal_period_epochs: Number of epochs after which the reveal will be performed. Corresponds to the hyperparameter `commit_reveal_weights_interval` of the subnet. In epochs.
31+
block_time: Amount of time in seconds for one block. Defaults to 12 seconds.
32+
2933
Returns:
30-
commit (bites): hex value of encrypted and compressed uids and weights values for setting weights.
34+
commit (bytes): Hex value of encrypted and compressed uids and weights values for setting weights.
3135
target_round (int): Drand round number when weights have to be revealed. Based on Drand Quicknet network.
32-
"""
36+
"""
3337
# function logic
3438
return commit, target_round
3539
```
3640

3741

3842
To test the function run in terminal:
43+
1. Spin up a local subtensor branch which includes CR3
44+
2. Create a subnet with netuid 1 (or replace the netuid with the one you create)
3945
```bash
4046
mkdir test
4147
cd test
@@ -54,10 +60,20 @@ then copy-past to ipython
5460
import numpy as np
5561
import bittensor_commit_reveal as crv3
5662
from bittensor.utils.weight_utils import convert_weights_and_uids_for_emit
63+
import bittensor as bt
5764

5865
uids = [1, 3]
5966
weights = [0.3, 0.7]
6067
version_key = 843000
68+
netuid = 1
69+
70+
subtensor = bt.Subtensor("local")
71+
72+
subnet_reveal_period_epochs = subtensor.get_subnet_reveal_period_epochs(
73+
netuid=netuid
74+
)
75+
tempo = subtensor.get_subnet_hyperparameters(netuid).tempo
76+
current_block = subtensor.get_current_block()
6177

6278
if isinstance(uids, list):
6379
uids = np.array(uids, dtype=np.int64)
@@ -66,7 +82,7 @@ if isinstance(weights, list):
6682

6783
uids, weights = convert_weights_and_uids_for_emit(uids, weights)
6884

69-
print(crv3.get_encrypted_commit(uids, weights, version_key))
85+
print(crv3.get_encrypted_commit(uids, weights, version_key, tempo, current_block, netuid, subnet_reveal_period_epochs))
7086
```
7187
expected result
7288
```python
@@ -159,7 +175,7 @@ import bittensor as bt
159175

160176
sub = bt.Subtensor(network="local")
161177

162-
netuid = 1 # your created subnets netuid
178+
netuid = 1 # your created subnet's netuid
163179

164180
print(sub.weights(netuid=netuid))
165181
```

0 commit comments

Comments
 (0)