为广大币圈朋友提供币圈基础入门专业知识!
当前位置首页 > 比特币基础> 正文

fabric区块链介绍,fabric区块链技术教程

发布时间:2023-12-12-15:58:00 来源:网络 比特币基础 区块   架构   网络

fabric区块链介绍,fabric区块链技术教程

Fabric区块链技术是一种分布式账本技术,它可以实现更快、更安全、更可靠的数据存储和交易。本文将介绍Fabric区块链技术的三个关键概念:节点,联盟链和智能合约。

节点:Fabric区块链技术是一种分布式账本技术,其中的核心概念是节点。节点是一种特殊的计算机,它可以运行Fabric区块链技术的软件,以及存储和处理区块链上的数据。节点可以安全地存储和传输数据,并且可以在网络中的其他节点之间进行安全的数据交换。

联盟链:联盟链是Fabric区块链技术的另一个核心概念。联盟链是一种分布式账本,可以由多个参与者共同维护。联盟链可以帮助企业和组织快速建立和管理共享的账本,从而更好地维护数据的安全性和可靠性。此外,联盟链还可以帮助企业和组织实现数据的可追溯性和可视性,从而更好地满足企业和组织的业务需求。

智能合约:智能合约是Fabric区块链技术的另一个核心概念。智能合约是一种可以在节点之间自动执行的程序,它可以根据区块链上的数据实现自动化的业务流程。智能合约可以帮助企业和组织实现数据的自动化处理,从而更好地实现业务流程的自动化,提高业务流程的效率。

以上就是Fabric区块链技术的三个关键概念:节点,联盟链和智能合约。Fabric区块链技术可以帮助企业和组织更好地管理和实现数据的安全性和可靠性,从而提高业务流程的效率。


请查看相关英文文档

㈠ First introduction to Hyperledger Fabric

Fabric is a consortium chain. Peer represents a series of organizations. Peers are the basis of the entire blockchain network because it is the basis of ledgers and smart contracts. carrier. Through smart contracts, the ledger records the entire transaction process in an immutable way.

For companies that cannot, there are different businesses, and different businesses are associated with different companies. Multiple alliance chains need to be created, so multiple channels need to be created. How many channels are there? A private network established between specific members for the purpose of confidential transactions. A peer can join multiple channels. Each channel maintains its own ledger. The ledgers are isolated from each other. Each channel can maintain one or more ledgers. . Therefore, in order to meet complex transaction requirements, different smart contracts can be installed on each peer. When the peer transaction is completed, an event will be sent to notify the Client. There is also a Local MSP (Member Service Provider) service on the peer, which provides functions such as identity authentication and cryptographic signatures.

WorldState maintains the current information of the current ledger in the form of key-value.

Smart Contract is the core of the blockchain, defining business specifications between different organizations, creating transactions and recording them in the ledger. Multiple smart contracts can be packaged into one chaincode. Smart contracts can only be used by applications after the chaincode is deployed.

Unlike ordinary chain codes that run in an independent container, system chain codes run on the peer process and implement some system behaviors.

In order to optimize network performance, improve security and scalability, Fabric divides each transaction into three parts: Endorsing Peer, Ording-Service and Committting Peer, which requires a secure, trusted and scalable data transfer protocol - Gossip Protocol. Gossip transmission protocol spreads information in a random mannerIn the network, it mainly performs three functions:

㈡ Brief analysis of Fabric Peer nodes

Hyperledger Fabric, also known as super ledger, was initiated by IBM and later became the Linux Foundation One of the blockchain projects in Hyperledger.

Fabric is a platform that provides distributed ledger solutions. The underlying ledger data storage uses blockchain. Blockchain platforms can usually be divided into public chains, alliance chains and private chains. Typical representatives of public chains are public blockchain networks such as Bitcoin, and anyone can join this network. The alliance chain has an access mechanism and cannot be added to the network at will. A typical example of the alliance chain is Fabric.

Fabric does not need to issue coins to motivate participants, nor does it require mining to prevent people from doing evil, so Fabric has better performance. In the Fabric network, there are also many different types of nodes to form the network. Among them, Peer nodes carry ledgers and smart contracts and are the foundation of the entire blockchain network. In this article, the structure of Peer and how it operates will be analyzed in detail.

