Distributed consensus method based on block chain and related equipment thereof

By introducing the grouping mechanism of standing and alternate consensus nodes into the blockchain, efficient consensus of the blockchain is achieved, which solves the problem of high communication complexity of the PBFT algorithm when the number of nodes increases, and improves consensus efficiency.

CN118802946AActive Publication Date: 2024-10-18CHINA MOBILE FINANCIAL TECHNOLOGY CO LTD +1
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202410465905.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-17
Publication Date
2024-10-18
Estimated Expiration
2044-04-17

AI Technical Summary

Technical Problem

When the number of nodes increases, the PBFT consensus algorithm has high communication complexity, resulting in low consensus efficiency.

Method used

Adopting a distributed consensus method based on the blockchain, through the grouping of standing consensus nodes and alternate consensus nodes, a 'small consensus' between all standing nodes is achieved, and then the block information is pushed to the alternate consensus nodes for one-time confirmation, completing The 'big consensus' of the entire chain reduces communication complexity.

Benefits of technology

It improves the consensus efficiency in multi-alliance node scenarios, reduces communication overhead, and improves the overall performance of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118802946A_ABST
    Figure CN118802946A_ABST
Patent Text Reader

Abstract

The invention discloses a distributed consensus method based on a block chain and related equipment thereof, relates to the technical field of block chains, and is applied to the block chain, the block chain comprises a common affair consensus node and a candidate consensus node, and the method comprises the following steps: the common affair consensus node receives a construction request sent by a service end or the candidate consensus node, generating a block proposal based on the construction request; the common affair consensus node sends the block proposal to other common affair consensus nodes, and generates block information according to confirmation messages sent by other common affair consensus nodes; wherein the confirmation message is obtained by confirming the block proposal by the other common affair consensus nodes; and after the common affair consensus node sends block information to the candidate consensus node, the candidate knowledge node receives and confirms the block information to obtain a consensus result. According to the invention, the consensus efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and in particular to a distributed consensus method based on blockchain and related equipment. Background Art

[0002] PBFT (Practical Byzantine Fault Tolerance) is an algorithm designed to solve the problem of how nodes in a distributed system reach consensus on a message or transaction. It is particularly suitable for consortium chain environments, where the number of nodes participating in the consensus is known and limited, and they are usually trusted to some extent. PBFT can tolerate Byzantine faults, that is, some nodes have any erroneous behavior (including failure, malicious behavior, etc.), but still ensure the consistency of the system.

[0003] However, a major limitation of the PBFT consensus algorithm is its high communication complexity. At each consensus stage, messages need to be broadcast among all nodes, so the overall communication complexity is O(n^2), where n represents the total number of nodes participating in the consensus. As the number of nodes increases, this communication overhead will grow rapidly, resulting in low consensus efficiency. Summary of the invention

[0004] The main purpose of this application is to provide a distributed consensus method based on blockchain and related equipment, aiming to solve the problem of low consensus efficiency.

[0005] To achieve the above purpose, the present application provides a distributed consensus method based on blockchain, which is applied to blockchain. The blockchain includes a standing consensus node and a candidate consensus node. The distributed consensus method based on blockchain includes the following steps:

[0006] The executive consensus node receives a construction request from the business end or the candidate consensus node, and generates a block proposal based on the construction request;

[0007] The standing consensus node sends the block proposal to other standing consensus nodes, and generates block information according to confirmation messages sent by the other standing consensus nodes; wherein the confirmation message is obtained by the other standing consensus nodes confirming the block proposal;

[0008] After the standing consensus node sends block information to the candidate consensus node, the candidate knowledge node receives and confirms the block information to obtain a consensus result.

[0009] Optionally, the blockchain includes a plurality of nodes, and after the standing consensus node sends the block information to the candidate consensus node, the candidate knowledge node receives and confirms the block information, and the step of obtaining the consensus result includes:

[0010] The node obtains node information of other nodes;

[0011] The node determines the malicious node in the blockchain through a smart contract according to the node information;

[0012] After the node sends a shielding instruction to the other nodes, the other nodes shield the malicious node.

[0013] Optionally, after the node issues a blocking instruction to the other nodes, the other nodes block the malicious node, including:

[0014] The node obtains the pre-selected node information of the other nodes that are not shielded; wherein the pre-selected node information includes the communication speed between the other nodes and the associated pre-selected nodes;

[0015] The node updates the standing consensus node group according to the communication speed; wherein the standing consensus node group includes all standing consensus nodes.

[0016] Optionally, the blockchain includes a plurality of nodes, and before the step of the standing consensus node receiving a construction request issued by the business end or the candidate consensus node and generating a block proposal based on the construction request, the step includes:

[0017] The node obtains the number of nodes in the blockchain, and calculates the number of groups according to the number of nodes;

[0018] The node determines a standing consensus node group and at least one candidate consensus node group based on the number of groups.

[0019] Optionally, the step of determining, by the node, a standing consensus node group and at least one candidate consensus node group based on the number of groups includes:

[0020] The node receives a test instruction and a reply message sent by other nodes based on the test instruction, and records the time interval between the test instruction and the reply message;

