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

Remove xcm on_runtime_upgrade pallet hook #7235

Merged
merged 15 commits into from
Aug 5, 2023

Conversation

pgherveou
Copy link
Contributor

Move the pallet on_runtime_upgrade hook logic into migration.rs

xcm/pallet-xcm/src/migration.rs Outdated Show resolved Hide resolved
@bkchr bkchr added the E0-runtime_migration PR introduces code that might require downstream chains to run a runtime upgrade. label May 17, 2023
Co-authored-by: Bastian Köcher <git@kchr.de>
@pgherveou pgherveou 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 17, 2023
@pgherveou pgherveou requested a review from KiChjang June 5, 2023 12:23
@@ -685,12 +685,6 @@ pub mod pallet {
}
weight_used
}
fn on_runtime_upgrade() -> Weight {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not 100% sure if the migration has already happened in all of the runtimes, but removing this here without adding the migration back to the runtimes would prevent any migration from happening. Have you checked what the onchain storage version is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's hard to check for all of them. Every migration should be tested with try-runtime which will yell at you if there is a storage mismatch for any pallet

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a list of runtimes we can check off before merging this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially did that in this PR, but after reviews decided to only apply it to the chain I was upgrading (contracts-rococo)
paritytech/cumulus#2570, (see also other earlier commit where I apply it to all runtimes paritytech/cumulus@d890570)

The reasoning is that adding a migration that have already been applied, adds some unnecessary bloat to the wasm runtime, so the best practice should be to test with try-runtime and see what needs to be included.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the basic ones that we care about the most would do, e.g. polkadot, kusama, westend, rococo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

following up, here since @vstam1 is trying to close all pending issues before the repo migration.
This logic is moved to the Migration Struct that should be included in the frame_executive::Executive when a migration needs to be passed.

My understanding is that on_runtime_upgrade hooks are deprecated and the migration logic should move out of the pallet into these Migration structs so that they can be controlled and configured by runtime authors.

This is why I opened this PR in the first place, so that pallet_xcm adheres to this new conventions and integrate better with tools like try-runtime

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but what we're saying here in this comment is whether or not the existing runtimes that we care about is already on storage version 1.

Copy link
Contributor Author

@pgherveou pgherveou Aug 3, 2023

Choose a reason for hiding this comment

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

I don't think this should impact whether or not we merge this PR?
The code here was moved to MigrateToV1.
If one runtime is not on v1 then it should run the upgrade by passing MigrateToV1 to frame_executive
if it's already on V1, then it should not use MigrateToV1.
In both scenarios dry-running the migration with try-runtime will tell you if something is missing or superfluous.

Feel free to close to unblock the repo migration if I got that wrong

xcm/pallet-xcm/src/migration.rs Outdated Show resolved Hide resolved
xcm/pallet-xcm/src/migration.rs Outdated Show resolved Hide resolved
@@ -685,12 +685,6 @@ pub mod pallet {
}
weight_used
}
fn on_runtime_upgrade() -> Weight {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a list of runtimes we can check off before merging this?

xcm/pallet-xcm/src/migration.rs Outdated Show resolved Hide resolved
Comment on lines +40 to +43
if StorageVersion::get::<Pallet<T>>() != 0 {
log::warn!("skipping v1, should be removed");
return 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 will work much better with try-runtime-cli. thanks. 👌

@pgherveou
Copy link
Contributor Author

bot merge

@paritytech-processbot paritytech-processbot bot merged commit c7f58c1 into master Aug 5, 2023
3 checks passed
@paritytech-processbot paritytech-processbot bot deleted the pg/move-xcm-upgrade branch August 5, 2023 16:09
s0me0ne-unkn0wn pushed a commit that referenced this pull request Aug 15, 2023
* move migration stuffs

* Apply suggestions from code review

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

* Fix test

* fix

* lint

* fix lint

* rm extra space

* fix lint

* PR review

* fixes

* use saturating_accrue in fn

* fix test

---------

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. E0-runtime_migration PR introduces code that might require downstream chains to run a runtime upgrade.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants