-
Notifications
You must be signed in to change notification settings - Fork 318
Conviction updates #2687
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
Conviction updates #2687
Changes from all commits
d19b049
136f362
2b9de9c
bdc4f16
155f246
c5181b7
6b36fd9
091058c
af92d76
dec8c87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| use super::*; | ||
| use frame_support::weights::Weight; | ||
| use scale_info::prelude::string::String; | ||
|
|
||
| /// Clears conviction v2 lock state that only exists on testnet before this | ||
| /// conviction design is deployed more broadly. | ||
| /// | ||
| /// `devnet-ready` had `Lock`, `HotkeyLock`, `DecayingHotkeyLock`, `OwnerLock`, | ||
| /// and `DecayingLock`, but did not have `DecayingOwnerLock`. `OwnerLock` also | ||
| /// used the old owner-coldkey aggregate semantics. Clear these prefixes without | ||
| /// decoding values so old or incompatible aggregate bytes are removed safely. | ||
| pub fn migrate_reset_tnet_conviction_locks<T: Config>() -> Weight { | ||
| let migration_name = b"migrate_reset_tnet_conviction_locks".to_vec(); | ||
| let mut weight = T::DbWeight::get().reads(1); | ||
|
|
||
| if HasMigrationRun::<T>::get(&migration_name) { | ||
| log::info!( | ||
| "Migration '{:?}' has already run. Skipping.", | ||
| String::from_utf8_lossy(&migration_name) | ||
| ); | ||
| return weight; | ||
| } | ||
|
|
||
| log::info!( | ||
| "Running migration '{}'", | ||
| String::from_utf8_lossy(&migration_name) | ||
| ); | ||
|
|
||
| // This only affects testnet: mainnet has not had this conviction lock state | ||
| // deployed with live values yet. | ||
| let lock_removal = Lock::<T>::clear(u32::MAX, None); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [HIGH] Migration clears user-sized lock storage in one upgrade block This migration calls
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [HIGH] Migration clears user-sized lock storage in one upgrade block This migration calls
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [HIGH] Migration clears user-sized lock storage in one upgrade block This runtime-upgrade migration clears every entry in |
||
| weight = weight.saturating_add( | ||
| T::DbWeight::get().reads_writes(lock_removal.loops as u64, lock_removal.backend as u64), | ||
| ); | ||
|
|
||
| let hotkey_lock_removal = HotkeyLock::<T>::clear(u32::MAX, None); | ||
| weight = weight.saturating_add(T::DbWeight::get().reads_writes( | ||
| hotkey_lock_removal.loops as u64, | ||
| hotkey_lock_removal.backend as u64, | ||
| )); | ||
|
|
||
| let decaying_hotkey_lock_removal = DecayingHotkeyLock::<T>::clear(u32::MAX, None); | ||
| weight = weight.saturating_add(T::DbWeight::get().reads_writes( | ||
| decaying_hotkey_lock_removal.loops as u64, | ||
| decaying_hotkey_lock_removal.backend as u64, | ||
| )); | ||
|
|
||
| let owner_lock_removal = OwnerLock::<T>::clear(u32::MAX, None); | ||
| weight = weight.saturating_add(T::DbWeight::get().reads_writes( | ||
| owner_lock_removal.loops as u64, | ||
| owner_lock_removal.backend as u64, | ||
| )); | ||
|
|
||
| let decaying_owner_lock_removal = DecayingOwnerLock::<T>::clear(u32::MAX, None); | ||
| weight = weight.saturating_add(T::DbWeight::get().reads_writes( | ||
| decaying_owner_lock_removal.loops as u64, | ||
| decaying_owner_lock_removal.backend as u64, | ||
| )); | ||
|
|
||
| let decaying_lock_removal = DecayingLock::<T>::clear(u32::MAX, None); | ||
| weight = weight.saturating_add(T::DbWeight::get().reads_writes( | ||
| decaying_lock_removal.loops as u64, | ||
| decaying_lock_removal.backend as u64, | ||
| )); | ||
|
|
||
| HasMigrationRun::<T>::insert(&migration_name, true); | ||
| weight = weight.saturating_add(T::DbWeight::get().writes(1)); | ||
|
|
||
| log::info!( | ||
| "Migration '{:?}' completed successfully. Removed Lock: {:?}, HotkeyLock: {:?}, DecayingHotkeyLock: {:?}, OwnerLock: {:?}, DecayingOwnerLock: {:?}, DecayingLock: {:?}.", | ||
| String::from_utf8_lossy(&migration_name), | ||
| lock_removal.backend, | ||
| hotkey_lock_removal.backend, | ||
| decaying_hotkey_lock_removal.backend, | ||
| owner_lock_removal.backend, | ||
| decaying_owner_lock_removal.backend, | ||
| decaying_lock_removal.backend, | ||
| ); | ||
|
|
||
| weight | ||
| } | ||
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.
[HIGH] Migration clears user-sized lock storage in one upgrade block
Lock,HotkeyLock,DecayingHotkeyLock,OwnerLock,DecayingOwnerLock, andDecayingLockare cleared withu32::MAXin a singleon_runtime_upgrademigration. These maps can scale with user lock activity, and computing the weight afterclear()does not bound the work already performed. If testnet/devnet has more entries than expected, the upgrade can exceed block limits or stall. Make this bounded with finite clear limits plus a cursor/progress flag, or otherwise gate/prove the exact live state size before running it.