Introduction#
Currently, there are various underlying platforms in the blockchain ecosystem, such as well-established ones like Hyperledger Fabric and Ethereum, as well as domestic ones like Hyperchain and Z-ledger. As the blockchain application ecosystem becomes more complex, single-chain performance faces certain limitations, and the coordination and interaction between chains (such as information synchronization, sharing, and contract interoperability) have become an important part of the development of chains and application ecosystems.
This article provides an overview of cross-chain technology concepts and mainstream solutions.
Overview of Cross-Chain Technology#
Due to the similarity of components such as underlying chain design, consensus algorithms, and network structure, it is relatively easy for homogeneous blockchains to interact with each other. However, it is more complex for heterogeneous blockchains to directly interact with each other, often requiring some auxiliary platforms/services for data format conversion, etc.
Cross-Chain Mechanisms#
Currently, cross-chain is mainly achieved through the following solutions:
- Notary Mechanism
- Hash Locking
- Distributed Private Key Control
- Sidechains/Relay Chains
Notary Mechanism#
The notary mechanism is a mechanism that uses a third-party intermediary to assist in the interaction between different chains. Essentially, it involves both parties trusting a third party to verify and forward cross-chain data or cross-chain interaction operations. This approach works well for heterogeneous blockchains but is a centralized method.
Many digital currency exchanges use this approach to facilitate the trading and conversion of different digital currencies. Essentially, the exchange acts as an intermediary for transactions, resulting in higher efficiency. However, there are certain security risks, and it only supports asset exchange.
Hash Locking#
Hash locking first appeared in the Lightning Network of Bitcoin and is a way to secure the assets of cross-chain parties through hash locks and time locks. The time lock restricts the transaction to a certain period of time, and if it exceeds the time limit, the transaction becomes invalid, thereby avoiding losses. However, this method can only achieve asset exchange and cannot achieve asset transfer.
Sidechains#
Sidechains are bidirectional anchored technologies. The initial sidechains were relative to the Bitcoin main chain, such as BTC-Relay. On these sidechains, new features can be developed and tested for Bitcoin, and when a large number of users are conducting transactions on the Bitcoin network, sidechains can effectively expand the network's throughput. For example, asset trading and value transfer can be done on the Ethereum main chain, while some DApps with high TPS requirements can run on the Ethereum sidechain.
Different sidechains of the same main chain can also interact with each other through the main chain, which is the basic principle of cross-chain using sidechains.
Relay Chains#
Relay chains are a comprehensive application of the aforementioned sidechains and notary mechanisms. They use cross-chain interaction mechanisms (such as Cosmos' IBC) to achieve information sharing and interaction between heterogeneous chains. The various parallel chains that need to be cross-chained are connected to a relay chain to assist in transaction verification and interaction.
Cross-Chain Technology Practice#
Development Practices#
Currently, I am working on the cross-chain functionality of a BaaS platform, and its basic architecture is as follows:
Subchains are mainly used to implement various business and application chains. When a subchain needs to interact with other chains for cross-chain business, it needs to execute cross-chain contracts. We provide a cross-chain gateway to listen to these cross-chain contracts. For heterogeneous blockchains such as Hyperledger Fabric and Ethereum, we provide different adapters to realize the interaction between the cross-chain SDK and the cross-chain gateway. The adapters provide cross-chain contract information query functionality. When the SDK of another business chain receives a cross-chain contract method, if it involves contract invocation or data transfer, it directly calls the corresponding contract method.
My main task is to work on the cross-chain adapter interface. As an adapter, it is a plugin embedded in the cross-chain gateway for different chains, which can assist the cross-chain gateway in listening, synchronizing, and executing transactions.
In the specific implementation, for example, in the Fabric network, the cross-chain business contract is called by the subchain, and the cross-chain business contract uniformly calls an adapter contract. In this adapter contract, we implement the transmission of transaction information and listen to it through the Fabric event mechanism (i.e., implementing the SetEvent
method in the contract and registering the corresponding events in the adapter to listen to the cross-chain contract.
For more details and implementation of Fabric event listening, please refer to "Hyperledger Fabric Go SDK Event Analysis".
Function Expansion#
Currently, MeshBox's BitXHub cross-chain platform is a well-implemented open-source cross-chain solution in the industry, with the following architecture:
It optimizes the functionality, security, and flexibility in the cross-chain process through relay chains, gateways, and plugin mechanisms. It designs the IBTP inter-chain universal transmission protocol to solve the verification, routing, and other issues in cross-chain transactions in conjunction with the "gateway + relay chain" architecture.
Conclusion#
The above is an overview and practical summary of cross-chain technology. In order to have a deeper understanding of the various aspects of cross-chain mechanisms, we will also conduct a more in-depth analysis and source code interpretation of the ongoing cross-chain services and the BitXHub platform.
References#
- Analysis and Thoughts on Cross-Chain Technology
- A Brief Study of Cross-Chain: From Principles to Technology
- BitXHub Cross-Chain Technology Platform
- Hash Time Lock in Blockchain Cross-Chain Technology
- Hyperledger Fabric Go SDK Event Analysis
- BitXHub Document
- Ten Questions about BitXHub: Architectural Design of Cross-Chain Platform