Hyperledger-Fabric模型
Hyperledger-Fabric模型
This section outlines the key design features woven into Hyperledger Fabric that fulfill its promise of a comprehensive, yet customizable, enterprise blockchain solution:
本节概述了编织到Hyperledger Fabric中的关键设计功能,这些功能实现了其全面,可定制的企业区块链解决方案的承诺:
-
Assets — Asset definitions enable the exchange of almost anything with monetary value over the network, from whole foods to antique cars to currency futures.
资产定义了允许通过网络交换的几乎所有具有货币价值的东西,从食品到古董车再到货币期货。
-
Chaincode — Chaincode execution is partitioned from transaction ordering, limiting the required levels of trust and verification across node types, and optimizing network scalability and performance.
链码执行从交易顺序中划分出来,从而限制了跨节点类型所需的信任和验证级别,并优化网络可伸缩和性能。
-
Ledger Features — The immutable, shared ledger encodes the entire transaction history for each channel, and includes SQL-like query capability for efficient auditing and dispute resolution.
不变的,共享的账本对每个通道的整个交易历史进行编码,并包括类似SQL的查询功能,以进行有效的审计和争议解决。
-
Privacy — Channels and private data collections enable private and confidential multi-lateral transactions that are usually required by competing businesses and regulated industries that exchange assets on a common network.
通道和隐私数据收集可实现私人和机密的多边交易,通常是在竞争企业和受管制的行业(在同一网络上交换资产)所需要。
-
Security & Membership Services — Permissioned membership provides a trusted blockchain network, where participants know that all transactions can be detected and traced by authorized regulators and auditors.
获得许可的成员资格提供了一个受信任的区块链网络,参与者知道所有交易都可以由授权的监管机构和审计师检测和追踪。
-
Consensus — A unique approach to consensus enables the flexibility and scalability needed for the enterprise.
一种唯一的共识方法可以实现企业所需的灵活性和可伸缩性。
Assets
Assets can range from the tangible (real estate and hardware) to the intangible (contracts and intellectual property). Hyperledger Fabric provides the ability to modify assets using chaincode transactions.
资产范围从有形资产(房地产和硬件)到无形资产(合同和知识产权)。Hyperledger Fabric提供了使用链码交易修改资产的功能。
Assets are represented in Hyperledger Fabric as a collection of key-value pairs, with state changes recorded as transactions on a Channel ledger. Assets can be represented in binary and/or JSON form.
资产在Hyperledger Fabric中表示为键值对的集合,状态更改记录为通道账本中的交易。资产可以二进制和/或JSON形式表示。
Chaincode
Chaincode is software defining an asset or assets, and the transaction instructions for modifying the asset(s); in other words, it’s the business logic. Chaincode enforces the rules for reading or altering key-value pairs or other state database information. Chaincode functions execute against the ledger’s current state database and are initiated through a transaction proposal. Chaincode execution results in a set of key-value writes (write set) that can be submitted to the network and applied to the ledger on all peers.
链码是定义了一个或多个资产的软件,以及用于修改资产的交易指令;Chaincode强制执行用于读取或更改键值对或其他状态数据库信息的规则。链码功能针对账本的当前状态数据库执行,并通过交易提议启动。链码执行产生的一组键值写操作(写集),这些键值写操作可以提交给网络,并应用于所有peer的账本中。
Ledger Features
The ledger is the sequenced, tamper-resistant record of all state transitions in the fabric. State transitions are a result of chaincode invocations (‘transactions’) submitted by participating parties. Each transaction results in a set of asset key-value pairs that are committed to the ledger as creates, updates, or deletes.
账本是Fabric中所有有序的、防篡改的状态转换。状态转换是参与方提交的链码调用(“交易”)的结果。每个交易都会产生一组资产键值对,这些键值对会在创建,更新或删除时提交到账本中。
The ledger is comprised of a blockchain (‘chain’) to store the immutable, sequenced record in blocks, as well as a state database to maintain current fabric state. There is one ledger per channel. Each peer maintains a copy of the ledger for each channel of which they are a member.
账本由区块链组成,以区块形式存储不可变的、有序的记录,以及用于维护当前结构状态的状态数据库。每个通道有一个账本。每个peer都为其所属的每个通道维护一个账本的副本。
Some features of a Fabric ledger(Fabric账本的一些功能):
-
Query and update ledger using key-based lookups, range queries, and composite key queries
使用基于键的查找,范围查询和组合键查询来查询和更新分类帐
-
Read-only queries using a rich query language (if using CouchDB as state database)
使用丰富查询语言的只读查询(如果使用CouchDB作为状态数据库)
-
Read-only history queries — Query ledger history for a key, enabling data provenance scenarios
只读历史记录查询—为一个key查询史记录,从而启用数据出处场景
-
Transactions consist of the versions of keys/values that were read in chaincode (read set) and keys/values that were written in chaincode (write set)
交易由链码中读取的键/值的版本 (读取集)和用链码编写的键/值(写入集)所组成。
-
Transactions contain signatures of every endorsing peer and are submitted to ordering service
交易包含每个背书peer的签名,并提交给排序服务
-
Transactions are ordered into blocks and are “delivered” from an ordering service to peers on a channel
交易被排序并打包成区块,并从排序服务“交付”到通道上的peer节点
-
Peers validate transactions against endorsement policies and enforce the policies
Peer根据背书策略验证交易并执行政策
-
Prior to appending a block, a versioning check is performed to ensure that states for assets that were read have not changed since chaincode execution time
在追加区块之前,执行版本检查,以确保自链码执行以来,已读取资产的状态未发生变化
-
There is immutability once a transaction is validated and committed
交易一旦经过验证并提交,便具有不变性
-
A channel’s ledger contains a configuration block defining policies, access control lists, and other pertinent information
通道的账本包含一个配置块,用于定义策略、访问控制列表和其他相关信息
-
Channels contain Membership Service Provider instances allowing for crypto materials to be derived from different certificate authorities
通道包含MSP实例,允许从不同的证书颁发机构生成加密材料
See the Ledger topic for a deeper dive on the databases, storage structure, and “query-ability.”
有关数据库,存储结构和“查询能力”的更深入了解,请参阅账本主题。
Privacy
Hyperledger Fabric employs an immutable ledger on a per-channel basis, as well as chaincode that can manipulate and modify the current state of assets (i.e. update key-value pairs). A ledger exists in the scope of a channel — it can be shared across the entire network (assuming every participant is operating on one common channel) — or it can be privatized to include only a specific set of participants.
Hyperledger Fabric在每个通道的基础上使用不变的账本,以及可以操纵和修改资产当前状态的链码。账本存在于通道范围内-可以在整个网络中共享(假设每个参与者都在一个公共频道上进行操作)也可以仅包括一组特定的参与者以将其私有化。
In the latter scenario, these participants would create a separate channel and thereby isolate/segregate their transactions and ledger. In order to solve scenarios that want to bridge the gap between total transparency and privacy, chaincode can be installed only on peers that need to access the asset states to perform reads and writes (in other words, if a chaincode is not installed on a peer, it will not be able to properly interface with the ledger).
在后一种情况下,这些参与者将创建一个单独的通道,从而隔离/分离他们的交易和账本。为了解决总体透明度和隐私之间存在间隙的场景,链码只能安装在需要访问资产状态以执行读写的peer节点上(换句话说,如果未在peer节点上安装链码,则它将无法与账本正确连接)。
When a subset of organizations on that channel need to keep their transaction data confidential, a private data collection (collection) is used to segregate this data in a private database, logically separate from the channel ledger, accessible only to the authorized subset of organizations.
当该渠道上的部分组织需要对其交易数据保密时,私有数据集合用于将这些数据隔离在私有数据库中,从逻辑上与通道账本隔离,并仅允许组织的授权子集访问。
Thus, channels keep transactions private from the broader network whereas collections keep data private between subsets of organizations on the channel.
因此,通道使交易对于更广泛的网络而言是不公开的,而集合则对通道上的组织子集之间的数据不公开。
To further obfuscate the data, values within chaincode can be encrypted (in part or in total) using common cryptographic algorithms such as AES before sending transactions to the ordering service and appending blocks to the ledger. Once encrypted data has been written to the ledger, it can be decrypted only by a user in possession of the corresponding key that was used to generate the cipher text.
为了进一步混淆数据,在将chaincode中的数据发送给排序服务和追加到账本区块上之前可以使用标准的加密算法(如AES)进行加密。加密数据一旦写入分类帐,则只有拥有用于生成密文的密钥的用户才能对其解密。
See the Private Data topic for more details on how to achieve privacy on your blockchain network.
有关如何在区块链网络上实现隐私的更多详细信息,请参阅私有数据主题。
Security & Membership Services
Hyperledger Fabric underpins a transactional network where all participants have known identities. Public Key Infrastructure is used to generate cryptographic certificates which are tied to organizations, network components, and end users or client applications. As a result, data access control can be manipulated and governed on the broader network and on channel levels. This “permissioned” notion of Hyperledger Fabric, coupled with the existence and capabilities of channels, helps address scenarios where privacy and confidentiality are paramount concerns.
Hyperledger Fabric支持所有参与者都具有已知身份的交易网络。公钥基础结构用于生成与组织,网络组件以及最终用户或客户端应用程序绑定的加密证书。结果,可以在更广泛的网络和通道级别上操纵和控制数据访问控制。Hyperledger Fabric的“许可”概念以及通道的存在和功能,帮助解决隐私和机密至关重要的情况。
See the Membership Service Providers (MSP) topic to better understand cryptographic implementations, and the sign, verify, authenticate approach used in Hyperledger Fabric.
Consensus
In distributed ledger technology, consensus has recently become synonymous with a specific algorithm, within a single function. However, consensus encompasses more than simply agreeing upon the order of transactions, and this differentiation is highlighted in Hyperledger Fabric through its fundamental role in the entire transaction flow, from proposal and endorsement, to ordering, validation and commitment. In a nutshell, consensus is defined as the full-circle verification of the correctness of a set of transactions comprising a block.
在分布式分类帐技术中,共识最近已成为单一功能内特定算法的同义词。但是,共识不只是简单地约定交易顺序,Hyperledger Fabric通过在整个交易流程(从提案和认可,到排序,验证和提交)中的基本作用,突显了这种差异。简而言之,共识被定义为对包含一个区块的一组交易的正确性的全面验证。
Consensus is achieved ultimately when the order and results of a block’s transactions have met the explicit policy criteria checks. These checks and balances take place during the lifecycle of a transaction, and include the usage of endorsement policies to dictate which specific members must endorse a certain transaction class, as well as system chaincodes to ensure that these policies are enforced and upheld. Prior to commitment, the peers will employ these system chaincodes to make sure that enough endorsements are present, and that they were derived from the appropriate entities. Moreover, a versioning check will take place during which the current state of the ledger is agreed or consented upon, before any blocks containing transactions are appended to the ledger. This final check provides protection against double spend operations and other threats that might compromise data integrity, and allows for functions to be executed against non-static variables.
区块交易的顺序和结果满足明确的策略标准检查后,才能最终达成共识。这些检查和平衡发生在交易的生命周期中,并包括使用背书策略规定哪些特定成员必须背书某个交易类别,以及系统链码确保这些策略得到实施和维护。在作出承诺之前,peer将使用这些系统链码来确保存在足够的背书,并且背书来自适当的实体。此外,在将包含交易的任何块追加到账本之前,将进行版本控制检查,在此期间将对账本的当前状态进行被同意或同意。最终检查可以防止重复使用操作和其他可能危害数据完整性的威胁,并允许针对非静态变量执行功能。
In addition to the multitude of endorsement, validity and versioning checks that take place, there are also ongoing identity verifications happening in all directions of the transaction flow. Access control lists are implemented on hierarchical layers of the network (ordering service down to channels), and payloads are repeatedly signed, verified and authenticated as a transaction proposal passes through the different architectural components. To conclude, consensus is not merely limited to the agreed upon order of a batch of transactions; rather, it is an overarching characterization that is achieved as a byproduct of the ongoing verifications that take place during a transaction’s journey from proposal to commitment.
除了进行大量的背书,有效性和版本检查外,还在交易流程的各个方向上都在进行身份验证。访问控制列表是在网络的分层的层面实现的,当交易提议通过不同的架构组件时,有效载荷将被反复签名,验证和认证。总而言之,共识不仅限于一批交易的商定顺序;它更是一项总体特征,它是交易从提案到承诺过程中不断进行的验证的副产品。
Check out the Transaction Flow diagram for a visual representation of consensus.
查看交易流程图以直观表示共识。