diff --git a/pallets/transaction-pause/src/migration.rs b/pallets/transaction-pause/src/migration.rs index 75dccfca7..569da8a5a 100644 --- a/pallets/transaction-pause/src/migration.rs +++ b/pallets/transaction-pause/src/migration.rs @@ -55,26 +55,28 @@ pub mod v1 { let mut weight = Weight::zero(); let status = v0::PausedTransactions::::drain().collect::>(); - weight.saturating_accrue(T::DbWeight::get().reads(status.len() as u64)); + weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); for ((pallet_name, function_name), _) in status.into_iter() { let pallet_name_b = BoundedVec::>::try_from(pallet_name.clone()); let function_name_b = BoundedVec::>::try_from(function_name.clone()); - if pallet_name_b.is_err() || function_name_b.is_err() { - log::info!( - target: TARGET, - "Value not migrated because it's too long: {:?}", - (pallet_name_b, function_name_b) - ); - continue; - } - crate::PausedTransactions::::insert((pallet_name_b.unwrap(), function_name_b.unwrap()), ()); + match (pallet_name_b, function_name_b) { + (Ok(pallet), Ok(function)) => { + crate::PausedTransactions::::insert((pallet, function), ()); + weight.saturating_accrue(T::DbWeight::get().writes(1)); + } + _ => log::info!( + target: TARGET, + "Value not migrated because BoundedVec exceeds its limit: {:?}", + (pallet_name, function_name) + ), + }; } StorageVersion::new(1).put::>(); - T::DbWeight::get().reads_writes(1, 1) + weight.saturating_add(T::DbWeight::get().writes(1)) } #[cfg(feature = "try-runtime")] @@ -87,7 +89,12 @@ pub mod v1 { .map(|v| (v.0.into_inner(), v.1.into_inner())) .collect::, Vec)>>(); - assert_eq!(previous_state, new_state, "Migrated storage entries don't match the entries prior migration!"); + for old_entry in previous_state.iter() { + assert!( + new_state.contains(old_entry), + "Migrated storage entries don't match the entries prior migration!" + ); + } log::info!(target: TARGET, "Transaction pause migration: POST checks successful!");