Home > Backend Development > Golang > Practical Blockchain-Hyperledger Fabric (1) 10-minute introduction for beginners

Practical Blockchain-Hyperledger Fabric (1) 10-minute introduction for beginners

michael li
Release: 2020-04-28 13:54:15
Original
3941 people have browsed it

Introduction

Hello everyone, my name is Michael, and I now work for an Internet company in Shanghai. As the government attaches great importance to the blockchain project, people are beginning to say that 2020 will It is the first year of the development of blockchain. I have talked about blockchain many times with my friends and wanted to practice it myself. So after researching many options such as Ethereum, EOS, NEO and so on, I chose the alliance chain, which is our Today’s protagonist is Hyperledger fabric.

Article structure

This series of articles will be divided into three parts. The three articles will help you get started with Hyperledger Fabric development and build your own alliance chain project:

1. Basic introduction

2. Environment setup

3. Application deployment and startup

Basic introduction

Hyperledger fabric - the new hope of the blockchain world

December 2015 , the flagship organization of the open source world, the Linux Foundation, took the lead and united with 30 initial corporate members (including IBM, Accenture, Intel, J.P. Morgan, R3, DAH, DTCC, FUJITSU, HITACHI, SWIFT, Cisco, etc.) to jointly announce Super The establishment of the Hyperledger joint project. The Hyperledger project is committed to providing an open source reference implementation for transparent, open, and decentralized enterprise-level distributed ledger technology, and promoting the development of blockchain and distributed ledger related protocols, specifications, and standards. The official website of the project is hyperledger.org, and Hyperledger fabric is one of its important projects.

Many new students may not know much about the many terms specific to blockchain, so in the first section I will introduce to you the terms involved in Hyperledger fabric.

Noun introduction:

Anchor Peer - Anchor node An anchor node is a peer that can be detected by all peer nodes in the channel and can communicate with it node. Each member in the channel has one (or more, in case of single point of failure) anchor node, allowing nodes with different memberships to discover other nodes present in the channel.

Block – A block is a collection of ordered transactions on a channel. Blocks are often connected to preceding blocks by cryptographic means (hash values).

Zhu Jiang: A block is an ordered set of transactions that are encrypted (hash-encrypted) in the channel and connected to the previous block.

Chain – Chain chain is a transaction log structured with hash connections between blocks. The peer receives the transaction block from the order service, marks whether the transaction on the block is valid based on the endorsement policy and concurrency conflicts, and then appends the block to the hash chain in the peer file system. Z

hu Jiang: The chain of the ledger is a transaction log structured by "hash connection" of transaction blocks. The peer node receives the transaction block from the ordering service, marks the block's transaction as valid or invalid based on the endorsement policy and concurrency conflicts, and appends the block to the hash chain of the peer node's file system.

Chaincode – Chaincode Chaincode is a software that runs on the ledger. It can encode assets, and the transaction instructions (or business logic) can also be used to modify assets.

Channel - Channel is a private blockchain built on the "Fabric" network, which achieves data isolation and confidentiality. The channel-specific ledger is shared with all peers in the channel, and transacting parties must be properly authenticated by the channel to interact with the ledger. Channels are defined by a "configuration block".

Commitment – ​​Commitment Each peer in a channel validates an ordered block of transactions and then commits (writes or appends) the block to each copy of the ledger on the channel. Peers also mark the status of each transaction in each block as valid or invalid.

Concurrency Control Version Check – Concurrency Control Version Check (CCVC) CCVC is a method of keeping state synchronized between peers in a channel. Peer nodes execute transactions in parallel. Before the transaction is submitted to the ledger, the peer node checks whether the data read during the transaction execution has been modified. If the read data is changed between execution and commit, a CCVC conflict will occur, the transaction will be marked as invalid in the ledger, and the value will not be updated in the state database.

Configuration Block – The configuration block contains configuration data that defines members and policies for a system chain (ordering service) or channel. Configuration modifications to a channel or the entire network (e.g., members leaving or joining) will cause a new configuration block to be generated and appended to the appropriate chain. This configuration block will contain the contents of the genesis block plus the increment.

Consensus – Consensus is a broad term used throughout the entire transaction process to produce an agreed upon order and confirm the correctness of the set of transactions that make up a block.

Current State – The current state of the ledger represents the latest values ​​of all keys in its chain transaction log. The peer will submit the modified value corresponding to each transaction in the processed block to the current state of the ledger. Since the current state represents all the latest k-v known to the channel, the current state is also called World State. Chaincode executes the transaction proposal against the current state.

Dynamic Membership – Dynamic Membership Fabric supports dynamic addition and removal of members, peers and ordering service nodes without affecting the operability of the entire network. Dynamic Membership is crucial when business relationships are adjusted or entities need to be added or removed for various reasons.

Endorsement – ​​Endorsement refers to the process in which a peer executes a transaction and returns YES-NO to the client app that generated the transaction proposal. The chaincode has corresponding endorsement policies, in which endorsing peers are specified.

Endorsement policy - Endorsement policy defines the necessary combination of conditions (i.e. conditions for returning Yes or No) of peers and response results (endorsements) on the channel that relies on a specific chaincode to execute transactions.

