1

Does code compiled to Wasm enables to forkless runtime upgrades in polkadot substrate development? Someone please explain me how forkless runtime upgrades features enables?

1 Answer 1

2

There are a number of videos which explain how forkless upgrades work in Substrate. Here are just two, but you can find more:

The simple summary of how this works is the following:

  • Inside of every Substrate binary is a Wasm executor.
  • The State Transition Function (aka the Runtime) of a blockchain is developed for, and compiled to Wasm. This is then executed by the Substrate binary (the node).
  • This Runtime is also stored into the blockchain state, and synchronized across the whole network, just like any user balances or other state of the blockchain. When executing a block, we use the Wasm stored in the blockchain state to check if a block is valid.
  • The runtime logic itself has a function to modify the storage of the current runtime code. You can think of this like an "auto-updater".
  • When the storage of the new runtime code is uploaded, all of the nodes on the network synchronize that new state, and use that new code to execute the following blocks.

So the reason we call this a "forkless upgrade" is that a node operator does not need to take any actions in order to run the latest runtime code for a Substrate chain. Just by synchronizing the previous blocks, the state transition function will be automatically upgraded. This avoids many of the human and coordination issues which currently plague the space when blockchain code is updated.

Auto-updating binaries can also do something similar to this, but the security guarantees are much weaker. If the binary itself auto-upgraded, you might worry that one upgrade will sneak in some virus which will affect all the nodes in the ecosystem. Since the "auto-upgrade" is isolated to Wasm, and Wasm is naturally executed in a sandboxed environment, this is much safer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.