Transaction processing method and device applied to blockchain

By selecting master nodes and replica nodes in the blockchain based on node credit rating and a preset election strategy, and by adding self-verification information interaction verification, the PBFT algorithm is optimized, solving the problems of low consensus efficiency and poor security, and improving the consensus efficiency and security of the system.

CN112883114BActive Publication Date: 2025-01-10INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110207436.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-24
Publication Date
2025-01-10
Estimated Expiration
2041-02-24

AI Technical Summary

Technical Problem

The PBFT algorithm suffers from low consensus efficiency and poor security in blockchain, especially when there are many nodes, it takes a long time, and the presence of Byzantine nodes as master nodes may lead to system performance degradation and security risks.

Method used

By determining the credit rating of nodes and selecting master nodes and replica nodes based on the credit rating and a preset election strategy, the consensus process is optimized by adding self-certification information of master nodes and interactive verification with clients.

Benefits of technology

It improves the efficiency and security of the consensus process, reduces the probability of malicious nodes becoming master nodes, and enhances the security of the blockchain system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112883114B_ABST
    Figure CN112883114B_ABST
Patent Text Reader

Abstract

The present disclosure provides a transaction processing method applied to a blockchain including N nodes, including: in response to a transaction request initiated by a client, determining the node credit level corresponding to each node in the N nodes, selecting a master node and M-1 replica nodes from the N nodes based on the node credit level corresponding to each node and a preset election strategy, and in response to the master node receiving the transaction request, sending a self-certification message response information including the master node to the client to obtain the verification result of the master node, the self-certification message is used to verify whether the master node is a malicious node, and in the case where the self-certification message of the master node passes the verification, determining the consensus verification result of the master node and the M-1 replica nodes for the transaction request, so as to feedback the processing result of the transaction request to the client. The present disclosure also provides a transaction processing device, equipment, medium and program product. The method and device provided by the present disclosure can be applied to the financial field or other fields, for example.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of blockchain technology, and in particular to a transaction processing method, device, equipment, medium and program product applied to blockchain. Background Art

[0002] The consensus verification of transaction requests to achieve consensus on the legitimacy of accounting has always been an important research topic in the distributed field. The consensus mechanism is one of the core technologies of blockchain. According to the different ways of selecting block accounting nodes, consensus algorithms can be roughly divided into the following four categories: proof-based consensus algorithms such as Proof of Work (PoW) algorithm, Proof of Stake (PoS) algorithm, broadcast election consensus algorithms such as Raft algorithm, rotation consensus algorithms such as Practical Byzantine Fault Tolerance (PBFT) algorithm, and hybrid consensus algorithms such as PoS+PBFT. Among them, Bitcoin uses the PoW algorithm, Ethereum uses the PoS algorithm, and the PBFT algorithm is used when the Byzantine problem exists.

[0003] However, when using the PBFT algorithm for consensus verification, block requests containing multiple transactions need to be agreed upon by all member nodes in the blockchain network. Each PBFT three-stage consensus process requires multiple interactions, multiple communications, high time complexity, and a serious decline in consensus efficiency. The more member nodes there are in the blockchain network, the longer it takes. The PBFT algorithm selects the master node from all member nodes through a random selector. This method makes it possible for Byzantine nodes (i.e., malicious nodes) to serve as master nodes. Once a malicious node serves as a master node, it will cause a view change, which will greatly reduce system performance, affect the consensus results, and bring great security risks to the transaction security of the entire blockchain. Summary of the invention

[0004] In view of this, in order to at least partially overcome the above-mentioned technical problems of low efficiency and poor security existing in the relevant PBFT algorithm, the present disclosure provides a transaction processing method, device, equipment, medium and program product for optimizing the relevant PBFT algorithm for application in blockchain.

[0005] In order to achieve the above objectives, one aspect of the present disclosure provides a transaction processing method applied to a blockchain, wherein the blockchain includes N nodes, N is a positive integer, and the method may include: in response to a transaction request initiated by a client, determining the node credit level corresponding to each node in the N nodes. Based on the node credit level corresponding to each node and the preset election strategy, a master node and M-1 replica nodes are selected from the N nodes, M<N. In response to the master node receiving the transaction request, a response message of the transaction request is sent to the client to obtain a verification result of the master node, wherein the response message at least includes a self-certification message of the master node, and the self-certification message is used to verify whether the master node is a malicious node. And when the self-certification message of the master node passes the verification, the consensus verification result of the master node and the M-1 replica nodes on the transaction request is determined to feedback the processing result of the transaction request to the client.

[0006] According to an embodiment of the present disclosure, the above-mentioned selecting the master node and M-1 replica nodes from the above-mentioned N nodes based on the node credit level corresponding to each node and the preset election strategy may include: based on the node credit level corresponding to each node, filtering out the nodes with the lowest node credit level from the above-mentioned N nodes to screen out a consensus node candidate set, wherein the above-mentioned consensus node candidate set includes M nodes, and the above-mentioned M nodes participate in the consensus verification of the above-mentioned transaction request. Based on the above-mentioned preset election strategy, the master node is selected from the above-mentioned consensus node candidate set. And the M-1 nodes other than the above-mentioned master node in the above-mentioned consensus node candidate set are determined as the above-mentioned M-1 replica nodes.

[0007] According to an embodiment of the present disclosure, the above-mentioned determination of the node credit level corresponding to each of the N nodes may include: determining the credit value corresponding to each of the N nodes by means of encrypted lottery. Obtaining a node credit level division rule, wherein the node credit level division rule includes P node credit levels from high to low credit levels and a preset credit threshold interval corresponding to each node credit level. And based on the credit value corresponding to each of the N nodes and the node credit level division rule, determining the node credit level corresponding to each of the nodes.

[0008] According to an embodiment of the present disclosure, the above-mentioned preset election strategy includes a priority election strategy and a master node election strategy. The above-mentioned selection of the master node from the above-mentioned consensus node candidate set based on the above-mentioned preset election strategy may include: based on the above-mentioned priority election strategy, detecting whether there is a node among the nodes with the highest node credit level. If so, based on the above-mentioned master node election strategy, detecting whether a master node is selected from the nodes with the highest node credit level. If not, based on the above-mentioned priority election strategy, detecting whether there is a node among the nodes with the next-highest node credit level. And if so, based on the above-mentioned master node election strategy, detecting whether a master node is selected from the nodes with the next-highest node credit level, until the above-mentioned master node is selected.

[0009] According to an embodiment of the present disclosure, the above master node election strategy may include: a heartbeat detection success strategy, a strategy of having the largest view number, and a strategy of having the largest serial number.

[0010] According to an embodiment of the present disclosure, the method may further include: in response to detecting that a new node has joined the blockchain, setting an initial credit value for the new node, wherein the node credit level corresponding to the initial credit value is an intermediate level between the highest level and the lowest level. And according to the consensus verification result of the new node participating in the consensus verification, adjusting the initial credit value to determine the credit value corresponding to the new node.

[0011] According to an embodiment of the present disclosure, the above method may further include: when the self-certification message of the above master node fails to pass the verification, re-selecting the master node and M-1 replica nodes from the above N nodes.

[0012] According to an embodiment of the present disclosure, the above-mentioned determination of the consensus verification result of the above-mentioned master node and the above-mentioned M-1 replica nodes on the above-mentioned transaction request may include: the above-mentioned master node generates a first transaction consensus message based on the above-mentioned transaction request, and broadcasts the above-mentioned first transaction consensus message to the above-mentioned M-1 replica nodes. Each of the above-mentioned M-1 replica nodes adds self-certification information to the above-mentioned first transaction consensus message to generate a second transaction consensus message, and broadcasts the above-mentioned second transaction consensus message to other nodes except itself. Determine whether the number of the above-mentioned second transaction consensus messages that have been verified and received by the above-mentioned master node and each of the above-mentioned replica nodes exceeds the first preset threshold. In the case of exceeding the above-mentioned first preset threshold, the above-mentioned master node and each of the above-mentioned replica nodes broadcast the confirmation message of the above-mentioned second transaction consensus message to other nodes except themselves. And according to the number of the above-mentioned confirmation messages that have been verified and received by the above-mentioned master node and each of the above-mentioned replica nodes, determine the consensus verification result of the above-mentioned master node and the above-mentioned M-1 replica nodes on the above-mentioned transaction request.

[0013] According to an embodiment of the present disclosure, the above-mentioned determination of the consensus verification result of the above-mentioned transaction request by the above-mentioned master node and the above-mentioned M-1 replica nodes according to the number of verification-passing confirmation messages received by the above-mentioned master node and each of the above-mentioned replica nodes may include: determining whether the number of verification-passing confirmation messages received by the above-mentioned master node and each of the above-mentioned replica nodes exceeds the above-mentioned first preset threshold. In the case of exceeding the above-mentioned first preset threshold, the above-mentioned master node and each of the above-mentioned replica nodes return a response message of the above-mentioned transaction request to the above-mentioned client. And in the case that the number of response messages of the above-mentioned transaction request received by the above-mentioned client exceeds the second preset threshold, confirming that the consensus verification result of the above-mentioned transaction request is consensus verification passed, wherein the above-mentioned second preset threshold is less than the above-mentioned first preset threshold.

