Multi-Block-Migrations, poll hook and new System callbacks#1781
Merged
Multi-Block-Migrations, poll hook and new System callbacks#1781
poll hook and new System callbacks#1781Conversation
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
liamaharon
reviewed
Oct 6, 2023
Contributor
liamaharon
left a comment
There was a problem hiding this comment.
Really great pallet docs 👌
Just a few small comments
Contributor
Can we enforce this somehow? |
Member
Author
I think so. I will try to add a check into the |
Co-authored-by: Liam Aharon <[email protected]>
poll hook and new System callbacks
This was referenced Oct 27, 2023
juangirini
reviewed
Oct 27, 2023
juangirini
reviewed
Oct 27, 2023
juangirini
reviewed
Oct 27, 2023
juangirini
reviewed
Oct 27, 2023
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
enddynayn
added a commit
to frequency-chain/frequency
that referenced
this pull request
Jul 26, 2024
- Upgrade Polkadot-sdk to v.1.8.0. - Update weights to reflect the new version. Notable Changes: - [System Callabacks](paritytech/polkadot-sdk#1781) - [Remove of pallet pallet::getter](paritytech/polkadot-sdk#3456) - [Add storage_proof_size host function](paritytech/polkadot-sdk#3002) For more details, please refer to: [Release Notes](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.9.0)
enddynayn
added a commit
to frequency-chain/frequency
that referenced
this pull request
Jul 26, 2024
- Upgrade Polkadot-sdk to v.1.8.0. - Update weights to reflect the new version. Notable Changes: - [System Callabacks](paritytech/polkadot-sdk#1781) - [Remove of pallet pallet::getter](paritytech/polkadot-sdk#3456) - [Add storage_proof_size host function](paritytech/polkadot-sdk#3002) - [Rename of storage version function](https://github.com/paritytech/polkadot-sdk/pull/1554/files#diff-01dc4f43df9baa537f30c6b369525715d596a3068944f38458e9f160d5412d58R306) For more details, please refer to: [Release Notes](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.9.0)
enddynayn
added a commit
to frequency-chain/frequency
that referenced
this pull request
Jul 26, 2024
- Upgrade Polkadot-sdk to v.1.9.0. - Update weights to reflect the new version. Notable Changes: - [System Callabacks](paritytech/polkadot-sdk#1781) - [Remove of pallet pallet::getter](paritytech/polkadot-sdk#3456) - [Add storage_proof_size host function](paritytech/polkadot-sdk#3002) - [Rename of storage version function](https://github.com/paritytech/polkadot-sdk/pull/1554/files#diff-01dc4f43df9baa537f30c6b369525715d596a3068944f38458e9f160d5412d58R306) For more details, please refer to: [Release Notes](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.9.0)
enddynayn
added a commit
to frequency-chain/frequency
that referenced
this pull request
Jul 26, 2024
- Upgrade Polkadot-sdk to v.1.9.0. - Update weights to reflect the new version. Notable Changes: - [System Callbacks](paritytech/polkadot-sdk#1781) - [Remove of pallet pallet::getter](paritytech/polkadot-sdk#3456) - [Add storage_proof_size host function](paritytech/polkadot-sdk#3002) - [Rename of storage version function](https://github.com/paritytech/polkadot-sdk/pull/1554/files#diff-01dc4f43df9baa537f30c6b369525715d596a3068944f38458e9f160d5412d58R306) For more details, please refer to: [Release Notes](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.9.0)
enddynayn
added a commit
to frequency-chain/frequency
that referenced
this pull request
Jul 26, 2024
- Update weights to reflect the new version. Notable Changes: - [System Callbacks](paritytech/polkadot-sdk#1781) For more details, please refer to: [Release Notes](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.10.0) issue-1922
enddynayn
added a commit
to frequency-chain/frequency
that referenced
this pull request
Jul 30, 2024
- Update weights to reflect the new version. Notable Changes: - [System Callbacks](paritytech/polkadot-sdk#1781) - [Remove experimental flag](https://github.com/paritytech/polkadot-sdk/pull/3654/files) - [Remove pallet::getter macr](paritytech/polkadot-sdk#3350) - [Refactor APIs](https://github.com/paritytech/polkadot-sdk/pull/3817/files#diff-b02373af4015a8ebdf3a3f5be9ea0ce555b6e45331872e0465fd2f488177d383) For more details, please refer to: [Release Notes](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.10.0) issue-1922
4 tasks
This was referenced Sep 2, 2024
rustadot
pushed a commit
to rustadot/recurrency
that referenced
this pull request
Sep 5, 2024
- Upgrade Polkadot-sdk to v.1.9.0. - Update weights to reflect the new version. Notable Changes: - [System Callbacks](paritytech/polkadot-sdk#1781) - [Remove of pallet pallet::getter](paritytech/polkadot-sdk#3456) - [Add storage_proof_size host function](paritytech/polkadot-sdk#3002) - [Rename of storage version function](https://github.com/paritytech/polkadot-sdk/pull/1554/files#diff-01dc4f43df9baa537f30c6b369525715d596a3068944f38458e9f160d5412d58R306) For more details, please refer to: [Release Notes](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.9.0)
Member
Author
|
There was a bug found and fixed in the original version of this: #5695 |
aurexav
added a commit
to darwinia-network/darwinia
that referenced
this pull request
Dec 18, 2024
This was referenced Aug 7, 2025
github-merge-queue bot
pushed a commit
that referenced
this pull request
Sep 2, 2025
…e_upgrade (#9451) Recently, when moving the single block migrations from `frame_executive::Executive` to `SingleBlockMigrations` in `frame_system::Config`, I noticed that `try_runtime_upgrade` was ignoring the `SingleBlockMigrations` defined in frame_system. More context at polkadot-fellows/runtimes#844 Based on PR #1781 and [PRDoc](https://github.com/paritytech/polkadot-sdk/blob/beb9030b249cc078b3955232074a8495e7e0302a/prdoc/1.9.0/pr_1781.prdoc#L29), the new way for providing the single block migrations should be through `SingleBlockMigrations` in `frame_system::Config`. Providing them from `frame_executive::Executive` is still supported, but from what I understood is or will be deprecated. > `SingleBlockMigrations` this is the new way of configuring migrations that run in a single block. Previously they were defined as last generic argument of Executive. This shift is brings all central configuration about migrations closer into view of the developer (migrations that are configured in Executive will still work for now but is deprecated). ## Follow-up Changes Will try to open a pull request tomorrow for deprecating the use of `OnRuntimeUpgrade` in `frame_executive::Executive`.
paritytech-release-backport-bot bot
pushed a commit
that referenced
this pull request
Sep 2, 2025
…e_upgrade (#9451) Recently, when moving the single block migrations from `frame_executive::Executive` to `SingleBlockMigrations` in `frame_system::Config`, I noticed that `try_runtime_upgrade` was ignoring the `SingleBlockMigrations` defined in frame_system. More context at polkadot-fellows/runtimes#844 Based on PR #1781 and [PRDoc](https://github.com/paritytech/polkadot-sdk/blob/beb9030b249cc078b3955232074a8495e7e0302a/prdoc/1.9.0/pr_1781.prdoc#L29), the new way for providing the single block migrations should be through `SingleBlockMigrations` in `frame_system::Config`. Providing them from `frame_executive::Executive` is still supported, but from what I understood is or will be deprecated. > `SingleBlockMigrations` this is the new way of configuring migrations that run in a single block. Previously they were defined as last generic argument of Executive. This shift is brings all central configuration about migrations closer into view of the developer (migrations that are configured in Executive will still work for now but is deprecated). ## Follow-up Changes Will try to open a pull request tomorrow for deprecating the use of `OnRuntimeUpgrade` in `frame_executive::Executive`. (cherry picked from commit 7753112)
paritytech-release-backport-bot bot
pushed a commit
that referenced
this pull request
Sep 2, 2025
…e_upgrade (#9451) Recently, when moving the single block migrations from `frame_executive::Executive` to `SingleBlockMigrations` in `frame_system::Config`, I noticed that `try_runtime_upgrade` was ignoring the `SingleBlockMigrations` defined in frame_system. More context at polkadot-fellows/runtimes#844 Based on PR #1781 and [PRDoc](https://github.com/paritytech/polkadot-sdk/blob/beb9030b249cc078b3955232074a8495e7e0302a/prdoc/1.9.0/pr_1781.prdoc#L29), the new way for providing the single block migrations should be through `SingleBlockMigrations` in `frame_system::Config`. Providing them from `frame_executive::Executive` is still supported, but from what I understood is or will be deprecated. > `SingleBlockMigrations` this is the new way of configuring migrations that run in a single block. Previously they were defined as last generic argument of Executive. This shift is brings all central configuration about migrations closer into view of the developer (migrations that are configured in Executive will still work for now but is deprecated). ## Follow-up Changes Will try to open a pull request tomorrow for deprecating the use of `OnRuntimeUpgrade` in `frame_executive::Executive`. (cherry picked from commit 7753112)
github-merge-queue bot
pushed a commit
that referenced
this pull request
Sep 12, 2025
#9638) Follow-up of #9451 Based on PR #1781 and [PRDoc](https://github.com/paritytech/polkadot-sdk/blob/beb9030b249cc078b3955232074a8495e7e0302a/prdoc/1.9.0/pr_1781.prdoc#L29), the new way for providing the single block migrations should be through `SingleBlockMigrations` in `frame_system::Config`. Providing them from `frame_executive::Executive` is still supported, but is deprecated. > `SingleBlockMigrations` this is the new way of configuring migrations that run in a single block. Previously they were defined as last generic argument of Executive. This shift is brings all central configuration about migrations closer into view of the developer (migrations that are configured in Executive will still work for now but is deprecated). `Executive` docs will look like: <img width="800" alt="image" src="https://github.com/user-attachments/assets/6f285c26-5c61-4350-a41b-aebc6b856601" /> Companion PR in polkadot-fellows/runtimes#844
bkchr
pushed a commit
to polkadot-fellows/runtimes
that referenced
this pull request
Oct 12, 2025
…nfig (#844) **Depends on** paritytech/polkadot-sdk#9451 --- Based on PR paritytech/polkadot-sdk#1781 and [PRDoc](https://github.com/paritytech/polkadot-sdk/blob/beb9030b249cc078b3955232074a8495e7e0302a/prdoc/1.9.0/pr_1781.prdoc#L29), the new way for providing the single block migrations should be through `SingleBlockMigrations` in `frame_system::Config`. Providing them from `frame_executive::Executive` is still supported, but from what I understood is or will be deprecated. > `SingleBlockMigrations` this is the new way of configuring migrations that run in a single block. Previously they were defined as last generic argument of Executive. This shift is brings all central configuration about migrations closer into view of the developer (migrations that are configured in Executive will still work for now but is deprecated). Will also open a PR on polkadot-sdk side, adding a deprecation warning.
alvicsam
pushed a commit
that referenced
this pull request
Oct 17, 2025
…e_upgrade (#9451) Recently, when moving the single block migrations from `frame_executive::Executive` to `SingleBlockMigrations` in `frame_system::Config`, I noticed that `try_runtime_upgrade` was ignoring the `SingleBlockMigrations` defined in frame_system. More context at polkadot-fellows/runtimes#844 Based on PR #1781 and [PRDoc](https://github.com/paritytech/polkadot-sdk/blob/beb9030b249cc078b3955232074a8495e7e0302a/prdoc/1.9.0/pr_1781.prdoc#L29), the new way for providing the single block migrations should be through `SingleBlockMigrations` in `frame_system::Config`. Providing them from `frame_executive::Executive` is still supported, but from what I understood is or will be deprecated. > `SingleBlockMigrations` this is the new way of configuring migrations that run in a single block. Previously they were defined as last generic argument of Executive. This shift is brings all central configuration about migrations closer into view of the developer (migrations that are configured in Executive will still work for now but is deprecated). ## Follow-up Changes Will try to open a pull request tomorrow for deprecating the use of `OnRuntimeUpgrade` in `frame_executive::Executive`.
alvicsam
pushed a commit
that referenced
this pull request
Oct 17, 2025
#9638) Follow-up of #9451 Based on PR #1781 and [PRDoc](https://github.com/paritytech/polkadot-sdk/blob/beb9030b249cc078b3955232074a8495e7e0302a/prdoc/1.9.0/pr_1781.prdoc#L29), the new way for providing the single block migrations should be through `SingleBlockMigrations` in `frame_system::Config`. Providing them from `frame_executive::Executive` is still supported, but is deprecated. > `SingleBlockMigrations` this is the new way of configuring migrations that run in a single block. Previously they were defined as last generic argument of Executive. This shift is brings all central configuration about migrations closer into view of the developer (migrations that are configured in Executive will still work for now but is deprecated). `Executive` docs will look like: <img width="800" alt="image" src="https://github.com/user-attachments/assets/6f285c26-5c61-4350-a41b-aebc6b856601" /> Companion PR in polkadot-fellows/runtimes#844
8 tasks
8 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🚨 BUG alert: Please ensure to apply this patch when you want to integrate this feature: #5695 🚨
This MR is the merge of paritytech/substrate#14414 and paritytech/substrate#14275. It implements RFC#13, closes #198.
It introduces three major topicals:
pollhook for periodic service workon_initializeandon_finalizein cases wherepollcannot be usedand some more general changes to FRAME.
The changes for each topical span over multiple crates. They are listed in topical order below.
1.) Multi-Block-Migrations
Multi-Block-Migrations are facilitated by creating
pallet_migrationsand configuringSystem::Config::MultiBlockMigratorto point to it. Executive picks this up and triggers one step of the migrations pallet per block.The chain is in lockdown mode for as long as an MBM is ongoing. Executive does this by polling
MultiBlockMigrator::ongoingand not allowing any transaction in a block, if true.A MBM is defined through trait
SteppedMigration. A condensed version looks like this:pallet_migrationscan be configured with an aggregated tuple of these migrations. It then starts to migrate them one-by-one on the next runtime upgrade.Two things are important here:
System::Config, otherwise it is not used.The pallet supports an
UpgradeStatusHandlerthat can be used to notify external logic of upgrade start/finish (for example to pause XCM dispatch).Error recovery is very limited in the case that a migration errors or times out (exceeds its
max_steps). Currently the runtime dev can decide inFailedMigrationHandler::failedhow to handle this. One follow-up would be to pair this with theSafeModepallet and enact safe mode when an upgrade fails, to allow governance to rescue the chain. This is currently not possible, since governance is notMandatory.Runtime API
Core:initialize_blocknow returnsExtrinsicInclusionModeto inform the Block Author whether they can push transactions.Integration
Add it to your runtime implementation of
CoreandBlockBuilder:2.)
pollhookA new pallet hook is introduced:
poll.Pollis intended to replace mostly all usage ofon_initialize.The reason for this is that any code that can be called from
on_initializecannot be migrated through an MBM. Currently there is no way to statically check this; the implication is to useon_initializeas rarely as possible.Failing to do so can result in broken storage invariants.
The implementation of the poll hook depends on the
Runtime APIchanges that are explained above.3.) Hard-Deadline callbacks
Three new callbacks are introduced and configured on
System::Config:PreInherents,PostInherentsandPostTransactions.These hooks are meant as replacement for
on_initializeandon_finalizein cases where the code that runs cannot be moved topoll.The reason for this is to make the usage of HD-code (hard deadline) more explicit - again to prevent broken invariants by MBMs.
4.) FRAME (general changes)
frame_systempalletA new memorize storage item
InherentsAppliedis added. It is used by executive to track whether inherents have already been applied. Executive and can then execute the MBMs directly between inherents and transactions.The
Configgets five new items:SingleBlockMigrationsthis is the new way of configuring migrations that run in a single block. Previously they were defined as last generic argument ofExecutive. This shift is brings all central configuration about migrations closer into view of the developer (migrations that are configured inExecutivewill still work for now but is deprecated).MultiBlockMigratorthis can be configured to an engine that drives MBMs. One example would be thepallet_migrations. Note that this is only the engine; the exact MBMs are injected into the engine.PreInherentsa callback that executes afteron_initializebut before inherents.PostInherentsa callback that executes after all inherents ran (including MBMs andpoll).PostTransactionsin symmetry toPreInherents, this one is called beforeon_finalizebut after all transactions.A sane default is to set all of these to
(). Example diff suitable for any chain:@@ impl frame_system::Config for Test { type MaxConsumers = ConstU32<16>; + type SingleBlockMigrations = (); + type MultiBlockMigrator = (); + type PreInherents = (); + type PostInherents = (); + type PostTransactions = (); }An overview of how the block execution now looks like is here. The same graph is also in the rust doc.
Inherent Order
Moved to #2154
TODO
try-runtimestill works