Skip to content

Commit c1a1861

Browse files
authored
Merge branch 'staging' into master
2 parents bf220a9 + 6b8a88a commit c1a1861

22 files changed

+801
-56
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Changelog
22

3+
## 9.3.1a1 /2025-04-14
4+
5+
## What's Changed
6+
* Release/9.3.0 by @ibraheem-abe in https://github.com/opentensor/bittensor/pull/2805
7+
* Fix for flaky behavior of `test_incentive`, `test_commit_weights` and `test_set_weights` by @basfroman in https://github.com/opentensor/bittensor/pull/2795
8+
* Add `get_next_epoch_start_block` method to Async/Subtensor by @basfroman in https://github.com/opentensor/bittensor/pull/2808
9+
* Adds compatibility for torch 2.6.0+ by @thewhaleking in https://github.com/opentensor/bittensor/pull/2811
10+
* f Update CONTRIBUTING.md by @Hack666r in https://github.com/opentensor/bittensor/pull/2813
11+
* docs: replaced discord link with documentation by @sashaphmn in https://github.com/opentensor/bittensor/pull/2809
12+
* sometimes it's still flaky because the chain returns data with time offset by @basfroman in https://github.com/opentensor/bittensor/pull/2816
13+
* Remove requirements directory by @thewhaleking in https://github.com/opentensor/bittensor/pull/2812
14+
* version in one place by @thewhaleking in https://github.com/opentensor/bittensor/pull/2806
15+
* Update CONTRIBUTING hyperlinks by @thewhaleking in https://github.com/opentensor/bittensor/pull/2820
16+
17+
## New Contributors
18+
* @Hack666r made their first contribution in https://github.com/opentensor/bittensor/pull/2813
19+
20+
**Full Changelog**: https://github.com/opentensor/bittensor/compare/v9.3.0...v9.3.1a1
21+
322
## 9.3.0 /2025-04-09
423

524
## What's Changed

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,3 @@ install:
2121

2222
install-dev:
2323
python3 -m pip install '.[dev]'
24-
25-
install-cubit:
26-
python3 -m pip install '.[cubit]'