[0021] The node exchanges the time interval with the other nodes, and determines a standing consensus node group and at least one candidate consensus node group according to the time interval.

[0022] Optionally, after the standing consensus node sends the block information to the candidate consensus node, the candidate knowledge node receives and confirms the block information, and before the step of obtaining the consensus result includes:

[0023] The standing consensus node determines the communication duration with each of the candidate consensus nodes, and exchanges the communication duration with the other standing consensus nodes;

[0024] The standing consensus node determines a target candidate consensus node according to the communication duration;

[0025] The standing consensus node sends the block information to the target candidate consensus node so that the target candidate consensus node can confirm the block information.

[0026] In addition, to achieve the above purpose, the present application also provides a distributed consensus device based on blockchain, and the distributed consensus device based on blockchain includes:

[0027] A receiving module, configured for the executive consensus node to receive a construction request from the business end or the candidate consensus node, and to generate a block proposal based on the construction request;

[0028] A small consensus module, which is used for the standing consensus node to send the block proposal to other standing consensus nodes, and generate block information according to the confirmation message sent by the other standing consensus nodes; wherein the confirmation message is obtained by the other standing consensus nodes confirming the block proposal;

[0029] The big consensus module is used for obtaining a consensus result after the standing consensus node sends block information to the candidate consensus node and the candidate knowledge node receives and confirms the block information.

[0030] In addition, to achieve the above-mentioned purpose, the present application also provides a blockchain-based distributed consensus device, which includes: a memory, a processor, and a blockchain-based distributed consensus program stored on the memory and executable on the processor, and the blockchain-based distributed consensus program is configured to implement the steps of the blockchain-based distributed consensus method.

[0031] In addition, to achieve the above-mentioned purpose, the present application also provides a storage medium, on which a distributed consensus program based on blockchain is stored. When the distributed consensus program based on blockchain is executed by a processor, the steps of the distributed consensus method based on blockchain are implemented.

[0032] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a distributed consensus program based on blockchain, and when the distributed consensus program based on blockchain is executed by a processor, it implements the steps of the distributed consensus method based on blockchain.

[0033] The present application provides a distributed consensus method based on blockchain and related equipment. A major limitation of the PBFT consensus algorithm in the related art is that its communication complexity is high. In each consensus stage, the message needs to be broadcast between all nodes, so the overall communication complexity is O(n^2), where n represents the total number of nodes participating in the consensus. As the number of nodes increases, this communication overhead will grow rapidly, resulting in a lower consensus efficiency. In this application, it is applied to a blockchain, and the blockchain includes a standing consensus node and a standby consensus node. The standing consensus node receives a build request issued by a business end or the standby consensus node, and generates a block proposal based on the build request; the standing consensus node sends the block proposal to other standing consensus nodes, and generates block information according to the confirmation message issued by the other standing consensus nodes; wherein the confirmation message is obtained by the other standing consensus nodes confirming the block proposal; after the standing consensus node sends the block information to the standby consensus node, the standby knowledge node receives and confirms the block information to obtain a consensus result. It can be understood that in the present application, when the consensus algorithm is running, the standing consensus node generates a block proposal based on the construction request issued by the business end or the candidate consensus node, and realizes the "small consensus" among all standing nodes, and then pushes the block information to multiple candidate consensus nodes. The candidate consensus nodes can complete the "big consensus" of the entire chain by confirming the consensus result once through communication. By expanding the process from the preliminary consensus reached by the local node set to the final consensus reached by the entire network, the complexity of communication in the multi-alliance node scenario is reduced, thereby reducing the communication overhead and improving the consensus efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 This is a first flow chart of the first embodiment of the distributed consensus method based on blockchain of this application;

[0035] Figure 2 This is a schematic diagram of the first scenario of the first embodiment of the distributed consensus method based on blockchain in this application;

[0036] Figure 3 This is a schematic diagram of the second scenario of the first embodiment of the distributed consensus method based on blockchain of this application;

[0037] Figure 4 This is a second flow chart of the second embodiment of the distributed consensus method based on blockchain of the present application;

[0038] Figure 5 This is a schematic diagram of the third scenario of the second embodiment of the distributed consensus method based on blockchain of this application;

[0039] Figure 6 This is a third flow chart of the third embodiment of the distributed consensus method based on blockchain of the present application;

[0040] Figure 7 This is a schematic diagram of the fourth scenario of the third embodiment of the distributed consensus method based on blockchain of this application;

[0041] Figure 8 This is a structural block diagram of the distributed consensus device based on blockchain in this application;

[0042] Fig. 9 This is a schematic diagram of the structure of the hardware operating environment involved in the embodiment of the present application.

[0043] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0044] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0045] Reference Figure 1 , Figure 1 This is a first flow chart of the first embodiment of the distributed consensus method based on blockchain in this application.

[0046] In a first embodiment, applied to a blockchain, the blockchain includes a standing consensus node and a candidate consensus node, and the distributed consensus method based on the blockchain includes the following steps:

[0047] Step S10, the standing consensus node receives a construction request from the business end or the candidate consensus node, and generates a block proposal based on the construction request;

