Written by: Phil Lucsok
Translation: PolkaWorld
Substrate has reached the major milestone of version 2.0. The blockchain framework now includes off-chain workers and more than 70 combinable modules, and has laid a solid foundation for building an optimized, Polkadot-compatible, and production-ready blockchain. Dozens of real-time blockchains are already running Substrate 2.0, including Polkadot[1] and Kusama[2], as well as a series of other dedicated blockchains in the Polkadot ecosystem.
Why use Substrate?
With Substrate, runtime is your blockchain canvas, providing you with the greatest freedom to create and customize blockchains completely based on your application or business logic. In runtime, you can use the built-in database management, libp2p network, and the fast and secure consensus protocol GRANDPA [3] to form any state transition function.
By leveraging Substrate’s modular design to use proven libraries while building the most important custom components, you can focus on your strengths.
At the end of 2018, Polkadot co-founder Gavin Wood showed [4] Substrate 1.0 can achieve pluggable consensus and no fork runtime upgrade. Now, with Substrate 2.0, builders can use the tried and tested framework to deploy what they have always wanted The necessary blockchain.
FRAME-Blockchain composability framework
The modularity of Substrate is part of its core design principles-you can replace many major components, from consensus and finality engines (Substrate comes with AURA, BABE, GRANDPA and built-in configurable PoW engines) and other network stacks, to runtime Development can be replaced.
Runtime modules (ie pallets) are pre-built components that can be used to form the Substrate runtime. Each pallet has its own logic, which can modify the characteristics and functions of the state transition function of the blockchain, so as to easily add basic functions and extended functions. FRAME is a framework for developing Substrate pallet. FRAME[5] makes it easier to find, select, and implement the correct pallet for your custom blockchain, making it the default modular and customizable runtime development framework for Substrate. Substrate 2.0 comes with many new pallets, these pallets will help you quickly and easily use the properties suitable for you and your network to build and deploy the blockchain runtime.
Use pallet to form your blockchain
As Parity and independent teams develop and release their own Substrate-based blockchain, the number of pallets will continue to grow over time.
Substrate 2.0 comes with more than 70 pallets to help you build a blockchain. It is now published on crates.io, which allows you to simplify package management through the Rust package manager cargo. Some examples of Pallet include:
- The Contracts [6] pallet allows smart contracts to be deployed to the WebAssembly virtual machine, allowing contracts to be written in any language that can be compiled into Wasm, such as Rust, C++, and Go.
- BABE[7] and GRANDPA[8] are supporting pallets for proof-of-stake networks that require fast and reliable block production and termination. Other methods of reaching consensus that are compatible with Substrate include Aura (permission rotation and instant sealing). You can learn more about the BABE and GRANDPA consensus here [9].
- Democracy [10] is a platform that implements an on-chain voting mechanism for rapid, binding and transparent governance by stakeholders.
- EVM[11] is a pallet that can replicate the functions of the Ethereum virtual machine, so that EVM applications can be quickly ported to the Substrate chain. Many existing chains are using this pallet to integrate Solidity-based contracts, such as Moonbeam [12] and Plasm [13].
- Treasury[14] pallet provides a way to add funds to the national treasury, which can be used to fund any activity the network wants to perform. The pallet is currently in use on Polkadot, Kusama and other real-time blockchains based on Substrate.
- The Identity[15] pallet allows users to publicly declare who owns certain accounts by providing account names and contact information. This is particularly useful for validators on the proof-of-stake network.
- Account and key security is extremely important for handling large amounts of funds. This is one of the main reasons to create the Multisig[16] pallet, which allows one account to control different keys/devices.
- Recovery[17] pallet introduces a recovery mechanism for on-chain assets, which is especially useful for recovering lost keys in a user-friendly way. Learn more about the social recovery mechanism here [18].
- The Kusama network is currently using the Society[19] pallet to establish Kappa Sigma Mu (Human Body Blockchain Project), in which members join through tattoos[20] and help take the initiative to bridge the gap between humans and machines .
Use on-chain protocols for off-chain calculations
Off-chain workers [21] is a new feature in Substrate 2.0 that allows you to securely integrate data into your blockchain, which is very suitable for Internet of Things (IoT) devices or through predictions The actual data input performed by the oracle.
In order to make off-chain data integration safer and more efficient, Substrate provides off-chain working machines. The off-chain worker subsystem allows for longer running time and potentially uncertain tasks (such as web requests, data encryption/decryption and signature, random number generation, CPU-intensive calculations, enumeration/aggregation of on-chain data, etc.) To take advantage of on-chain data and access. An example is the “I’m online” pallet, which takes advantage of off-chain working machines. In this way, validators in the proof-of-stake network can automatically send transactions to the chain to show that they are still available. This ensures that validators are available, so they should not be kicked or slashed because they are offline.
The code of the off-chain working machine is stored on the chain and can access the on-chain environment, but it will never be executed as part of the block processing. The off-chain working machine can easily run the correct code and allows longer running tasks to be performed without occupying the blockchain. However, the on-chain code allows verification mechanisms such as voting, averaging, and challenge to be implemented in the state transition function of the blockchain on which it runs. Blockchain/oracles network designers and nodes running on the network can determine who should do what, when, and rewards and penalties for participants.
Substrate 2.0 comes with a set of pallets, which can make the data integration of blockchains that rely on existing or real-world data more efficient.
Substrate 2.0 is for builders
With Substrate 2.0, it is easier than ever to build a custom and extensible blockchain that can interoperate with the Polkadot ecosystem, which contains the business logic needed to achieve the team’s design goals. Substrate’s developer ecosystem also helps you prepare for blockchain production through a continuously improving developer tool suite, as well as a benchmarking and monitoring solution suite, which is what a first-class commercial software framework expects.
On the Substrate Developer Hub[22], you can learn more about all technical documents, tutorials and resources to get started. If you need instant feedback, please chat with our developers directly in the Substrate Technical[23] Element chat room.
On October 15th, at Sub0 Online[24] (Substrate Developer Community Meeting), we will learn more about the powerful functions and use cases of Substrate, and establish contact with the Substrate community. The free multi-channel online conference will provide lectures and workshops for all levels of Substrate developers, learners, and newcomers who want to learn more about how to use the blockchain framework to build the future of Web3. Speakers will include Parity founders Gavin Wood and Jutta Steiner, as well as Parity developers who built Substrate and Polkadot, as well as ecosystem builders from various use cases and industry verticals. Learn more and register here [25].