bittensor/core/async_subtensor.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
publish_metadata,
5858
get_metadata,
5959
)
60+
from bittensor.core.extrinsics.asyncex.start_call import start_call_extrinsic
6061
from bittensor.core.extrinsics.asyncex.serving import serve_axon_extrinsic
6162
from bittensor.core.extrinsics.asyncex.staking import (
6263
add_stake_extrinsic,
@@ -3181,7 +3182,7 @@ async def sign_and_send_extrinsic(
31813182
return True, ""
31823183

31833184
if raise_error:
3184-
raise ChainError.from_error(response.error_message)
3185+
raise ChainError.from_error(await response.error_message)
31853186

31863187
return False, format_error_message(await response.error_message)
31873188

@@ -3986,6 +3987,36 @@ async def serve_axon(
39863987
certificate=certificate,
39873988
)
39883989

3990+
async def start_call(
3991+
self,
3992+
wallet: "Wallet",
3993+
netuid: int,
3994+
wait_for_inclusion: bool = True,
3995+
wait_for_finalization: bool = False,
3996+
) -> tuple[bool, str]:
3997+
"""
3998+
Submits a start_call extrinsic to the blockchain, to trigger the start call process for a subnet (used to start a
3999+
new subnet's emission mechanism).
4000+
4001+
Args:
4002+
wallet (Wallet): The wallet used to sign the extrinsic (must be unlocked).
4003+
netuid (int): The UID of the target subnet for which the call is being initiated.
4004+
wait_for_inclusion (bool, optional): Whether to wait for the extrinsic to be included in a block. Defaults to True.
4005+
wait_for_finalization (bool, optional): Whether to wait for finalization of the extrinsic. Defaults to False.
4006+
4007+
Returns:
4008+
Tuple[bool, str]:
4009+
- True and a success message if the extrinsic is successfully submitted or processed.
4010+
- False and an error message if the submission fails or the wallet cannot be unlocked.
4011+
"""
4012+
return await start_call_extrinsic(
4013+
subtensor=self,
4014+
wallet=wallet,
4015+
netuid=netuid,
4016+
wait_for_inclusion=wait_for_inclusion,
4017+
wait_for_finalization=wait_for_finalization,
4018+
)
4019+
39894020
async def swap_stake(
39904021
self,
39914022
wallet: "Wallet",

bittensor/core/chain_data/metagraph_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _chr_str(codes: tuple[int]) -> str:
2525
def process_nested(data: Union[tuple, dict], chr_transform):
2626
"""Processes nested data structures by applying a transformation function to their elements."""
2727
if isinstance(data, (list, tuple)):
28-
if len(data) > 0 and isinstance(data[0], dict):
28+
if len(data) > 0:
2929
return [
3030
{k: chr_transform(v) for k, v in item.items()}
3131
if item is not None

bittensor/core/extrinsics/asyncex/registration.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ async def set_subnet_identity_extrinsic(
498498
},
499499
)
500500

501-
response = await subtensor.substrate.submit_extrinsic(
501+
success, error_message = await subtensor.sign_and_send_extrinsic(
502502
call=call,
503503
wallet=wallet,
504504
wait_for_inclusion=wait_for_inclusion,
@@ -508,14 +508,13 @@ async def set_subnet_identity_extrinsic(
508508
if not wait_for_finalization and not wait_for_inclusion:
509509
return True, f"Identities for subnet {netuid} are sent to the chain."
510510

511-
if await response.is_success:
511+
if success:
512512
logging.success(
513513
f":white_heavy_check_mark: [green]Identities for subnet[/green] [blue]{netuid}[/blue] [green]are set.[/green]"
514514
)
515515
return True, f"Identities for subnet {netuid} are set."
516-
else:
517-
error_message = await response.error_message
518-
logging.error(
519-
f":cross_mark: Failed to set identity for subnet [blue]{netuid}[/blue]: {error_message}"
520-
)
521-
return False, f"Failed to set identity for subnet {netuid}: {error_message}"
516+
517+
logging.error(
518+
f":cross_mark: Failed to set identity for subnet [blue]{netuid}[/blue]: {error_message}"
519+
)
520+
return False, f"Failed to set identity for subnet {netuid}: {error_message}"
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
from typing import TYPE_CHECKING
2+
3+
from bittensor.utils import unlock_key
4+
from bittensor.utils.btlogging import logging
5+
6+
if TYPE_CHECKING:
7+
from bittensor_wallet import Wallet
8+
from bittensor.core.async_subtensor import AsyncSubtensor
9+
10+
11+
async def start_call_extrinsic(
12+
subtensor: "AsyncSubtensor",
13+
wallet: "Wallet",
14+
netuid: int,
15+
wait_for_inclusion: bool = True,
16+
wait_for_finalization: bool = False,
17+
) -> tuple[bool, str]:
18+
"""
19+
Submits a start_call extrinsic to the blockchain, to trigger the start call process for a subnet (used to start a
20+
new subnet's emission mechanism).
21+
22+
Args:
23+
subtensor (Subtensor): The Subtensor client instance used for blockchain interaction.
24+
wallet (Wallet): The wallet used to sign the extrinsic (must be unlocked).
25+
netuid (int): The UID of the target subnet for which the call is being initiated.
26+
wait_for_inclusion (bool, optional): Whether to wait for the extrinsic to be included in a block. Defaults to True.
27+
wait_for_finalization (bool, optional): Whether to wait for finalization of the extrinsic. Defaults to False.
28+
29+
Returns:
30+
Tuple[bool, str]:
31+
- True and a success message if the extrinsic is successfully submitted or processed.
32+
- False and an error message if the submission fails or the wallet cannot be unlocked.
33+
"""
34+
if not (unlock := unlock_key(wallet)).success:
35+
logging.error(unlock.message)
36+
return False, unlock.message
37+
38+
async with subtensor.substrate as substrate:
39+
start_call = await substrate.compose_call(
40+
call_module="SubtensorModule",
41+
call_function="start_call",
42+
call_params={"netuid": netuid},
43+
)
44+
signed_ext = await substrate.create_signed_extrinsic(
45+
call=start_call,
46+
keypair=wallet.coldkey,
47+
)
48+
49+
response = await substrate.submit_extrinsic(
50+
extrinsic=signed_ext,
51+
wait_for_inclusion=wait_for_inclusion,
52+
wait_for_finalization=wait_for_finalization,
53+
)
54+
55+
if not wait_for_finalization and not wait_for_inclusion:
56+
return True, "Not waiting for finalization or inclusion."
57+
58+
if await response.is_success:
59+
return True, "Success with `start_call` response."
60+
61+
return False, await response.error_message
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from typing import TYPE_CHECKING
2+
3+
from bittensor.utils import unlock_key
4+
from bittensor.utils.btlogging import logging
5+
6+
if TYPE_CHECKING:
7+
from bittensor_wallet import Wallet
8+
from bittensor.core.subtensor import Subtensor
9+
10+
11+
def start_call_extrinsic(
12+
subtensor: "Subtensor",
13+
wallet: "Wallet",
14+
netuid: int,
15+
wait_for_inclusion: bool = True,
16+
wait_for_finalization: bool = False,
17+
) -> tuple[bool, str]:
18+
"""
19+
Submits a start_call extrinsic to the blockchain, to trigger the start call process for a subnet (used to start a
20+
new subnet's emission mechanism).
21+
22+
Args:
23+
subtensor (Subtensor): The Subtensor client instance used for blockchain interaction.
24+
wallet (Wallet): The wallet used to sign the extrinsic (must be unlocked).
25+
netuid (int): The UID of the target subnet for which the call is being initiated.
26+
wait_for_inclusion (bool, optional): Whether to wait for the extrinsic to be included in a block. Defaults to True.
27+
wait_for_finalization (bool, optional): Whether to wait for finalization of the extrinsic. Defaults to False.
28+
29+
Returns:
30+
Tuple[bool, str]:
31+
- True and a success message if the extrinsic is successfully submitted or processed.
32+
- False and an error message if the submission fails or the wallet cannot be unlocked.
33+
"""
34+
if not (unlock := unlock_key(wallet)).success:
35+
logging.error(unlock.message)
36+
return False, unlock.message
37+
38+
with subtensor.substrate as substrate:
39+
start_call = substrate.compose_call(
40+
call_module="SubtensorModule",
41+
call_function="start_call",
42+
call_params={"netuid": netuid},
43+
)
44+
45+
signed_ext = substrate.create_signed_extrinsic(
46+
call=start_call,
47+
keypair=wallet.coldkey,
48+
)
49+
50+
response = substrate.submit_extrinsic(
51+
extrinsic=signed_ext,
52+
wait_for_inclusion=wait_for_inclusion,
53+
wait_for_finalization=wait_for_finalization,
54+
)
55+
56+
if not wait_for_finalization and not wait_for_inclusion:
57+
return True, "Not waiting for finalization or inclusion."
58+
59+
if response.is_success:
60+
return True, "Success with `start_call` response."
61+
62+
return False, response.error_message

bittensor/core/subtensor.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
get_metadata,
6161
serve_axon_extrinsic,
6262
)
63+
from bittensor.core.extrinsics.start_call import start_call_extrinsic
6364
from bittensor.core.extrinsics.set_weights import set_weights_extrinsic
6465
from bittensor.core.extrinsics.staking import (
6566
add_stake_extrinsic,
@@ -3252,6 +3253,36 @@ def serve_axon(
32523253
certificate=certificate,
32533254
)
32543255

3256+
def start_call(
3257+
self,
3258+
wallet: "Wallet",
3259+
netuid: int,
3260+
wait_for_inclusion: bool = True,
3261+
wait_for_finalization: bool = False,
3262+
) -> tuple[bool, str]:
3263+
"""
3264+
Submits a start_call extrinsic to the blockchain, to trigger the start call process for a subnet (used to start a
3265+
new subnet's emission mechanism).
3266+
3267+
Args:
3268+
wallet (Wallet): The wallet used to sign the extrinsic (must be unlocked).
3269+
netuid (int): The UID of the target subnet for which the call is being initiated.
3270+
wait_for_inclusion (bool, optional): Whether to wait for the extrinsic to be included in a block. Defaults to True.
3271+
wait_for_finalization (bool, optional): Whether to wait for finalization of the extrinsic. Defaults to False.
3272+
3273+
Returns:
3274+
Tuple[bool, str]:
3275+
- True and a success message if the extrinsic is successfully submitted or processed.
3276+
- False and an error message if the submission fails or the wallet cannot be unlocked.
3277+
"""
3278+
return start_call_extrinsic(
3279+
subtensor=self,
3280+
wallet=wallet,
3281+
netuid=netuid,
3282+
wait_for_inclusion=wait_for_inclusion,
3283+
wait_for_finalization=wait_for_finalization,
3284+
)
3285+
32553286
def swap_stake(
32563287
self,
32573288
wallet: "Wallet",

0 commit comments

Comments
 (0)