As we mentioned earlier, in blockchain 3.0, the form of smart contract + private chain has been developed, and the most widely used form of this form is what we will talk about today: Hyperledger fabric.
1. Introduction to Hyperledger fabric
Hyperledger Fabric is a distributed ledger solution platform based on a modular architecture. It is an alliance chain project initiated by IBM. It was handed over to the Linux Foundation at the end of 2015 and became an open source project. There are many big names in the members of the Hyperledger Foundation, such as IBM, Intel, Cisco, etc. Many blockchain projects have been incubated in the foundation, and Fabric is the most famous one. Generally speaking, Hyperledger basically refers to Fabric.
Hyperledger fabric is not currency technology, but blockchain technology. Therefore, fabric has no concept of mining and is green and environmentally friendly.
2. Advantages of Hyperledger fabric
1. Distributed ledger storage
2. Each node saves complete data, so that the data cannot be tampered with.
3. Data in the blockchain cannot be deleted, but can only be added and modified. The changed data status is World State
3. Use Hyperledger fabric to solve real-world problems
If Company A and Company B want to exchange assets, the data is stored in their own servers.
Since Company A and Company B do not trust each other, the two companies need to reconcile accounts. In fact, the accounts often do not match.
General traditional solution:
Solve by introducing a third-party central organization. In fact, this method also has problems: 1. High cost
. Each structure has its own ledger, and the data is consistent. 2. The fabric ensures data synchronization. 3. If organization A tampers with the data, other organizations will find that the data of organization A is wrong. 4. In fact, the fabric solution is a trust issue.
case analysis
Project: Jiangsu Provincial Department of Agriculture and Animal Husbandry Blockchain Fishery Management System
Participants in the fishery supply chain
channel
If Wang Dazhuang’s transactions with restaurants A and B are placed on the same channel, then the price privacy data cannot be guaranteed.
In Hyperledger fabric, channel can be understood as an independent instance. Participants are called peers.
In fact, it can be understood as two WeChat groups,
chaincode (smart contract)
Chaincode is a smart contract. It is the only way to read and modify data.
Chaincode belongs to a certain channel, and all peers in the channel need to install the Chaincode, otherwise data inconsistency will result.
The life cycle of Chaincode is:
1) install install
2) instantiate init
3) call invoke
work process
The SDK is an API that provides operations for the client, and has nothing to do with the implementation language.
peer
1) peer0, peer1, and peer2 are in the same channel
2) Multiple peers must have the same MSP (Membership Service Provider) to communicate.
suggestion
1) The client initiates a proposal through the SDK, such as: I need to modify a piece of data.
2) After receiving the proposal, each peer performs a simulation execution, which will generate a read-write set, and internally uses the version mechanism to record the state before and after modification.
endorsement
1) Each peer will send the simulated execution result and signature to the SDK
update application
1) After the SDK collects a certain number of endorsements, it will send a formal update application to the orderer
orderer
1) Verify the content and signature of the request
2) If the verification is complete and there is no problem, a real call update will be sent to each peer, and each peer will actually perform the update.
3) If the request is illegal, it will also be saved to the block chain to facilitate subsequent review.
4) Sorting solves the double-spending problem by converting parallel problems into serial execution.
Practical application in the project
The essence of the pain points is trust issues:
1) Restaurants don’t trust Wang Dazhuang
2) Regulators don’t trust restaurants
3) Regulators don’t trust Wang Dazhuang
4) Wang Dazhuang’s privacy issues