Node consensus method and system

By introducing supervisory nodes into the blockchain network to oversee the consensus process, the problem of consensus forks and failures caused by the random selection of consensus nodes in a large number of nodes is solved, thereby improving the security and efficiency of consensus.

CN116232598BActive Publication Date: 2026-01-02LINGSHU TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211664644.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-23
Publication Date
2026-01-02
Estimated Expiration
2042-12-23

AI Technical Summary

Technical Problem

In large-scale blockchain networks, randomly selecting a set of consensus nodes can easily lead to problems such as consensus failure or forks, and existing technologies lack effective solutions.

Method used

Supervisory nodes are introduced to monitor the consensus process. By randomly selecting a set of supervisory nodes and a set of consensus nodes, the supervisory nodes observe whether the number of blocks meets the standard, detect the consensus content, reselect the set of consensus nodes, select the optimal blockchain, and record malicious nodes.

Benefits of technology

It avoids the problems of blockchain forks and consensus failures, and improves the security and efficiency of the consensus process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116232598B_ABST
    Figure CN116232598B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a node consensus method and system, wherein the method comprises: randomly selecting a supervision node set and a consensus node set in a total node set; using the consensus node set to perform consensus according to a consensus protocol to establish a block chain; when the number of blocks does not reach a standard within a preset time, using the supervision node set to supervise and detect the consensus content, and reselecting the consensus node set when it is confirmed that consensus cannot be performed; when the number of blocks reaches the standard within the preset time and a forked block chain appears, taking the forked block chains as the consensus content respectively, using the supervision node set to supervise and detect, selecting an optimal block chain as a final target block chain to complete block chain confirmation; when the number of blocks reaches the standard within the preset time and there is only one target block chain, taking the target block chain as the consensus content, using the supervision node set to supervise and detect the consensus content, and completing block chain confirmation. The safety and consensus efficiency of the consensus process are 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, in particular to a node consensus method and system. BACKGROUND

[0002] PBFT is a deterministic consensus protocol that can tolerate Byzantine errors and does not produce forks. In the context of consortium chain, PBFT consensus protocol is widely used, and the complexity of its network communication is n square, so it is generally used in small-scale node scenarios. When the number of nodes exceeds a certain scale, the consensus speed decreases significantly. Therefore, in the case of large-scale nodes, PBFT consensus protocol cannot be used.

[0003] An improved method is to randomly select a part of nodes from a large number of nodes to form a consensus node set to participate in consensus, for example, in a network of 1000 nodes, 7 nodes are randomly selected to form a consensus node set, and the subsequent communication required by the consensus protocol is also between the 7 nodes. In order to increase security, the consensus node set generally needs to be replaced at regular intervals, that is, a random selection algorithm is run to select a new consensus node set. In the environment of blockchain, a consensus node set is randomly selected for each block.

[0004] Although this method of dynamically and randomly selecting a consensus node set can reduce the risk of collusion of consensus nodes, there are still problems. According to the Byzantine fault-tolerant model, assuming that in a network of 1000 nodes, the number of malicious nodes does not exceed one-third, the randomly selected node set also requires that the number of malicious nodes does not exceed one-third. If 7 nodes are selected from 1000 nodes as consensus nodes, there is a probability that 2 or more malicious nodes are included in the selected 7 nodes, thereby not meeting the requirements of the Byzantine model, which will result in the consensus being unable to proceed or producing a forked consensus result.

[0005] There is currently no effective solution to the problem that the random selection of a consensus node set in the prior art can easily cause the consensus to be unable to proceed or produce a fork. SUMMARY

[0006] To solve the above problems, the present application provides a node consensus method and system, which introduces a supervision node to supervise the consensus process to ensure the security of the consensus protocol of the consensus node.

[0007] To achieve the above object, the embodiment of the present application provides a node consensus method, comprising: S1, randomly selecting a supervision node set and a consensus node set in a total node set; S2, using the consensus node set to perform consensus according to a consensus protocol to establish a block chain; S3, using the supervision node set to observe whether the number of blocks in the block chain within a preset time meets a standard, when the number of blocks within the preset time does not meet the standard, using the supervision node set to supervise and detect consensus content, and reselecting a consensus node set when it is confirmed that consensus cannot be performed; S4, when the number of blocks within the preset time meets the standard and a forked block chain appears, taking the forked block chain as consensus content respectively, using the supervision node set to supervise and detect the consensus content, selecting an optimal block chain as a final target block chain to complete block chain confirmation, and taking a consensus node causing the fork as a malicious node and recording it into a malicious node set; and S5, when the number of blocks within the preset time meets the standard and there is only one target block chain, taking the target block chain as consensus content, using the supervision node set to supervise and detect the consensus content, and completing block chain confirmation.

