Skip to content

Commit faf1ef7

Browse files
Merge branch 'staging' into fix/zyzniewski/test_incentive
2 parents ffe6a41 + 9730f51 commit faf1ef7

15 files changed

+100
-95
lines changed

.github/workflows/e2e-subtensor-tests.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ concurrency:
66

77
on:
88
push:
9-
branches: [main, development, staging]
9+
branches: [master, development, staging]
1010

1111
pull_request:
12-
branches: [main, development, staging]
12+
branches: [master, development, staging]
1313
types: [ opened, synchronize, reopened, ready_for_review ]
1414

1515
workflow_dispatch:

CHANGELOG.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## 9.0.5 /2025-03-12
3+
## 9.1.0 /2025-03-12
44

55
## What's Changed
66
* Refactor duplicated unittests code by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2724
@@ -12,8 +12,13 @@
1212
* All metagraph subtensor methods now use block by @thewhaleking in https://github.com/opentensor/bittensor/pull/2738
1313
* Tests: increse test_incentive timeout + fix sudo_set_weights_set_rate_limit by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2739
1414
* Feat/safe staking by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2736
15+
* 9.0.5: Bumps version and changelog by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2741
16+
* Tests: enable E2E test_batch_operations by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2744
17+
* Fix: burned_register supports root subnet (netuid=0 param) by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2732
18+
* Feat: set_delegate_take by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2731
19+
* Renames rate_threshold -> rate_tolerance by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2745
1520

16-
**Full Changelog**: https://github.com/opentensor/bittensor/compare/v9.0.4...v9.0.5
21+
**Full Changelog**: https://github.com/opentensor/bittensor/compare/v9.0.4...v9.1.0
1722

1823
## 9.0.4 /2025-03-06
1924

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9.0.5
1+
9.1.0

