paritytech / substrate

Substrate: The platform for blockchain innovators
Apache License 2.0
8.39k stars 2.65k forks source link

try-runtime-cli: support testing new multi-block migrations #14291

Closed liamaharon closed 1 year ago

liamaharon commented 1 year ago
          @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 `on-runtime-upgrade`, maybe make it auto-mine blocks until all multi-block migrations are complete & provide a hook that runs afterwards?

Originally posted by @liamaharon in https://github.com/paritytech/substrate/issues/14275#issuecomment-1570824518

Kian response:

Good to think about it early, and yes I think it is possible with little effort. I believe follow-chain will already do everything needed to test an MBM?


I don't think follow-chain is necessarily a good solution.

  1. We need to call each upgrade's post_upgrade hook once its migration has finished executing.
  2. We can't use snapshots with follow-chain, making development iterations much slower and requiring a live node running. Some of the plumbing in fast-forward is might be a better solution here?

Ideally, I think we'd be able to run on-runtime-upgrade like usual and it'll fast-forward until all migrations have completed, and then run a post_migration hook. Unfortunately fast-forward is not production ready due to the inherents issue, it seems this feature makes fixing the inherents issue much higher priority now?

ggwpez commented 1 year ago

I think fast-forward is good, since follow-chain applies extrinsics; those get rejected while MBMs are active anyway. (and is slow)
Just calling on_runtime_upgrade and then on_initialize repeatedly until event UpgradeCompleted | UpgradeFailed is received is enough AFAIK.

liamaharon commented 1 year ago

Yeah, calling on_runtime_upgrade and then on_initialize repeatedly is a better idea and will be easier to implement, thanks @ggwpez 👌

What do you think about adding a try-runtime feature gated method to the migrations pallet called something like run_to_completion that does that? That way, the cli tool needs not be concerned about the mechanism that migrations progress.

liamaharon commented 1 year ago

Moved to https://github.com/paritytech/try-runtime-cli/issues/17