[0008] Further optionally, the supervision and detection of the consensus content by the supervision node set comprises: S01, randomly selecting one supervision node from the supervision node set as a leader supervision node; S02, using the leader supervision node to take consensus information of the consensus content as broadcast information and broadcast the broadcast information to other supervision nodes in the supervision node set; S03, within a preset time limit, verifying, by other supervision nodes receiving the broadcast information, whether a signature list in the broadcast information is valid, if the broadcast information is valid and does not exist in a content set corresponding to the broadcast information, adding the broadcast information to the content set, adding a signature of the supervision node to the signature list of the broadcast information to obtain latest broadcast information; wherein the content set is initially empty; S04, broadcasting, by other supervision nodes generating the latest broadcast information, the latest broadcast information to other supervision nodes not in the signature list, and repeating steps S03-S04 until a preset time threshold is reached to complete supervision and detection.

[0009] Further optionally, the selection of the optimal block chain as the final target block chain comprises: S401, comparing lengths of all forked block chains, and selecting a block chain with the longest length as the optimal block chain; and S402, when the lengths of the forked block chains are the same, selecting a block chain to which a tail block with the largest hash value belongs as the optimal block chain.

[0010] Further optionally, after the random selection of the supervision node set in the total node set, comprising: S6, reselecting the supervision node set every predetermined time interval; or S7, reselecting the supervision node set when the number of blocks for supervision and detection reaches a preset number threshold.

[0011] Further optionally, the method further comprises: S403, checking the consensus nodes that voted for the forked block in the forked block, and taking the consensus nodes as malicious nodes that caused the fork; S404, recording the malicious nodes in a malicious node set; and S405, excluding the malicious nodes in the malicious node set when randomly selecting the set of supervisory nodes and the set of consensus nodes from the total node set.

[0012] In another aspect, the embodiments of the present application also provide a node consensus system, comprising: a node selection module, configured to randomly select a set of supervisory nodes and a set of consensus nodes from a total node set; a consensus module, configured to perform consensus according to a consensus protocol by using the set of consensus nodes to establish a block chain; a first supervisory detection module, configured to observe whether the number of blocks in the block chain within a preset time meets a standard by using the set of supervisory nodes, and when the number of blocks within the preset time does not meet the standard, to perform supervisory detection on consensus content by using the set of supervisory nodes, and to reselect the set of consensus nodes when it is confirmed that consensus cannot be performed; a second supervisory detection module, configured to, when the number of blocks within the preset time meets the standard and a forked block chain appears, take the forked block chain as consensus content, perform supervisory detection on the consensus content by using the set of supervisory nodes, select an optimal block chain as a final target block chain to complete block chain confirmation, and take a consensus node that caused the fork as a malicious node and record the malicious node in a malicious node set; and a third supervisory detection module, configured to, when the number of blocks within the preset time meets the standard and there is only one target block chain, take the target block chain as consensus content, perform supervisory detection on the consensus content by using the set of supervisory nodes, and complete block chain confirmation.

[0013] Further optionally, the first supervisory detection module, the second supervisory detection module, and the third supervisory detection module each comprise: a leader supervisory node selection submodule, configured to randomly select one supervisory node from the set of supervisory nodes as a leader supervisory node; a broadcast submodule, configured to broadcast, by using the leader supervisory node, consensus information of consensus content as broadcast information to other supervisory nodes in the set of supervisory nodes; a signature submodule, configured to, within a preset time limit, verify, by other supervisory nodes that received the broadcast information, whether a signature list in the broadcast information is valid, and if the broadcast information is valid and does not exist in a content set corresponding to the content, add the broadcast information to the content set, and add a signature of the supervisory node to the signature list of the broadcast information to obtain latest broadcast information; wherein the content set is initially empty; and a supervisory detection submodule, configured to broadcast, by other supervisory nodes of the latest broadcast information, the latest broadcast information to other supervisory nodes that are not in the signature list, and repeat the steps of the broadcast submodule and the signature submodule until a preset time threshold is reached to complete supervisory detection.

[0014] Further optionally, the second supervision detection module further comprises: a length comparison submodule, configured to compare lengths of all forked blockchains, and select a blockchain with the longest length as the optimal blockchain; and a hash value comparison submodule, configured to select a blockchain to which a tail block with the largest hash value belongs as the optimal blockchain when lengths of the forked blockchains are the same.

[0015] Further optionally, the method further comprises: a first supervision node updating module, configured to reselect the set of supervision nodes every predetermined time interval; and a second supervision node updating module, configured to reselect the set of supervision nodes when a number of blockchains supervised and detected reaches a preset threshold.

[0016] Further optionally, the second supervision detection module further comprises: a forked block identification submodule, configured to check consensus nodes that vote for all forked blocks, and select the consensus nodes as malicious nodes causing the forks; a malicious node recording submodule, configured to record the malicious nodes in a set of malicious nodes; and a malicious node avoidance submodule, configured to exclude the malicious nodes in the set of malicious nodes when randomly selecting the set of supervision nodes and the set of consensus nodes from the set of total nodes.

[0017] The above technical solution has the following beneficial effects: the introduction of the supervision nodes supervises the consensus process of the randomly selected consensus nodes, avoids problems caused by blockchain forks or failure of the consensus, and improves safety and efficiency of the consensus process. BRIEF DESCRIPTION OF DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description only show some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.

[0019] Figure 1 is a flowchart of the node consensus method provided by the embodiments of the present application;

[0020] Figure 2 is a flowchart of the supervision node supervision detection method provided by the embodiments of the present application;

