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

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

            
89
1
    fn migrate(&self, _available_weight: Weight) -> Weight {
90
        const CONFIGURATION_ACTIVE_CONFIG_KEY: &[u8] =
91
            &hex_literal::hex!("06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385");
92
        const CONFIGURATION_PENDING_CONFIGS_KEY: &[u8] =
93
            &hex_literal::hex!("06de3d8a54d27e44a9d5ce189618f22d53b4123b2e186e07fb7bad5dda5f55c0");
94
1
        let default_config = HostConfiguration::default();
95
1

            
96
1
        // Modify active config
97
1
        let old_config: HostConfigurationV2 =
98
1
            frame_support::storage::unhashed::get(CONFIGURATION_ACTIVE_CONFIG_KEY)
99
1
                .expect("configuration.activeConfig should have value");
100
1
        let new_config = HostConfiguration {
101
1
            max_collators: old_config.max_collators,
102
1
            min_orchestrator_collators: old_config.min_orchestrator_collators,
103
1
            max_orchestrator_collators: old_config.max_orchestrator_collators,
104
1
            collators_per_container: old_config.collators_per_container,
105
1
            full_rotation_period: old_config.full_rotation_period,
106
1
            collators_per_parathread: old_config.collators_per_parathread,
107
1
            parathreads_per_collator: old_config.parathreads_per_collator,
108
1
            target_container_chain_fullness: old_config.target_container_chain_fullness,
109
1
            max_parachain_cores_percentage: default_config.max_parachain_cores_percentage,
110
1
        };
111
1
        frame_support::storage::unhashed::put(CONFIGURATION_ACTIVE_CONFIG_KEY, &new_config);
112
1

            
113
1
        // Modify pending configs, if any
114
1
        let old_pending_configs: Vec<(u32, HostConfigurationV2)> =
115
1
            frame_support::storage::unhashed::get(CONFIGURATION_PENDING_CONFIGS_KEY)
116
1
                .unwrap_or_default();
117
1
        let mut new_pending_configs: Vec<(u32, HostConfiguration)> = vec![];
118

            
119
3
        for (session_index, old_config) in old_pending_configs {
120
2
            let new_config = HostConfiguration {
121
2
                max_collators: old_config.max_collators,
122
2
                min_orchestrator_collators: old_config.min_orchestrator_collators,
123
2
                max_orchestrator_collators: old_config.max_orchestrator_collators,
124
2
                collators_per_container: old_config.collators_per_container,
125
2
                full_rotation_period: old_config.full_rotation_period,
126
2
                collators_per_parathread: old_config.collators_per_parathread,
127
2
                parathreads_per_collator: old_config.parathreads_per_collator,
128
2
                target_container_chain_fullness: old_config.target_container_chain_fullness,
129
2
                max_parachain_cores_percentage: default_config.max_parachain_cores_percentage,
130
2
            };
131
2
            new_pending_configs.push((session_index, new_config));
132
2
        }
133

            
134
1
        if !new_pending_configs.is_empty() {
135
1
            frame_support::storage::unhashed::put(
136
1
                CONFIGURATION_PENDING_CONFIGS_KEY,
137
1
                &new_pending_configs,
138
1
            );
139
1
        }
140

            
141
1
        <T as pallet_configuration::Config>::WeightInfo::set_config_with_u32()
142
1
    }
143

            
144
    /// Run a standard pre-runtime test. This works the same way as in a normal runtime upgrade.
145
    #[cfg(feature = "try-runtime")]
146
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
147
        const CONFIGURATION_ACTIVE_CONFIG_KEY: &[u8] =
148
            &hex_literal::hex!("06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385");
149

            
150
        let old_config_bytes =
151
            frame_support::storage::unhashed::get_raw(CONFIGURATION_ACTIVE_CONFIG_KEY)
152
                .expect("configuration.activeConfig should have value");
153
        // This works because there is no enum in the v2
154
        assert_eq!(
155
            old_config_bytes.len(),
156
            HostConfigurationV2::default().encoded_size()
157
        );
158

            
159
        use parity_scale_codec::Encode;
160
        Ok((old_config_bytes).encode())
161
    }
162

            
163
    /// Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
164
    #[cfg(feature = "try-runtime")]
165
    fn post_upgrade(
166
        &self,
167
        _number_of_invulnerables: Vec<u8>,
168
    ) -> Result<(), sp_runtime::DispatchError> {
169
        let new_config = pallet_configuration::Pallet::<T>::config();
170
        let default_config = HostConfiguration::default();
171
        assert_eq!(
172
            new_config.max_parachain_cores_percentage,
173
            default_config.max_parachain_cores_percentage
174
        );
175
        Ok(())
176
    }
177
}
178

            
179
#[derive(
180
    Clone,
181
    parity_scale_codec::Encode,
182
    parity_scale_codec::Decode,
183
    PartialEq,
184
    sp_core::RuntimeDebug,
185
    scale_info::TypeInfo,
186
)]
187
struct HostConfigurationV1 {
188
    pub max_collators: u32,
189
    pub min_orchestrator_collators: u32,
190
    pub max_orchestrator_collators: u32,
191
    pub collators_per_container: u32,
192
    pub full_rotation_period: u32,
193
}
194

            
195
pub struct MigrateConfigurationParathreads<T>(pub PhantomData<T>);
196
impl<T> Migration for MigrateConfigurationParathreads<T>
197
where
198
    T: pallet_configuration::Config,
