Feat/transfer stake destination hotkey #2299
Open
+153
−43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When using
transfer_stake, users previously couldn't specify a destination hotkey - the stake would transfer to a new coldkey but remain on the original hotkey. This was problematic because the new coldkey doesn't own that hotkey, so the stake wouldn't show up in btcli commands for the recipient.This PR adds a
destination_hotkeyparameter totransfer_stake, allowing users to transfer stake to both a different coldkey AND a different hotkey in a single operation. This makes the transfer actually useful - recipients can now receive stake on their own hotkey.What changed
The
transfer_stakeextrinsic now accepts:destination_coldkey- who receives the stakeorigin_hotkey- the hotkey to take stake fromdestination_hotkey- the hotkey to put stake on (NEW)origin_netuid/destination_netuid- subnet IDsalpha_amount- amount to transferPreviously, the single
hotkeyparameter was used for both origin and destination.Related Issue(s)
Type of Change
Breaking Change
This is a breaking change for existing callers of
transfer_stake:Before:
After:
Migration: Existing callers should pass the same hotkey for both
origin_hotkeyanddestination_hotkeyto maintain the previous behavior.Affected interfaces:
transferStake(bytes32,bytes32,bytes32,uint256,uint256,uint256)Checklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctlyScreenshots (if applicable)
Additional Notes
Files changed
pallets/subtensor/src/macros/dispatches.rsdestination_hotkeyparameter to dispatchpallets/subtensor/src/staking/move_stake.rsdo_transfer_staketo use both hotkeyspallets/subtensor/src/macros/events.rsStakeTransferredevent to include both hotkeysprecompiles/src/staking.rsprecompiles/src/solidity/stakingV2.solchain-extensions/src/lib.rscontract-tests/bittensor/lib.rspallets/transaction-fee/src/lib.rsdocs/wasm-contracts.mdWhy this matters
Before this change, if Alice transferred stake to Bob, the stake would end up on Alice's hotkey but owned by Bob's coldkey. Bob couldn't see or manage this stake easily because his btcli commands filter by his own hotkeys.
Now, Alice can transfer stake directly to Bob's hotkey, making the transfer actually useful for the recipient.
Contribution by Gittensor, learn more at https://gittensor.io/