[0021] Figure 3 is a flowchart of the optimal blockchain selection method provided by the embodiments of the present application;

[0022] Figure 4 is a flowchart of the supervision node set updating method provided by the embodiments of the present application;

[0023] Figure 5is a flowchart of a malicious node identification processing method provided by an embodiment of the present application;

[0024] Figure 6 is a structural schematic diagram of a node consensus system provided by an embodiment of the present application;

[0025] Figure 7 is a structural schematic diagram of a sub-module for supervision detection provided by an embodiment of the present application;

[0026] Figure 8 is a structural schematic diagram of a sub-module for selecting an optimal blockchain in a second supervision detection module provided by an embodiment of the present application;

[0027] Figure 9 is a structural schematic diagram of a module for updating a supervision node set provided by an embodiment of the present application;

[0028] Figure 10 is a structural schematic diagram of a sub-module for malicious node identification processing in a second supervision detection module provided by an embodiment of the present application.

[0029] The figure mark: 100-node selection module; 200-consensus module; 300-first supervision detection module; 400-second supervision detection module; 4001-length comparison sub-module; 4002-hash value comparison sub-module; 4003-fork block identification sub-module; 4004-malicious node record sub-module; 4005-malicious node avoidance sub-module; 500-third supervision detection module; 001-leader supervision node selection sub-module; 002-broadcasting sub-module; 003-signature sub-module; 004-supervision detection sub-module; 600-first supervision node updating module; 700-second supervision node updating module. DETAILED DESCRIPTION

[0030] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative labor fall within the protection scope of the present application.

[0031] To solve the problem that a consensus protocol cannot be performed or forks after large-scale consensus nodes are randomly selected and consensus is performed in the prior art, an embodiment of the present application provides a node consensus method, Figure 1 is a flowchart of a node consensus method provided by an embodiment of the present application, as Figure 1 shown, the method comprises the following steps.

[0032] S1, randomly selecting a supervision node set and a consensus node set in a total node set;

[0033] Suppose there are N nodes, all of which are numbered as 0, 1, 2, …, N-1 to form a total node set.

[0034] When selecting the supervisory node set, a random number can be generated by using a VRF random number function, and a part of the supervisory nodes can be selected from the N nodes by using the random number; meanwhile, a distributed random number can be generated by using a BLS signature, and then a part of the supervisory nodes can be selected according to the random number. The supervisory node set obtained by the above two methods is the supervisory node set.

[0035] When selecting the consensus node set, a consensus node selection random number can be generated by using a BLS signature, and the consensus nodes can be selected in the total node set according to the random number to form the consensus node set of the current term.

[0036] S2, consensus is performed according to a consensus protocol by using the consensus node set to establish a block chain;

[0037] The consensus nodes perform consensus according to the consensus protocol in the consensus scheme, and the consensus process includes proposing a block, packaging a block, and constructing a block chain.

[0038] As an optional implementation, the consensus node set of each term is responsible for proposing and consensus of 100 blocks.

[0039] Among them, the consensus nodes use a PBFT-like method to perform consensus, and the consensus nodes gradually establish a block chain through consensus, such as 0 block→1 block→…99 block. The consensus node set of the current term stops working after completing the consensus of 100 blocks, and then is dissolved.

[0040] S3, the number of blocks in the block chain within a preset time is observed by using the supervisory node set, and when the number of blocks within the preset time does not reach the standard, the consensus content is supervised and detected by using the supervisory node set, and the consensus is confirmed to be unable to proceed, and then the consensus node set is reselected;

[0041] During the consensus process, the consensus protocol may not be able to proceed. For this situation, the supervisory node is provided with a timeout time (a preset time), and once the timeout time is exceeded, the supervisory node observes that the consensus does not reach the preset number (the blocks do not continue to increase), and it is considered that the consensus protocol cannot proceed. At this time, the consensus content obtained by the consensus so far is supervised and detected by using the supervisory node set, and it is confirmed that the timeout has occurred. At this time, the consensus node set is reselected, and the node consensus program of the next term is prepared to start.

[0042] S4, when the number of blocks in the preset time meets the standard and the forked block chain appears, the forked block chain is taken as the consensus content respectively, the consensus content is supervised and detected by the supervision node set, the optimal block chain is selected as the final target block chain to complete the block chain confirmation, the consensus node causing the fork is taken as a malicious node and recorded into the malicious node set;

[0043] In the consensus process, the situation of forking may occur, for this situation, each chain of the fork is taken as the consensus content, and the supervision node set is used to complete the supervision detection. From the multiple chains after the supervision detection, the optimal block chain is selected as the final target block chain, that is, as the consensus result. And the specific malicious node is found from the forked block and recorded into the malicious node set. In the subsequent supervision node selection and consensus node selection, these malicious nodes are avoided to be randomly selected.

[0044] S5, when the number of blocks in the preset time meets the standard and there is only one target block chain, the target block chain is taken as the consensus content, and the supervision node set is used to supervise and detect the consensus content to complete the block chain confirmation.

[0045] When the supervision node observes that the current consensus node set has completed the construction of a predetermined number of blocks (100 in this embodiment), the supervision node set is used to supervise and detect, and after the supervision and detection are completed, it is considered that the predetermined number of blocks in the target block chain are valid. At this time, the selection of the new consensus node and the consensus can be prepared.

