-
Notifications
You must be signed in to change notification settings - Fork 208
Introduce stake lock after add_stake operation. #1666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devnet-ready
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest that we remove the key here if lock is expired.
@@ -1176,6 +1094,19 @@ pub mod pallet { | |||
pub type TokenSymbol<T: Config> = | |||
StorageMap<_, Identity, u16, Vec<u8>, ValueQuery, DefaultUnicodeVecU8<T>>; | |||
|
|||
#[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
Description
This PR addresses the stake manipulation problem. It introduces a stake lock after each stake deposit operation (like
add_stake
oradd_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 fmt
andcargo clippy
to ensure my code is formatted and linted correctly