Skip to content

Fix/delegate all#125

Merged
thewhaleking merged 4 commits intoopentensor:mainfrom
404-Repo:fix/delegate_all
Sep 27, 2024
Merged

Fix/delegate all#125
thewhaleking merged 4 commits intoopentensor:mainfrom
404-Repo:fix/delegate_all

Conversation

@the-mx
Copy link
Contributor

@the-mx the-mx commented Sep 26, 2024

Changes made:

  1. Fixed the issue when --all option is used for delegate-stake and undelegate-stake.
  2. Existential deposit is requested from the subtensor (previously: hardcoded 1`000 rao).
  3. Fixed the issue when updated staking value (existential deposit subtracted) is not used for the stake or unstake.
  4. Unit tests updated to catch the previous error.

Copy link
Contributor

@thewhaleking thewhaleking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good; let's just change the arg name to avoid name shadowing.

"""

async def _do_delegation() -> tuple[bool, str]:
async def _do_delegation(staking_balance: Balance) -> tuple[bool, str]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change this to staking_balance_ to avoid name shadowing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

@the-mx the-mx requested a review from thewhaleking September 26, 2024 15:13
thewhaleking
thewhaleking previously approved these changes Sep 26, 2024
@@ -569,14 +569,7 @@ async def get_stake_for_coldkey_and_hotkey(
# Stake it all.
staking_balance = Balance.from_tao(my_prev_coldkey_balance.tao)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey!

Since this also include undelegating, we should also make a distinction here when unstaking all:

    if amount is None:
        # Stake it all.
        if delegate_string == "delegate":
            staking_balance = Balance.from_tao(my_prev_coldkey_balance.tao)
        else:
            # Unstake all
            staking_balance = Balance.from_tao(my_prev_delegated_stake.tao)
    else:
        staking_balance = Balance.from_tao(amount)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Unit tests need to be updated as well to check for the wallet balance change. Unit tests stopped working locally for me (infinite wait for the local subtensor). Once I resolve the issue I will update the tests too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit tests updated.

However, I couldn't check the delegate balance when staking all. Float existential deposit, some bug or output value got truncated (rounded). Used wallet balance instead. Open for suggestions or could be just merged as is :)

@thewhaleking
Copy link
Contributor

This looks good. I just want to test out something with regard to the checking staked balance instead of coldkey balance before merging.

@thewhaleking thewhaleking merged commit e22d3fe into opentensor:main Sep 27, 2024
@ibraheem-abe ibraheem-abe mentioned this pull request Oct 2, 2024
@thewhaleking thewhaleking linked an issue Oct 2, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

root undelegate inconsistency

3 participants