Endorsement policy can specify the minimum number of endorsement nodes or the minimum percentage of endorsement nodes that can endorse a transaction for a certain chaincode. Endorsement policies are organized and managed by endorsing nodes based on the application and desired level of protection against bad behavior. The endorsement policy needs to be specified when installing and instantiate Chaincode (deploy tx).

Fabric-caFabric-ca is the default certificate management component that issues PKI-based certificates to network members and their users. The CA issues a root certificate (rootCert) for each member, a registration certificate (eCert) for each authorized user, and a large number of transaction certificates (tCerts) for each registration certificate.

Genesis Block - The initial block Genesis Block is the configuration block that initializes the blockchain network or channel, and is also the first block on the chain.

Gossip Protocol - Gossip Protocol The Gossip data transmission protocol has three functions:

1) Manage peer discovery and channel members;

2) Broadcast ledger among all peers on the channel Data;

3) Synchronize ledger data between all peers on the channel.

Initialize – Initialize a method to initialize the chaincode program.

Install – The process of installing chaincode into the peer’s file system. (Annotation: The ChaincodeDeploymentSpec information is stored in the chaincodeInstallPath-chaincodeName.chainVersion file)

Instantiate – the process of instantiating and starting the chaincode container. (Annotation: Save ChaincodeData to state in lccc, then deploy Chaincode and execute the Init method) Invoke – Call is used to call functions within the chaincode.

Chaincode invoke is a transaction proposal, and then executes a modular process (endorsement, consensus, verification, submission). The structure of invoke is a function and a parameter array.

Leading Peer - Leading Node Each Member can have multiple peers on the channel it subscribes to, and one of the peers will serve as the leading peer of the channel to communicate with the ordering service on behalf of the Member. The ordering service delivers the block to the leading peer, which then distributes the block to other peers under the same member.

Ledger – Ledger A ledger is a channel’s chain and current state data which is maintained by each peer on the channel. Ledger is a channel’s chain and world state maintained by each peer in the channel. (This explanation is a bit strange)

Member – A legally independent entity whose members own the unique root certificate of the network. Network components such as peer nodes and app clients are linked to a Member.

Membership Service Provider – MSPMSP refers to the system abstract component that provides certificates for clients and peers.

Clients use certificates to authenticate their transactions; peers use certificates to authenticate their transaction endorsements. This interface is closely related to the transaction processing component of the system and is designed to allow defined membership service components to be plugged in smoothly in this way without modifying the core of the transaction processing component of the system.

Membership Services - Membership Services Membership Services authenticate, authorize and manage identities on a permissioned blockchain network.

The member service code running in peer and order will authenticate and authorize blockchain operations. It is an MSP implementation based on PKI. The fabric-ca component implements membership services to manage identities. In particular, it handles the issuance and revocation of ECerts and TCerts. ECert is a long-term identity credential; TCert is a short-term identity credential, which is anonymous and unlinkable.

Ordering Service – The ordering service or consensus service sorts transactions into a set of nodes in the block.

The ordering service is independent of the peer process and sorts transactions for all channels on the network on a first-come, first-served basis. The ordering service supports pluggable implementation, and currently SOLO and Kafka are implemented by default. The ordering service is a common binding for the entire network and contains cryptographic materials related to each Member. Peer – A network entity that maintains the ledger and runs the Chaincode container to perform read-write operations on the ledger. Peers are owned and maintained by Members.

Policy – ​​Strategies include endorsement strategy, verification strategy, block submission strategy, Chaincode management strategy and network-channel management strategy.

Proposal – Propose an endorsement request for a peer in the channel. Each proposal is either Chaincode instantiate or Chaincode invoke.

Query – Query request for the value of a key in the current state.

Software Development Kit – SDKSDK provides developers with a structured library environment for writing and testing chaincode applications.

The SDK can be completely configured and extended through standard interfaces, and components such as signed encryption algorithms, logging frameworks, and state storage can be easily replaced. The SDK API uses gRPC for transaction processing, and member services, node traversal, and event processing are all used to communicate with the fabric. Currently the SDK supports Node.js, Java and Python.

State Database – stateDB In order to efficiently read and write from Chaincode, Current state data is stored in stateDB, including levelDB and couchDB.

System Chain – The system chain contains the configuration blocks that define the network at the system level.

The system chain exists in the ordering service. Similar to the channel, it has an initial configuration containing the following information: MSP information, policy and information configuration. Any changes to the entire network (such as new Org joining or adding new Ordering nodes) will cause new configuration blocks to be added to the system chain.

The system chain can be regarded as the common binding of a channel or a group of channels. For example, a collection of financial institutions can form a consortium (represented by a system chain) and then create channels based on their same or different businesses.

Transaction – The invoke or instantiate operation of transaction Chaincode. Invoke requests the read-write set from the ledger; Instantiate requests to start the Chaincode container on the peer.

Summary:

The above is the basic knowledge of blockchain that we introduced to you in the first section. These may be boring, but we need to understand these terms and content A preliminary understanding is just like when we write code, we need to know the function names and keywords. Only by mastering these can we start our work better.

The above is the detailed content of Practical Blockchain-Hyperledger Fabric (1) 10-minute introduction for beginners. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template