1
// Copyright (C) Moondance Labs Ltd.
2
// This file is part of Tanssi.
3

            
4
// Tanssi is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8

            
9
// Tanssi is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13

            
14
// You should have received a copy of the GNU General Public License
15
// along with Tanssi.  If not, see <http://www.gnu.org/licenses/>
16
// Copyright (C) Moondance Labs Ltd.
17
// This file is part of Tanssi.
18

            
19
// Tanssi is free software: you can redistribute it and/or modify
20
// it under the terms of the GNU General Public License as published by
21
// the Free Software Foundation, either version 3 of the License, or
22
// (at your option) any later version.
23

            
24
// Tanssi is distributed in the hope that it will be useful,
25
// but WITHOUT ANY WARRANTY; without even the implied warranty of
26
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
// GNU General Public License for more details.
28

            
29
// You should have received a copy of the GNU General Public License
30
// along with Tanssi.  If not, see <http://www.gnu.org/licenses/>
31

            
32
//! # Migrations
33
//!
34
//! This module acts as a registry where each migration is defined. Each migration should implement
35
//! the "Migration" trait declared in the pallet-migrations crate.
36

            
37
use {
38
    cumulus_primitives_core::ParaId,
39
    frame_support::{
40
        migration::{clear_storage_prefix, move_pallet, storage_key_iter},
41
        pallet_prelude::GetStorageVersion,
42
        traits::{
43
            fungible::MutateHold, OnRuntimeUpgrade, PalletInfoAccess, ReservableCurrency,
44
            StorageVersion,
45
        },
46
        weights::Weight,
47
        Blake2_128Concat, BoundedVec, StoragePrefixedMap,
48
    },
49
    pallet_configuration::{weights::WeightInfo as _, HostConfiguration},
50
    pallet_foreign_asset_creator::{AssetId, AssetIdToForeignAsset, ForeignAssetToAssetId},
51
    pallet_migrations::{GetMigrations, Migration},
52
    pallet_registrar::HoldReason,
53
    sp_core::Get,
54
    sp_runtime::Perbill,
55
    sp_std::{collections::btree_set::BTreeSet, marker::PhantomData, prelude::*},
56
};
57
#[cfg(feature = "try-runtime")]
58
use {frame_support::ensure, parity_scale_codec::DecodeAll};
59

            
60
#[derive(
61
    Default,
62
    Clone,
63
    parity_scale_codec::Encode,
64
    parity_scale_codec::Decode,
65
    PartialEq,
66
    sp_core::RuntimeDebug,
67
    scale_info::TypeInfo,
68
)]
69
pub struct HostConfigurationV3 {
70
    pub max_collators: u32,
71
    pub min_orchestrator_collators: u32,
72
    pub max_orchestrator_collators: u32,
73
    pub collators_per_container: u32,
74
    pub full_rotation_period: u32,
75
    pub collators_per_parathread: u32,
76
    pub parathreads_per_collator: u32,
77
    pub target_container_chain_fullness: Perbill,
78
    pub max_parachain_cores_percentage: Option<Perbill>,
79
}
80

            
81
pub struct MigrateConfigurationAddFullRotationMode<T>(pub PhantomData<T>);
82
impl<T> Migration for MigrateConfigurationAddFullRotationMode<T>
83
where
84
    T: pallet_configuration::Config,
85
{
86
3
    fn friendly_name(&self) -> &str {
87
3
        "TM_MigrateConfigurationAddFullRotationMode"
88
3
    }
89

            
90
2
    fn migrate(&self, _available_weight: Weight) -> Weight {
91
2
        let default_config = HostConfiguration::default();
92
2

            
93
2
        // Modify active config
94
2
        let old_config: HostConfigurationV3 = frame_support::storage::unhashed::get(
95
2
            &pallet_configuration::ActiveConfig::<T>::hashed_key(),
96
2
        )
97
2
        .expect("configuration.activeConfig should have value");
98
2
        let new_config = HostConfiguration {
99
2
            max_collators: old_config.max_collators,
100
2
            min_orchestrator_collators: old_config.min_orchestrator_collators,
101
2
            max_orchestrator_collators: old_config.max_orchestrator_collators,
102
2
            collators_per_container: old_config.collators_per_container,
103
2
            full_rotation_period: old_config.full_rotation_period,
104
2
            collators_per_parathread: old_config.collators_per_parathread,
105
2
            parathreads_per_collator: old_config.parathreads_per_collator,
106
2
            target_container_chain_fullness: old_config.target_container_chain_fullness,
107
2
            max_parachain_cores_percentage: old_config.max_parachain_cores_percentage,
108
2
            full_rotation_mode: default_config.full_rotation_mode.clone(),
109
2
        };
110
2
        frame_support::storage::unhashed::put(
111
2
            &pallet_configuration::ActiveConfig::<T>::hashed_key(),
112
2
            &new_config,
113
2
        );
114
2

            
115
2
        // Modify pending configs, if any
116
2
        let old_pending_configs: Vec<(u32, HostConfigurationV3)> =
117
2
            frame_support::storage::unhashed::get(
118
2
                &pallet_configuration::PendingConfigs::<T>::hashed_key(),
119
2
            )
120
2
            .unwrap_or_default();
121
2
        let mut new_pending_configs: Vec<(u32, HostConfiguration)> = vec![];
122

            
123
6
        for (session_index, old_config) in old_pending_configs {
124
4
            let new_config = HostConfiguration {
125
4
                max_collators: old_config.max_collators,
126
4
                min_orchestrator_collators: old_config.min_orchestrator_collators,
127
4
                max_orchestrator_collators: old_config.max_orchestrator_collators,
128
4
                collators_per_container: old_config.collators_per_container,
129
4
                full_rotation_period: old_config.full_rotation_period,
130
4
                collators_per_parathread: old_config.collators_per_parathread,
131
4
                parathreads_per_collator: old_config.parathreads_per_collator,
132
4
                target_container_chain_fullness: old_config.target_container_chain_fullness,
133
4
                max_parachain_cores_percentage: old_config.max_parachain_cores_percentage,
134
4
                full_rotation_mode: default_config.full_rotation_mode.clone(),
135
4
            };
136
4
            new_pending_configs.push((session_index, new_config));
137
4
        }
138

            
139
2
        if !new_pending_configs.is_empty() {
140
2
            frame_support::storage::unhashed::put(
141
2
                &pallet_configuration::PendingConfigs::<T>::hashed_key(),
142
2
                &new_pending_configs,
143
2
            );
144
2
        }
145

            
146
2
        <T as pallet_configuration::Config>::WeightInfo::set_config_with_u32()
147
2
    }
148

            
149
    /// Run a standard pre-runtime test. This works the same way as in a normal runtime upgrade.
150
    #[cfg(feature = "try-runtime")]
151
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
152
        log::info!(
153
            "hashed key {:?}",
154
            pallet_configuration::ActiveConfig::<T>::hashed_key()
155
        );
156
        let old_config_bytes = frame_support::storage::unhashed::get_raw(
157
            &pallet_configuration::ActiveConfig::<T>::hashed_key(),
158
        )
159
        .unwrap();
160
        let old_config: Result<HostConfigurationV3, _> =
161
            DecodeAll::decode_all(&mut old_config_bytes.as_ref());
162
        let new_config: Result<HostConfiguration, _> =
163
            DecodeAll::decode_all(&mut old_config_bytes.as_ref());
164

            
165
        assert!(old_config.is_ok());
166
        assert!(new_config.is_err());
167

            
168
        Ok(vec![])
169
    }
