Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Migration hook fixes #14174

Merged
merged 13 commits into from
May 23, 2023
Merged

Migration hook fixes #14174

merged 13 commits into from
May 23, 2023

Conversation

liamaharon
Copy link
Contributor

@liamaharon liamaharon commented May 18, 2023

Partial paritytech/polkadot#7187
Partial paritytech/polkadot#6657

  • Add #[pallet::storage_version(STORAGE_VERSION)] to ChildBounties pallet
  • Fixes nomination pools v3 migration
  • Update some pre/post migration hooks so they won't start failing after the migration is enacted on-chain (responsible for some of the Rococo issues)
    • Question: we should probably create some best practices/guidelines about how to write these hooks so they 1. will check the migration correctly 2. won't do something like start failing after they're enacted? If this sounds good let me know and I'll create an issue to add something to the contributing guidelines or somewhere similar.

Together with paritytech/polkadot#7251, this fixes all storage / migration hook issues on Rococo & Westend (also verified Polkadata & Kusama still work).

@liamaharon liamaharon requested review from bkchr, ggwpez and a team May 18, 2023 13:19
Comment on lines 552 to 566
ensure!(
BondedPools::<T>::iter().all(|(_, inner)| inner.commission.current.is_none() &&
inner.commission.max.is_none() &&
inner.commission.change_rate.is_none() &&
inner.commission.throttle_from.is_none()),
"a commission value has been incorrectly set"
BondedPools::<T>::iter().all(|(_, inner)|
// Check current
(inner.commission.current.is_none() ||
inner.commission.current.is_some()) &&
// Check max
(inner.commission.max.is_none() || inner.commission.max.is_some()) &&
// Check change_rate
(inner.commission.change_rate.is_none() ||
inner.commission.change_rate.is_some()) &&
// Check throttle_from
(inner.commission.throttle_from.is_none() ||
inner.commission.throttle_from.is_some())),
"a commission value has not been set correctly"
);
Copy link
Contributor Author

@liamaharon liamaharon May 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensure! was failing on Rococo I guess because commission became no longer None for everything after people started using the pallet.

But the checks seem kind of like a noop (checking is_some || is_none). Can we just remove them?

@liamaharon liamaharon added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels May 18, 2023
frame/child-bounties/src/lib.rs Outdated Show resolved Hide resolved
frame/nomination-pools/src/migration.rs Outdated Show resolved Hide resolved
frame/nomination-pools/src/migration.rs Outdated Show resolved Hide resolved
frame/nomination-pools/src/migration.rs Outdated Show resolved Hide resolved
frame/offences/src/migration.rs Outdated Show resolved Hide resolved
@liamaharon liamaharon requested a review from gpestana May 22, 2023 09:11
@liamaharon liamaharon changed the title Set ChildBounties storage version & migration hook fixes Migration hook fixes May 23, 2023
@liamaharon
Copy link
Contributor Author

bot merge

@paritytech-processbot paritytech-processbot bot merged commit dca6ebe into master May 23, 2023
@paritytech-processbot paritytech-processbot bot deleted the liam-migration-hook-fixes branch May 23, 2023 16:01
gpestana pushed a commit that referenced this pull request May 27, 2023
* fix offences pre_upgrade hook

* identify source of ensure! failures

* stop migration hooks breaking post migration

* add childbounties storage version

* init child bounties version to zero

* Update frame/child-bounties/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* remove redundant preupgrade version checks

* update test

* fix nom pools v3 migration

* kick ci

* kick ci

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
Ank4n pushed a commit that referenced this pull request Jul 8, 2023
* fix offences pre_upgrade hook

* identify source of ensure! failures

* stop migration hooks breaking post migration

* add childbounties storage version

* init child bounties version to zero

* Update frame/child-bounties/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* remove redundant preupgrade version checks

* update test

* fix nom pools v3 migration

* kick ci

* kick ci

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
nathanwhit pushed a commit to nathanwhit/substrate that referenced this pull request Jul 19, 2023
* fix offences pre_upgrade hook

* identify source of ensure! failures

* stop migration hooks breaking post migration

* add childbounties storage version

* init child bounties version to zero

* Update frame/child-bounties/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* remove redundant preupgrade version checks

* update test

* fix nom pools v3 migration

* kick ci

* kick ci

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants