随着区块链慢慢出现在大众视野中,从2009年比特币诞生至今,各式各样的区块链系统或基于区块链的应用不断被开发出来,并被应用到大量的场景中,而区块链技术本身也在不停地变化和改进。
As block chains slowly appear in public view, from the birth of Bitcoin in 2009 to the present, a variety of block chain systems or block-based applications are being developed and applied to a large number of scenarios, while block chain technologies themselves are constantly changing and improving.
区块链又被称为分布式账本,与之对应的则是中心化账本,比如银行。与中心化账本不同的是,分布式账本依靠的是将账本数据冗余存储在所有参与节点中来保证账本的安全性。简单地说,区块链会用到三种底层技术:点对点网络、密码学和分布式一致性算法。而通常,区块链系统还会“免费附赠”一种被称为智能合约的功能。智能合约虽然不是区块链系统的必要组成部分,但由于区块链天生所具备的去中心化特点,使它可以很好地为智能合约提供可信的计算环境。
Block chains are also referred to as distributed books, which correspond to centralized books, such as banks. Unlike centralized books, distributed books rely on storing redundant account data in all participating nodes to ensure the security of the books. Simply put, block chains use three bottom technologies: point-to-point networks, cryptography, and distributed consistency algorithms.
为了适应不同场景的需求,区块链系统在实际应用的过程中往往会需要进行各种改造,以满足特定业务的要求,比如身份认证、共识机制、密钥管理、吞吐量、响应时间、隐私保护、监管要求等。而实际应用区块链系统的公司往往没有进行这种改造的能力,于是市场上慢慢出现了一些用于定制专用区块链系统的框架,采用这些框架就可以很方便地定制出适用于企业自身业务需求的区块链系统。本文将对目前市场上几个典型的区块链框架进行横向对比。
In order to adapt to the needs of different scenarios, block chain systems often need to be adapted in practice to meet the requirements of specific operations, such as identification, consensus mechanisms, key management, throughput, response time, privacy protection, and regulatory requirements. And companies applying block chain systems often do not have the capacity to do so.
比特币(Bitcoin)源自中本聪(Satoshi Nakamoto)在2008年发表的一篇论文《比特币:一种点对点的电子现金系统》(Bitcoin:A Peer-to-PeerElectronic Cash System),文中描述了一种被他称为“比特币”的电子货币及其算法。在之后的几年里,比特币不断成长和成熟,而它的底层技术也逐渐被人们认识并抽象出来,这就是区块链技术。比特币作为区块链的鼻祖,在区块链的大家族中具有举足轻重的地位,基于比特币技术开发出的山寨币(Altcoins)的数量有如天上繁星,难以计数。
Bitcoin originated from a 2008 paper by Satoshi Nakamoto, “Bitcoin: an electronic cash system for point-to-points” (Bitcoin: A Peer-to-PeerElectrical Cash System), which describes an electronic currency and its algorithm, which he calls “bitcoin.” In the following years, Bitcoin grew and mature, while its bottom technology became increasingly known and abstracted, which is block-chain technology. Bitcoin, as the nostril of the block chain, has a strong position in the extended family of the block chain, and the amount of Altcoins, based on Bitcoins, is as big as the stars, difficult to count.
中本聪设计比特币的目的,就是希望能够实现一种完全基于点对点网络的电子现金系统,使得在线支付能够直接由一方发起并支付给另外一方,中间不需要通过任何的中介机构。总结来说,他希望比特币能够实现以下这些设计目标:
In summary, he hopes that Bitcoin will achieve the following design objectives:
1、不需要中央机构就可以发行货币
1. Money can be issued without the need for a central agency
2、不需要中介机构就可以支付
2. Pay without the need for an intermediary
3、保持使用者匿名
3. Keeping the user anonymous
4、交易无法被撤销
4. Transactions cannot be avoided
从电子现金系统的角度来看,以上这些目标在比特币中基本都得到了实现,但是依然有一些技术问题有待解决,比如延展性攻击、区块容量限制、区块分叉、扩展性等。
From the point of view of the e-cash system, these objectives have been largely achieved in bitcoin, but there are still technical problems to be resolved, such as extended attacks, block capacity limits, block fork and expansion.
在应用场景方面,目前大量的数字货币项目都是基于比特币架构来设计的,此外还有一些比较实际的应用案例,比如彩色币、t?等。
In the application landscape, a large number of digital money items are currently designed on the basis of a bitcoin structure, in addition to more practical applications such as colour currency, t?
彩色币(Coloredcoin),通过仔细跟踪一些特定比特币的来龙去脉,可以将它们与其他的比特币区分开来,这些特定的比特币就叫作彩色币。它们具有一些特殊的属性,从而具有与比特币面值无关的价值,利用彩色币的这种特性,开发者可以在比特币网络上创建其他的数字资产。彩色币本身就是比特币,存储和转移不需要第三方,可以利用已经存在的比特币基础网络。
Colour coins (Colorredcoin), by carefully tracking the origins of certain bitcoins, can distinguish them from other bitcoins, which are called colourcoins. They have a number of special attributes, thus having value unrelated to the bitcoins face value, which allows developers to create other digital assets on the Bitcoins network. The colour coins are bitcoins themselves, and no third party is needed to store and transfer them, using the basic Bitcoins network that already exists.
t?是比特币区块链在金融领域的应用,是美国在线零售商Overstock推出的基于区块链的私有和公有股权交易平台。
t? is the financial application of the Bitcoin block chain and is the private and public equity trading platform based on the block chain launched by Overstock, an online retailer in the United States.
以太坊(Ethereum)的目标是提供一个带有图灵完备语言的区块链,用这种语言可以创建合约来编写任意状态转换功能。用户只要简单地用几行代码来实现逻辑,就能够创建一个基于区块链的应用程序,并应用于货币以外的场景。以太坊的设计思想是不直接“支持”任何应用,但图灵完备的编程语言意味着理论上任意合约逻辑和任何类型的应用都可以被创建出来。总结来说,以太坊在比特币的功能之外,还有以下几个设计目标:
The goal of Etheeum is to provide a chain of blocks with the perfect language of Turing, in which a contract can be created to create an arbitrary conversion function. By simply using a few lines of code to achieve logic, users can create an application based on the chain of blocks and apply it to a scenario other than the currency. The idea of the Taiyem is not to “support” any application, but the perfect programming language of Turing means that theoretically free contract logic and any type of application can be created. In summary, Taiyuan has the following design objectives in addition to the Bitcoin function:
1、图灵完备的合约语言
1. A fully-fledged contract language for Turing
2、内置的持久化状态存储
2. Built-in permanent state storage
目前基于以太坊的合约项目已达到数百个,比较有名的有Augur、TheDAO、Digix、FirstBlood等。
Augur是一个去中心化的预测市场平台,基于以太坊区块链技术。用户可以用数字货币进行预测和下注,依靠群众的智慧来预判事件的发展结果,可以有效地消除对手方风险和服务器的中心化风险。
Augur is a decentralised predictive market platform based on the tether block chain technology. Users can use digital currency for forecasting and bets, relying on popular wisdom to prejudge the outcome of events, and effectively eliminate the risk of manual risk and server centralization.
限于篇幅,基于以太坊智能合约平台的项目就不多介绍了。基于以太坊的代码进行改造的区块链项目也有不少,但几乎都是闭源项目,只能依靠一些公开的特性来推断,所以就不在本文展开讨论了。
There are also a number of block-chain projects that have been remodeled using Taiyan code, but are almost all closed-source projects that can only be deduced by public features, so there is no discussion here.
Fabric是由IBM和DAH主导开发的一个区块链框架,是超级帐本的项目成员之一。它的功能与以太坊类似,也是一个分布式的智能合约平台。但与以太坊和比特币不同的是,它从一开始就是一个框架,而不是一个公有链,也没有内置的代币(Token)。
Fabric is a block chain framework, developed by IBM and DAH, and is one of the project members of the super-accounts. It functions like Ether, and it is a distributed smart contract platform. Unlike Ether and Bitcoin, however, it was a framework from the beginning, not a public chain, and there is no built-in token (Token).
超级账本(Hyperledger)是Linux基金会于2015年发起的推进区块链技术和标准的开源项目,加入成员包括:荷兰银行(ABN AMRO)、埃森哲(Accenture)等十几个不同利益体,目标是让成员共同合作,共建开放平台,满足来自多个不同行业各种用户案例,并简化业务流程。
Superbooks (Hyperledger) is an open-source project initiated by the Linux Foundation in 2015 to promote block chain technologies and standards, with the participation of more than a dozen different interests, including the Bank of the Netherlands (ABN AMRO) and Accenture, with the aim of bringing members together to build open platforms to accommodate a variety of user cases from a variety of industries and to simplify business processes.
作为一个区块链框架,Fabric采用了松耦合的设计,将共识机制、身份验证等组件模块化,使之在应用过程中可以方便地根据应用场景来选择相应的模块。除此之外,Fabric还采用了容器技术,将智能合约代码(Chaincode)放在Docker中运行,从而使智能合约可以用几乎任意的高级语言来编写。
As a block chain framework, Fabric uses a pine-coup design that modularizes components such as consensus mechanisms, identification, etc. so that it can easily select the corresponding modules according to the application scenario. In addition, Fabric uses container technology to run the smart contract code (Chaincode) in Docker, so that smart contracts can be written in almost any advanced language.
以下是Fabric的一些设计目标:
The following are some of Fabric's design objectives:
1、模块化设计,组件可替换
1. Modular design and replacement of components
2、运行于Docker的智能合约
2. Smart contracts running on Docker
目前已经有不少采用Fabric架构进行开发的概念验证(POC)项目在实施过程中,其中不乏一些金融机构做出的尝试,不过由于项目刚刚起步,还没有比较成熟的落地应用。
A number of conceptual validation (POC) projects have been developed using the Fabric architecture, including attempts by some financial institutions, but they have not yet been used in a more mature manner, as the project has just begun.
Onchain DNA(Onchain Distributed Networks Architecture),是由总部位于上海的区块链创业公司“分布科技”开发的区块链架构,可以同时支持公有链、联盟链、私有链等不同应用类型和场景,并快速与业务系统集成。分布科技同样也是超级账本的成员之一。
Onchain DNA (Onchaid Networks Engineering), a block chain architecture developed by the Shanghai-based block chain start-up company, Distributed Technology, can support different applications and scenarios, such as public chains, union chains, private chains, and fast integration with business systems. Distribution technology is also a member of the super-accounts.
与以太坊、Fabric不同的是,Onchain DNA在系统底层实现了对多种数字资产的支持,用户可以直接在链上创建自己的资产类型,并用智能合约来控制它的发行和交易逻辑。对于绝大部分的区块链应用场景,数字资产是必不可少的,而为每一种数字资产都开发一套基于智能合约的业务流程非常浪费且低效。因此,由区块链底层提供直接的数字资产功能十分必要。而对于那些完全不需要数字资产的应用场景,同样可以基于Onchain DNA提供的智能合约功能来编写任意的自定义逻辑来实现。
Unlike Ether, Fabric, Onchain DNA supports multiple digital assets at the bottom of the system, where users can directly create their own asset types on the chain and use smart contracts to control their distribution and transactional logic. is essential for most block-chain applications, while the development of a business process based on smart contracts for each digital asset is wasteful and inefficient.
Onchain DNA的设计目标主要有以下几点:
Onchain's DNA is designed with the following main objectives:
1、多种数字资产的底层支持
1. Bottom-line support for multi-digital assets
2、图灵完备的智能合约和持久化状态
2. Turing's full-fledged intellectual contract and durability
3、跨链互操作性
3. Cross-chain interoperability
4、交易的最终性
4. Finality of the transaction
目前已有不少金融机构采用Onchain DNA架构来进行区块链概念验证产品的开发,如银行、券商、支付、登记结算机构等。除此之外,还有一些已经落地的区块链项目,如小蚁、法链等。
There are already a number of financial institutions using Onchain DNA structures for the development of block chain concept validation products, such as banks, bond dealers, payment agencies, registration clearing agencies, etc. In addition, there are a number of block chain projects that have already landed, such as small ants, legal chains, etc.
小蚁(Antshares)是一个定位于资产数字化的公有链,将实体世界的资产和权益进行数字化,通过点对点网络进行登记发行、转让交易、清算交割等金融业务的去中心化网络协议。它采用社区化开发的模式,在架构上与Onchain DNA保持一致,从而可以与任何基于Onchain DNA的区块链系统发生跨链互操作。
Antshares is a public chain of asset digitization that digitizes the assets and interests of the real world and decentralizes financial operations such as issuing, transferring transactions, clearing transactions, etc. through a point-to-point network. It uses a community-based development model that is structurally aligned with Onchain DNA, which allows interlinking with any Onchain DNA-based block chain system.
法链是全球第一个大规模商用的法律存证区块链,一个底层基于Onchain DNA区块链技术,并由多个机构参与建立和运营的证据记录和保存系统。该系统没有中心控制点,且数据一旦录入,单个机构或节点无法篡改,从而满足司法存证的要求。
The legal chain is the world’s first large-scale commercial chain of legal holdings, with a bottom-line based on Onchain DNA block chain technology, with multiple institutions involved in the establishment and operation of a system of evidence recording and preservation. The system does not have a central control point, and once the data are entered, individual agencies or nodes cannot be tampered with, thus meeting the requirements for judicial evidence.
Corda是由一家总部位于纽约的区块链创业公司R3CEV开发的,由其发起的R3区块链联盟,至今已吸引了数十家巨头银行的参与,其中包括富国银行、美国银行、纽约梅隆银行、花旗银行、德国商业银行、德意志银行、汇丰银行、三菱UFJ金融集团、摩根士丹利、澳大利亚国民银行、加拿大皇家银行、瑞典北欧斯安银行(SEB)、法国兴业银行等。从R3成员的组成上也可以看出,Corda是一款专门用于银行与银行间业务的技术架构。尽管R3声称Corda不是区块链,但它具备区块链的一些重要特性。
Corda, developed by R3CEV, a New York-based block chain start-up company, has so far attracted the participation of dozens of large banks, including wealthy banks, United States banks, New York Melon Bank, Citibank, German commercial banks, Deutsche Bank, HSBC, Mitsubishi UFJ Financial Group, Morgan Stanley, National Bank of Australia, Royal Bank of Canada, Banco Norte de Seño (SEB) of Sweden, and the Bank of Episcopalism of France. From the composition of the R3 members, Corda is a technical structure dedicated to banking and interbank business. Although R3 claims that Corda is not a sector chain, it has important features of the sector chain .
Corda由Java和Kotlin开发,并在其各项功能中充分依赖于Java,比如智能合约、数据访问接口等。Corda的设计目标主要是:
Corda is developed by Java and Kotlin and relies heavily on Java in its functions, such as smart contracts, data access interfaces, etc.
1、没有全局账本
1. No global book of accounts
2、由公证人(Notaries)来解决交易的多重支付问题
2. The multiple payment of a transaction by a notary (notaries)
3、只有交易的参与者和公证人才能看到交易
3. Only participants in the transaction and notaries can see the transaction
为此,Corda的所有交易都不会向全网进行广播,而且所有的节点都是直接通信,没有P2P网络。这一点导致了其网络规模会被限制在一个较小的规模内,无法形成大规模的联盟链,适用的业务场景比较狭窄。
For this reason, all Corda’s transactions are not broadcast on the Internet, and all nodes are direct communications without a P2P network. This has led to a limited network size that does not allow for large-scale alliances and a narrower business landscape.
接下来,我们将针对前文中所提到的这些区块链框架进行一系列的技术对比,并从多个维度展开讨论它们的区别与相似之处。
Next, we will conduct a series of technical comparisons with the framework of the blocks chain referred to in the preceding paragraph and discuss their differences and similarities from multiple dimensions.
区块链的内置代币通常是一种经济激励模型和防止垃圾交易的手段。比特币天生就有且只有一种内置代币,所以在比特币系统中所有的“交易”本质上都是转账行为,除非通过外部的协议层来给比特币增加额外的数字资产。
The built-in token of the block chain is usually an economic incentive model and a means of preventing garbage trading. bitcoin has a natural and only one built-in token, so all “transactions” in the bitcoin system are essentially transfers unless extra digital assets are added to bitcoin through the external contract layer.
以太坊和Onchain DNA具有内置代币,它们的作用除了以上提到的经济激励和防止垃圾交易之外,还为系统内置功能提供了一个收费的渠道。比如以太坊的智能合约运行需要消耗GAS,而Onchain DNA的数字资产创建也需要消耗一定的代币(可选)。
In addition to the above-mentioned economic incentives and the prevention of garbage trading, the use of Taiwan and Onchain DNA has built-in tokens that provide a fee-for-charge channel for the system’s functionality. For example, Taichain’s smart contracts require the consumption of GAS, while Onchain’s digital asset creation also requires the consumption of some tokens (optional).
以太坊和Fabric没有内置的多种数字资产支持,而是通过智能合约来实现相应的功能。这种方式的好处在于,系统设计可以做到非常简洁,而且资产的行为可以任意指定,自由度极高。然而这样的设计也会带来一系列的负面影响,比如所有的资产创建者不得不自己编写重复的业务逻辑,而用户也没有办法通过统一的方式去操作自己的资产。
The benefits of this approach are that systems can be designed in such a way as to be very simple and that assets can be designated at will and with a high degree of freedom. However, such design also has a number of negative implications, such as all asset creators having to prepare their own duplicate business logic, and users have no way of operating their assets in a uniform manner.
相比之下,Onchain DNA和Corda采用了在底层支持多种数字资产的方式,让资产创建者可以方便地创建自己的资产类型,而用户也可以在同一个客户端中管理所有的资产。对于逻辑更加复杂一点的业务场景来说,他们同样可以利用智能合约来强化资产的功能,或者创建一种与资产无关的业务逻辑。
Onchain DNA and Corda, by contrast, take the approach of supporting multiple digital assets at the bottom, so that asset creators can easily create their own asset types, and users can manage all assets in the same client. For a business scene where logic is more complex, they can also use smart contracts to enhance the functionality of assets or create a business logic that is not asset-related.
?
UTXO(Unspent Transaction Output)是这样一种机制:每一枚数字货币都会被登记在一个账户的所有权之下,一枚数字货币有两种状态,即要么还没有被花费,要么已经被花费。当需要使用一枚数字货币的时候,就将它的状态标记为已经花费,并创造一枚新的与之等额的数字货币,将它的所有权登记到新的账户之下。在这个过程中,被标记为已花费的数字货币就被称为交易的输入,而创造出来的新的数字货币被称为交易的输出,在一笔交易中,可以包含多个输入和多个输出,但是输入之和与输出之和必须相等。计算一个账户的余额时,只要将所有登记在该账户下的数字货币的面额相加即可。
UTXO (Unspent Transport Output) is a mechanism whereby each digital currency is registered under the ownership of an account, and a digital currency is in two forms, either not spent or spent. When a digital currency is needed, its status is marked as spent and a new digital equivalent is created to register its ownership under the new account. In this process, the new digital currency created, marked as spent, is referred to as the input of the transaction, and the value of the transaction is referred to as the output of the transaction, in which it may contain multiple inputs and multiple outputs, but the sum of the input and the amount of the output must be equal. When calculating the balance of an account, it is sufficient to add the face of all the digital currency registered under the account.
比特币和Corda就采用了UTXO这样一种账户机制,而以太坊则采用了更加直观的余额机制:每个账户都有一个状态,状态中直接记录了账户当前的余额,转账的逻辑就是从一个账户中减去一部分金额,并在另一个账户中加上相应的金额,减去的部分和加上的部分必须相等。Onchain DNA在账户机制上同时兼容这两种模式。
Bitcoin and Corda have adopted an account mechanism such as UTXO, while Etheria has adopted a more intuitive balance mechanism: each account has a state in which the current balance of the account is recorded directly, and the logic of the transfer is to deduct a portion of the amount from one account and add the corresponding amount to another account, which must be equal. Onchain DNA is compatible with both models on the account mechanism.
那么UTXO模式和余额模式,究竟有什么区别呢?UTXO最大的好处就是,基于UTXO的交易可以并行验证且任意排序,因为所有的UTXO之间都是没有关联的,这对区块链未来的扩展性有很大的帮助,而基于余额的设计就没有这个优势了。反过来,余额设计的优点是设计思想非常简洁和直观,便于程序实现,特别是在智能合约中,要处理UTXO的状态是非常困难的。这也是为什么以智能合约为主要功能的以太坊选择余额设计的原因,而比特币、OnchainDNA、Corda这些以数字资产为核心的架构则更倾向于UTXO设计。
So what's the difference between the UTXO model and the balance model? The greatest benefit of UTXO is that transactions based on UTXO can be verified in parallel and sorted randomly, because all UTXOs are unrelated, which greatly facilitates the future expansion of the block chain, and the balance-based design has no such advantage. Conversely, the balance design has the advantage of being very concise and intuitive in its design, which makes it very difficult to deal with the status of UTXO, especially in smart contracts.
关于身份认证,比特币和以太坊基本没有身份认证的设计,原因很简单,因为这两者的设计思想都是强调隐私和匿名,反对监管和中心化,而身份认证就势必要引入一些中心或者弱化的中心机构。
As far as identification is concerned, Bitcoin and Ethio have virtually no design for identification, for the simple reason that both are designed to emphasize privacy and anonymity and to oppose regulation and centralization, which makes it necessary to introduce a number of centres or weakened central institutions.
Fabric、Onchain DNA和Corda不约而同地选择了采用数字证书来对用户身份进行认证,原因在于这三者都有应用于现有金融系统的设计目标,而金融系统必然要考虑合规化并接受监管,此外现有的金融系统已经大范围地采用数字证书方案,这样便可以和区块链系统快速集成。
Fabric, Onchain DNA and Corda have chosen digital certificates to authenticate user identities in the same way, because they are designed to apply to the existing financial system, which necessarily considers compliance and regulation, and because the existing financial system has adopted digital certification schemes on a large scale, allowing rapid integration with block chain systems.
共识机制是分布式系统的核心算法,因为分布式系统的数据分散在各个参与节点中,这些分散的数据必须通过一种算法来保持一致性,否则系统将无法正常工作。与传统的分布式系统不同,区块链是一个去中心化的系统,并且可能会承载大量的金融资产,所以它可能会面临大量的拜占庭故障而非一般性故障,而中心化的分布式系统则很少遇到拜占庭故障。因此,区块链的共识机制与传统的分布式系统存在较大的差异。
The consensus mechanism is the core algorithm of the distributed system, because the distributed system's data are scattered among the various participating nodes, and the scattered data must be consistent with an algorithm, otherwise the system will not work properly. Unlike the traditional distribution system, the block chain is a decentralised system and may carry a large number of financial assets, so it may face a large number of Byzantine failures rather than general failures, while the centralized distribution system rarely encounters Byzantine failures.
比特币和以太坊采用了工作量证明(Proof-of-Work)机制来保证账本数据的一致性。工作量证明同时也是一种代币分发机制,它通过经济激励的方式来鼓励节点参与区块的构造过程,节点在构造区块的时候需要穷举一个随机数以使得区块符合规定的难度要求,一旦区块链出现分叉,诚实的节点将选择工作量较大的链条,而抛弃工作量较小的。由于假设所有节点都是逐利的,而选择工作量较小的链条就会使自己获得的激励无效,所以最终所有的节点都会是诚实的,从而使每个节点的区块链数据都保持一致。
Bitcoin and Etheria have used the Proof-of-Work mechanism to ensure consistency in book data. workload proof is also a token distribution mechanism that encourages nodes to participate in the construction process of blocks through economic incentives, which require a random number of blocks to be constructed to meet the required difficulty, and honest nodes to choose larger chains, while leaving smaller ones behind. Since it is assumed that all nodes are profit-driven, the selection of smaller nodes would render the incentive to themselves ineffective, all nodes would ultimately be honest, so that the serial data for each node would be consistent.
为了维护这样一个工作量证明机制的区块链,需要全网具备较大规模的算力支撑来保证网络的安全性,否则账本数据就有可能被篡改。此外,即使维持较大的算力来保护网络,工作量证明也无法从根本上保证交易的最终性,比如比特币就经常产生孤立区块(Orphaned Block),而包含在孤立区块中的交易就有可能被撤销。因此比特币通常要求用户等待6个区块的确认,即1小时左右的时间,才能在一个可接受的概率上认为交易已经最终完成,而这个概率也并非是最终性的——你永远也不知道暗中是否有一个远超过全网的庞大算力正在试图撤销以前的交易。而为了维护庞大算力而支出的电力成本也是相当可观,因此,以太坊已经在设计从工作量证明机制切换到其他共识机制上的方案。
In order to maintain the chain of blocks of such a workload proof mechanism, a larger network-wide computing power is required to ensure the security of the network, without which the book data may be tampered with. Moreover, even if a larger network is maintained, workload proof cannot fundamentally guarantee the finality of the transaction, for example, that Bitcoin often produces isolated blocks (Orphaned Block) and that transactions contained in isolated blocks can be cancelled. Thus, Bitcoin usually requires users to wait for confirmation from six blocks, i.e., an hour or so, in order to assume that the transaction is finally completed on an acceptable probability, and that the probability is not final – you never know whether there is an enormous amount of calculation in the dark that goes far beyond the Internet trying to cancel previous transactions.
Fabric和Onchain DNA都设计了基于拜占庭容错(Byzantine Fault Tolerance)模型的共识机制。节点被分为普通节点和记账节点(Validating Peer),只有记账节点才会参与到区块的构造过程,这种角色的分离使得算法的设计者有机会将运行共识算法的节点数量限定在一个可控的规模内。
Fabric and Onchain DNA both designed a consensus mechanism based on the Byzantine Fault Tolerance model. nodes are divided into ordinary nodes and account nodes (Validating Peer) and only account nodes are involved in the construction of blocks. This separation of roles gives the designer of the algorithm the opportunity to limit the number of nodes running the Consensus algorithm to a manageable size.
拜占庭容错模型对网络中的节点做出了假设和要求:如果共识中有f个节点会出现拜占庭故障,那么至少需要3f+1个节点参与共识才能避免网络出现分叉。在这个模型下,每个区块的构造过程都需要至少2f+1个节点的参与才能够完成,而不像工作量证明机制下每个节点都独立构造区块。一旦区块被构造出来,它就无法被撤销,因为2f+1个诚实的记账节点不会在同一高度对两个不同的区块进行签名认证。
The Byzantine Error Model assumes and requires nodes in the network: if a Byzantine malfunction occurs in the F node in the consensus, at least 3f+1 node in the consensus will be required to avoid a network split. Under the model, the construction process of each block will require at least 2f+1 node in order to be completed, rather than building blocks independently of each node under the workload proof mechanism. Once the block is constructed, it will not be withdrawn, because 2f+1 honest booking nodes will not be signed at the same height for two different blocks.
相比较而言,工作量证明机制提供了极高的灵活性和可用性,因为每个节点都独立构造区块而几乎不需要其他节点的参与,节点可以随时加入或者退出网络,即使全网只剩下一个节点,网络还是可以继续工作,但是相应的它也失去了交易的最终性;而拜占庭容错的机制则与之相反,牺牲了一定的灵活性和可用性,记账节点必须在线提供服务而不能退出网络,一旦出现1/3的记账节点停机,那么网络将变得不可用,但它保证了交易的最终性。
By contrast, the workload-evidence mechanism provides a very high degree of flexibility and availability, since each node is constructed independently of the other nodes, with little or nodes required to participate, the node can be added to or out of the network at any time, and even if there is only one node left on the network, the network can continue to work, but the corresponding node loses the finality of the transaction; the Byzantine node, by contrast, has sacrificed some flexibility and availability, the account node must be available online and cannot withdraw from the network, and if a one-third account node is down, the network becomes unusable, but it ensures the finality of the transaction.
智能合约是1994年由密码学家尼克萨博(Nick Szabo)首次提出的理念,几乎与互联网同龄。智能合约是指能够自动执行合约条款的计算机程序,在比特币出现以前,因为不存在安全可靠的执行环境,智能合约一直不能够应用到现实中。区块链由于其去中心化、公开透明等特性,天生就可以为智能合约提供可信的执行环境。所以,新型的区块链框架几乎都会内置智能合约的功能。
Smart contracts are the idea first proposed in 1994 by the cryptographer Nick Szabo, almost the same age as the Internet. Smart contracts are computer programs that can implement their terms automatically, and, until Bitcoin appears, smart contracts cannot be applied to reality because of the absence of a safe and secure enforcement environment.
比特币内置了一套基于栈的脚本执行引擎,可以运行一种独有的脚本代码,用于对交易进行简单的有效性验证,比如签名验证和多重签名验证等。比特币这套脚本语言被有意设计成非图灵完备的,足够简单却也足以应对货币转账的各种需求。
Bitcoin has a store-based script execution engine that can run a unique script code for simple validation of transactions, such as signature validation and multiple signature validation. The bitcoin script language is deliberately designed to be non-tulling, simple enough to respond to the demand for money transfers.
以太坊是首个以图灵完备智能合约为主要功能的区块链,用户可以在以太坊的平台上创建自己的合约,而合约的内容可以包含货币转账在内的任意逻辑。合约使用一种名为Solidity的语言来编写,它是以太坊团队开发的专门用于编写智能合约的一种高级语言,语法类似JavaScript,最终被编译成字节码并运行在EVM(Ethereum Virtual Machine)之中。EVM提供了堆栈、内存、存储器等虚拟硬件,以及一套专用的指令集,所有的代码都在沙盒中运行。它提供了合约间相互调用的能力,甚至可以在运行时动态加载其它合约的代码来执行。这种能力使得以太坊的合约具有非常高的灵活性,但也可能会使合约的功能具有不确定性。
The Etherm is the first block chain with the primary function of the Turing Smart Contract. Users can create their own contracts on the Taiteng platform, and the contract contains any logic for currency transfers. The contract is written in a language called Solidity, which is an advanced language developed by the Taitern Team dedicated to the preparation of intelligent contracts. The syntax is similar to JavaScript, which is eventually translated into bytes and operated in EVM. The EVM provides virtual hardware such as stacking, memory, storage, and a dedicated set of instructions, all of which operate in sandboxes. It provides the ability to interlock contracts, and can even be implemented by dynamically loading other contracts at the time of operation.
与以太坊自己动手开发语言、虚拟机的思路不同,Fabric选择了使用现有的容器技术来支持智能合约功能。Fabric的智能合约理论上可以用任何语言来编写,这一点对开发者相当友好,他们将无需学习新的语言,并且可以复用现有的业务代码和丰富的开发库,并使用自己熟悉的开发工具。相对的,采用Docker的智能合约架构也有大量的问题:首先,它很难对智能合约的执行流程进行控制,从而无法对其功能进行限制;其次,它无法对合约运行所消耗的计算资源进行精确的评估;此外,运行Docker相对而言是极其耗费资源的操作,这就使得难以在移动设备上运行合约;最后,不同节点的硬件配置、合约引用的开发库等,都有可能会使合约的行为具有很强的不确定性。
Unlike the idea of a virtual machine, Fabric chose to use existing container technology to support intelligent contract functions. Fabric's smart contract could theoretically be written in any language, which is quite friendly to developers, who will not need to learn new languages and will be able to reuse existing business codes and rich development banks, as well as to use their familiar development tools. In contrast, there are many problems with the smart contractual structure using Docker: first, it is difficult to control the implementation process of a smart contract, which makes it impossible to limit its functionality; secondly, it is impossible to accurately assess the computing resources consumed by contract operations; moreover, the operation of Docker is a relatively resource-intensive operation, which makes it difficult to operate contracts on mobile equipment; and finally, hardware configuration at different points, contract reference development banks, etc., all have the potential to create considerable uncertainty about contract behaviour.
Onchain DNA采用了AVM(Antshares Virtual Machine)作为其智能合约功能的底层支持。AVM是一个微核心的、平台无关的智能合约执行环境,它提供了一套包含堆栈操作、流程控制、逻辑运算、算数运算、密码学运算、字符串操作、数组操作的指令集,在硬件方面,它只提供了两个计算堆栈。不过,由于它允许区块链的实现者创建自己的虚拟硬件,并以接口的形式开放给智能合约来使用,使得合约可以在运行时取得平台相关的数据、持久化存储以及访问互联网等。虽然这也有可能会使合约的行为具有不确定性,但区块链的实现者可以通过合理编写虚拟硬件来消除这种不确定性。不过,由于目前尚无与AVM配套的编译器和开发环境,这使得基于AVM进行智能合约开发变得相当困难,开发者不得不使用一种类似汇编的语法来进行合约编写,需要较高的技术能力。
Onchain DNA uses AVM as a base support for its intellectual contract function. AVM is a micro-core, platform-related intelligent contract enforcement environment that provides uncertainty about how to operate, process control, logical calculations, cryptographic calculations, string operations, arrays of instructions. However, since there is currently no AVM-backed compiler and development environment, it makes it difficult to create its own virtual hardware and to open it to smart contracts in the form of interfaces, making it possible to obtain platform-related data, sustainable storage, and access to the Internet. While this may also create uncertainty about the behaviour of the contract, the realization of the block chain can overcome this uncertainty by reasonably developing virtual hardware.
Corda的智能合约功能与其自身一样,都是基于JVM(Java Virtual Machine)的。因此,你可以使用任何与JVM兼容的语言来进行开发,比如Java、Kotlin等。不过,它对JVM进行了一定的改造,使得在其上运行的合约脚本具备确定性。开发的过程大致是这样的:使用Java创建一个实现Contract接口的类(Class),并提供一个名为verify的函数(Function)用于对交易进行验证,该函数接受当前的交易作为参数,如果交易验证失败,则抛出异常(Exception),没有异常就表示验证通过。Corda使用JPA(Java Persistence Architecture)来提供持久化功能,支持SQL语句和常用的数据库,不过需要安装相应的插件,并且由于数据仅存放在合约执行者的节点,因此无法进行全局的持久化存储。
Corda's smart contract function, like itself, is based on JVM. , so you can use any language compatible with JVM for development, such as Java, Kotlin, etc. However, it has made some modifications to JVM, making the contract script running on it certain. The process is largely as follows: Java is used to create a class (Class) to achieve the Contract interface and to provide a function for validation of the transaction (Function), which accepts the current transaction as a parameter, and if the transaction is not validated, then the exception (Exception) is not an exception. Corda uses the JPA to provide durable functionality, supports the SQL phrase and the usual database, but requires the installation of the corresponding plugins, and because the data is stored only at the site of the contract implementer, it is not possible to make permanent storage of the entire site.
区块链的数据结构通常是只能追加记录,而不能修改或删除记录,它真实地记录下完整的历史数据,使得新加入的节点有能力对全网的完整交易历史进行验证,而无需信任其它节点。这种特性带来了去中心化的便利性,但也影响了区块链系统的扩展性,因为区块会无休止地增长,直到塞满整个硬盘。所以有必要提供一种空间回收的机制来应对不断增长的数据。
The data structure of the block chain is usually additional to the records, which cannot be modified or deleted, and which actually records the complete historical data so that the newly added nodes can validate the complete web-wide transaction history without trusting other nodes. This feature makes it easier to decentralize, but it also affects the expansion of the block chain system, since blocks will grow endlessly until they are filled with the entire hard disk. It is therefore necessary to provide a mechanism for spatial recovery to cope with the growing data.
比特币提出了使用默克尔树(Merkle tree)来存放交易散列的方式,当需要回收硬盘空间时,只需将老旧的交易从默克尔树中剔除即可。一个不含交易信息的区块头大小仅有80字节。按照比特币区块生成的速率为每10分钟一个,那么每一年产生的数据约为4.2MB,即使将全部的区块头存储于内存之中都不是问题。
bitcoin proposes the use of Merkle tree to store transactional hash, and simply removes old transactions from the Merkel when it is necessary to recover hard disk space. A block that does not contain trade information has only 80 bytes of size. Based on the speed of production of bitcoin blocks, the data generated in each year is about 4.2MB, even if it is not a problem to store the entire block head in memory.
以太坊、Fabric和Onchain DNA在比特币区块压缩的基础上,又采用了状态快照的方式来节约硬盘空间。具体来说,就是在区块头的结构中不但记录了当前区块所有交易的根散列,还记录了当前区块及过去所有区块中的状态根散列。这些状态包括所有的UTXO、账户余额、合约存储等,所以节点只需要保留最新的区块和完整的状态信息即可。
saves hard disk space by using state snapshots based on the compressed DNA of Tails, Fabric and Onchain in bitcoin. Specifically, the structure of blocks records not only the roots of all current block transactions, but also the status of the current block and all past blocks. These states include all UTXOs, account balances, contract storage, etc., so nodes only need to keep up-to-date block and complete status information.
扩展性的另一个重要指标是交易的吞吐量。决定吞吐量的因素有很多种,如网络结构、加密算法、共识机制等,但最重要的还是交易是否可以被并行验证。如果交易可以被并行验证,那么未来就可以通过简单地增加CPU数量来提高吞吐量。
Another important indicator of expansion is the volume of traffic. There are many factors that determine the amount of traffic, such as network structures, encryption algorithms, consensus mechanisms, etc. But the most important is whether the transaction can be verified in parallel.
基于UTXO系统的比特币可以很容易地对交易进行并行验证,因为UTXO之间是没有关联的,对任何一个UTXO的状态改变都可以独立进行且与顺序无关;而基于余额的账户系统则不那么容易实现并行,因为可能会同时发生多笔交易对同一个账户进行资产操作,需要进行一些额外的步骤来处理。举个例子,假设账户中的余额为10元,有两笔针对该账户的交易同时发生,第一笔交易在账户中+5元,而第二笔交易在账户中-11元。那么如果先执行第一笔交易,则两笔都能成功,最终余额为4元;如果先执行第二笔交易,那么它会因余额不足而失败,只有第一笔交易会成功,最终余额为15元。
Bitcoin based on the UTXO system can easily be verified in parallel, because UTXO is unconnected, and changes in the status of any UTXO can be made independently and not in sequence; the balance-based account system is not so easy to achieve parallels, because there may be multiple transactions to operate assets on the same account at the same time, and additional steps are required. For example, assuming that the balance in the account is 10 dollars, that there are two transactions in the account at the same time, that the first transaction is +5 dollars in the account, and that the second transaction is –11 dollars in the account. If a transaction is executed first, then it will be successful, with a final balance of 4 dollars; if a second transaction is executed first, it will fail because the balance is insufficient, only the first transaction will be successful and the final balance will be $15.
而对交易的并行验证起到决定性作用的,是智能合约是否具备状态持久化的能力。如果一组合约都是无状态的,那么它们就可以按任意的顺序被执行,不会产生任何副作用;相反,如果合约可以对一组状态产生影响,那么按不同的顺序来执行合约产生的结果也会不同。举个例子,一个计算存款利息的合约,它具有两个子功能:存款和利息结算。假设账户中有100元,利率为10%,现在同时发生了两笔交易,第一笔交易的内容是存入100元,第二笔交易的内容是结算利息。假如第一笔交易先执行,那么最终账户的余额是:100+100)*110%=220元;如果第二笔交易先执行,那么账户余额将是:100*110%+100=210元。由此可见,具备状态持久化能力的智能合约是顺序相关的,因此难以并发验证,特别是如果合约之间还可以相互调用的话,情况将会更加复杂。
For example, a contract that calculates interest on deposits has two subfunctional functions: deposit and interest settlement. Assuming that there are 100 dollars in the account, 10% interest rate, two transactions have occurred at the same time, the first one is 100 dollars and the second transaction is interest settlement. If the first transaction is executed first, the final account balance will be 100+100* 110% = 220 dollars; if the second transaction is executed first, the account balance will be 100*110 + 100 = 210 dollars.
目前Fabric没有提出什么好的办法来解决这个问题;而Corda则没有这个问题,因为它的交易本身就不会向全网进行广播,所以只要交易参与者和公证人可以验证即可。以太坊和Onchain DNA的方法都是分区,即将各个合约分到不同的逻辑区中,每个区中的合约都顺序执行,而不同的区之间并行执行。以太坊将合约地址的首个字节作为分区依据,由此产生了256个分区,每个合约都在自己的分区中运行,且只能调用与自己相同分区的合约。但这种做法实际上并不能有效地解决问题,因为总有一些通用的底层合约因为被广泛使用,而把大多数的调用者合约聚集在同一个分区中。
Fabric does not currently propose any good solution to this problem; Corda does not have this problem because its deal itself will not be broadcast to the whole network, so only participants and notaries can verify it. Ethio and Onchain DNA methods are partitions, assigning contracts to different logical zones, where contracts are executed in sequence and in parallel between different districts. By using the first bytes of the contract address as the basis for partitions, there are 256 subdistricts, each operating in its own subdistrict, and only using contracts with its own subdistricts.
Onchain DNA将合约分为功能合约(Function code)和应用合约(Applicationcode)。其中功能合约专门用于提供可复用的功能函数,被其它合约调用,且必须被声明为无状态,这一点消除了绝大部分的合约聚集现象;而只有应用合约可以保存自己的状态,所以在执行应用合约时,对其采用动态分区方案:在合约被执行之前,会先计算出它们的调用树,并将调用树有交集的合约放在同一个分区中执行。
Onchain DNA divides the contract into a functional contract (Function code) and an application contract (Applicabilitycode). The functional contract is dedicated to providing reusable functional functions, is called by other contracts and must be declared indeterminate, which eliminates the great majority of contract conglomerations; while only the application contract can preserve itself, the application contract is implemented using a dynamic zoning programme: before the contract is enforced, the call tree is calculated and the call log contract is placed in the same partition.
5大项目独有特性
Features unique to five major projects
幽灵协议是以太坊对现有POW算法的改进,它提出的动机是当前快速确认的区块链因为区块的高作废率而受到的低安全性困扰。因为区块需要花一定时间扩散至全网,如果矿工A挖出了一个区块然后矿工B碰巧在A的区块传播至B之前挖出了另外一个区块,矿工B的区块就会作废并且没有对网络安全作出贡献。如果A是一个拥有全网30%算力的矿池而B拥有10%的算力,A将面临70%的时间都在产生作废区块的风险而B在90%的时间里都在产生作废区块。通过在计算哪条链“最长”的时候把废区块也包含进来,幽灵协议解决了降低网络安全性的第一个问题;这就是说,不仅一个区块的父区块和更早的祖先块,祖先块的作废的后代区块(以太坊术语中称之为“叔区块”)也被加进来以计算哪一个区块拥有最大的工作量证明。以太坊付给以“叔区块”身份为新块确认作出贡献的废区块87.5%的奖励,把它们纳入计算的“侄子区块”将获得奖励的12.5%。计算表明,带有激励的五层幽灵协议即使在出块时间为15s的情况下也实现了95%以上的效率,而拥有25%算力的矿工从中心化得到的益处小于3%。
The phantom agreement is an improvement in the existing Pow algorithm. It is motivated by the low security distress of the currently rapidly recognized chain of blocks due to the high rate of waste of blocks. Because blocks need to spread over a period of time to the whole net, if miners A dig out a block and then miners B coincidentally dig up another block before block A spreads to B, the miner B’s block will be destroyed and will not contribute to cybersecurity. If A is a 30-per-cent-capture tank and B has 10-per-cent capacity, A will be exposed to a 70-per-cent-time risk of creating a waste block, while B will be able to generate a waste block in 90-per-cent-time time. By adding a “several” to the chain, the ghost agreement solves the first problem of reducing cybersecurity; that is to say, not only the parent block of a block in a block, but also the early ancestors’ block, have an incentive block of 10-per-cent-per-cent-cent-per-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-cent-of-of-cent-cent-of-of-the-the-the-the-the-the-the-the-the-life zone zone zone-the-life zone-the-the-the-the-the-the-the-life zone-the-the-the-the-the-life zone-the-the-the-the-the-the-the-the-the-the-the-the-life zone-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-the-
国密算法是由中国国家密码管理局制定的一系列商用密码学算法,其中包括了对称加密算法SM1,椭圆曲线非对称加密算法SM2,杂凑算法SM3等。通常区块链在使用密码学算法时会采用国际标准,如AES、ECDSA、SHA2等。而国内的金融机构在选用密码学方案的时候,通常会考虑国密算法。Onchain DNA提供了可选的密码学模块,针对不同的应用场景可以选择不同密码学标准,解决了安全性和政策性风险。
National secret algorithms are a series of commercial cryptography algorithms developed by the Chinese National Password Authority, including symmetric cryptography algorithm SM1, elliptical asymmetric encryption algorithm SM2, patchy algorithm SM3. Often block chains use international standards when using cryptography algorithms, such as AES, ECDSA, SHA2.
目前,区块链技术正处于百花齐放、百家争鸣的时代,各种不同的区块链纷纷涌现出来,区块链之间的互操作性成为了一个非常重要而又迫切的需求。企业用户可能需要在不同的链之间进行业务迁移;普通用户可能需要在不同的链之间进行资产交换;央行的数字法币可能会需要在各个区块链上流通等。Onchain DNA提供了一种跨链互操作协议,通过这种跨链协议,用户可以跨越不同的区块链进行资产交易、合约执行等操作,并保证该操作在各个区块链上的事务一致性。
At present, block chain technology is in an era of flowering and bickering, with different blocks chains emerging, and interoperability between blocks becoming a very important and urgent need. Business users may need to migrate between chains; ordinary users may need to exchange assets between chains; central banks may need to circulate digital French coins across blocks.
正如Corda在白皮书中所宣称的那样,它没有链式结构,交易也不向全网进行广播,而只在交易的参与者和公证人之间发送。因此,数据只有“需要访问的人”才能访问,避免了隐私泄露的问题。由于没有全局的链式结构,每个节点只存放和自己有关的交易,而无需存放全网的所有交易,大大的节省了空间。
As Corda declared in the White Paper, it does not have a chain structure and transactions are not broadcast on the Internet, but only between participants and notaries. Thus, data can only be accessed by “persons who need to be interviewed” to avoid disclosure of privacy.
本文从多个维度比较并讨论了当前各个区块链框架的特点和功能,并阐述了它们在各方面的优缺点,以及在应用领域上的适用性和局限性。
The paper compares multiple dimensions and discusses the characteristics and functions of the current framework of the block chains and describes their strengths and weaknesses in various areas, as well as their applicability and limitations in the field of application.
比特币虽然是区块链技术的原型,具有非常重要的地位,但由于其技术架构的局限性,如挖矿、非图灵完备等,很难应用到复杂的业务场景中去,但非常适合用于货币发行。
Bitcoin, although a prototype of block chain technology and of great importance, is difficult to apply to complex business scenes because of its technical architecture limitations, such as mining, non-turing, etc., but is well suited for currency distribution.
以太坊虽然也采用挖矿的形式,但其幽灵协议提高了挖矿效率,新的共识算法也在开发中。以太坊还开发了较多基于密码学的隐私保护方案,比如环签名混币方案,非常适合于创建去中心化自治组织(Decentralized Autonomous Organization)。
Even though it also takes the form of mining, the phantom agreement improves the efficiency of mining, and new consensus algorithms are being developed. It has also developed more cryptography-based privacy protection programmes, such as the Ring Sign Coin Scheme, which is well suited to creating decentralised self-government organizations.
Fabric和Onchain DNA的定位都是企业级区块链解决方案,适合用于定制各种特定业务的联盟链,包括金融领域的应用场景。区别在于Fabric以智能合约为导向,而Onchain DNA则以数字资产为导向;前者更适合开发复杂的自定义业务流程,而后者则更适合于构建以数字资产为核心的金融业务系统或权益登记流转系统,且具有较强的扩展性。
The location of Fabric and Onchain DNA is enterprise-level block chain solutions that are suitable for customizing the various business-specific chains, including the financial field. The difference is that Fabric is guided by smart contracts, whereas Onchai DNA is driven by digital assets; the former is better suited to develop complex, self-defined business processes; and the latter is better suited to build financial business systems or equity registry systems with digital assets at their core, with a stronger expansion.
Corda的定位是用于银行间业务的“分布式数据库”,它摒弃了区块和链式结构,更好地把参与者的业务数据区隔开来;但引入了公证人的角色,网络结构较为固定不具灵活性和扩展性,且与现有的银行体系的运作方式差别不大。
Corda was positioned as a “distributed database” for inter-bank operations, leaving blocks and chain structures to better separate participants' business data areas; however, the role of notaries was introduced, the network structure was more fixed and not flexible and expansionary and did not differ significantly from the way the existing banking system operated.
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论