@@ -127,27 +127,35 @@ pub struct V5HostConfiguration<BlockNumber> {
127
127
pub minimum_validation_upgrade_delay : BlockNumber ,
128
128
}
129
129
130
- #[ frame_support:: storage_alias]
131
- pub ( crate ) type V4ActiveConfig < T : Config > =
132
- StorageValue < Pallet < T > , V4HostConfiguration < BlockNumberFor < T > > , OptionQuery > ;
133
-
134
- #[ frame_support:: storage_alias]
135
- pub ( crate ) type V4PendingConfigs < T : Config > = StorageValue <
136
- Pallet < T > ,
137
- Vec < ( SessionIndex , V4HostConfiguration < BlockNumberFor < T > > ) > ,
138
- OptionQuery ,
139
- > ;
140
-
141
- #[ frame_support:: storage_alias]
142
- pub ( crate ) type V5ActiveConfig < T : Config > =
143
- StorageValue < Pallet < T > , V5HostConfiguration < BlockNumberFor < T > > , OptionQuery > ;
144
-
145
- #[ frame_support:: storage_alias]
146
- pub ( crate ) type V5PendingConfigs < T : Config > = StorageValue <
147
- Pallet < T > ,
148
- Vec < ( SessionIndex , V5HostConfiguration < BlockNumberFor < T > > ) > ,
149
- OptionQuery ,
150
- > ;
130
+ mod v4 {
131
+ use super :: * ;
132
+
133
+ #[ frame_support:: storage_alias]
134
+ pub ( crate ) type ActiveConfig < T : Config > =
135
+ StorageValue < Pallet < T > , V4HostConfiguration < BlockNumberFor < T > > , OptionQuery > ;
136
+
137
+ #[ frame_support:: storage_alias]
138
+ pub ( crate ) type PendingConfigs < T : Config > = StorageValue <
139
+ Pallet < T > ,
140
+ Vec < ( SessionIndex , V4HostConfiguration < BlockNumberFor < T > > ) > ,
141
+ OptionQuery ,
142
+ > ;
143
+ }
144
+
145
+ mod v5 {
146
+ use super :: * ;
147
+
148
+ #[ frame_support:: storage_alias]
149
+ pub ( crate ) type ActiveConfig < T : Config > =
150
+ StorageValue < Pallet < T > , V5HostConfiguration < BlockNumberFor < T > > , OptionQuery > ;
151
+
152
+ #[ frame_support:: storage_alias]
153
+ pub ( crate ) type PendingConfigs < T : Config > = StorageValue <
154
+ Pallet < T > ,
155
+ Vec < ( SessionIndex , V5HostConfiguration < BlockNumberFor < T > > ) > ,
156
+ OptionQuery ,
157
+ > ;
158
+ }
151
159
152
160
impl < BlockNumber : Default + From < u32 > > Default for V4HostConfiguration < BlockNumber > {
153
161
fn default ( ) -> Self {
@@ -266,6 +274,7 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToV5<T> {
266
274
}
267
275
268
276
fn on_runtime_upgrade ( ) -> Weight {
277
+ log:: info!( target: configuration:: LOG_TARGET , "MigrateToV5 started" ) ;
269
278
if StorageVersion :: get :: < Pallet < T > > ( ) == 4 {
270
279
let weight_consumed = migrate_to_v5 :: < T > ( ) ;
271
280
@@ -352,13 +361,13 @@ executor_params : Default::default(),
352
361
}
353
362
} ;
354
363
355
- let v4 = V4ActiveConfig :: < T > :: get ( )
364
+ let v4 = v4 :: ActiveConfig :: < T > :: get ( )
356
365
. defensive_proof ( "Could not decode old config" )
357
366
. unwrap_or_default ( ) ;
358
367
let v5 = translate ( v4) ;
359
- V5ActiveConfig :: < T > :: set ( Some ( v5) ) ;
368
+ v5 :: ActiveConfig :: < T > :: set ( Some ( v5) ) ;
360
369
361
- let pending_v4 = V4PendingConfigs :: < T > :: get ( )
370
+ let pending_v4 = v4 :: PendingConfigs :: < T > :: get ( )
362
371
. defensive_proof ( "Could not decode old pending" )
363
372
. unwrap_or_default ( ) ;
364
373
let mut pending_v5 = Vec :: new ( ) ;
@@ -367,7 +376,7 @@ executor_params : Default::default(),
367
376
let v5 = translate ( v4) ;
368
377
pending_v5. push ( ( session, v5) ) ;
369
378
}
370
- V5PendingConfigs :: < T > :: set ( Some ( pending_v5. clone ( ) ) ) ;
379
+ v5 :: PendingConfigs :: < T > :: set ( Some ( pending_v5. clone ( ) ) ) ;
371
380
372
381
let num_configs = ( pending_v5. len ( ) + 1 ) as u64 ;
373
382
T :: DbWeight :: get ( ) . reads_writes ( num_configs, num_configs)
@@ -397,8 +406,8 @@ mod tests {
397
406
// doesn't need to be read and also leaving it as one line allows to easily copy it.
398
407
let raw_config = hex_literal:: hex![ "0000a000005000000a00000000c8000000c800000a0000000a000000100e0000580200000000500000c800000700e8764817020040011e00000000000000005039278c0400000000000000000000005039278c0400000000000000000000e8030000009001001e00000000000000009001008070000000000000000000000a0000000a0000000a00000001000000010500000001c80000000600000058020000580200000200000059000000000000001e000000280000000700c817a80402004001010200000014000000" ] ;
399
408
400
- let v4 = v5 :: V4HostConfiguration :: < primitives :: BlockNumber > :: decode ( & mut & raw_config [ .. ] )
401
- . unwrap ( ) ;
409
+ let v4 =
410
+ V4HostConfiguration :: < primitives :: BlockNumber > :: decode ( & mut & raw_config [ .. ] ) . unwrap ( ) ;
402
411
403
412
// We check only a sample of the values here. If we missed any fields or messed up data types
404
413
// that would skew all the fields coming after.
@@ -421,7 +430,7 @@ mod tests {
421
430
// We specify only the picked fields and the rest should be provided by the `Default`
422
431
// implementation. That implementation is copied over between the two types and should work
423
432
// fine.
424
- let v4 = v5 :: V4HostConfiguration :: < primitives:: BlockNumber > {
433
+ let v4 = V4HostConfiguration :: < primitives:: BlockNumber > {
425
434
ump_max_individual_weight : Weight :: from_parts ( 0x71616e6f6e0au64 , 0x71616e6f6e0au64 ) ,
426
435
needed_approvals : 69 ,
427
436
thread_availability_period : 55 ,
@@ -438,13 +447,13 @@ mod tests {
438
447
439
448
new_test_ext ( Default :: default ( ) ) . execute_with ( || {
440
449
// Implant the v4 version in the state.
441
- V4ActiveConfig :: < Test > :: set ( Some ( v4) ) ;
442
- V4PendingConfigs :: < Test > :: set ( Some ( pending_configs) ) ;
450
+ v4 :: ActiveConfig :: < Test > :: set ( Some ( v4) ) ;
451
+ v4 :: PendingConfigs :: < Test > :: set ( Some ( pending_configs) ) ;
443
452
444
453
migrate_to_v5 :: < Test > ( ) ;
445
454
446
- let v5 = V5ActiveConfig :: < Test > :: get ( ) . unwrap ( ) ;
447
- let mut configs_to_check = V5PendingConfigs :: < Test > :: get ( ) . unwrap ( ) ;
455
+ let v5 = v5 :: ActiveConfig :: < Test > :: get ( ) . unwrap ( ) ;
456
+ let mut configs_to_check = v5 :: PendingConfigs :: < Test > :: get ( ) . unwrap ( ) ;
448
457
configs_to_check. push ( ( 0 , v5. clone ( ) ) ) ;
449
458
450
459
for ( _, v4) in configs_to_check {
0 commit comments