bittensor/core/async_subtensor.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -2821,7 +2821,7 @@ async def add_stake(
28212821
wait_for_finalization: bool = False,
28222822
safe_staking: bool = False,
28232823
allow_partial_stake: bool = False,
2824-
rate_threshold: float = 0.005,
2824+
rate_tolerance: float = 0.005,
28252825
) -> bool:
28262826
"""
28272827
Adds the specified amount of stake to a neuron identified by the hotkey ``SS58`` address.
@@ -2836,11 +2836,11 @@ async def add_stake(
28362836
wait_for_inclusion (bool): Waits for the transaction to be included in a block.
28372837
wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain.
28382838
safe_staking (bool): If true, enables price safety checks to protect against fluctuating prices. The stake
2839-
will only execute if the price change doesn't exceed the rate threshold. Default is False.
2839+
will only execute if the price change doesn't exceed the rate tolerance. Default is False.
28402840
allow_partial_stake (bool): If true and safe_staking is enabled, allows partial staking when
28412841
the full amount would exceed the price threshold. If false, the entire stake fails if it would
28422842
exceed the threshold. Default is False.
2843-
rate_threshold (float): The maximum allowed price change ratio when staking. For example,
2843+
rate_tolerance (float): The maximum allowed price change ratio when staking. For example,
28442844
0.005 = 0.5% maximum price increase. Only used when safe_staking is True. Default is 0.005.
28452845
28462846
Returns:
@@ -2861,7 +2861,7 @@ async def add_stake(
28612861
wait_for_finalization=wait_for_finalization,
28622862
safe_staking=safe_staking,
28632863
allow_partial_stake=allow_partial_stake,
2864-
rate_threshold=rate_threshold,
2864+
rate_tolerance=rate_tolerance,
28652865
)
28662866

28672867
async def add_stake_multiple(
@@ -3540,7 +3540,7 @@ async def swap_stake(
35403540
wait_for_finalization: bool = False,
35413541
safe_staking: bool = False,
35423542
allow_partial_stake: bool = False,
3543-
rate_threshold: float = 0.005,
3543+
rate_tolerance: float = 0.005,
35443544
) -> bool:
35453545
"""
35463546
Moves stake between subnets while keeping the same coldkey-hotkey pair ownership.
@@ -3555,12 +3555,12 @@ async def swap_stake(
35553555
wait_for_inclusion (bool): Waits for the transaction to be included in a block.
35563556
wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain.
35573557
safe_staking (bool): If true, enables price safety checks to protect against fluctuating prices. The swap
3558-
will only execute if the price ratio between subnets doesn't exceed the rate threshold.
3558+
will only execute if the price ratio between subnets doesn't exceed the rate tolerance.
35593559
Default is False.
35603560
allow_partial_stake (bool): If true and safe_staking is enabled, allows partial stake swaps when
35613561
the full amount would exceed the price threshold. If false, the entire swap fails if it would
35623562
exceed the threshold. Default is False.
3563-
rate_threshold (float): The maximum allowed increase in the price ratio between subnets
3563+
rate_tolerance (float): The maximum allowed increase in the price ratio between subnets
35643564
(origin_price/destination_price). For example, 0.005 = 0.5% maximum increase. Only used
35653565
when safe_staking is True. Default is 0.005.
35663566
@@ -3570,9 +3570,9 @@ async def swap_stake(
35703570
The price ratio for swap_stake in safe mode is calculated as: origin_subnet_price / destination_subnet_price
35713571
When safe_staking is enabled, the swap will only execute if:
35723572
- With allow_partial_stake=False: The entire swap amount can be executed without the price ratio
3573-
increasing more than rate_threshold
3573+
increasing more than rate_tolerance
35743574
- With allow_partial_stake=True: A partial amount will be swapped up to the point where the
3575-
price ratio would increase by rate_threshold
3575+
price ratio would increase by rate_tolerance
35763576
"""
35773577
amount = check_and_convert_to_balance(amount)
35783578
return await swap_stake_extrinsic(
@@ -3586,7 +3586,7 @@ async def swap_stake(
35863586
wait_for_finalization=wait_for_finalization,
35873587
safe_staking=safe_staking,
35883588
allow_partial_stake=allow_partial_stake,
3589-
rate_threshold=rate_threshold,
3589+
rate_tolerance=rate_tolerance,
35903590
)
35913591

35923592
async def transfer_stake(
@@ -3677,7 +3677,7 @@ async def unstake(
36773677
wait_for_finalization: bool = False,
36783678
safe_staking: bool = False,
36793679
allow_partial_stake: bool = False,
3680-
rate_threshold: float = 0.005,
3680+
rate_tolerance: float = 0.005,
36813681
) -> bool:
36823682
"""
36833683
Removes a specified amount of stake from a single hotkey account. This function is critical for adjusting
@@ -3692,11 +3692,11 @@ async def unstake(
36923692
wait_for_inclusion (bool): Waits for the transaction to be included in a block.
36933693
wait_for_finalization (bool): Waits for the transaction to be finalized on the blockchain.
36943694
safe_staking (bool): If true, enables price safety checks to protect against fluctuating prices. The unstake
3695-
will only execute if the price change doesn't exceed the rate threshold. Default is False.
3695+
will only execute if the price change doesn't exceed the rate tolerance. Default is False.
36963696
allow_partial_stake (bool): If true and safe_staking is enabled, allows partial unstaking when
36973697
the full amount would exceed the price threshold. If false, the entire unstake fails if it would
36983698
exceed the threshold. Default is False.
3699-
rate_threshold (float): The maximum allowed price change ratio when unstaking. For example,
3699+
rate_tolerance (float): The maximum allowed price change ratio when unstaking. For example,
37003700
0.005 = 0.5% maximum price decrease. Only used when safe_staking is True. Default is 0.005.
37013701
37023702
Returns:
@@ -3716,7 +3716,7 @@ async def unstake(
37163716
wait_for_finalization=wait_for_finalization,
37173717
safe_staking=safe_staking,
37183718
allow_partial_stake=allow_partial_stake,
3719-
rate_threshold=rate_threshold,
3719+
rate_tolerance=rate_tolerance,
37203720
)
37213721

37223722
async def unstake_multiple(

bittensor/core/extrinsics/asyncex/move_stake.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ async def swap_stake_extrinsic(
162162
wait_for_finalization: bool = False,
163163
safe_staking: bool = False,
164164
allow_partial_stake: bool = False,
165-
rate_threshold: float = 0.005,
165+
rate_tolerance: float = 0.005,
166166
) -> bool:
167167
"""
168168
Swaps stake from one subnet to another for a given hotkey in the Bittensor network.
@@ -177,8 +177,8 @@ async def swap_stake_extrinsic(
177177
wait_for_inclusion (bool): If True, waits for transaction inclusion in a block. Defaults to True.
178178
wait_for_finalization (bool): If True, waits for transaction finalization. Defaults to False.
179179
safe_staking (bool): If true, enables price safety checks to protect against price impact.
180-
allow_partial_stake (bool): If true, allows partial stake swaps when the full amount would exceed the price threshold.
181-
rate_threshold (float): Maximum allowed increase in price ratio (0.005 = 0.5%).
180+
allow_partial_stake (bool): If true, allows partial stake swaps when the full amount would exceed the price tolerance.
181+
rate_tolerance (float): Maximum allowed increase in price ratio (0.005 = 0.5%).
182182
183183
Returns:
184184
bool: True if the swap was successful, False otherwise.
@@ -224,7 +224,7 @@ async def swap_stake_extrinsic(
224224
subtensor.subnet(netuid=destination_netuid),
225225
)
226226
swap_rate_ratio = origin_pool.price.rao / destination_pool.price.rao
227-
swap_rate_ratio_with_tolerance = swap_rate_ratio * (1 + rate_threshold)
227+
swap_rate_ratio_with_tolerance = swap_rate_ratio * (1 + rate_tolerance)
228228

229229
logging.info(
230230
f"Swapping stake with safety for hotkey [blue]{hotkey_ss58}[/blue]\n"

bittensor/core/extrinsics/asyncex/staking.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def add_stake_extrinsic(
2323
wait_for_finalization: bool = False,
2424
safe_staking: bool = False,
2525
allow_partial_stake: bool = False,
26-
rate_threshold: float = 0.005,
26+
rate_tolerance: float = 0.005,
2727
) -> bool:
2828
"""
2929
Adds the specified amount of stake to passed hotkey `uid`.
@@ -41,7 +41,7 @@ async def add_stake_extrinsic(
4141
or returns `False` if the extrinsic fails to be finalized within the timeout.
4242
safe_staking: If set, uses safe staking logic
4343
allow_partial_stake: If set, allows partial stake
44-
rate_threshold: The rate threshold for safe staking
44+
rate_tolerance: The rate tolerance for safe staking
4545
4646
Returns:
4747
success: Flag is `True` if extrinsic was finalized or included in the block. If we did not wait for
@@ -112,7 +112,7 @@ async def add_stake_extrinsic(
112112
if safe_staking:
113113
pool = await subtensor.subnet(netuid=netuid)
114114
base_price = pool.price.rao
115-
price_with_tolerance = base_price * (1 + rate_threshold)
115+
price_with_tolerance = base_price * (1 + rate_tolerance)
116116
call_params.update(
117117
{
118118
"limit_price": price_with_tolerance,
@@ -123,11 +123,11 @@ async def add_stake_extrinsic(
123123

124124
# For logging
125125
base_rate = pool.price.tao
126-
rate_with_tolerance = base_rate * (1 + rate_threshold)
126+
rate_with_tolerance = base_rate * (1 + rate_tolerance)
127127
logging.info(
128128
f":satellite: [magenta]Safe Staking to:[/magenta] "
129129
f"[blue]netuid: [green]{netuid}[/green], amount: [green]{staking_balance}[/green], "
130-
f"tolerance percentage: [green]{rate_threshold*100}%[/green], "
130+
f"tolerance percentage: [green]{rate_tolerance*100}%[/green], "
131131
f"price limit: [green]{rate_with_tolerance}[/green], "
132132
f"original price: [green]{base_rate}[/green], "
133133
f"with partial stake: [green]{allow_partial_stake}[/green] "

bittensor/core/extrinsics/asyncex/unstaking.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async def unstake_extrinsic(
2222
wait_for_finalization: bool = False,
2323
safe_staking: bool = False,
2424
allow_partial_stake: bool = False,
25-
rate_threshold: float = 0.005,
25+
rate_tolerance: float = 0.005,
2626
) -> bool:
2727
"""Removes stake into the wallet coldkey from the specified hotkey ``uid``.
2828
@@ -38,8 +38,8 @@ async def unstake_extrinsic(
3838
wait_for_finalization (bool): If set, waits for the extrinsic to be finalized on the chain before returning
3939
``True``, or returns ``False`` if the extrinsic fails to be finalized within the timeout.
4040
safe_staking: If true, enables price safety checks
41-
allow_partial_stake: If true, allows partial unstaking if price threshold exceeded
42-
rate_threshold: Maximum allowed price decrease percentage (0.005 = 0.5%)
41+
allow_partial_stake: If true, allows partial unstaking if price tolerance exceeded
42+
rate_tolerance: Maximum allowed price decrease percentage (0.005 = 0.5%)
4343
4444
Returns:
4545
success (bool): Flag is ``True`` if extrinsic was finalized or included in the block. If we did not wait for
@@ -97,16 +97,16 @@ async def unstake_extrinsic(
9797
if safe_staking:
9898
pool = await subtensor.subnet(netuid=netuid)
9999
base_price = pool.price.rao
100-
price_with_tolerance = base_price * (1 - rate_threshold)
100+
price_with_tolerance = base_price * (1 - rate_tolerance)
101101

102102
# For logging
103103
base_rate = pool.price.tao
104-
rate_with_tolerance = base_rate * (1 - rate_threshold)
104+
rate_with_tolerance = base_rate * (1 - rate_tolerance)
105105

106106
logging.info(
107107
f":satellite: [magenta]Safe Unstaking from:[/magenta] "
108108
f"netuid: [green]{netuid}[/green], amount: [green]{unstaking_balance}[/green], "
109-
f"tolerance percentage: [green]{rate_threshold*100}%[/green], "
109+
f"tolerance percentage: [green]{rate_tolerance*100}%[/green], "
110110
f"price limit: [green]{rate_with_tolerance}[/green], "
111111
f"original price: [green]{base_rate}[/green], "
112112
f"with partial unstake: [green]{allow_partial_stake}[/green] "

bittensor/core/extrinsics/move_stake.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def swap_stake_extrinsic(
159159
wait_for_finalization: bool = False,
160160
safe_staking: bool = False,
161161
allow_partial_stake: bool = False,
162-
rate_threshold: float = 0.005,
162+
rate_tolerance: float = 0.005,
163163
) -> bool:
164164
"""
165165
Moves stake between subnets while keeping the same coldkey-hotkey pair ownership.
@@ -174,8 +174,8 @@ def swap_stake_extrinsic(
174174
wait_for_inclusion (bool): If true, waits for inclusion before returning.
175175
wait_for_finalization (bool): If true, waits for finalization before returning.
176176
safe_staking (bool): If true, enables price safety checks to protect against price impact.
177-
allow_partial_stake (bool): If true, allows partial stake swaps when the full amount would exceed the price threshold.
178-
rate_threshold (float): Maximum allowed increase in price ratio (0.005 = 0.5%).
177+
allow_partial_stake (bool): If true, allows partial stake swaps when the full amount would exceed the price tolerance.
178+
rate_tolerance (float): Maximum allowed increase in price ratio (0.005 = 0.5%).
179179
180180
Returns:
181181
success (bool): True if the swap was successful.
@@ -220,7 +220,7 @@ def swap_stake_extrinsic(
220220
origin_pool = subtensor.subnet(netuid=origin_netuid)
221221
destination_pool = subtensor.subnet(netuid=destination_netuid)
222222
swap_rate_ratio = origin_pool.price.rao / destination_pool.price.rao
223-
swap_rate_ratio_with_tolerance = swap_rate_ratio * (1 + rate_threshold)
223+
swap_rate_ratio_with_tolerance = swap_rate_ratio * (1 + rate_tolerance)
224224

225225
logging.info(
226226
f"Swapping stake with safety for hotkey [blue]{hotkey_ss58}[/blue]\n"

bittensor/core/extrinsics/staking.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def add_stake_extrinsic(
2121
wait_for_finalization: bool = False,
2222
safe_staking: bool = False,
2323
allow_partial_stake: bool = False,
24-
rate_threshold: float = 0.005,
24+
rate_tolerance: float = 0.005,
2525
) -> bool:
2626
"""
2727
Adds the specified amount of stake to passed hotkey `uid`.
@@ -37,8 +37,8 @@ def add_stake_extrinsic(
3737
wait_for_finalization: If set, waits for the extrinsic to be finalized on the chain before returning `True`,
3838
or returns `False` if the extrinsic fails to be finalized within the timeout.
3939
safe_staking (bool): If true, enables price safety checks
40-
allow_partial_stake (bool): If true, allows partial unstaking if price threshold exceeded
41-
rate_threshold (float): Maximum allowed price increase percentage (0.005 = 0.5%)
40+
allow_partial_stake (bool): If true, allows partial unstaking if price tolerance exceeded
41+
rate_tolerance (float): Maximum allowed price increase percentage (0.005 = 0.5%)
4242
4343
Returns:
4444
success: Flag is `True` if extrinsic was finalized or included in the block. If we did not wait for
@@ -106,16 +106,16 @@ def add_stake_extrinsic(
106106
if safe_staking:
107107
pool = subtensor.subnet(netuid=netuid)
108108
base_price = pool.price.rao
109-
price_with_tolerance = base_price * (1 + rate_threshold)
109+
price_with_tolerance = base_price * (1 + rate_tolerance)
110110

111111
# For logging
112112
base_rate = pool.price.tao
113-
rate_with_tolerance = base_rate * (1 + rate_threshold)
113+
rate_with_tolerance = base_rate * (1 + rate_tolerance)
114114

115115
logging.info(
116116
f":satellite: [magenta]Safe Staking to:[/magenta] "
117117
f"[blue]netuid: [green]{netuid}[/green], amount: [green]{staking_balance}[/green], "
118-
f"tolerance percentage: [green]{rate_threshold*100}%[/green], "
118+
f"tolerance percentage: [green]{rate_tolerance*100}%[/green], "
119119
f"price limit: [green]{rate_with_tolerance}[/green], "
120120
f"original price: [green]{base_rate}[/green], "
121121
f"with partial stake: [green]{allow_partial_stake}[/green] "

0 commit comments

Comments
 (0)