Hyperledger fabric on SAP Cloud Platform

Source: Internet
Author: User
Tags sorts hyperledger fabric

Today's article is from Wen Aviva, who is a face-to-face programmer of Jerry.

Jerry has introduced Aviva in his previous article titled "displaying the 3D model view of product master data with pure Javascript in sap ui, other colleagues in the SAP Chengdu c4c development team commented that:"Beauty and wisdom embodiment","Queen of the cloud age","Is the Guide to cutting-edge technologies". Because Jerry and Aviva are in a group, my opinion is that these reviews are all named.

For example, Jerry learned about JavaScript 3D rendering and augmented reality (ARgumentREality) and hyperledger fabric mentioned in this article are all learned from Aviva.

Each colleague of SAP Chengdu Research Institute participated in the activity of scanning the lucky character to receive red packets at the annual meeting at the end of 2017, theoretically, Aviva and Zhao Rina, another Chengdu programmer, are used to develop small ar-based applications.

In early July 2017, the Chengdu c4c development team was just created. In addition to the boss Max, there were only five members:Haha, brother David, like a teacher, Brother Yong and a Shuang. At that time, the most pressing problem facing the new development team was to win the trust of c4c's U.S. Development headquarters, so as to move from its headquarters to Chengdu. What can be used to gain trust? For programmers, it is of course talk is cheap, show me the code. At that time, the team of five people who had just been set up did not know about c4c, but chose a Chinese customer with a high level of voices and hoped to add it to the backlog of c4c standard products. In just one month, the five-member team completed the entire process from learning c4c product knowledge and development knowledge in the front and back, to implementing backlog as a prototype. After the original videos were delivered to the U.S. Development boss, they were highly praised. They were amazed that it took only one month for the team to create and productive. The successful completion of this prototype laid a solid foundation for the subsequent development and growth of the c4c team in Chengdu.

The final delivery form of this prototype is the iOS app. At that time, none of our five colleagues developed the iOS platform. Fortunately, we have Aviva. Max rented Aviva from SAP Chengdu digital innovation space. With her help, the prototype release was successfully completed. Even more admirable, Aviva shares her iOS development experience with other colleagues in the team. Now, many colleagues in the c4c team can work on the iOS platform. I think, when the c4c team in Chengdu participated in the programming marathon in March this year, the team was named"Hi Aviva!", Maybe I want to thank Aviva for its contribution to the c4c team in this way.

Jerry is glad to be able to work with such colleagues every day.

The following is the body of Aviva.

What is blockchain? In short, blockchain is a distributed ledger or distributed database.

The data structure of the blockchain is a linked list. transaction data is stored in the block of the linked list. The first block of the blockchain is the creation block. Apart from the creation block, each block also contains the hash pointer of the previous block. The value of this hash pointer is calculated based on the actual data of the previous block. The hash pointer refers to the forward block, and the block following it can find the information of all the blocks above.

The data structure of the ledger is such a linked list. What does the distributed structure mean?

Many participants in the blockchain form a loose and self-governing P2P network. We call the participants in the blockchain network a node. Each node has a ledger copy, and all the ledger information is consistent, there are no central nodes in the blockchain. Every time a new transaction comes in, the ledger of all nodes will be updated and eventually consistent. The update method is not to modify the value of a block, but to save transaction records. For example, in the bitcoin system, it does not have the concept of user asset record. Unlike ordinary databases, it uses a data storage asset, the values of bitcoin user assets are obtained by concatenating all transaction records. The asset sources in the account can be traced up until the block is created. The transaction data in the blockchain can be any information that needs to be recorded according to the specific scenario.

Smart contract

To support continuous information updates and manage the ledger (write transactions and query), blockchain network introducesSmart contractTo access and control the ledger. Smart contracts can be used not only to package information in the blockchain network, but also to automatically perform specific transaction operations defined by participants.

For example, a smart contract can specify the transportation costs in logistics, charge different fees based on the speed of logistics, and automatically transfer the money based on the arrival time of the goods. The smart contract uploaded to the blockchain network is packaged into a block. Therefore, once written into the blockchain, the smart contract cannot be changed.

Consensus Mechanism

The process of synchronizing transaction information in the blockchain network ensures that the transaction is updated only after the approval of the appropriate participants. All participants will update the same information in the same order, such a process is called consensus. Consensus mechanism is one of the core of blockchain.

The first application of blockchainBitcoinThe consensus mechanism of proof work is adopted. A Brief Introduction to the bitcoin consensus mechanism. You can check the White Paper for details about the algorithm. After receiving a transaction, the node checks the validity of the transaction based on the judgment criteria. invalid transactions are discarded. Transactions that pass verification will be broadcast to other nodes. Other nodes perform the same independent verification. When Valid transactions reach all nodes in the network,This transaction is valid"Consensus. Each node receives many valid transactions that have not been packaged into a block. These transactions are assembled into a Merkle tree. The first transaction of the Merkle tree is special, called coinbase, which is created by the node itself, pay the mining reward to the miner's address. The mining rewards include the newly created Bitcoin and the total service fees for all transactions packaged into the block. Then the node calculates a hash value that meets the difficulty. The mining is to continuously calculate the hash value of the block by modifying the parameters until the difficulty requirement is met, which indirectly proves that the node has paid the corresponding workload, this is the proof of workload. In Jerry's public account article "Implementing a simplest blockchain prototype by using the ABAP method cl_abap_message_digest => calculate_hash_for_char", line 1 ABAP code is used to calculate the hash value of a block.

