One of Substrate's main features is its support for runtime chain upgrades without forking the code base. Compared to other blockchain frameworks, Substrate makes it easy to add new features to the logic that defines how a chain runs. This is possible because the runtime definition is part of the chain state, meaning it can be validated and set through a chain's usual consensus mechanisms.
This page describes how to upgrade the runtime when using sqnc-node.
A local checkout of sqnc-node that is successfully running and creating blocks.
In a terminal window separate from the currently running sqnc-node, checkout a branch of a newer runtime that includes any desired changes. For the upgrade to work, spec_version in runtime/src/lib.rs must be set to a higher number than the current runtime. The current runtime version is also visible in the top-left of Polkadot Substrate Portal.
Compile the new runtime with cargo build --release. The --release command generates a smaller build artifact for submitting to the network. Artifacts are generated in target/release/wbuild/sqnc-node-runtime:
sqnc_node_runtime.compact.compressed.wasm
sqnc_node_runtime.compact.wasm
sqnc_node_runtime.wasm
The compiled wasm artifact containing the runtime logic can be submitted to the running chain either as an admin user, using Substrate's sudo pallet, or through a vote, using a custom sqnc pallet called doas alongside Substrate's collective pallet.
If a chain has an agreed administrator account, that account can be used to upgrade the runtime with sudo. This example uses the default Alice account that's part of the membership of sqnc-node when run in dev mode.
- Open Polkadot Substrate Portal in a browser and connect to the local node.
- Go to
Developer->Sudo. - Set the call to
systemandsetCode(code). - Click
file uploadand uploadsqnc_node_runtime.compact.compressed.wasm. - Click
with weight overrideand set unchecked weight to1.
- Click
Submit Sudo UncheckedthenSign and Submit. - If the transaction is successful the spec version in the top-left will have changed to match the new runtime version. The runtime is upgraded!
Instead of requiring an administrator, the doas pallet may be used in conjunction with the collective pallet to enable sudo-like functionality where a majority of a chain's membership must agree to perform a Root call, such as a runtime upgrade.
- Open Polkadot Substrate Portal in a browser and connect to the local node.
- Go to
Governance->Tech. comm->Proposals. ClickSubmit proposal - Propose from any account e.g.
Bob. As the transaction will be voted on, the submitter doesn't have to be an admin. - Keep threshold as
2. This is the minimum number of votes required for approval. - Propose the
doaspallet and thedoasRootUncheckedWeight(call, weight)function. This is necessary to bypass weight checking that would normally cause a transaction block as large as this to fail. - Set the call to
systemandsetCode(code). - Click
file uploadand uploadsqnc_node_runtime.compact.compressed.wasm. Weightcan remain as0.
- Click
SubmitthenSign and Submit. - Click
Voteand submitVote Ayetwice, using any two accounts. - Now the the threshold is met, click
Closeon the proposal, thenSubmit->Sign and Submit. - If the transaction is successful the spec version in the top-left will have changed to match the new runtime version. The runtime is upgraded!


