Skip to content

Commit f3a4db3

Browse files
authored
Merge branch 'staging' into fix-verify
2 parents 6dce705 + 0503b66 commit f3a4db3

35 files changed

+1453
-407
lines changed

.github/workflows/docker_release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ jobs:
2424
uses: sigstore/cosign-installer@v3
2525

2626
- name: Log in to Docker Hub
27-
uses: docker/login-action@v2
27+
uses: docker/login-action@v3
2828
with:
2929
registry: docker.io
3030
username: ${{ secrets.DOCKERHUB_USERNAME }}
3131
password: ${{ secrets.DOCKERHUB_TOKEN }}
3232

3333
- name: Set up Docker Buildx
34-
uses: docker/setup-buildx-action@v2
34+
uses: docker/setup-buildx-action@v3
3535

3636
- name: Build and push Docker image
37-
uses: docker/build-push-action@v4
37+
uses: docker/build-push-action@v6
3838
with:
3939
context: .
4040
push: true

bittensor/core/async_subtensor.py

Lines changed: 202 additions & 115 deletions
Large diffs are not rendered by default.

bittensor/core/chain_data/dynamic_info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def _from_dict(cls, decoded: dict) -> "DynamicInfo":
9090
decoded["subnet_identity"]["subnet_contact"]
9191
).decode(),
9292
subnet_url=bytes(decoded["subnet_identity"]["subnet_url"]).decode(),
93+
logo_url=bytes(decoded["subnet_identity"]["logo_url"]).decode(),
9394
discord=bytes(decoded["subnet_identity"]["discord"]).decode(),
9495
description=bytes(decoded["subnet_identity"]["description"]).decode(),
9596
additional=bytes(decoded["subnet_identity"]["additional"]).decode(),

