Skip to content

Commit e93b7af

Browse files
authored
Release pango-6611 (#1467)
* Release `pango-6611` * Fix migration
1 parent 4c7c156 commit e93b7af

File tree

4 files changed

+61
-7
lines changed

4 files changed

+61
-7
lines changed

runtime/crab/src/migration.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,28 @@ pub struct CustomOnRuntimeUpgrade;
2727
impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
2828
#[cfg(feature = "try-runtime")]
2929
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::DispatchError> {
30+
log::info!("pre");
31+
3032
assert!(Balances::free_balance(ROOT) != 0);
3133

34+
<pallet_balances::Locks<Runtime>>::iter().for_each(|(k, v)| {
35+
log::info!("{k:?}");
36+
log::info!("{v:?}");
37+
});
38+
3239
Ok(Vec::new())
3340
}
3441

3542
#[cfg(feature = "try-runtime")]
3643
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
44+
log::info!("post");
45+
3746
assert!(Balances::free_balance(ROOT) == 0);
3847

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+
4052
assert!(!v.is_empty());
4153
});
4254

@@ -87,7 +99,13 @@ fn migrate() -> frame_support::weights::Weight {
8799
});
88100

89101
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+
}
91109

92110
w += 1;
93111
}

runtime/darwinia/src/migration.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,28 @@ pub struct CustomOnRuntimeUpgrade;
2727
impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
2828
#[cfg(feature = "try-runtime")]
2929
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::DispatchError> {
30+
log::info!("pre");
31+
3032
assert!(migration::have_storage_value(b"EcdsaAuthority", b"Authorities", &[]));
3133

34+
<pallet_balances::Locks<Runtime>>::iter().for_each(|(k, v)| {
35+
log::info!("{k:?}");
36+
log::info!("{v:?}");
37+
});
38+
3239
Ok(Vec::new())
3340
}
3441

3542
#[cfg(feature = "try-runtime")]
3643
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
44+
log::info!("post");
45+
3746
assert!(!migration::have_storage_value(b"EcdsaAuthority", b"Authorities", &[]));
3847

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+
4052
assert!(!v.is_empty());
4153
});
4254

@@ -86,7 +98,13 @@ fn migrate() -> frame_support::weights::Weight {
8698
});
8799

88100
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+
}
90108

91109
w += 1;
92110
}

runtime/pangolin/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion {
7575
spec_name: sp_runtime::create_runtime_str!("Pangolin2"),
7676
impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"),
7777
authoring_version: 0,
78-
spec_version: 6_6_1_0,
78+
spec_version: 6_6_1_1,
7979
impl_version: 0,
8080
apis: RUNTIME_API_VERSIONS,
8181
transaction_version: 0,

runtime/pangolin/src/migration.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,24 @@ pub struct CustomOnRuntimeUpgrade;
2727
impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
2828
#[cfg(feature = "try-runtime")]
2929
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+
3037
Ok(Vec::new())
3138
}
3239

3340
#[cfg(feature = "try-runtime")]
3441
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+
3648
assert!(!v.is_empty());
3749
});
3850

@@ -82,7 +94,13 @@ fn migrate() -> frame_support::weights::Weight {
8294
});
8395

8496
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+
}
86104

87105
w += 1;
88106
}

0 commit comments

Comments
 (0)