diff --git a/runtime/parachains/src/configuration/migration/v7.rs b/runtime/parachains/src/configuration/migration/v7.rs index d3b1d8b94832..cdff80a31a3a 100644 --- a/runtime/parachains/src/configuration/migration/v7.rs +++ b/runtime/parachains/src/configuration/migration/v7.rs @@ -156,9 +156,8 @@ executor_params : pre.executor_params, let v7 = translate(v6); v7::ActiveConfig::::set(Some(v7)); - let pending_v6 = v6::PendingConfigs::::get() - .defensive_proof("Could not decode old pending") - .unwrap_or_default(); + // Allowed to be empty. + let pending_v6 = v6::PendingConfigs::::get().unwrap_or_default(); let mut pending_v7 = Vec::new(); for (session, v6) in pending_v6.into_iter() { @@ -291,4 +290,20 @@ mod tests { } }); } + + // Test that migration doesn't panic in case there're no pending configurations upgrades in pallet's storage. + #[test] + fn test_migrate_to_v7_no_pending() { + let v6 = V6HostConfiguration::::default(); + + new_test_ext(Default::default()).execute_with(|| { + // Implant the v6 version in the state. + v6::ActiveConfig::::set(Some(v6)); + // Ensure there're no pending configs. + v6::PendingConfigs::::set(None); + + // Shouldn't fail. + migrate_to_v7::(); + }); + } }