Feat/transfer stake destination hotkey#2299
Feat/transfer stake destination hotkey#2299MkDev11 wants to merge 2 commits intoopentensor:devnet-readyfrom
Conversation
Closes opentensor#1377 This PR allows users to specify a destination hotkey when transferring stake to a different coldkey. Previously, transfer_stake only allowed changing the coldkey while keeping the same hotkey, which caused issues because the new coldkey wouldn't own the original hotkey. Changes: - Add destination_hotkey parameter to transfer_stake dispatch (call_index 86) - Update do_transfer_stake to use separate origin_hotkey and destination_hotkey - Update StakeTransferred event to include both hotkeys - Update precompiles (transferStake now takes 6 params instead of 5) - Update chain-extensions for new signature - Update contract interface (ink! contracts) - Update solidity interface - Add test for transferring to different hotkey - Update all existing tests to use new parameter - Update documentation This is a breaking change for existing callers of transfer_stake.
|
@sam0x17 Please check the PR and let me know the result. Thanks. |
|
We should avoid updating EVM interfaces because they are breaking |
@sam0x17 What do you think of that? |
- Keep transferStake with 5 params (same hotkey) for backward compatibility - Add transferStakeV2 with 6 params (different origin/destination hotkeys) - Update chain-extensions with TransferStakeV1 (5 params) and TransferStakeV2 (6 params) - Update contract-tests and docs accordingly
|
I would defer to vune on this one, unless there is a way you can make this non-breaking |
Just updated again. This has been made non-breaking. The original |
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.