File tree 4 files changed +61
-7
lines changed 4 files changed +61
-7
lines changed Original file line number Diff line number Diff line change @@ -27,16 +27,28 @@ pub struct CustomOnRuntimeUpgrade;
27
27
impl frame_support:: traits:: OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
28
28
#[ cfg( feature = "try-runtime" ) ]
29
29
fn pre_upgrade ( ) -> Result < Vec < u8 > , sp_runtime:: DispatchError > {
30
+ log:: info!( "pre" ) ;
31
+
30
32
assert ! ( Balances :: free_balance( ROOT ) != 0 ) ;
31
33
34
+ <pallet_balances:: Locks < Runtime > >:: iter ( ) . for_each ( |( k, v) | {
35
+ log:: info!( "{k:?}" ) ;
36
+ log:: info!( "{v:?}" ) ;
37
+ } ) ;
38
+
32
39
Ok ( Vec :: new ( ) )
33
40
}
34
41
35
42
#[ cfg( feature = "try-runtime" ) ]
36
43
fn post_upgrade ( _state : Vec < u8 > ) -> Result < ( ) , sp_runtime:: DispatchError > {
44
+ log:: info!( "post" ) ;
45
+
37
46
assert ! ( Balances :: free_balance( ROOT ) == 0 ) ;
38
47
39
- <pallet_balances:: Locks < Runtime > >:: iter_values ( ) . for_each ( |v| {
48
+ <pallet_balances:: Locks < Runtime > >:: iter ( ) . for_each ( |( k, v) | {
49
+ log:: info!( "{k:?}" ) ;
50
+ log:: info!( "{v:?}" ) ;
51
+
40
52
assert ! ( !v. is_empty( ) ) ;
41
53
} ) ;
42
54
@@ -87,7 +99,13 @@ fn migrate() -> frame_support::weights::Weight {
87
99
} ) ;
88
100
89
101
if changed {
90
- <pallet_balances:: Locks < Runtime > >:: insert ( k, v) ;
102
+ if v. is_empty ( ) {
103
+ // Clear the storage entry if the vector is empty.
104
+
105
+ <pallet_balances:: Locks < Runtime > >:: remove ( k) ;
106
+ } else {
107
+ <pallet_balances:: Locks < Runtime > >:: insert ( k, v) ;
108
+ }
91
109
92
110
w += 1 ;
93
111
}
Original file line number Diff line number Diff line change @@ -27,16 +27,28 @@ pub struct CustomOnRuntimeUpgrade;
27
27
impl frame_support:: traits:: OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
28
28
#[ cfg( feature = "try-runtime" ) ]
29
29
fn pre_upgrade ( ) -> Result < Vec < u8 > , sp_runtime:: DispatchError > {
30
+ log:: info!( "pre" ) ;
31
+
30
32
assert ! ( migration:: have_storage_value( b"EcdsaAuthority" , b"Authorities" , & [ ] ) ) ;
31
33
34
+ <pallet_balances:: Locks < Runtime > >:: iter ( ) . for_each ( |( k, v) | {
35
+ log:: info!( "{k:?}" ) ;
36
+ log:: info!( "{v:?}" ) ;
37
+ } ) ;
38
+
32
39
Ok ( Vec :: new ( ) )
33
40
}
34
41
35
42
#[ cfg( feature = "try-runtime" ) ]
36
43
fn post_upgrade ( _state : Vec < u8 > ) -> Result < ( ) , sp_runtime:: DispatchError > {
44
+ log:: info!( "post" ) ;
45
+
37
46
assert ! ( !migration:: have_storage_value( b"EcdsaAuthority" , b"Authorities" , & [ ] ) ) ;
38
47
39
- <pallet_balances:: Locks < Runtime > >:: iter_values ( ) . for_each ( |v| {
48
+ <pallet_balances:: Locks < Runtime > >:: iter ( ) . for_each ( |( k, v) | {
49
+ log:: info!( "{k:?}" ) ;
50
+ log:: info!( "{v:?}" ) ;
51
+
40
52
assert ! ( !v. is_empty( ) ) ;
41
53
} ) ;
42
54
@@ -86,7 +98,13 @@ fn migrate() -> frame_support::weights::Weight {
86
98
} ) ;
87
99
88
100
if changed {
89
- <pallet_balances:: Locks < Runtime > >:: insert ( k, v) ;
101
+ if v. is_empty ( ) {
102
+ // Clear the storage entry if the vector is empty.
103
+
104
+ <pallet_balances:: Locks < Runtime > >:: remove ( k) ;
105
+ } else {
106
+ <pallet_balances:: Locks < Runtime > >:: insert ( k, v) ;
107
+ }
90
108
91
109
w += 1 ;
92
110
}
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion {
75
75
spec_name : sp_runtime:: create_runtime_str!( "Pangolin2" ) ,
76
76
impl_name : sp_runtime:: create_runtime_str!( "DarwiniaOfficialRust" ) ,
77
77
authoring_version : 0 ,
78
- spec_version : 6_6_1_0 ,
78
+ spec_version : 6_6_1_1 ,
79
79
impl_version : 0 ,
80
80
apis : RUNTIME_API_VERSIONS ,
81
81
transaction_version : 0 ,
Original file line number Diff line number Diff line change @@ -27,12 +27,24 @@ pub struct CustomOnRuntimeUpgrade;
27
27
impl frame_support:: traits:: OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
28
28
#[ cfg( feature = "try-runtime" ) ]
29
29
fn pre_upgrade ( ) -> Result < Vec < u8 > , sp_runtime:: DispatchError > {
30
+ log:: info!( "pre" ) ;
31
+
32
+ <pallet_balances:: Locks < Runtime > >:: iter ( ) . for_each ( |( k, v) | {
33
+ log:: info!( "{k:?}" ) ;
34
+ log:: info!( "{v:?}" ) ;
35
+ } ) ;
36
+
30
37
Ok ( Vec :: new ( ) )
31
38
}
32
39
33
40
#[ cfg( feature = "try-runtime" ) ]
34
41
fn post_upgrade ( _state : Vec < u8 > ) -> Result < ( ) , sp_runtime:: DispatchError > {
35
- <pallet_balances:: Locks < Runtime > >:: iter_values ( ) . for_each ( |v| {
42
+ log:: info!( "post" ) ;
43
+
44
+ <pallet_balances:: Locks < Runtime > >:: iter ( ) . for_each ( |( k, v) | {
45
+ log:: info!( "{k:?}" ) ;
46
+ log:: info!( "{v:?}" ) ;
47
+
36
48
assert ! ( !v. is_empty( ) ) ;
37
49
} ) ;
38
50
@@ -82,7 +94,13 @@ fn migrate() -> frame_support::weights::Weight {
82
94
} ) ;
83
95
84
96
if changed {
85
- <pallet_balances:: Locks < Runtime > >:: insert ( k, v) ;
97
+ if v. is_empty ( ) {
98
+ // Clear the storage entry if the vector is empty.
99
+
100
+ <pallet_balances:: Locks < Runtime > >:: remove ( k) ;
101
+ } else {
102
+ <pallet_balances:: Locks < Runtime > >:: insert ( k, v) ;
103
+ }
86
104
87
105
w += 1 ;
88
106
}
You can’t perform that action at this time.
0 commit comments