[0014] According to an embodiment of the present disclosure, the method may further include: when the number of response messages of the transaction request received by the client does not exceed the second preset threshold, confirming that the consensus verification result of the transaction request is consensus verification failure.

[0015] In order to achieve the above objectives, another aspect of the present disclosure provides a transaction processing device applied to a blockchain, wherein the blockchain includes N nodes, N is a positive integer, and the device may include: a first determination module, for determining the node credit level corresponding to each node in the N nodes in response to a transaction request initiated by a client. A first selection module, for selecting a master node and M-1 replica nodes from the N nodes based on the node credit level corresponding to each node and a preset election strategy, M<N. A verification module, for sending a response message of the transaction request to the client in response to the master node receiving the transaction request, so as to obtain a verification result of the master node, wherein the response message at least includes a self-certification message of the master node, and the self-certification message is used to verify whether the master node is a malicious node. And a second determination module, for determining the consensus verification result of the transaction request by the master node and the M-1 replica nodes in the case where the self-certification message of the master node passes the verification, so as to feedback the processing result of the transaction request to the client.

[0016] According to an embodiment of the present disclosure, the first selection module may include: a screening submodule, for filtering out nodes with the lowest node credit level from the N nodes based on the node credit level corresponding to each node, so as to screen out a consensus node candidate set, wherein the consensus node candidate set includes M nodes, and the M nodes participate in the consensus verification of the transaction request. A first selection submodule, for selecting a master node from the consensus node candidate set based on the preset election strategy. And a first determination submodule, for determining the M-1 nodes in the consensus node candidate set other than the master node as the M-1 replica nodes.

[0017] According to an embodiment of the present disclosure, the first determination module may include: a second determination submodule, for determining the credit value corresponding to each of the above nodes by means of encrypted lottery. A first acquisition submodule, for acquiring a node credit rating division rule, wherein the node credit rating division rule includes P node credit ratings from high to low and a preset credit threshold interval corresponding to each node credit rating. And a third determination submodule, for determining the node credit rating corresponding to each of the above nodes based on the credit value corresponding to each of the above nodes and the node credit rating division rule.

[0018] According to an embodiment of the present disclosure, the above-mentioned preset election strategy includes a priority election strategy and a master node election strategy, and the above-mentioned first selection submodule may include: a first detection unit, for detecting whether there is a node among the nodes with the highest node credit level based on the above-mentioned priority election strategy. A second detection unit, for detecting whether a master node is selected from the nodes with the highest node credit level based on the above-mentioned master node election strategy if it exists. A third detection unit, for detecting whether there is a node among the nodes with the next highest node credit level based on the above-mentioned priority election strategy if it cannot be selected. And a fourth detection unit, for detecting whether a master node is selected from the nodes with the next highest node credit level based on the above-mentioned master node election strategy if it exists, until the above-mentioned master node is selected.

[0019] According to an embodiment of the present disclosure, the above master node election strategy may include: a heartbeat detection success strategy, a strategy of having the largest view number, and a strategy of having the largest serial number.

[0020] According to an embodiment of the present disclosure, the first determination module may further include: a setting submodule, configured to set an initial credit value for the new node in response to detecting that a new node has joined the blockchain, wherein the node credit level corresponding to the initial credit value is an intermediate level between the highest level and the lowest level. And a fourth determination submodule, configured to adjust the initial credit value according to the consensus verification result of the new node participating in the consensus verification, so as to determine the credit value corresponding to the new node.

[0021] According to an embodiment of the present disclosure, the above-mentioned device may also include: a second selection module, used to re-select the master node and M-1 replica nodes from the above-mentioned N nodes when the self-certification message of the above-mentioned master node fails to pass the verification.

[0022] According to an embodiment of the present disclosure, the second determination module may include: a first broadcast submodule, for the master node to generate a first transaction consensus message based on the transaction request, and broadcast the first transaction consensus message to the M-1 replica nodes. A second broadcast submodule, for each of the M-1 replica nodes to add self-certification information to the first transaction consensus message to generate a second transaction consensus message, and broadcast the second transaction consensus message to other nodes except itself. A fifth determination submodule, for determining whether the number of the second transaction consensus messages received by the master node and each of the replica nodes that have passed the verification exceeds a first preset threshold. A third broadcast submodule, for the master node and each of the replica nodes to broadcast the confirmation message of the second transaction consensus message to other nodes except themselves when the first preset threshold is exceeded. And a sixth determination submodule, for determining the consensus verification result of the master node and the M-1 replica nodes on the transaction request according to the number of the confirmation messages received by the master node and each of the replica nodes that have passed the verification.

[0023] According to an embodiment of the present disclosure, the sixth determination submodule may include: a first determination unit, configured to determine whether the number of verification confirmation messages received by the master node and each of the replica nodes exceeds the first preset threshold. A return unit, configured to return a response message of the transaction request to the client by the master node and each of the replica nodes when the number of verification confirmation messages exceeds the first preset threshold. And a second determination unit, configured to confirm that the consensus verification result of the transaction request is consensus verification passed when the number of response messages of the transaction request received by the client exceeds the second preset threshold, wherein the second preset threshold is less than the first preset threshold.

[0024] According to an embodiment of the present disclosure, the sixth determination submodule may further include: a third determination unit, configured to confirm that the consensus verification result of the transaction request is consensus verification failure when the number of response information of the transaction request received by the client does not exceed the second preset threshold.

[0025] In order to achieve the above objectives, another aspect of the present disclosure provides an electronic device, including: one or more processors, and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the transaction processing method applied to the blockchain as described above.

[0026] In order to achieve the above objectives, another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which, when executed, are used to implement the transaction processing method applied to the blockchain as described above.

[0027] In order to achieve the above objectives, another aspect of the present disclosure provides a computer program, which includes computer executable instructions, and when the instructions are executed, they are used to implement the transaction processing method applied to the blockchain as described above.

[0028] Compared with the related art, according to the transaction processing method provided by the present invention, based on the node credit level corresponding to each node and the preset election strategy, some but not all nodes included in the blockchain are screened out to participate in the consensus process, which can at least partially reduce the probability of malicious nodes becoming master nodes, reduce the number of consensus nodes, and improve the efficiency of the consensus process. By adding self-certification information to the master node and performing interactive verification with the client, when the self-certification information of the master node is verified, the consensus node performs consensus verification on the transaction request, which can at least partially improve the security of the master node, thereby improving the security of the blockchain system. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0030] Figure 1 The system architecture of the transaction processing method, apparatus, device, medium and program product applied to blockchain applicable to the embodiments of the present disclosure is schematically shown;

[0031] Figure 2 A flowchart of a transaction processing method applied to a blockchain according to an embodiment of the present disclosure is schematically shown;

[0032] Figure 3 The following schematically shows the consensus node screening process according to an embodiment of the present disclosure;

[0033] Figure 4 The schematic diagram shows the three-stage consensus process of the related technology Byzantine fault tolerance;

[0034] Figure 5 The Byzantine fault-tolerant three-stage consensus process of the embodiment of the present disclosure is schematically shown;

[0035] Figure 6 A flowchart of a transaction processing method applied to a blockchain according to another embodiment of the present disclosure is schematically shown;

[0036] Figure 7 A block diagram of a transaction processing device applied to a blockchain according to an embodiment of the present disclosure is schematically shown;

[0037] Figure 8 A schematic diagram schematically shows a computer-readable storage medium product suitable for implementing the transaction processing method described above according to an embodiment of the present disclosure; and

[0038] Fig. 9 A block diagram of an electronic device suitable for implementing the transaction processing method described above according to an embodiment of the present disclosure is schematically shown.

[0039] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.

[0040] It should be noted that the drawings are not drawn to scale and that for illustrative purposes, elements of similar structure or function are generally represented by like reference numerals throughout the drawings. DETAILED DESCRIPTION

[0041] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0042] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "including", "comprising", etc. used herein indicate the presence of the above-mentioned features, steps, operations and / or components, but do not exclude the presence or addition of one or more other features, steps, operations or components. All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having meanings consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0043] In the case of using expressions such as "at least one of A, B, and C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.). In the case of using expressions such as "at least one of A, B, or C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, or C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0044] Some block diagrams and / or flow charts are shown in the accompanying drawings. It should be understood that some blocks or combinations thereof in the block diagrams and / or flow charts can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable transaction processing device, so that these instructions can create a device for implementing the functions / operations described in these block diagrams and / or flow charts when executed by the processor. The technology of the present disclosure can be implemented in the form of hardware and / or software (including firmware, microcode, etc.). In addition, the technology of the present disclosure can take the form of a computer program product on a computer-readable storage medium storing instructions, which can be used by an instruction execution system or in combination with an instruction execution system.

