How to make a parachain runtime upgrade
This post should get you through the workflow of making a runtime upgrade for your parachain.
Still valid in 2023!
First you need to have a running parachain on a local or live testnet of some kind. The chain needs to be producing blocks, and you need to have the sudo key of the chain.
Bump version and compile
Make sure to bump up the relevant version in your `runtime/src/lib.rs` file, if its a change to the runtime you need to increase the `impl version`, but if the function of the extrinsics are changed you will also need to bump the `spec version`. More here.
Get and save new runtime wasm blob
Create a build spec to extract the wasm code.
./target/release/parachain-collator build-spec —chain dev > upgraded-chain.json
or in general terms:
./target/release/<name of your target binary> build-spec --chain <any command that targets the correct chain spec, but really shouldn't matter, "dev" may do> > <name of the output file you export the chain spec to>.json
Once the build spec is created containing the updated wasm blob, we find the file and copy the code and save it in its own file we are calling ours Kabocha-release-blov-v0.1.4, you can name yours as you wish.
In live conditions you will want to use SRTOOL to guarantee that the code is in the right place, which makes it easily verifiable by others. https://www.chevdor.com/project/2020/2020-srtool/
Make the upgrade on-chain
Then we need to inform the relay chain we will be running an upgrade, so we send them a hash of our wasm blob via a sudo extrinsic call from our parachain.
Developer > Utilities > Hash data // Hash data is a tab
sudo > parachainSystem > AuthorizeUpgrade
Once that has been submitted correctly then:
extrinsics > parachainSystem > enactAuthorizedUpgrade
Now wait for the parachain to schedule which relayBlockNumber the upgrade will be propagated to all the validators in the relay network. You can find the scheduled blocknumber by going to the relay chain and:
Developer > chain state > paras > futureCodeUpgrades(enter para id)
Hopefully that completed the process for you? : )
If you increased the spec version, you will see the new spec version in the top left of your polkadot-js apps UI screen, once the upgrade is executed.
Parachain upgrade without sudo
If making an upgrade without sudo, you need to put the AuthorizeUpgrade
through (root) refendum, and the enactAuthorizeUpgrade
can be executed by anyone after launch.
All the best,
Ramsey (Decentration)
ramsey@decentration.org