-
Notifications
You must be signed in to change notification settings - Fork 86
Add node and runtime page #369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
78f330c
Add node and runtime page
0xLucca ae22b6b
Apply suggestions from code review
0xLucca f0bb1ea
Apply suggestions
0xLucca b2e7579
Merge branch 'master' into 0xlucca/runtime-and-node
0xLucca c79baae
Update llms.txt
0xLucca 90ae452
Apply suggestions from code review
0xLucca f3d5783
Move above Interoperability
0xLucca ff2a068
Update llms.txt
0xLucca 142d3c5
Merge branch 'master' into 0xlucca/runtime-and-node
0xLucca bc14d93
Update llms.txt
0xLucca 1fd3bb5
update llms
eshaben f59fb2f
Merge remote-tracking branch 'origin/master' into 0xlucca/runtime-and…
eshaben 669c78e
llms
eshaben e60ec43
llms
eshaben File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| --- | ||
| title: Node and Runtime | ||
| description: Learn how Polkadot SDK-based nodes function, how the client and runtime are separated, and how they communicate using SCALE-encoded data. | ||
| --- | ||
|
|
||
| # Node and Runtime | ||
|
|
||
| ## Introduction | ||
|
|
||
| Every blockchain platform relies on a decentralized network of computers, called nodes, that communicate with each other about transactions and blocks. In this context, a node refers to the software running on the connected devices rather than the physical or virtual machines in the network. | ||
|
|
||
| Polkadot SDK-based nodes consist of two main components, each with distinct responsibilities: the client (also called node) and the runtime. | ||
|
|
||
| If the system were a monolithic protocol, any modification would require updating the entire system. Instead, Polkadot achieves true upgradeability by defining an immutable meta-protocol (the client) and a protocol (the runtime) that can be upgraded independently. | ||
|
|
||
| This separation gives the [Polkadot Relay Chain](/polkadot-protocol/architecture/polkadot-chain){target=\_blank} and all connected [parachains](/polkadot-protocol/architecture/parachains){target=\_blank} an evolutionary advantage over other blockchain platforms. | ||
|
|
||
| ## Architectural Principles | ||
|
|
||
| The Polkadot SDK-based blockchain architecture is fundamentally built on two distinct yet interconnected components: | ||
|
|
||
| - **Client (Meta-protocol)** | ||
| - Handles the foundational infrastructure of the blockchain | ||
| - Manages runtime execution, networking, consensus, and other off-chain components | ||
| - Provides an immutable base layer that ensures network stability | ||
| - Upgradable only through hard forks | ||
|
|
||
| - **Runtime (Protocol)** | ||
| - Defines the blockchain's state transition logic | ||
| - Determines the specific rules and behaviors of the blockchain | ||
| - Compiled to WebAssembly (Wasm) for platform-independent execution | ||
| - Capable of being upgraded without network-wide forking | ||
|
|
||
| ### Advantages of this Architecture | ||
|
|
||
| - **Forkless upgrades** - runtime can be updated without disrupting the entire network | ||
| - **Modularity** - clear separation allows independent development of client and runtime | ||
| - **Flexibility** - enables rapid iteration and evolution of blockchain logic | ||
| - **Performance** - WebAssembly compilation provides efficient, cross-platform execution | ||
|
|
||
| ## Node (Client) | ||
|
|
||
| The node, also known as the client, is the core component responsible for executing the Wasm runtime and orchestrating various essential blockchain components. It ensures the correct execution of the state transition function and manages multiple critical subsystems, including: | ||
|
|
||
| - **Wasm execution** - runs the blockchain runtime, which defines the state transition rules | ||
| - **Database management** - stores blockchain data | ||
| - **Networking** - facilitates peer-to-peer communication, block propagation, and transaction gossiping | ||
| - **Transaction pool (Mempool)** - manages pending transactions before they are included in a block | ||
| - **Consensus mechanism** - ensures agreement on the blockchain state across nodes | ||
| - **RPC services** - provides external interfaces for applications and users to interact with the node | ||
|
|
||
| ## Runtime | ||
|
|
||
| The runtime is more than just a set of rules. It's the fundamental logic engine that defines a blockchain's entire behavior. In Polkadot SDK-based blockchains, the runtime represents a complete, self-contained description of the blockchain's state transition function. | ||
|
|
||
| ### Characteristics | ||
|
|
||
| The runtime is distinguished by three key characteristics: | ||
|
|
||
| - **Business logic** - defines the complete application-specific blockchain behavior | ||
| - **WebAssembly compilation** - ensures platform-independent, secure execution | ||
| - **On-chain storage** - stored within the blockchain's state, allowing dynamic updates | ||
|
|
||
| ### Key Functions | ||
|
|
||
| The runtime performs several critical functions, such as: | ||
|
|
||
| - Define state transition rules | ||
| - Implement blockchain-specific logic | ||
| - Manage account interactions | ||
| - Control transaction processing | ||
| - Define governance mechanisms | ||
| - Handle custom pallets and modules | ||
|
|
||
| ## Communication Between Node and Runtime | ||
|
|
||
| The client and runtime communicate exclusively using [SCALE-encoded](/polkadot-protocol/basics/data-encoding){target=\_blank} communication. This ensures efficient and compact data exchange between the two components. | ||
|
|
||
| ### Runtime APIs | ||
|
|
||
| The Runtime API consists of well-defined functions and constants a client assumes are implemented in the Runtime Wasm blob. These APIs enable the client to interact with the runtime to execute blockchain operations and retrieve information. The client invokes these APIs to: | ||
|
|
||
| - Build, execute, and finalize blocks | ||
| - Access metadata | ||
| - Access consensus related information | ||
| - Handle transaction execution | ||
|
|
||
| ### Host Functions | ||
|
|
||
| During execution, the runtime can access certain external client functionalities via host functions. The specific functions the client exposes allow the runtime to perform operations outside the WebAssembly domain. Host functions enable the runtime to: | ||
|
|
||
| - Perform cryptographic operations | ||
| - Access the current blockchain state | ||
| - Handle storage modifications | ||
| - Allocate memory | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.