[0048] Step S20, the standing consensus node sends the block proposal to other standing consensus nodes, and generates block information according to confirmation messages sent by the other standing consensus nodes; wherein the confirmation message is obtained by the other standing consensus nodes confirming the block proposal;

[0049] Step S30: After the standing consensus node sends block information to the candidate consensus node, the candidate knowledge node receives and confirms the block information to obtain a consensus result.

[0050] The purpose of this embodiment is: when the consensus algorithm is running, the standing consensus node generates a block proposal based on the construction request issued by the business end or the candidate consensus node, and realizes the "small consensus" among all standing nodes through the improved PBFT algorithm, and then pushes the block information to multiple candidate consensus nodes. The candidate consensus nodes can complete the "big consensus" of the whole chain by confirming the consensus result in one communication. By expanding the process from the preliminary consensus reached by the local node set to the final consensus reached by the entire network, the complexity of communication in the multi-alliance node scenario is reduced, thereby reducing the communication overhead and improving the consensus efficiency.

[0051] The specific steps are described below:

[0052] Step S10, the standing consensus node receives a construction request from the business end or the candidate consensus node, and generates a block proposal based on the construction request;

[0053] It should be noted that the executor of this embodiment is a distributed consensus device based on blockchain, and the distributed consensus device based on blockchain may be subordinate to the blockchain. The blockchain includes a standing consensus node and a standby consensus node, and the blockchain may be subordinate to a distributed consensus device based on blockchain.

[0054] It should be noted that blockchain is a distributed database technology, also known as distributed ledger technology, which ensures the security, integrity and immutability of data through decentralization, openness, transparency and collective maintenance.

[0055] It should be noted that the standing consensus node refers to a node that is more active in the consensus mechanism and is qualified to generate new blocks. After receiving a build request, the standing consensus node will convert the request into a preliminary block proposal based on preset rules and protocols. This proposal contains transactions to be confirmed and other relevant information.

[0056] It should be noted that the candidate consensus node refers to a node that does not directly participate in block generation but plays an auxiliary or backup role. The candidate consensus node will follow the network communication protocol and forward the received build request to the known standing consensus node in a timely manner. Even if the business end does not directly interact with the standing consensus node, its transaction request can be passed to the correct processing path through the candidate node, thereby participating in the consensus process of the entire blockchain network.

[0057] It should be noted that PBFT (Practical Byzantine Fault Tolerance), also known as the Practical Byzantine Fault Tolerance algorithm, is a consensus protocol that ensures data consistency in a distributed system. Its main process includes: Phase 1, the client submits a new transaction or request to the master node in the current view. Phase 2, after receiving the client request, the master node assigns it a globally unique sequence number and constructs a "prepare" message, which includes the content of the request and the sequence number; the master node broadcasts this pre-prepare message to all slave nodes. Phase 3, after receiving the pre-prepare message, the slave node checks the correctness of the message and the validity of the sequence number; if the slave node verifies that it is correct, it agrees with the master node's proposal and sends a "prepare" message to all other nodes (including the master node and other slave nodes); when a slave node collects a sufficient number (usually 2f, where f is the number of Byzantine fault nodes that the system can tolerate) of prepare messages with the same sequence number from different nodes, it considers that the request has reached the "prepared" state and holds the corresponding prepared authentication certificate. Phase 4: Once the slave node enters the prepared state, it will further send a "commit" type message to all nodes in the network, indicating that it has confirmed and committed to executing the request; if a node receives 2f+1 commit messages for the same request (which means at least f+1 confirmations from non-Byzantine nodes), then it can determine that the request has been accepted by the majority of nodes and enters the "committed" state. Phase 5: When the node's request state becomes committed, it will execute the requested operation locally (for example, process transactions and update its local ledger); after execution, the node will generate a response result and send it back to the client as a "reply" message.

[0058] In this embodiment, the distributed consensus device based on blockchain performs full-chain consensus of blockchain based on the improved PBFT algorithm, and its main process includes: Phase 1, the client initiates a construction request, marks the block as "pre-pre" state, and then broadcasts it to all standing consensus nodes. Phase 2, after receiving the request, the standing consensus node checks whether there is a duplicate request, and discards it if there is; the standing consensus node verifies the block number to ensure that it complies with the expected sorting rules and has not been pre-authenticated; the validity of the block content is verified and executed through business logic. When the block is legal and executed correctly, it is placed in the Prepare queue and changed to "prepare" state, and then broadcast to the entire network. Phase 3, the receiving node performs the same strict verification on the block number again; if the number is valid, the node updates the block state to "commit" and broadcasts the change to other standing consensus nodes. In stage 4, when a standing consensus node collects more than the legal number of commit confirmations (i.e., 2f+1, where f is the maximum number of tolerable faulty nodes), it will determine that the block has been agreed upon in the network and set the block to the "committed" state; the node will then write the block metadata to the blockchain and archive the complete block content to the local relational database. In stage 5, the message of the new block generation will be broadcast to all standing consensus nodes; when each node receives the notification of the new block generation, it will check whether the local block has been processed, and if it has not been processed, it will continue with the subsequent operation; the node will write the metadata of the new block to the blockchain and store the block content in the local database. In stage 6, after consensus is reached among the standing consensus nodes, the selected block will be set to the "commit-all" state and broadcast to the candidate consensus nodes in the entire network; after receiving the message, each candidate consensus node will write the local data and reply to the message whether the write is successful. If not, the local retry will reply after success.