[0045] As a decentralized, peer-to-peer transaction system, Bitcoin has quickly and successfully attracted widespread attention from the cryptocurrency community with its unique concept in just a few years. Researchers have separated Bitcoin from virtual digital currency by analyzing, outlining, and abstracting its underlying technology, summarizing blockchain technology, and thus creating a new technological field. Blockchain is a solution that uses peer-to-peer communication technology to achieve peer-to-peer communication between blockchain network nodes, uses consensus mechanisms to achieve bookkeeping legitimacy, and uses chain structures to store data for joint bookkeeping. In essence, blockchain is a new application model of decentralized, distributed data storage, peer-to-peer transmission, consensus mechanisms, encryption algorithms, and other technologies. It is considered to be one of the emerging technologies for disruptive changes in human society. Its application range is very wide, and its main application areas involve digital assets, digital currencies, smart contracts, identity authentication, and e-commerce.

[0046] The present disclosure provides a transaction processing method for a blockchain including N (N is a positive integer) nodes, including a consensus node screening stage and a consensus verification stage. In the consensus node screening stage, first respond to the transaction request initiated by the client, determine the node credit level corresponding to each node in the N nodes, and then select the master node and M-1 replica nodes from the N nodes based on the node credit level corresponding to each node and the preset election strategy, M<N. In the consensus verification stage, first respond to the master node receiving the transaction request, send a response message of the transaction request to the client to obtain the verification result of the master node, the response message at least includes the self-certification message of the master node, the self-certification message is used to verify whether the master node is a malicious node, and then determine the consensus verification result of the transaction request by the master node and M-1 replica nodes when the self-certification message of the master node passes the verification, and finally feedback the processing result of the transaction request to the client according to the consensus verification result.

[0047] According to the transaction processing method provided by the present invention, based on the node credit level corresponding to each node and the preset election strategy, some nodes are screened to participate in the consensus verification process of the transaction request, which can at least partially reduce the number of nodes, reduce the number of communications between nodes, simplify the time complexity, and increase self-certification information for the master node so that the master node and the client can perform interactive verification, which can verify the master node and improve the security of the master node, thereby improving the efficiency of the consensus process and the security of the blockchain network system.

[0048] It should be noted that the transaction processing method and device provided by the present disclosure can be used in the financial field, and can also be used in any field other than the financial field. Therefore, the application field of the transaction processing method and device provided by the present disclosure is not limited.

[0049] As an emerging technology, blockchain is a decentralized distributed ledger technology achieved by the deep integration of multiple technologies such as distributed systems, consensus algorithms, cryptography, and peer-to-peer networks. It provides a trusted channel for information and value transfer in a trustless environment.

[0050] In terms of application scope, blockchain mainly includes three forms, namely public blockchain, consortium blockchain and private blockchain. Among them, the public blockchain is a completely decentralized transaction system with no official management agency and central server. Nodes freely access the network according to system rules and work based on consensus mechanism. Since it has no management mechanism and supervision mechanism, anyone can participate in the public blockchain and access the storage data of the chain structure. Therefore, there is a risk of blockchain network being attacked, and privacy and security are difficult to guarantee. The consortium blockchain is jointly initiated by several institutions. New nodes can only join after being approved by the alliance. It is mainly used within corporate organizations. Since only specific member nodes can access the blockchain network, transaction data can be protected and security is strong, so it can well support enterprise-level applications. Private blockchain is for internal enterprises, with limited node data and operates according to the system rules required by the enterprise. Since it only allows one company or individual to have write permission to perform accounting or data update on the blockchain, its essence is not much different from distributed storage.

[0051] Alliance blockchain (abbreviated as alliance chain) is for specific groups. Only authorized nodes can join a specific blockchain network. Nodes in the alliance chain need to be authenticated and registered. Encryption is usually not involved in the consensus process. Member nodes have a common goal, but do not fully trust each other in maintaining verification data. Compared with public chains, alliance chain nodes usually have good connections, higher verification and confirmation speeds, faster block times, and lower system maintenance costs. Combined with the latest technological developments in blockchain, the alliance chain can realize that internal members are jointly responsible for account maintenance. At the same time, the registration mechanism can limit the behavior of participating nodes and flexibly handle permissions. To a certain extent, a decentralized and distributed system has been built, which gets rid of the security risks such as single point failures caused by the only central organization, solves the trust problem, and can be applied to financial, supply chain, public welfare and other application scenarios. As a key technology in the alliance chain, the consensus algorithm directly affects the transaction processing capability, scalability and security of the alliance chain.

[0052] Figure 1 The system architecture 100 of the transaction processing method, apparatus, device, medium and program product applied to blockchain in the embodiment of the present disclosure is schematically shown. It should be noted that: Figure 1What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.

[0053] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a blockchain system 110 composed of terminal devices 111 to 114, and electronic devices 120, 130, 140, and 150.

[0054] According to an embodiment of the present disclosure, the terminal devices 111 to 114 may communicate with each other via a network, which may be, for example, a wired or wireless communication link or an optical fiber cable.

[0055] Consensus verification of transaction requests to achieve consensus on the legitimacy of accounting has always been one of the core technologies of blockchain. For a transaction, if several consensus nodes with irrelevant interests can reach a consensus, it is considered that all consensus nodes in the blockchain system 110 can reach a consensus on this, that is, the consensus of the entire network. According to an embodiment of the present disclosure, the blockchain system 110 can be, for example, a consortium chain, and the consensus algorithm used is the PBFT algorithm used by the consortium chain. The premise of this algorithm is to use a cryptographic algorithm to ensure that the message transmission between nodes cannot be tampered with, and the number of invalid or malicious nodes tolerated is f. At the same time, the number of normal nodes is 2f+1, and the total number of system nodes is 3f+1. In other words, the PBFT algorithm can tolerate less than 1 / 3 invalid or malicious nodes while ensuring activity and security. For example Figure 1 The total number of nodes in the blockchain system 110 is 4, the number of invalid or malicious nodes tolerated is 1, and the number of normal nodes is 3. Each of the terminal devices 111 to 114 can serve as a node in the blockchain system 110.

[0056] According to an embodiment of the present disclosure, a user may use electronic devices 120, 130, 140, 150 to communicate with nodes in the blockchain system 110 through a network to receive or send messages, etc. Various clients (or user terminals) may be installed on the electronic devices 120, 130, 140, 150, such as online transaction applications, shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples). The electronic devices 120, 130, 140, and 150 may be various electronic devices with display screens and supporting web browsing, including but not limited to smartphones, tablet computers, laptop portable computers, and desktop computers, etc.

[0057] According to an embodiment of the present disclosure, when a user uses any electronic device among electronic devices 120, 130, 140, and 150 to initiate a transaction request, some nodes are selected from all nodes of the blockchain system 110 as consensus nodes to participate in the consensus verification of the transaction request, and a master node is elected from the consensus nodes, and the remaining consensus nodes automatically become replica nodes. The master node can generate a transaction consensus message according to the transaction request and broadcast it to all replica nodes. After the replica node receives the transaction consensus message, it verifies it. The verified replica node broadcasts the transaction consensus message to other replica nodes and receives confirmation messages from other nodes. When this node receives a set number of consistent confirmation messages, the node enters the confirmation stage, executes this block transaction, and replies to the client. The client's superior node reaches a consensus based on the node reply message received by the client, and each node executes the block chain to complete an accounting or data update.

[0058] It should be noted that the transaction processing method applied to the blockchain provided by the embodiment of the present disclosure can generally be executed by some nodes selected from all nodes in the blockchain system. Accordingly, the transaction processing device applied to the blockchain provided by the embodiment of the present disclosure can generally be set in some nodes selected from all nodes in the blockchain system.

[0059] It should be understood that Figure 1 The number and type of terminal devices and electronic devices in the embodiment are only for illustration purposes. Any number and type of terminal devices and electronic devices may be provided as required.

[0060] In response to the technical problems of low consensus efficiency and low system security in the PBFT algorithm, related technologies also provide some solutions. For example, each consensus stage in the PBFT three-stage consensus process is verified. Only when the verification of the current consensus stage is passed, the next consensus stage will be entered. Although security can be improved, the delay is long and the efficiency of consensus cannot be improved. For example, the reliability of member nodes is verified based on the ring signature method, but the implementation process of the ring signature algorithm is relatively complicated, resulting in a long delay, and it is also impossible to take into account the consensus efficiency and system security of the PBFT algorithm. In view of this, the present disclosure provides an optimization method for the PBFT algorithm, and the optimized PBFT algorithm can improve both the efficiency of consensus and the security of the system.

