-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[FRAME] Simple multi block migrations #14275
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
frame/support/src/migrations.rs
Outdated
|
||
/// A migration that can proceed in multiple steps. | ||
pub trait SteppedMigration { | ||
fn id(&self) -> BoundedVec<u8, ConstU32<32>>; |
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.
Vec is also fine here, but I have usually seen types like [8u; 32]
being used for such cases.
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.
I also made it generic. But with the new config defaults, we could add some sane default like this 🤔
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.
So far everything LGTM.
Can fn poll()
be done in a separate PR? I presume yes, and perhaps it would be good for someone to start that already.
One important topic related to https://github.com/paritytech/substrate/pull/14275/files#r1211972428 is also tx-pool validation. @ggwpez and I discussed if fn validate_transaction
should also be aware of transaction suspension, and signal the pool that everything is "temporarily" invalid.
@kianenigma am I right to assume we'll want to make it easy to test these with try-runtime-cli? Ideally should be as easy as |
Does this pauses user tx and incoming XCM etc? because otherwise it will be bad. |
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
It pauses non-mandatory extrinsics in frame-executive by checking a flag. For XCM we probably need a suspension and resume hook additionally. But now that Im thinking about this again; this would make it impossible to rescue if one of the migrations errors, since governance requires things like the referenda pallet. |
Good to think about it early, and yes I think it is possible with little effort. I believe |
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
The CI pipeline was cancelled due to failure one of the required jobs. |
The CI pipeline was cancelled due to failure one of the required jobs. |
Is this more or less ready for final review? |
Still first need to merge #14414. I will ping you there for review when its ready. |
Partial paritytech/polkadot-sdk#198 (
on_poll
in #14279).pallet-migrations
This pallet takes a configuration of migrations
Vec<Box<dyn SteppedMigration<…>>>
and executes these in orderon_initialize
. The execution starts on each runtime upgrade. The unique identifiers of each executed migration are stored to prevent accidental re-execution of old ones.While migrations are executed, only
Mandatory
extrinsics and inherents are allowed to execute. This is accomplished by implementingMultiStepMigrator
for the pallet and querying it inframe-executive
before each non-mandatory TX. Concretely this means that these transactions will panic and make a block un-importable. The BlockBuilder respects this limitation and retains all extrinsics in the pool while migrations are ongoing. Once the MBMs are done, these extrinsics will start to be included again. From a user's perspective this just results in an increased time until the TX is included.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 inUpgradeStatusHandler::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
.frame-executive
+BlockBuilder
Executive
now additionally takes anMultiStepMigrator
trait that defaults to()
.IT IS PARAMOUNT TO SET THIS TO THE MIGRATIONS PALLET WHEN YOU DEPLOY IT.
The kitchensink runtime contains an example.
The block builder is aware of the new
after_inherents
function and uses it to figure out the MBM state.As comparison the old and new logic (changes with
+
):Runtime API
BlockBuilder
: Addedafter_inherents
to progress ongoing MBMs and thepoll
hook TBD in FRAME: Add newpoll
hook + various other improvements to pallet hooks #14279.frame-support
SteppedMigration
: A multi-step migration.ExtrinsicSuspenderQuery
: Implemented by themigrations
pallet and used byframe-executive
to check TX suspension.UpgradeStatusHandler
: React to upgrade start, completion and failure.FailedUpgradeHandling
: Decide how to handle a failed upgrade. EitherForceUnstuck
orKeepStuck
.TODO