170

            
171
    /// Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
172
    #[cfg(feature = "try-runtime")]
173
    fn post_upgrade(
174
        &self,
175
        _number_of_invulnerables: Vec<u8>,
176
    ) -> Result<(), sp_runtime::DispatchError> {
177
        let new_config_bytes = frame_support::storage::unhashed::get_raw(
178
            &pallet_configuration::ActiveConfig::<T>::hashed_key(),
179
        )
180
        .unwrap();
181
        let old_config: Result<HostConfigurationV3, _> =
182
            DecodeAll::decode_all(&mut new_config_bytes.as_ref());
183
        let new_config: Result<HostConfiguration, _> =
184
            DecodeAll::decode_all(&mut new_config_bytes.as_ref());
185

            
186
        assert!(old_config.is_err());
187
        assert!(new_config.is_ok());
188

            
189
        let new_config = pallet_configuration::Pallet::<T>::config();
190
        let default_config = HostConfiguration::default();
191
        assert_eq!(
192
            new_config.full_rotation_mode,
193
            default_config.full_rotation_mode
194
        );
195
        Ok(())
196
    }
197
}
198

            
199
pub struct MigrateServicesPaymentAddCollatorAssignmentCredits<T>(pub PhantomData<T>);
200
impl<T> Migration for MigrateServicesPaymentAddCollatorAssignmentCredits<T>
201
where
202
    T: pallet_services_payment::Config + pallet_registrar::Config,
203
{
204
    fn friendly_name(&self) -> &str {
205
        "TM_MigrateServicesPaymentAddCollatorAssignmentCredits"
206
    }
207

            
208
2
    fn migrate(&self, _available_weight: Weight) -> Weight {
209
2
        // For each parachain in pallet_registrar (active, pending or pending_verification),
210
2
        // insert `MaxCreditsStored` to pallet_services_payment,
211
2
        // and mark that parachain as "given_free_credits".
212
2
        let mut para_ids = BTreeSet::new();
213
2
        let active = pallet_registrar::RegisteredParaIds::<T>::get();
214
2
        let pending = pallet_registrar::PendingParaIds::<T>::get();
215
2

            
216
2
        let paused = pallet_registrar::Paused::<T>::get();
217
2
        para_ids.extend(active);
218
2
        para_ids.extend(pending.into_iter().flat_map(|(_session, active)| active));
219
2
        para_ids.extend(paused);
220
2

            
221
2
        let reads = 3 + 2 * para_ids.len() as u64;
222
2
        let writes = 2 * para_ids.len() as u64;
223

            
224
6
        for para_id in para_ids {
225
4
            // 2 reads 2 writes
226
4
            pallet_services_payment::Pallet::<T>::set_free_collator_assignment_credits(
227
4
                &para_id,
228
4
                T::FreeCollatorAssignmentCredits::get(),
229
4
            );
230
4
        }
231

            
232
2
        let db_weights = T::DbWeight::get();
233
2
        db_weights.reads_writes(reads, writes)
234
2
    }
235
    /// Run a standard pre-runtime test. This works the same way as in a normal runtime upgrade.
236
    #[cfg(feature = "try-runtime")]
237
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
238
        let mut para_ids = BTreeSet::new();
239
        let active = pallet_registrar::RegisteredParaIds::<T>::get();
240
        let pending = pallet_registrar::PendingParaIds::<T>::get();
241
        let paused = pallet_registrar::Paused::<T>::get();
242
        para_ids.extend(active);
243
        para_ids.extend(pending.into_iter().flat_map(|(_session, active)| active));
244
        para_ids.extend(paused);
245

            
246
        for para_id in para_ids {
247
            assert!(
248
                pallet_services_payment::CollatorAssignmentCredits::<T>::get(para_id).is_none()
249
            );
250
        }
251

            
252
        Ok(vec![])
253
    }
254

            
255
    // Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
256
    #[cfg(feature = "try-runtime")]
257
    fn post_upgrade(&self, _result: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
258
        let mut para_ids = BTreeSet::new();
259
        let active = pallet_registrar::RegisteredParaIds::<T>::get();
260
        let pending = pallet_registrar::PendingParaIds::<T>::get();
261
        let paused = pallet_registrar::Paused::<T>::get();
262
        para_ids.extend(active);
263
        para_ids.extend(pending.into_iter().flat_map(|(_session, active)| active));
264
        para_ids.extend(paused);
265

            
266
        for para_id in para_ids {
267
            assert_eq!(
268
                pallet_services_payment::CollatorAssignmentCredits::<T>::get(para_id),
269
                Some(T::FreeCollatorAssignmentCredits::get())
270
            );
271
        }
272

            
273
        Ok(())
274
    }
275
}
276

            
277
pub struct PolkadotXcmMigrationFixVersion<T, PolkadotXcm>(pub PhantomData<(T, PolkadotXcm)>);
278
impl<T, PolkadotXcm> Migration for PolkadotXcmMigrationFixVersion<T, PolkadotXcm>
279
where
280
    PolkadotXcm: GetStorageVersion + PalletInfoAccess,