[0061] The following will be based on Figure 1 The described system architecture 100 is implemented by Figure 2 to Figure 6 The transaction processing method applied to the blockchain of the embodiment of the present disclosure is elaborated in detail.

[0062] Figure 2The flowchart of the transaction processing method applied to the blockchain according to the embodiment of the present disclosure is schematically shown. Figure 2 As shown, the transaction processing method 200 of this embodiment may include operations S210 to S240.

[0063] In operation S210 , in response to a transaction request initiated by a client, a node credit level corresponding to each node among N nodes is determined.

[0064] According to the embodiments of the present disclosure, the client or user end refers to an application program corresponding to the server and providing local services to users, which can be installed on Figure 1 In any electronic device shown. As the transaction initiator, the transaction is broadcast to the entire network and the sender's signature is attached. All nodes independently monitor the transaction data of the entire network to verify the legitimacy of the transaction. In the present disclosure, the transaction request initiated by the client may include the message content, the message summary, the specific operation of the transaction request, the timestamp added by the client when the transaction request occurs, and the client identification.

[0065] In related technologies, every transaction needs to be agreed upon by all member nodes in the blockchain network. Each PBFT three-stage consensus process requires multiple interactions, multiple communications, high time complexity, and a serious decline in consensus efficiency. The more member nodes there are in the blockchain network, the longer it takes. The PBFT algorithm selects the master node from all member nodes through a random selector. This method makes it possible for Byzantine nodes (i.e., malicious nodes) to serve as master nodes. Once a malicious node serves as the master node, it will cause a view change, which will greatly reduce system performance, affect the consensus results, and bring great security risks to the transaction security of the entire blockchain. Therefore, the PBFT algorithm cannot take into account both the efficiency of consensus and the security of the system. To this end, the present disclosure avoids the solution of selecting the master node through a random selector, and provides a method for electing the master node according to the credit level of each node. First, it is necessary to determine the credit level corresponding to each node. Different node credit levels correspond to different node roles. The node role is used to indicate whether the node can participate in the consensus process. If it can participate in the consensus process, the role of the node in the consensus process is the role of the master node or the role of the replica node. It should be noted that the number of credit levels can be pre-set according to actual conditions, and the present disclosure does not limit this.

[0066] In operation S220, a master node and M-1 replica nodes are selected from N nodes based on the node credit level corresponding to each node and a preset election strategy, where M<N.

[0067] According to an embodiment of the present disclosure, based on the node credit level corresponding to each node, some M nodes can be screened out from all N nodes included in the blockchain system to participate in the consensus verification process of subsequent transaction requests as consensus nodes, and according to a preset election strategy, a master node can be elected from the screened M consensus nodes. At this time, the other M-1 nodes among the M consensus nodes except the master node automatically become replica nodes (also called slave nodes).

[0068] In operation S230, in response to the master node receiving the transaction request, response information of the transaction request is sent to the client to obtain a verification result of the master node.

[0069] According to an embodiment of the present disclosure, after receiving a transaction request signed by a client, the master node needs to verify whether the signature of the client request message is correct. If the verification result indicates that the signature of the client request message is incorrect, indicating that the client's transaction request is an illegal request, it can be directly discarded. If the verification result indicates that the signature of the client request message is correct, a response message of the transaction request is sent to the client to obtain the verification result of the master node. The response information includes at least a self-certification message of the master node, and the self-certification message is used to verify whether the master node is a malicious node, for example, it may include but is not limited to the execution result of the master node. If the client does not receive the self-certification message returned by the master node within a certain period of time, the master node is considered to be a malicious node, and a transaction request can be initiated again to re-elect the master node.

[0070] In operation S240, when the self-certification message of the master node passes the verification, the consensus verification result of the master node and M-1 replica nodes on the transaction request is determined to feed back the processing result of the transaction request to the client.

[0071] According to the embodiments of the present disclosure, if the self-certification message of the master node is verified, indicating that the master node is a normal node and a non-malicious node, the master node and the replica node enter the consensus verification process to verify the transaction request from the client. If the verification result shows that the verification is passed, the message of the verification is written into the account book of the current block and the transaction request processing result is replied to the client. If the verification result shows that the verification is not passed, the message of the verification is not passed is replied to the client so that the client can determine whether it needs to re-initiate the transaction request.

[0072] Through the embodiments of the present disclosure, based on the node credit level corresponding to each node and the preset election strategy, some but not all nodes are screened out from all the nodes included in the blockchain to participate in the consensus process, which can at least partially reduce the probability of malicious nodes becoming master nodes, reduce the number of consensus nodes, and improve the efficiency of the consensus process. By adding self-certification information to the master node and performing interactive verification with the client, when the self-certification information of the master node is verified, the consensus node performs consensus verification on the transaction request, which can at least partially improve the security of the master node, thereby improving the security of the blockchain system.

[0073] As an optional embodiment, selecting a master node and M-1 replica nodes from N nodes based on the node credit level corresponding to each node and a preset election strategy may include: filtering out nodes with the lowest node credit level from the N nodes based on the node credit level corresponding to each node to screen out a consensus node candidate set, wherein the consensus node candidate set includes M nodes, and the M nodes participate in the consensus verification of the transaction request; selecting a master node from the consensus node candidate set based on the preset election strategy; and determining the M-1 nodes other than the master node in the consensus node candidate set as M-1 replica nodes.

[0074] According to the embodiments of the present disclosure, since each node level is divided according to the node credit value, each node level has different permissions. The node with the lowest node credit level has the highest probability of being a malicious node and is not suitable for participating in the consensus process. The node with the highest node credit level has the lowest probability of being a malicious node and is most suitable for electing a master node. Therefore, in the process of screening consensus nodes in the present disclosure, the nodes with the lowest node credit level are filtered out. Specifically, taking the node credit levels from high to low as A, B, C, and D as an example, Class A nodes have excellent credit and the highest level, and are given priority to serve as master nodes; Class B nodes have good credit. When Class A nodes are selected or Class A nodes do not exist, master nodes can be selected from Class B nodes. Class C nodes have medium credit and low levels and are not suitable for serving as master nodes, but can still participate in block consensus as slave nodes. Class D nodes have poor credit and cannot participate in consensus. Furthermore, since D nodes do not participate in the consensus process, D nodes can be filtered out, leaving M∈N nodes, reducing the number of nodes by (NM) / N×100%, and reducing the number of nodes that enter the three-stage consensus later. For example, before filtering, the number of nodes included in the blockchain network is N=4, and there is 1 node with the lowest credit level. Then, after filtering, the number of consensus nodes included in the consensus node candidate set is M=3, which can reduce 25% of the nodes entering the consensus process.

[0075] Through the embodiments of the present disclosure, considering that the node with the lowest credit rating has the highest probability of becoming a malicious node, in order to ensure that there are no malicious nodes in the consensus node, it is filtered out, reducing communication losses and the number of view switching changes, thereby greatly improving system efficiency.

[0076] As an optional embodiment, determining the node credit level corresponding to each node among N nodes may include: determining the credit value corresponding to each node by means of encrypted lottery; obtaining a node credit level division rule, wherein the node credit level division rule includes P node credit levels from high to low and a preset credit threshold interval corresponding to each node credit level; and determining the node credit level corresponding to each node based on the credit value corresponding to each node and the node credit level division rule.

[0077] According to an embodiment of the present disclosure, the process of determining the credit value corresponding to each node by means of encrypted lottery is described as follows:

[0078]

[0079] Among them, the verifiable random function VRF(·) is used to obtain<hash,pi> , hash and pi are the hash value and proof obtained by performing VRF (Verifiable Random Function) operation on the lottery parameters, sk is the user's private key, seed is the random seed of this round, role and round are used to distinguish the role of the node in the consensus process and the consensus round in which the node participates, w is the participant's credit value, ∑w is the total credit value of the participant, j is the lottery result, j=0 means no lottery, j>0 means lottery and j credit values ​​are obtained. During the initialization process, the weights of each node are set equal, that is, w0=w1=…w m , which reflects the fairness of participating in the lottery. The equal-weight random verification lottery algorithm has the following characteristics: all participating nodes draw independently, do not interact with other participating nodes during the lottery process, all participating nodes can verify the correctness of the lottery results through the public keys of other participating nodes, and all participating nodes draw with the same probability, and the lottery process is fair and just.

[0080] According to an embodiment of the present disclosure, the credit value C corresponding to each node determined by encrypted lottery can be iNormalization is performed and four threshold intervals are set reasonably. Each threshold interval corresponds to a node credit level. Then, node levels are divided according to the credit value corresponding to each node and the threshold interval to determine the node credit level corresponding to each node. The node credit level can be divided into four levels from high to low. The node credit levels are A, B, C, and D from the highest to the lowest. That is, the node credit value of the node application level A is the highest, and the node credit value of the node application level D is the lowest. The corresponding relationship between the node credit level and the node role is shown in Table 1.