[0059] It can be understood that the business end initiates a build request to any node in the blockchain. If the business end sends the build request to the standing consensus node, the standing consensus node generates a block proposal based on the build request; if the business end sends the build request to the candidate consensus node, the candidate consensus node forwards the build request to the known standing consensus node.

[0060] In the specific implementation, the candidate consensus node selects the standing consensus node that communicates the fastest with the current candidate consensus node based on the historically published data synchronization performance with the standing consensus node, and forwards the build request to the standing consensus node that communicates the fastest with the current candidate consensus node. After the candidate consensus node receives the confirmation data returned by the standing consensus node, it calculates the time taken to send and receive the data, and updates the data synchronization performance with the standing consensus node.

[0061] It is understandable that the business end initiates a build request, sets the block status to the pre-prepare status, and then broadcasts it to all standing consensus nodes.

[0062] It is understandable that after receiving a build request, the standing consensus node checks whether it is a duplicate request, and if so, discards it; if the received build request is not a duplicate request, the standing consensus node verifies the block number according to specific rules (such as block height or timestamp), and does not process the request if the verification fails; if the verification succeeds, the standing consensus node performs pre-generation of the block proposal based on the build request, and if the execution is valid, the block is added to the Prepare queue and the block status is changed to prepare.

[0063] In the specific implementation, the way in which the standing consensus node verifies the block number according to specific rules includes: traversing all voting information in the block status stage, if the block corresponding to the hash has been voted, the number verification fails; if the block number to be voted is smaller than the current block number, the number verification fails.

[0064] Step S20, the standing consensus node sends the block proposal to other standing consensus nodes, and generates block information according to confirmation messages sent by the other standing consensus nodes; wherein the confirmation message is obtained by the other standing consensus nodes confirming the block proposal;

[0065] It can be understood that the standing consensus node sends a block proposal to other standing consensus nodes. After receiving the block proposal, other standing consensus nodes perform number verification. If the number is valid, the block status is updated to commit, and a confirmation message is sent to all standing consensus nodes in the standing consensus node group.

[0066] In the specific implementation, the standing consensus node counts the confirmation messages received. When it receives confirmation messages from more than 2f+1 different nodes (including itself), the standing consensus node believes that the block proposal has been agreed upon by the entire network, enters the committed state, writes the block information into the blockchain, and saves the entire content of the block in the local relational database.

[0067] In the specific implementation, the standing consensus node broadcasts the generated new block to the standing consensus node group. After other standing consensus nodes receive the message that the new block has been generated, they check whether the block has been generated locally. If it has been generated, the message is ignored; if it has not been generated, the metadata information of the block is written into the blockchain and the entire content of the block is saved in the local relational database.

[0068] Step S30: After the standing consensus node sends block information to the candidate consensus node, the candidate knowledge node receives and confirms the block information to obtain a consensus result.

[0069] It is understandable that the standing consensus node sets the consensus block to the full-chain consensus state, sets the block state to the commit-all state, and broadcasts it to the candidate consensus nodes in the entire network.

[0070] In the specific implementation, the standing consensus node determines the communication duration between itself and each candidate consensus node, exchanges the communication duration with other standing consensus nodes, and then determines the target candidate consensus node based on the global ranking of the communication duration. The standing consensus node sends the block information to the candidate consensus node.

[0071] In the specific implementation, after receiving the block information, each candidate consensus node writes the local data and replies whether the block information is written successfully. If unsuccessful, the local retry will reply after success, thereby further reducing a round of communication process with the candidate consensus nodes.

[0072] Specifically, before step S30, steps t1-t3 are also included:

[0073] Step t1, the standing consensus node determines the communication duration with each of the candidate consensus nodes, and exchanges the communication duration with the other standing consensus nodes;

[0074] In the specific implementation, the executive consensus node obtains the top M candidate consensus nodes with the shortest communication time and several candidate consensus nodes with relatively long communication time according to the smart contract. The executive consensus node packages the top M candidate consensus nodes, several candidate consensus nodes with relatively long communication time and the communication time into a block and sends it to other executive consensus nodes.

[0075] Step t2, the standing consensus node determines the target candidate consensus node according to the communication duration;

[0076] In the specific implementation, the standing consensus node performs two rounds of sorting operations based on the candidate consensus nodes: in the first round, for each candidate consensus node, the communication time with different standing consensus nodes is sorted from short to long; in the second round, the shortest total communication time of the candidate consensus nodes is sorted.

[0077] For example, refer to Figure 2After the first round of sorting, for candidate node 1, the sorting from short to long according to the communication duration is: standing consensus node 1, standing consensus node 2 and standing consensus node 3; for candidate node 2, the sorting from short to long according to the communication duration is: standing consensus node 1, standing consensus node 2 and standing consensus node 3; for candidate node 3, the sorting from short to long according to the communication duration is: standing consensus node 1, standing consensus node 2 and standing consensus node 3.