199
{
200
2
    fn friendly_name(&self) -> &str {
201
2
        "TM_MigrateConfigurationParathreads"
202
2
    }
203

            
204
1
    fn migrate(&self, _available_weight: Weight) -> Weight {
205
        const CONFIGURATION_ACTIVE_CONFIG_KEY: &[u8] =
206
            &hex_literal::hex!("06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385");
207
        const CONFIGURATION_PENDING_CONFIGS_KEY: &[u8] =
208
            &hex_literal::hex!("06de3d8a54d27e44a9d5ce189618f22d53b4123b2e186e07fb7bad5dda5f55c0");
209
1
        let default_config = HostConfiguration::default();
210
1

            
211
1
        // Modify active config
212
1
        let old_config: HostConfigurationV1 =
213
1
            frame_support::storage::unhashed::get(CONFIGURATION_ACTIVE_CONFIG_KEY)
214
1
                .expect("configuration.activeConfig should have value");
215
1
        let new_config = HostConfiguration {
216
1
            max_collators: old_config.max_collators,
217
1
            min_orchestrator_collators: old_config.min_orchestrator_collators,
218
1
            max_orchestrator_collators: old_config.max_orchestrator_collators,
219
1
            collators_per_container: old_config.collators_per_container,
220
1
            full_rotation_period: old_config.full_rotation_period,
221
1
            collators_per_parathread: default_config.collators_per_parathread,
222
1
            parathreads_per_collator: default_config.parathreads_per_collator,
223
1
            target_container_chain_fullness: default_config.target_container_chain_fullness,
224
1
            max_parachain_cores_percentage: default_config.max_parachain_cores_percentage,
225
1
        };
226
1
        frame_support::storage::unhashed::put(CONFIGURATION_ACTIVE_CONFIG_KEY, &new_config);
227
1

            
228
1
        // Modify pending configs, if any
229
1
        let old_pending_configs: Vec<(u32, HostConfigurationV1)> =
230
1
            frame_support::storage::unhashed::get(CONFIGURATION_PENDING_CONFIGS_KEY)
231
1
                .unwrap_or_default();
232
1
        let mut new_pending_configs: Vec<(u32, HostConfiguration)> = vec![];
233

            
234
3
        for (session_index, old_config) in old_pending_configs {
235
2
            let new_config = HostConfiguration {
236
2
                max_collators: old_config.max_collators,
237
2
                min_orchestrator_collators: old_config.min_orchestrator_collators,
238
2
                max_orchestrator_collators: old_config.max_orchestrator_collators,
239
2
                collators_per_container: old_config.collators_per_container,
240
2
                full_rotation_period: old_config.full_rotation_period,
241
2
                collators_per_parathread: default_config.collators_per_parathread,
242
2
                parathreads_per_collator: default_config.parathreads_per_collator,
243
2
                target_container_chain_fullness: default_config.target_container_chain_fullness,
244
2
                max_parachain_cores_percentage: default_config.max_parachain_cores_percentage,
245
2
            };
246
2
            new_pending_configs.push((session_index, new_config));
247
2
        }
248

            
249
1
        if !new_pending_configs.is_empty() {
250
1
            frame_support::storage::unhashed::put(
251
1
                CONFIGURATION_PENDING_CONFIGS_KEY,
252
1
                &new_pending_configs,
253
1
            );
254
1
        }
255

            
256
1
        <T as pallet_configuration::Config>::WeightInfo::set_config_with_u32()
257
1
    }
258

            
259
    /// Run a standard pre-runtime test. This works the same way as in a normal runtime upgrade.
260
    #[cfg(feature = "try-runtime")]
261
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
262
        const CONFIGURATION_ACTIVE_CONFIG_KEY: &[u8] =
263
            &hex_literal::hex!("06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385");
264

            
265
        let old_config_bytes =
266
            frame_support::storage::unhashed::get_raw(CONFIGURATION_ACTIVE_CONFIG_KEY)
267
                .expect("configuration.activeConfig should have value");
268
        assert_eq!(old_config_bytes.len(), 20);
269

            
270
        use parity_scale_codec::Encode;
271
        Ok((old_config_bytes).encode())
272
    }
273

            
274
    /// Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
275
    #[cfg(feature = "try-runtime")]
276
    fn post_upgrade(
277
        &self,
278
        _number_of_invulnerables: Vec<u8>,
279
    ) -> Result<(), sp_runtime::DispatchError> {
280
        let new_config = pallet_configuration::Pallet::<T>::config();
281
        let default_config = HostConfiguration::default();
282
        assert_eq!(
283
            new_config.collators_per_parathread,
284
            default_config.collators_per_parathread
285
        );
286
        assert_eq!(
287
            new_config.parathreads_per_collator,
288
            default_config.collators_per_parathread
289
        );
290
        assert_eq!(
291
            new_config.target_container_chain_fullness,
292
            default_config.target_container_chain_fullness
293
        );
294

            
295
        Ok(())
296
    }
297
}
298

            
299
pub struct MigrateServicesPaymentAddCollatorAssignmentCredits<T>(pub PhantomData<T>);
300
impl<T> Migration for MigrateServicesPaymentAddCollatorAssignmentCredits<T>
301
where
302
    T: pallet_services_payment::Config + pallet_registrar::Config,
