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

Remove all stale on_runtime_upgrade hooks in the runtime #10650

Merged
merged 9 commits into from
Jan 19, 2022

Conversation

kianenigma
Copy link
Contributor

@kianenigma kianenigma commented Jan 13, 2022

and henceforth, we really try to not introduce them again, in the spirit of paritytech/polkadot-sdk#296 et. al. \

related but won't close #8713

This will also make the logs of try-runtime much cleaner.

@kianenigma kianenigma 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 Jan 13, 2022
@@ -321,10 +321,6 @@ pub mod pallet {
Storage::<T>::process_deletion_queue_batch(weight_limit)
.saturating_add(T::WeightInfo::on_initialize())
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@athei please confirm this is not used.

Copy link
Member

Choose a reason for hiding this comment

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

How would I know if anyone uses this? It will migrate when appropriate. The code isn't there for fun.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well this is exactly the reason why we are removing these hooks, because it is not clear who and when uses them.

My rephrased question is: are there any teams that you are aware of that would be affected if we remove this code?

note that I will re-expose this migration code as a standalone function, in case anyone needs it so they can manually apply it, and mark the PR is release-note.

Copy link
Member

Choose a reason for hiding this comment

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

Its fine then. But I really much preferred the old way where it just worked. Won't I get all these dead code warnings after this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You will see the outcome soon.

@@ -316,13 +316,6 @@ pub mod pallet {
Unapproved,
}

#[pallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hamidra please confirm this is not used.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is needed for the next statemine/statemint release to add ClassAccount storage to uniques.
Is this PR just a cleanup or we need to get rid of all migrations in the pallets?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay @hamidra you need to make sure that you we manually add this migration now to the next release of statemine. cc @joepetrowski

Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

Maybe update the docs of on_runtime_upgrade as well to tell people that it is discouraged to run migrations in there?

@kianenigma
Copy link
Contributor Author

Maybe update the docs of on_runtime_upgrade as well to tell people that it is discouraged to run migrations in there?

Might even be able to generate a compiler warning if it gets implemented inside the pallet 💡

@kianenigma
Copy link
Contributor Author

Okay the warning's not possible without the unstable Diognastics API. If no one has a better idea, then we roll with this for now and call it a day.

@hamidra hamidra assigned hamidra and unassigned hamidra Jan 14, 2022
@hamidra hamidra self-requested a review January 14, 2022 17:38
@kianenigma
Copy link
Contributor Author

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

@paritytech-processbot
Copy link

Merge cancelled due to error. Error: Head SHA changed from 500824a to 899fb3f

@@ -316,13 +316,6 @@ pub mod pallet {
Unapproved,
}

#[pallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is needed for the next statemine/statemint release to add ClassAccount storage to uniques.
Is this PR just a cleanup or we need to get rid of all migrations in the pallets?!

@kianenigma
Copy link
Contributor Author

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

@paritytech-processbot
Copy link

Merge cancelled due to error. Error: Checks failed for edbe7a6

@kianenigma
Copy link
Contributor Author

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

@paritytech-processbot
Copy link

Merge cancelled due to error. Error: Checks failed for 882992e

@bkchr bkchr merged commit 33c518e into master Jan 19, 2022
@bkchr bkchr deleted the kiz-remove-stale-on-runtime-upgrades branch January 19, 2022 19:58
grishasobol pushed a commit to gear-tech/substrate that referenced this pull request Mar 28, 2022
…h#10650)

* Remove all stale on_runtime_upgrade hooks in the runtime

* add docs

* cleanup

* fix warn

* fix more warnings

* fix offence test

* overwrite the damn UItest
AurevoirXavier added a commit to darwinia-network/darwinia-common that referenced this pull request Sep 14, 2022
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
…h#10650)

* Remove all stale on_runtime_upgrade hooks in the runtime

* add docs

* cleanup

* fix warn

* fix more warnings

* fix offence test

* overwrite the damn UItest
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.

propose removing all on_runtime_upgrade logic from the pallets and handling it directly at the runtime level
6 participants