[0078] For example, refer to Figure 3 After the second round of sorting, the ranking of the shortest communication time of the candidate consensus nodes is: candidate node 3 (1.1+2.1+3.1=6.3 seconds), candidate node 2 (1.2+2.2+2.3=6.6 seconds) and candidate node 1 (1.3+2.3+3.3=6.9 seconds).

[0079] In the specific implementation, each candidate consensus node selects the standing consensus node with which it can communicate the fastest. The standing consensus node calculates the number of candidate consensus nodes currently corresponding to the node. If each number is M, the currently corresponding candidate consensus node is determined as the target candidate consensus node.

[0080] In a specific implementation, if the number of candidate consensus nodes currently corresponding to this node is less than M, the standing consensus node will list this node in the table List; if the number of candidate consensus nodes currently corresponding to this node is greater than M, the standing consensus node will select the fastest M candidate consensus nodes, and list the candidate consensus nodes exceeding M in the table List; the standing consensus node will compare the second or third fastest standing consensus node of the candidate consensus node with the List, and change the mapping relationship sent to the suboptimal fastest standing consensus node currently found.

[0081] Step t3, the standing consensus node sends the block information to the target candidate consensus node, so that the target candidate consensus node confirms the block information.

[0082] In the specific implementation, the executive consensus node sends the block information to the target candidate consensus node, and the target candidate consensus node confirms the block information.

[0083] In this embodiment, a major limitation of the PBFT consensus algorithm in the related art is that its communication complexity is high. In each consensus stage, messages need to be broadcast between all nodes, so the overall communication complexity is O(n^2), where n represents the total number of nodes participating in the consensus. As the number of nodes increases, this communication overhead will grow rapidly, resulting in lower consensus efficiency. In this embodiment, it is applied to the blockchain, and the blockchain includes a standing consensus node and a standby consensus node. The standing consensus node receives a build request issued by the business end or the standby consensus node, and generates a block proposal based on the build request; the standing consensus node sends the block proposal to other standing consensus nodes, and generates block information according to the confirmation message issued by the other standing consensus nodes; wherein the confirmation message is obtained by the other standing consensus nodes confirming the block proposal; after the standing consensus node sends the block information to the standby consensus node, the standby knowledge node receives and confirms the block information to obtain a consensus result. That is, in this embodiment, when the consensus algorithm is running, the standing consensus node generates a block proposal based on the construction request issued by the business end or the candidate consensus node, and realizes the "small consensus" among all standing nodes through the improved PBFT algorithm, and then pushes the block information to multiple candidate consensus nodes. The candidate consensus nodes can complete the "big consensus" of the entire chain by confirming the consensus result in one communication. By expanding the process from the preliminary consensus reached by the local node set to the final consensus reached by the entire network, the complexity of communication in the multi-alliance node scenario is reduced, thereby reducing communication overhead and improving consensus efficiency.

[0084] Further, refer to Figure 4 Based on the above embodiment, a second embodiment of the present application is provided. In this embodiment, the blockchain includes multiple nodes. After step S30, the following steps are further included:

[0085] Step A10, the node obtains node information of other nodes;

[0086] In the specific implementation, the nodes in the blockchain use the interface of the alliance chain management node service in the data zone, which will return the legitimate alliance chain node information for verification.

[0087] Step A20, the node determines the malicious node in the blockchain through a smart contract according to the node information;

[0088] It should be noted that the smart contract includes a contract metadata area, a contract data area, a contract area and a contract data verification area.

[0089] In the specific implementation, refer to Figure 5The contract metadata area (ContractMetaData) includes the contract number (string field type, field name contract_num), contract name (string field type, field name contract_name), contract version (string field type, field name contract_version) and contract triggering method (integer field type, field name contract_runway).

[0090] In specific implementation, there are many ways to trigger a contract, including but not limited to time-based (real-time triggering and timed triggering) and data volume-based. In the time-based method, when triggered in real time, contract_runway = 0; when triggered on a timed basis, the trigger time is written in the form of an integer string, such as 2023-04-1010:00:00 can be written as 20230410100000, that is, contract_runway = 20230410100000. In the data volume method, the contract is triggered according to the number of data that meet the triggering conditions.

[0091] In the specific implementation, refer to Figure 5 The contract data area (ContractData) includes the alliance management node service interface and the malicious node identification rules. The interface is used for smart contracts to query the number of nodes and IP information. The interface and rules together provide data support for identifying malicious nodes. The contract area (Contract) includes a group calculation function, which is used to calculate how many groups the nodes of the current alliance chain can be divided into; the contract area (Contract) also includes an alliance node classification and grouping function, which is used to classify and group alliance chain nodes into standing consensus nodes and candidate consensus nodes; the contract area (Contract) also includes a malicious node identification function, which is used to identify malicious nodes. The contract data verification area (ContractVerifyData) includes metadata verification, data area verification, and contract area verification, so as to verify the integrity and authenticity of data in the blockchain.