303
{
304
2
    fn friendly_name(&self) -> &str {
305
2
        "TM_MigrateServicesPaymentAddCollatorAssignmentCredits"
306
2
    }
307

            
308
2
    fn migrate(&self, _available_weight: Weight) -> Weight {
309
2
        // For each parachain in pallet_registrar (active, pending or pending_verification),
310
2
        // insert `MaxCreditsStored` to pallet_services_payment,
311
2
        // and mark that parachain as "given_free_credits".
312
2
        let mut para_ids = BTreeSet::new();
313
2
        let active = pallet_registrar::RegisteredParaIds::<T>::get();
314
2
        let pending = pallet_registrar::PendingParaIds::<T>::get();
315
2

            
316
2
        let paused = pallet_registrar::Paused::<T>::get();
317
2
        para_ids.extend(active);
318
2
        para_ids.extend(pending.into_iter().flat_map(|(_session, active)| active));
319
2
        para_ids.extend(paused);
320
2

            
321
2
        let reads = 3 + 2 * para_ids.len() as u64;
322
2
        let writes = 2 * para_ids.len() as u64;
323

            
324
6
        for para_id in para_ids {
325
4
            // 2 reads 2 writes
326
4
            pallet_services_payment::Pallet::<T>::set_free_collator_assignment_credits(
327
4
                &para_id,
328
4
                T::FreeCollatorAssignmentCredits::get(),
329
4
            );
330
4
        }
331

            
332
2
        let db_weights = T::DbWeight::get();
333
2
        db_weights.reads_writes(reads, writes)
334
2
    }
335
    /// Run a standard pre-runtime test. This works the same way as in a normal runtime upgrade.
336
    #[cfg(feature = "try-runtime")]
337
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
338
        let mut para_ids = BTreeSet::new();
339
        let active = pallet_registrar::RegisteredParaIds::<T>::get();
340
        let pending = pallet_registrar::PendingParaIds::<T>::get();
341
        let paused = pallet_registrar::Paused::<T>::get();
342
        para_ids.extend(active);
343
        para_ids.extend(pending.into_iter().flat_map(|(_session, active)| active));
344
        para_ids.extend(paused);
345

            
346
        for para_id in para_ids {
347
            assert!(
348
                pallet_services_payment::CollatorAssignmentCredits::<T>::get(para_id).is_none()
349
            );
350
        }
351

            
352
        Ok(vec![])
353
    }
354

            
355
    // Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
356
    #[cfg(feature = "try-runtime")]
357
    fn post_upgrade(&self, _result: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
358
        let mut para_ids = BTreeSet::new();
359
        let active = pallet_registrar::RegisteredParaIds::<T>::get();
360
        let pending = pallet_registrar::PendingParaIds::<T>::get();
361
        let paused = pallet_registrar::Paused::<T>::get();
362
        para_ids.extend(active);
363
        para_ids.extend(pending.into_iter().flat_map(|(_session, active)| active));
364
        para_ids.extend(paused);
365

            
366
        for para_id in para_ids {
367
            assert_eq!(
368
                pallet_services_payment::CollatorAssignmentCredits::<T>::get(para_id),
369
                Some(T::FreeCollatorAssignmentCredits::get())
370
            );
371
        }
372

            
373
        Ok(())
374
    }
375
}
376

            
377
pub struct PolkadotXcmMigrationFixVersion<T, PolkadotXcm>(pub PhantomData<(T, PolkadotXcm)>);
378
impl<T, PolkadotXcm> Migration for PolkadotXcmMigrationFixVersion<T, PolkadotXcm>
379
where
380
    PolkadotXcm: GetStorageVersion + PalletInfoAccess,
381
    T: cumulus_pallet_xcmp_queue::Config,
382
{
383
266
    fn friendly_name(&self) -> &str {
384
266
        "MM_PolkadotXcmMigrationFixVersion"
385
266
    }
386

            
387
    fn migrate(&self, _available_weight: Weight) -> Weight {
388
        if <PolkadotXcm as GetStorageVersion>::on_chain_storage_version() == 0 {
389
            StorageVersion::new(1).put::<PolkadotXcm>();
390
            return T::DbWeight::get().writes(1);
391
        }
392
        Weight::default()
393
    }
394

            
395
    #[cfg(feature = "try-runtime")]
396
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
397
        ensure!(
398
            <PolkadotXcm as GetStorageVersion>::on_chain_storage_version() == 0,
399
            "PolkadotXcm storage version should be 0"
400
        );
401
        Ok(vec![])
402
    }
403

            
404
    // Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
405
    #[cfg(feature = "try-runtime")]
406
    fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
407
        ensure!(
408
            <PolkadotXcm as GetStorageVersion>::on_chain_storage_version() == 1,
409
            "PolkadotXcm storage version should be 1"
410
        );
411
        Ok(())
412
    }
413
}
414

            
415
pub struct XcmpQueueMigrationFixVersion<T, XcmpQueue>(pub PhantomData<(T, XcmpQueue)>);
416
impl<T, XcmpQueue> Migration for XcmpQueueMigrationFixVersion<T, XcmpQueue>
417
where
418
    XcmpQueue: GetStorageVersion + PalletInfoAccess,
419
    T: cumulus_pallet_xcmp_queue::Config,
420
{
421
266
    fn friendly_name(&self) -> &str {
422
266
        "MM_XcmpQueueMigrationFixVersion"
423
266
    }
424

            
425
    fn migrate(&self, _available_weight: Weight) -> Weight {
426
        if <XcmpQueue as GetStorageVersion>::on_chain_storage_version() == 0 {
427
            StorageVersion::new(2).put::<XcmpQueue>();
428
            return T::DbWeight::get().writes(1);
429
        }
430
        Weight::default()
431
    }
432

            
433
    #[cfg(feature = "try-runtime")]
434
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
435
        ensure!(
436
            <XcmpQueue as GetStorageVersion>::on_chain_storage_version() == 0,
437
            "XcmpQueue storage version should be 0"
438
        );
439
        Ok(vec![])
440
    }
441

            
442
    // Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
443
    #[cfg(feature = "try-runtime")]
444
    fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
445
        // Greater than because the post_upgrade is run after all the migrations, so
446
        // it can be greater if the following XcmpQueue migrations are applied in the
447
        // same runtime
448
        ensure!(
449
            <XcmpQueue as GetStorageVersion>::on_chain_storage_version() >= 2,
450
            "XcmpQueue storage version should be at least 2"
451
        );
452
        Ok(())
453
    }
454
}
455

            
456
pub struct XcmpQueueMigrationV3<T>(pub PhantomData<T>);
457
impl<T> Migration for XcmpQueueMigrationV3<T>
458
where
459
    T: cumulus_pallet_xcmp_queue::Config,
460
{
461
266
    fn friendly_name(&self) -> &str {
462
266
        "MM_XcmpQueueMigrationV3"
463
266
    }
464

            
465
    fn migrate(&self, _available_weight: Weight) -> Weight {
466
        cumulus_pallet_xcmp_queue::migration::v3::MigrationToV3::<T>::on_runtime_upgrade()
467
    }
468

            
469
    // #[cfg(feature = "try-runtime")]
470
    // let mut pre_upgrade_result: Vec<u8>;
471

            
472
    #[cfg(feature = "try-runtime")]
473
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
474
        cumulus_pallet_xcmp_queue::migration::v3::MigrationToV3::<T>::pre_upgrade()
475
    }
476

            
477
    // Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
478
    #[cfg(feature = "try-runtime")]
479
    fn post_upgrade(&self, state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
480
        cumulus_pallet_xcmp_queue::migration::v3::MigrationToV3::<T>::post_upgrade(state)
481
    }
482
}
483

            
484
pub struct XcmpQueueMigrationV4<T>(pub PhantomData<T>);
485
impl<T> Migration for XcmpQueueMigrationV4<T>
486
where
487
    T: cumulus_pallet_xcmp_queue::Config,
488
{
489
267
    fn friendly_name(&self) -> &str {
490
267
        "MM_XcmpQueueMigrationV4"
491
267
    }
492

            
493
    fn migrate(&self, _available_weight: Weight) -> Weight {
494
        cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4::<T>::on_runtime_upgrade()
495
    }
496

            
497
    #[cfg(feature = "try-runtime")]
498
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
499
        cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4::<T>::pre_upgrade()
500
    }
501

            
502
    // Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
503
    #[cfg(feature = "try-runtime")]
504
    fn post_upgrade(&self, state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
505
        cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4::<T>::post_upgrade(state)
506
    }
507
}
508

            
509
pub struct RegistrarPendingVerificationValueToMap<T>(pub PhantomData<T>);
510
impl<T> Migration for RegistrarPendingVerificationValueToMap<T>
511
where
512
    T: pallet_registrar::Config,
513
{
514
2
    fn friendly_name(&self) -> &str {
515
2
        "TM_RegistrarPendingVerificationValueToMap"
516
2
    }
517

            
518
1
    fn migrate(&self, _available_weight: Weight) -> Weight {
519
1
        let para_ids: Vec<ParaId> = frame_support::storage::unhashed::take(
520
1
            &frame_support::storage::storage_prefix(b"Registrar", b"PendingVerification"),
521
1
        )
522
1
        .unwrap_or_default();
523
1

            
524
1
        let total_weight = T::DbWeight::get()
525
1
            .reads(1)
526
1
            .saturating_add(T::DbWeight::get().writes(1));
527

            
528
5
        for para_id in para_ids {
529
4
            total_weight.saturating_add(T::DbWeight::get().writes(1));
530
4
            pallet_registrar::PendingVerification::<T>::insert(para_id, ());
531
4
        }
532

            
533
1
        total_weight
534
1
    }
535

            
536
    #[cfg(feature = "try-runtime")]
537
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
538
        Ok(vec![])
539
    }
540

            
541
    // Run a standard post-runtime test. This works the same way as in a normal runtime upgrade.
542
    #[cfg(feature = "try-runtime")]
543
    fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
544
        Ok(())
545
    }
546
}
547

            
548
pub struct RegistrarParaManagerMigration<T>(pub PhantomData<T>);
549
impl<T> Migration for RegistrarParaManagerMigration<T>
550
where
551
    T: pallet_registrar::Config,
