-
Notifications
You must be signed in to change notification settings - Fork 1.1k
migrations: prevent accidentally using unversioned migrations instead of VersionedMigration
#3835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
liamaharon
merged 21 commits into
paritytech:master
from
dastansam:feat/unchecked-on-runtime-upgrade
Apr 2, 2024
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ba4600c
Initial draft
dastansam a13f875
Add prdoc and fix clippy
dastansam 0c20030
Fix prdoc
dastansam 8e3107c
Fix prdoc
dastansam cf6d395
CI fixes
dastansam 928744c
Rename prdoc
dastansam d54f0b0
Remove `try_on_runtime_upgrade`
dastansam 2e99db8
Merge branch 'master' into feat/unchecked-on-runtime-upgrade
dastansam ec4066b
Merge branch 'master' into feat/unchecked-on-runtime-upgrade
dastansam a2bcbd8
Resolve comments
dastansam 6eb02fc
Fix compile errors
dastansam 8141e73
Update more docs
dastansam 2470ee7
Merge branch 'master' into feat/unchecked-on-runtime-upgrade
dastansam 5fd3005
Run fmt on doc
dastansam d3a15b7
Merge branch 'feat/unchecked-on-runtime-upgrade' of github-dastansam:…
dastansam 8f94b39
Merge branch 'master' into feat/unchecked-on-runtime-upgrade
liamaharon ffb3623
Remove `version_unchecked`
dastansam 5f317c2
Merge branch 'feat/unchecked-on-runtime-upgrade' of github-dastansam:…
dastansam 6fb9911
Fix clippy
dastansam 21eb1b2
Update docs
dastansam bfed050
Merge branch 'master' into feat/unchecked-on-runtime-upgrade
liamaharon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 | ||
| # See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json | ||
|
|
||
| title: "migrations: prevent accidentally using inner unversioned migration instead of `VersionedMigration`" | ||
|
|
||
| doc: | ||
| - audience: Runtime Dev | ||
| description: | | ||
| Currently, it is possible to accidentally use inner unversioned migration instead of `VersionedMigration` | ||
| since both implement `OnRuntimeUpgrade`. With this change, we make it clear that `Inner` is not intended | ||
| to be used directly. It is achieved by bounding `Inner` to new trait `UncheckedOnRuntimeUpgrade`, which | ||
| has the same interface as `OnRuntimeUpgrade`, but can not be used directly for runtime upgrade migrations. | ||
|
|
||
| This change will break all existing migrations passed to `VersionedMigration`. Developers should simply change | ||
| those migrations to implement `UncheckedOnRuntimeUpgrade` instead of `OnRuntimeUpgrade`. | ||
|
|
||
| Example: | ||
|
|
||
| ``` | ||
| --- a/path/to/migration.rs | ||
| +++ b/path/to/migration.rs | ||
| @@ -1,7 +1,7 @@ | ||
| -impl<T: Config> OnRuntimeUpgrade for MigrateVNToVM<T> { | ||
| +impl<T: Config> UncheckedOnRuntimeUpgrade for MigrateVNToVM<T> { | ||
| fn on_runtime_upgrade() -> Weight { | ||
| // Migration logic here | ||
| // Adjust the migration logic if necessary to align with the expectations | ||
| // of new `UncheckedOnRuntimeUpgrade` trait. | ||
| 0 | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| crates: | ||
| - name: "pallet-example-single-block-migrations" | ||
dastansam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| bump: "major" | ||
| - name: "pallet-xcm" | ||
| bump: "major" | ||
| - name: "pallet-grandpa" | ||
| bump: "major" | ||
| - name: "pallet-identity" | ||
| bump: "major" | ||
| - name: "pallet-nomination-pools" | ||
| bump: "major" | ||
| - name: "pallet-society" | ||
| bump: "major" | ||
| - name: "frame-support" | ||
| bump: "major" | ||
| - name: "pallet-uniques" | ||
| bump: "major" | ||
| - name: "polkadot-runtime-parachains" | ||
| bump: "major" | ||
| - name: "polkadot-runtime-common" | ||
| bump: "major" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.