How to make a parachain runtime upgrade

This post should get you through the workflow of making a runtime upgrade for your parachain.

Ramsey Ajram (Decentration)
3 min readFeb 24, 2022

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.

Copy the wasm blob be sure to not include the quotation marks

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 
paste blob into field
sudo > parachainSystem > AuthorizeUpgrade
enactAuthorize

Once that has been submitted correctly then:

extrinsics > parachainSystem > enactAuthorizedUpgrade
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 enactAuthorizeUpgradecan be executed by anyone after launch.

All the best,

Ramsey (Decentration)

ramsey@decentration.org

--

--

Ramsey Ajram (Decentration)
Ramsey Ajram (Decentration)

Written by Ramsey Ajram (Decentration)

Decentralising the web. Stewarding new paradigms. Engineering and product.

No responses yet