-
Notifications
You must be signed in to change notification settings - Fork 244
kappa root only #2139
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
Merged
Merged
kappa root only #2139
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dd3688e
make kappa root only
JohnReedV 81667e1
fix tests
JohnReedV fcdc3ab
auto-update benchmark weights
github-actions[bot] e6e7b8a
Merge branch 'devnet-ready' into kappa-sudo-only
JohnReedV fe70e19
Merge branch 'devnet-ready' into kappa-sudo-only
JohnReedV 17d0d48
migrate kappa to default
JohnReedV feb736e
fix test
JohnReedV 6ca4b24
clippy
JohnReedV 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
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
54 changes: 54 additions & 0 deletions
54
pallets/subtensor/src/migrations/migrate_kappa_map_to_default.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,54 @@ | ||
use super::*; | ||
use frame_support::{traits::Get, weights::Weight}; | ||
use log; | ||
use scale_info::prelude::string::String; | ||
|
||
pub fn migrate_kappa_map_to_default<T: Config>() -> Weight { | ||
let mig_name: Vec<u8> = b"kappa_map_to_default".to_vec(); | ||
let mig_name_str = String::from_utf8_lossy(&mig_name); | ||
|
||
// 1 read for the HasMigrationRun flag | ||
let mut total_weight = T::DbWeight::get().reads(1); | ||
|
||
// Run once guard | ||
if HasMigrationRun::<T>::get(&mig_name) { | ||
log::info!("Migration '{mig_name_str}' already executed - skipping"); | ||
return total_weight; | ||
} | ||
|
||
log::info!("Running migration '{mig_name_str}'"); | ||
|
||
let target: u16 = DefaultKappa::<T>::get(); | ||
|
||
let mut reads: u64 = 0; | ||
let mut writes: u64 = 0; | ||
let mut visited: u64 = 0; | ||
let mut updated: u64 = 0; | ||
let mut unchanged: u64 = 0; | ||
|
||
for (netuid, current) in Kappa::<T>::iter() { | ||
visited = visited.saturating_add(1); | ||
reads = reads.saturating_add(1); | ||
|
||
if current != target { | ||
Kappa::<T>::insert(netuid, target); | ||
writes = writes.saturating_add(1); | ||
updated = updated.saturating_add(1); | ||
} else { | ||
unchanged = unchanged.saturating_add(1); | ||
} | ||
} | ||
|
||
total_weight = total_weight.saturating_add(T::DbWeight::get().reads_writes(reads, writes)); | ||
|
||
log::info!( | ||
"Kappa migration summary: visited={visited}, updated={updated}, unchanged={unchanged}, target_default={target}" | ||
); | ||
|
||
HasMigrationRun::<T>::insert(&mig_name, true); | ||
total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); | ||
|
||
log::info!("Migration '{mig_name_str}' completed"); | ||
|
||
total_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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Are we allowed to execute this in the last 10 blocks of a tempo @ppolewicz ? If no, there is the
ensure_root_with_rate_limit
, name is strange but it only allows in the freeze window, there is no rate limit