File tree Expand file tree Collapse file tree 9 files changed +918
-140
lines changed Expand file tree Collapse file tree 9 files changed +918
-140
lines changed Original file line number Diff line number Diff line change @@ -262,5 +262,7 @@ mod errors {
262262 UidMapCouldNotBeCleared ,
263263 /// Trimming would exceed the max immune neurons percentage
264264 TrimmingWouldExceedMaxImmunePercentage ,
265+ /// Violating the rules of Childkey-Parentkey consistency
266+ ChildParentInconsistency ,
265267 }
266268}
Original file line number Diff line number Diff line change @@ -150,6 +150,8 @@ mod hooks {
150150 . saturating_add ( migrations:: migrate_subnet_locked:: migrate_restore_subnet_locked :: < T > ( ) )
151151 // Migrate subnet burn cost to 2500
152152 . saturating_add ( migrations:: migrate_network_lock_cost_2500:: migrate_network_lock_cost_2500 :: < T > ( ) )
153+ // Cleanup child/parent keys
154+ . saturating_add ( migrations:: migrate_fix_childkeys:: migrate_fix_childkeys :: < T > ( ) )
153155 // Migrate AutoStakeDestinationColdkeys
154156 . saturating_add ( migrations:: migrate_auto_stake_destination:: migrate_auto_stake_destination :: < T > ( ) ) ;
155157 weight
Original file line number Diff line number Diff line change 1+ use super :: * ;
2+ use alloc:: string:: String ;
3+
4+ pub fn migrate_fix_childkeys < T : Config > ( ) -> Weight {
5+ let migration_name = b"migrate_fix_childkeys" . to_vec ( ) ;
6+ let mut weight = T :: DbWeight :: get ( ) . reads ( 1 ) ;
7+
8+ if HasMigrationRun :: < T > :: get ( & migration_name) {
9+ log:: info!(
10+ "Migration '{:?}' has already run. Skipping." ,
11+ String :: from_utf8_lossy( & migration_name)
12+ ) ;
13+ return weight;
14+ }
15+
16+ log:: info!(
17+ "Running migration '{}'" ,
18+ String :: from_utf8_lossy( & migration_name)
19+ ) ;
20+
21+ ////////////////////////////////////////////////////////
22+ // Actual migration
23+
24+ Pallet :: < T > :: clean_zero_childkey_vectors ( & mut weight) ;
25+ Pallet :: < T > :: clean_zero_parentkey_vectors ( & mut weight) ;
26+ Pallet :: < T > :: clean_self_loops ( & mut weight) ;
27+ Pallet :: < T > :: repair_child_parent_consistency ( & mut weight) ;
28+
29+ ////////////////////////////////////////////////////////
30+
31+ HasMigrationRun :: < T > :: insert ( & migration_name, true ) ;
32+ weight = weight. saturating_add ( T :: DbWeight :: get ( ) . writes ( 1 ) ) ;
33+
34+ log:: info!(
35+ target: "runtime" ,
36+ "Migration '{}' completed successfully." ,
37+ String :: from_utf8_lossy( & migration_name)
38+ ) ;
39+ weight
40+ }
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ pub mod migrate_crv3_v2_to_timelocked;
1515pub mod migrate_delete_subnet_21;
1616pub mod migrate_delete_subnet_3;
1717pub mod migrate_disable_commit_reveal;
18+ pub mod migrate_fix_childkeys;
1819pub mod migrate_fix_is_network_member;
1920pub mod migrate_fix_root_subnet_tao;
2021pub mod migrate_fix_root_tao_and_alpha_in;
You can’t perform that action at this time.
0 commit comments