From 5834b81e177b4af3c113a95bdab2c787b3786125 Mon Sep 17 00:00:00 2001 From: s5k0651 Date: Fri, 24 Feb 2023 17:58:12 +0530 Subject: [PATCH 1/4] remove deprecated remove_prefix to clear era_info --- frame/staking/src/pallet/impls.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 99c2f6043ee2c..7c4f4da7986fb 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -668,12 +668,9 @@ impl Pallet { /// Clear all era information for given era. pub(crate) fn clear_era_information(era_index: EraIndex) { - #[allow(deprecated)] - >::remove_prefix(era_index, None); - #[allow(deprecated)] - >::remove_prefix(era_index, None); - #[allow(deprecated)] - >::remove_prefix(era_index, None); + let _ = >::clear_prefix(era_index, u32::MAX, None); + let _ = >::clear_prefix(era_index, u32::MAX, None); + let _ = >::clear_prefix(era_index, u32::MAX, None); >::remove(era_index); >::remove(era_index); >::remove(era_index); From 321f55f0c2647c114afca16036f621f68389f36c Mon Sep 17 00:00:00 2001 From: s5k0651 Date: Wed, 12 Apr 2023 23:16:18 +0530 Subject: [PATCH 2/4] add debug assertions to check that the returned cursor is None --- frame/staking/src/pallet/impls.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 7c4f4da7986fb..b4e6c847572c3 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -668,9 +668,9 @@ impl Pallet { /// Clear all era information for given era. pub(crate) fn clear_era_information(era_index: EraIndex) { - let _ = >::clear_prefix(era_index, u32::MAX, None); - let _ = >::clear_prefix(era_index, u32::MAX, None); - let _ = >::clear_prefix(era_index, u32::MAX, None); + debug_assert!(>::clear_prefix(era_index, u32::MAX, None).maybe_cursor.is_none()); + debug_assert!(>::clear_prefix(era_index, u32::MAX, None).maybe_cursor.is_none()); + debug_assert!(>::clear_prefix(era_index, u32::MAX, None).maybe_cursor.is_none()); >::remove(era_index); >::remove(era_index); >::remove(era_index); From 0f4fd95432f3530af89bb6556e55b177a89e864b Mon Sep 17 00:00:00 2001 From: s5k0651 Date: Wed, 12 Apr 2023 23:38:04 +0530 Subject: [PATCH 3/4] add a variable to hold the cursor --- frame/staking/src/pallet/impls.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index b4e6c847572c3..7007933a58611 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -668,9 +668,12 @@ impl Pallet { /// Clear all era information for given era. pub(crate) fn clear_era_information(era_index: EraIndex) { - debug_assert!(>::clear_prefix(era_index, u32::MAX, None).maybe_cursor.is_none()); - debug_assert!(>::clear_prefix(era_index, u32::MAX, None).maybe_cursor.is_none()); - debug_assert!(>::clear_prefix(era_index, u32::MAX, None).maybe_cursor.is_none()); + let mut cursor = >::clear_prefix(era_index, u32::MAX, None); + debug_assert!(cursor.maybe_cursor.is_none()); + cursor = >::clear_prefix(era_index, u32::MAX, None); + debug_assert!(cursor.maybe_cursor.is_none()); + cursor = >::clear_prefix(era_index, u32::MAX, None); + debug_assert!(cursor.maybe_cursor.is_none()); >::remove(era_index); >::remove(era_index); >::remove(era_index); From 9d855fda56d867b68407e841c17cf48710a3af87 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Sat, 13 May 2023 17:33:50 +0000 Subject: [PATCH 4/4] ".git/.scripts/commands/fmt/fmt.sh" --- frame/staking/src/pallet/impls.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 7007933a58611..d0c8457e7ab09 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -673,7 +673,7 @@ impl Pallet { cursor = >::clear_prefix(era_index, u32::MAX, None); debug_assert!(cursor.maybe_cursor.is_none()); cursor = >::clear_prefix(era_index, u32::MAX, None); - debug_assert!(cursor.maybe_cursor.is_none()); + debug_assert!(cursor.maybe_cursor.is_none()); >::remove(era_index); >::remove(era_index); >::remove(era_index);