Design of MeerContract

Qitmeer Network
4 min readJan 13, 2022

--

Since we explained why MeerContract is cross-chained in the last lecture, let’s further explain the specific implementation.

Deployment

The first problem to be solved across every chain is the deployment of the contract chain. The classical practice requires maintaining the main chain and the contract chain independently, which intuitively means that the node maintainer has to start the main chain node and the contract chain node at the same time. This will incur some maintenance costs, for example, if the node maintainer forgets to turn on the contract node or if the contract node is unexpectedly terminated, causing the contract to be unprocessed.

The current solution of MeerContract is to integrate the client of the contract chain into the client of the main chain in the form of a network library, so that although only one chain is running on the surface, in fact, two chains are running at the same time. Moreover, the communication between the two chains is also interacted by RPC, instead of directly calling each other’s functions.

Consensus

The contract chain and the main chain are two separate chains, so they can have independent consensus, which is the technical advantage of MeerContract. Contract chains are more computationally intensive, and a certain application will likely be more popular and cause congestion on the entire main chain. The contract chain can adopt a consensus that supports higher transaction throughput according to the load level of contract transactions and even if the contract chain is congested due to unexpected circumstances, the normal operation of the main chain will not be affected.

It is worth noting that a fully independent consensus would be a security risk due to the insufficient transaction volume on the initial contract chain. Therefore, MeerContract will synchronize each contract transaction on the main chain to ensure the security of the consensus of the contract chain by using the high security of the MeerDAG consensus protocol based on proof of work on the main chain. In the future, when the volume of contract transactions stabilizes, the reliance on the main chain consensus will be gradually reduced to ensure the efficiency of the contract and the stability of the main chain.

Data structure

Three types of transactions are currently added to the types of transactions.

Transferring a pass from the main chain to the contract chain

Transferring passes from the contract chain to the main chain

Smart contracts

Since MeerDAG is based on the UTXO model, its transaction data structure is not compatible with the account-based transaction data structure of Ethernet. To maintain the UTXO transaction structure, MeerDAG cleverly utilizes the signature script and sequence fields in the input of the transaction structure

One of the Sequence fields is not used much in general transactions, so MeerDAG uses this field to distinguish between different transaction types, such as the three contract transaction types mentioned above and the multiple operation types of the MeerToken asset issuance system. Since the transaction type is identified, the field SignScript can have different transaction data rules depending on the type. Therefore, MeerDAG fully preserves the UTXO data structure, which is both compatible with classic UTXO transactions and very scalable.

Summary

First, the cross-chain design of the contract chain allows the contract chain to have greater independence, thus ensuring the efficiency of the contract chain and the stability of the main chain; second, by cleverly redefining the data structure of UTXO, MeerContract can be more scalable and solve the problem of incompatibility between the transactions of the UTXO model and the transactions of the account model. It also solves the problem of incompatibility between UTXO model transactions and account model transactions.

About Qitmeer

Qitmeer is the next-generation public chain based on BlockDAG which is dedicated to serving the ecosystem of Islamic Finance, ethical finance, and socially responsible investment, thereby enhancing financial inclusion and creating social impact.

In contrast to the competition model, BlockDAG’s collaboration model in the mining achieves a desirable balance of typical blockchain metrics among the security, openness, fairness, and scalability.

Qitmeer adopts a classic POW consensus and UTXO data model and designs a unique asset issuing mechanism which requires the reserve of native currency, which is in line with core ethical financial values.

Contact Us

Website / Qitmeer talk / GitHub / Twitter / Facebook / Telegram / Instagram / LinkedIn

--

--

Qitmeer Network
Qitmeer Network

Written by Qitmeer Network

Qitmeer Network is the next generation payment network infrastructure based on BlockDAG technology.

No responses yet