When the node calculates a difficult block hash, it indicates that the miner has successfully mined the block. The Node assembles the block into the local blockchain, this block is also broadcast to other nodes. After receiving the block, other nodes verify that the block is valid. It is possible that two nodes have dug up the new blocks B1 and B2 at the same time. The previous blocks are the same block p. Some nodes may receive B1 first, and some may receive B2 first. At this time, the blockchain has two temporary forks. To break this situation, it depends on whether the next block is generated based on B1 or B2. If the chain B1 is based on, it becomes the longest chain. Other nodes that contain B2 will re-select the longest chain, and B2 will be discarded as an isolated block.

So far, we can regard blockchain as a shared, decentralized multi-Backup System, and update transaction data through smart contracts, at the same time, all nodes in the network are consistent through the collaboration process of consensus.

Transactions can refer to any data, such as digital currency, contracts, records, or any other information.

Blockchain type
  • Public chain: nodes in the network can be connected at will, and the data read and write permissions in the network are unrestricted. All nodes participate in the consensus process. Bitcoin, ethereum, and other digital currencies all belong to the public chain.

  • Private chain: nodes in the network are controlled by an organization and are exclusively authorized to write data to the blockchain. Private chain is not much different from other distributed storage.

  • Consortium: multiple companies or organizations access the consortium through authorization and some nodes participate in the consensus process. Hyperledger fabric belongs to the consortium chain.

What is hyperledger fabric?

Hyperledger fabric is one of the hyperledger projects launched by the Linux Foundation. Hyperledger fabric is an open-source blockchain-based distributed ledger designed for use in enterprise environments. Hyperledger fabric can be used in global supply chain management, financial transactions, asset accounting, human resources, insurance, health and digital music.

The Ledger Subsystem (ledger) in hyperledger fabric includes two components:World View (World State) andTransaction Log (Transaction Log ). The world view records the current situation of the ledger at a specific time point. It is a key-value database. The transaction log records all transactions that generate the current value of the world status, which is the update history of the world outlook. The underlying database of the ledger world view can be changed. You can choose leveldb or couchdb.

Hyperledger fabric is the first blockchain platform that supports writing smart contracts in common languages. You can use Java, nodejs, and go to write smart contracts. The smart contract in hyperledger fabric is also called chain code ).

Unlike other public blockchain platforms, hyperledger fabric is private and can be accessed only after authorization.MSP (The membership service provider module provides the member management service.

CA (Certificate Authority) is responsible for permission management, Member identity-related certificate management (enrollment certificateauthority), and transaction-related certificate management (transaction Certificate Authority.

Hyperledger fabric provides the channel creation function, which allows participants to create a separate ledger for transactions. This feature becomes especially important when some participants in the network are competitors. Because these participants do not want all transaction information-for example, the specific price information provided to some customers-to be made public to all participants on the network. Only the participants in the same channel can have the account book in the channel. Other participants not in this channel cannot see this account book.

Hyperledger fabric uses an independent sorting node (order) to provide consensus services, order transactions, and globally confirm the transaction order.

The application accesses hyperledger fabric through the SDK.

In the design of the latest hyperledger fabric version, node roles are decoupled based on functions to allow different nodes to handle different types of workloads. In terms of business logic, the node is divided into the endorsement node (endorser) and the commit node (committer ).

  • Endorser peer: checks the validity and permissions of the transactions from the client (simulates the transaction). if the transaction is verified, the signature is signed and the result is returned to the client.

  • Committer peer: maintains the ledger, checks the status of batch transaction results in an agreed order, generates blocks, executes legal transactions, and writes them to the ledger, the same physical node can assume both the endorser and committer roles.

Hyperledger fabric transaction process: consensus

The consensus process consists of three phases: Proposal, packaging, and validation.

Proposal

The application submits a transaction proposal and then submits it to all endorsement nodes. After receiving the request, the latter executes the chaincode as the input to generate the corresponding transaction proposal response. At this time, the ledger is not updated, but the signature of the transaction proposal is responded and returned to the application. After the application receives the response from the signature, the first phase of the consensus process is completed.

Packaging

In this phase, the Order node sorts and packages transactions. The Order node receives the proposal response from each application, sorts the transactions, sorts them, and packs them into blocks.

Validation

In the last phase of the consensus process, the Order node distributes the block to all nodes connected to it. These nodes confirm that the transactions in the block are signed by the endorsement node, then, update the confirmed block to the ledger.

The entire process is called consensus. All nodes have reached an agreement on the transaction content and order. This process is controlled by the Order node. Consensus is a multi-step process. The account book is updated only when the entire process is completed. The update time of each node may be slightly different.

Hyperledger fabric service on SAP cloud platform (1)

Building a hyperledger fabric platform is not easy. It requires both hardware infrastructure investment and comprehensive development and operation management (devops ). In addition to the platform itself, a complete set of solutions also include management functions such as device access, access control, and service monitoring.

SAP cloud platform (SCP) provides the out-of-the-box hyperledger fabric service, providing powerful service support for developers:

  • The intuitive and friendly visual monitoring and operation interface helps developers apply for blockchain networks as needed and create management nodes and channels without considering underlying hardware resources.

  • A simple and easy-to-use smart contract development and testing environment allows developers to conveniently manage application code.

  • Security and privacy are guaranteed, and performance of related resources is optimized.

The above are some of my understanding of hyperledger fabric. The time to contact and understand blockchain is limited, and some errors are inevitable. please correct me. We will introduce some details about hyperledger Fabric development on the SAP cloud platform in the future.

References

  • Hyperledger fabric Official Website

    Https://hyperledger-fabric.readthedocs.io/en/latest/whatis.html

  • Hyperledger fabric service on SCP

    Https://help.sap.com/viewer/p/HYPERLEDGER_FABRIC

For more original Jerry articles, follow the Public Account "Wang zixi ":

Hyperledger fabric on SAP Cloud Platform

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.