First Successfully Merge Of Substrate Solo-Chain And Polkadot Parachain

Darwinia
DARWINIA NETWORK
Published in
5 min readJan 18, 2023

--

Darwinia 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, we 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, we 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:

  1. 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.
  2. 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.
  3. 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.
  4. 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 Chainand 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.

References

https://polkadot.network/blog/first-parachain-successfully-migrates-from-kusama-to-polkadot/?utm_source=twitter&utm_medium=social&utm_campaign=kilt kusama to polkadot&utm_content=polkadot

https://www.youtube.com/watch?v=sIgvyRFs-N4

Related Readings

About Darwinia Network

GitHub | Website | Medium | Twitter | Telegram | Discord

Darwinia is a cross-chain messaging infrastructure, which provides a light client-based, programmable, universal cross-chain messaging network for decentralized applications. Now, we’ve successfully used Darwinia’s light-client cross-chain messaging protocol(LCMP) to bridge cross-chain messages between substrate-based chains, and even between substrate-based chains and EVM chains, meanwhile, Darwinia provides developers with an SDK, so they can easily integrate cross-chain capabilities into their Dapps. This has significant implications for cross-chain interoperability and will enable the creation of a hybrid cross-chain network through Darwinia’s role as a cross-chain messaging infrastructure.

--

--

Darwinia
DARWINIA NETWORK

As an open cross-chain bridge protocol based on Substrate, Darwinia focuses on the construction of future Internet of Tokens. TG: http://t.me/DarwiniaNetwork