Skip to content

Commit f0e3fee

Browse files
authored
Merge pull request #130 from latent-to/btcli-stake
updated btcli child hotkey commands
2 parents df5f474 + 679e98a commit f0e3fee

File tree

2 files changed

+68
-110
lines changed

2 files changed

+68
-110
lines changed

docs/learn/chain-rate-limits.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ This rate limit prevents frequent changes to delegate take percentages.
3636
- Chain State Variable: `TxDelegateTakeRateLimit`
3737
- Error message: [`DelegateTxRateLimitExceeded`](../errors/subtensor.md#delegatetxratelimitexceeded)
3838

39-
### Child key take rate limit
40-
41-
This rate limit prevents the owner of a child hotkey from making frequent changes to the child key take percentages. This protects against rapid manipulation of child key relationships and ensures stability in the child key delegation system.
42-
43-
- Rate Limit: 216,000 blocks (~30 days)
44-
- Chain State Variable: `TxChildkeyTakeRateLimit`
45-
- Error message: [`TxChildkeyTakeRateLimitExceeded`](../errors/subtensor.md#txchildkeytakeratelimitexceeded)
4639

4740
### Hotkey swap rate limit
4841

@@ -123,6 +116,24 @@ This rate limit controls how frequently a user can perform staking operations (a
123116
- Rate Limit: 1 per block
124117
- Chain State Variable: `StakingOperationRateLimiter` (Bool, since limit is 1 operation)
125118
- Error message: [`StakingOperationRateLimitExceeded`](../errors/subtensor.md#stakingoperationratelimitexceeded)
119+
120+
121+
### Child hotkey operations rate limit
122+
123+
This rate limit controls how frequently a parent hotkey can set or revoke child hotkeys on a specific subnet. Note that revoking children is implemented by calling `set_children` with an empty list, so both operations share the same rate limit.
124+
125+
- Rate Limit: 150 blocks (~30 minutes)
126+
- Source Code: [rate_limiting.rs](https://github.com/opentensor/subtensor/blob/main/pallets/subtensor/src/utils/rate_limiting.rs#L25-L28)
127+
- Error message: [`TxRateLimitExceeded`](../errors/subtensor.md#txratelimitexceeded)
128+
129+
### Child key take rate limit
130+
131+
This rate limit prevents the owner of a child hotkey from making frequent changes to the child key take percentages.
132+
133+
- Rate Limit: 216,000 blocks (~30 days)
134+
- Chain State Variable: `TxChildkeyTakeRateLimit`
135+
- Error message: [`TxChildkeyTakeRateLimitExceeded`](../errors/subtensor.md#txchildkeytakeratelimitexceeded)
136+
126137
## Subnet-specific rate limits
127138

128139
This section discusses rate limits that apply within a specific subnet on the network. These limits are typically configurable at the subnet level.

docs/validators/child-hotkeys.md

Lines changed: 50 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: "Child Hotkeys"
3+
toc_max_heading_level: 2
34
---
45

56
import ThemedImage from '@theme/ThemedImage';
@@ -64,10 +65,10 @@ The child hotkey features are as follows:
6465

6566
The following rate limits apply for child hotkeys:
6667

67-
- A child hotkey's take rate can only be adjusted once per 30 days.
68-
- One successful execution of `set_children` or `revoke_children` is allowed for every 720 blocks.
68+
- Setting or revoking children is allowed for every 150 blocks (~30 minutes).
69+
- A given child hotkey's take rate can only be adjusted once per 30 days.
6970

70-
See [Rate Limits in Bittensor](../learn/chain-rate-limits.md).
71+
See [Rate Limits in Bittensor: Child hotkey operations rate limit](../learn/chain-rate-limits#child-hotkey-operations-rate-limit).
7172

7273
## Minimum stake requirement
7374

@@ -84,49 +85,41 @@ The minimum stake requirement is:
8485
Query `subtensorModule.stakeThreshold()` to check the current threshold.
8586
:::
8687

87-
8888
## Child hotkey commands
8989

9090
Use the `btcli` command options described below to work with child hotkeys.
9191

9292
## Setting a child hotkey
9393

94-
This command assigns a proportion of the parent hotkey's stake weight to the child hotkeys. Specific proportion for each child hotkey can be set. The parent hotkey must be registered on at least one `netuid`. This `netuid` need not be the same `netuid` used in this command. Only the stake TAO of the parent hotkey can be assigned to the child hotkeys.
94+
You can allocate a portion of the parent hotkeys stake weight to its child hotkeys, specifying the exact proportion for each one. The parent hotkey must be registered on at least one netuid, but it doesn’t have to be registered on the same netuid where the child weights are being set. However, all child hotkeys assigned must be registered on the netuid specified in the command.
9595

9696
### Usage
9797

9898
```bash
99-
btcli stake set_children --netuid <netuid> --children <a list of SS58 child hotkeys> --proportions <a list of decimal numbers> --hotkey <parent hotkey> --wallet.name <coldkey>
99+
btcli stake child set --netuid <netuid> --children <a list of SS58 child hotkeys> --proportions <a list of decimal numbers> --hotkey <parent hotkey> --wallet.name <coldkey>
100100
```
101101

102102
### Parameters
103103

104-
- `--netuid:` Integer. Should be a single integer value representing a current subnet's `netuid`.
105-
- Must be greater than `0` (`netuid 0` is not allowed).
106-
- Integer values greater than the value of current subnet limit, i.e., greater than the value of `subtensorModule.subnetLimit()`, will be rejected with an error message and the command will stop.
107-
- All child hotkeys used in this command must be already registered on this `netuid`.
108-
- `--children`: SS58. A comma-separated ordered list of SS58 hotkeys for child hotkeys.
104+
- `--netuid:` The netuid of the subnet in the network. Value must be greater than zero.
105+
- `--children`: A comma-separated ordered list of SS58 hotkeys for the child hotkeys.
106+
- `--proportions`: A comma-separated ordered list of the stake weight proportions for the child hotkeys listed in the `--children` parameter.
107+
- `--hotkey`: A single SS58 of the parent hotkey. This must be a delegate hotkey that is already registered in with any `netuid`.
108+
- `--wallet.name`: Name of the wallet or the SS58 of the coldkey. This coldkey must be matched with the parent hotkey SS58 of the `--hotkey`.
109109

110-
- There should be a maximum of five, 5, SS58 hotkeys in this comma-separated list. If there are more than five hotkeys, the command will issue an error message and stop.
111-
- The number of list elements should match the number of elements passed in the `--proportions` parameter. If the number of list elements do not match, the command will issue an error and stop.
112-
- All hotkeys used here must be already registered on the `netuid` used in this command.
110+
:::info
113111

114-
- `--proportions`: Floating. A comma-separated ordered list of floating values. Each proportion value of the parent hotkey's stake weight will be assigned to the corresponding child hotkey in the `--children` parameter.
115-
- Each floating value should be a number greater than zero and equal to or less than `1.0`.
116-
- If a value is zero, the corresponding child hotkey will be revoked.
117-
- If a value is greater than `1.0`, the command will issue an error message and stop.
118-
- All the proportions for a given `netuid` must sum to less than or equal to `1.0`. If the proportions sum to greater than `1.0`, the command will issue an error message and stop.
119-
- `--hotkey`: SS58. A single SS58 of the parent hotkey. This must be a delegate hotkey that is already registered in with any `netuid`. This `netuid` need not be the same `netuid` used in this command.
120-
- If this parent hotkey has zero stake, then the command will issue an error message and stop.
121-
- Note that this `--hotkey` parameter expects parent hotkey whereas the `--hotkey` parameter of the [Setting child hotkey take](#parameters-1) expects child hotkey.
122-
- `--wallet.name`: String or SS58. Name of the wallet or the SS58 of the coldkey. This coldkey must be matched with the parent hotkey SS58 of the `--hotkey`. If the coldkey and the parent hotkey do not match, the command will issue an error message and stop.
112+
- The `--children` and `--proportions` parameters can each include up to five comma-separated values.
113+
- The sum of all proportion values for the child hotkeys should be less than or equal to 1.
114+
- All hotkeys listed in the `--children` parameter must be already registered on the `netuid` used in this command.
115+
- Only the staked TAO of the parent hotkey can be assigned to the child hotkeys. If the parent hotkey has zero stake, then the command will issue an error message and stop.
123116

124-
### Examples
117+
:::
125118

126119
#### Setting a single child hotkey
127120

128121
```bash
129-
btcli stake set_children \
122+
btcli stake child set \
130123
--netuid 4 \
131124
--children 5HEXVAHY9gyavj5xnbov9Qoba4hPJYkkwwnq1MQFepLK7Gei \
132125
--proportions 0.5 \
@@ -137,144 +130,98 @@ btcli stake set_children \
137130
#### Setting multiple child hotkeys
138131

139132
```bash
140-
btcli stake set_children \
133+
btcli stake child set \
141134
--netuid 4 \
142135
--children 5Gx1CZ9jviC6V2KynBAcTpES4yK76riCagv5o5SFFZFYXj4s,5HEXVAHY9gyavj5xnbov9Qoba4hPJYkkwwnq1MQFepLK7Gei \
143136
--proportions 0.3,0.7 \
144137
--hotkey 5DqJdDLU23m7yf6rZSmbLTshU7Bfn9eCTBkduhF4r9i73B9Y \
145-
--wallet.name Alice
138+
--wallet.name Alice\
146139
```
147140

148141
## Adding a new child hotkey
149142

150-
If a parent hotkey has, for example, three child hotkeys: child hotkey A, child hotkey B and child hotkey C, then to add a fourth child hotkey D, you must run `set_children` command again with the parent hotkey and all four child hotkeys A, B, C and D.
143+
If a parent hotkey has, for example, three child hotkeys: `child hotkey A`, `child hotkey B` and `child hotkey C`, then to add a fourth`child hotkey D`, you must run `btcli stake child set` command again with the parent hotkey and set the proportions for all four child hotkeys `A`, `B`, `C` and `D`.
151144

152-
## Changing the proportions
145+
:::info Updating hotkey proportions
146+
When updating the proportion of a child hotkey, you must rerun the `btcli stake child set` command with the parent hotkey and all existing child hotkeys, including their updated proportions.
153147

154-
If a parent hotkey has, for example, three child hotkeys:
155-
156-
- child hotkey A with `0.2` proportion.
157-
- child hotkey B with `0.5` proportion.
158-
- child hotkey C with `0.1` proportion.
159-
160-
Then to change the proportion of, for example, the child hotkey B from `0.5` to `0.3`, you must run `set_children` command again with the parent hotkey and all three child hotkeys A, B, and C set to `0.2`, `0.3` and `0.1` proportions.
148+
:::
161149

162150
## Getting the child hotkeys
163151

164-
This command displays all the child hotkeys for a given parent hotkey.
165-
166-
### Usage
167-
168-
```bash
169-
btcli stake get_children --netuid <netuid> --hotkey <parent hotkey> --all
170-
```
171-
172-
### Example
152+
Run the following command to display all the child hotkeys for a given parent hotkey.
173153

174154
```bash
175-
btcli stake get_children \
176-
--netuid 4 \
177-
--hotkey 5DqJdDLU23m7yf6rZSmbLTshU7Bfn9eCTBkduhF4r9i73B9Y \
178-
--wallet.name Alice \
179-
--all
155+
btcli stake child get
180156
```
181157

182-
or
158+
### Example usage
183159

184160
```bash
185-
btcli stake get_children
161+
btcli stake child get --netuid <netuid> --hotkey <parent hotkey> --all
186162
```
187163

188-
and follow the prompts.
189-
190164
## Revoking the child hotkeys
191165

192-
This command revokes **all** the child hotkeys for a given parent hotkey.
166+
This is used to remove delegated authority from all child hotkeys, removing their position and influence on the subnet.
193167

194-
:::danger Revoking a specific child hotkey is not allowed
195-
Currently it is not possible to revoke a specific child hotkey. However, if a parent hotkey has, for example, three child hotkeys: child hotkey A, child hotkey B and child hotkey C, then setting the parent hotkey again with only child hotkeys A and B will result in revoking the child hotkey C.
168+
:::info Revoking a specific child hotkey is not allowed
169+
It is not possible to revoke a specific child hotkey. However, if a parent hotkey has, for example, three child hotkeys: `child hotkey A`, `child hotkey B` and `child hotkey C`, then setting the parent hotkey again with only child hotkeys `A` and `B` will result in revoking `child hotkey C`.
196170
:::
197171

198172
### Usage
199173

200174
```bash
201-
btcli stake revoke_children \
202-
--netuid <netuid> \
203-
--hotkey <parent hotkey> \
204-
--wallet.name <coldkey>
175+
btcli stake child revoke
205176
```
206177

207178
### Example
208179

209180
```bash
210-
btcli stake revoke_children \
181+
btcli stake child revoke \
211182
--netuid 4 \
212183
--hotkey 5DqJdDLU23m7yf6rZSmbLTshU7Bfn9eCTBkduhF4r9i73B9Y \
213184
--wallet.name Alice
214185
```
215186

216-
or
217-
218-
```bash
219-
btcli stake revoke_children
220-
```
221-
222-
and follow the prompts.
187+
## Get and set child hotkey take
223188

224-
## Setting child hotkey take
189+
Each child hotkey can have a defined take percentage that determines the portion of rewards it receives on a given netuid. The take value can range from `0` (0%) to `0.18` (18%). This configuration is subnet-specific meaning that a child hotkey may have one take percentage on one netuid and a different value on another.
225190

226-
This command sets the take percentage of the child hotkey for a given `netuid`. The `take` can be between `0` (0%) and `0.18` (18%).
191+
The child hotkey can also set its delegate take separately from the child hotkey take. That is, a child hotkey can carry two separate take rates: the child hotkey take rate and the delegate take rate. For the delegate take rate, see [Set delegate take](../btcli/btcli.md#btcli-sudo-set-take).
227192

228-
A child hotkey's `take` is subnet-specific, i.e., a child hotkey can have one `take` in one `netuid` and a different `take` in another `netuid`.
193+
### Usage
229194

230-
The child hotkey take rate is an attribute of the child hotkey and this take rate applies to all the parent hotkeys for which this hotkey is the child hotkey.
195+
```bash
196+
btcli stake child take
197+
```
231198

232-
The child hotkey can also set its delegate take separately from the child hotkey take. That is, a child hotkey can carry two separate take rates: the child hotkey take rate and the delegate take rate. For the delegate take rate, see [Set delegate take](../btcli/btcli.md#btcli-sudo-set-take).
199+
:::info
200+
Running the command without the `--take` flag only retrieves the child hotkey's take on the subnet. To set the child hotkey take, you must run the command with the `--take` flag.
201+
:::
233202

234-
### Usage
203+
To set child hotkey take, run the following command:
235204

236205
```bash
237-
btcli stake set_childkey_take \
206+
btcli stake child take \
238207
--netuid <netuid> \
239-
--hotkey <child hotkey> \
208+
--child-hotkey-ss58 <child hotkey> \
240209
--take <decimal number> \
241210
--wallet.name <coldkey>
242211
```
243212

244213
### Parameters
245214

246-
- `--hotkey`: SS58. A single SS58 of the child hotkey. Note that this `--hotkey` parameter expects child hotkey whereas the `--hotkey` parameter of the [Setting a child hotkey](#parameters) expects parent hotkey.
247-
- `--take`: Floating. A value between `0` (0%) and `0.18` (18%). Default value is `0`.
248-
- `--netuid`: Integer. The `netuid` in which this child hotkey's `take` is applicable. Note that a child hotkey's `take` is subnet-specific, i.e., a child hotkey can have one `take` in one `netuid` and a different `take` in another `netuid`.
215+
- `--child-hotkey-ss58 `: A single SS58 of the child hotkey. If not provided, it assigns the take value to the hotkey of the signing wallet.
216+
- `--take`: A value between `0` (0%) and `0.18` (18%). Default value is `0`.
217+
- `--netuid`: The `netuid` in which this child hotkey's `take` is applicable. Note that a child hotkey's `take` is subnet-specific, i.e., a child hotkey can have one `take` in one `netuid` and a different `take` in another `netuid`.
249218

250219
### Example
251220

252221
```bash
253-
btcli stake set_childkey_take \
222+
btcli stake take child take \
254223
--netuid 4 \
255224
--hotkey 5DqJdDLU23m7yf6rZSmbLTshU7Bfn9eCTBkduhF4r9i73B9Y \
256225
--take 0.09 \
257226
--wallet.name Alice
258227
```
259-
260-
## Getting child hotkey take
261-
262-
This command displays the take percentage of a given child hotkey and `netuid`.
263-
264-
### Usage
265-
266-
```bash
267-
btcli stake get_childkey_take \
268-
--netuid <netuid> \
269-
--hotkey <child hotkey> \
270-
--wallet.name <coldkey>
271-
```
272-
273-
### Example
274-
275-
```bash
276-
btcli stake get_childkey_take \
277-
--netuid 4 \
278-
--hotkey 5Gx1CZ9jviC6V2KynBAcTpES4yK76riCagv5o5SFFZFYXj4s \
279-
--wallet.name Bob
280-
```

0 commit comments

Comments
 (0)