[0081] Table 1

[0082] Credit rating Prioritize being the master node Can serve as master node Slave Node A-level √ √ √ Class B × √ √ C-Class × × √ D-Class × × ×

[0083] Through the embodiments of the present disclosure, the credit value of the node is determined according to the encrypted lottery method, and the node credit level corresponding to each node is determined according to the preset node credit level. This can not only greatly improve the enthusiasm of the nodes, but also effectively prevent malicious nodes from becoming master nodes, and effectively reduce the participation of malicious nodes in consensus.

[0084] Figure 3 The consensus node screening process according to an embodiment of the present disclosure is schematically illustrated.

[0085] like Figure 3 As shown, the consensus node screening process 300 provided by the present disclosure can be described as: when the alliance blockchain system 310 includes member nodes 311~318, the lottery result of the credit value of each member node is determined, and after filtering out the member nodes with the lowest node credit level, a candidate node set 320 including consensus nodes 311, 312, 315, and 316 is obtained. According to the credit values ​​of consensus nodes 311, 312, 315, and 316, the master node can be elected as consensus node 311, and consensus nodes 312, 315, and 316 can be elected as replica nodes.

[0086] As an optional embodiment, the preset election strategy includes a priority election strategy and a master node election strategy. Based on the preset election strategy, selecting a master node from the consensus node candidate set may include: based on the priority election strategy, detecting whether there is a node among the nodes with the highest node credit level; if so, based on the master node election strategy, detecting whether a master node is selected from the nodes with the highest node credit level; if not, based on the priority election strategy, detecting whether there is a node among the nodes with the next highest node credit level; and if so, based on the master node election strategy, detecting whether a master node is selected from the nodes with the next highest node credit level, until a master node is selected.

[0087] According to the embodiments of the present disclosure, taking the node credit levels from high to low as A, B, C, and D as an example, Class A nodes have excellent credit and the highest level, and are given priority to serve as master nodes; Class B nodes have good credit, and when Class A nodes are selected or there are no Class A nodes, the master node can be selected from Class B nodes; Class C nodes have medium credit and a low level and are not suitable for serving as master nodes, but can still participate in block consensus as slave nodes.

[0088] According to an embodiment of the present disclosure, based on the priority election strategy, the master node is preferentially selected within the range of Class A nodes, followed by Class B, and so on.

[0089] The PBFT algorithm is a consensus algorithm based on the principle of State Machine Replication (SMR). It is mainly composed of a consistency protocol, a view switching protocol, and a checkpoint protocol. Under normal circumstances, the system runs under the consistency protocol and the checkpoint protocol. All replicas operate in a view rotation process. The master node is determined based on the view number and the number of nodes. When the master node fails, the view switching protocol will be started to ensure that the system executes client requests in an orderly manner. The PBFT algorithm traverses all member nodes in the alliance blockchain to obtain consensus results through point-to-point communication between member nodes. The entire consensus verification process is divided into three stages, namely the PRE-PREPARE stage, the PREPARE stage, and the COMMIT stage.

[0090] As an optional embodiment, as an optional embodiment, the master node election strategy may include: a heartbeat detection success strategy, a strategy of having the largest view number, and a strategy of having the largest serial number.

[0091] According to the embodiments of the present disclosure, based on the master node election strategy, the master node election is based on the heartbeat detection mechanism and the longest chain principle. First, a heartbeat detection is performed on the candidate node range. If the heartbeat detection result is successful, it is screened according to the longest chain principle to finally obtain the master node. Assuming that a primary node Primary(i) is elected, the replica node sends a Ping command to the primary node once every certain period of time and performs a heartbeat detection. It is stipulated that the node that succeeds in Ping within T time and has the largest view number and the largest number is the primary node. On the contrary, if the replica node sends a Ping command to the primary node Primary(i) and does not receive a response within the predetermined time or receives an incorrect response, it is considered that this primary node is unavailable and the primary node is searched again.

[0092] Through the embodiments of the present disclosure, based on the heartbeat detection mechanism and the longest chain principle, the master node is elected in order from high to low node credit levels, which can avoid the probability of malicious nodes becoming master nodes, reduce the impact of malicious nodes, and improve system security.

[0093] As an optional embodiment, the method may also include: in response to detecting that a new node has joined the blockchain, setting an initial credit value for the new node, wherein the node credit level corresponding to the initial credit value is an intermediate level between the highest level and the lowest level; and adjusting the initial credit value based on the consensus verification result of the new node participating in the consensus verification to determine the credit value corresponding to the new node.

[0094] According to the embodiments of the present disclosure, rules for node credit rewards and penalties can be formulated for nodes. Optionally, rewards or penalties are given based on the behavior of the node in the system, and the credit value of the newly added node is set to C nomal , making it at level B or C. When a node participates in the generation of a valid block in the system, it will be rewarded, and the node credit points will increase by X add ; When a node fails to generate a valid block in the system, it will be punished and its credit points will be reduced by X sub .

[0095] Through the embodiments of the present disclosure, the credit value of the newly joined node is set at an intermediate level in the node credit rating, and rewards and penalties are given according to its participation in consensus behavior, so that the credit value of the newly joined node can be managed dynamically and objectively.

[0096] As an optional embodiment, the method may further include: if the self-certification message of the master node fails to pass the verification, re-selecting the master node and M-1 replica nodes from the N nodes. According to the embodiment of the present disclosure, before the master node broadcasts the transaction consensus request to the M-1 replica nodes, if the self-certification message of the master node fails to pass the verification, the broadcast of the transaction consensus message is terminated in time, and the master node is re-elected, which can improve the security of the system.

[0097] As an optional embodiment, determining the consensus verification results of the master node and M-1 replica nodes for a transaction request may include: the master node generates a first transaction consensus message based on the transaction request, and broadcasts the first transaction consensus message to the M-1 replica nodes; each of the M-1 replica nodes adds self-certification information to the first transaction consensus message to generate a second transaction consensus message, and broadcasts the second transaction consensus message to other nodes except itself; determining whether the number of second transaction consensus messages that have passed the verification received by the master node and each replica node exceeds a first preset threshold; if the number exceeds the first preset threshold, the master node and each replica node broadcast a confirmation message of the second transaction consensus message to other nodes except themselves; and determining the consensus verification results of the master node and the M-1 replica nodes for the transaction request based on the number of confirmation messages that have passed the verification received by the master node and each replica node.

[0098] According to an embodiment of the present disclosure, after receiving the request, the master node sends a self-certification message to the client to prove that the master node itself is not a Byzantine node. The verification content includes: verifying the message signature, timestamp, and whether the execution result of the master node is consistent with the message. If the verification passes, it enters the pre-prepare stage, and the master node broadcasts the message to other replica nodes, otherwise the master node is re-selected. If within a certain time τ, the client has not received the self-certification message returned by the master node, then it is considered that the master node is a Byzantine node, and the master node should be re-elected. When the master node is abnormal, it stops broadcasting messages to the replica nodes. When the replica node receives the message broadcast by the master node, the replica node also needs to add self-certification information v to the message r to obtain the prepare message<r,v> , the replica node will prepare the message<r,v> Broadcast to nodes other than itself, this process is called the prepare phase. It should be noted that if the master node is abnormal, the message broadcast to the replica node will be terminated. The first preset threshold can be 2f+1, where f represents the number of fault-tolerant member nodes that can be supported in the blockchain network.

[0099] Through the embodiments of the present disclosure, in the preparation stage of the transaction consensus message, the replica node adds a self-certification message in the message broadcast to other nodes, thereby increasing the self-certification link of the replica node. Only when the self-certification is passed can the subsequent consensus stage be continued, which can improve the security of the system.

[0100] As an optional embodiment, determining the consensus verification results of the master node and M-1 replica nodes for a transaction request based on the number of verification-passing confirmation messages received by the master node and each replica node may include: determining whether the number of verification-passing confirmation messages received by the master node and each replica node exceeds a first preset threshold; if it exceeds the first preset threshold, the master node and each replica node return a response message of the transaction request to the client; and if the number of response messages of the transaction request received by the client exceeds a second preset threshold, confirming that the consensus verification result of the transaction request is consensus verification passed, wherein the second preset threshold is less than the first preset threshold.

[0101] According to the embodiment of the present disclosure, the self-certification information in the commit message of the replica node is verified to be consistent with its behavior. If the verification is passed, the reply phase is entered, and the verified message is written into the account book of the current block and replied to the client. The second preset threshold can be f+1, where f represents the number of fault-tolerant member nodes that can be supported in the blockchain network.

[0102] Through the embodiments of the present disclosure, in the confirmation phase of the transaction consensus message, a self-certification link of the replica node is added, and the subsequent consensus phase is continued only when the self-certification passes, which can improve the security of the system.

[0103] As an optional embodiment, the method may further include: when the number of response information of the transaction request received by the client does not exceed the second preset threshold, confirming that the consensus verification result of the transaction request is consensus verification failure.

[0104] Through the embodiments of the present disclosure, according to the number of transaction request response messages received by the client, it can be determined whether the transaction request initiated by it has reached a consensus of the entire network. When a consensus of the entire network is reached, the block is put on the chain, further improving the security of the transaction system.

[0105] According to the embodiments of the present disclosure, the consensus process includes a transaction request sending phase (REQUEST), a first consensus process (PRE-PREPARE, pre-preparation phase), a second consensus process (PREPARE, preparation phase), a third consensus process (COMMIT, submission phase) and a transaction request feedback phase (REPLY). PRE-PREPARE, PREPARE and COMMIT constitute a Byzantine fault-tolerant three-stage consensus process. In view of the Byzantine fault-tolerant three-stage consensus process, the present disclosure optimizes and improves the relevant technology, which will be described below. Figure 4 and Figure 5 Provide detailed explanation.

[0106] Figure 4 The following schematically shows the three-stage consensus process of Byzantine fault tolerance in the related art. Figure 4 As shown, in the related art, the nodes referring to the consensus process include a master node, a replica node 1, a replica node 2 and a replica node 3, and the contents included in each consensus process are described as follows.

[0107] In the transaction request sending phase (REQUEST): the transaction initiator broadcasts the transaction to the entire network and attaches the sender's signature. All consensus nodes independently monitor the transaction data of the entire network to verify the legitimacy of the transaction. Specifically, the client sends a<REQUEST,o,t,c> Transaction request, where REQUEST indicates the message content m and the message digest d(m), o indicates the specific operation of the transaction request, t indicates the timestamp added by the client when the transaction request occurs, and c indicates the client identifier. The client signs the transaction request. All nodes are allowed to serve as master nodes through a random selector.

[0108] In the first consensus process (PRE-PREPARE): After receiving the transaction request signed by the client, the master node needs to verify whether the signature of the client request message is correct. If the verification result indicates that the signature of the client request message is incorrect, indicating that the client's transaction request is an illegal request, it can be directly discarded. If the verification result indicates that the signature of the client request message is correct, a number n is first assigned. The number n is mainly used to sort the client's transaction requests. n is in a certain range [h, H]. Then broadcast a <<PRE-PREPARE,v,n,d> , m> message to all other replica nodes, where v represents the view number, d represents the client message digest, and m represents the message content.<PRE-PREPARE,v,n,d> Message signing.

[0109] In the second consensus process (PREPARE): After receiving the PRE-PREPARE message signed by the master node, the replica node Replica i (1<i≤M) needs to perform the following verifications: (1) Whether the signature of the master node PRE-PREPARE message is correct. (2) Whether the current replica node has received a PRE-PREPARE message with the same view number v and the same number n, but with a different signature. (3) Whether the client message digest d is consistent with the digest of the message content m. (4) Whether the number n is in the interval [h, H]. If the verification result indicates that it is an illegal transaction request, it can be discarded directly. If the verification result indicates that it is a correct transaction request, the replica node Replica i sends a message to other nodes (including other replica nodes and the master node).<PREPARE,v,n,d,i> The message, v, n, d are the same as those in the above PRE-PREPARE message. i represents the current replica node number. The replica node i is<PREPARE,v,n,d,i> Message signature. Record PRE-PREPARE and PREPARE messages in the log to recover unfinished request operations during the View Change process.

[0110] In the third consensus process (COMMIT): the replica node broadcasts a message to other replica nodes, and receives confirmation messages from other nodes, checks whether the message signature, summary, view number, etc. are correct, etc. If the verification is successful, it is cached. When the replica node receives consistent information from more than 2f+1 different nodes, the node enters the confirmation phase, executes this block transaction, and replies to the client. Specifically, after receiving the signed PREPARE message, the master node and the replica node need to perform the following verifications: (1) Whether the replica node PREPARE message signature is correct. (2) Whether the current replica node has received the number n under the same view v. (3) Whether the client message summary d is consistent with the summary in the currently received PRE-PREPARE. (4) Whether the number n is within the interval [h, H]. If the verification result indicates that it is an illegal transaction request, it can be directly discarded. If replica node i receives 2f+1 verified PREPARE messages, it sends a message to other nodes (including other replica nodes and the master node).<COMMIT,v,n,d,i> The message, v, n, d, i are the same as those in the above PREPARE message. The replica node i has<COMMIT,v,n,d,i> Message signature. Record COMMIT messages in the log to recover unfinished request operations during the View Change process, and record PREPARE messages sent by other replica nodes in the log.

[0111] In the transaction request feedback phase (REPLY): After receiving the signed COMMIT message, the master node and the replica node need to perform the following verifications: (1) Whether the signature of the replica node COMMIT message is correct. (2) Whether the current replica node has received the number n under the same view v. (3) Whether the client message digest d is consistent with the digest in the currently received PRE-PREPARE. (4) Whether the number n is in the interval [h, H]. If the verification result indicates that it is an illegal transaction request, it can be discarded directly. If the master node and the replica node i receive 2f+1 verified COMMIT messages, it means that most of the nodes in the current alliance blockchain network have reached a consensus. At this time, run the client's request operation o and return<REPLY,v,t,c,i,r> The client sends a message to the client, and r indicates the operation result of the transaction request. If the client receives f+1 identical REPLY messages, that is, the REPLY messages have the same timestamp and reply message, it means that the transaction request initiated by the client has reached a consensus across the entire network, and each node executes the block on the chain. If the client does not receive f+1 identical REPLY messages, the client needs to determine whether to resend the transaction request to the master node and record the COMMIT messages sent by other replica nodes in the log.

[0112] Figure 5 The Byzantine fault-tolerant three-stage consensus process of the embodiment of the present disclosure is schematically illustrated.

[0113] like Figure 5 As shown, the embodiment of the present disclosure improves and optimizes the PBFT algorithm, which is specifically reflected in two aspects. The first aspect is to reduce the number of nodes participating in the Byzantine fault-tolerant three-stage consensus process. The second aspect is to increase the node self-certification information. Specifically, Figure 5 As shown, in this disclosure, the nodes referring to the consensus process include the master node, replica node 1 and replica node 2, and the replica node 3 with the lowest node credit rating is filtered out. The verification content added in each consensus process is described as follows: In the transaction request sending stage (REQUEST): the master node adds self-certification information to achieve interactive authentication with the client. In the first consensus process (PRE-PREPARE): the replica node receives the message broadcast by the master node, that is, <<PRE-PREPARE,v,n,d> , m> message, at this time the replica node also needs to<PRE-PREPARE,v,n,d> , add self-certification information v to the message m> to get the prepare message. In the third consensus process (COMMIT): verify whether the self-certification information in the commit message of the replica node is consistent with its behavior. If the verification is successful, enter the REPLY phase, write the verified message into the account book of the current block and reply to the client.

[0114] Through the transaction processing method provided by the present invention, a practical Byzantine fault tolerance optimization method based on node credit grading is used to elect the master node and the replica node according to the node credit level and the preset election strategy. The master node adds self-certification information to interact with the client for verification, and further verifies the master node. During the consensus process, the master node and the replica node broadcast a message including the message itself and the node self-certification information, and increase the verification step. This can reduce the impact of malicious nodes to a certain extent, reduce the number of point-to-point communications, and improve the efficiency of the alliance chain consensus process and the security of the system.

[0115] Figure 6 The flowchart of the transaction processing method applied to blockchain according to another embodiment of the present disclosure is schematically shown. Figure 6 As shown, the transaction processing method 600 of this embodiment may include operations S610 to S680.

[0116] First, an encrypted lottery is performed to obtain the node credit value (operation S610), then the node information is evaluated and the node levels are divided (operation S620), and then a candidate master node is selected (operation S630), and then the candidate master node is verified (operation S640). If the verification passes, the consistency protocol is executed (operation S650). If the verification fails, the candidate master node is reselected (operation S630), and then it is detected whether the timeout condition is triggered (operation S660). If so, the checkpoint protocol is executed (operation S670). If not, a new block is generated (operation S680).

[0117] The disclosed embodiment provides a transaction processing method, which mainly considers the credibility and scope of application of the alliance blockchain node. First, by encrypting and drawing lots for the nodes, some rather than all nodes are selected to participate in the consensus process, thereby reducing the number of nodes; secondly, the node credit is divided and a reward and punishment system is formulated to achieve the purpose of node grading; then, self-certification information is added to the master node, and interactive verification is performed with the client to improve the security of the master node; finally, self-certification information and verification process are added to the consensus process to increase the security of the consensus process. To a certain extent, the present invention can reduce the impact of malicious nodes, reduce the number of point-to-point communications, and improve the efficiency of the alliance chain consensus process and the security of the system.

[0118] Figure 7 The block diagram of the transaction processing device applied to blockchain according to the embodiment of the present disclosure is schematically shown. Figure 7 As shown, the transaction processing device 700 of this embodiment may include a first determination module 710 , a first selection module 720 , a verification module 730 and a second determination module 740 .

[0119] The first determination module 710 is used to determine the node credit level corresponding to each node in the N nodes in response to the transaction request initiated by the client. Optionally, the first determination module 710 can be used to perform Figure 2 The operation S210 described above will not be described in detail here.

[0120] The first selection module 720 is used to select a master node and M-1 replica nodes from N nodes based on the node credit level corresponding to each node and a preset election strategy, where M<N. Optionally, the first selection module 720 can be used to perform Figure 2 The operation S220 described above will not be described in detail here.

[0121] The verification module 730 is used to send a response message of the transaction request to the client in response to the master node receiving the transaction request, so as to obtain the verification result of the master node, wherein the response message at least includes a self-verification message of the master node, and the self-verification message is used to verify whether the master node is a malicious node. Optionally, the verification module 730 can be used to perform, for example Figure 2 The operation S230 described above will not be described in detail here.

[0122] The second determination module 740 is used to determine the consensus verification result of the transaction request by the master node and M-1 replica nodes when the self-certification message of the master node passes the verification, so as to feedback the processing result of the transaction request to the client. Optionally, the second determination module 740 can be used to perform Figure 2 The operation S240 described above will not be described in detail here.

[0123] As an optional embodiment, the aforementioned first selection module may include: a screening submodule, used to filter out nodes with the lowest node credit level from N nodes based on the node credit level corresponding to each node, so as to screen out a consensus node candidate set, wherein the consensus node candidate set includes M nodes, and the M nodes participate in the consensus verification of the transaction request; a first selection submodule, used to select a master node from the consensus node candidate set based on a preset election strategy; and a first determination submodule, used to determine M-1 nodes in the consensus node candidate set except the master node as M-1 replica nodes.

[0124] As an optional embodiment, the aforementioned first determination module may include: a second determination submodule, used to determine the credit value corresponding to each node by means of encrypted lottery; a first acquisition submodule, used to obtain a node credit level division rule, wherein the node credit level division rule includes P node credit levels from high to low and a preset credit threshold interval corresponding to each node credit level; and a third determination submodule, used to determine the node credit level corresponding to each node based on the credit value corresponding to each node and the node credit level division rule.

[0125] As an optional embodiment, the preset election strategy includes a priority election strategy and a master node election strategy, and the aforementioned first selection submodule may include: a first detection unit, used to detect whether there is a node among the nodes with the highest node credit level based on the priority election strategy; a second detection unit, used to detect whether a master node is selected from the nodes with the highest node credit level based on the master node election strategy if such node exists; a third detection unit, used to detect whether there is a node among the nodes with the next highest node credit level based on the priority election strategy if such node cannot be selected; and a fourth detection unit, used to detect whether a master node is selected from the nodes with the next highest node credit level based on the master node election strategy if such node exists, until the master node is selected.

[0126] As an optional embodiment, the aforementioned master node election strategy may include: a heartbeat detection success strategy, a strategy of having the largest view number, and a strategy of having the largest serial number.

[0127] As an optional embodiment, the aforementioned first determination module may also include: a setting submodule, used to set an initial credit value for the new node in response to detecting that a new node has joined the blockchain, and the node credit level corresponding to the initial credit value is an intermediate level between the highest level and the lowest level; and a fourth determination submodule, used to adjust the initial credit value according to the consensus verification result of the new node participating in the consensus verification, so as to determine the credit value corresponding to the new node.

[0128] As an optional embodiment, the device may further include: a second selection module, used to re-select the master node and M-1 replica nodes from the N nodes when the self-certification message of the master node fails to pass the verification.

[0129] As an optional embodiment, the aforementioned second determination module may include: a first broadcast submodule, for the master node to generate a first transaction consensus message based on the transaction request, and broadcast the first transaction consensus message to M-1 replica nodes; a second broadcast submodule, for each of the M-1 replica nodes to add self-certification information to the first transaction consensus message to generate a second transaction consensus message, and broadcast the second transaction consensus message to other nodes except itself; a fifth determination submodule, for determining whether the number of verified second transaction consensus messages received by the master node and each replica node exceeds a first preset threshold; a third broadcast submodule, for the master node and each replica node to broadcast a confirmation message of the second transaction consensus message to other nodes except themselves when the number exceeds the first preset threshold; and a sixth determination submodule, for determining the consensus verification result of the master node and the M-1 replica nodes on the transaction request based on the number of verified confirmation messages received by the master node and each replica node.

[0130] As an optional embodiment, the aforementioned sixth determination submodule may include: a first determination unit, used to determine whether the number of verification confirmation messages received by the master node and each replica node exceeds a first preset threshold; a return unit, used to, when the number exceeds the first preset threshold, the master node and each replica node return a response message of the transaction request to the client; and a second determination unit, used to confirm that the consensus verification result of the transaction request is consensus verification passed when the number of response messages of the transaction request received by the client exceeds a second preset threshold, wherein the second preset threshold is less than the first preset threshold.

[0131] As an optional embodiment, the aforementioned sixth determination submodule may further include: a third determination unit, configured to confirm that the consensus verification result of the transaction request is consensus verification failure when the number of response information of the transaction request received by the client does not exceed the second preset threshold.

[0132] It should be noted that the implementation methods, technical problems solved, functions realized, and technical effects achieved of each module in some embodiments of the transaction processing device are the same or similar to the implementation methods, technical problems solved, functions realized, and technical effects achieved of each corresponding step in some embodiments of the transaction processing method, and they will not be repeated here.

[0133] According to the embodiments of the present invention, any one or more of the modules, submodules, and units, or at least part of the functions of any one of them, can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules, submodules, and units can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules, submodules, and units can be at least partially implemented as hardware circuits, such as field programmable gate arrays (FNGA), programmable logic arrays (NLA), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (ASICs), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules, submodules, and units can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be performed.