[0046] As an optional implementation, Figure 2 is a flowchart of the supervision and detection method of the supervision node provided by the embodiment of the application, as shown in Figure 2 The supervision and detection of the consensus content by the supervision node set in steps S3, S4 and S5 includes:

[0047] S01, a supervision node is randomly selected from the supervision node set as a leader supervision node;

[0048] S02, the consensus information of the consensus content is taken as broadcast information by the leader supervision node, and broadcast to other supervision nodes in the supervision node set;

[0049] S03, within a preset time limit, the other supervision nodes receiving the broadcast information verify whether the signature list in the broadcast information is valid, if the broadcast information is valid and does not exist in the content set, the broadcast information is added to the content set, and the signature of the supervision node is added to the signature list of the broadcast information to obtain the latest broadcast information; wherein, the content set is initially empty;

[0050] S04, the other supervision nodes generating the latest broadcast information broadcast the latest broadcast information to the other supervision nodes not in the signature list, repeating steps S03-S04 until a preset time threshold is reached to complete the supervision detection. The supervision node set is used to supervise the consensus content, that is, the check consensus protocol is run, which specifically includes the following steps:

[0051] 1. A supervision node is randomly selected from the supervision node set as the leader supervision node for this check consensus;

[0052] 2. The leader supervision node broadcasts the consensus information of the consensus content to the other supervision nodes, wherein the consensus information includes the hash values of the first and last blocks and the node signature. Specifically, taking a block chain composed of 100 blocks as an example, the leader supervision node organizes the consensus information into the following form ((0 block hash, 99 block hash), node signature), and broadcasts the above consensus information to all supervision nodes;

[0053] 3. After each supervision node receives the above content, it checks whether the node signature is correct. If each supervision node checks, the check consensus protocol between the supervision nodes can be completed, that is, it can be verified.

[0054] Further, the check consensus protocol run in the supervision detection process requires that all nodes must be broadcast at least f+1 times to complete the protocol, where f is the number of malicious nodes. If there are 2 malicious nodes in 7 supervision nodes, the leader supervision node will be a malicious node, at which time the leader supervision node will send different contents to different supervision nodes, causing all supervision nodes to be unable to reach an agreement. To avoid the above situation, the embodiment adopts the following process:

[0055] 1) Each other supervision node in the supervision node set maintains a supervision content set C={}, which is initially empty.

[0056] 2) After receiving the broadcast information, if the broadcast information v is not in the content set C of the other supervision node, v is added to C to make C={v}. In addition, the signature of the other supervision node is attached to the broadcast information and broadcast to all other nodes (excluding the leader supervision node). For example: for x node, the broadcast information format sent is v:s[0]:s[x], wherein s[0] represents the signature of the leader supervision node, and s[x] represents the signature of the x node.

[0057] 3) other monitoring nodes x receive the message in the form of v:s[0]:s[1]:s[2]...s[k], if v is not in C, add v to C, and send the broadcast information with the signature to all other monitoring nodes not in the signature list (for example, do not send to nodes 0, 1, 2...k). For example, the format of the sent message is: v:s[0]:s[1]:s[2]...s[k]:s[x].

[0058] 4) For steps 2) and 3) above, the following requirements are required: 1. Check if the signature list is valid, if any is invalid, ignore the broadcast information; 2. The broadcast information needs to arrive within a preset time limit, otherwise ignore the broadcast information.

[0059] As an optional implementation, assuming that the maximum delay of network communication + the maximum clock difference between different nodes is L, for a message with k signatures, the preset time limit of the broadcast information is T0+k*L, where T0 is the time when the monitoring node starts to run the checking consensus protocol, and the broadcast information exceeding the preset time limit is considered invalid.

[0060] 5) After T0+(f+1)*L time (preset time threshold), end the protocol, where f is the number of malicious nodes in the network.

[0061] Check the values in the set C, if it is an empty set, it means that the consensus cannot be performed, and the consensus node set needs to be reselected; if the set C has only one value, it means that the consensus is normal and a target chain is determined; if the set C has multiple values, it means that the consensus has a fork situation.

[0062] It should be noted that the checking consensus protocol used between the monitoring nodes in the monitoring node set in the embodiment requires only one honest node to work, so if the number of monitoring nodes in the monitoring node set is greater than 100, when there are no more than one-third malicious nodes in the total node set, the probability of selecting a monitoring node set that does not contain an honest node (all selected malicious nodes) is very small and can be ignored.

[0063] As an optional implementation, Figure 3 is a flowchart of the optimal blockchain selection method provided by the embodiment of the application, as Figure 3 shown, selecting the optimal blockchain as the final target blockchain comprises:

[0064] S401, comparing the lengths of all forked blockchains, and selecting the longest blockchain as the optimal blockchain;

[0065] S402, when the lengths of the forked blockchains are the same, selecting the blockchain to which the tail block with the largest hash value belongs as the optimal blockchain.

