diff --git a/bittensor/core/async_subtensor.py b/bittensor/core/async_subtensor.py index 9998029fa3..d199c029fc 100644 --- a/bittensor/core/async_subtensor.py +++ b/bittensor/core/async_subtensor.py @@ -4191,54 +4191,30 @@ async def get_stake( reuse_block: bool = False, ) -> Balance: """ - Returns the stake under a coldkey - hotkey pairing. + Returns the amount of Alpha staked by a specific coldkey to a specific hotkey within a given subnet. Parameters: - hotkey_ss58: The SS58 address of the hotkey. - coldkey_ss58: The SS58 address of the coldkey. - netuid: The subnet ID. - block: The block number at which to query the stake information. - block_hash: The hash of the block to retrieve the stake from. Do not specify if using block - or reuse_block - reuse_block: Whether to use the last-used block. Do not set if using `block_hash` or `block`. + coldkey_ss58: The SS58 address of the coldkey that delegated the stake. This address owns the stake. + hotkey_ss58: The SS58 address of the hotkey which the stake is on. + netuid: The unique identifier of the subnet to query. + block: The specific block number at which to retrieve the stake information. + or `reuse_block`. + block_hash: The hash of the block to retrieve the stake from. Do not specify if using `block` + or `reuse_block`. + reuse_block: Whether to use the last-used block hash. Do not set if using `block_hash` or `block`. Returns: - Balance: The stake under the coldkey - hotkey pairing. + An object representing the amount of Alpha (TAO ONLY if the subnet's netuid is 0) currently staked from the + specified coldkey to the specified hotkey within the given subnet. """ block_hash = await self.determine_block_hash(block, block_hash, reuse_block) - - alpha_shares = await self.query_subtensor( - name="Alpha", - block=block, - block_hash=block_hash, - reuse_block=reuse_block, + result = await self.query_runtime_api( + runtime_api="StakeInfoRuntimeApi", + method="get_stake_info_for_hotkey_coldkey_netuid", params=[hotkey_ss58, coldkey_ss58, netuid], - ) - hotkey_alpha_result = await self.query_subtensor( - name="TotalHotkeyAlpha", - block=block, - block_hash=block_hash, - reuse_block=reuse_block, - params=[hotkey_ss58, netuid], - ) - hotkey_shares = await self.query_subtensor( - name="TotalHotkeyShares", - block=block, block_hash=block_hash, - reuse_block=reuse_block, - params=[hotkey_ss58, netuid], ) - - hotkey_alpha = getattr(hotkey_alpha_result, "value", hotkey_alpha_result) - alpha_shares_as_float = fixed_to_float(alpha_shares) - hotkey_shares_as_float = fixed_to_float(hotkey_shares) - - if hotkey_shares_as_float == 0: - return Balance.from_rao(0).set_unit(netuid=netuid) - - stake = alpha_shares_as_float / hotkey_shares_as_float * cast(int, hotkey_alpha) - - return Balance.from_rao(int(stake)).set_unit(netuid=netuid) + return StakeInfo.from_dict(result).stake async def get_stake_add_fee( self, diff --git a/bittensor/core/extrinsics/asyncex/mev_shield.py b/bittensor/core/extrinsics/asyncex/mev_shield.py index b0cd644e12..d4bf360997 100644 --- a/bittensor/core/extrinsics/asyncex/mev_shield.py +++ b/bittensor/core/extrinsics/asyncex/mev_shield.py @@ -10,6 +10,7 @@ from bittensor.core.extrinsics.utils import ( get_mev_shielded_ciphertext, get_event_data_by_event_name, + resolve_mev_shield_period, ) from bittensor.core.types import ExtrinsicResponse from bittensor.utils import format_error_message @@ -146,7 +147,8 @@ async def submit_encrypted_extrinsic( inner_signing_keypair = getattr(wallet, sign_with) - era = "00" if period is None else {"period": period} + effective_period = resolve_mev_shield_period(period) + era = {"period": effective_period} current_nonce = await subtensor.substrate.get_account_next_index( account_address=inner_signing_keypair.ss58_address @@ -172,7 +174,7 @@ async def submit_encrypted_extrinsic( sign_with=sign_with, call=extrinsic_call, nonce=current_nonce, - period=period, + period=effective_period, raise_error=raise_error, wait_for_inclusion=wait_for_inclusion, wait_for_finalization=wait_for_finalization, diff --git a/bittensor/core/extrinsics/mev_shield.py b/bittensor/core/extrinsics/mev_shield.py index ab34ae07cf..fd618a6ee8 100644 --- a/bittensor/core/extrinsics/mev_shield.py +++ b/bittensor/core/extrinsics/mev_shield.py @@ -11,6 +11,7 @@ from bittensor.core.extrinsics.utils import ( get_mev_shielded_ciphertext, get_event_data_by_event_name, + resolve_mev_shield_period, ) from bittensor.core.types import ExtrinsicResponse from bittensor.utils.btlogging import logging @@ -146,7 +147,8 @@ def submit_encrypted_extrinsic( inner_signing_keypair = getattr(wallet, sign_with) - era = "00" if period is None else {"period": period} + effective_period = resolve_mev_shield_period(period) + era = {"period": effective_period} current_nonce = subtensor.substrate.get_account_next_index( account_address=inner_signing_keypair.ss58_address @@ -170,7 +172,7 @@ def submit_encrypted_extrinsic( sign_with=sign_with, call=extrinsic_call, nonce=current_nonce, - period=period, + period=effective_period, raise_error=raise_error, wait_for_inclusion=wait_for_inclusion, wait_for_finalization=wait_for_finalization, diff --git a/bittensor/core/extrinsics/utils.py b/bittensor/core/extrinsics/utils.py index 6244635efe..a491d82da8 100644 --- a/bittensor/core/extrinsics/utils.py +++ b/bittensor/core/extrinsics/utils.py @@ -8,9 +8,16 @@ from bittensor_wallet import Keypair from bittensor.core.extrinsics.pallets import Sudo +from bittensor.core.settings import MAX_MEV_SHIELD_PERIOD from bittensor.core.types import ExtrinsicResponse from bittensor.utils.balance import Balance +if TYPE_CHECKING: + from bittensor_wallet import Wallet + from bittensor.core.chain_data import StakeInfo + from bittensor.core.subtensor import Subtensor + from scalecodec.types import GenericExtrinsic + # TODO: Michael/Roman add the link to the docs once it's ready.' MEV_HOTKEY_USAGE_WARNING = ( "MeV Shield cannot be used with hotkey-signed extrinsics. The transaction will fail because the hotkey cannot pay " @@ -18,11 +25,22 @@ " the transaction." ) -if TYPE_CHECKING: - from bittensor_wallet import Wallet - from bittensor.core.chain_data import StakeInfo - from bittensor.core.subtensor import Subtensor - from scalecodec.types import GenericExtrinsic + +def resolve_mev_shield_period(period: Optional[int]) -> int: + """Return effective era period for MEV Shield extrinsics. + + MEV Shield extrinsics must use a short-lived era. If period is omitted or + exceeds the MEV limit, the maximum allowed MEV period is applied. + + Parameters: + period: The period to resolve. + + Returns: + The effective period (in blocks). + """ + if period is None or period > MAX_MEV_SHIELD_PERIOD: + return MAX_MEV_SHIELD_PERIOD + return period def get_old_stakes( diff --git a/bittensor/core/settings.py b/bittensor/core/settings.py index 1d7ed87932..06c900062b 100644 --- a/bittensor/core/settings.py +++ b/bittensor/core/settings.py @@ -70,6 +70,10 @@ # details https://paritytech.github.io/polkadot-sdk/master/src/sp_runtime/generic/era.rs.html#65-72 DEFAULT_PERIOD = 128 +# Maximum period (in blocks) for MEV Shield-protected extrinsics Era. +# This keeps encrypted submissions short-lived in the mempool. +MAX_MEV_SHIELD_PERIOD = 8 + # Default MEV Shield protection setting for extrinsics. # When enabled, transactions are encrypted to protect against Miner Extractable Value (MEV) attacks. DEFAULT_MEV_PROTECTION = os.getenv("BT_MEV_PROTECTION", "").lower() in ( diff --git a/bittensor/core/subtensor.py b/bittensor/core/subtensor.py index dcb6b25805..53f594e4f8 100644 --- a/bittensor/core/subtensor.py +++ b/bittensor/core/subtensor.py @@ -3465,11 +3465,10 @@ def get_stake( ) -> Balance: """ Returns the amount of Alpha staked by a specific coldkey to a specific hotkey within a given subnet. - This function retrieves the delegated stake balance, referred to as the 'Alpha' value. Parameters: coldkey_ss58: The SS58 address of the coldkey that delegated the stake. This address owns the stake. - hotkey_ss58: The ss58 address of the hotkey which the stake is on. + hotkey_ss58: The SS58 address of the hotkey which the stake is on. netuid: The unique identifier of the subnet to query. block: The specific block number at which to retrieve the stake information. @@ -3477,41 +3476,13 @@ def get_stake( An object representing the amount of Alpha (TAO ONLY if the subnet's netuid is 0) currently staked from the specified coldkey to the specified hotkey within the given subnet. """ - alpha_shares_query = self.query_module( - module="SubtensorModule", - name="Alpha", - block=block, + result = self.query_runtime_api( + runtime_api="StakeInfoRuntimeApi", + method="get_stake_info_for_hotkey_coldkey_netuid", params=[hotkey_ss58, coldkey_ss58, netuid], - ) - alpha_shares = alpha_shares_query - - hotkey_alpha_obj = cast( - ScaleObj, - self.query_module( - module="SubtensorModule", - name="TotalHotkeyAlpha", - block=block, - params=[hotkey_ss58, netuid], - ), - ) - hotkey_alpha = hotkey_alpha_obj.value - - hotkey_shares = self.query_module( - module="SubtensorModule", - name="TotalHotkeyShares", block=block, - params=[hotkey_ss58, netuid], ) - - alpha_shares_as_float = fixed_to_float(alpha_shares) - hotkey_shares_as_float = fixed_to_float(hotkey_shares) - - if hotkey_shares_as_float == 0: - return Balance.from_rao(0).set_unit(netuid=netuid) - - stake = alpha_shares_as_float / hotkey_shares_as_float * hotkey_alpha - - return Balance.from_rao(int(stake)).set_unit(netuid=netuid) + return StakeInfo.from_dict(result).stake def get_stake_for_coldkey_and_hotkey( self, diff --git a/tests/e2e_tests/test_root_claim.py b/tests/e2e_tests/test_root_claim.py index 77a87b30a2..012a0858ac 100644 --- a/tests/e2e_tests/test_root_claim.py +++ b/tests/e2e_tests/test_root_claim.py @@ -382,7 +382,7 @@ def test_root_claim_keep_with_zero_num_root_auto_claims( hotkey_ss58=alice_wallet.hotkey.ss58_address, netuid=sn2.netuid, ) - assert stake_after_charlie >= claimable_stake_before_charlie + assert stake_after_charlie >= claimable_stake_before_charlie - Balance.from_rao(1, sn2.netuid) logging.console.info(f"[blue]Charlie after:[/blue]") logging.console.info(f"RootClaimed: {claimed_after_charlie}") @@ -559,7 +559,7 @@ async def test_root_claim_keep_with_zero_num_root_auto_claims_async( hotkey_ss58=alice_wallet.hotkey.ss58_address, netuid=sn2.netuid, ) - assert stake_after_charlie >= claimable_stake_before_charlie + assert stake_after_charlie >= claimable_stake_before_charlie - Balance.from_rao(1, sn2.netuid) logging.console.info(f"[blue]Charlie after:[/blue]") logging.console.info(f"RootClaimed: {claimed_after_charlie}") diff --git a/tests/e2e_tests/test_staking.py b/tests/e2e_tests/test_staking.py index b95879993b..f0010f234f 100644 --- a/tests/e2e_tests/test_staking.py +++ b/tests/e2e_tests/test_staking.py @@ -444,8 +444,8 @@ def test_batch_operations(subtensor, alice_wallet, bob_wallet): ) assert CloseInValue( # Make sure we are within 0.0002 TAO due to tx fees - balances[bob_wallet.coldkey.ss58_address], Balance.from_rao(1_500_000) - ) == Balance.from_tao(999_999.7956) + balances[bob_wallet.coldkey.ss58_address], Balance.from_rao(5_000_000) + ) == Balance.from_tao(999_999.7979) assert balances[alice_wallet.coldkey.ss58_address] > alice_balance @@ -570,8 +570,8 @@ async def test_batch_operations_async(async_subtensor, alice_wallet, bob_wallet) ) assert CloseInValue( # Make sure we are within 0.0002 TAO due to tx fees - balances[bob_wallet.coldkey.ss58_address], Balance.from_rao(1_500_000) - ) == Balance.from_tao(999_999.7956) + balances[bob_wallet.coldkey.ss58_address], Balance.from_rao(5_000_000) + ) == Balance.from_tao(999_999.7979) assert balances[alice_wallet.coldkey.ss58_address] > alice_balance diff --git a/tests/unit_tests/extrinsics/asyncex/test_mev_shield.py b/tests/unit_tests/extrinsics/asyncex/test_mev_shield.py index 057484603a..241203f80d 100644 --- a/tests/unit_tests/extrinsics/asyncex/test_mev_shield.py +++ b/tests/unit_tests/extrinsics/asyncex/test_mev_shield.py @@ -4,6 +4,7 @@ from scalecodec.types import GenericCall from bittensor.core.extrinsics.asyncex import mev_shield +from bittensor.core.settings import MAX_MEV_SHIELD_PERIOD from bittensor.core.types import ExtrinsicResponse @@ -220,7 +221,7 @@ async def test_submit_encrypted_extrinsic_success_with_revealed_execution( call=call, keypair=fake_wallet.coldkey, nonce=next_nonce, - era="00", + era={"period": 8}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -235,7 +236,7 @@ async def test_submit_encrypted_extrinsic_success_with_revealed_execution( sign_with="coldkey", call=mock_extrinsic_call, nonce=current_nonce, - period=None, + period=8, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, @@ -337,7 +338,7 @@ async def test_submit_encrypted_extrinsic_success_without_revealed_execution( call=call, keypair=fake_wallet.coldkey, nonce=next_nonce, - era="00", + era={"period": 8}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -352,7 +353,7 @@ async def test_submit_encrypted_extrinsic_success_without_revealed_execution( sign_with="coldkey", call=mock_extrinsic_call, nonce=current_nonce, - period=None, + period=8, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, @@ -557,7 +558,7 @@ async def test_submit_encrypted_extrinsic_encrypted_submitted_event_not_found( call=call, keypair=fake_wallet.coldkey, nonce=next_nonce, - era="00", + era={"period": 8}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -572,7 +573,7 @@ async def test_submit_encrypted_extrinsic_encrypted_submitted_event_not_found( sign_with="coldkey", call=mock_extrinsic_call, nonce=current_nonce, - period=None, + period=8, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, @@ -694,7 +695,7 @@ async def test_submit_encrypted_extrinsic_failed_to_find_outcome( call=call, keypair=fake_wallet.coldkey, nonce=next_nonce, - era="00", + era={"period": 8}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -709,7 +710,7 @@ async def test_submit_encrypted_extrinsic_failed_to_find_outcome( sign_with="coldkey", call=mock_extrinsic_call, nonce=current_nonce, - period=None, + period=8, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, @@ -846,7 +847,7 @@ async def test_submit_encrypted_extrinsic_execution_failure( call=call, keypair=fake_wallet.coldkey, nonce=next_nonce, - era="00", + era={"period": 8}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -861,7 +862,7 @@ async def test_submit_encrypted_extrinsic_execution_failure( sign_with="coldkey", call=mock_extrinsic_call, nonce=current_nonce, - period=None, + period=8, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, @@ -962,7 +963,7 @@ async def test_submit_encrypted_extrinsic_sign_and_send_failure( call=call, keypair=fake_wallet.coldkey, nonce=next_nonce, - era="00", + era={"period": 8}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -977,7 +978,7 @@ async def test_submit_encrypted_extrinsic_sign_and_send_failure( sign_with="coldkey", call=mock_extrinsic_call, nonce=current_nonce, - period=None, + period=8, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, @@ -1064,7 +1065,7 @@ async def test_submit_encrypted_extrinsic_with_hotkey(subtensor, fake_wallet, mo call=call, keypair=fake_wallet.hotkey, nonce=next_nonce, - era="00", + era={"period": 8}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -1079,7 +1080,7 @@ async def test_submit_encrypted_extrinsic_with_hotkey(subtensor, fake_wallet, mo sign_with="hotkey", call=mock_extrinsic_call, nonce=current_nonce, - period=None, + period=8, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, @@ -1167,7 +1168,7 @@ async def test_submit_encrypted_extrinsic_with_period(subtensor, fake_wallet, mo call=call, keypair=fake_wallet.coldkey, nonce=next_nonce, - era={"period": period}, + era={"period": MAX_MEV_SHIELD_PERIOD}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -1182,7 +1183,7 @@ async def test_submit_encrypted_extrinsic_with_period(subtensor, fake_wallet, mo sign_with="coldkey", call=mock_extrinsic_call, nonce=current_nonce, - period=period, + period=MAX_MEV_SHIELD_PERIOD, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, diff --git a/tests/unit_tests/extrinsics/test_mev_shield.py b/tests/unit_tests/extrinsics/test_mev_shield.py index a2642b0764..2c0fba851b 100644 --- a/tests/unit_tests/extrinsics/test_mev_shield.py +++ b/tests/unit_tests/extrinsics/test_mev_shield.py @@ -4,6 +4,7 @@ from async_substrate_interface.errors import SubstrateRequestException from bittensor.core.extrinsics import mev_shield +from bittensor.core.settings import MAX_MEV_SHIELD_PERIOD from bittensor.core.types import ExtrinsicResponse @@ -196,7 +197,7 @@ def test_submit_encrypted_extrinsic_success_with_revealed_execution( call=call, keypair=fake_wallet.coldkey, nonce=next_nonce, - era="00", + era={"period": 8}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -211,7 +212,7 @@ def test_submit_encrypted_extrinsic_success_with_revealed_execution( sign_with="coldkey", call=mock_extrinsic_call, nonce=current_nonce, - period=None, + period=8, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, @@ -308,7 +309,7 @@ def test_submit_encrypted_extrinsic_success_without_revealed_execution( call=call, keypair=fake_wallet.coldkey, nonce=next_nonce, - era="00", + era={"period": 8}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -323,7 +324,7 @@ def test_submit_encrypted_extrinsic_success_without_revealed_execution( sign_with="coldkey", call=mock_extrinsic_call, nonce=current_nonce, - period=None, + period=8, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, @@ -510,7 +511,7 @@ def test_submit_encrypted_extrinsic_encrypted_submitted_event_not_found( call=call, keypair=fake_wallet.coldkey, nonce=next_nonce, - era="00", + era={"period": 8}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -525,7 +526,7 @@ def test_submit_encrypted_extrinsic_encrypted_submitted_event_not_found( sign_with="coldkey", call=mock_extrinsic_call, nonce=current_nonce, - period=None, + period=8, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, @@ -636,7 +637,7 @@ def test_submit_encrypted_extrinsic_failed_to_find_outcome( call=call, keypair=fake_wallet.coldkey, nonce=next_nonce, - era="00", + era={"period": 8}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -651,7 +652,7 @@ def test_submit_encrypted_extrinsic_failed_to_find_outcome( sign_with="coldkey", call=mock_extrinsic_call, nonce=current_nonce, - period=None, + period=8, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, @@ -775,7 +776,7 @@ def test_submit_encrypted_extrinsic_execution_failure(subtensor, fake_wallet, mo call=call, keypair=fake_wallet.coldkey, nonce=next_nonce, - era="00", + era={"period": 8}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -790,7 +791,7 @@ def test_submit_encrypted_extrinsic_execution_failure(subtensor, fake_wallet, mo sign_with="coldkey", call=mock_extrinsic_call, nonce=current_nonce, - period=None, + period=8, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, @@ -883,7 +884,7 @@ def test_submit_encrypted_extrinsic_sign_and_send_failure( call=call, keypair=fake_wallet.coldkey, nonce=next_nonce, - era="00", + era={"period": 8}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -898,7 +899,7 @@ def test_submit_encrypted_extrinsic_sign_and_send_failure( sign_with="coldkey", call=mock_extrinsic_call, nonce=current_nonce, - period=None, + period=8, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, @@ -977,7 +978,7 @@ def test_submit_encrypted_extrinsic_with_hotkey(subtensor, fake_wallet, mocker): call=call, keypair=fake_wallet.hotkey, nonce=next_nonce, - era="00", + era={"period": 8}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -992,7 +993,7 @@ def test_submit_encrypted_extrinsic_with_hotkey(subtensor, fake_wallet, mocker): sign_with="hotkey", call=mock_extrinsic_call, nonce=current_nonce, - period=None, + period=8, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, @@ -1072,7 +1073,7 @@ def test_submit_encrypted_extrinsic_with_period(subtensor, fake_wallet, mocker): call=call, keypair=fake_wallet.coldkey, nonce=next_nonce, - era={"period": period}, + era={"period": MAX_MEV_SHIELD_PERIOD}, ) mocked_get_mev_shielded_ciphertext.assert_called_once_with( signed_ext=mock_signed_extrinsic, @@ -1087,7 +1088,7 @@ def test_submit_encrypted_extrinsic_with_period(subtensor, fake_wallet, mocker): sign_with="coldkey", call=mock_extrinsic_call, nonce=current_nonce, - period=period, + period=MAX_MEV_SHIELD_PERIOD, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, diff --git a/tests/unit_tests/extrinsics/test_staking.py b/tests/unit_tests/extrinsics/test_staking.py index c354daf0db..6ac282605b 100644 --- a/tests/unit_tests/extrinsics/test_staking.py +++ b/tests/unit_tests/extrinsics/test_staking.py @@ -181,6 +181,7 @@ def test_add_stake_multiple_extrinsic(subtensor, mocker, fake_wallet): "get_stake_info_for_coldkey", return_value=[Balance(1.1), Balance(0.3)], ) + mocker.patch.object(subtensor, "get_stake", return_value=Balance.from_tao(2.2)) mocker.patch.object(subtensor, "get_balance", return_value=Balance.from_tao(10)) mocker.patch.object( staking, "get_old_stakes", return_value=[Balance(1.1), Balance(0.3)] diff --git a/tests/unit_tests/extrinsics/test_unstaking.py b/tests/unit_tests/extrinsics/test_unstaking.py index f5c6f578a9..710d052062 100644 --- a/tests/unit_tests/extrinsics/test_unstaking.py +++ b/tests/unit_tests/extrinsics/test_unstaking.py @@ -119,7 +119,8 @@ def test_unstake_multiple_extrinsic(subtensor, fake_wallet, mocker): mocked_balance = mocker.patch.object( subtensor, "get_balance", return_value=Balance.from_tao(1.0) ) - mocked_get_stake_for_coldkey_and_hotkey = mocker.patch.object( + mocker.patch.object(subtensor, "get_stake", return_value=Balance.from_tao(8.9)) + mocker.patch.object( subtensor, "get_stake_for_coldkey_and_hotkey", return_value=[Balance(10.0)] ) mocked_unstake_extrinsic = mocker.patch.object( diff --git a/tests/unit_tests/test_async_subtensor.py b/tests/unit_tests/test_async_subtensor.py index 0de06619e3..072be4b650 100644 --- a/tests/unit_tests/test_async_subtensor.py +++ b/tests/unit_tests/test_async_subtensor.py @@ -3874,7 +3874,6 @@ async def fake_current_sqrt_prices(): assert result == expected_prices - @pytest.mark.asyncio async def test_all_subnets(subtensor, mocker): """Verify that `all_subnets` calls proper methods and returns the correct value.""" diff --git a/tests/unit_tests/test_subtensor.py b/tests/unit_tests/test_subtensor.py index 97645d27f5..0a55814fd7 100644 --- a/tests/unit_tests/test_subtensor.py +++ b/tests/unit_tests/test_subtensor.py @@ -4151,8 +4151,6 @@ def test_get_subnet_prices(subtensor, mocker): assert result == expected_prices - - def test_all_subnets(subtensor, mocker): """Verify that `all_subnets` calls proper methods and returns the correct value.""" # Preps