mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-22 19:49:22 +00:00
Don't allow immediate deallocations for active validators even if the key shares remain the same
There's an exploit where the prior set improperly mints coins, the new set occurs (resetting the oracle), and they immediately deallocate 49.9% of their coins (which is more than enough to achieve profitability). Now, anyone in set must wait until after the next set completes to perform any deallocation, enabling time to halt upon improper mints.
This commit is contained in:
parent
91905284bf
commit
8cc0adf281
1 changed files with 2 additions and 10 deletions
|
@ -611,16 +611,8 @@ pub mod pallet {
|
|||
}
|
||||
}
|
||||
|
||||
// If we're not in-set, or this doesn't decrease our key shares, allow immediate deallocation
|
||||
let active = Self::in_set(network, account);
|
||||
if (!active) || (!decreased_key_shares) {
|
||||
if active {
|
||||
// Since it's being immediately deallocated, decrease TotalAllocatedStake
|
||||
TotalAllocatedStake::<T>::set(
|
||||
network,
|
||||
Some(Amount(TotalAllocatedStake::<T>::get(network).unwrap_or(Amount(0)).0 - amount.0)),
|
||||
);
|
||||
}
|
||||
// If we're not in-set, allow immediate deallocation
|
||||
if !Self::in_set(network, account) {
|
||||
Self::deposit_event(Event::AllocationDecreased {
|
||||
validator: account,
|
||||
network,
|
||||
|
|
Loading…
Reference in a new issue