281
    T: cumulus_pallet_xcmp_queue::Config,
282
{
283
472
    fn friendly_name(&self) -> &str {
284
472
        "MM_PolkadotXcmMigrationFixVersion"
285
472
    }
286

            
287
    fn migrate(&self, _available_weight: Weight) -> Weight {
288
        if <PolkadotXcm as GetStorageVersion>::on_chain_storage_version() == 0 {
289
            StorageVersion::new(1).put::<PolkadotXcm>();
290
            return T::DbWeight::get().writes(1);
291
        }
292
        Weight::default()
293
    }
294

            
295
    #[cfg(feature = "try-runtime")]
296
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
297
        ensure!(
298
            <PolkadotXcm as GetStorageVersion>::on_chain_storage_version() == 0,
299
            "PolkadotXcm storage version should be 0"
300
        );
301
        Ok(vec![])
302
    }
303

            
304
    // Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
305
    #[cfg(feature = "try-runtime")]
306
    fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
307
        ensure!(
308
            <PolkadotXcm as GetStorageVersion>::on_chain_storage_version() == 1,
309
            "PolkadotXcm storage version should be 1"
310
        );
311
        Ok(())
312
    }
313
}
314

            
315
pub struct XcmpQueueMigrationFixVersion<T, XcmpQueue>(pub PhantomData<(T, XcmpQueue)>);
316
impl<T, XcmpQueue> Migration for XcmpQueueMigrationFixVersion<T, XcmpQueue>
317
where
318
    XcmpQueue: GetStorageVersion + PalletInfoAccess,
319
    T: cumulus_pallet_xcmp_queue::Config,
320
{
321
472
    fn friendly_name(&self) -> &str {
322
472
        "MM_XcmpQueueMigrationFixVersion"
323
472
    }
324

            
325
    fn migrate(&self, _available_weight: Weight) -> Weight {
326
        if <XcmpQueue as GetStorageVersion>::on_chain_storage_version() == 0 {
327
            StorageVersion::new(2).put::<XcmpQueue>();
328
            return T::DbWeight::get().writes(1);
329
        }
330
        Weight::default()
331
    }
332

            
333
    #[cfg(feature = "try-runtime")]
334
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
335
        ensure!(
336
            <XcmpQueue as GetStorageVersion>::on_chain_storage_version() == 0,
337
            "XcmpQueue storage version should be 0"
338
        );
339
        Ok(vec![])
340
    }
341

            
342
    // Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
343
    #[cfg(feature = "try-runtime")]
344
    fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
345
        // Greater than because the post_upgrade is run after all the migrations, so
346
        // it can be greater if the following XcmpQueue migrations are applied in the
347
        // same runtime
348
        ensure!(
349
            <XcmpQueue as GetStorageVersion>::on_chain_storage_version() >= 2,
350
            "XcmpQueue storage version should be at least 2"
351
        );
352
        Ok(())
353
    }
354
}
355

            
356
pub struct XcmpQueueMigrationV3<T>(pub PhantomData<T>);
357
impl<T> Migration for XcmpQueueMigrationV3<T>
358
where
359
    T: cumulus_pallet_xcmp_queue::Config,
360
{
361
472
    fn friendly_name(&self) -> &str {
362
472
        "MM_XcmpQueueMigrationV3"
363
472
    }
364

            
365
    fn migrate(&self, _available_weight: Weight) -> Weight {
366
        cumulus_pallet_xcmp_queue::migration::v3::MigrationToV3::<T>::on_runtime_upgrade()
367
    }
368

            
369
    // #[cfg(feature = "try-runtime")]
370
    // let mut pre_upgrade_result: Vec<u8>;
371

            
372
    #[cfg(feature = "try-runtime")]
373
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
374
        cumulus_pallet_xcmp_queue::migration::v3::MigrationToV3::<T>::pre_upgrade()
375
    }
376

            
377
    // Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
378
    #[cfg(feature = "try-runtime")]
379
    fn post_upgrade(&self, state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
380
        cumulus_pallet_xcmp_queue::migration::v3::MigrationToV3::<T>::post_upgrade(state)
381
    }
382
}
383

            
384
pub struct XcmpQueueMigrationV4<T>(pub PhantomData<T>);
385
impl<T> Migration for XcmpQueueMigrationV4<T>
386
where
387
    T: cumulus_pallet_xcmp_queue::Config,
388
{
389
472
    fn friendly_name(&self) -> &str {
390
472
        "MM_XcmpQueueMigrationV4"
391
472
    }
392

            
393
    fn migrate(&self, _available_weight: Weight) -> Weight {
394
        cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4::<T>::on_runtime_upgrade()
395
    }
396

            
397
    #[cfg(feature = "try-runtime")]
398
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
399
        cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4::<T>::pre_upgrade()
400
    }
401

            
402
    // Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
403
    #[cfg(feature = "try-runtime")]
404
    fn post_upgrade(&self, state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
405
        cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4::<T>::post_upgrade(state)
406
    }
407
}
408

            
409
pub struct RegistrarPendingVerificationValueToMap<T>(pub PhantomData<T>);
410
impl<T> Migration for RegistrarPendingVerificationValueToMap<T>
411
where
412
    T: pallet_registrar::Config,
413
{
414
    fn friendly_name(&self) -> &str {
415
        "TM_RegistrarPendingVerificationValueToMap"
416
    }
417

            
418
1
    fn migrate(&self, _available_weight: Weight) -> Weight {
419
1
        let para_ids: Vec<ParaId> = frame_support::storage::unhashed::take(
420
1
            &frame_support::storage::storage_prefix(b"Registrar", b"PendingVerification"),
421
1
        )
422
1
        .unwrap_or_default();
423
1

            
424
1
        let total_weight = T::DbWeight::get()
425
1
            .reads(1)
426
1
            .saturating_add(T::DbWeight::get().writes(1));
427

            
428
5
        for para_id in para_ids {
429
4
            total_weight.saturating_add(T::DbWeight::get().writes(1));
430
4
            pallet_registrar::PendingVerification::<T>::insert(para_id, ());
431
4
        }
432

            
433
1
        total_weight
434
1
    }
435

            
436
    #[cfg(feature = "try-runtime")]
437
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
438
        Ok(vec![])
439
    }