In this article, it is assumed that readers already understand concepts such as blockchain and smart contracts.

This article is based on Fabric1.4 LTS.

The blockchain network is a distributed network, and so is Fabric. Since Fabric is a consortium chain and requires an access mechanism, the network structure will be much more complicated. Here is a simplified Fabric network:

The meaning of each element is as follows:

For the Fabric network, external users need to access the network through the client application, which is A1, A2 or A3 in the figure. The client application You need to identify yourself through the CA certificate so that you can access the authorized parts of the Fabric network.

In the above network, there are four organizations, R1, R2, R3 and R4. Among them, R4 is the creator of the entire Fabric network, and the network is configured according to NC4.

In the Fabric network, different organizations can form alliances, and data between different alliances are isolated through Channels. The data in the Channel can only be accessed by organizations in the alliance. Each new Channel can be considered as a new chain. Unlike other blockchain networks that usually only have one chain, Fabric can quickly build a new blockchain in the network through Channel.

Above R1 and R2 form an alliance and trade on C1. R2 also formed another alliance with R3 to trade on C2. When R1 and R2 trade on C1, they are invisible to R3. When R2 and R3 trade on C2, they are invisible to R1. The Channel mechanism provides good privacy protection capabilities.

The Orderer node is common to the entire Fabric network and is used to sort and package all transactions. For example, the O4 node in the above network. This article will not explain the Orderer node in detail. This function can be understood as the mining process in the Bitcoin network.

Peer node represents a node in the network. Usually a Peer represents an organization. Peer is the foundation of the entire blockchain network and the carrier of smart contracts and ledgers. Peer is also the focus of this article.

A Peer node can host multiple sets of ledgers and smart contracts. For example, the P2 node maintains not only C1's ledgers and smart contracts, but also C2's ledgers and smart contracts.

In order to have a deeper understanding of the role of Peer nodes, first understand the overall transaction process of Fabric. The overall transaction flow chart is as follows:

Peer nodes can be divided into endorsement nodes and accounting nodes according to their functions.

The client will submit a transaction request to the endorsement node, and the endorsement node will start to simulate the execution of the transaction. After the simulation execution, the endorsement node will not update the ledger data, but will encrypt and sign the transaction, and then Returned to the client.

After receiving this response, the client will submit the response to the Orderer node. The Orderer node will sort these transactions, package them into blocks, and then distribute them to the accounting node, and the accounting node will Verify the transaction. After the verification is completed, the transaction will be recorded in the ledger.

Whether a transaction can succeed is specified based on the endorsement strategy. Each smart contract will specify an endorsement strategy.

Peer nodes represent various organizations in the alliance chain. The blockchain network is also composed of Peer nodes and is also the carrier of ledgers and smart contracts.

From the understanding of the above transaction process, we can know that the Peer node is the main participant. If users want to access ledger resources, they must interact with peer nodes. In a Peer node, multiple ledgers can be maintained at the same time, and these ledgers belong to different Channels. eachPeer nodes will maintain a set of redundant ledgers, thus avoiding single points of failure.

Peer nodes can be divided into endorsement nodes (Endorser) and accounting nodes (Committer) according to their different roles in transactions. The endorsement node will simulate the execution of the transaction, and the accounting node will actually store the data. into the ledger.

The ledger can be divided into two parts, one is the blockchain and the other is the Current State, also called the World State.

Only appends can be made to the blockchain, past data cannot be modified. The chain also contains two parts of information, one part is the channel configuration information, and the other part is an unmodifiable, serialized record. Each block records the information of the previous block and then connects it into a chain, as shown in the figure below:

The first block is called the genesis block, which does not store transaction information. Each block can be divided into block header, block data and block metadata. The block header stores the block number of the current block, the hash value of the current block and the hash value of the previous block, so that all blocks can be connected. Block data contains transaction data. Block metadata includes the time when the block was written, the person who wrote it, and the signature.