552
{
553
2
    fn friendly_name(&self) -> &str {
554
2
        "TM_RegistrarParaManagerMigration"
555
2
    }
556

            
557
    fn migrate(&self, _available_weight: Weight) -> Weight {
558
        let mut total_weight = Weight::default();
559
        for (para_id, deposit) in pallet_registrar::RegistrarDeposit::<T>::iter() {
560
            pallet_registrar::ParaManager::<T>::insert(para_id, deposit.creator);
561
            total_weight = total_weight.saturating_add(
562
                T::DbWeight::get()
563
                    .reads(1)
564
                    .saturating_add(T::DbWeight::get().writes(1)),
565
            );
566
        }
567

            
568
        total_weight
569
    }
570

            
571
    #[cfg(feature = "try-runtime")]
572
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
573
        Ok(vec![])
574
    }
575

            
576
    #[cfg(feature = "try-runtime")]
577
    fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
578
        Ok(())
579
    }
580
}
581

            
582
pub struct RegistrarReserveToHoldMigration<T>(pub PhantomData<T>);
583
impl<T> Migration for RegistrarReserveToHoldMigration<T>
584
where
585
    T: pallet_registrar::Config,
586
    T: pallet_balances::Config,
587
    <T as pallet_balances::Config>::RuntimeHoldReason: From<pallet_registrar::HoldReason>,
588
    <T as pallet_balances::Config>::Balance: From<
589
        <<T as pallet_registrar::Config>::Currency as frame_support::traits::fungible::Inspect<
590
            T::AccountId,
591
        >>::Balance,
592
    >,
593
    <T as pallet_balances::Config>::Balance: From<u128>,
594
{
595
2
    fn friendly_name(&self) -> &str {
596
2
        "TM_RegistrarReserveToHoldMigration"
597
2
    }
598

            
599
2
    fn migrate(&self, _available_weight: Weight) -> Weight {
600
2
        let mut total_weight = Weight::default();
601
4
        for (_para_id, deposit) in pallet_registrar::RegistrarDeposit::<T>::iter() {
602
2
            pallet_balances::Pallet::<T>::unreserve(&deposit.creator, deposit.deposit.into());
603
2
            let _ = pallet_balances::Pallet::<T>::hold(
604
2
                &HoldReason::RegistrarDeposit.into(),
605
2
                &deposit.creator,
606
2
                deposit.deposit.into(),
607
2
            );
608
2
            total_weight = total_weight.saturating_add(T::DbWeight::get().reads_writes(2, 2));
609
2
        }
610

            
611
2
        total_weight
612
2
    }
613

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

            
618
        for (_para_id, deposit) in pallet_registrar::RegistrarDeposit::<T>::iter() {
619
            ensure!(
620
                pallet_balances::Pallet::<T>::reserved_balance(&deposit.creator)
621
                    >= deposit.deposit.into(),
622
                "Reserved balanced cannot be less than deposit amount"
623
            );
624

            
625
            ensure!(
626
                pallet_balances::Pallet::<T>::balance_on_hold(
627
                    &HoldReason::RegistrarDeposit.into(),
628
                    &deposit.creator
629
                ) == 0u128.into(),
630
                "Balance on hold for RegistrarDeposit should be 0"
631
            );
632
        }
633
        Ok(vec![])
634
    }
635

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

            
640
        for (_para_id, deposit) in pallet_registrar::RegistrarDeposit::<T>::iter() {
641
            ensure!(
642
                pallet_balances::Pallet::<T>::balance_on_hold(
643
                    &HoldReason::RegistrarDeposit.into(),
644
                    &deposit.creator
645
                ) >= deposit.deposit.into(),
646
                "Balance on hold for RegistrarDeposit should be deposit"
647
            );
648
        }
649

            
650
        Ok(())
651
    }
652
}
653
pub struct MigrateToLatestXcmVersion<Runtime>(PhantomData<Runtime>);
654
impl<Runtime> Migration for MigrateToLatestXcmVersion<Runtime>
655
where
656
    pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>:
657
        frame_support::traits::OnRuntimeUpgrade,
658
{
659
1
    fn friendly_name(&self) -> &str {
660
1
        "MM_MigrateToLatestXcmVersion"
661
1
    }
662

            
663
    fn migrate(&self, _available_weight: Weight) -> Weight {
664
        pallet_xcm::migration::MigrateToLatestXcmVersion::<Runtime>::on_runtime_upgrade()
665
    }
666

            
667
    #[cfg(feature = "try-runtime")]
668
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
669
        pallet_xcm::migration::MigrateToLatestXcmVersion::<Runtime>::pre_upgrade()
670
    }
671

            
672
    #[cfg(feature = "try-runtime")]
673
    fn post_upgrade(&self, state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
674
        pallet_xcm::migration::MigrateToLatestXcmVersion::<Runtime>::post_upgrade(state)
675
    }
676
}
677

            
678
pub struct DataPreserversAssignmentsMigration<T>(pub PhantomData<T>);
679
impl<T> Migration for DataPreserversAssignmentsMigration<T>
680
where
681
    T: pallet_data_preservers::Config + pallet_registrar::Config,
682
    T::AccountId: From<[u8; 32]>,
