Skip to content

Commit

Permalink
Release pango-6611 (#1467)
Browse files Browse the repository at this point in the history
* Release `pango-6611`

* Fix migration
  • Loading branch information
AurevoirXavier authored Apr 2, 2024
1 parent 4c7c156 commit e93b7af
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 7 deletions.
22 changes: 20 additions & 2 deletions runtime/crab/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,28 @@ pub struct CustomOnRuntimeUpgrade;
impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::DispatchError> {
log::info!("pre");

assert!(Balances::free_balance(ROOT) != 0);

<pallet_balances::Locks<Runtime>>::iter().for_each(|(k, v)| {
log::info!("{k:?}");
log::info!("{v:?}");
});

Ok(Vec::new())
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
log::info!("post");

assert!(Balances::free_balance(ROOT) == 0);

<pallet_balances::Locks<Runtime>>::iter_values().for_each(|v| {
<pallet_balances::Locks<Runtime>>::iter().for_each(|(k, v)| {
log::info!("{k:?}");
log::info!("{v:?}");

assert!(!v.is_empty());
});

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

if changed {
<pallet_balances::Locks<Runtime>>::insert(k, v);
if v.is_empty() {
// Clear the storage entry if the vector is empty.

<pallet_balances::Locks<Runtime>>::remove(k);
} else {
<pallet_balances::Locks<Runtime>>::insert(k, v);
}

w += 1;
}
Expand Down
22 changes: 20 additions & 2 deletions runtime/darwinia/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,28 @@ pub struct CustomOnRuntimeUpgrade;
impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::DispatchError> {
log::info!("pre");

assert!(migration::have_storage_value(b"EcdsaAuthority", b"Authorities", &[]));

<pallet_balances::Locks<Runtime>>::iter().for_each(|(k, v)| {
log::info!("{k:?}");
log::info!("{v:?}");
});

Ok(Vec::new())
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
log::info!("post");

assert!(!migration::have_storage_value(b"EcdsaAuthority", b"Authorities", &[]));

<pallet_balances::Locks<Runtime>>::iter_values().for_each(|v| {
<pallet_balances::Locks<Runtime>>::iter().for_each(|(k, v)| {
log::info!("{k:?}");
log::info!("{v:?}");

assert!(!v.is_empty());
});

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

if changed {
<pallet_balances::Locks<Runtime>>::insert(k, v);
if v.is_empty() {
// Clear the storage entry if the vector is empty.

<pallet_balances::Locks<Runtime>>::remove(k);
} else {
<pallet_balances::Locks<Runtime>>::insert(k, v);
}

w += 1;
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/pangolin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion {
spec_name: sp_runtime::create_runtime_str!("Pangolin2"),
impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"),
authoring_version: 0,
spec_version: 6_6_1_0,
spec_version: 6_6_1_1,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
Expand Down
22 changes: 20 additions & 2 deletions runtime/pangolin/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,24 @@ pub struct CustomOnRuntimeUpgrade;
impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::DispatchError> {
log::info!("pre");

<pallet_balances::Locks<Runtime>>::iter().for_each(|(k, v)| {
log::info!("{k:?}");
log::info!("{v:?}");
});

Ok(Vec::new())
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
<pallet_balances::Locks<Runtime>>::iter_values().for_each(|v| {
log::info!("post");

<pallet_balances::Locks<Runtime>>::iter().for_each(|(k, v)| {
log::info!("{k:?}");
log::info!("{v:?}");

assert!(!v.is_empty());
});

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

if changed {
<pallet_balances::Locks<Runtime>>::insert(k, v);
if v.is_empty() {
// Clear the storage entry if the vector is empty.

<pallet_balances::Locks<Runtime>>::remove(k);
} else {
<pallet_balances::Locks<Runtime>>::insert(k, v);
}

w += 1;
}
Expand Down

0 comments on commit e93b7af

Please sign in to comment.