Link to the original text: http://tabalt.net/blog/consor…
Alliance chain and hyperledger fabric
What is alliance chain?
According to the different degree of decentralization, three kinds of blockchains in different application scenarios are differentiated
- Public chain: the whole network is open, and the majority of users can participate in it
- Alliance chain: it is used between multiple organizations, allowing authorized nodes to join the network, and querying or modifying information according to permissions
- Private chain: all nodes in the network are in the hands of one organization
Advantages and disadvantages of alliance chain
Compared with public chain, alliance chain has more advantages in efficiency and flexibility
- The transaction cost is lower, and the transaction only needs to be verified by several trusted nodes with high computing power, without confirmation of the whole network.
- The nodes are small in scale and can be connected well. The fault can be repaired quickly by human intervention.
- We can use the deterministic consensus algorithm and shorten the block generation time to complete the transaction faster.
- Read and write permissions can be controlled to provide better privacy protection.
- The participants of the alliance chain can more easily reach an agreement to update the rules of the blockchain, restore the transaction, modify the balance, etc.
- Compared with the public chain, the decentralization of alliance chain is not enough
The development prospect of alliance chain
Alliance chain supported by policy
- It does not rely on issuing currency to encourage users to participate, and there is no regulatory problem
- It doesn’t need to consume a lot of power resources to mine
Alliance chain is the technical carrier of “blockchain +”
- Support the demand of some data in the existing business system
- Trust created by alliances creates new business direction
The development status of alliance chain
Lack of killer apps
- There are a lot of people landing on the ground, but few people applauding
Difficulties in alliance building
- It needs enough influence to unite the unrelated and even competing institutions
Large initial investment and weak profitability
- No money, capital comes from traditional financing channels
- It is difficult to make profits before the scale of business is formed
Technical bottleneck to be broken through
- With the increase of the number of nodes, the network structure becomes more and more complex, and the performance and stability are reduced
- The characteristics of blockchain make it difficult to support large capacity and large-scale data storage
Application of alliance chain
Alliance chain technology platform
Introduction to hyperledger fabric
- Hyperledger is an open source project initiated by Linux foundation to promote cross industry application of blockchain, and fabric is the most successful sub project.
- With highly modular and configurable architecture, it can support a wide range of industry use cases, such as banking, finance, insurance, medical and so on.
- Support to use general programming language (such as go / Java)/ Node.js ）Instead of a constrained domain specific language (DSL) to write smart contracts.
- Pluggable consensus protocol is supported to adapt to the specific trust model. The authorization of nodes is convenient for network governance, and there is no need to issue cryptocurrency to stimulate accounting.
- Fabric is an open source enterprise class licensed distributed ledger technology platform. Its differentiated design can provide enterprises with directly available security, scalability, confidentiality and high performance.
Identity and membership
- Fabric uses X.509 format certificate as identity to identify all participants in the blockchain network, and provides some attributes for determining the permission. The certificate is issued by the certification authority (CA).
- Fabric also provides a membership service provider (MSP) to determine which CAS are trusted, list organization membership, identify the specific roles of participants in the organization, and define network and channel access rights.
- Fabric’s ledger consists of two different but related parts: state of the world and blockchain.
- Word stat saves the current value of the ledger data, which can be changed frequently and is easy for applications to access directly. It is essentially a kV database and currently supports leveldb and CouchDB.
- Blockchain records all the change logs that lead to the current world state, which cannot be modified after being written, so it is convenient for history tracking.
Smart contracts and chaincode
- Smart contract defines the transaction logic of a specific business process, mainly in the world state to place, obtain, delete state, or query blockchain transaction records, which is the focus of application development.
- Chain code is a set of technology containers for installing and instantiating smart contracts. A chain code can contain multiple smart contracts.
- Peer component is the basic element of fabric blockchain network. It hosts ledger and smart contract, and can host multiple ledger and smart contract at the same time.
- Blockchain network has multiple peer nodes under multiple organizations, and peer nodes have the identity assigned by digital certificate issued by specific ca.
- The channel allows a group of specific peer nodes and applications to communicate with each other in the blockchain network. The channel does not actually exist, but is a logical structure formed by a collection of physical peer nodes.
- Each channel has a completely independent ledger, which means a completely independent blockchain and a completely independent world state.
- An organization can join multiple channels to participate in multiple independent blockchain networks.
- Fabric uses a special node called sorting service to sort transactions and generate blocks, forming a deterministic consensus mechanism. Any block generated by the sorting service can be guaranteed to be final and correct, without bifurcation.
- The sorting service also maintains a list of organizations that are allowed to create channels, and implements basic access control on channels, thus limiting who can read, write and configure their data.
There are three kinds of implementation of sorting service, which make the nodes reach a consensus on the strict transaction order
- Solo: there is only one sort node, which is not fault-tolerant, but can be used in development test environment
- Kafka: crash tolerant (CFT) mechanism, elects leader nodes, and followers copy their decisions
- Raft: it is also a crash tolerance (CFT) mechanism, which is easier to configure and manage than Kafka
Construction process of blockchain network
- Organization R4 creates network configuration NC4, and relevant identity certificates are issued from certification authority CA4
- Start the sorting service O4, and the network is formed
- The organization R4 updates the network configuration NC4 and allows R1 to become an administrator. R1 and R4 have the same rights in the network configuration
- The network administrator defines a federation x1, which consists of two members, organizations R1 and R2
- The relevant identity certificates of R1 and R2 are issued by CA1 and Ca2 respectively
- Channel C1 is created for R1 and R2 using Federation definition x1, and the connection between sorting service O4 and channel C1 is established
- The channel is controlled by channel configuration CC1, which is completely independent of the network configuration. CC1 is managed by R1 and R2 who have equal rights to C1
- Peer node P1 joins channel C1. P1 hosts ledger L1 and installs smart contract S5. P1 and O4 can communicate with each other through C1
- Application A1 also joins channel C1, A1 connects to P1 and O4 at the same time through C1, A1 can access L1 through S5 on P1 node
- P1 and A1 belong to organization R1, and the relevant identity certificates are issued by CA1
- Peer P2 and application A2 of organization R2 join channel C1, and the relevant identity certificate is issued by Ca2
- Node P2 also hosts a copy of ledger L1 and installs smart contract S5
- Organizations R1 and R2 can trade on a blockchain network through channel C1
- A new federation X2 is defined, which includes organizations R3 and R2. R3 related identity certificates are issued by CA3
- The channel configuration CC2 managed by R2 and R3 is created, channel C2 is started, and an independent blockchain network is formed
- P3 and A3 of tissue R3 were added with C2, and P2 and A2 of tissue R2 were added with C2
- Peer node P2 hosts ledger L2 at the same time, installs smart contract S6, and application A2 can access two blockchain networks at the same time
Complete process of transaction (consensus formation)
Stage 1: proposal
- Application A1 generates a transaction proposal and sends it to each required peer for signature
- Each signature node uses the transaction suggestion to execute the smart contract independently to generate and return the suggestion response. At this time, the ledger will not be updated
- Application A1 receives a sufficient number of signed proposal responses to complete phase 1
Phase 2: sorting and packaging
- A1 submits the transaction proposal response containing the signature to the sorting service node O1
- O1 receives batch submitted transactions at the same time, arranges them into well-defined sequences, and packages them into blocks
- O1 doesn’t judge the transaction content, but just mechanically packages it. The transaction order that arrives at the same time may not be consistent with the order in the block
Phase 3: validation and submission
- O1 distributes the packed blocks to peer nodes, and the nodes that are not online can synchronize from other nodes through gossip protocol
- Each peer will independently but determinedly verify the block (signature matching, not invalidated by other transactions)
- Invalid transactions remain in immutable blocks, but peers mark them as invalid and do not update the world state
- After the ledger is updated, the peer node can notify the connected application that the transaction has been processed
- Official document: https://hyperledger-fabric.re…
- Github： https://github.com/hyperledge…
Link to the original text: http://tabalt.net/blog/consor…