From 3896e2e39c58655abae1a7090d32be63356b98da Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 29 Jan 2025 21:31:26 +0200 Subject: [PATCH] Polkadot Relay fix corrupt ledger migration checks (#566) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes `try-runtime` migration validation for the `restore_corrupt_ledger_2` migration. 🚨 This fix is required to unblock CI for all other PRs, which are currently incorrectly failing migration CI checks. - [x] Does not require a CHANGELOG entry --- relay/polkadot/src/lib.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/relay/polkadot/src/lib.rs b/relay/polkadot/src/lib.rs index 4bcd057726..20eaa1d098 100644 --- a/relay/polkadot/src/lib.rs +++ b/relay/polkadot/src/lib.rs @@ -2036,13 +2036,18 @@ pub mod restore_corrupt_ledger_2 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { - assert!(pallet_staking::Ledger::::get(CorruptStash::get()).is_some()); - Ok(Default::default()) + let found_corrupted = + pallet_staking::Ledger::::get(CorruptStash::get()).is_some(); + Ok(found_corrupted.encode()) } #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), sp_runtime::TryRuntimeError> { - assert!(pallet_staking::Ledger::::get(CorruptStash::get()).is_none()); + fn post_upgrade(state: Vec) -> Result<(), sp_runtime::TryRuntimeError> { + let found_corrupted: bool = Decode::decode(&mut &state[..]) + .map_err(|_| sp_runtime::TryRuntimeError::Corruption)?; + if found_corrupted { + assert!(pallet_staking::Ledger::::get(CorruptStash::get()).is_none()); + } Ok(()) } }