# Runtime upgrade

{% embed url="<https://wiki.polkadot.network/docs/learn-runtime-upgrades>" %}

You may have encountered the term **"hard fork"** before in the blockchain space. A **hard fork** occurs when a blockchain's logic changes such that nodes that do not include the new changes cannot remain in consensus with nodes that do. Such changes are backward incompatible. Hard forks can be political due to the nature of the upgrades and logistically demanding due to the number (potentially thousands) of nodes in the network that need to upgrade their software.&#x20;

Thus, hard forking is slow, inefficient, and error-prone due to the levels of offline coordination required and, therefore, the propensity to bundle many upgrades into one large-scale event.

* [Link to the DAO hard fork](https://en.wikipedia.org/wiki/The_DAO)

<figure><img src="https://2688244615-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqpKohKlriBQm0I9cc9k5%2Fuploads%2F86LeiuacrNxC7htT2hpR%2FScreenshot%202024-11-25%20at%2012.15.03.png?alt=media&#x26;token=297ab727-66be-48dc-b854-f75d12f038ea" alt=""><figcaption><p>Soft Fork and Hard Fork</p></figcaption></figure>

The usage of [WebAssembly](https://wiki.polkadot.network/docs/learn-wasm) in the Polkadot SDK (the framework powering Polkadot, Kusama and their respective parachains), give the relay chain, its parachains, as well as any other standalone solo chains built with the Polkadot SDK the ability to upgrade their runtime (the chain's "business logic") without a hard fork of the respective network.

* [Link to FRAME runtime upgrades and migrations](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_runtime_upgrades_and_migrations/index.html)

Rather than encoding the runtime in the nodes, Polkadot nodes contain a WebAssembly [execution host](https://wiki.polkadot.network/docs/learn-polkadot-host). They maintain consensus on a very low-level and well-established instruction set. Upgrades can be small, isolated, and very specific by deploying WebAssembly on-chain and having nodes auto-enact the new logic at a particular block height. The runtime is stored on the blockchain itself.&#x20;

<figure><img src="https://2688244615-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqpKohKlriBQm0I9cc9k5%2Fuploads%2FV26hm743Y7JpemNDoA8z%2FScreenshot%202024-11-25%20at%2012.00.19.png?alt=media&#x26;token=0fc794ee-1712-4419-9b60-a3efe28791a7" alt=""><figcaption><p>Forkless Runtime Upgrade in Substrate</p></figcaption></figure>

### Decentralized Polkadot runtime upgrade

Polkadot can upgrade its runtime by upgrading the logic stored on-chain and removes the coordination challenge of requiring thousands of node operators to upgrade in advance of a given block number. Polkadot stakeholders propose and approve upgrades through the [on-chain governance](https://wiki.polkadot.network/docs/learn-polkadot-opengov) system, which also enacts them autonomously once the runtime upgrade referendum is approved through on-chain voting.

As a result of storing the runtime as part of the state, the runtime code itself becomes state sensitive, and calls to runtime can change the runtime code itself. Therefore, the Polkadot Host must always ensure it provides the runtime corresponding to the state in which the entry point has been called.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bootcamp.openguild.wtf/building-a-blockchain-with-polkadot-sdk/polkadot-sdk/substrate/runtime-upgrade.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