440

            
441
    // Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
442
    #[cfg(feature = "try-runtime")]
443
    fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
444
        Ok(())
445
    }
446
}
447

            
448
pub struct RegistrarParaManagerMigration<T>(pub PhantomData<T>);
449
impl<T> Migration for RegistrarParaManagerMigration<T>
450
where
451
    T: pallet_registrar::Config,
452
{
453
    fn friendly_name(&self) -> &str {
454
        "TM_RegistrarParaManagerMigration"
455
    }
456

            
457
    fn migrate(&self, _available_weight: Weight) -> Weight {
458
        let mut total_weight = Weight::default();
459
        for (para_id, deposit) in pallet_registrar::RegistrarDeposit::<T>::iter() {
460
            pallet_registrar::ParaManager::<T>::insert(para_id, deposit.creator);
461
            total_weight = total_weight.saturating_add(
462
                T::DbWeight::get()
463
                    .reads(1)
464
                    .saturating_add(T::DbWeight::get().writes(1)),
465
            );
466
        }
467

            
468
        total_weight
469
    }
470

            
471
    #[cfg(feature = "try-runtime")]
472
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
473
        Ok(vec![])
474
    }
475

            
476
    #[cfg(feature = "try-runtime")]
477
    fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
478
        Ok(())
479
    }
480
}
481

            
482
pub struct RegistrarReserveToHoldMigration<T>(pub PhantomData<T>);
483
impl<T> Migration for RegistrarReserveToHoldMigration<T>
484
where
485
    T: pallet_registrar::Config,
486
    T: pallet_balances::Config,
487
    <T as pallet_balances::Config>::RuntimeHoldReason: From<pallet_registrar::HoldReason>,
488
    <T as pallet_balances::Config>::Balance: From<
489
        <<T as pallet_registrar::Config>::Currency as frame_support::traits::fungible::Inspect<
490
            T::AccountId,
491
        >>::Balance,
492
    >,
493
    <T as pallet_balances::Config>::Balance: From<u128>,
494
{
495
    fn friendly_name(&self) -> &str {
496
        "TM_RegistrarReserveToHoldMigration"
497
    }
498

            
499
2
    fn migrate(&self, _available_weight: Weight) -> Weight {
500
2
        let mut total_weight = Weight::default();
501
4
        for (_para_id, deposit) in pallet_registrar::RegistrarDeposit::<T>::iter() {
502
2
            pallet_balances::Pallet::<T>::unreserve(&deposit.creator, deposit.deposit.into());
503
2
            let _ = pallet_balances::Pallet::<T>::hold(
504
2
                &HoldReason::RegistrarDeposit.into(),
505
2
                &deposit.creator,
506
2
                deposit.deposit.into(),
507
2
            );
508
2
            total_weight = total_weight.saturating_add(T::DbWeight::get().reads_writes(2, 2));
509
2
        }
510

            
511
2
        total_weight
512
2
    }
513

            
514
    #[cfg(feature = "try-runtime")]
515
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
516
        use frame_support::traits::fungible::InspectHold;
517

            
518
        for (_para_id, deposit) in pallet_registrar::RegistrarDeposit::<T>::iter() {
519
            ensure!(
520
                pallet_balances::Pallet::<T>::reserved_balance(&deposit.creator)
521
                    >= deposit.deposit.into(),
522
                "Reserved balanced cannot be less than deposit amount"
523
            );
524

            
525
            ensure!(
526
                pallet_balances::Pallet::<T>::balance_on_hold(
527
                    &HoldReason::RegistrarDeposit.into(),
528
                    &deposit.creator
529
                ) == 0u128.into(),
530
                "Balance on hold for RegistrarDeposit should be 0"
531
            );
532
        }
533
        Ok(vec![])
534
    }
535

            
536
    #[cfg(feature = "try-runtime")]
537
    fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
538
        use frame_support::traits::fungible::InspectHold;
539

            
540
        for (_para_id, deposit) in pallet_registrar::RegistrarDeposit::<T>::iter() {
541
            ensure!(
542
                pallet_balances::Pallet::<T>::balance_on_hold(
543
                    &HoldReason::RegistrarDeposit.into(),
544
                    &deposit.creator
545
                ) >= deposit.deposit.into(),
546
                "Balance on hold for RegistrarDeposit should be deposit"
547
            );
548
        }
549

            
550
        Ok(())
551
    }
552
}
553
pub struct MigrateToLatestXcmVersion<Runtime>(PhantomData<Runtime>);
554
impl<Runtime> Migration for MigrateToLatestXcmVersion<Runtime>
555
where
556
    pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>:
557
        frame_support::traits::OnRuntimeUpgrade,
558
{
559
    fn friendly_name(&self) -> &str {
560
        "MM_MigrateToLatestXcmVersion"
561
    }
562

            
563
    fn migrate(&self, _available_weight: Weight) -> Weight {
564
        pallet_xcm::migration::MigrateToLatestXcmVersion::<Runtime>::on_runtime_upgrade()
565
    }
566

            
567
    #[cfg(feature = "try-runtime")]
568
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
569
        pallet_xcm::migration::MigrateToLatestXcmVersion::<Runtime>::pre_upgrade()
570
    }
571

            
572
    #[cfg(feature = "try-runtime")]
573
    fn post_upgrade(&self, state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
574
        pallet_xcm::migration::MigrateToLatestXcmVersion::<Runtime>::post_upgrade(state)
575
    }
576
}
577

            
578
pub struct DataPreserversAssignmentsMigration<T>(pub PhantomData<T>);
579
impl<T> Migration for DataPreserversAssignmentsMigration<T>
580
where
581
    T: pallet_data_preservers::Config + pallet_registrar::Config,
582
    T::AccountId: From<[u8; 32]>,
