Darwinia 2.0 Developments
Darwinia 2.0 First Successfully Merge Of Substrate Solo-Chain And Polkadot Parachain
Darwinia 2.0 recently attempted to merge its solo Substrate-based chain and its Polkadot while preserving the paraId of the parachain.
Prior to the merge, Darwinia had two separate chains: the solo Darwinia Chain
and the Darwinia Parachain
which run on the Polkadot Relay Chain. The virtual chain Darwinia Smart Chain
as an evm module is not considered in this scenario.
After the merge, Darwinia will have a single chain called Darwinia 2.0.
Why Darwinia Does This?
Prior to the launch of the Polkadot Relay Chain, Darwinia operated its solo blockchain called the Darwinia Chain
. After winning a slot in the Polkadot parachain auction, Darwinia launched the Darwinia Parachain
on the Polkadot network. To make the two blockchains work together, Darwinia creates a substrate-to-substrate cross-chain messaging channel between them.
At the time, if Darwinia only had one chain, it would have to migrate back and forth between solo and parachain mode whenever it lost and regained its parachain slot. To avoid this inconvenience, Darwinia decided to run both a solo chain and a parachain simultaneously, using its ability to connect two Substrate-based blockchains. The parachain is governed through remote governance from the solo chain.
However, they have encountered some issues in practice. Firstly, the existence of two chains is confusing for users and hinders understanding of Darwinia. Secondly, it is a burden for the development team, as it requires more time for development and testing, which slows down the code iteration process. Additionally, the cross-chain process becomes more time-consuming and costly due to the added hop.
As the team gained more experience with Substrate and related tools improved, it became possible to simplify the Darwinia Network by merging the Darwinia Chain
and Darwinia Parachain
. This proposal was made due to the reason above and the added complexity introduced at the start of Darwinia’s design. As a result, they attempted the first merge of a solo chain and parachain in the Polkadot ecosystem.
How
The process of merging involves exporting the data from both the Darwinia Chain
and the Darwinia Parachain
, merging the data, and then migrating the merged data and new code into the Darwinia Parachain
. In summary, the Darwinia Chain
and Darwinia Parachain
are merged into the Darwinia Parachain
.
Steps
The merge is divided into two main steps: chainstate processing and parachain migration.
1. Chainstate Processing
The first step in the merge process is to export the data from both the Darwinia Chain
and the Darwinia Parachain
. This data is then preprocessed and merged to generate a genesis file, which can be used to start a new shell chain.
During the preprocessing of the data, several steps are taken, including:
- Removing storage data that is no longer needed, particularly from pallets that are no longer in use, such as those related to consensus. Read more.
- Converting account-related storage data into data to be migrated in the account_migration pallet. The final migration of assets in the account will need to be done by the user in the new chain. See the article about account migration.
- Adjusting data bound to the block height. For example, if you lock RINGs for 3 months, you end up storing a block-height-related value in storage. After 2.0, the height starts from 0 and the block time span will be changed from 6s to 12s. The final lock length must be adjusted accordingly.
- Making other data upgrades for Darwinia 2.0, including adjusting token precision and unifying address formats. Details can be found here.
The chainstate processing portion of the work is mainly carried out using the state-processor tool state-processor.
Additional information on chainstate processing can be found here
2. Parachain Migration
The data from the genesis file and the code of the new parachain are migrated into the Darwinia Parachain
using Parity Technologies’ solo-to-para pallet. Following the migration, the Darwinia Parachain
becomes the new Darwinia 2.0 and retains its original paraId.
Without the solo-to-para pallet, it would have been difficult to complete this process while preserving the paraId.
Chains Upgrade Pathway
To ensure the accuracy and completeness of the merge, thorough testing and checking is necessary. It must also be verified on testnet and canary networks before Darwinia can be upgraded.
The merge will be tested on Pangolin 2.0, the testnet for Crab 2.0, to check for data completeness and accuracy. After this, Crab 2.0, the result of merging the Crab Chain
and Crab Parachain
, will be launched. Crab 2.0 is an economically valuable network, so it will not only be tested for data completeness and accuracy, but also for economic feasibility. If there are no issues on Pangolin 2.0 and Crab 2.0, the merge will proceed to Pangoro 2.0, the test network for Darwinia 2.0. If everything is successful on Pangoro 2.0, the merge for Darwinia 2.0 will be carried out.
In summary: Pangolin 2.0 → Crab 2.0 → Pangoro 2.0 → Darwinia 2.0.
Less Is More
After the merge, Darwinia will have only one chain, Darwinia 2.0, a simplified Polkadot parachain that will begin producing blocks from block number 0.
The Darwinia community reached consensus on the merge through discussion and will vote on it through referendum. The high-quality technology ecosystem of Polkadot has made this merge possible. Once the referendum on Darwinia 1.0 passes, it will be retired. All of Darwinia 1.0’s on-chain state will be preserved in Darwinia 2.0, including user account ledgers.
The simpler Darwinia 2.0 will provide a stronger foundation for the future development of Darwinia, leading to higher code quality, faster development iteration cycles, shorter cross-chain routing paths, and a better user experience.
Due to Substrate’s modular design and well-established toolchain, the merge process is relatively straightforward. We are confident that it can be completed in a relatively short time. If we had only focused on the merge, we believe it would have been finished even more quickly, as a significant amount of time was spent on other data upgrade work in addition to the merge.
About Darwinia Network
Darwinia a cross-chain messaging infrastructure, which provides a light client-based, programmable, universal cross-chain messaging network for decentralized applications.