683
{
684
2
    fn friendly_name(&self) -> &str {
685
2
        "TM_DataPreserversAssignmentsMigration"
686
2
    }
687

            
688
2
    fn migrate(&self, _available_weight: Weight) -> Weight {
689
        use {
690
            frame_support::BoundedBTreeSet,
691
            frame_system::RawOrigin,
692
            pallet_data_preservers::{AssignmentPayment, ParaIdsFilter, Profile, ProfileMode},
693
        };
694

            
695
2
        let mut total_weight = Weight::default();
696
2

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

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

            
702
2
        let pallet_prefix: &[u8] = b"DataPreservers";
703
2
        let storage_item_prefix: &[u8] = b"BootNodes";
704
2
        let bootnodes_storage: Vec<_> = storage_key_iter::<
705
2
            ParaId,
706
2
            BoundedVec<BoundedVec<u8, T::MaxNodeUrlLen>, T::MaxAssignmentsPerParaId>,
707
2
            Blake2_128Concat,
708
2
        >(pallet_prefix, storage_item_prefix)
709
2
        .collect();
710
2

            
711
2
        total_weight = total_weight.saturating_add(
712
2
            T::DbWeight::get()
713
2
                .reads(bootnodes_storage.len() as u64)
714
2
                .saturating_add(T::DbWeight::get().writes(bootnodes_storage.len() as u64)),
715
2
        );
716

            
717
6
        for (para_id, bootnodes) in bootnodes_storage {
718
12
            for bootnode_url in bootnodes {
719
8
                let profile = Profile {
720
8
                    url: bootnode_url,
721
8
                    para_ids: ParaIdsFilter::Whitelist({
722
8
                        let mut set = BoundedBTreeSet::new();
723
8
                        set.try_insert(para_id).expect("to be in bound");
724
8
                        set
725
8
                    }),
726
8
                    mode: ProfileMode::Bootnode,
727
8
                    assignment_request: request.clone(),
728
8
                };
729
8

            
730
8
                let profile_id = pallet_data_preservers::NextProfileId::<T>::get();
731

            
732
8
                if let Some(weight) = pallet_data_preservers::Pallet::<T>::force_create_profile(
733
8
                    RawOrigin::Root.into(),
734
8
                    profile,
735
8
                    dummy_profile_owner.clone(),
736
8
                )
737
8
                .expect("to create profile")
738
8
                .actual_weight
739
                {
740
                    total_weight = total_weight.saturating_add(weight);
741
8
                }
742

            
743
8
                if let Some(weight) = pallet_data_preservers::Pallet::<T>::force_start_assignment(
744
8
                    RawOrigin::Root.into(),
745
8
                    profile_id,
746
8
                    para_id,
747
8
                    witness.clone(),
748
8
                )
749
8
                .expect("to start assignment")
750
8
                .actual_weight
751
                {
752
                    total_weight = total_weight.saturating_add(weight);
753
8
                }
754
            }
755
        }
756

            
757
2
        let _ = clear_storage_prefix(pallet_prefix, storage_item_prefix, &[], None, None);
758
2

            
759
2
        total_weight
760
2
    }
761

            
762
    #[cfg(feature = "try-runtime")]
763
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
764
        use parity_scale_codec::Encode;
765

            
766
        let pallet_prefix: &[u8] = b"DataPreservers";
767
        let storage_item_prefix: &[u8] = b"BootNodes";
768
        let state: Vec<_> = storage_key_iter::<
769
            ParaId,
770
            BoundedVec<BoundedVec<u8, T::MaxNodeUrlLen>, T::MaxAssignmentsPerParaId>,
771
            Blake2_128Concat,
772
        >(pallet_prefix, storage_item_prefix)
773
        .collect();
774

            
775
        Ok(state.encode())
776
    }
777

            
778
    #[cfg(feature = "try-runtime")]
779
    fn post_upgrade(&self, state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
780
        use parity_scale_codec::Decode;
781

            
782
        let pallet_prefix: &[u8] = b"DataPreservers";
783
        let storage_item_prefix: &[u8] = b"BootNodes";
784

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

            
788
        for (para_id, bootnodes) in pre_state {
789
            let assignments = pallet_data_preservers::Assignments::<T>::get(para_id);
790
            assert_eq!(assignments.len(), bootnodes.len());
791

            
792
            let profiles: Vec<_> =
793
                pallet_data_preservers::Pallet::<T>::assignments_profiles(para_id).collect();
794

            
795
            for bootnode in bootnodes {
796
                assert_eq!(
797
                    profiles
798
                        .iter()
799
                        .filter(|profile| profile.url == bootnode)
800
                        .count(),
801
                    1
802
                );
803
            }
804
        }
805

            
806
        assert_eq!(
807
            storage_key_iter::<
808
                ParaId,
809
                BoundedVec<BoundedVec<u8, T::MaxNodeUrlLen>, T::MaxAssignmentsPerParaId>,
810
                Blake2_128Concat,
811
            >(pallet_prefix, storage_item_prefix)
812
            .count(),
813
            0
814
        );
815

            
816
        Ok(())
817
    }
818
}
819

            
820
pub struct ForeignAssetCreatorMigration<Runtime>(pub PhantomData<Runtime>);
821

            
822
impl<Runtime> Migration for ForeignAssetCreatorMigration<Runtime>
823
where
824
    Runtime: pallet_foreign_asset_creator::Config,
825
    <Runtime as pallet_foreign_asset_creator::Config>::ForeignAsset:
826
        TryFrom<staging_xcm::v3::MultiLocation>,
