diff --git a/bittensor/core/extrinsics/asyncex/move_stake.py b/bittensor/core/extrinsics/asyncex/move_stake.py index 8ed6a29141..268d59e5fa 100644 --- a/bittensor/core/extrinsics/asyncex/move_stake.py +++ b/bittensor/core/extrinsics/asyncex/move_stake.py @@ -98,7 +98,7 @@ async def transfer_stake_extrinsic( ) call = await subtensor.substrate.compose_call( call_module="SubtensorModule", - call_function="transfer_stake", + call_function="transfer_stake_aggregate", call_params={ "destination_coldkey": destination_coldkey_ss58, "hotkey": hotkey_ss58, @@ -233,14 +233,14 @@ async def swap_stake_extrinsic( "allow_partial": allow_partial_stake, } ) - call_function = "swap_stake_limit" + call_function = "swap_stake_limit_aggregate" else: logging.info( f"Swapping stake for hotkey [blue]{hotkey_ss58}[/blue]\n" f"Amount: [green]{amount}[/green] from netuid [green]{origin_netuid}[/green] to netuid " f"[green]{destination_netuid}[/green]" ) - call_function = "swap_stake" + call_function = "swap_stake_aggregate" call = await subtensor.substrate.compose_call( call_module="SubtensorModule", @@ -353,7 +353,7 @@ async def move_stake_extrinsic( ) call = await subtensor.substrate.compose_call( call_module="SubtensorModule", - call_function="move_stake", + call_function="move_stake_aggregate", call_params={ "origin_hotkey": origin_hotkey, "origin_netuid": origin_netuid, diff --git a/bittensor/core/extrinsics/asyncex/staking.py b/bittensor/core/extrinsics/asyncex/staking.py index 76ffe73285..0f19688f3c 100644 --- a/bittensor/core/extrinsics/asyncex/staking.py +++ b/bittensor/core/extrinsics/asyncex/staking.py @@ -144,14 +144,14 @@ async def add_stake_extrinsic( "allow_partial": allow_partial_stake, } ) - call_function = "add_stake_limit" + call_function = "add_stake_limit_aggregate" else: logging.info( f":satellite: [magenta]Staking to:[/magenta] " f"[blue]netuid: [green]{netuid}[/green], amount: [green]{staking_balance}[/green] " f"on [blue]{subtensor.network}[/blue][magenta]...[/magenta]" ) - call_function = "add_stake" + call_function = "add_stake_aggregate" call = await subtensor.substrate.compose_call( call_module="SubtensorModule", @@ -346,7 +346,7 @@ async def add_stake_multiple_extrinsic( ) call = await subtensor.substrate.compose_call( call_module="SubtensorModule", - call_function="add_stake", + call_function="add_stake_aggregate", call_params={ "hotkey": hotkey_ss58, "amount_staked": staking_balance.rao, diff --git a/bittensor/core/extrinsics/asyncex/unstaking.py b/bittensor/core/extrinsics/asyncex/unstaking.py index fcc0416dd5..cc81957fa8 100644 --- a/bittensor/core/extrinsics/asyncex/unstaking.py +++ b/bittensor/core/extrinsics/asyncex/unstaking.py @@ -131,14 +131,14 @@ async def unstake_extrinsic( "allow_partial": allow_partial_stake, } ) - call_function = "remove_stake_limit" + call_function = "remove_stake_limit_aggregate" else: logging_info = ( f":satellite: [magenta]Unstaking from:[/magenta] " f"netuid: [green]{netuid}[/green], amount: [green]{unstaking_balance}[/green] " f"on [blue]{subtensor.network}[/blue]" ) - call_function = "remove_stake" + call_function = "remove_stake_aggregate" call = await subtensor.substrate.compose_call( call_module="SubtensorModule", @@ -255,7 +255,7 @@ async def unstake_all_extrinsic( async with subtensor.substrate as substrate: call = await substrate.compose_call( call_module="SubtensorModule", - call_function="remove_stake_full_limit", + call_function="remove_stake_full_limit_aggregate", call_params=call_params, ) @@ -387,7 +387,7 @@ async def unstake_multiple_extrinsic( try: call = await subtensor.substrate.compose_call( call_module="SubtensorModule", - call_function="remove_stake", + call_function="remove_stake_aggregate", call_params={ "hotkey": hotkey_ss58, "amount_unstaked": unstaking_balance.rao, diff --git a/bittensor/core/extrinsics/move_stake.py b/bittensor/core/extrinsics/move_stake.py index d3874f1e68..fd5002ee2b 100644 --- a/bittensor/core/extrinsics/move_stake.py +++ b/bittensor/core/extrinsics/move_stake.py @@ -95,7 +95,7 @@ def transfer_stake_extrinsic( ) call = subtensor.substrate.compose_call( call_module="SubtensorModule", - call_function="transfer_stake", + call_function="transfer_stake_aggregate", call_params={ "destination_coldkey": destination_coldkey_ss58, "hotkey": hotkey_ss58, @@ -229,14 +229,14 @@ def swap_stake_extrinsic( "allow_partial": allow_partial_stake, } ) - call_function = "swap_stake_limit" + call_function = "swap_stake_limit_aggregate" else: logging.info( f"Swapping stake for hotkey [blue]{hotkey_ss58}[/blue]\n" f"Amount: [green]{amount}[/green] from netuid [green]{origin_netuid}[/green] to netuid " f"[green]{destination_netuid}[/green]" ) - call_function = "swap_stake" + call_function = "swap_stake_aggregate" call = subtensor.substrate.compose_call( call_module="SubtensorModule", @@ -348,7 +348,7 @@ def move_stake_extrinsic( ) call = subtensor.substrate.compose_call( call_module="SubtensorModule", - call_function="move_stake", + call_function="move_stake_aggregate", call_params={ "origin_hotkey": origin_hotkey, "origin_netuid": origin_netuid, diff --git a/bittensor/core/extrinsics/staking.py b/bittensor/core/extrinsics/staking.py index fc8b69c48b..a9228b9a5a 100644 --- a/bittensor/core/extrinsics/staking.py +++ b/bittensor/core/extrinsics/staking.py @@ -136,14 +136,14 @@ def add_stake_extrinsic( "allow_partial": allow_partial_stake, } ) - call_function = "add_stake_limit" + call_function = "add_stake_limit_aggregate" else: logging.info( f":satellite: [magenta]Staking to:[/magenta] " f"[blue]netuid: [green]{netuid}[/green], amount: [green]{staking_balance}[/green] " f"on [blue]{subtensor.network}[/blue][magenta]...[/magenta]" ) - call_function = "add_stake" + call_function = "add_stake_aggregate" call = subtensor.substrate.compose_call( call_module="SubtensorModule", @@ -328,7 +328,7 @@ def add_stake_multiple_extrinsic( ) call = subtensor.substrate.compose_call( call_module="SubtensorModule", - call_function="add_stake", + call_function="add_stake_aggregate", call_params={ "hotkey": hotkey_ss58, "amount_staked": staking_balance.rao, diff --git a/bittensor/core/extrinsics/unstaking.py b/bittensor/core/extrinsics/unstaking.py index 8f0ce3329d..1ccae86eb4 100644 --- a/bittensor/core/extrinsics/unstaking.py +++ b/bittensor/core/extrinsics/unstaking.py @@ -130,14 +130,14 @@ def unstake_extrinsic( "allow_partial": allow_partial_stake, } ) - call_function = "remove_stake_limit" + call_function = "remove_stake_limit_aggregate" else: logging_info = ( f":satellite: [magenta]Unstaking from:[/magenta] " f"netuid: [green]{netuid}[/green], amount: [green]{unstaking_balance}[/green] " f"on [blue]{subtensor.network}[/blue]" ) - call_function = "remove_stake" + call_function = "remove_stake_aggregate" call = subtensor.substrate.compose_call( call_module="SubtensorModule", @@ -252,7 +252,7 @@ def unstake_all_extrinsic( call = subtensor.substrate.compose_call( call_module="SubtensorModule", - call_function="remove_stake_full_limit", + call_function="remove_stake_full_limit_aggregate", call_params=call_params, ) @@ -379,7 +379,7 @@ def unstake_multiple_extrinsic( try: call = subtensor.substrate.compose_call( call_module="SubtensorModule", - call_function="remove_stake", + call_function="remove_stake_aggregate", call_params={ "hotkey": hotkey_ss58, "amount_unstaked": unstaking_balance.rao, diff --git a/tests/e2e_tests/test_staking.py b/tests/e2e_tests/test_staking.py index b201805d55..b14f5d8561 100644 --- a/tests/e2e_tests/test_staking.py +++ b/tests/e2e_tests/test_staking.py @@ -79,7 +79,9 @@ def test_single_operation(subtensor, alice_wallet, bob_wallet): logging.console.info(f"Bob stake: {stake_bob}") assert stake_bob > Balance(0).set_unit(alice_subnet_netuid) - stakes = subtensor.get_stake_for_coldkey(alice_wallet.coldkey.ss58_address) + stakes = subtensor.get_stake_for_coldkey( + coldkey_ss58=alice_wallet.coldkey.ss58_address + ) expected_stakes = [ StakeInfo( @@ -119,8 +121,8 @@ def test_single_operation(subtensor, alice_wallet, bob_wallet): assert subtensor.get_stake_for_coldkey == subtensor.get_stake_info_for_coldkey stakes = subtensor.get_stake_for_coldkey_and_hotkey( - alice_wallet.coldkey.ss58_address, - bob_wallet.hotkey.ss58_address, + coldkey_ss58=alice_wallet.coldkey.ss58_address, + hotkey_ss58=bob_wallet.hotkey.ss58_address, ) assert stakes == { @@ -195,7 +197,7 @@ def test_batch_operations(subtensor, alice_wallet, bob_wallet): for _ in netuids: subtensor.register_subnet( - alice_wallet, + wallet=alice_wallet, wait_for_inclusion=True, wait_for_finalization=True, ) @@ -206,16 +208,16 @@ def test_batch_operations(subtensor, alice_wallet, bob_wallet): for netuid in netuids: subtensor.burned_register( - bob_wallet, - netuid, + wallet=bob_wallet, + netuid=netuid, wait_for_inclusion=True, wait_for_finalization=True, ) for netuid in netuids: stake = subtensor.get_stake( - alice_wallet.coldkey.ss58_address, - bob_wallet.hotkey.ss58_address, + coldkey_ss58=alice_wallet.coldkey.ss58_address, + hotkey_ss58=bob_wallet.hotkey.ss58_address, netuid=netuid, ) @@ -337,33 +339,33 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet): 2. Succeeds with strict threshold (0.5%) and partial staking allowed 3. Succeeds with lenient threshold (10% and 30%) and no partial staking """ - alice_subnet_netuid = subtensor.get_total_subnets() # 2 + alice_subnet_netuid = subtensor.subnets.get_total_subnets() # 2 # Register root as Alice - the subnet owner and validator - assert subtensor.register_subnet(alice_wallet, True, True) + assert subtensor.subnets.register_subnet(alice_wallet, True, True) # Verify subnet created successfully - assert subtensor.subnet_exists(alice_subnet_netuid), ( + assert subtensor.subnets.subnet_exists(alice_subnet_netuid), ( "Subnet wasn't created successfully" ) assert wait_to_start_call(subtensor, alice_wallet, alice_subnet_netuid) - subtensor.burned_register( - alice_wallet, + subtensor.extrinsics.burned_register( + wallet=alice_wallet, netuid=alice_subnet_netuid, wait_for_inclusion=True, wait_for_finalization=True, ) - subtensor.burned_register( - bob_wallet, + subtensor.extrinsics.burned_register( + wallet=bob_wallet, netuid=alice_subnet_netuid, wait_for_inclusion=True, wait_for_finalization=True, ) - initial_stake = subtensor.get_stake( - alice_wallet.coldkey.ss58_address, - bob_wallet.hotkey.ss58_address, + initial_stake = subtensor.staking.get_stake( + coldkey_ss58=alice_wallet.coldkey.ss58_address, + hotkey_ss58=bob_wallet.hotkey.ss58_address, netuid=alice_subnet_netuid, ) assert initial_stake == Balance(0).set_unit(alice_subnet_netuid) @@ -372,9 +374,9 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet): stake_amount = Balance.from_tao(100) # 1. Strict params - should fail - success = subtensor.add_stake( - alice_wallet, - bob_wallet.hotkey.ss58_address, + success = subtensor.staking.add_stake( + wallet=alice_wallet, + hotkey_ss58=bob_wallet.hotkey.ss58_address, netuid=alice_subnet_netuid, amount=stake_amount, wait_for_inclusion=True, @@ -383,11 +385,11 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet): rate_tolerance=0.005, # 0.5% allow_partial_stake=False, ) - assert success is False + assert success is False, "Staking should fail." - current_stake = subtensor.get_stake( - alice_wallet.coldkey.ss58_address, - bob_wallet.hotkey.ss58_address, + current_stake = subtensor.staking.get_stake( + coldkey_ss58=alice_wallet.coldkey.ss58_address, + hotkey_ss58=bob_wallet.hotkey.ss58_address, netuid=alice_subnet_netuid, ) assert current_stake == Balance(0).set_unit(alice_subnet_netuid), ( @@ -395,9 +397,9 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet): ) # 2. Partial allowed - should succeed partially - success = subtensor.add_stake( - alice_wallet, - bob_wallet.hotkey.ss58_address, + success = subtensor.staking.add_stake( + wallet=alice_wallet, + hotkey_ss58=bob_wallet.hotkey.ss58_address, netuid=alice_subnet_netuid, amount=stake_amount, wait_for_inclusion=True, @@ -408,9 +410,9 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet): ) assert success is True - partial_stake = subtensor.get_stake( - alice_wallet.coldkey.ss58_address, - bob_wallet.hotkey.ss58_address, + partial_stake = subtensor.staking.get_stake( + coldkey_ss58=alice_wallet.coldkey.ss58_address, + hotkey_ss58=bob_wallet.hotkey.ss58_address, netuid=alice_subnet_netuid, ) assert partial_stake > Balance(0).set_unit(alice_subnet_netuid), ( @@ -422,9 +424,9 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet): # 3. Higher threshold - should succeed fully amount = Balance.from_tao(100) - success = subtensor.add_stake( - alice_wallet, - bob_wallet.hotkey.ss58_address, + success = subtensor.staking.add_stake( + wallet=alice_wallet, + hotkey_ss58=bob_wallet.hotkey.ss58_address, netuid=alice_subnet_netuid, amount=amount, wait_for_inclusion=True, @@ -435,17 +437,17 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet): ) assert success is True - full_stake = subtensor.get_stake( - alice_wallet.coldkey.ss58_address, - bob_wallet.hotkey.ss58_address, + full_stake = subtensor.staking.get_stake( + coldkey_ss58=alice_wallet.coldkey.ss58_address, + hotkey_ss58=bob_wallet.hotkey.ss58_address, netuid=alice_subnet_netuid, ) # Test Unstaking Scenarios # 1. Strict params - should fail - success = subtensor.unstake( - alice_wallet, - bob_wallet.hotkey.ss58_address, + success = subtensor.staking.unstake( + wallet=alice_wallet, + hotkey_ss58=bob_wallet.hotkey.ss58_address, netuid=alice_subnet_netuid, amount=full_stake, wait_for_inclusion=True, @@ -456,9 +458,9 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet): ) assert success is False, "Unstake should fail." - current_stake = subtensor.get_stake( - alice_wallet.coldkey.ss58_address, - bob_wallet.hotkey.ss58_address, + current_stake = subtensor.staking.get_stake( + coldkey_ss58=alice_wallet.coldkey.ss58_address, + hotkey_ss58=bob_wallet.hotkey.ss58_address, netuid=alice_subnet_netuid, ) @@ -470,9 +472,9 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet): ) # 2. Partial allowed - should succeed partially - success = subtensor.unstake( - alice_wallet, - bob_wallet.hotkey.ss58_address, + success = subtensor.staking.unstake( + wallet=alice_wallet, + hotkey_ss58=bob_wallet.hotkey.ss58_address, netuid=alice_subnet_netuid, amount=current_stake, wait_for_inclusion=True, @@ -483,9 +485,9 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet): ) assert success is True - partial_unstake = subtensor.get_stake( - alice_wallet.coldkey.ss58_address, - bob_wallet.hotkey.ss58_address, + partial_unstake = subtensor.staking.get_stake( + coldkey_ss58=alice_wallet.coldkey.ss58_address, + hotkey_ss58=bob_wallet.hotkey.ss58_address, netuid=alice_subnet_netuid, ) logging.console.info(f"[orange]Partial unstake: {partial_unstake}[orange]") @@ -494,9 +496,9 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet): ) # 3. Higher threshold - should succeed fully - success = subtensor.unstake( - alice_wallet, - bob_wallet.hotkey.ss58_address, + success = subtensor.staking.unstake( + wallet=alice_wallet, + hotkey_ss58=bob_wallet.hotkey.ss58_address, netuid=alice_subnet_netuid, amount=partial_unstake, wait_for_inclusion=True, diff --git a/tests/unit_tests/extrinsics/asyncex/test_unstaking.py b/tests/unit_tests/extrinsics/asyncex/test_unstaking.py index 24857e0261..69567d4d6e 100644 --- a/tests/unit_tests/extrinsics/asyncex/test_unstaking.py +++ b/tests/unit_tests/extrinsics/asyncex/test_unstaking.py @@ -43,7 +43,7 @@ async def test_unstake_extrinsic(fake_wallet, mocker): fake_subtensor.substrate.compose_call.assert_awaited_once_with( call_module="SubtensorModule", - call_function="remove_stake", + call_function="remove_stake_aggregate", call_params={ "hotkey": "hotkey", "amount_unstaked": 1100000000, @@ -89,7 +89,7 @@ async def test_unstake_all_extrinsic(fake_wallet, mocker): fake_substrate.compose_call.assert_awaited_once_with( call_module="SubtensorModule", - call_function="remove_stake_full_limit", + call_function="remove_stake_full_limit_aggregate", call_params={ "hotkey": "hotkey", "netuid": fake_netuid, @@ -152,7 +152,7 @@ async def test_unstake_multiple_extrinsic(fake_wallet, mocker): fake_subtensor.substrate.compose_call.assert_any_call( call_module="SubtensorModule", - call_function="remove_stake", + call_function="remove_stake_aggregate", call_params={ "hotkey": "hotkey1", "amount_unstaked": 1100000000, @@ -161,7 +161,7 @@ async def test_unstake_multiple_extrinsic(fake_wallet, mocker): ) fake_subtensor.substrate.compose_call.assert_any_call( call_module="SubtensorModule", - call_function="remove_stake", + call_function="remove_stake_aggregate", call_params={ "hotkey": "hotkey1", "amount_unstaked": 1100000000, diff --git a/tests/unit_tests/extrinsics/test_staking.py b/tests/unit_tests/extrinsics/test_staking.py index 80ecb5c240..0373b6eb37 100644 --- a/tests/unit_tests/extrinsics/test_staking.py +++ b/tests/unit_tests/extrinsics/test_staking.py @@ -40,7 +40,7 @@ def test_add_stake_extrinsic(mocker): fake_subtensor.substrate.compose_call.assert_called_once_with( call_module="SubtensorModule", - call_function="add_stake", + call_function="add_stake_aggregate", call_params={"hotkey": "hotkey", "amount_staked": 9, "netuid": 1}, ) fake_subtensor.sign_and_send_extrinsic.assert_called_once_with( @@ -115,7 +115,7 @@ def test_add_stake_multiple_extrinsic(mocker): fake_subtensor.substrate.compose_call.assert_any_call( call_module="SubtensorModule", - call_function="add_stake", + call_function="add_stake_aggregate", call_params={ "hotkey": "hotkey2", "amount_staked": 2199999333, @@ -124,7 +124,7 @@ def test_add_stake_multiple_extrinsic(mocker): ) fake_subtensor.substrate.compose_call.assert_any_call( call_module="SubtensorModule", - call_function="add_stake", + call_function="add_stake_aggregate", call_params={ "hotkey": "hotkey2", "amount_staked": 2199999333, diff --git a/tests/unit_tests/extrinsics/test_unstaking.py b/tests/unit_tests/extrinsics/test_unstaking.py index 69e020854f..3d15ced095 100644 --- a/tests/unit_tests/extrinsics/test_unstaking.py +++ b/tests/unit_tests/extrinsics/test_unstaking.py @@ -39,7 +39,7 @@ def test_unstake_extrinsic(fake_wallet, mocker): fake_subtensor.substrate.compose_call.assert_called_once_with( call_module="SubtensorModule", - call_function="remove_stake", + call_function="remove_stake_aggregate", call_params={ "hotkey": "hotkey", "amount_unstaked": 1100000000, @@ -84,7 +84,7 @@ def test_unstake_all_extrinsic(fake_wallet, mocker): fake_subtensor.substrate.compose_call.assert_called_once_with( call_module="SubtensorModule", - call_function="remove_stake_full_limit", + call_function="remove_stake_full_limit_aggregate", call_params={ "hotkey": "hotkey", "netuid": fake_netuid, @@ -146,16 +146,7 @@ def test_unstake_multiple_extrinsic(fake_wallet, mocker): fake_subtensor.substrate.compose_call.assert_any_call( call_module="SubtensorModule", - call_function="remove_stake", - call_params={ - "hotkey": "hotkey1", - "amount_unstaked": 1100000000, - "netuid": 1, - }, - ) - fake_subtensor.substrate.compose_call.assert_any_call( - call_module="SubtensorModule", - call_function="remove_stake", + call_function="remove_stake_aggregate", call_params={ "hotkey": "hotkey1", "amount_unstaked": 1100000000, diff --git a/tests/unit_tests/test_subtensor_extended.py b/tests/unit_tests/test_subtensor_extended.py index 8869084668..42e0c13889 100644 --- a/tests/unit_tests/test_subtensor_extended.py +++ b/tests/unit_tests/test_subtensor_extended.py @@ -711,7 +711,7 @@ def test_move_stake(mock_substrate, subtensor, fake_wallet, wait): mock_substrate, fake_wallet.coldkey, call_module="SubtensorModule", - call_function="move_stake", + call_function="move_stake_aggregate", call_params={ "origin_hotkey": "origin_hotkey", "origin_netuid": 1, @@ -762,7 +762,7 @@ def test_move_stake_error(mock_substrate, subtensor, fake_wallet, mocker): mock_substrate, fake_wallet.coldkey, call_module="SubtensorModule", - call_function="move_stake", + call_function="move_stake_aggregate", call_params={ "origin_hotkey": "origin_hotkey", "origin_netuid": 1, @@ -793,7 +793,7 @@ def test_move_stake_exception(mock_substrate, subtensor, fake_wallet): mock_substrate, fake_wallet.coldkey, call_module="SubtensorModule", - call_function="move_stake", + call_function="move_stake_aggregate", call_params={ "origin_hotkey": "origin_hotkey", "origin_netuid": 1, @@ -1077,7 +1077,7 @@ def test_swap_stake(mock_substrate, subtensor, fake_wallet, mocker): mock_substrate, fake_wallet.coldkey, call_module="SubtensorModule", - call_function="swap_stake", + call_function="swap_stake_aggregate", call_params={ "hotkey": fake_wallet.hotkey.ss58_address, "origin_netuid": 1, @@ -1421,7 +1421,7 @@ def test_transfer_stake(mock_substrate, subtensor, fake_wallet, mocker, wait): mock_substrate, fake_wallet.coldkey, call_module="SubtensorModule", - call_function="transfer_stake", + call_function="transfer_stake_aggregate", call_params={ "destination_coldkey": "dest", "hotkey": "hotkey_ss58", @@ -1472,7 +1472,7 @@ def test_transfer_stake_error( mock_substrate, fake_wallet.coldkey, call_module="SubtensorModule", - call_function="transfer_stake", + call_function="transfer_stake_aggregate", call_params={ "destination_coldkey": "dest", "hotkey": "hotkey_ss58",