The structure of each transaction is as follows. The Header contains the name and version information of the ChainCode. Signature is the signature of the user who initiated the transaction. Proposal mainly contains some parameters. Response contains the result of smart contract execution. Endorsements are the results returned by the endorsement results.

WorldState maintains the current status of the ledger. The data is stored in the form of Key-Value and can be quickly queried and modified. Every modification to WorldState will be recorded in the blockchain. The data in WorldState needs to rely on external storage, usually using LevelDB or CouchDB.

Blockchain and WorldState form a complete ledger. WorldState ensures flexible changes in business data, while blockchain ensures that all modifications are traceable and non-tamperable.

After the transaction is completed and the data has been written to the ledger, the data needs to be synchronized to other Peers.The Gossip protocol is used in Fabric. Gossip is also Channel-isolated and will only broadcast and synchronize ledger data among Peers in the Channel.

Smart contracts need to be installed on the Peer node. Smart contracts are the only way to access the ledger. Smart contracts can be written in languages ​​such as Go and Java.

After the smart contract is written, it needs to be packaged into ChainCode. Each ChainCode can contain multiple smart contracts. ChainCode needs to be installed, and ChainCode needs to be installed on the Peer node. After installation, ChainCode needs to be instantiated on the Channel, and the endorsement policy needs to be specified when instantiating.

After the smart contract is instantiated, it can be used to interact with the ledger. The flow chart is as follows:

After the user writes and deploys the instantiated smart contract, it can use the client application Program to submit a request to the smart contract, and the smart contract will get, put or delete the data in WorldState. The get operation directly reads the current status information of the transaction object from WorldState and does not write information to the blockchain. However, in addition to modifying WorldState, the put and delete operations also write a transaction information to the blockchain, and Transaction information cannot be modified.

Information on the blockchain can be accessed through smart contracts or directly through APIs in client applications.

Event is a way for the client application to interact with the Fabric network. The client application can subscribe to the event. When the event occurs, the client application will receive the message.

There are two types of event sources, one is Events issued by smart contracts, and the other is Events triggered by changes in the ledger. Users can obtain transaction information from Event, such as block height and other information.

In this article, we first introduce the overall network architecture of Fabric, discuss the role of peer nodes in transactions through the analysis of Fabric transaction process, and then analyze in detail the ledger maintained by peer nodes. and smart contracts, and analyzed the process of peer nodes maintaining ledgers and peer nodes executing smart contracts.

Text / Rayjun

[1] https://hyperledger-fabric.readthedocs.io/zh_CN/release-1.4/whatis.html

[2] https://developer.ibm.com/zh/ technologies/blockchain/series/os-academy-hyperledger-fabric/

[3] https://en.wikipedia.org/wiki/Gossip_protocol

㈢ How to learn blockchain Technology_How to understand blockchain technology

1. Technical language

Python and Go are the two technical languages ​​that are mentioned in recruitment by many companies. Need to prioritize learning. Moreover, these two languages ​​​​also have great applications in the direction of sliding technology outside of the blockchain. For example, Go is used in the background construction of large-scale concurrent systems, and Python is used in the construction of artificial intelligence systems. So learning these two languages ​​is a priority.

2. Technical framework

Master one or more of Bitcoin, ETH and Hyperledger. Needless to say, BTC is written in C at the bottom level. A large number of currency projects, such as Litecoin, Dash, Monero, zcash, etc., all use Bitcoin technology for secondary development.

ETH is the representative of blockchain 2.0, and various application Dapps can be built on the ETH network. Nowadays, a large number of application blockchain projects are developed using the ETH platform.

Hyperledgerfabric is a blockchain development platform strongly promoted by IBM. It is mainly used for the development of alliance chains and is currently the most popular alliance chain development platform.

3. Algorithm

POW (Proof of Work Algorithm), POS (Proof of Stake Algorithm), PBFT (Byzantine Fault Tolerance Algorithm), etc. are all important in the cryptography part of the blockchain Composition, a full understanding of these algorithms will help you have a better understanding of the cryptography part when participating in the underlying development of blockchain projects.

(3) Fabric network architecture blockchain extended reading:

Blockchain technology is a distributed accounting technology, and its characteristic is decentralization , open and transparent, allowing everyone to participate in the establishment of the database, and each created data cannot be tampered with. With everyone participating, the problem of trust between strangers is solved.

Blockchain technology has emerged. It is an accounting technology that allows all people to participate. The transaction information and data between AB are made public and cannot be tampered with. Everyone knows this. happens, then there is no need for any authoritative third party hereC, or everyone in the system plays the role of C, which is also called decentralization.

㈣ What is the model architecture of blockchain?

Currently, there are a wide range of blockchain training courses on the market, and the course content and teaching formats are also diverse.

Blockchain

1. Introduction to programming basics

Computer software and hardware basics, character sets and character encodings, HTMLCSS (including HTML5CSS3), ECMABOMDOM, jQuery, node.js, Ajax and Express

2. Go programming language

Go basic syntax, process control, functions and data, error handling, Go object-oriented programming, Go concurrent programming, Go Network programming, Go security programming, Go advanced programming (goroutine, channel), database MySQL, LevelDB

3, Blockchain 1.0 - Bitcoin Bitcoin

Bitcoin principle, Bitcoin system architecture, cryptographic algorithm (implemented in Go language), consensus algorithm (implemented in Go language), Bitcoin transaction principles and transaction scripts, Bitcoin RPC programming (implemented by node.js), Bitcoin Minhra coin source code analysis

4. Blockchain 2.0 - Ethereum

The working principle and infrastructure of Ethereum, basic concepts of Ethereum (account, transaction, Gas), Ethereum wallet Mist and Metamask, Ethereum Forex trading, ERC20 standard Token development and deployment, developing IDE with Ethereum as a bridge - remix-ide, smart contracts and Solidity, Solidity deployment, backup and calling, framework technology: truffle and web3, DApp development practice, Geth

5. Blockchain 3.0 - Fabric of Hyperledger

Hyperledger project introduction, Fabric deployment and usage, Fabric configuration management, Fabric architecture design, Fabric CA application and configuration, application development Actual combat.

㈤ Hot! Create and play with your own blockchain in 5 minutes


Blockchain is developing so fast this year! From an unfamiliar concept at the beginning, it has now taken off in various industries. A single spark has the potential to start a prairie fire. I really hope I can have my own blockchain to practice with! But how can one person and one computer set up a blockchain environment? The blockchain is so popular that it is not easy to say that I love you!


Don’t Worry! The editor has been addicted to blockchain and smart contracts and can’t extricate himself! Now I will take you step by step to start from scratch and create your own blockchain in 5 minutes! ~
Super Cloud (Sup) developed by IBM China Research InstituteerVessel) platform provides a blockchain development and testing environment for blockchain enthusiasts and developers. Through this platform, users can create multi-node blockchains based on Hyperledger Fabric for free and super quickly, and play with smart contracts on their own chains.
----
0.
Preparation
All you need is your local browser!
1. Register an account
Access the public beta address of SuperVessel blockchain service: 8800/bc.
Click the Log in button in the upper right corner, click Register in the pop-up window, fill in your email and password and submit. At this time, it is recommended to check the activation email in your mailbox and activate your account (Editor's tip: It doesn't matter if you activate lazily, but some advanced services must be activated before they can be used).
2.
Quickly create your own blockchain
After registration is completed, return to the homepage and click on the huge GIVE ME A BLOCKCHAIN ​​(Give me a blockchain!) button. Select the Consensus Plugin (consensus plug-in) and Size (number of blockchain network nodes) you want in the pop-up box.
Editor's note: Currently there are two consensus plug-ins officially provided by Hyperledger Fabric: noops and pbft.
After clicking Submit, you will get your own blockchain in a few seconds and automatically enter the monitoring panel. That’s right, getting your own blockchain is that simple!
After entering the monitoring panel, you can see that the left side is the smart contract management panel, including the management and deployment of smart contracts; the right side is the network panel, which displays the applied blockchain network status, topology, and connections between nodes. Latency information, etc. are clear at a glance; click the telescope icon in the upper right corner to monitor the log information of each node in real time. The bottom is the blockchain panel, which shows the overall situation of the current blockchain. In the initial state, there is only one block.
3. Deploy and use smart contracts
Next, the editor will teach you how to deploy and use smart contracts on your own blockchain.
Under the Smart Contracts tab of the smart contract management panel, 2 smart contracts are listed as examples, namely map and chaincode_example02. The map contract can store key-value pairs, and the chaincode_example02 contract can simulate transfers and queries between two people.
Editor's note: The code for these two sample contracts can be found in the Hyperledger Fabric source code.
Take the deployment and use of the chaincode_example02 contract as an example:
Deploy the contract
Click on the corresponding chaincode_example02 contractClick the Deploy button and fill in the initialization value of the contract, including contract name, initial function, and initial parameters. The initial function of the contract is init, and the initial parameters need to be filled in according to the format, such as ["a", "100", "b", "200"], which means registering two people a and b, giving them 100 units and 200 units respectively.
Click the Deploy button and the contract will be deployed in your blockchain. The process will take about 20 to 40 seconds. When a new block appears on the blockchain panel, it usually means that the contract has been deployed.
Call the contract
After the deployment is completed, view the deployed contract instance under the My Deployment tab of the smart contract management panel.
Click the Invoke button below the Action to call the smart contract, and fill in the called method name and corresponding parameters (the method names and parameters of different contracts have different meanings, which are related to the content of the contract). For this contract, call the invoke method name and fill in the parameters ["a", "b", "50"], which means a transfers 50 units to b.
After clicking Submit to complete the call, you can view the blockchain situation and a new block will be generated.


