-
Notifications
You must be signed in to change notification settings - Fork 5
How to test runtime (try runtime)
Build the binary with the --features try-runtime
flag
cargo build --features try-runtime
Check out what the try-runtime sub-command has to offer
./target/debug/seed try-runtime --help
Here we are interested in the on-runtime-upgrade
command
The on-runtime-upgrade
sub-command contains two additional sub-commands, live
and snap
.
./target/debug/seed try-runtime on-runtime-upgrade --help
In this example we will use the live
sub-command.
./target/debug/seed try-runtime on-runtime-upgrade live --help
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.
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
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).
-
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.
-
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. -
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
- 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