blockchain network

This article makes a summary with reference to the fabric network process. Reference link:

Blockchain Network — hyperledger-fabricdocs master documentation

I read it roughly when I was learning the blockchain network before, but the understanding of beginners is not deep, so I read it again and continue to understand. Every time I learn to different degrees and read these articles, I will have new gains. Based on fabric2.2 blockchain network.

The final simple network will look like this, which looks complicated and requires a little analysis.

1. At the beginning of the network, we can imagine the entire network as a blank area, and no one participates in the network. At this time, the network needs people to participate. We assume that an organization R4 joins the network. The organization is allowed to join through the certificate issued by the corresponding CA institution. The components accompanying this organization include NC4, O4, and CA4. Next, I will explain these nouns one by one. What is an organization? An organization can be as large as a region or as small as a store. It is an independent individual or collection. For example, each company may have different numbers of people, but each company can be regarded as an organization. CA4 is a visa agency, which is used to issue certificates to organizations in need, so that these organizations can obtain permission for network operations. O4 is a sorting node, which sorts the received transactions. It can also store organization alliance information locally (the alliance will be mentioned later). The operation authority of O4 is mainly controlled by NC4. NC4 is the network configuration and can define strategies (strategies are The meaning of the rules), such as assigning the R4 organization as an administrator, having the highest authority on the network, allowing O4 nodes to store alliance information locally, etc. As shown in the figure below, since these components are issued certificates by CA4, R4 can communicate with O4.

 Next, in the initial network, an administrator R4 organization joins the network. R4 can modify the network configuration of NC4. Adding organization R1 to the network has the same authority as it does. Therefore, modifying the NC4 configuration allows R1 to obtain management authority. Then R1 is also an administrator. Whether it is possible to modify the NC4 network configuration and delete R4 later depends on whether R4 allowed R1 to join the network at that time. Here, the modification policy mod_poicy needs to be introduced. Although R1 has management rights, it cannot modify the policy mod_poicy. Once R4 will If R1 is added to mod_poicy, then R1 also has the permission to delete R4, but in reality, when R1 needs to call mod_poicy, it needs permission from R4.

 At this time, R1 and R4 have the same authority, and CA1 issues a certificate for R1. If R1 wants R2 to join the network at this time, but does not want R2 to communicate with R4, for example, R1 is a supplier, R4 and R2 are buyers, and R1 gives Their prices are not the same, and it is not expected that R2 and R4 will communicate at this time. At this time, the concept of alliance is introduced. That is, if R1 and R2 are allied to the network, how can the network know the existence of R2? At this time, R1 will play its role as an administrator to configure NC4 to write itself and R2, and tell NC4 that it wants to form an alliance with R2. The figure below \times1shows the meaning of the alliance. There can be multiple alliances, not necessarily two. The document uses two as an example. When the network knows that the R2 organization has joined, the NC4 configuration file will call the O4 ordering node to let it create a channel information locally for R1 and R2, as shown in the following figure C1 channel. The concept of a channel is similar to the communication between two organizations, such as creating a group chat, R1 and R2 create a group chat, then R1 and R2 are equivalent to building a channel C1. The C1 channel is a logical concept. In fact, the channel information is stored locally in O4, so the block information on C1 can communicate with the ordering node O4. After R1 and R2 are united, a channel configuration CC1 will be generated. Unlike NC4, NC4 is Network configuration, manage channel information of the whole network organization, CC1 is only channel configuration of channel C1, this configuration is only applicable to C1 channel.

We add two components on the existing basis, ledger L1 and peer node P1. 

When the P1 node is activated by the certificate issued by CA1, it uses O4 to join the channel C1, and uses CC1 to set the permissions of P1. P1 can be considered as a node for storing books and verifying operations. L1 is the ledger of the channel C1. In the figure below, it refers to the transaction records between the R1 organization and the R2 organization. Since P1 is also a server in the entity, the ledger is physically stored in the node P1. The channel is a concept, so it cannot actually store data. On the channel, but logically the ledger is on the channel, because the channel can obtain the L1 ledger by calling the Peer node P1 to call the smart contract interface (to be introduced soon), so the physical ledger is stored on P1, and logically the ledger is stored in the channel on C1. As shown in the figure below, if node P1 joins C1, it can communicate with O4 through C1.

What if the account book L1 needs to be changed? The security of the blockchain network, the account book is a very important element and cannot be easily changed, so the smart contract S5 is introduced. The smart contract is a piece of code that is automatically executed after being triggered. When the client A1 When you want to get the account book L1, you will submit it to S5 through the network request, and S5 will automatically execute the call L1 operation, and S5 provides complete query and update operations 

Can the A1 client directly access the S5 smart contract interface through the channel C1? No, you can't, there is a concept that needs to be mentioned here. Chaincode definition, when the smart contract is installed on the Peer node, most organizations need to agree to a chaincode definition. The Peer node can only see the interface where the smart contract is installed, but cannot see the complete implementation. The chaincode definition means that most organizations Agree to a standard to modify the ledger. After agreeing, the chaincode definition can be submitted to the channel, so that the client can access the smart contract through the chaincode definition to call the ledger. The most important information in the chaincode definition is the endorsement policy, namely When the client makes a transaction, it must specify a specific organization signature before the transaction block can be stored in the copy of the ledger.

Next, the same components as before are added to the network in the same way, and P2 is also stored locally in smart contracts and ledgers, but the official emphasizes that ledgers are physically stored on peer nodes, logical storage and channels. They are all installed with S5 smart contracts, because R2 must agree to the same chain code definition when P2 nodes join in, so that they can access the ledger with the same operations. Such a small blockchain network is constructed! It is not necessary to install the S5 smart contract in the network. Peer can choose not to install the smart contract, so that the Peer node can be divided into several roles. 1. Submitting node: All Peer nodes are submitting nodes, and they can verify the authenticity of the block and select or reject the block into their own copy of the ledger. 2. Endorsement node: Only Peer nodes with smart contracts installed can be selected as endorsement nodes. In fact, the nodes specified in the transaction proposal sent by the client are the real endorsement nodes. The smart contracts on the nodes are recognized by the client. Call to generate a signed response, so a smart contract must be used. 3. Master node: There is a master node in each channel, which is used to collect transaction signatures and distribute blocks, etc. 4. Anchor node: This node is optional and is mainly responsible for communication between organizations. O4 in this block network is more like a centralized node. In fact, because the network components are relatively small, O4 can also be decentralized. There can be multiple order sorting nodes, and there are channels between them, which are called super channels. , mainly to copy the channel information (application channel, such as C1) of other order nodes, and can also reduce the overhead of an order device. If the network is large enough, the general structure of the entire network is like this, and the next components are added according to the above rules. It may be complicated to read the document at the beginning, and I need to absorb the official document several times. I still have many questions, such as the actual location of each configuration, that is, where is the physical storage, and what is the specific information in the configuration, CA How the organization issues certificates and operates, etc., all need to be gradually understood later.

Guess you like

Origin blog.csdn.net/m0_56327342/article/details/121312391