Skip to content

remove_stake_limit function has a bug #1962

@basfroman

Description

@basfroman

Short

remove_stake_limit extrinsic executes partially even when allow_partial=False.

Detailed

When executing the unstake extrinsic from the Bittensor SDK with allow_partial_stake=False, the expected behavior is fill-or-kill:

  • If the unstake can be fully executed under the given conditions, it should complete successfully.
  • If not, the extrinsic should fail entirely and no stake should be removed.

Currently, we observe partial unstaking:

  • The extrinsic returns an error (transaction fails),
  • but part of the stake is still removed, and the wallet balance is increased.

This breaks the fill-or-kill guarantee and leads to inconsistent state.

Code:

  full_stake = subtensor.get_stake(
      coldkey_ss58=alice_wallet.coldkey.ss58_address,
      hotkey_ss58=bob_wallet.hotkey.ss58_address,
      netuid=alice_subnet_netuid,
  )
  success = subtensor.extrinsics.unstake(
      wallet=alice_wallet,
      hotkey_ss58=bob_wallet.hotkey.ss58_address,
      netuid=alice_subnet_netuid,
      amount=full_stake,
      wait_for_inclusion=True,
      wait_for_finalization=True,
      safe_staking=True,
      rate_tolerance=0.005,
      allow_partial_stake=False,
  )

Expected Behavior

  • If the unstake can be fully executed within rate_tolerance and allow_partial_stake=False, unstake succeeds.
  • If not, the extrinsic fails entirely and no stake or balance change occurs.

Actual Behavior

  • Extrinsic fails with error.
  • However, a portion of stake is still removed and the coldkey balance is credited, i.e. partial execution occurred despite allow_partial_stake=False.

Impact

  • Users relying on strict fill-or-kill semantics may lose part of their stake unexpectedly.
  • Balances and staking state can become inconsistent from the user’s perspective.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions