Test runtime upgrades
The following guide shows how to test runtime upgrades.
Last updated
Was this helpful?
The following guide shows how to test runtime upgrades.
Last updated
Was this helpful?
A key feature of Substrate is its support for forkless upgrades. Testing the blockchain runtime upgrade process is essential to ensure a seamless network transition without disruptions.
To simulate and validate the process of upgrading a blockchain's runtime, the on-runtime-upgrade
executes the hooks of a runtime against the state of a live blockchain or a snapshot.
Hence, there are two subcommands live
and snap
to specify the source of the runtime state.
By running the command pop test on-runtime-upgrade
, you can test the and in a simulated environment.
Before running the migration, you will be prompted to confirm if you want to specify which runtime to run the migration on:
Pop CLI will automatically locate the runtime binary based on the provided
--profile
. Pop CLI will automatically build the runtime if not found.
If not, the migration will be run against the code that's currently running on the remote node or the one stored inside the snapshot file you provide.
Snapshot can be created with
pop test create-snapshot
.
To run the migrations on top of live state manually:
Note: The specified runtime and the remote node's runtime must have the same name and version. If not, the migration will fail. You can add the flag --disable-spec-version-check
and --disable-spec-name-check
to bypass the checks.
After that, you can select the upgrade checks to perform:
A second approach to test migrations is with a snapshot file. First, you need to create a snapshot file of a live network. You can do this by running the following command:
The interactive interface to prompts for the live URI and the path of the snapshot file:
To skip the interactive prompt, use the --uri
and --path
flags:
If the path of snapshot file is not provided, the default name following a format <spec-name>-<spec-version>@<block-hash>.snap
will be used. Note that the remote node must be built with --try-runtime
feature enabled.
Assume there is a snapshot file created with the name example.snap
:
To run migrations with a snapshot manually:
Technical Support
If you choose to specify, you will be prompted to select the runtime to run the migration on. The feature requires your runtime to be .
You'll be asked to enter the URI of a live node and optionally provide a block hash. If a is given, the state will be executed at the specified block hash on the provided network.
🧑🏫 To learn about Polkadot in general, website is a good starting point.
🧑🔧 For technical introduction of the try-runtime
, .
Learn more about and .
Create a question and tag it with ""
Share the StackExchange question in our