827
{
828
90
    fn friendly_name(&self) -> &str {
829
90
        "TM_ForeignAssetCreatorMigration"
830
90
    }
831

            
832
1
    fn migrate(&self, _available_weight: Weight) -> Weight {
833
        use frame_support::pallet_prelude::*;
834

            
835
        use staging_xcm::v3::MultiLocation as OldLocation;
836

            
837
1
        let pallet_prefix = AssetIdToForeignAsset::<Runtime>::pallet_prefix();
838
1
        let asset_id_to_foreign_asset_storage_prefix =
839
1
            AssetIdToForeignAsset::<Runtime>::storage_prefix();
840
1
        let foreign_asset_to_asset_id_prefix = ForeignAssetToAssetId::<Runtime>::storage_prefix();
841
1

            
842
1
        // Data required to migrate ForeignAsset values
843
1
        // Read all the data into memory.
844
1
        let asset_id_to_foreign_asset_data: Vec<_> =
845
1
            storage_key_iter::<AssetId<Runtime>, OldLocation, Blake2_128Concat>(
846
1
                pallet_prefix,
847
1
                asset_id_to_foreign_asset_storage_prefix,
848
1
            )
849
1
            .drain()
850
1
            .collect();
851
1

            
852
1
        // Data required to migrate ForeignAsset keys
853
1
        let foreign_asset_to_asset_id_data: Vec<_> =
854
1
            storage_key_iter::<OldLocation, AssetId<Runtime>, Blake2_128Concat>(
855
1
                pallet_prefix,
856
1
                foreign_asset_to_asset_id_prefix,
857
1
            )
858
1
            .drain()
859
1
            .collect();
860
1

            
861
1
        let migrated_count = asset_id_to_foreign_asset_data
862
1
            .len()
863
1
            .saturating_add(foreign_asset_to_asset_id_data.len());
864
1

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

            
867
        // Write to the new storage with removed and added fields
868
3
        for (asset_id, old_location) in asset_id_to_foreign_asset_data {
869
2
            if let Ok(new_location) = Runtime::ForeignAsset::try_from(old_location) {
870
2
                AssetIdToForeignAsset::<Runtime>::insert(asset_id, new_location);
871
2
            } else {
872
                log::warn!("Location could not be converted safely to xcmV4")
873
            }
874
        }
875

            
876
3
        for (old_location, asset_id) in foreign_asset_to_asset_id_data {
877
2
            if let Ok(new_location) = Runtime::ForeignAsset::try_from(old_location) {
878
2
                ForeignAssetToAssetId::<Runtime>::insert(new_location, asset_id);
879
2
            } else {
880
                log::warn!("Location could not be converted safely to xcmV4")
881
            }
882
        }
883

            
884
        // One db read and one db write per element, plus the on-chain storage
885
1
        Runtime::DbWeight::get().reads_writes(migrated_count as u64, 2 * migrated_count as u64)
886
1
    }
887

            
888
    #[cfg(feature = "try-runtime")]
889
    fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
890
        Ok(vec![])
891
    }
892

            
893
    #[cfg(feature = "try-runtime")]
894
    fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
895
        Ok(())
896
    }
897
}
898

            
899
pub struct FlashboxMigrations<Runtime>(PhantomData<Runtime>);
900

            
901
impl<Runtime> GetMigrations for FlashboxMigrations<Runtime>
902
where
903
    Runtime: pallet_balances::Config,
904
    Runtime: pallet_configuration::Config,
905
    Runtime: pallet_registrar::Config,
906
    Runtime: pallet_data_preservers::Config,
907
    Runtime: pallet_services_payment::Config,
908
    Runtime: pallet_data_preservers::Config,
909
    Runtime::AccountId: From<[u8; 32]>,
910
    <Runtime as pallet_balances::Config>::RuntimeHoldReason: From<pallet_registrar::HoldReason>,
911
    <Runtime as pallet_balances::Config>::Balance: From<<<Runtime as pallet_registrar::Config>::Currency as frame_support::traits::fungible::Inspect<Runtime::AccountId>>::Balance>,
912
    <Runtime as pallet_balances::Config>::Balance: From<u128>,
913
{
914
1
    fn get_migrations() -> Vec<Box<dyn Migration>> {
915
1
        //let migrate_services_payment =
916
1
        //    MigrateServicesPaymentAddCredits::<Runtime>(Default::default());
917
1
        //let migrate_boot_nodes = MigrateBootNodes::<Runtime>(Default::default());
918
1
        let migrate_config_parathread_params =
919
1
            MigrateConfigurationParathreads::<Runtime>(Default::default());
920
1

            
921
1
        let migrate_add_collator_assignment_credits =
922
1
            MigrateServicesPaymentAddCollatorAssignmentCredits::<Runtime>(Default::default());
923
1
        let migrate_registrar_pending_verification =
924
1
            RegistrarPendingVerificationValueToMap::<Runtime>(Default::default());
925
1
        let migrate_registrar_manager =
926
1
            RegistrarParaManagerMigration::<Runtime>(Default::default());
927
1
        let migrate_data_preservers_assignments =
928
1
            DataPreserversAssignmentsMigration::<Runtime>(Default::default());
929
1
        let migrate_registrar_reserves = RegistrarReserveToHoldMigration::<Runtime>(Default::default());
930
1
        let migrate_config_max_parachain_percentage = MigrateConfigurationAddParachainPercentage::<Runtime>(Default::default());
931
1

            
932
1
        vec![
933
1
            // Applied in runtime 400
934
1
            //Box::new(migrate_services_payment),
935
1
            // Applied in runtime 400
936
1
            //Box::new(migrate_boot_nodes),
937
1
            // Applied in runtime 400
938
1
            Box::new(migrate_config_parathread_params),
939
1
            Box::new(migrate_add_collator_assignment_credits),
940
1
            Box::new(migrate_registrar_pending_verification),
941
1
            Box::new(migrate_registrar_manager),
942
1
            Box::new(migrate_data_preservers_assignments),
943
1
            Box::new(migrate_registrar_reserves),
944
1
            Box::new(migrate_config_max_parachain_percentage),
945
1
        ]
946
1
    }
947
}
948

            
949
pub struct DanceboxMigrations<Runtime>(PhantomData<Runtime>);
950

            
951
impl<Runtime> GetMigrations for DanceboxMigrations<Runtime>
952
where
953
    Runtime: pallet_pooled_staking::Config,