583
{
584
    fn friendly_name(&self) -> &str {
585
        "TM_DataPreserversAssignmentsMigration"
586
    }
587

            
588
2
    fn migrate(&self, _available_weight: Weight) -> Weight {
589
        use {
590
            frame_support::BoundedBTreeSet,
591
            frame_system::RawOrigin,
592
            pallet_data_preservers::{AssignmentPayment, ParaIdsFilter, Profile, ProfileMode},
593
        };
594

            
595
2
        let mut total_weight = Weight::default();
596
2

            
597
2
        let (request, _extra, witness) = T::AssignmentPayment::free_variant_values()
598
2
            .expect("free variant values are necessary to perform migration");
599
2

            
600
2
        let dummy_profile_owner = T::AccountId::from([0u8; 32]);
601
2

            
602
2
        let pallet_prefix: &[u8] = b"DataPreservers";
603
2
        let storage_item_prefix: &[u8] = b"BootNodes";
604
2
        let bootnodes_storage: Vec<_> = storage_key_iter::<
605
2
            ParaId,
606
2
            BoundedVec<BoundedVec<u8, T::MaxNodeUrlLen>, T::MaxAssignmentsPerParaId>,
607
2
            Blake2_128Concat,
608
2
        >(pallet_prefix, storage_item_prefix)
609
2
        .collect();
610
2

            
611
2
        total_weight = total_weight.saturating_add(
612
2
            T::DbWeight::get()
613
2
                .reads(bootnodes_storage.len() as u64)
614
2
                .saturating_add(T::DbWeight::get().writes(bootnodes_storage.len() as u64)),
615
2
        );
616

            
617
6
        for (para_id, bootnodes) in bootnodes_storage {
618
12
            for bootnode_url in bootnodes {
619
8
                let profile = Profile {
620
8
                    url: bootnode_url,
621
8
                    para_ids: ParaIdsFilter::Whitelist({
622
8
                        let mut set = BoundedBTreeSet::new();
623
8
                        set.try_insert(para_id).expect("to be in bound");
624
8
                        set
625
8
                    }),
626
8
                    mode: ProfileMode::Bootnode,
627
8
                    assignment_request: request.clone(),
628
8
                };
629
8

            
630
8
                let profile_id = pallet_data_preservers::NextProfileId::<T>::get();
631

            
632
8
                if let Some(weight) = pallet_data_preservers::Pallet::<T>::force_create_profile(
633
8
                    RawOrigin::Root.into(),
634
8
                    profile,
635
8
                    dummy_profile_owner.clone(),
636
8
                )
637
8
                .expect("to create profile")
638
8
                .actual_weight
639
                {
640
                    total_weight = total_weight.saturating_add(weight);
641
8
                }
642

            
643
8
                if let Some(weight) = pallet_data_preservers::Pallet::<T>::force_start_assignment(
644
8
                    RawOrigin::Root.into(),
645
8
                    profile_id,
646
8
                    para_id,
647
8
                    witness.clone(),
648
8
                )
649
8
                .expect("to start assignment")
650
8
                .actual_weight
651
                {
652
                    total_weight = total_weight.saturating_add(weight);
653
8
                }
654
            }
655
        }
656

            
657
2
        let _ = clear_storage_prefix(pallet_prefix, storage_item_prefix, &[], None, None);
658
2

            
659
2
        total_weight
660
2
    }
661

            
662
    #[cfg(feature = "try-runtime")]
663
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
664
        use parity_scale_codec::Encode;
665

            
666
        let pallet_prefix: &[u8] = b"DataPreservers";
667
        let storage_item_prefix: &[u8] = b"BootNodes";
668
        let state: Vec<_> = storage_key_iter::<
669
            ParaId,
670
            BoundedVec<BoundedVec<u8, T::MaxNodeUrlLen>, T::MaxAssignmentsPerParaId>,
671
            Blake2_128Concat,
672
        >(pallet_prefix, storage_item_prefix)
673
        .collect();
674

            
675
        Ok(state.encode())
676
    }
677

            
678
    #[cfg(feature = "try-runtime")]
679
    fn post_upgrade(&self, state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
680
        use parity_scale_codec::Decode;
681

            
682
        let pallet_prefix: &[u8] = b"DataPreservers";
683
        let storage_item_prefix: &[u8] = b"BootNodes";
684

            
685
        let pre_state: Vec<(ParaId, Vec<Vec<u8>>)> =
686
            Decode::decode(&mut &state[..]).expect("state to be decoded properly");
687

            
688
        for (para_id, bootnodes) in pre_state {
689
            let assignments = pallet_data_preservers::Assignments::<T>::get(para_id);
690
            assert_eq!(assignments.len(), bootnodes.len());
691

            
692
            let profiles: Vec<_> =
693
                pallet_data_preservers::Pallet::<T>::assignments_profiles(para_id).collect();
694

            
695
            for bootnode in bootnodes {
696
                assert_eq!(
697
                    profiles
698
                        .iter()
699
                        .filter(|profile| profile.url == bootnode)
700
                        .count(),
701
                    1
702
                );
703
            }
704
        }
705

            
706
        assert_eq!(
707
            storage_key_iter::<
708
                ParaId,
709
                BoundedVec<BoundedVec<u8, T::MaxNodeUrlLen>, T::MaxAssignmentsPerParaId>,
710
                Blake2_128Concat,
711
            >(pallet_prefix, storage_item_prefix)
712
            .count(),
713
            0
714
        );
715

            
716
        Ok(())
717
    }
718
}
719

            
720
pub struct ForeignAssetCreatorMigration<Runtime>(pub PhantomData<Runtime>);
721

            
722
impl<Runtime> Migration for ForeignAssetCreatorMigration<Runtime>
723
where
724
    Runtime: pallet_foreign_asset_creator::Config,
725
    <Runtime as pallet_foreign_asset_creator::Config>::ForeignAsset:
726
        TryFrom<staging_xcm::v3::MultiLocation>,
