Conversation
| #[pallet::type_value] | ||
| /// Default value for block number | ||
| pub fn DefaultBlockNumber<T: Config>() -> BlockNumberFor<T> { | ||
| 0u32.into() |
There was a problem hiding this comment.
To avoid confusion, please change to u64 because block numbers are u64 in subtensor.
| let coldkey = ensure_signed(origin)?; | ||
|
|
||
| // Prevent DoS attacks | ||
| let set_lock = coldkey == destination_coldkey; |
There was a problem hiding this comment.
Noo, the transfer stake functionality main use case is to transfer from one coldkey to another :)
|
If we're going to lock stake up for a whole epoch, then it seems fair to remove the dynamic staking fee when unstaking. Currently on non root subnets the fee is equivalent to 1 epoch of staking rewards for the amount being unstaked. This should go back to the fixed 50k RAO as you can no longer manipulate an epoch of rewards by staking on the block before the step then leaving the block after. |
@bdmason , true, but with swap v3 the dynamic fees will go away and will be replaced with flat rate swap fee (because there will be users providing liquidity who receive these fees). |
What about a MEV bot running with two cold keys? |
|
I've been thinking about this a bit more... whilst I've been wanting stake locks for a long time, Bittensor has moved on and become a marketplace. Have we considered the effect stake locks could have on integrations with exchanges e.g. Binance? The functionality to stop sandwich attacks already exists in Also, on the topic of sandwich attacks, the recent update to mainnet Aren't we just complicating the network to fix a problem that was fixed a long time ago with limit prices? |
Description
This PR introduces stake locks.
This PR addresses the stake manipulation problem by introducing a stake lock after each stake deposit operation (like add_stake or add_stake_limit). The lock is the block number after which stake removal is allowed. It calculates as "current_block + subnet tempo".
This PR relates to both MEV and "stake delta" problems.
Affected extrinsics:
All extrinsics that add stake to the destination netuid lock tuple (hotkey, coldkey, netuid) for the tempo period of the subnet. All extrinsics that remove stake check the stake lock first and fail with the
StakeLockederror if the lock is active. The only exception istransfer_stakewhen the destination coldkey is different from the origin (to prevent putting locks on others).Related Issue(s)
Type of Change
Breaking Change
The code that removes the stake immediately will stop working.
Checklist
cargo fmtandcargo clippyto ensure my code is formatted and linted correctlyAdditional Notes
The additional weights fix commit will be likely required and added after the initial code review.