Polkadot Parachain Explained
Polkadot is a heterogeneous multi-chain framework that allows specialized blockchains called parachains to connect to and take advantage of its security and cross-chain communication features. Parachains are application-specific blockchains that can have their own tokens and optimize their blockchain for specific use cases.
The key innovation of Polkadot is its relay chain which coordinates consensus and cross-chain communication between the parachains. Parachains lease slots on the relay chain in auctions to gain connectivity to the Polkadot ecosystem. This allows parachains to focus on their specific use case rather than building their own blockchain infrastructure from scratch.
Parachain Basics
A parachain is a blockchain that derives security from Polkadot's relay chain rather than securing itself. Parachains connect to the relay chain via collators. Collators maintain full nodes of the parachain and collect parachain transactions from users to produce new blocks.
The key components of a parachain are:
- State Transition Function (STF) - Defines valid state transitions and the rules for processing transactions
- Collators - Maintain full nodes and produce new parachain blocks
- Relay Chain Validators - Verify parachain blocks and provide security
- Cumulus Runtime Module - Allows interaction with the relay chain
Parachains have their own sovereign state transition function and can have their own tokens. This allows them to be optimized for specific goals like decentralised finance, identity, supply chain tracking etc.
Parachains benefit from the shared security provided by the relay chain's validators. The validators sample parachain blocks and verify them against the parachain's STF. This removes the need for every blockchain project to bootstrap its own validator set.
Connecting to the Relay Chain
In order to take advantage of the shared security and cross-chain communication provided by Polkadot, parachains must lease a slot to connect to the relay chain.
There is a limited number of slots on the relay chain available to be leased. Parachain teams participate in candle auctions to bid for these scarce slots. Teams bid with the native DOT token locked for increasing periods of time. The highest bidders win the slots which they lease for up to 2 years.
Once connected, the parachain benefits from the validator set of the Polkadot relay chain verifying its blocks. The parachain validators no longer need to directly incentivise validators which removes a major bootstrap challenge faced by new blockchains.
The lease also gives the parachain access to the entire Polkadot ecosystem including cross-chain transfers, shared security, and interoperability with other chains.
Parachain Block Production
Parachain blocks are produced independently of the relay chain by parachain collators. The collators maintain full archival nodes of the parachain blockchain and gather transactions from users.
The collators produce parachain blocks that execute the transactions against the parachain's state transition function. This updates the parachain's state.
The block production process for a parachain is:
- Collators gather parachain transactions from users
- Collators execute transactions against parachain STF to get new state
- Collators create parachain block with new state and transactions
- Collators pass parachain block to Relay Chain validators
This process executes transactions and updates the state of the parachain. The updated state is encapsulated in the parachain block which is then passed to the relay chain validators for verification.
Parachain Block Verification
The Polkadot relay chain secures the connected parachains by verifying parachain blocks. The validators sample parachain blocks and validate that they are valid under the parachain's state transition function.
The verification process for parachain blocks is:
- Parachain collators submit parachain block to relay chain
- Relay chain validators sample parachain block
- Validators verify block state transition is valid
- Validators execute transactions against parachain state
- Validators confirm block is valid
- Relay chain finalizes parachain block
This verifies that the new parachain block state is valid given the old parachain state. Invalid state transitions that break the rules of the parachain's STF will be rejected.
Once the relay chain finalizes the new parachain block, its updated state is confirmed across the Polkadot ecosystem.
Cross-Chain Communication
A key benefit of connecting to the Polkadot relay chain is cross-chain communication between parachains. This allows decentralized apps to be composed across multiple specialized blockchains.
There are two main cross-chain communication schemes that parachains can utilize:
- XCMP (Cross-Chain Message Passing) - Send arbitrary data between parachains
- XCM (Cross-Consensus Message format) - Transfer tokens between parachains
These cross-chain formats allow trustless communication between parachains. For example an identity parachain could pass an identity proof to a DeFi parachain for automated loan approval. XCMP provides asynchronous communication while XCM allows transfer of value.
The trustlessness comes from the sender chain submitting the cross-chain message in a transaction. This transaction is validated by the relay chain to ensure validity before passing it to the destination parachain.
This interchain composability is a major advantage of becoming a parachain over an isolated sovereign blockchain. Building on Polkadot allows blockchain projects to focus on their specific use case while still being able to interoperate with the whole ecosystem.
Parachain Slot Economics
There are a limited number of parachain slots available to lease on the Polkadot relay chain. The scarcity of slots combined with high demand creates an economic model to allocate slots efficiently.
Parachain slots are leased for up to 2 years via an unpermissioned candle auction. Anyone can bid on a slot by locking up DOT tokens for a slot lease period. The highest bidders win the auctions and get to lease slots.
If demand for slots goes up, then bids will increase accordingly until the point where the cost outweighs the benefit of securing a slot. This allows the market to determine the fair price for a scarce resource.
At the end of the lease period, DOT is returned and projects can choose to bid again to retain their slot. If they lose the slot or choose not to bid again, then their parachain will disconnect from the relay chain.
The parachain slot model aligns incentives around efficient allocation of scarce slots to the projects that value them most. This prevents waste through high throughput applications subsidizing low value ones on a shared chain.
Parachain Development Kits
In order to simplify development of parachains, Polkadot provides parachain development kits (PDKs) that include most of the functionality needed to build a custom parachain.
The key PDK provided is Rococo which provides a local environment for testing parachain functionality. Rococo includes:
- Local relay chain with validators
- Local parachains connected to relay
- Support for testing XCMP and XCM
- Faucet for test tokens
By basig a parachain on Rococo, developers can focus on the state transition function for their specific use case rather than low level blockchain development.
There are also helpful frameworks like Cumulus that provide much of the parachain machinery like collators, consensus clients etc. Cumulus makes it easy to connect a custom runtime to the relay chain.
These development kits significantly lower the barrier to creating specialized parachains and integrating into the Polkadot ecosystem.
Governance
Polkadot has an advanced governance system that allows the stakeholders in the network to control operational parameters and guide the development roadmap.
There are several layers of governance including:
- Relay Chain Council - Elected body to represent passive stakeholders
- Referenda - On-chain voting to approve changes
- Signals - Indicative votes to gauge sentiment
Parachains follow the governance processes of the relay chain when it relates to Polkadot level changes. But they are still sovereign blockchains and govern their own internal logic.
For example, the DOT holders would vote on relay chain upgrades that affect security. But each parachain community governs how their specific chain should upgrade over time.
This split governance model maintains autonomy at the parachain level while still allowing coordination across Polkadot on key issues like security and upgrades.
Parachains allow the blockchain ecosystem to specialize into many sovereign chains that focus on specific use cases. The Polkadot relay chain then sews these together into an interoperable internet of blockchains.
Instead of competing for dominance as general purpose global chains, parachains embrace interoperability and composability. This "lego block" approach allows decentralized apps to spread across multiple specialized blockchains each with their own tokens and governance.
The relay chain model drastically lowers the barriers to creating valuable new blockchains.
The shared security, cross-chain composability and liquid token markets provided by Polkadot allow builders to focus on innovation rather than bootstrapping yet another siloed blockchain.
This vision of heterogeneous interconnected blockchains offers a promising path to scaling innovation in the Web3 ecosystem while avoiding the bottlenecks of monolithic "world computer" smart contract platforms.