727
{
728
189
    fn friendly_name(&self) -> &str {
729
189
        "TM_ForeignAssetCreatorMigration"
730
189
    }
731

            
732
1
    fn migrate(&self, _available_weight: Weight) -> Weight {
733
        use frame_support::pallet_prelude::*;
734

            
735
        use staging_xcm::v3::MultiLocation as OldLocation;
736

            
737
1
        let pallet_prefix = AssetIdToForeignAsset::<Runtime>::pallet_prefix();
738
1
        let asset_id_to_foreign_asset_storage_prefix =
739
1
            AssetIdToForeignAsset::<Runtime>::storage_prefix();
740
1
        let foreign_asset_to_asset_id_prefix = ForeignAssetToAssetId::<Runtime>::storage_prefix();
741
1

            
742
1
        // Data required to migrate ForeignAsset values
743
1
        // Read all the data into memory.
744
1
        let asset_id_to_foreign_asset_data: Vec<_> =
745
1
            storage_key_iter::<AssetId<Runtime>, OldLocation, Blake2_128Concat>(
746
1
                pallet_prefix,
747
1
                asset_id_to_foreign_asset_storage_prefix,
748
1
            )
749
1
            .drain()
750
1
            .collect();
751
1

            
752
1
        // Data required to migrate ForeignAsset keys
753
1
        let foreign_asset_to_asset_id_data: Vec<_> =
754
1
            storage_key_iter::<OldLocation, AssetId<Runtime>, Blake2_128Concat>(
755
1
                pallet_prefix,
756
1
                foreign_asset_to_asset_id_prefix,
757
1
            )
758
1
            .drain()
759
1
            .collect();
760
1

            
761
1
        let migrated_count = asset_id_to_foreign_asset_data
762
1
            .len()
763
1
            .saturating_add(foreign_asset_to_asset_id_data.len());
764
1

            
765
1
        log::info!("Migrating {:?} elements", migrated_count);
766

            
767
        // Write to the new storage with removed and added fields
768
3
        for (asset_id, old_location) in asset_id_to_foreign_asset_data {
769
2
            if let Ok(new_location) = Runtime::ForeignAsset::try_from(old_location) {
770
2
                AssetIdToForeignAsset::<Runtime>::insert(asset_id, new_location);
771
2
            } else {
772
                log::warn!("Location could not be converted safely to xcmV4")
773
            }
774
        }
775

            
776
3
        for (old_location, asset_id) in foreign_asset_to_asset_id_data {
777
2
            if let Ok(new_location) = Runtime::ForeignAsset::try_from(old_location) {
778
2
                ForeignAssetToAssetId::<Runtime>::insert(new_location, asset_id);
779
2
            } else {
780
                log::warn!("Location could not be converted safely to xcmV4")
781
            }
782
        }
783

            
784
        // One db read and one db write per element, plus the on-chain storage
785
1
        Runtime::DbWeight::get().reads_writes(migrated_count as u64, 2 * migrated_count as u64)
786
1
    }
787

            
788
    #[cfg(feature = "try-runtime")]
789
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
790
        Ok(vec![])
791
    }
792

            
793
    #[cfg(feature = "try-runtime")]
794
    fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
795
        Ok(())
796
    }
797
}
798

            
799
pub struct ExternalValidatorsInitialMigration<Runtime>(pub PhantomData<Runtime>);
800

            
801
impl<Runtime> Migration for ExternalValidatorsInitialMigration<Runtime>
802
where
803
    Runtime: pallet_external_validators::Config,
804
    Runtime: pallet_session::Config<
805
        ValidatorId = <Runtime as pallet_external_validators::Config>::ValidatorId,
806
    >,
807
{
808
    fn friendly_name(&self) -> &str {
809
        "TM_ExternalValidatorsInitialMigration"
810
    }
811

            
812
1
    fn migrate(&self, _available_weight: Weight) -> Weight {
813
        use frame_support::pallet_prelude::*;
814

            
815
        // Set initial WhitelistedValidators to current validators from pallet session
816
1
        let session_keys = pallet_session::QueuedKeys::<Runtime>::get();
817
1
        let session_validators = BoundedVec::truncate_from(
818
1
            session_keys
819
1
                .into_iter()
820
2
                .map(|(validator, _keys)| validator)
821
1
                .collect(),
822
1
        );
823
1
        pallet_external_validators::WhitelistedValidators::<Runtime>::put(session_validators);
824
1

            
825
1
        // Kill storage of ValidatorManager pallet
826
1
        let pallet_prefix: &[u8] = b"ValidatorManager";
827
1
        let _ = clear_storage_prefix(pallet_prefix, b"", b"", None, None);
828
1

            
829
1
        // One db read and one db write per element, plus the on-chain storage
830
1
        Runtime::DbWeight::get().reads_writes(1, 1)
831
1
    }
832

            
833
    #[cfg(feature = "try-runtime")]
834
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
835
        Ok(vec![])
836
    }
837

            
838
    #[cfg(feature = "try-runtime")]
839
    fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
840
        Ok(())
841
    }
842
}
843

            
844
pub struct MigrateMMRLeafPallet<T>(pub PhantomData<T>);
845

            
846
impl<T: frame_system::Config> Migration for MigrateMMRLeafPallet<T> {
847
    fn friendly_name(&self) -> &str {
848
        "SM_MigrateMMRLeafPallet"
849
    }
850

            
851
1
    fn migrate(&self, available_weight: Weight) -> Weight {
852
1
        let new_name =
853
1
            <<T as frame_system::Config>::PalletInfo as frame_support::traits::PalletInfo>::name::<
854
1
                pallet_beefy_mmr::Pallet<T>,
855
1
            >()
856
1
            .expect("pallet_beefy_mmr must be part of dancelight before this migration");
857
1
        move_pallet(Self::old_pallet_name().as_bytes(), new_name.as_bytes());
858
1
        available_weight
859
1
    }
860

            
861
    #[cfg(feature = "try-runtime")]
862
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
863
        Ok(vec![])
864
    }
865

            
866
    #[cfg(feature = "try-runtime")]
867
    fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
868
        Ok(())
869
    }
870
}
871

            
872
impl<T> MigrateMMRLeafPallet<T> {
873
2
    pub fn old_pallet_name() -> &'static str {
874
2
        "MMRLeaf"
875
2
    }
876
}
877

            
878
pub struct BondedErasTimestampMigration<Runtime>(pub PhantomData<Runtime>);
879

            
880
impl<Runtime> Migration for BondedErasTimestampMigration<Runtime>
881
where
882
    Runtime: pallet_external_validator_slashes::Config,