bittensor/core/chain_data/subnet_identity.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class SubnetIdentity:
99
github_repo: str
1010
subnet_contact: str
1111
subnet_url: str
12+
logo_url: str
1213
discord: str
1314
description: str
1415
additional: str
@@ -21,6 +22,7 @@ def _from_dict(cls, decoded: dict) -> "SubnetIdentity":
2122
github_repo=decoded["github_repo"],
2223
subnet_contact=decoded["subnet_contact"],
2324
subnet_url=decoded["subnet_url"],
25+
logo_url=decoded["logo_url"],
2426
discord=decoded["discord"],
2527
description=decoded["description"],
2628
additional=decoded["additional"],
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
from typing import TYPE_CHECKING, Optional
2+
from bittensor.utils import float_to_u64, unlock_key
3+
4+
if TYPE_CHECKING:
5+
from bittensor_wallet import Wallet
6+
from bittensor.core.async_subtensor import AsyncSubtensor
7+
8+
9+
async def set_children_extrinsic(
10+
subtensor: "AsyncSubtensor",
11+
wallet: "Wallet",
12+
hotkey: str,
13+
netuid: int,
14+
children: list[tuple[float, str]],
15+
wait_for_inclusion: bool = True,
16+
wait_for_finalization: bool = False,
17+
raise_error: bool = False,
18+
period: Optional[int] = None,
19+
):
20+
"""
21+
Allows a coldkey to set children-keys.
22+
23+
Arguments:
24+
subtensor: bittensor subtensor.
25+
wallet: bittensor wallet instance.
26+
hotkey: The ``SS58`` address of the neuron's hotkey.
27+
netuid: The netuid value.
28+
children: A list of children with their proportions.
29+
wait_for_inclusion: Waits for the transaction to be included in a block.
30+
wait_for_finalization: Waits for the transaction to be finalized on the blockchain.
31+
raise_error: Raises a relevant exception rather than returning `False` if unsuccessful.
32+
period: The number of blocks during which the transaction will remain valid after it's submitted. If the
33+
transaction is not included in a block within that number of blocks, it will expire and be rejected. You can
34+
think of it as an expiration date for the transaction.
35+
36+
Returns:
37+
tuple[bool, str]: A tuple where the first element is a boolean indicating success or failure of the operation,
38+
and the second element is a message providing additional information.
39+
40+
Raises:
41+
DuplicateChild: There are duplicates in the list of children.
42+
InvalidChild: Child is the hotkey.
43+
NonAssociatedColdKey: The coldkey does not own the hotkey or the child is the same as the hotkey.
44+
NotEnoughStakeToSetChildkeys: Parent key doesn't have minimum own stake.
45+
ProportionOverflow: The sum of the proportions does exceed uint64.
46+
RegistrationNotPermittedOnRootSubnet: Attempting to register a child on the root network.
47+
SubNetworkDoesNotExist: Attempting to register to a non-existent network.
48+
TooManyChildren: Too many children in request.
49+
TxRateLimitExceeded: Hotkey hit the rate limit.
50+
bittensor_wallet.errors.KeyFileError: Failed to decode keyfile data.
51+
bittensor_wallet.errors.PasswordError: Decryption failed or wrong password for decryption provided.
52+
"""
53+
unlock = unlock_key(wallet, raise_error=raise_error)
54+
55+
if not unlock.success:
56+
return False, unlock.message
57+
58+
async with subtensor.substrate as substrate:
59+
call = await substrate.compose_call(
60+
call_module="SubtensorModule",
61+
call_function="set_children",
62+
call_params={
63+
"children": [
64+
(
65+
float_to_u64(proportion),
66+
child_hotkey,
67+
)
68+
for proportion, child_hotkey in children
69+
],
70+
"hotkey": hotkey,
71+
"netuid": netuid,
72+
},
73+
)
74+
75+
success, message = await subtensor.sign_and_send_extrinsic(
76+
call=call,
77+
wallet=wallet,
78+
wait_for_inclusion=wait_for_inclusion,
79+
wait_for_finalization=wait_for_finalization,
80+
raise_error=raise_error,
81+
period=period,
82+
)
83+
84+
if not wait_for_finalization and not wait_for_inclusion:
85+
return True, message
86+
87+
if success:
88+
return True, "Success with `set_children_extrinsic` response."
89+
90+
return True, message
91+
92+
93+
async def root_set_pending_childkey_cooldown_extrinsic(
94+
subtensor: "AsyncSubtensor",
95+
wallet: "Wallet",
96+
cooldown: int,
97+
wait_for_inclusion: bool = True,
98+
wait_for_finalization: bool = False,
99+
period: Optional[int] = None,
100+
) -> tuple[bool, str]:
101+
"""
102+
Allows a coldkey to set children-keys.
103+
"""
104+
unlock = unlock_key(wallet)
105+
106+
if not unlock.success:
107+
return False, unlock.message
108+
109+
async with subtensor.substrate as substrate:
110+
call = await substrate.compose_call(
111+
call_module="SubtensorModule",
112+
call_function="set_pending_childkey_cooldown",
113+
call_params={"cooldown": cooldown},
114+
)
115+
116+
sudo_call = await substrate.compose_call(
117+
call_module="Sudo",
118+
call_function="sudo",
119+
call_params={"call": call},
120+
)
121+
122+
success, message = await subtensor.sign_and_send_extrinsic(
123+
call=sudo_call,
124+
wallet=wallet,
125+
wait_for_inclusion=wait_for_inclusion,
126+
wait_for_finalization=wait_for_finalization,
127+
period=period,
128+
)
129+
130+
if not wait_for_finalization and not wait_for_inclusion:
131+
return True, message
132+
133+
if success:
134+
return (
135+
True,
136+
"Success with `root_set_pending_childkey_cooldown_extrinsic` response.",
137+
)
138+
139+
return True, message

