Skip to content

How to test runtime (try runtime)

Marko Petrlić edited this page Dec 6, 2022 · 2 revisions

Build the binary

Build the binary with the --features try-runtime flag

cargo build --features try-runtime

Check out the sub-command

Check out what the try-runtime sub-command has to offer

./target/debug/seed try-runtime --help

image

Here we are interested in the on-runtime-upgrade command

On-runtime-upgrade

The on-runtime-upgrade sub-command contains two additional sub-commands, live and snap.

./target/debug/seed try-runtime on-runtime-upgrade --help

image

In this example we will use the live sub-command.

./target/debug/seed try-runtime on-runtime-upgrade live --help

image

There are some interesting options that we can use. For example, if instead of getting the latest state we want to take the blockchain state from a specific block, we can use the -a flag. Likewise if we don't want to get all the state data from the remote chain we can specify which pallets to scrap via -p flag.

Demo time

For this demonstration we will get data from one of our own local nodes. Let's start that node

./target/debug/seed --dev

Let's get the data from our local node and execute a runtime upgrade

./target/debug/seed try-runtime --chain dev on-runtime-upgrade live --uri ws://127.0.0.1:9944

image

image

As it is visible, the runtime upgrade was executed without any issues. At the bottom we can see how much weight has been used and we can also see our own custom messages that we have put to be shown during the pre and post phase ( Pre upgrade. and Post upgrade. respectively).

Notes

  1. When you use the try-runtime feature make sure that the spec version match. If the local spec version is greater than the one from where we get the data, a warning will be shown. image

  2. If the spec name doesn't match the client will panic. if --no-spec-name-check flag is used then the spec check will not panic and instead only show a warning. image

  3. Instead of always getting the data from the remote chain we can used the -s flag to create a snapshot that we can then use later.

./target/debug/seed try-runtime --chain dev on-runtime-upgrade live --uri ws://127.0.0.1:9944 -s ./snap
  1. To get the data from Porcini use the following command:
./target/debug/seed try-runtime --chain dev on-runtime-upgrade live --uri wss://porcini.au.rootnet.app:443/archive/ws