[0092] In the specific implementation, the verified data is calculated based on the MD5 value of the JSON of each group of data. Taking the generation of data verification data in the metadata area as an example: Step 1, organize the contract number, contract name, contract version and contract trigger method and their corresponding values ​​into JSON format; Step 2, generate the contract metadata verification metaVerify according to the MD5 algorithm from the JSON in step 1, that is, the contract metadata verification metaVerify = MD5 (JSON). When the contract needs to be generated, fill in the value of the corresponding field according to the data structure of the above contract to complete the assembly of the smart contract data, and then the contract is published on the chain and enters the alliance chain for consensus and localized storage of contracts at each node.

[0093] It is understandable that in order to avoid interference from a small number of malicious nodes in the standing consensus nodes, the number of consensus nodes is required to be no less than 2 / 3 of the number of standing consensus nodes during the standing consensus node consensus period.

[0094] In this embodiment, the nodes in the blockchain determine the malicious nodes in other standing consensus nodes and candidate consensus nodes based on the node information through the malicious node identification function in the smart contract. There are three situations where malicious nodes exist: all or most of the malicious nodes are in the standing consensus nodes; a small part of the malicious nodes are in the standing consensus nodes; the malicious nodes are not in the standing consensus nodes.

[0095] Step A30: After the node sends a shielding instruction to the other nodes, the other nodes shield the malicious node.

[0096] In the specific implementation, the malicious nodes identified by the nodes in the blockchain will be broadcast throughout the chain by the smart contract, and each node will receive the malicious nodes calculated by the smart contracts of other nodes (including the alliance chain management node service); then the whole chain will reach a consensus on the malicious node information and block the malicious node (that is, it will not be allowed to communicate, such as in the standing consensus node, it will be removed from the standing consensus node record).

[0097] In a specific implementation, the nodes in the blockchain obtain the pre-selected node information of other unshielded nodes, and update the standing consensus node group according to the communication speed between other nodes and the associated pre-selected nodes in the pre-selected node information.

[0098] Specifically, after step A30, steps A31-A32 are also included:

[0099] Step A31, the node obtains the pre-selected node information of the other nodes that are not shielded; wherein the pre-selected node information includes the communication speed between the other nodes and the associated pre-selected nodes;

[0100] In the specific implementation, when the malicious node is broadcast to each node of the alliance chain, the standing consensus node is dynamically adjusted, that is, the node in the blockchain sends the top N / M node information obtained by the node statistics to other nodes. After each node receives the top N / M data pushed by other nodes, it can calculate the global top N / M nodes.

[0101] In the specific implementation, the nodes in the blockchain continuously calculate the communication speed of the previous N / M node information based on the time each node sends to this node during the operation of the consensus algorithm.

[0102] Step A32, the node updates the standing consensus node group according to the communication speed; wherein the standing consensus node group includes all standing consensus nodes.

[0103] In the specific implementation, the nodes in the blockchain reach consensus on the calculated global top N / M nodes to obtain the initialized standing consensus node, and each node records it in its own node.

[0104] In this embodiment, compared with the PBFT in the related art, if the master node is a malicious node (Byzantine node), it may send inconsistent messages to different slave nodes in an attempt to destroy the consensus. Although PBFT has designed a certain fault-tolerant mechanism to deal with this situation, if the master node completely controls more than f slave nodes (that is, when the total number of nodes is 3f+1, at most f Byzantine nodes can be tolerated), the system may be attacked and unable to reach a correct consensus. In this embodiment, the node obtains the node information of other nodes; the node determines the malicious node in the blockchain through a smart contract based on the node information; after the node sends a shielding instruction to the other node, the other node shields the malicious node. That is, in this embodiment, the node in the blockchain obtains the node information of other nodes, and determines the malicious node through a smart contract. Other nodes shield the malicious node based on the received shielding instruction, and identify the malicious nodes in the alliance chain through monitoring so as to eliminate them in time to ensure the healthy, stable and orderly operation of the alliance chain.

[0105] Further, refer to Figure 6 Based on the above embodiment, a third embodiment of the present application is provided. In this embodiment, the blockchain includes multiple nodes, and the distributed consensus method based on the blockchain further includes the following steps:

[0106] Step B10, the node obtains the number of nodes in the blockchain, and calculates the number of groups according to the number of nodes;

[0107] In a specific implementation, the node obtains the number N of nodes in the current alliance chain, and calculates the number M of groups according to the number of nodes:

[0108] Step B20: The node determines a standing consensus node group and at least one candidate consensus node group based on the number of groups.

[0109] In a specific implementation, the node divides N / M nodes into the standing consensus node group, and the others are standby consensus nodes.

[0110] For example, refer to Figure 7 Group 1 includes standing node 1, standing node 2 and standing node N / M, group 2 includes candidate node 1, candidate node 2 and candidate node N / M, and group M includes candidate node 1, candidate node 2 and candidate node N / M.

[0111] In a specific implementation, the node receives a test instruction and a reply message sent by other nodes based on the test instruction, and records the time interval between the test instruction and the reply message; the node exchanges time intervals with other nodes, and determines a standing consensus node group and at least one standby consensus node group based on the time interval.

[0112] Specifically, the step B20 further includes steps B21-B22:

[0113] Step B21, the node receives the test instruction and the reply message sent by other nodes based on the test instruction, and records the time interval between the test instruction and the reply message;

[0114] In the specific implementation, one of the nodes in the blockchain sends a test message to all nodes based on the smart contract, and then starts timing to count the time it takes for each node to reply to the message and it arrives at this node.

