CTO’s Read: Mainstream Blockchain Architectures’ Analysis by Antshares’ Erik Zhang
I.A General-knowledge lesson on Blockchain
Since the inception of Bitcoin in 2009, we have seen the fast development of Blockchain systems or Blockchain-based applications that have been built in various scenarios, which is the epitome of the continuing changes and improvement of Blockchain technology.
Blockchain is a distributed ledger. Unlike centralized ledger like a bank, it ensures ledger’s safety by storing the data on each node of the network. Simply put, Blockchain technology will use three bottom-level technologies: P2P, cryptology and distributed algorithm of consistence. In many cases, Blockchain systems will offer another function free: smart contract. Though a Blockchain system does not see smart contract function the indispensable part, it provides sound environment of trust for smart contract as it is decentralized in nature.
In order to meet the demands of different scenarios, Blockchain system will be modified before applied like the modification of ID recognition, consensus system, management of key, responding time, throughput capacity, privacy protection and monitoring systems etc. As companies that are in need of Blockchain systems are usually unable to do such modification, there are tailor-made Blockchain frameworks that can bespoke Blockchain systems to satisfy the needs of those companies.
This article will compare the features of Blockchain structures of the mainstream and typical Blockchain projects in the community. In order to maintain objectivity and fairness, this article only discusses open source Blockchain frameworks.
II. Brief introduction of Blockchain Architecture of Mainstream Projects
Bitcoin originates from an essay written by Satoshi Nakamoto in 2008 named Bitcoin: A Peer-to-Peer Electronic Cash System, in which Satoshi described a digital cash and algorithm called Bitcoin. In the following years, the underlying technology of Bitcoin has been recognized and is named Blockchain. Bitcoin, as the harbinger of Blockchain technology, is the most influential and essential project in Blockchain family: numerous altcoins are based on Bitcoin’s technology. From Satoshi we can know the objective of Bitcoin is to achieve a pure peer-to-peer digital cash system, making online payment direct between senders and receivers without the involvement of an intermediary. These objectives can be summarized as following:
a1. A digital currency that can be issued without central agency
a2. To pay without intermediaries
a3. To maintain anonymity of users
a4. Trade can be revoked
From the angle of a digital cash system, Bitcoin has basically achieved these objectives. However, there are problems for Bitcoin to solve: attack of malleability, limit of Blocksize, fork and scalability.
Currently there are many digital currency are based on the framework of Bitcoin, of which there are some practical applications like coloredcoin and tØ.
Coloredcoin: some Bitcoins are carefully tracked and thus can be distinguished from other coins. These coins are called coloredcoin. Coloredcoin has some unique features irrelevant to Bitcoin so developers can create other digital assets on Bitcoin network. Coloredcoin itself is Bitcoin and thus can be stored or transferred without a third party.
tØ is the financial application of Bitcoin. It is Blockchain-based public&private share trading platform initiated by Overstock, an online seller in America.
The objective of Ethereum is to provide a Blockchain of Turing-complete language, with which users can create contracts to script codes to achieve multiple functional changes. With Ethereum, users can create a Blockchain-based application with a logic compiled by a few lines of codes. Ethereum can be applied to areas beyond currency.
The philosophy of Ethereum is to support “no” application. But the Turing-complete language means any type of application based on any contract logic can be created on it. To conclude, apart from the functions found in Bitcoin, Ehereum has other objectives as following:
2a. Turing-complete contract language
2b. Constant built-in storage of state
There are hundreds of Ethereum-based projects now, among which Augur, the Dao, Digix and FirstBlood are well-known.
Augur is decentralized platform for market prediction based on Ethereum. Users on it can use digital currency to make predictions and bet as a way of prediction via the wisdom of the masses, greatly eliminating the centralized risks from rivals and servers.
Owing to the limit of length of the this article, I cannot introduce all Ethereum- based projects. There are also many Blockchain projects based on modified code of Ethereum but most of them are close-source ones hence this article will not discuss them.
Fabric is a project member of Hyperledger and its development was by IBM and DAH. Similar to Ehereum, Fabric is also a distributed smart contract platform. What differentiate it from Ethereum is that it is a framework instead of public chain from beginning and it does not have built-in tokens.
As for Hyperledger, it is initiated by Linux Foundation and is an open-source project aiming at promoting Blockchain technology and standards. Members of Hyperledger now totals 100 including ABN AMRO, Accenture, JP Morgan, Huawei and other dozes of groups of interests. The objective of Hyperleger is to use the platform to promote and streamline cooperation between members to meet the demands from different sectors.
Back to Fabric. Fabric as a Blockchain framework is based on loose coupling. It sets consensus mechanism, ID recognition and other components as modules so Fabric enables users to choose proper modules according to specific scenarios. Moreover, Fabric uses container technology: chaincode is running in the docker so that smart contracts can be coded through any advanced language.
The objectives of Fabric:
3a. Module-based, components fungible
3b. Smart contract run on docker
There are quite a few Fabric-based projects including financial ones are underway using Proof of Concept, they are still in infancy, tough.
Onchain DNA (Onchain Distributed Networks Architecture) is a Blockchain framework developed by Onchain, s Blockchain start-up based in Shanghai. Onchain DNA can support public chain, private chain and consortium chain and can be integrated with business systems.
Different from Ethereum and Fabric, Onchain DNA’s underlying technology can support various digital assets, enabling users to create assets on the chain and use smart contract to control issuance and trade logic of the assets. For most scenarios of Blockchain, digital assets are necessary. However, to develop a smart contract based business proc for each type of digital assets is wasteful and ineffective. Therefore, bottom-layer support of digital assets is essential. For scenarios where there is no need of digital assets, the Blockchain application can also be achieved via user-defined logic of smart contract on Onchain DNA.
Here are the objectives of Onchain DNA
4a.Bottom support of various digital assets
4c.Trade can be finalized
Now there are a number of financial agencies including banks, security companies, payment and clearance companies using Onchain DNA to develop POC(proof of concept) products. Projects like antshare and Lawchain are the mature projects based on Onchain DNA.
Antshare is a public chain focusing on digital assets. Through a P2P decentralized protocol that can register, issue, transfer, trade and settle digital assets, antshares helps digitalize assets and equity in real world. Antshares’s structure is in line with Onchain DNA and thus can operate between chains as long as they are based on Onchain DNA.
Lawchain is the world’s first commercialized Blockchain project featuring storage of legal evidence. It is based on Onchain DNA. Its record and storage system are the joint efforts of multiple agencies. The system is decentralized and no single agency or node can mutate the information recorded, thus meeting the demand of legal evidence required by judicial system.
Corda is developed by R3CEV, a Blockchain start-up headquartered in New York. R3 Blockchain consortium has attracted dozens of giants in banking industry including HSBC, Mitsubishi UFJ Financial Group, Morgan Stanley, National Bank of Australia, Royal Bank of Canada, Sweden Nordic Bank (SEB), Bank of America, Bank of America, Bank of New York Mellon, Citibank and the French Industrial Bank. From the nature of R3’s member, we can tell Corda is a technology structure designed for inter-bank business. Though R3 claims it is not Blockchain, R3 still has several important features of Blockchain.
Corda is developed by Java and Kotlin, and its major functions like smart contract and data access all rely on Java.
The objectives of Corda:
5a.no general ledger
5b.Notaries will solve the double-spending problem
5c.Only participants and notaries can see the transactions
To achieve these objectives, transactions on Corda will not be broadcast to the full network. Besides there is no direct communication between nodes and there is no P2P network either. Hence, Corda’s network will be confined to a small scale and its application will be narrower.
III.Detailed Comparison from technological levels
In this chapter, we will make a series of comparisons among Blockchain structures mentioned previously and further discuss their differences and similarities.
The internal token of Blockchain projects is usually an economic impetus mode and a way to prevent valueless trade. Bitcoin by nature only has one and the only one internal token. Therefore, all the “transactions” are transferring tokens in essence.
The internal tokens of Ethereum and Onchain DNA not only functions as impetus mode and preventative measure for valueless trade, they also serve as a channel to charge fees. For example, the running of smart contract on Ethereum needs to consume GAS and the creation of digital assets on Onchain DNA also needs to consume tokens (optional).
Ehereum and Fabric do not have bottom-level support for various digital assets. They support digital assets via smart contract. The positive side of this design is that the Blockchain system will be very simple and the handling of assets will be very free. Nonetheless, the negative side of such design is that assets creator needs to code repetitive business logic and there is no unified way for users to manage their own assets.
For Onchain DNA and Corda, they have the bottom-level support for various assets, allowing users to create assets conveniently. And users can manage all the assets in the same application. For business scenario that requires more complicated logic, users can also use smart contract to diversify the functions of the assets or to create a business logic unrelated to digital assets.
2. Account system
UTXO (Unspent Transaction Output): Each digital coin will be registered under the ownership of a certain account. A digital coin will be in of the two sates: either spent or unspent. When we need to use a coin, we will mark the coin as “spent” and simultaneously create a new coin of same value. The created new coin will be recorded in the balance of a new account. In this process, the coin marked as “spent” is called input of the trade while the coin newly created is called the output of the trade. There will be more than one input and output in one transaction but the sum of inputs must be equal to the sum of outputs. To calculate the balances an account, we only need to sum the face value of all coins registered under that account.
Bitcoin and Corda use UTXO as its account system but Ethereum use the more direct one –Balance system: each account directly records the balances of the account. Transferring coins is to reduce the balance of an account and to add the equivalent amount to another account. Onchain DNA is compatible to the two modes.
Then what is the differences between UBXO and Balance mode? The advantage of UTXO is that trade can be verified and can be done in random order as there are no connection between accounts, which is very helpful for its scalability. On the other hand, Balance mode is also good as it is simple and direct, making it easier to achieve application. In the case of smart contract, to handle UTXO mode is extremely hard. This explains why smart contract oriented Ethereum use Balance mode while the assets oriented Blockchain, Onchain DNA and Corda tends to use UTXO.
As for ID recognition, Bitcoin and Ethereum barely have such design. The reason is simple: the two Blockchain projects emphasize privacy and anonymity and are against monitoring and centralization. It is apparent that ID recognition will introduce some centralized agency or weakened centralized agency.
Fabric, Onchain DNA and Corda coincidentally choose digital certificates to recognize users’ ID. The reason: the three Blockchain systems all have objective of being applied to existing financial system and financial system is subjected to regulation and government monitoring. Furthermore, digital certificate has already been extensively used in financial system. Blockchain’s ID recognition system via digital certificate will make its integration into financial system more quickly.
3. Consensus system
Consensus system is the core algorithm for digital system. The data on distributed system are scattered on each of nodes of the systems and thus these data need an algorithm to maintain consistency. Different from traditional distributed system, Blockchain is decentralized and in many cases, financial assets will be involved. Therefore, Blockchain system face Byzantine problems instead of general problems that are more common for decentralized distributed systems.
Bitcoin and Ethereum use Proof of Work to keep ledger’s consistency. PoW is also a distribution mechanism of token. Via economic incentives, it encourages code to be a part of efforts in developing the Blockchain community, and nodes need to exhaust a random number so that the blocks meet the required difficulty requirements. Once the Blockchain faces a fork, the honest nodes will choose chain of larger workload and abandon the one of lower workload. The fact that all nodes are profit-driven and that choosing the chain with lower workload means invalid incentive, all nodes will finally choose the honest chain. Hence, all the nodes become aligned and consistent.
To maintain such a Blockchain of PoW, powerful computation capability for the whole network is needed or the ledger’s data could be mutated. Moreover, even there is strong enough hash power to protect network, PoW is unable to make sure trades can be finalized. For example, Bitcoin’s network often see the generation of orphaned blocks. Data on orphaned blocks can be revoked. That is why it takes 6 blocks to confirm one trade as the benchmark that the trade is theoretically finalized. Even so, the confirmation is yet to be absolute as one can never be sure that there is no hash power greater than the sum of the network trying to cancel the previous trade. The cost of electricity used by computers of the whole network is also enormous. Actually, Ethereum is considering using other consensus mechanism instead of PoW
Fabric and Onchain DNA both have Byzantine Fault Tolerance (BFT) as the consensus mechanism where nodes are classified into normal nodes and validating nodes. Only validating nodes can build blocks. The separation allows the designer to have the chance to limit the number of nodes into a controllable scale.
There are requirements for nodes in the BFT: we assume that f nodes in total are faulty, then there should be at least 3f+1 nodes participating the whole network to avoid fork. In BFT, the building of each block needs at least 2f+1 nodes to participate while with PoW each node can build one block. In BTF, once a block is formed, it cannot be revoked as 2f+1 honest nodes will not sign two blocks at the same height.
PoW is highly flexible and practical as each node can build a block with almost no need of other nodes. Nodes can join or exit the network at will. Even there is only one node in the network, it can still function normally, the cost is that trade can not be finalized, though. BFT, on the other hand, is less flexible and practical. Validating nodes have to be online and can not exit the network. Once 1/3 of the nodes breakdown, the whole network stops to work. However, BFT can make sure that all trades are finalized.
In 1994 cryptologist Nick Szabo firstly initiated the concept of smart contract, which is almost as old as internet. Smart contract refers to the computer programs that can automatically execute the terms of the contract. Before the emergence of Bitcoin, there is no safe and reliable execution environment, so smart contract was unable to be applied to reality. Blockchain, for its centralization, openness and transparency, is born to be able to provide reliable environment for smart contract to be implemented. Therefore, the new blockchain frameworks almost all have built-in smart contract function.
Bitcoin has a built-in stack-based script execution engine that runs a unique scripting code for simple validation of transactions, such as signature verification and multiple signature verification. This set of scripting language is designed intentionally: non-Turing complete is simple but still enough to deal with the various needs of money transfer.
Fabric, unlike Ethereum that invents its own language and virtual machines, chooses the existing container technology to support its smart contract function. Fabric’s smart contracts can theoretically be written in any language, which is very friendly to developers as there is no need for them to learn new languages and developers can reuse existing code and the resourceful development pool with familiar development tool. Fabric’s runtime is docker. There are problems for this structure: first, it is difficult to control the execution process of the smart contract so that its function can not be limited; secondly, it can not evaluate accurately on computing resources needed for running smart contract.
In addition, running the docker is relatively costly, which makes it difficult to run contracts on mobile devices; Finally, different hardware configuration, contract reference library of different nodes all contribute possible uncertainty of contract
Onchain DNA uses AVM (Antshares Virtual Machine) as the bottom support for its smart contract function. AVM is a micro-core and platform-independent smart contract execution environment that provides a set of instructions including stack operations, flow control, logical calculation, arithmetic calculation, cryptographic calculation, string calculation and array operations. For hardware, AVM only provides two computing stacks. However, since it allows the implementer of the Blockchain to create its own virtual hardware and use it as an interface to the smart contract, the contract can still obtain platform-related data, persistent storage, and access to the Internet at runtime. While this may also lead to uncertainty of contracts’ behavior, the implementer of the Blockchain can eliminate this uncertainty by writing proper virtual hardware. However, due to the absence of compilers and development environments that are compatible with AVM, it is difficult to develop smart contract based on AVM. Developers have to use a similar to assembly syntax for coding smart contracts, which requires relatively higher technological proficiency.
Corda’s smart contracts, like Corda itself, are based on Java Virtual Machine (JVM). Therefore, you can use any JVM-compatible language like Java and Kotlin to develop. However, Corda has made some changes to the JVM, bringing more certainty to the contracts run on it. The development process is roughly like this: use Java to create a class that implements the Contract interface and provide a function called verify that is used to validate the transaction. The function accepts the current transaction as a parameter. If validation of transaction fails, the function will show abnormal (exception), no such signal means that verification is successful. Corda uses JPA (Java Persistence Architecture) to provide constant storage. It supports SQL and commonly used databases without the need to install plug-ins. As the data are only stored at the nodes of contract implementers, global permanent storage cannot be achieved.
The data structure of Blockchain usually only allows for adding data instead of modifying or deleting records. Blockchain honestly records the historical data, enabling the new nodes to verify transaction history of the whole network without the need to trust other nodes. This feature leads to convenience of decentralization but also to challenges for scalability of Blockchain. As Blockchain will grow indefinitely until the block is full, it is necessary to provide a storage reduction mechanism to handle the ever-increasing data.
Bitcoin use Merkel tree to store the transaction hash. When you need to reclaim the disk space, you only need to remove the old transaction from the Merkel tree. A block header containing zero transaction information is only 80 bytes big. Bitcoin’s blockchain will generate data of 4.2MB at the rate of 10 minutes/block. Then it won’t be a problem to store all the block headers in the memory.
Based on Block compression mechanism, Ethereum, Fabric and Onchain DNA further use state flash mechanism to save disk space. Specifically, sate flash means that the block header will not only record the root hash of all transactions of current block but also root hash of previous blocks. These include all the UTXO, balance account and contract storage, etc. In this case, all the nodes only need to keep the latest blocks and the complete status information.
Another important indicator of scalability is the throughput of transactions. Tough many factors will determine throughput capacity like network structure, encryption algorithms, and consensus mechanism, the most important thing is whether the transaction can be verified in parallel. If the transaction can be verified in parallel, then by simply increasing the number of CPU the throughput can be increased.
It is very easy to do parallel transaction on Bitcoin that is based on UTXO: there is no direct connection between UTXO and the change of any UTXO can be done independently without the need to consider order. On the other hand, parallel verification on balance account system won’t be that easy as there can be cases where multiple transactions are impact the same account so you need some extra additional steps to handle. For example, there are 2 transactions that are related to the same account with balance of 10 USD. The first transaction will add 5 USD to the account while the other will minus 11 USD from the account. If we execute the first transaction, then the two transactions can be executed and the final balance will be 4 USD. However, if we execute the second transaction first, then it will fails for insufficient balances. Only the first transaction will succeed. The final balance is 15 USD.
IV.Uniqueness of each Project
The “Greedy Heaviest Observed Subtree” (GHOST) protocol is an updated version of the PoW used by Ethereum. The motivation behind GHOST is that blockchains with fast confirmation times currently suffer from reduced security due to a high stale rate – because blocks take a certain time to propagate through the network, if miner A mines a block and then miner B happens to mine another block before miner A’s block propagates to B, miner B’s block will end up wasted and will not contribute to network security. Furthermore, there is a centralization issue: if miner A is a mining pool with 30% hash power and B has 10% hash power, A will have a risk of producing a stale block 70% of the time (since the other 30% of the time A produced the last block and so will get mining data immediately) whereas B will have a risk of producing a stale block 90% of the time.
GHOST solves the first issue of network security loss by including stale blocks in the calculation of which chain is the “longest”; that is to say, not just the parent and further ancestors of a block, but also the stale descendants of the block’s ancestor (in Ethereum jargon, “uncles”) are added to the calculation of which block has the largest total proof of work backing it. To solve the second issue of centralization bias, GHOST also provides block rewards to stales: a stale block receives 87.5% of its base reward, and the nephew that includes the stale block receives the remaining 12.5%. Transaction fees, however, are not awarded to uncles. Calculation shows that 5- level GHOST protocol with incentives can achieve more than 95% valid rate of blocks. A miner of 25% hash power benefit less than 3% from centralization.
2.National Encryption and Algorithm
National Encryption Algorithm refers to the commercial encryption algorithm set at national level or international level. In China, there are SM1, a symmetry algorithm, SM2, an asymmetry elliptical encryption algorithm and SM3, a hashing algorithm. Usually Blockchain projects will use international standards like AES, ECDSA and SHA2.
For financial agencies in China, they tend to choose the national standard.
Onchain DNA provides module for users to choose proper encryption algorithm based on different scenarios, which provides security and avoids policy risks.
Currently every day will witness numerous Blockchain projects and the cross-chain operation becomes an urgent need. Corporate users may need can transfer their business between different chains. Private users may need assets exchanges between different chains. The digital currency of PBOC may also need to circulate on different chains.
Onchain DNA actually provides a cross-chain inter-operation protocol. Users can trade assets and implement contracts across chains while the operation can maintain consistent on different chains.
As said in the Whitepaper of Corda, it does not have a chain structure. Its transaction will not be broadcast to the network and will only be transmitted between trade participants and notaries. Therefore, only certain people have access to the data and this protects privacy. As Corda’s nodes only needs store related transaction information instead of the all trade information, the storage space will be spacious.
This article compares and discusses the characteristics and functions of each Blockchain frameworks from multiple dimensions, and expounds their advantages, disadvantages and limitations in the application field.
Bitcoin, as the prototype of Blockchain technology, is the most essential one among the community. However, because of bottom technology’ limitations like such as mining, non-Turing completeness, it is difficult to apply it to complex business scenarios. On the other hand, Bitcoin will very suitable for currency issuance.
Although Ethereum also uses mining mechanism, its GHOST protocol improves the efficiency of mining. Moreover, Ethereum is also developing the new consensus algorithm and developing more privacy protection programs based on encryption such as coinjion plan based on ring signature, which is very suitable for the creation of decentralized autonomous organizations (DAO).
Fabric and Onchain DNA mainly provide Blockchain solutions to enterprise-level problems. Solutions. They are suitable for customizing consortium chains in various fields including in financial area. The difference between the two is that Fabric focuses more on smart contracts and Onchain DNA on digital currency. Besides, fabric is more suitable for the development of complex customized business processes, while the Onchain DNA is more suitable for digital assets-oriented financial business system and equity registration and transfer system.
Corda is the “distributed database” for banks. It abandons block and chain and thus can better separate the trade data. However, Corda has introduced the concept of notary, making the network inflexible and inscalable. Coada show no distinctions with the existing banking network.
The original text is written by Erick Zhang in Chinese on Chinese site of 8btc. see original text