Query Contract
After the call is completed, you can query the contract execution results. Still under the My Deployment tab, click the Query button under Action to query the smart contract, and fill in the query method name and corresponding parameters. If you select the query method name and fill in the parameter ["a"], it means querying the current unit of a.
After clicking Submit, you can see that the current unit of a is 50. You can try query b again!
OK, then you can continue to operate the contract, observe the blockchain situation, or deploy a new smart contract, such as map, on the blockchain. For ease of use, the method names and parameter formats for deploying, calling, and querying contracts are all filled in by default. You only need to select a method name and change the parameters as you like! See how long you can play with the chain~
4. Upload and test your own private smart contract
In addition to the two public smart contracts currently provided, you can also upload and test your own private contract! Private contracts can only be seen by you.
Click Import private smart contract under the Smart Contracts tab.
After filling in the contract name and description, and uploading the contract code file, click Import to complete the upload.
Then the contract I uploaded will appear in the Smart Contracts list and can be deployed, called and queried as before.

㈥What are the blockchain system development platforms?

Fabric blockchain development is explained in detail. This course is forFor beginners, the content of Yu Na Bao Qing Code includes core concepts such as Hyperledger Fabric's identity certificate and MSP service, permission strategy, channel configuration and startup, chain code communication interface, etc. It also includes operational practices of Fabric network design, chain code and application development. , is the best choice for learning Fabric blockchain development.

Let me give you a free blockchain blog to check out.

㈦ Use AWS Blockchain Template to build Hyperledger Fabric

AWS Blockchain Template claims to be able to create and deploy a blockchain network in minutes.

Two types of blockchain networks can be built using AWS Blockchain Templates:

For specific construction steps, please refer to the AWS Blockchain Templates Developer Guide, which has details on building Ethereum. Steps, the "prerequisites" setting items in the document are used to build the Ethereum network and are not applicable to the Fabric network, so here we talk about building the Fabric of Hyperledger.

Before using the template to quickly create a stack, be sure to set the relevant content in advance:

Note:

The above five prerequisites are set correctly. We can use the blockchain template to create the Fabric network. Let’s talk about the two more difficult configurations with red boxes:

Setting steps:

Click " Review Policy", set the name (myFabricPolicy) and description (...) of this permission policy file, and finally click "Create Policy":

The settings are as follows:

AWS Console - Service - VPC - Click the blue button "Launch VPC Wizard" in the VPC control panel and select the VPC with a single public subnet:

Set the VPC name and subnet name, and other values ​​are default values.

Click the launch link in the Hyperledger Fabric section of the AWS Blockchain Templates Developer Guide:

The setting reference is as follows:

After creation, drink a cup of coffee ☕️ and wait for a while. ..

Wait until the status is displayed as "CREATE_COMPLETE" and it will be OK. 🎉🎉🎉

㈧ Blockchain Alliance Chain (3) Understanding Fabric

Fabric is the core blockchain framework launched by the Hyperledger Alliance , it is suitable for building alliance chains within complex enterprises and between enterprises. According to the goals of the Hyperledger Alliance, Fabric is built as a modular basic alliance chain framework that supports pluggable components. ;

Unlike Ethereum-based Quorum, Fabric only considered inter-enterprise applications from the beginning. Its unique channel concept connects enterprises in different subnets according to different business purposes. Each subnet corresponds to a channel, and each channel has its own independent blockchain. Quorum obviously has only one public network (all enterprise nodes join it), and private business between enterprises is completed through Private Manager.

The simplest way to understand channel is to analogize it to a Topic provided by a message service. In fact, Fabic was first implemented based on Kafka's distributed message service.

  In the Fabric network, an enterprise can have one or more nodes join the entire alliance chain; an enterprise can join 1 or more Channels (subnets); a node can join 1 or more channels. Each channel forms a subnet, so Fabric is a network composed of subnets.

So how does Fabric implement the execution of smart contracts and complete business uploading (recording transaction results in the blockchain)?

Unlike other frameworks, Fabric divides the entire process into three stages:

Business endorsement stage: The endorsement node sent by the customer's request completes the business calculation through smart contracts (but does not update the status), and completes the endorsement; returns the endorsement result to the client.

Business sorting phase: The client sends the endorsement results to the ordering node (orderer) through the Channel. The ordering node completes the sorting of transactions, packages them into blocks, and finally distributes them to all connected The node of the channel.

Business verification and writing to the ledger stage: Through the Gossip network, all Channel nodes will receive the new block. The nodes will verify each transaction in the block to determine whether it is valid: valid will be followed by In the new world state, invalid ones will be marked as "invalid" and the world state will not be updated, but the entire block will be completely added to the ledger (including invalid transactions).

Based on the above description, Fabric nodes can actually be divided into , ordinary nodes and Order nodes:

Peer, ordinary nodes, complete endorsement (including execution of contracts only) and Verification.

orderer, sorting node, completes sorting.

The Fabric network that joins the orderer node can be described as follows:

Each Channel defines all nodes belonging to the channel, but it is not necessary that all nodes are connected to the Orderer Nodes (private data or transactions can be spread between nodes through gossip protocol communication).

In the blockchain, consensus is the basis of the blockchain. Different from the public chain, the consensus of the alliance chain requiresAll transactions added to the ledger must be deterministic and final, that is, there must be no forks, the order between blocks must be certain, and there must be only one chain. In Fabric, this objective requirement is realized by sorting. All transactions will be submitted to the orderer node to obtain a determined order, and finally packaged into blocks and entered into the ledger. Fabric supports the implementation of ordering services based on Raft starting from 1.4.1, which can be considered as the implementation of consensus based on Raft.

The RAFT-based sorting service has better distribution and simpler configuration than the early Kafka. It is a commonly used consensus algorithm in alliance chains. Quorum uses RAFT as the consensus by default. layer. Simply put, RAFT is a leader and follower model. All nodes joining the RAFT network have a leader at any time. Only this leader has the right to decide the order of transactions and package them into blocks. Other nodes can only submit transactions as followers. and sync block.

Based on the FAFT network, each enterprise can have one or more nodes participating in the Orderer. In Frabric, the network connection between enterprises can be changed into the following form:

Users of blockchain are called EOA (External of Account) in Ethereum, and the carrier of EOA is a wallet. Let's use this concept to see how Fabric implements users and initiates transactions. EOA in Fabric is a certificate (x.509) issued by the CA center. A Certificate represents an Identity (this is still very different from Ethereum. An EOA in Ethereum is actually a hash address). Channels that EOA can participate in And the authorized operations are determined by the MSP (Membership Service Provider) of the channel (as shown below).