[0115] Step B22: the node exchanges the time interval with the other nodes, and determines a standing consensus node group and at least one standby consensus node group according to the time interval.

[0116] In a specific implementation, the node receives the information of the first N / M+1 nodes and can obtain the first N / M with the fastest communication speed and not its own (the 1 in +1 is the node's voice) at the local node; the smart contract of each node sends the first N / M node information obtained by statistics of the local node to other nodes; after each node receives the first N / M data pushed by other nodes, it can calculate the global first N / M nodes; then each node reaches a consensus on the calculated global first N / M nodes to obtain the initialized standing consensus node, and each node records it in its own node.

[0117] In this embodiment, when the master node fails or the network partition causes the master node to fail to work properly, the system must perform a view change process to re-elect a new master node. In this process, the PBFT consensus will temporarily stop processing client requests until a new master node is elected and the consensus process is resumed. This means that during the election of the master, the availability and efficiency of the system will be affected. In this embodiment, the node obtains the number of nodes in the blockchain and calculates the number of groups based on the number of nodes; the node determines a standing consensus node group and at least one alternate consensus node group based on the number of groups. That is, in this embodiment, the number of groups is calculated based on the number of nodes in the blockchain, and a standing consensus node group and at least one alternate consensus node group are determined. The algorithm has no master node, and the status of each node in the alliance chain is equal, which avoids the situation where the master node fails or the network partition causes the master node to fail to work properly, thereby improving the availability and efficiency of the system.

[0118] In addition, the present application also proposes a distributed consensus device based on blockchain, referring to Figure 8 , the distributed consensus device based on blockchain includes:

[0119] The receiving module 10 is used for the standing consensus node to receive a construction request sent by the business end or the candidate consensus node, and to generate a block proposal based on the construction request;

[0120] Small consensus module 20, used for the standing consensus node to send the block proposal to other standing consensus nodes, and generate block information according to the confirmation message sent by the other standing consensus nodes; wherein the confirmation message is obtained by the other standing consensus nodes confirming the block proposal;

[0121] The large consensus module 30 is used for obtaining a consensus result after the standing consensus node sends block information to the candidate consensus node and the candidate knowledge node receives and confirms the block information.

[0122] In this embodiment, it is applied to a blockchain, and the blockchain includes a standing consensus node and a candidate consensus node. The standing consensus node receives a build request from a business terminal or the candidate consensus node, and generates a block proposal based on the build request; the standing consensus node sends the block proposal to other standing consensus nodes, and generates block information according to a confirmation message sent by the other standing consensus nodes; wherein the confirmation message is obtained by the other standing consensus nodes confirming the block proposal; after the standing consensus node sends the block information to the candidate consensus node, the candidate knowledge node receives and confirms the block information to obtain a consensus result. That is, in this embodiment, when the consensus algorithm is running, the standing consensus node generates a block proposal based on the construction request issued by the business end or the candidate consensus node, and realizes the "small consensus" among all standing nodes through the improved PBFT algorithm, and then pushes the block information to multiple candidate consensus nodes. The candidate consensus nodes can complete the "big consensus" of the entire chain by confirming the consensus result in one communication. By expanding the process from the preliminary consensus reached by the local node set to the final consensus reached by the entire network, the complexity of communication in the multi-alliance node scenario is reduced, thereby reducing communication overhead and improving consensus efficiency.

[0123] The specific implementation of the distributed consensus device based on blockchain in this application is basically the same as the above-mentioned embodiments of the distributed consensus method based on blockchain, and will not be repeated here.

[0124] Reference Fig. 9 , Fig. 9 This is a schematic diagram of the structure of a distributed consensus device based on blockchain in the hardware operating environment involved in the embodiment of the present application.

[0125] like Fig. 9 As shown, the distributed consensus device based on blockchain may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0126] Those skilled in the art will understand that Fig. 9 The structure shown in does not constitute a limitation on the distributed consensus device based on blockchain, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0127] like Fig. 9 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a distributed consensus program based on blockchain.

[0128] Among them, the operating system is a program for managing and controlling distributed consensus devices and software resources based on blockchain, supporting the operation of network communication modules, user interface modules, distributed consensus programs based on blockchain, and other programs or software. The network communication module is used to manage and control network interface 1004; the user interface module is used to manage and control user interface 1003.

[0129] exist Fig. 9 In the blockchain-based distributed consensus device shown, the blockchain-based distributed consensus device calls the blockchain-based distributed consensus program stored in the memory 1005 through the processor 1001 to implement the steps of any of the above-mentioned blockchain-based distributed consensus methods.

[0130] The specific implementation methods of the distributed consensus device based on blockchain in this application are basically the same as the above-mentioned embodiments of the distributed consensus method based on blockchain, and will not be repeated here.

[0131] In addition, an embodiment of the present invention also proposes a storage medium. An embodiment of the present application provides a storage medium, and the storage medium stores one or more programs. The one or more programs can also be executed by one or more processors to implement the steps of the blockchain-based distributed consensus method described in any one of the above items.

