MBM `try-runtime` support (#4251)
# MBM try-runtime support This MR adds support to the try-runtime trait such that the try-runtime-CLI will be able to support MBM testing [here](https://github.com/paritytech/try-runtime-cli/pull/90). It mainly adds two feature-gated hooks to the `SteppedMigration` hook to facilitate testing. These hooks are named `pre_upgrade` and `post_upgrade` and have the same signature and implications as for single-block migrations. ## Integration To make use of this in your Multi-Block-Migration, just implement the two new hooks and test pre- and post-conditions in them: ```rust #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result<Vec<u8>, frame_support::sp_runtime::TryRuntimeError> { // ... } #[cfg(feature = "try-runtime")] fn post_upgrade(prev: Vec<u8>) -> Result<(), frame_support::sp_runtime::TryRuntimeError> { // ... } ``` You may return an error or panic in these functions to indicate failure. This will then show up in the try-runtime-CLI and can be used in CI for testing. Changes: - Adds `try-runtime` gated methods `pre_upgrade` and `post_upgrade` on `SteppedMigration` - Adds `try-runtime` gated methods `nth_pre_upgrade` and `nth_post_upgrade` on `SteppedMigrations` - Modifies `pallet_migrations` implementation to run pre_upgrade and post_upgrade steps at the appropriate times, and panic in the event of migration failure. --------- Signed-off-by:Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Signed-off-by:
georgepisaltu <george.pisaltu@parity.io> Co-authored-by:
Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by:
claravanstaden <claravanstaden64@gmail.com> Co-authored-by:
ggwpez <ggwpez@users.noreply.github.com> Co-authored-by:
georgepisaltu <george.pisaltu@parity.io>
parent
286af23b
Showing
- .gitlab/pipeline/test.yml 24 additions, 0 deletions.gitlab/pipeline/test.yml
- Cargo.lock 1 addition, 0 deletionsCargo.lock
- cumulus/parachains/runtimes/people/people-rococo/src/lib.rs 1 addition, 0 deletionscumulus/parachains/runtimes/people/people-rococo/src/lib.rs
- prdoc/pr_4251.prdoc 79 additions, 0 deletionsprdoc/pr_4251.prdoc
- substrate/frame/examples/multi-block-migrations/src/migrations/v1/mod.rs 43 additions, 0 deletions.../examples/multi-block-migrations/src/migrations/v1/mod.rs
- substrate/frame/migrations/Cargo.toml 1 addition, 0 deletionssubstrate/frame/migrations/Cargo.toml
- substrate/frame/migrations/src/lib.rs 57 additions, 7 deletionssubstrate/frame/migrations/src/lib.rs
- substrate/frame/migrations/src/mock_helpers.rs 33 additions, 0 deletionssubstrate/frame/migrations/src/mock_helpers.rs
- substrate/frame/migrations/src/tests.rs 97 additions, 1 deletionsubstrate/frame/migrations/src/tests.rs
- substrate/frame/support/src/migrations.rs 94 additions, 2 deletionssubstrate/frame/support/src/migrations.rs
- substrate/frame/support/src/traits/try_runtime/mod.rs 2 additions, 2 deletionssubstrate/frame/support/src/traits/try_runtime/mod.rs
Please register or sign in to comment