Note: Certificate is a common method of verifying identity in cryptography; certificate contains personal information, public key and signature of the CA that issued the certificate. The verifier only needs to have the CA's certificate (including the CA's public key) to verify whether the signature is correct and whether the content of the certificate has been tampered with. Simply put, through CA and Certificate, we can obtain a verifiable identity and trust chain.

As shown in the picture above, fabric Zhongtong uses Wallet as the carrier of EOA. A Wallet can contain multiple Identities (x.509 certificate). Identity verifies correctness through the chain of trust provided by the CA.

After verifying the identity, Fabric uses MSP to resolve in the blockchain network whether the identity represents a member of the organization and what role it has within the organization. For example, the channel will first verify whether the current user Identity is a valid identity, then check the enterprise and role it has through MSP, and finally determine whether the user has the right to perform operations.

It can be said that Fabric access control is completed through MSP. An MSP needs to be defined every time access control is required. For example, each channel defines an MSP, which specifies the access rights to resources within the channel range. MSP is an obscure concept in Fabric, and it is also the basis for providing secure access between enterprises.

As mentioned earlier, Fabric divides business processing and Internet access into three parts: endorsement, sorting, and adding to the ledger after verification.

Endorsement is the stage in which Fabric executes smart contracts. In Ethereum, smart contracts are executed in the EVM and are supported in multiple languages. In Fabric, smart contracts are called chaincode: A chaincode can be understood as a container of smart contracts, which can contain one or more smart contracts. It is not used in EVM. Chaincode is executed in JVM or NodeJS.

Client applications access the ledger through smart contracts. Each accessible smart contract is installed on a node accessible to the client and is defined in the channel. (Nodes with smart contracts are called endorsement nodes, nodes without smart contracts are called unsubmitted nodes, and submitting nodes only maintain ledgers)

The client application submits a transaction request, and the request reaches the endorsement node , the endorsement node will first verify the customer's signature to ensure that the customer's identity has the right to execute this transaction, then execute the smart contract (chaincode) mentioned in the transaction, and generate an endorsement response (or transaction proposal, trans-proposal). This endorsement response usually contains the world state's read set, write set, and the node's signature for this transaction. The main difference here from the Ethereum alliance chain is that: The endorsement phase only simulates transactions and does not actually update the transaction results. The real update transaction is completed in the third phase. The endorsement node finally sends the generated endorsement response fanhui to the client, and the execution of the smart contract part ends.

Usually the execution of a transaction requires the signatures of multiple parties, so the client needs to send a transaction to multiple endorsement nodes, and the selection of these endorsement nodes needs to meet the requirements of the endorsement policy.

The following figure is a network diagram including customers, endorsement nodes, and submission nodes.

According to Fabric’s official reference document, the process of successful customer transactions can be described in the following figure.

As shown in the figure above, from 1 to 3, it is the endorsement stage, 4 is the sorting stage, and 4.1, 4, 2, 5 are the verification and submission stages. Refer to Frabic's node concept to learn more about the concept of transaction details.

Generally speaking, Fabric is more focused on inter-enterprise. Through the above, everyone can have a general understanding of the basic composition and concepts of Fabric. Fabric itself is not mysterious. It uses existing inter-enterprise technologies. For a better understanding, it is recommended to read Support for Distributed Messaging Systems and Enterprise Security Infrastructure (CA related). Compared with the Ethereum-based alliance chain implementation, Fabric's subnet concept is more adaptable to complex inter-enterprise applications, but its complex security considerations make operating costs very high. In addition, Fabric uses Certificate as user identity, which has great The limitations of Fabric will be changed in the new 2.0.

In the next article, we will take a look at Sawtooth, a blockchain framework provided by Inter.

Blockchain Alliance Chain (1) Understanding Ethereum

Blockchain Alliance Chain (2) Understanding Quotum

Blockchain Alliance Chain of Blockchain (3) Understanding Fabric

Alliance Chain of Blockchain (4) Understanding Sawtooth

博客主人唯心底涂
男,单身,无聊上班族,闲着没事喜欢研究股票,无时无刻分享股票入门基础知识,资深技术宅。
  • 38226 文章总数
  • 3637387访问次数
  • 3084建站天数