[0132] The specific implementation methods of the storage medium of the present application are basically the same as the above-mentioned embodiments of the distributed consensus method based on blockchain, and will not be repeated here.

[0133] In addition, an embodiment of the present invention also proposes a computer program product, including a distributed consensus program based on blockchain, which, when executed by a processor, implements the steps of the distributed consensus method based on blockchain as described above.

[0134] The specific implementation methods of the computer program product of the present invention are basically the same as the above-mentioned blockchain-based distributed consensus method embodiments, and will not be repeated here.

[0135] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0136] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0137] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0138] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A distributed consensus method based on blockchain, characterized in that: Applied to a blockchain, the blockchain includes a standing consensus node and a candidate consensus node, and the distributed consensus method based on the blockchain includes the following steps: The executive consensus node receives a construction request from the business end or the candidate consensus node, and generates a block proposal based on the construction request; The standing consensus node sends the block proposal to other standing consensus nodes, and generates block information according to confirmation messages sent by the other standing consensus nodes; wherein the confirmation message is obtained by the other standing consensus nodes confirming the block proposal; After the standing consensus node sends the block information to the candidate consensus node, the candidate knowledge node receives and confirms the block information to obtain a consensus result.

2. The distributed consensus method based on blockchain as claimed in claim 1, characterized in that: The blockchain includes a plurality of nodes. After the standing consensus node sends block information to the candidate consensus node, the candidate knowledge node receives and confirms the block information, and the consensus result is obtained, including: The node obtains node information of other nodes; The node determines the malicious node in the blockchain through a smart contract according to the node information; After the node sends a shielding instruction to the other nodes, the other nodes shield the malicious node.

3. The distributed consensus method based on blockchain as claimed in claim 2, characterized in that: After the node issues a shielding instruction to the other nodes, the other nodes shield the malicious node, including: The node obtains the pre-selected node information of the other nodes that are not shielded; wherein the pre-selected node information includes the communication speed between the other nodes and the associated pre-selected nodes; The node updates the standing consensus node group according to the communication speed; wherein the standing consensus node group includes all standing consensus nodes.

4. The distributed consensus method based on blockchain according to any one of claims 1 to 3, characterized in that: The blockchain includes a plurality of nodes, and before the step of the standing consensus node receiving a construction request from a business terminal or the candidate consensus node and generating a block proposal based on the construction request, the step includes: The node obtains the number of nodes in the blockchain, and calculates the number of groups according to the number of nodes; The node determines a standing consensus node group and at least one candidate consensus node group based on the number of groups.

5. The distributed consensus method based on blockchain as claimed in claim 4, characterized in that: The step of determining, by the node, a standing consensus node group and at least one candidate consensus node group based on the number of groups includes: The node receives a test instruction and a reply message sent by other nodes based on the test instruction, and records the time interval between the test instruction and the reply message; The node exchanges the time interval with the other nodes, and determines a standing consensus node group and at least one candidate consensus node group according to the time interval.

6. The distributed consensus method based on blockchain according to any one of claims 1 to 3, characterized in that: After the standing consensus node sends the block information to the candidate consensus node, the candidate knowledge node receives and confirms the block information, and before the step of obtaining the consensus result includes: The standing consensus node determines the communication duration with each of the candidate consensus nodes, and exchanges the communication duration with the other standing consensus nodes; The standing consensus node determines a target candidate consensus node according to the communication duration; The standing consensus node sends the block information to the target candidate consensus node so that the target candidate consensus node can confirm the block information.

7. A distributed consensus device based on blockchain, characterized in that: The distributed consensus device based on blockchain includes: A receiving module, configured for the executive consensus node to receive a construction request from the business end or the candidate consensus node, and to generate a block proposal based on the construction request; A small consensus module, which is used for the standing consensus node to send the block proposal to other standing consensus nodes, and generate block information according to the confirmation message sent by the other standing consensus nodes; wherein the confirmation message is obtained by the other standing consensus nodes confirming the block proposal; The big consensus module is used for obtaining a consensus result after the standing consensus node sends block information to the candidate consensus node and the candidate knowledge node receives and confirms the block information.

8. A distributed consensus device based on blockchain, characterized in that: The device includes: a memory, a processor, and a blockchain-based distributed consensus program stored in the memory and executable on the processor, wherein the blockchain-based distributed consensus program is configured to implement the steps of the blockchain-based distributed consensus method as described in any one of claims 1 to 6.

9. A storage medium, characterized in that: The storage medium stores a distributed consensus program based on blockchain, and when the distributed consensus program based on blockchain is executed by the processor, the steps of the distributed consensus method based on blockchain as described in any one of claims 1 to 6 are implemented.

10. A computer program product, characterized in that The computer program product includes a distributed consensus program based on blockchain, and when the distributed consensus program based on blockchain is executed by a processor, the steps of the distributed consensus method based on blockchain as described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Block chain data interaction method and device capable of switching consensus algorithms

    CN110365695A

  • Consensus method based on block chain system and block chain system

    CN111698094A

  • Double-layer grouping Byzantine fault-tolerant consensus method and system

    CN113642019A

  • Consensus method and block chain node

    CN114710507A

  • Low-complexity extensible Byzantine fault tolerance method and device and storage medium

    CN116112490A