883
{
884
1
    fn friendly_name(&self) -> &str {
885
1
        "TM_ExternalValidatorSlashesBondedErasTimestampMigration"
886
1
    }
887

            
888
1
    fn migrate(&self, _available_weight: Weight) -> Weight {
889
        use frame_support::pallet_prelude::*;
890

            
891
1
        let bonded_eras: Vec<(sp_staking::EraIndex, sp_staking::SessionIndex)> =
892
1
            frame_support::storage::unhashed::get(
893
1
                &pallet_external_validator_slashes::BondedEras::<Runtime>::hashed_key(),
894
1
            )
895
1
            .unwrap_or_default();
896
1
        let new_eras = bonded_eras
897
1
            .iter()
898
3
            .map(|(era, session)| (*era, *session, 0u64))
899
1
            .collect();
900
1
        pallet_external_validator_slashes::BondedEras::<Runtime>::set(new_eras);
901
1

            
902
1
        // One db read and one db write per element, plus the on-chain storage
903
1
        Runtime::DbWeight::get().reads_writes(1, 1)
904
1
    }
905

            
906
    #[cfg(feature = "try-runtime")]
907
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
908
        use frame_support::pallet_prelude::*;
909

            
910
        let previous_bonded_eras: Vec<(sp_staking::EraIndex, sp_staking::SessionIndex)> =
911
            frame_support::storage::unhashed::get(
912
                &pallet_external_validator_slashes::BondedEras::<Runtime>::hashed_key(),
913
            )
914
            .unwrap_or_default();
915

            
916
        Ok(previous_bonded_eras.encode())
917
    }
918

            
919
    #[cfg(feature = "try-runtime")]
920
    fn post_upgrade(&self, state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
921
        use parity_scale_codec::Decode;
922
        let previous_bonded_eras: Vec<(sp_staking::EraIndex, sp_staking::SessionIndex)> =
923
            Decode::decode(&mut &state[..]).expect("state to be decoded properly");
924
        let new_eras = pallet_external_validator_slashes::BondedEras::<Runtime>::get();
925
        for (i, bonded) in new_eras.iter().enumerate() {
926
            assert_eq!(previous_bonded_eras[i].0, bonded.0);
927
            assert_eq!(previous_bonded_eras[i].1, bonded.1);
928
            assert_eq!(bonded.2, 0u64);
929
        }
930
        Ok(())
931
    }
932
}
933

            
934
pub struct FlashboxMigrations<Runtime>(PhantomData<Runtime>);
935

            
936
impl<Runtime> GetMigrations for FlashboxMigrations<Runtime>
937
where
938
    Runtime: pallet_balances::Config,
939
    Runtime: pallet_configuration::Config,
940
    Runtime: pallet_registrar::Config,
941
    Runtime: pallet_data_preservers::Config,
942
    Runtime: pallet_services_payment::Config,
943
    Runtime: pallet_data_preservers::Config,
944
    Runtime::AccountId: From<[u8; 32]>,
945
    <Runtime as pallet_balances::Config>::RuntimeHoldReason: From<pallet_registrar::HoldReason>,
946
    <Runtime as pallet_balances::Config>::Balance: From<<<Runtime as pallet_registrar::Config>::Currency as frame_support::traits::fungible::Inspect<Runtime::AccountId>>::Balance>,
947
    <Runtime as pallet_balances::Config>::Balance: From<u128>,
948
{
949
1
    fn get_migrations() -> Vec<Box<dyn Migration>> {
950
1
        //let migrate_services_payment =
951
1
        //    MigrateServicesPaymentAddCredits::<Runtime>(Default::default());
952
1
        //let migrate_boot_nodes = MigrateBootNodes::<Runtime>(Default::default());
953
1
        //let migrate_config_parathread_params =
954
1
        //    MigrateConfigurationParathreads::<Runtime>(Default::default());
955
1

            
956
1
        //let migrate_add_collator_assignment_credits =
957
1
        //    MigrateServicesPaymentAddCollatorAssignmentCredits::<Runtime>(Default::default());
958
1
        //let migrate_registrar_pending_verification =
959
1
        //    RegistrarPendingVerificationValueToMap::<Runtime>(Default::default());
960
1
        //let migrate_registrar_manager =
961
1
        //    RegistrarParaManagerMigration::<Runtime>(Default::default());
962
1
        //let migrate_data_preservers_assignments =
963
1
        //    DataPreserversAssignmentsMigration::<Runtime>(Default::default());
964
1
        //let migrate_registrar_reserves = RegistrarReserveToHoldMigration::<Runtime>(Default::default());
965
1
        //let migrate_config_max_parachain_percentage = MigrateConfigurationAddParachainPercentage::<Runtime>(Default::default());
966
1
        let migrate_config_full_rotation_mode = MigrateConfigurationAddFullRotationMode::<Runtime>(Default::default());
967
1

            
968
1
        vec![
969
1
            // Applied in runtime 400
970
1
            //Box::new(migrate_services_payment),
971
1
            // Applied in runtime 400
972
1
            //Box::new(migrate_boot_nodes),
973
1
            // Applied in runtime 400
974
1
            //Box::new(migrate_config_parathread_params),
975
1
            // Applied in runtime 500
976
1
            //Box::new(migrate_add_collator_assignment_credits),
977
1
            // Applied in runtime 700
978
1
            //Box::new(migrate_registrar_pending_verification),
979
1
            // Applied in runtime 700
980
1
            //Box::new(migrate_registrar_manager),
981
1
            // Applied in runtime 700
982
1
            //Box::new(migrate_data_preservers_assignments),
983
1
            // Applied in runtime 800
984
1
            //Box::new(migrate_registrar_reserves),
985
1
            // Applied in runtime 900
986
1
            //Box::new(migrate_config_max_parachain_percentage),
987
1
            Box::new(migrate_config_full_rotation_mode),
988
1
        ]
989
1
    }
990
}
991

            
992
pub struct DanceboxMigrations<Runtime>(PhantomData<Runtime>);
993

            
994
impl<Runtime> GetMigrations for DanceboxMigrations<Runtime>
995
where
996
    Runtime: pallet_pooled_staking::Config,
997
    Runtime: pallet_registrar::Config,
998
    Runtime: pallet_balances::Config,
