-
Notifications
You must be signed in to change notification settings - Fork 732
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
Multi-Block-Migrations, poll
hook and new System callbacks
#1781
Conversation
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]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really great pallet docs 👌
Just a few small comments
Can we enforce this somehow? |
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
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
hi there from Subsquid team! we've discovered that this pr introduces event pointing to non-existing extrinsics which is a "crime" in context of data indexing :) |
Hey i personally use Subsquid, nice work! What is inconsistency that this introduces? You mean an event references an |
yes, exactly this |
Originally we wanted to merge this right after: #3666 |
got it! thanks for the inside |
- 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)
- 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)
- 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)
- 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)
- 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)
- 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
- 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
- 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)
There was a bug found and fixed in the original version of this: #5695 |
🚨 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:
poll
hook for periodic service workon_initialize
andon_finalize
in cases wherepoll
cannot 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_migrations
and configuringSystem::Config::MultiBlockMigrator
to 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::ongoing
and not allowing any transaction in a block, if true.A MBM is defined through trait
SteppedMigration
. A condensed version looks like this:pallet_migrations
can 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
UpgradeStatusHandler
that 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::failed
how to handle this. One follow-up would be to pair this with theSafeMode
pallet 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_block
now returnsExtrinsicInclusionMode
to inform the Block Author whether they can push transactions.Integration
Add it to your runtime implementation of
Core
andBlockBuilder
:2.)
poll
hookA new pallet hook is introduced:
poll
.Poll
is intended to replace mostly all usage ofon_initialize
.The reason for this is that any code that can be called from
on_initialize
cannot be migrated through an MBM. Currently there is no way to statically check this; the implication is to useon_initialize
as rarely as possible.Failing to do so can result in broken storage invariants.
The implementation of the poll hook depends on the
Runtime API
changes that are explained above.3.) Hard-Deadline callbacks
Three new callbacks are introduced and configured on
System::Config
:PreInherents
,PostInherents
andPostTransactions
.These hooks are meant as replacement for
on_initialize
andon_finalize
in 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_system
palletA new memorize storage item
InherentsApplied
is 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
Config
gets five new items:SingleBlockMigrations
this 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 inExecutive
will still work for now but is deprecated).MultiBlockMigrator
this 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.PreInherents
a callback that executes afteron_initialize
but before inherents.PostInherents
a callback that executes after all inherents ran (including MBMs andpoll
).PostTransactions
in symmetry toPreInherents
, this one is called beforeon_finalize
but after all transactions.A sane default is to set all of these to
()
. Example diff suitable for any chain: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-runtime
still works