[0066] In the case of a blockchain fork, an optimal blockchain needs to be selected from the multiple forked blockchains as a consensus result. Taking a fork into two chains as an example, the two forked chains are taken as consensus contents, and the supervision node set is used for supervision detection. In the two chains that complete consensus through supervision detection, the longest chain is selected as the optimal blockchain. If the lengths of the two forked chains are the same, the hash values of the blocks at the tail of the two chains are compared, and the blockchain of the block with the largest hash value is selected as the optimal blockchain, which is taken as the consensus result of this consensus.

[0067] As an optional implementation, Figure 4 is a flowchart of the supervision node set updating method provided by the embodiment of the application, as shown in the figure, after the supervision node set is randomly selected from the total node set, it includes: Figure 4

[0068] S6, the supervision node set is reselected every predetermined time interval;

[0069] Or, S7, the supervision node set is reselected when the supervised blocks reach a preset number threshold.

[0070] In order to ensure security, the supervision node set needs to be updated regularly. A predetermined time interval can be set in advance. When the running time of the supervision node set exceeds the predetermined time interval, the random node selection is restarted to form the latest supervision node set. In addition, the number of supervised blocks can also be recorded. When the number of blocks reaches a preset number threshold, the random node selection is restarted to form the latest supervision node set.

[0071] As an optional implementation, the supervision node set is reselected every ten thousand blocks.

[0072] As an optional implementation, Figure 5 is a flowchart of the malicious node identification processing method provided by the embodiment of the application, as shown in the figure, the consensus node causing the fork is taken as a malicious node and recorded in the malicious node set, including: Figure 5 S403, the consensus node that votes for the fork block in the block where the fork occurs is taken as a malicious node causing the fork;

[0073] S404, the malicious node is recorded in the malicious node set;

[0074] S405, when the supervision node set and the consensus node set are randomly selected from the total node set, the malicious nodes in the malicious node set are excluded.

[0075]

[0076] ​​Check the forked block to see the specific malicious node (the node that voted for the forked block);

[0077] Record the malicious node into the ledger of the blockchain (malicious node set);

[0078] When performing the supervision node selection and the consensus node selection, the confirmed malicious node in the malicious node set is excluded.

[0079] The embodiment of the application further provides a node consensus system, Figure 6 is a structural schematic diagram of the node consensus system provided by the embodiment of the application, and the system comprises:

[0080] The node selection module 100 is used for randomly selecting the supervision node set and the consensus node set from the total node set.

[0081] Suppose that there are N nodes, and all the nodes are numbered as 0, 1, 2…N-1 to form the total node set.

[0082] When the supervision node set is selected, a random number can be generated by using the VRF random number function, and the random number is used to select a part of supervision nodes from the N nodes; meanwhile, a distributed random number can be generated by using the BLS signature mode, and then a part of supervision nodes are selected according to the random number. The supervision node set obtained by the above two modes is the supervision node set.

[0083] When the consensus node set is selected, the BLS signature mode can be used to generate a consensus node selection random number, and the consensus node set is selected from the total node set according to the random number to form the consensus node set of the current term.

[0084] The consensus module 200 is used for performing consensus according to the consensus protocol by using the consensus node set to establish the blockchain.

[0085] The consensus nodes perform consensus according to the consensus protocol in the consensus scheme, and the consensus process comprises: proposing a block, packing a block and constructing a blockchain.

[0086] As an optional implementation, the consensus node set of each term is responsible for proposing and consensus of 100 blocks.

[0087] The consensus nodes use the PBFT mode to perform consensus, and the consensus nodes gradually establish a blockchain after consensus, such as: 0 block→1 block→…99 block. The consensus node set of the current term stops working after completing the consensus of 100 blocks, and then is dissolved.

[0088] The first supervision and detection module 300 is used for observing whether the number of blocks in the blockchain meets the standard within a preset time by using the supervision node set, and when the number of blocks does not meet the standard within the preset time, the supervision and detection is performed on the consensus content by using the supervision node set, and the consensus node set is reselected after confirming that the consensus cannot be performed;

[0089] In the consensus process, the consensus protocol may not be able to be performed. For this situation, the supervision node is provided with a timeout time (a preset time) in this embodiment. Once the timeout time is exceeded, the supervision node observes that the consensus does not reach the preset number (the blocks do not continue to increase), and it is considered that the consensus protocol cannot be performed. At this time, the supervision and detection is performed on the consensus content obtained by the consensus so far by using the supervision node set, it is confirmed that the timeout has occurred, and the consensus node set is reselected to prepare to start the node consensus procedure of the next session.

[0090] The second supervision and detection module 400 is used for, when the number of blocks meets the standard within a preset time and the forked blockchain appears, taking the forked blockchains as the consensus content respectively, performing the supervision and detection on the consensus content by using the supervision node set, selecting the optimal blockchain as the final target blockchain, taking the consensus node causing the fork as a malicious node and recording it into the malicious node set;

[0091] In the consensus process, the forked situation may appear. For this situation, each forked chain is taken as the consensus content in this embodiment, and the supervision and detection is completed by using the supervision node set. From the multiple chains on which the supervision and detection is completed, the optimal blockchain is selected as the final target blockchain, that is, as the consensus result. The specific malicious node is found from the forked blocks and recorded into the malicious node set. In the subsequent supervision node selection and consensus node selection, these malicious nodes are avoided to be randomly selected.