999
    Runtime: pallet_configuration::Config,
    Runtime: pallet_services_payment::Config,
    Runtime: cumulus_pallet_xcmp_queue::Config,
    Runtime: pallet_data_preservers::Config,
    Runtime: pallet_xcm::Config,
    <Runtime as pallet_balances::Config>::RuntimeHoldReason:
        From<pallet_pooled_staking::HoldReason>,
    Runtime: pallet_foreign_asset_creator::Config,
    <Runtime as pallet_foreign_asset_creator::Config>::ForeignAsset:
        TryFrom<staging_xcm::v3::MultiLocation>,
    <Runtime as pallet_balances::Config>::RuntimeHoldReason:
        From<pallet_registrar::HoldReason>,
    Runtime::AccountId: From<[u8; 32]>,
    <Runtime as pallet_balances::Config>::Balance: From<<<Runtime as pallet_registrar::Config>::Currency as frame_support::traits::fungible::Inspect<Runtime::AccountId>>::Balance>,
    <Runtime as pallet_balances::Config>::Balance: From<u128>,
{
1
    fn get_migrations() -> Vec<Box<dyn Migration>> {
1
        // let migrate_invulnerables = MigrateInvulnerables::<Runtime>(Default::default());
1
        // let migrate_holds = MigrateHoldReason::<Runtime>(Default::default());
1
        // let migrate_config = MigrateConfigurationFullRotationPeriod::<Runtime>(Default::default());
1
        // let migrate_xcm = PolkadotXcmMigration::<Runtime>(Default::default());
1
        // let migrate_xcmp_queue = XcmpQueueMigration::<Runtime>(Default::default());
1
        // let migrate_services_payment =
1
        //     MigrateServicesPaymentAddCredits::<Runtime>(Default::default());
1
        // let migrate_boot_nodes = MigrateBootNodes::<Runtime>(Default::default());
1
        // let migrate_hold_reason_runtime_enum =
1
        //     MigrateHoldReasonRuntimeEnum::<Runtime>(Default::default());
1

            
1
        //let migrate_config_parathread_params =
1
        //    MigrateConfigurationParathreads::<Runtime>(Default::default());
1
        //let migrate_add_collator_assignment_credits =
1
        //    MigrateServicesPaymentAddCollatorAssignmentCredits::<Runtime>(Default::default());
1
        //let migrate_xcmp_queue_v4 = XcmpQueueMigrationV4::<Runtime>(Default::default());
1
        //let migrate_registrar_pending_verification =
1
        //    RegistrarPendingVerificationValueToMap::<Runtime>(Default::default());
1
        //let migrate_registrar_manager =
1
        //    RegistrarParaManagerMigration::<Runtime>(Default::default());
1
        //let migrate_data_preservers_assignments =
1
        //    DataPreserversAssignmentsMigration::<Runtime>(Default::default());
1

            
1
        //let migrate_pallet_xcm_v4 = MigrateToLatestXcmVersion::<Runtime>(Default::default());
1
        //let foreign_asset_creator_migration =
1
        //    ForeignAssetCreatorMigration::<Runtime>(Default::default());
1
        //let migrate_registrar_reserves = RegistrarReserveToHoldMigration::<Runtime>(Default::default());
1
        let migrate_config_full_rotation_mode = MigrateConfigurationAddFullRotationMode::<Runtime>(Default::default());
1

            
1
        vec![
1
            // Applied in runtime 200
1
            //Box::new(migrate_invulnerables),
1
            // Applied in runtime 200
1
            //Box::new(migrate_holds),
1
            // Applied in runtime 300
1
            //Box::new(migrate_config),
1
            // Applied in runtime 300
1
            //Box::new(migrate_xcm),
1
            // Applied in runtime 300
1
            //Box::new(migrate_xcmp_queue),
1
            // Applied in runtime 400
1
            //Box::new(migrate_services_payment),
1
            // Applied in runtime 400
1
            //Box::new(migrate_hold_reason_runtime_enum),
1
            // Applied in runtime 400
1
            //Box::new(migrate_boot_nodes),
1
            // Applied in runtime 500
1
            //Box::new(migrate_config_parathread_params),
1
            // Applied in runtime 500
1
            //Box::new(migrate_add_collator_assignment_credits),
1
            // Applied in runtime 500
1
            //Box::new(migrate_xcmp_queue_v4),
1
            // Applied in runtime 700
1
            //Box::new(migrate_registrar_pending_verification),
1
            // Applied in runtime 700
1
            //Box::new(migrate_registrar_manager),
1
            // Applied in runtime 700
1
            //Box::new(migrate_pallet_xcm_v4),
1
            // Applied in runtime 700
1
            //Box::new(foreign_asset_creator_migration),
1
            // Applied in runtime 700
1
            //Box::new(migrate_data_preservers_assignments),
1
            // Applied in runtime 800
1
            //Box::new(migrate_registrar_reserves),
1
            // Applied in runtime 900
1
            //Box::new(migrate_config_max_parachain_percentage),
1
            Box::new(migrate_config_full_rotation_mode),
1
        ]
1
    }
}
pub struct DancelightMigrations<Runtime>(PhantomData<Runtime>);
impl<Runtime> GetMigrations for DancelightMigrations<Runtime>
where
    Runtime: frame_system::Config,
    Runtime: pallet_external_validators::Config,
    Runtime: pallet_configuration::Config,
    Runtime: pallet_session::Config<
        ValidatorId = <Runtime as pallet_external_validators::Config>::ValidatorId,
    >,
    Runtime: pallet_external_validator_slashes::Config,
{
1
    fn get_migrations() -> Vec<Box<dyn Migration>> {
1
        let migrate_config_full_rotation_mode =
1
            MigrateConfigurationAddFullRotationMode::<Runtime>(Default::default());
1

            
1
        let external_validator_slashes_bonded_eras_timestamp =
1
            BondedErasTimestampMigration::<Runtime>(Default::default());
1

            
1
        vec![
1
            // Applied in runtime 1000
1
            //Box::new(migrate_mmr_leaf_pallet),
1
            // Applied in runtime 900
1
            //Box::new(migrate_external_validators),
1
            Box::new(migrate_config_full_rotation_mode),
1
            Box::new(external_validator_slashes_bonded_eras_timestamp),
1
        ]
1
    }
}