Introduce stake lock after add_stake operation.#1666
Introduce stake lock after add_stake operation.#1666shamil-gadelshin wants to merge 3 commits intodevnet-readyfrom
Conversation
|
@opentensor/cerebrum / @opentensor/gyrus / @opentensor/cortex breaking change detected! Please prepare accordingly! |
|
cc @ppolewicz |
| return Ok(()); | ||
| } | ||
|
|
||
| let stake_lock = StakeLocks::<T>::get(hotkey, netuid); |
There was a problem hiding this comment.
I suggest that we remove the key here if lock is expired.
|
|
||
| #[pallet::storage] | ||
| /// DMAP ( hot, netuid ) --> lock until block number | Returns the block number of the stake lock | ||
| pub type StakeLocks<T: Config> = StorageDoubleMap< |
There was a problem hiding this comment.
The stake locks should be by hotkey, coldkey, and netuid. Otherwise, we will be locking all nominators (all coldkeys) as soon as one coldkey stakes to this hotkey and nobody will be able to unstake until the next epoch.
Also, what happens if a coldkey has a 1000 TAO stake with expired lock and adds 1 TAO more? Should we keep them from unlocking only 1 TAO or the whole 1001 TAO amount?
There was a problem hiding this comment.
The stake locks should be by hotkey, coldkey, and netuid. Otherwise, we will be locking all nominators (all coldkeys) as soon as one coldkey stakes to this hotkey and nobody will be able to unstake until the next epoch.
Indeed, this is a mistake. FYI: this was the issue that alpha mentioned to const.
Also, what happens if a coldkey has a 1000 TAO stake with expired lock and adds 1 TAO more? Should we keep them from unlocking only 1 TAO or the whole 1001 TAO amount?
I thought about that - IMO introducing complex lock math leads to a lot of confusion: add 100 TAO, add 10 TAO - remove 90 TAO. Can I remove my 20 remaining TAO? We need to introduce a special interface for locked TAO schedule etc. The current approach could be investigated using a simple RPC call for the current lock by (coldkey, hotkey, subnet) tuple.
|
Update version is here: #1731 |
Description
This PR addresses the stake manipulation problem. It introduces a stake lock after each stake deposit operation (like
add_stakeoradd_stake_limit). The lock is the block number after which stake removal is allowed. It calculates as "current_block + subnet tempo".It relates to both MEV and "stake delta" problems.
The PR removes the commented code related to #1641 in the first commit.
Related Issue(s)
Type of Change
Breaking Change
Code that removes the stake immediately will stop working.
Checklist
cargo fmtandcargo clippyto ensure my code is formatted and linted correctly