954
    Runtime: pallet_registrar::Config,
955
    Runtime: pallet_balances::Config,
956
    Runtime: pallet_configuration::Config,
957
    Runtime: pallet_services_payment::Config,
958
    Runtime: cumulus_pallet_xcmp_queue::Config,
959
    Runtime: pallet_data_preservers::Config,
960
    Runtime: pallet_xcm::Config,
961
    <Runtime as pallet_balances::Config>::RuntimeHoldReason:
962
        From<pallet_pooled_staking::HoldReason>,
963
    Runtime: pallet_foreign_asset_creator::Config,
964
    <Runtime as pallet_foreign_asset_creator::Config>::ForeignAsset:
965
        TryFrom<staging_xcm::v3::MultiLocation>,
966
    <Runtime as pallet_balances::Config>::RuntimeHoldReason:
967
        From<pallet_registrar::HoldReason>,
968
    Runtime::AccountId: From<[u8; 32]>,
969
    <Runtime as pallet_balances::Config>::Balance: From<<<Runtime as pallet_registrar::Config>::Currency as frame_support::traits::fungible::Inspect<Runtime::AccountId>>::Balance>,
970
    <Runtime as pallet_balances::Config>::Balance: From<u128>,
971
{
972
1
    fn get_migrations() -> Vec<Box<dyn Migration>> {
973
1
        // let migrate_invulnerables = MigrateInvulnerables::<Runtime>(Default::default());
974
1
        // let migrate_holds = MigrateHoldReason::<Runtime>(Default::default());
975
1
        // let migrate_config = MigrateConfigurationFullRotationPeriod::<Runtime>(Default::default());
976
1
        // let migrate_xcm = PolkadotXcmMigration::<Runtime>(Default::default());
977
1
        // let migrate_xcmp_queue = XcmpQueueMigration::<Runtime>(Default::default());
978
1
        // let migrate_services_payment =
979
1
        //     MigrateServicesPaymentAddCredits::<Runtime>(Default::default());
980
1
        // let migrate_boot_nodes = MigrateBootNodes::<Runtime>(Default::default());
981
1
        // let migrate_hold_reason_runtime_enum =
982
1
        //     MigrateHoldReasonRuntimeEnum::<Runtime>(Default::default());
983
1

            
984
1
        let migrate_config_parathread_params =
985
1
            MigrateConfigurationParathreads::<Runtime>(Default::default());
986
1
        let migrate_add_collator_assignment_credits =
987
1
            MigrateServicesPaymentAddCollatorAssignmentCredits::<Runtime>(Default::default());
988
1
        let migrate_xcmp_queue_v4 = XcmpQueueMigrationV4::<Runtime>(Default::default());
989
1
        let migrate_registrar_pending_verification =
990
1
            RegistrarPendingVerificationValueToMap::<Runtime>(Default::default());
991
1
        let migrate_registrar_manager =
992
1
            RegistrarParaManagerMigration::<Runtime>(Default::default());
993
1
        let migrate_data_preservers_assignments =
994
1
            DataPreserversAssignmentsMigration::<Runtime>(Default::default());
995
1

            
996
1
        let migrate_pallet_xcm_v4 = MigrateToLatestXcmVersion::<Runtime>(Default::default());
997
1
        let foreign_asset_creator_migration =
998
1
            ForeignAssetCreatorMigration::<Runtime>(Default::default());
999
1
        let migrate_registrar_reserves = RegistrarReserveToHoldMigration::<Runtime>(Default::default());
1
        let migrate_config_max_parachain_percentage = MigrateConfigurationAddParachainPercentage::<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
            Box::new(migrate_config_parathread_params),
1
            Box::new(migrate_add_collator_assignment_credits),
1
            Box::new(migrate_xcmp_queue_v4),
1
            Box::new(migrate_registrar_pending_verification),
1
            Box::new(migrate_registrar_manager),
1
            Box::new(migrate_pallet_xcm_v4),
1
            Box::new(foreign_asset_creator_migration),
1
            Box::new(migrate_data_preservers_assignments),
1
            Box::new(migrate_registrar_reserves),
1
            Box::new(migrate_config_max_parachain_percentage)
1
        ]
1
    }
}
pub struct DancelightMigrations<Runtime>(PhantomData<Runtime>);
impl<Runtime> GetMigrations for DancelightMigrations<Runtime> {
1
    fn get_migrations() -> Vec<Box<dyn Migration>> {
1
        vec![]
1
    }
}