[0092] The third supervision and detection module 500 is used for, when the number of blocks meets the standard within a preset time and there is only one target blockchain, taking the target blockchain as the consensus content, performing the supervision and detection on the consensus content by using the supervision node set, and completing the blockchain confirmation.

[0093] When the supervision node observes that the consensus node set of the current session has completed the construction of a predetermined number of blocks (100 in this embodiment), the supervision and detection is performed by using the supervision node set. After the supervision and detection is completed, it is considered that the predetermined number of blocks in the target blockchain are valid, and at this time, the new session of the consensus node selection and the consensus can be prepared.

[0094] As an optional implementation manner, Figure 7 is a sub-module structure schematic diagram for supervision and detection provided by the embodiment of the present application, as shown in Figure 7 The first supervision and detection module 300, the second supervision and detection module 400 and the third supervision and detection module 500 all include:

[0095] The leader supervisory node selection submodule 001 is configured to randomly select one supervisory node from the supervisory node set as a leader supervisory node;

[0096] The broadcasting submodule 002 is configured to broadcast, by the leader supervisory node, consensus information of consensus content as broadcast information to other supervisory nodes in the supervisory node set;

[0097] The signature submodule 003 is configured to, within a preset time limit, verify, by other supervisory nodes receiving the broadcast information, whether a signature list in the broadcast information is valid, and if the broadcast information is valid and does not exist in a content set, add the broadcast information to the content set, and add a signature of the supervisory node to the signature list of the broadcast information to obtain the latest broadcast information; wherein the content set is initially empty.

[0098] The supervision detection submodule 004 is configured to broadcast, by other supervisory nodes of the latest broadcast information, the latest broadcast information to other supervisory nodes not in the signature list, and repeat the steps of the broadcasting submodule and the signature submodule until a preset time threshold is reached to complete supervision detection.

[0099] The consensus content is supervised and detected by using the supervisory node set, that is, a check consensus protocol is run, and the check consensus protocol specifically includes the following steps:

[0100] 1. A supervisory node is randomly selected from the supervisory node set as a leader supervisory node for checking consensus this time;

[0101] 2. The leader supervisory node broadcasts consensus information of consensus content to other supervisory nodes, wherein the consensus information includes hash values of head and tail blocks and node signatures. Specifically, taking a block chain composed of 100 blocks as an example, the leader supervisory node organizes the consensus information into the following form ((hash of 0 block, hash of 99 block), node signature), and broadcasts the above consensus information to all supervisory nodes;

[0102] 3. Each supervisory node checks whether the node signature is correct after receiving the above content, and if each supervisory node checks, the check consensus protocol between supervisory nodes can be completed, that is, verification can be passed.

[0103] Further, the check consensus protocol run in the supervision detection process requires that all nodes pass at least f+1 times of broadcasting to complete the protocol, wherein f is the number of malicious nodes. If there are 2 malicious nodes in 7 supervisory nodes, the leader supervisory node may be a malicious node, at which time the leader supervisory node sends different content to different supervisory nodes, so that all supervisory nodes cannot reach an agreement. To avoid the above situation, the embodiment adopts the following process:

[0104] 1) Each other supervisory node in the supervisory node set maintains a supervisory content set C = {}, which is initially empty.

[0105] 2) After receiving the broadcast information, if the broadcast information v is not in the content set C of the other supervisory node, v is added to C, so that C = {v}. In addition, the signature of the other supervisory node is attached to the broadcast information and broadcast to all other nodes (excluding the leader supervisory node). For example, for node x, the broadcast information sent is in the format of v:s[0]:s[x], where s[0] represents the signature of the leader supervisory node, and s[x] represents the signature of node x.

[0106] 3) After receiving the message in the form of v:s[0]:s[1]:s[2]...s[k], if v is not in C, v is added to C, and the signature of the other supervisory node is attached to the broadcast information and sent to all other supervisory nodes not in the signature list (for example, not sent to nodes 0, 1, 2...k). For example, the message sent is in the format of v:s[0]:s[1]:s[2]...s[k]:s[x].

[0107] 4) For steps 2) and 3) above, the following requirements are met: 1. Check if the signature list is valid, and if any is invalid, ignore the broadcast information; 2. The broadcast information needs to arrive within a preset time limit, otherwise it is ignored.

[0108] As an optional implementation, assuming that the maximum delay of network communication + the maximum clock difference between different nodes is L, for a message with k signatures, the preset time limit of the broadcast information is T0+k*L, where T0 is the time when the supervisory detection starts to run the check consensus protocol, and the broadcast information exceeding the preset time limit is considered invalid.

[0109] 5) After T0+(f+1)*L time (preset time threshold), the protocol ends, where f is the number of malicious nodes in the network.

[0110] Check the values in set C. If it is an empty set, it means that consensus cannot be performed, and the consensus node set needs to be reselected. If set C has only one value, it means that consensus is normal and a target chain is determined. If set C has multiple values, it means that consensus has a fork situation.

