-
Notifications
You must be signed in to change notification settings - Fork 319
Everyone's convinction to subnet owners is immediate #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
Open
gztensor
wants to merge
4
commits into
devnet-ready
Choose a base branch
from
feat/conviction-v2
base: devnet-ready
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d19b049
Anyone is able to lock stake to subnet owners hotkey and receives imm…
gztensor 136f362
Merge branch 'devnet-ready' into feat/conviction-v2
gztensor 2b9de9c
Add migration to clean the existing testnet conviction state
gztensor bdc4f16
chore: auditor auto-fix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
pallets/subtensor/src/migrations/migrate_reset_testnet_conviction_locks.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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_testnet_conviction_locks<T: Config>() -> Weight { | ||
| let migration_name = b"migrate_reset_testnet_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); | ||
| 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 | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.