@@ -2,7 +2,7 @@ use super::*;
22use crate :: HasMigrationRun ;
33use frame_support:: { traits:: Get , weights:: Weight } ;
44use scale_info:: prelude:: string:: String ;
5- use sp_io:: { storage:: clear_prefix, KillStorageResult } ;
5+ use sp_io:: { hashing :: twox_128 , storage:: clear_prefix, KillStorageResult } ;
66
77pub fn migrate_commit_reveal_2 < T : Config > ( ) -> Weight {
88 let migration_name = b"migrate_commit_reveal_2" . to_vec ( ) ;
@@ -25,14 +25,17 @@ pub fn migrate_commit_reveal_2<T: Config>() -> Weight {
2525 // Step 1: Remove WeightCommitRevealInterval entries
2626 // ------------------------------
2727
28- const WEIGHT_COMMIT_REVEAL_INTERVAL_PREFIX : & [ u8 ] =
29- b"pallet_subtensor::WeightCommitRevealInterval" ;
30- let removal_results = clear_prefix ( WEIGHT_COMMIT_REVEAL_INTERVAL_PREFIX , Some ( u32:: MAX ) ) ;
28+ let mut weight_commit_reveal_interval_prefix = Vec :: new ( ) ;
29+ weight_commit_reveal_interval_prefix. extend_from_slice ( & twox_128 ( "SubtensorModule" . as_bytes ( ) ) ) ;
30+ weight_commit_reveal_interval_prefix
31+ . extend_from_slice ( & twox_128 ( "WeightCommitRevealInterval" . as_bytes ( ) ) ) ;
32+
33+ let removal_results = clear_prefix ( & weight_commit_reveal_interval_prefix, Some ( u32:: MAX ) ) ;
3134
3235 let removed_entries_count = match removal_results {
3336 KillStorageResult :: AllRemoved ( removed) => removed as u64 ,
3437 KillStorageResult :: SomeRemaining ( removed) => {
35- log:: info!( "Failed To Remove Some Items During migrate_commit_reveal_v2" , ) ;
38+ log:: info!( "Failed To Remove Some Items During migrate_commit_reveal_v2" ) ;
3639 removed as u64
3740 }
3841 } ;
@@ -48,13 +51,16 @@ pub fn migrate_commit_reveal_2<T: Config>() -> Weight {
4851 // Step 2: Remove WeightCommits entries
4952 // ------------------------------
5053
51- const WEIGHT_COMMITS_PREFIX : & [ u8 ] = b"pallet_subtensor::WeightCommits" ;
52- let removal_results_commits = clear_prefix ( WEIGHT_COMMITS_PREFIX , Some ( u32:: MAX ) ) ;
54+ let mut weight_commits_prefix = Vec :: new ( ) ;
55+ weight_commits_prefix. extend_from_slice ( & twox_128 ( "SubtensorModule" . as_bytes ( ) ) ) ;
56+ weight_commits_prefix. extend_from_slice ( & twox_128 ( "WeightCommits" . as_bytes ( ) ) ) ;
57+
58+ let removal_results_commits = clear_prefix ( & weight_commits_prefix, Some ( u32:: MAX ) ) ;
5359
5460 let removed_commits_entries = match removal_results_commits {
5561 KillStorageResult :: AllRemoved ( removed) => removed as u64 ,
5662 KillStorageResult :: SomeRemaining ( removed) => {
57- log:: info!( "Failed To Remove Some Items During migrate_commit_reveal_v2" , ) ;
63+ log:: info!( "Failed To Remove Some Items During migrate_commit_reveal_v2" ) ;
5864 removed as u64
5965 }
6066 } ;
0 commit comments