[0134] For example, the first determination module, the selection module, the verification module, the second determination module, the screening submodule, the first selection submodule, the first determination submodule, the second determination submodule, the first acquisition submodule, the third determination submodule, the setting submodule, the fourth determination submodule, the second selection submodule, the first broadcast submodule, the second broadcast submodule, the fifth determination submodule, the third broadcast submodule, the sixth determination submodule, the first detection unit, the second detection unit, the third detection unit, the fourth detection unit, the first determination unit, the return unit, the second determination unit, and the third determination unit can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the first determination module, the selection module, the verification module, the second determination module, the screening submodule, the first selection submodule, the first determination submodule, the second determination submodule, the first acquisition submodule, the third determination submodule, the setting submodule, the fourth determination submodule, the second selection submodule, the first broadcast submodule, the second broadcast submodule, the fifth determination submodule, the third broadcast submodule, the sixth determination submodule, the first detection unit, the second detection unit, the third detection unit, the fourth detection unit, the first determination unit, the return unit, the second determination unit and the third determination unit can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FNGA), a programmable logic array (NLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or can be implemented in any one of the three implementation methods of software, hardware and firmware or in an appropriate combination of any of them. Alternatively, at least one of the first determination module, the selection module, the verification module, the second determination module, the screening submodule, the first selection submodule, the first determination submodule, the second determination submodule, the first acquisition submodule, the third determination submodule, the setting submodule, the fourth determination submodule, the second selection submodule, the first broadcast submodule, the second broadcast submodule, the fifth determination submodule, the third broadcast submodule, the sixth determination submodule, the first detection unit, the second detection unit, the third detection unit, the fourth detection unit, the first determination unit, the return unit, the second determination unit and the third determination unit can be at least partially implemented as a computer program module, and when the computer program module is executed, the corresponding function can be executed.

[0135] Figure 8 A schematic diagram of a computer-readable storage medium product suitable for implementing the transaction processing method described above according to an embodiment of the present disclosure is schematically shown.

[0136] In some possible implementations, various aspects of the present invention may also be implemented in the form of a program product, which includes a program code. When the program product is run on a device, the program code is used to enable the device to perform the aforementioned operations (or steps) in the transaction processing method according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification. For example, the electronic device may perform the following operations: Figure 2 Operations S210 to S240 shown in FIG. Figure 6 Operations S610 to S680 shown in FIG.

[0137] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, system or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (ENROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0138] like Figure 8 As shown, a program product 800 for transaction processing according to an embodiment of the present invention is described, which can be in a portable compact disk read-only memory (CD-ROM) and includes program code, and can be run on a device, such as a personal computer. However, the program product of the present invention is not limited thereto, and in this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, system or device.

[0139] The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, in which a readable program code is carried. Such propagated data signals may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, system, or device. The program code contained on the readable medium may be transmitted using any suitable medium, including, but not limited to, wireless, wired, optical cable, RF, etc., or any suitable combination of the above.

[0140] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C", language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user computing device, partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device via any type of network, including a local area network (LAA) or a wide area network (WAA), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0141] Fig. 9 A block diagram of an electronic device suitable for implementing the transaction processing method described above according to an embodiment of the present disclosure is schematically shown. Fig. 9 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0142] like Fig. 9 As shown, the electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CNU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), and the like. The processor 901 may also include an onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.

[0143] In RAM 903, various programs and data required for the operation of electronic device 900 are stored. Processor 901, ROM 902 and RAM 903 are connected to each other via bus 904. Processor 901 executes various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 902 and / or RAM 903. It should be noted that the program can also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 can also execute the program stored in the one or more memories according to the embodiment of the present disclosure. Figure 2 Operations S210 to S240 shown in FIG. Figure 6 Operations S610 to S680 shown in FIG.

[0144] According to an embodiment of the present disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to the bus 904. The system 900 may further include one or more of the following components connected to the I / O interface 905: an input portion 906 including a keyboard, a mouse, etc.; an output portion 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 908 including a hard disk, etc.; and a communication portion 909 including a network interface card such as an LAA card, a modem, etc. The communication portion 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage portion 908 as needed.

[0145] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.

[0146] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the transaction processing method according to the embodiment of the present disclosure is implemented, including the following steps: Figure 2 Operations S210 to S240 shown in FIG. Figure 6 Operations S610 to S680 shown in FIG.

[0147] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (ENROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 902 and / or RAM 903 described above and / or one or more memories other than ROM 902 and RAM 903.

[0148] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0149] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0150] The embodiments of the present disclosure are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. A transaction processing method applied to a blockchain, wherein: The blockchain includes N nodes, where N is a positive integer, and the method includes: In response to a transaction request initiated by a client, determining a node credit rating corresponding to each of the N nodes; Based on the node credit level corresponding to each node and the preset election strategy, a master node and M-1 replica nodes are selected from the N nodes, M <N; In response to the master node receiving the transaction request, sending response information of the transaction request to the client to obtain a verification result of the master node, wherein the response information at least includes a self-verification message of the master node, and the self-verification message is used to verify whether the master node is a malicious node; When the self-certification message of the master node passes the verification, determining the consensus verification result of the transaction request by the master node and the M-1 replica nodes, so as to feed back the processing result of the transaction request to the client; Wherein, the selecting of the master node and M-1 replica nodes from the N nodes based on the node credit level corresponding to each node and the preset election strategy includes: filtering out nodes with the lowest node credit level from the N nodes based on the node credit level corresponding to each node, so as to screen out a consensus node candidate set, wherein the consensus node candidate set includes M nodes, and the M nodes participate in the consensus verification of the transaction request; selecting the master node from the consensus node candidate set based on the preset election strategy; determining the M-1 nodes in the consensus node candidate set except the master node as the M-1 replica nodes; Among them, the determination of the consensus verification result of the transaction request by the master node and the M-1 replica nodes includes: the master node generates a first transaction consensus message based on the transaction request, and broadcasts the first transaction consensus message to the M-1 replica nodes; each of the M-1 replica nodes adds self-certification information to the first transaction consensus message to generate a second transaction consensus message, and broadcasts the second transaction consensus message to other nodes except itself; determines whether the number of the second transaction consensus messages that have passed the verification received by the master node and each replica node exceeds a first preset threshold; if the first preset threshold is exceeded, the master node and each replica node broadcast a confirmation message of the second transaction consensus message to other nodes except themselves; determines the consensus verification result of the transaction request by the master node and the M-1 replica nodes according to the number of confirmation messages that have passed the verification received by the master node and each replica node.

2. The method according to claim 1, wherein: Determining the node credit level corresponding to each node in the N nodes includes: Determine the credit value corresponding to each node by means of encrypted lottery; Obtaining a node credit rating classification rule, wherein the node credit rating classification rule includes P node credit ratings from high to low credit ratings and a preset credit threshold interval corresponding to each node credit rating; Based on the credit value corresponding to each node and the node credit grade classification rule, the node credit grade corresponding to each node is determined.

3. The method according to claim 2, wherein: The preset election strategy includes a priority election strategy and a master node election strategy. The selecting of a master node from the consensus node candidate set based on the preset election strategy includes: Based on the priority election strategy, detecting whether there is a node among the nodes with the highest node credit level; If so, based on the master node election strategy, detect whether a master node is selected from the nodes with the highest credit level; If no node can be selected, based on the priority election strategy, check whether there is a node among the nodes with the next highest node credit level; If so, based on the master node election strategy, it is detected whether a master node is selected from the nodes with the next higher credit level until the master node is selected.

4. The method according to claim 3, wherein: The master node election strategies include: a heartbeat detection success strategy, a strategy with the largest view number, and a strategy with the largest serial number.

5. The method according to claim 2, wherein: The method further comprises: In response to detecting that a new node joins the blockchain, setting an initial credit value for the new node, wherein the node credit level corresponding to the initial credit value is an intermediate level between a highest level and a lowest level; According to the consensus verification result of the new node participating in the consensus verification, the initial credit value is adjusted to determine the credit value corresponding to the new node.

6. The method according to claim 1, wherein: The method further comprises: When the self-certification message of the master node fails to pass the verification, the master node and M-1 replica nodes are re-selected from the N nodes.

7. The method according to claim 1, wherein: Determining the consensus verification result of the transaction request by the master node and the M-1 replica nodes according to the number of verification-passing confirmation messages received by the master node and each replica node includes: Determine whether the number of verification-passed confirmation messages received by the master node and each of the replica nodes exceeds the first preset threshold; In the case where the first preset threshold is exceeded, the master node and each of the replica nodes return a response message of the transaction request to the client; When the number of response messages of the transaction request received by the client exceeds a second preset threshold, the consensus verification result of the transaction request is confirmed as consensus verification passed, wherein the second preset threshold is less than the first preset threshold.

8. The method according to claim 7, wherein: The method further comprises: When the number of response messages of the transaction request received by the client does not exceed the second preset threshold, it is confirmed that the consensus verification result of the transaction request is that the consensus verification fails.

9. A transaction processing device applied to a blockchain, wherein: The blockchain includes N nodes, where N is a positive integer, and the device includes: A first determination module, configured to determine, in response to a transaction request initiated by a client, a node credit rating corresponding to each of the N nodes; The first selection module is used to select a master node and M-1 replica nodes from the N nodes based on the node credit level corresponding to each node and a preset election strategy, M <N; A verification module, configured to, in response to the master node receiving the transaction request, send a response message of the transaction request to the client to obtain a verification result of the master node, wherein the response message at least includes a self-certification message of the master node, and the self-certification message is used to verify whether the master node is a malicious node; A second determination module is used to determine the consensus verification result of the transaction request by the master node and the M-1 replica nodes when the self-certification message of the master node passes the verification, so as to feed back the processing result of the transaction request to the client; The first selection module includes: a screening submodule, for filtering out nodes with the lowest node credit level from the N nodes based on the node credit level corresponding to each node, so as to screen out a consensus node candidate set, wherein the consensus node candidate set includes M nodes, and the M nodes participate in the consensus verification of the transaction request; a first selection submodule, for selecting a master node from the consensus node candidate set based on the preset election strategy; and a first determination submodule, for determining M-1 nodes in the consensus node candidate set except the master node as the M-1 replica nodes; The second determination module includes: a first broadcast submodule, for the master node to generate a first transaction consensus message based on the transaction request, and broadcast the first transaction consensus message to the M-1 replica nodes; a second broadcast submodule, for each of the M-1 replica nodes to add self-certification information to the first transaction consensus message to generate a second transaction consensus message, and broadcast the second transaction consensus message to other nodes except itself; a fifth determination submodule, for determining whether the number of the second transaction consensus messages that have been verified and received by the master node and each replica node exceeds a first preset threshold; a third broadcast submodule, for the master node and each replica node to broadcast a confirmation message of the second transaction consensus message to other nodes except themselves when the first preset threshold is exceeded; and a sixth determination submodule, for determining the consensus verification result of the master node and the M-1 replica nodes on the transaction request according to the number of the confirmation messages that have been verified and received by the master node and each replica node.

10. An electronic device comprising: one or more processors; as well as a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors are caused to perform the method according to any one of claims 1 to 8.

11. A computer-readable storage medium storing computer-executable instructions, which, when executed, cause a processor to perform the method according to any one of claims 1 to 8.

12. A computer program product, comprising a computer program, which, when executed by a processor, performs the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Verifiable random number generation method and device

    CN111600709A

  • Byzantine fault-tolerant alliance chain consensus method and system for power consumption information protection and storage medium

    CN111612455A