How to Validate Cross-Chain Transactions in the Ontology Multichain Design

The Ontology Team
OntologyNetwork
Published in
5 min readAug 7, 2019

Foreword

As a distributed ledger technology, blockchain can be used in various sectors, such as finance, health care, supply chain, and asset management. However, limited throughput and scalability, and network isolation prevent blockchain projects from better serving business applications. Among these limitations, network isolation hinders the collaboration between different blockchains and significantly limits what blockchain can do.

Introduction

In the previous articles, we explained what can the multichain management contract do and how to implement it. One of the keys of cross-chain transactions is how to validate cross-chain transactions. When the source chain initiates a cross-chain transaction, the target chain needs to validate the legitimacy of the cross-chain data. In this article, we will introduce how two chains validate the transactions on each other’s chain in the Ontology multichain design.

Cross-Chain Transaction Validation

Cross-chain transaction validation is realized by the block header synchronization contract and cross-chain management contract.

1. Block Header Synchronization Contract

The Ontology cross-chain solution is more intuitive. The synced block headers are stored in the block header synchronization contract, and any other contract on the current chain can read the synchronized block headers from the contract. The block header synchronization contract has two APIs:

a. Block header synchronization between the main chain and side-chain

Figure: Key Block Header Synchronization

In the consensus governance model of the Ontology main chain, the Ontology network switches the consensus node after a certain number of blocks, but the validator set remains unchanged during a consensus round. Therefore, if the side-chain is a homogeneous chain, then not all the blocks need to be synced, instead, only the key blocks (i.e. the epoch switch block that switches the validator set) and the block in which the cross-chain transaction takes place need to be synced. Such design greatly reduces the number of synced block headers.

In the meantime, in case the key block header synchronization is not updated on the side-chain after a consensus switch epoch, and the validators from the previous side-chain consensus epoch create malicious block headers, Ontology adds side-chain consensus epoch management in the multichain management contract on the main chain. The validators on the current side-chain can alter the attribute. After the side-chain consensus epoch has ended, if there is no new key block header being submitted, then the cross-chain interaction between the side-chain and the main chain will be terminated. If the new side-chain validators find out the consensus epoch on the main chain is inconsistent with the actual consensus switch epoch on the side-chain, they can alter the attribute on the main chain, and the side-chains will be punished accordingly.

b. Block header synchronization between side-chains

The way block headers are synchronized between side-chains and between the main chain and side-chains is different in that key block header information is obtained differently. Having said that, the block header synchronization process of cross-chain transactions is the same.

The information of all the side-chains is recorded on the main chain. If chain A and chain B want to interact directly, they do not need to register with each other, nor do they need to sync each other’s key block header information from the genesis block, since both of them can get the key block header information about each other from and validated by the main chain. They only need to obtain the information about the key block header that comes before the cross-chain transactions.

2. Cross-Chain Management Contract

When the dApp is processing cross-chain transactions between the main chain and the side-chain, the dApp contract first processes its logic on the source chain and call the cross-chain API of the cross-chain management contract. After the Relayer syncs the validated state information to the target chain, the dApp continues to process its logic on the target chain. The procedures are as follows:

Figure: Cross-Chain Interaction

The cross-chain management contract on the source chain will assign an auto-increment ID for each cross-chain transaction, put the transaction into the Merkle Tree, and then the Merkle Root will be put into the block headers of the current block. After this, the ID and block height will be broadcast as an event. At the same time, when initiating cross-chain transactions, users need to burn or freeze an amount of ONG on the source chain as mining fees.

The Relayer is responsible for monitoring these cross-chain events. When the Relayer is monitoring a cross-chain transaction, it can obtain Merkle proof on the source chain according to the ID and block height, and then submit the Merkle proof to the target chain, during which a mining fee needs to be paid.

After the target chain (its cross-chain management contract) receives the Merkle proof, it will obtain and validate the completed cross-chain transaction on the source chain, and label the transaction ID as “spent”. Then, according to the cross-chain transaction parameters, it will call the dApp contract on the target chain and complete the dApp contract logic on the target chain.

After the cross-chain transaction is successfully executed on the target chain, the Relayer will receive incentives accordingly. Based on transaction types, the incentives could be ONGx issued by the ONGx contract on the side-chain or ONG released by the multichain management contract on the main chain.

Afterword

The Ontology multichain design uses the block header synchronization contract and cross-chain management contract to validate cross-chain transactions and thus lays the foundation for cross-chain interaction.

We will share more about the Ontology multichain design in future tech point articles. Also, the Ontology cross-chain TestNet was launched in May and we have prepared detailed Developer Manual and video tutorials for fellow developers. Try developing on the TestNet and give us your feedback.

Ontology Multichain Documentation Link:

Ontology Multichain Developer Manual

Cross-Chain Tutorial

Video Tutorials Link:

Ontology Multichain TestNet

Ontology Cross-chain Contract Development

About the Ontology Research Institute

Ontology set up the research institute in order to focus more on the research and development of core blockchain technology and strengthen the ability to explore, reflect on, and apply emerging technologies, as well as make contributions to the entire industry. At present, there is more than 10 R&D personnel in the Ontology Research Institute.

Are you a developer? Make sure you have joined our tech community on Discord. Also, take a look at the Developer Center on our website, there you can find developer tools, documentation, and more.

--

--