[0111] It should be noted that the check consensus protocol used between the supervision nodes in the supervision node set in the embodiment requires only one honest node to work, so if the number of supervision nodes in the supervision node set is greater than 100, the probability of selecting a supervision node set that does not contain an honest node (all selected malicious nodes) is very small and can be ignored when there are no more than one-third malicious nodes in the total node set.

[0112] As an optional implementation, Figure 8 is a sub-module structure diagram for selecting an optimal blockchain in the second supervision detection module provided by the embodiment of the application, as shown in Figure 8 The second supervision detection module 400 further includes:

[0113] The length comparison sub-module 4001 is configured to compare the lengths of all forked blockchains and select the longest blockchain as the optimal blockchain.

[0114] The hash value comparison sub-module 4002 is configured to select the blockchain to which the tail block with the largest hash value belongs as the optimal blockchain when the lengths of the forked blockchains are the same.

[0115] For the case of blockchain forking, one optimal blockchain needs to be selected from the multiple forked blockchains as a consensus result. Taking the case of forking into two chains as an example, the two forked chains are taken as the consensus content, and the supervision node set is used for supervision detection. In the two chains that complete the consensus through the supervision detection, the longest chain is selected as the optimal blockchain. If the lengths of the two forked chains are the same, the hash values of the tail blocks of the two chains are compared, and the blockchain of the block with the largest hash value is selected as the optimal blockchain, which is taken as the consensus result of this consensus.

[0116] As an optional implementation, Figure 9 is a structure diagram of a module for updating the supervision node set provided by the embodiment of the application, as shown in Figure 9 The system further includes:

[0117] The first supervision node updating module 600 is configured to reselect the supervision node set at a predetermined time interval.

[0118] The second supervision node updating module 700 is configured to reselect the supervision node set when the number of blockchains subjected to supervision detection reaches a preset threshold.

[0119] In order to ensure safety, a predetermined time interval can be set in advance, and when the running time of the supervision node set exceeds the predetermined time interval, the random node selection is restarted to form the latest supervision node set; in addition, the number of supervised blocks can also be recorded, and when the number of blocks reaches the preset number threshold, the random node selection is restarted to form the latest supervision node set. As an optional implementation manner, the supervision node set is reselected every ten thousand blocks.

[0120] As an optional implementation manner, Figure 10 is a structural schematic diagram of a sub-module for malicious node identification processing in the second supervision detection module provided by the embodiment of the application, as Figure 10 indicated, the second supervision detection module further comprises:

[0121] The fork block identification sub-module 4003 is configured to check the consensus nodes that vote for the fork block in the fork block, and take the consensus nodes as malicious nodes causing the fork;

[0122] The malicious node recording sub-module 4004 is configured to record the malicious nodes in the malicious node set;

[0123] The malicious node avoidance sub-module 4005 is configured to exclude the malicious nodes in the malicious node set when randomly selecting the supervision node set and the consensus node set from the total node set.

[0124] The fork block is checked to view the specific malicious nodes (the nodes that vote for the fork block);

[0125] The malicious nodes are recorded in the ledger (the malicious node set) of the block chain;

[0126] When the supervision node selection and the consensus node selection are performed, the confirmed malicious nodes in the malicious node set are excluded. The above technical solution has the following beneficial effects: by introducing the supervision node, the consensus process of the randomly selected consensus node is supervised, the problems caused by the block chain fork or the failure of the consensus are avoided, and the safety and the consensus efficiency of the consensus process are improved.

[0127] The above specific embodiments of the application further illustrate the purposes, technical solutions and beneficial effects of the application, and it should be understood that the above content is only the specific embodiments of the application and is not used to limit the protection scope of the application, and any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the application should be included in the protection scope of the application.

Claims

1. A node consensus method, characterized in that, The method comprises the following steps: S1, randomly selecting a set of supervision nodes and a set of consensus nodes in a total node set; S2, performing consensus according to a consensus protocol by using the set of consensus nodes to establish a block chain; S3, observing whether the number of blocks in the block chain reaches a standard within a preset time by using the set of supervision nodes, when the number of blocks does not reach the standard within the preset time, taking the block which has completed the consensus as the consensus content, performing supervision detection on the consensus content by using the set of supervision nodes, and reselecting the set of consensus nodes when the consensus cannot be performed; S4, when the number of blocks reaches the standard within the preset time and a forked block chain appears, taking the forked block chain as the consensus content respectively, performing supervision detection on the consensus content by using the set of supervision nodes, selecting an optimal block chain as a final target block chain to complete block chain confirmation, and taking the consensus nodes causing the fork as malicious nodes and recording the malicious nodes into a malicious node set; S5, when the number of blocks reaches the standard within the preset time and there is only one target block chain, taking the target block chain as the consensus content, performing supervision detection on the consensus content by using the set of supervision nodes, and completing block chain confirmation.