bittensor/core/extrinsics/asyncex/registration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ async def set_subnet_identity_extrinsic(
470470
github_repo: str,
471471
subnet_contact: str,
472472
subnet_url: str,
473+
logo_url: str,
473474
discord: str,
474475
description: str,
475476
additional: str,
@@ -488,6 +489,7 @@ async def set_subnet_identity_extrinsic(
488489
github_repo (str): URL of the GitHub repository related to the subnet.
489490
subnet_contact (str): Subnet's contact information, e.g., email or contact link.
490491
subnet_url (str): The URL of the subnet's primary web portal.
492+
logo_url (str): The URL of the logo's primary web portal.
491493
discord (str): Discord server or contact for the subnet.
492494
description (str): A textual description of the subnet.
493495
additional (str): Any additional metadata or information related to the subnet.
@@ -516,6 +518,7 @@ async def set_subnet_identity_extrinsic(
516518
"github_repo": github_repo,
517519
"subnet_contact": subnet_contact,
518520
"subnet_url": subnet_url,
521+
"logo_url": logo_url,
519522
"discord": discord,
520523
"description": description,
521524
"additional": additional,

bittensor/core/extrinsics/asyncex/unstaking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ async def unstake_multiple_extrinsic(
291291
for idx, (hotkey_ss58, amount, old_stake, netuid) in enumerate(
292292
zip(hotkey_ss58s, amounts, old_stakes, netuids)
293293
):
294-
# Covert to bittensor.Balance
294+
# Convert to bittensor.Balance
295295
if amount is None:
296296
# Unstake it all.
297297
unstaking_balance = old_stake
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
from typing import TYPE_CHECKING, Optional
2+
from bittensor.utils import float_to_u64, unlock_key
3+
4+
if TYPE_CHECKING:
5+
from bittensor_wallet import Wallet
6+
from bittensor.core.subtensor import Subtensor
7+
8+
9+
def set_children_extrinsic(
10+
subtensor: "Subtensor",
11+
wallet: "Wallet",
12+
hotkey: str,
13+
netuid: int,
14+
children: list[tuple[float, str]],
15+
wait_for_inclusion: bool = True,
16+
wait_for_finalization: bool = False,
17+
raise_error: bool = False,
18+
period: Optional[int] = None,
19+
):
20+
"""
21+
Allows a coldkey to set children-keys.
22+
23+
Arguments:
24+
subtensor: bittensor subtensor.
25+
wallet: bittensor wallet instance.
26+
hotkey: The ``SS58`` address of the neuron's hotkey.
27+
netuid: The netuid value.
28+
children: A list of children with their proportions.
29+
wait_for_inclusion: Waits for the transaction to be included in a block.
30+
wait_for_finalization: Waits for the transaction to be finalized on the blockchain.
31+
raise_error: Raises a relevant exception rather than returning `False` if unsuccessful.
32+
period: The number of blocks during which the transaction will remain valid after it's submitted. If the
33+
transaction is not included in a block within that number of blocks, it will expire and be rejected. You can
34+
think of it as an expiration date for the transaction.
35+
36+
Returns:
37+
tuple[bool, str]: A tuple where the first element is a boolean indicating success or failure of the operation,
38+
and the second element is a message providing additional information.
39+
40+
Raises:
41+
DuplicateChild: There are duplicates in the list of children.
42+
InvalidChild: Child is the hotkey.
43+
NonAssociatedColdKey: The coldkey does not own the hotkey or the child is the same as the hotkey.
44+
NotEnoughStakeToSetChildkeys: Parent key doesn't have minimum own stake.
45+
ProportionOverflow: The sum of the proportions does exceed uint64.
46+
RegistrationNotPermittedOnRootSubnet: Attempting to register a child on the root network.
47+
SubNetworkDoesNotExist: Attempting to register to a non-existent network.
48+
TooManyChildren: Too many children in request.
49+
TxRateLimitExceeded: Hotkey hit the rate limit.
50+
bittensor_wallet.errors.KeyFileError: Failed to decode keyfile data.
51+
bittensor_wallet.errors.PasswordError: Decryption failed or wrong password for decryption provided.
52+
"""
53+
unlock = unlock_key(wallet, raise_error=raise_error)
54+
55+
if not unlock.success:
56+
return False, unlock.message
57+
58+
call = subtensor.substrate.compose_call(
59+
call_module="SubtensorModule",
60+
call_function="set_children",
61+
call_params={
62+
"children": [
63+
(
64+
float_to_u64(proportion),
65+
child_hotkey,
66+
)
67+
for proportion, child_hotkey in children
68+
],
69+
"hotkey": hotkey,
70+
"netuid": netuid,
71+
},
72+
)
73+
74+
success, message = subtensor.sign_and_send_extrinsic(
75+
call=call,
76+
wallet=wallet,
77+
wait_for_inclusion=wait_for_inclusion,
78+
wait_for_finalization=wait_for_finalization,
79+
raise_error=raise_error,
80+
period=period,
81+
)
82+
83+
if not wait_for_finalization and not wait_for_inclusion:
84+
return True, message
85+
86+
if success:
87+
return True, "Success with `set_children_extrinsic` response."
88+
89+
return True, message
90+
91+
92+
def root_set_pending_childkey_cooldown_extrinsic(
93+
subtensor: "Subtensor",
94+
wallet: "Wallet",
95+
cooldown: int,
96+
wait_for_inclusion: bool = True,
97+
wait_for_finalization: bool = False,
98+
period: Optional[int] = None,
99+
) -> tuple[bool, str]:
100+
"""
101+
Allows a coldkey to set children-keys.
102+
"""
103+
unlock = unlock_key(wallet)
104+
105+
if not unlock.success:
106+
return False, unlock.message
107+
108+
call = subtensor.substrate.compose_call(
109+
call_module="SubtensorModule",
110+
call_function="set_pending_childkey_cooldown",
111+
call_params={"cooldown": cooldown},
112+
)
113+
114+
sudo_call = subtensor.substrate.compose_call(
115+
call_module="Sudo",
116+
call_function="sudo",
117+
call_params={"call": call},
118+
)
119+
120+
success, message = subtensor.sign_and_send_extrinsic(
121+
call=sudo_call,
122+
wallet=wallet,
123+
wait_for_inclusion=wait_for_inclusion,
124+
wait_for_finalization=wait_for_finalization,
125+
period=period,
126+
)
127+
128+
if not wait_for_finalization and not wait_for_inclusion:
129+
return True, message
130+
131+
if success:
132+
return (
133+
True,
134+
"Success with `root_set_pending_childkey_cooldown_extrinsic` response.",
135+
)
136+
137+
return True, message

bittensor/core/extrinsics/registration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ def set_subnet_identity_extrinsic(
462462
github_repo: str,
463463
subnet_contact: str,
464464
subnet_url: str,
465+
logo_url: str,
465466
discord: str,
466467
description: str,
467468
additional: str,
@@ -480,6 +481,7 @@ def set_subnet_identity_extrinsic(
480481
github_repo (str): URL of the GitHub repository related to the subnet.
481482
subnet_contact (str): Subnet's contact information, e.g., email or contact link.
482483
subnet_url (str): The URL of the subnet's primary web portal.
484+
logo_url (str): The URL of the logo's primary web portal.
483485
discord (str): Discord server or contact for the subnet.
484486
description (str): A textual description of the subnet.
485487
additional (str): Any additional metadata or information related to the subnet.
@@ -508,6 +510,7 @@ def set_subnet_identity_extrinsic(
508510
"github_repo": github_repo,
509511
"subnet_contact": subnet_contact,
510512
"subnet_url": subnet_url,
513+
"logo_url": logo_url,
511514
"discord": discord,
512515
"description": description,
513516
"additional": additional,

bittensor/core/extrinsics/unstaking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def unstake_multiple_extrinsic(
281281
for idx, (hotkey_ss58, amount, old_stake, netuid) in enumerate(
282282
zip(hotkey_ss58s, amounts, old_stakes, netuids)
283283
):
284-
# Covert to bittensor.Balance
284+
# Convert to bittensor.Balance
285285
if amount is None:
286286
# Unstake it all.
287287
unstaking_balance = old_stake

0 commit comments

Comments
 (0)