Upgrading Your Runtime
Sudo Required
You need access to a sudo account to authorize and apply upgrades!
Every parachain runtime (the code in src/runtime/*) compiles to a single .wasm blob. The relay chain uses this blob to validate state transitions. "Forkless upgrades" simply mean replacing this WebAssembly blob with a new one.
The Parachain Upgrade Process
On a solo chain, you just call system.setCode. On a parachain, it's a two-step process because the relay chain must be notified:
- Authorize:
system.authorizeUpgrade- Notify the relay chain of the impending upgrade (requires the hash of the new runtime). - Apply:
system.applyAuthorizedUpgrade- Upload the new code.
1. Compile your WASM Blob
Compile your runtime in release mode:
The artifact will be at: target/release/wbuild/educhain-runtime/educhain_runtime.compressed.wasm
2. Obtain Runtime Hash
You need the Blake2b_256 hash of your new runtime file.
- Option A: Use this online tool.
- Option B: Upload the file in PolkadotJS UI (under
system.authorizeUpgrade) to see the hash, then copy it.
3. Perform the Upgrade
- Authorize: Call
system.authorizeUpgradewith your new runtime hash.- Note: This is done on the parachain.
- Wait: If using on-demand coretime, order a block to process the transaction. You should see the upgrade queued.
- Apply: Call
system.applyAuthorizedUpgradeand upload your compressed WASM blob (educhain_runtime.compressed.wasm).- Don't forget to order coretime if needed!
Prerequisites
- Clone the modified frontend template.
- Update
src/config/development.jsonwith your node details.
You can use the frontend template's upgrade function, but remember to still use the pallet interactor to authorize the upgrade first.