2. The node consensus method of claim 1, wherein, The supervision detection on the consensus content by using the set of supervision nodes comprises the following steps: S01, randomly selecting a supervision node from the set of supervision nodes as a leader supervision node; S02, taking consensus information of the consensus content as broadcast information by using the leader supervision node, and broadcasting the broadcast information to other supervision nodes in the set of supervision nodes; S03, when other supervision nodes do not receive the broadcast information within a preset time limit, the broadcast information is ignored; otherwise, the other supervision nodes receiving the broadcast information verify whether a signature list in the broadcast information is valid, if the broadcast information is valid and does not exist in a content set corresponding to the broadcast information, the broadcast information is added to the content set, and a signature of the supervision node is added to the signature list of the broadcast information to obtain the latest broadcast information; wherein, the content set is initially empty; S04, the other supervision nodes generating the latest broadcast information broadcast the latest broadcast information to other supervision nodes not in the signature list, and steps S03-S04 are repeated until a preset time threshold is reached to complete the supervision detection.

3. The node consensus method of claim 1, wherein, The selection of the optimal block chain as the final target block chain comprises the following steps: S401, comparing the lengths of all forked block chains, and selecting a block chain with the longest length as the optimal block chain; S402, when the lengths of the forked block chains are the same, selecting a block chain to which a tail block with the largest hash value belongs as the optimal block chain.

4. The node consensus method of claim 1, wherein, After the set of supervision nodes is randomly selected in the total node set, the following steps are included: S6, reselecting the set of supervision nodes every predetermined time interval; Or, S7, reselecting the set of supervision nodes when the number of blocks for supervision detection reaches a preset number threshold.

5. The node consensus method of claim 1, wherein, The taking of the consensus nodes causing the fork as malicious nodes and the recording of the malicious nodes into the malicious node set comprise the following steps: S403, checking the consensus nodes which vote for the forked blocks in the forked blocks, and taking the consensus nodes as malicious nodes causing the fork; S404, recording the malicious nodes into the malicious node set; S405、from the total node set randomly select a set of supervision nodes and consensus node set, exclude the malicious nodes in the malicious node set.

6. A node consensus system, characterized in that, Comprise: Node selection module, for randomly selecting a set of supervision nodes and consensus node set in the total node set; Consensus module, for using the consensus node set to reach consensus according to the consensus protocol to establish a block chain; The first supervision detection module is used for observing whether the number of blocks in the block chain reaches the standard within a predetermined time, and when the number of blocks within the predetermined time does not reach the standard, the block which has completed the consensus is taken as the consensus content, and the supervision node set is used to supervise and detect the consensus content, and when the consensus cannot be carried out, the consensus node set is reselected; The second supervision detection module is used for when the number of blocks within the predetermined time reaches the standard and the forked block chain appears, taking the forked block chain as the consensus content, using the supervision node set to supervise and detect the consensus content, selecting the optimal block chain as the final target block chain to complete the block chain confirmation, and taking the consensus node causing the fork as a malicious node and recording it into the malicious node set; The third supervision detection module is used for when the number of blocks within the predetermined time reaches the standard and there is only one target block chain, taking the target block chain as the consensus content, using the supervision node set to supervise and detect the consensus content, and completing the block chain confirmation. 7.The node consensus system of claim 6, wherein, The first supervision detection module, the second supervision detection module and the third supervision detection module all comprise: Leader supervision node selection submodule, for randomly selecting a supervision node from the supervision node set as a leader supervision node; Broadcasting submodule, for using the leader supervision node to broadcast the consensus information of the consensus content as broadcast information to other supervision nodes in the supervision node set; Signature submodule, for when other supervision nodes do not receive the broadcast information within a predetermined time limit, ignoring the broadcast information; otherwise, the other supervision nodes receiving the broadcast information verify whether the signature list in the broadcast information is valid, if valid and the broadcast information does not exist in the content set, adding the broadcast information to the content set, and adding the supervision node signature to the signature list of the broadcast information to obtain the latest broadcast information; wherein the content set is initially empty; Supervision detection submodule, for generating the latest broadcast information of other supervision nodes broadcasting the latest broadcast information to other supervision nodes not in the signature list, repeating the operation of the signature submodule and the supervision detection submodule until a predetermined time threshold is reached to complete the supervision detection. 8.The node consensus system of claim 6, wherein, The second supervision detection module further comprises: Length comparison submodule, for comparing the lengths of all forked block chains, and selecting the block chain with the longest length as the optimal block chain; Hash value comparison submodule, for when the lengths of the forked block chains are the same, selecting the block chain to which the tail block with the largest hash value belongs as the optimal block chain. 9.The node consensus system of claim 6, wherein, Further comprising: The first supervision node updating module is used for reselecting the supervision node set every predetermined time interval; The second supervision node updating module is configured to reselect the supervision node set when the detected blocks reach a preset number threshold. 10.The node consensus system of claim 6, wherein, The second supervision detection module further comprises: The bifurcation block identification submodule is configured to check the consensus nodes that vote for each of the bifurcation blocks in the bifurcation blocks, and take the consensus nodes as malicious nodes causing the bifurcation; The malicious node recording submodule is configured to record the malicious nodes into a malicious node set; The malicious node avoidance submodule is configured to exclude the malicious nodes in the malicious node set when randomly selecting the supervision node set and the consensus node set from the total node set.

Citation Information

Patent Citations

  • Consensus method applied to agricultural product supply chain scene

    CN114466042A

  • Data processing method and device, computer equipment and storage medium

    CN115454320A