IoT Leader Election Method and Broadcasting Method Based on Blockchain Consensus
The election of leader nodes through the proof-of-stake consensus mechanism and erasure coding technology has solved the problem of high computing power demand in the existing technology and improved the performance and scalability of the Internet of Things blockchain system.
Patent Information
- Application Number
- CN202211476386.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-23
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2042-11-23
AI Technical Summary
The existing consensus mechanism requires a lot of computing power to elect leader nodes in the IoT blockchain system, resulting in a reduction in the performance of the IoT blockchain system.
The proof-of-stake consensus mechanism is used to elect committee nodes from the Internet of Things nodes, and random numbers are generated based on the hash value and the number of stages of the block, and the leader node is elected in combination with the credibility, and block broadcast is used to use erasure coding technology and Streamlet consensus protocol.
Save computing power, improve the performance and scalability of the IoT blockchain system, reduce the bandwidth load of leader nodes, and improve the block confirmation speed.
Smart Images

Figure CN115834083B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of the Internet of Things, and specifically to an Internet of Things leader election method and a broadcast method based on blockchain consensus. Background Art
[0002] A common feature of Internet of Things systems is that many of the devices (nodes) that make up these systems are resource-constrained, and these devices need to communicate automatically without human intervention. Currently, most of the main solutions for the Internet of Things rely on a centralized client-server model, in which case the server requires a large amount of processing power and storage space. In addition, even if the devices are close to each other, all communication between the devices must pass through the Internet. At the same time, the dependence on cloud servers makes the systems of this structure prone to single point of failure problems, thereby reducing the robustness of the system. Although there are currently some methods attempting to secure Internet of Things devices, these methods are complex and not suitable for Internet of Things devices with resource constraints and limited computing power. Considering the growth rate of the Internet of Things network and the disadvantages of the mentioned client-server model, there is a need for better methods in the future to make the network more decentralized. As a decentralized system, the blockchain system easily solves some problems of the Internet of Things. The most important feature of the blockchain lies in its decentralization and security, and these features are also very suitable for the Internet of Things. As a distributed system, the blockchain solves the problem of how to make the nodes in the system reach an agreement on the proposals of the system. Among them, the consensus algorithm is one of the core components of the blockchain system and is the key to solving this problem. However, according to the FLP and CAP theories, it will be found that in actual application scenarios, there is no perfect consensus mechanism that can be applied to any blockchain system, and for different blockchain application scenarios, a specific consensus algorithm that meets the requirements often needs to be designed. The same is true for the Internet of Things blockchain system. Existing consensus mechanisms require a large amount of computing power to elect leader nodes in the Internet of Things blockchain system, thereby reducing the performance of the Internet of Things blockchain system.
[0003] In summary, the consensus mechanism in the prior art reduces the performance of the Internet of Things blockchain system.
[0004] Therefore, the prior art still needs to be improved and enhanced. Summary of the Invention
[0005] To solve the above technical problems, the present invention provides an Internet of Things leader election method and a broadcast method based on blockchain consensus, which solve the problem that the consensus mechanism in the prior art reduces the performance of the Internet of Things blockchain system.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] In a first aspect, the present invention provides an Internet of Things leader election method based on blockchain consensus, which includes:
[0008] According to the proof-of-stake consensus mechanism, select committee nodes for the Internet of Things blockchain from a number of Internet of Things nodes;
[0009] Generate a first random number corresponding to the block according to the hash value of the current block of the Internet of Things blockchain and the current stage number of the Internet of Things blockchain;
[0010] Select a leader node from each of the committee nodes according to the credibility of each committee node and the first random number, where the credibility is used to measure the performance of the committee node in transmitting blocks.
[0011] In one implementation, the step of selecting committee nodes for the Internet of Things blockchain from a number of Internet of Things nodes according to the proof-of-stake consensus mechanism includes:
[0012] Statistically analyze the data information of disruptive behaviors generated by the Internet of Things nodes, where the data information of disruptive behaviors is information that interferes with the Internet of Things blockchain;
[0013] According to the proof-of-stake consensus mechanism, obtain the credibility mechanism in the proof-of-stake consensus mechanism;
[0014] Select committee nodes for the Internet of Things blockchain from a number of Internet of Things nodes according to the data information of disruptive behaviors and the credibility mechanism.
[0015] In one implementation, the step of selecting a leader node from each of the committee nodes according to the credibility of each committee node and the first random number, where the credibility is used to measure the performance of the committee node in transmitting blocks, includes:
[0016] Generate a second random number according to the credibility of each committee node and the attribute information of each committee node;
[0017] Select a leader node from each of the committee nodes according to the first random number and the second random number.
[0018] In a second aspect, an embodiment of the present invention further provides an Internet of Things blockchain broadcasting method, which includes:
[0019] The leader node screens out target blocks from each of the original blocks according to the duration after the hash value of each original block is notarized, where the notarization is the verification information of the committee node where the leader node is located for the hash value;
[0020] The leader node applies erasure coding technology to encode the target block into encoded content;
[0021] The leader node broadcasts the encoded content to the committee nodes.
[0022] In one implementation, the leader node applies erasure coding technology to encode the target block into encoded content, including:
[0023] The leader node applies erasure coding technology to encode the data part of the target block into a block code;
[0024] The leader node applies Merkle tree technology to generate a Merkle root from the hash value of the target block;
[0025] The leader node generates the encoded content based on the block code and the Merkle root.
[0026] In one implementation, the leader node broadcasts the encoded content to the committee nodes, including:
[0027] The leader node counts the total number of nodes formed by the committee nodes;
[0028] The leader node divides the encoded content into several pieces of encoded content corresponding to the total number of nodes according to the total number of nodes;
[0029] The leader node broadcasts several pieces of encoded content to each of the committee nodes.
[0030] In one implementation, it further includes:
[0031] The leader node notarizes the hash value of the original block according to the Streamlet consensus protocol.
[0032] In one implementation.
[0033] In a second aspect, an embodiment of the present invention further provides an Internet of Things leader election device based on blockchain consensus, where the device includes the following components:
[0034] A first election module, configured to elect committee nodes of the Internet of Things blockchain from a number of Internet of Things nodes according to the proof-of-stake consensus mechanism;
[0035] A random number generation module, configured to generate a first random number corresponding to the block according to the hash value of the current block of the Internet of Things blockchain and the current stage number of the Internet of Things blockchain;
[0036] A second election module, configured to elect a leader node from each of the committee nodes according to the credibility of each committee node and the first random number, where the credibility is used to measure the performance of the committee node in transmitting blocks.
[0037] In a third aspect, an embodiment of the present invention further provides a terminal device. The terminal device includes a memory, a processor, and an Internet of Things leader election program based on blockchain consensus stored in the memory and executable on the processor. When the processor executes the Internet of Things leader election program based on blockchain consensus, the steps of the above-mentioned Internet of Things leader election method based on blockchain consensus are implemented.
[0038] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium. An Internet of Things leader election program based on blockchain consensus is stored on the computer-readable storage medium. When the Internet of Things leader election program based on blockchain consensus is executed by a processor, the steps of the above-mentioned Internet of Things leader election method based on blockchain consensus are implemented.
[0039] Beneficial effects: The present invention first elects committee nodes of the Internet of Things blockchain from several Internet of Things nodes according to the proof-of-stake consensus mechanism; then generates a first random number corresponding to a block according to the hash value of the current block of the Internet of Things blockchain and the current stage number of the Internet of Things blockchain; and finally elects a leader node from each committee node according to the credibility of each committee node and the first random number. Since the proof-of-stake consensus mechanism is only associated with the credibility of each Internet of Things node and does not involve other data, computing power can be saved. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a schematic diagram of the member structure of the Internet of Things blockchain in an embodiment of the present invention;
[0041] Figure 2 It is the overall flowchart of the present invention;
[0042] Figure 3 It is a schematic diagram of the structure of the Internet of Things blockchain system in an embodiment of the present invention;
[0043] Figure 4 It is a schematic diagram of the functions of an observer, a candidate, and a committee member in an embodiment of the present invention;
[0044] Figure 5 It is a flowchart of the consensus leader election in an embodiment of the present invention;
[0045] Figure 6 It is a flowchart of generating a random list in an embodiment of the present invention;
[0046] Figure 7 It is the flowchart of block publishing in the embodiment of the present invention;
[0047] Figure 8 It is the flowchart of committee voting in the embodiment of the present invention;
[0048] Figure 9 It is the flowchart of block confirmation in the embodiment of the present invention;
[0049] Figure 10 It is the internal structure principle block diagram of the terminal device provided by the embodiment of the present invention. Specific implementation manners
[0050] The technical solutions in the present invention will be clearly and completely described below in conjunction with the embodiments and the accompanying drawings of the specification. Based on the embodiments in the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0051] Through research, it is found that the common feature of the Internet of Things system is that many of the devices (nodes) that make up these systems are resource-constrained, and these devices need to communicate automatically without human intervention. At present, most of the main solutions for the Internet of Things rely on the centralized client-server mode. In this case, the server requires a large amount of processing power and storage space. In addition, even if the devices are very close to each other, all communications between the devices must pass through the Internet. At the same time, the dependence on the cloud server makes the system of this structure prone to single-point failure problems, thereby reducing the robustness of the system. Although there are some methods trying to make the Internet of Things devices secure at present, these methods are complex and not suitable for the resource-constrained and limited computing power Internet of Things devices. Considering the growth rate of the Internet of Things network and the mentioned disadvantages of the client-server mode, better methods are needed in the future to make the network more decentralized. As a decentralized system, the blockchain system easily solves some problems of the Internet of Things. The most important feature of the blockchain is its decentralization and security, and these features are also very suitable for the Internet of Things. As a distributed system, the blockchain solves the problem of how to make the nodes in the system reach an agreement on the system's proposal. Among them, the consensus algorithm is one of the core components of the blockchain system and is the key to solving this problem. However, according to the FLP and CAP theories, it will be found that in the actual application scenario, there is no perfect consensus mechanism that can be applied to any blockchain system. For different application scenarios of the blockchain, a specific consensus algorithm that meets the requirements often needs to be designed. The same is true for the Internet of Things blockchain system. The existing consensus mechanisms require a large amount of computing power to elect the leader node in the Internet of Things blockchain system, thus reducing the performance of the Internet of Things blockchain system.
[0052] To solve the above technical problems, the present invention provides an Internet of Things leader election method and a broadcasting method based on blockchain consensus, which solves the problem that the consensus mechanism in the prior art reduces the performance of the Internet of Things blockchain system. Specifically, in implementation, first, according to the proof-of-stake consensus mechanism, committee nodes of the Internet of Things blockchain are elected from a number of Internet of Things nodes; then, according to the hash value of the current block of the Internet of Things blockchain and the current stage number of the Internet of Things blockchain, a first random number corresponding to the block is generated; then, according to the credibility of each committee node and the first random number, a leader node is elected from each committee node; finally, the leader node broadcasts the block to each committee node.
[0053] For example, take an Internet of Things blockchain composed of twenty Internet of Things nodes (a node is a device in the Internet of Things used to transmit data such as a block). As Figure 1 shown, first, fifteen Internet of Things nodes that have not committed any malicious acts (in the Internet of Things system, malicious acts mean that the node has poor performance, maliciously attacks other nodes, causing data loss to other nodes) are selected from these twenty Internet of Things nodes acting as observers as candidates, and then, according to the proof-of-stake consensus mechanism PoS, ten Internet of Things nodes are selected from the fifteen candidates to form committee members. After that, according to the hash value of the current block of the Internet of Things blockchain (the current block is the data received by the Internet of Things blockchain from other Internet of Things blockchains, and the hash value is saved in the block. The hash value is used as a kind of visa, and through the hash value, it can be verified whether the publisher of the block has signed correctly and whether the data of the block has been tampered with) and the current stage number (in the Internet of Things, this stage number represents the number of times the blockchain of the Internet of Things initiates the consensus stage of the block, that is, the first time to execute blockchain consensus) and the credibility of each committee member, a leader node is elected from the committee members. Finally, the leader node broadcasts (sends) the blocks received from the Internet of Things blockchain in chunks to the nodes other than the leader node among the committee members, and the committee members then broadcast the chunked blocks received by each of them to each other within the committee members so that each node in the committee members can receive all the blocks.
[0054] Exemplary method
[0055] The Internet of Things broadcasting method based on blockchain consensus in this embodiment can be applied to a terminal device, and the terminal device can be a terminal product with computing and storage functions, such as a computer or other servers. In this embodiment, as Figure 2 shown, specifically, it includes the following steps:
[0056] S100, according to the proof-of-stake consensus mechanism PoS, committee nodes of the Internet of Things blockchain are elected from a number of Internet of Things nodes.
[0057] Step S100 includes the following steps S101, S102, and S103:
[0058] S101, count the damage behavior data information generated by the IoT nodes, where the damage behavior data information is information that interferes with the IoT blockchain.
[0059] For example, if there are ten nodes (devices) in the IoT blockchain, and one of the nodes sends data viruses (interference information) to other nodes twice, then the damage behavior data information of this node (referred to as a malicious node) is two, and the other nine nodes are nodes that do not generate damage behavior data information.
[0060] S102, according to the proof-of-stake consensus mechanism, obtain the credibility mechanism in the proof-of-stake consensus mechanism.
[0061] In this embodiment, the credibility mechanism is used as the proof-of-stake consensus mechanism PoS, and the credibility is related to the network stability of the nodes (devices or servers). The higher the network stability, the greater the credibility.
[0062] S103, according to the damage behavior data information and the credibility mechanism, select committee nodes from several IoT nodes to serve as the IoT blockchain.
[0063] Figure 3 The committee selection module in [] will select committee nodes from several candidate nodes according to whether each candidate node sends damaging behavior and its credibility.
[0064] Steps S101, S102, and S102 select committee nodes based on the following principle:
[0065] During the operation of the IoT blockchain, each node will be divided into three roles, namely Figure 1 the observers, candidates, and committee members in []. Among them, committee members must be candidates, and candidates must be observers. The initial role of any node is an observer. In this embodiment, multiple consensus stages are called a consensus epoch, and a consensus epoch consists of multiple consensus stages. Each round of consensus stages will be jointly executed by the committee members of this stage for the consensus process of the block. Since the Byzantine consensus PBFT requires that the malicious nodes (such as nodes that send virus data to other nodes) among the committee members participating in the consensus be less than 1 / 3 of the total number of committee members participating in the consensus, some screening mechanisms are needed to further reduce the possibility of malicious nodes participating in the consensus. Such as Figure 4As shown, if a node (candidate node) wants to become a member of the consensus committee in the next stage, it needs to pledge a specified amount of assets as a guarantee (the network stability of the Internet node can be used as the guarantee). After pledging sufficient guarantee, the node will become the corresponding candidate. At the same time, in order to ensure that the blockchain system in the Internet of Things can better use the blockchain to record data, a parameter called credibility will be set for each blockchain node participating in the consensus. In the initial state of a node, its credibility is 1. For each blockchain node that becomes a candidate in each stage, the probability of its finally becoming a member of the consensus committee is related to its credibility. The more prominent the credibility of a single node is in the current candidate pool, the greater the probability that it will be selected as a member of the consensus committee in the current consensus stage.
[0066] If a node has good performance, a good network and does not act maliciously, then the higher the efficiency of its broadcasting blocks and voting, the more it should be selected as a member of the consensus committee. If a node has average performance or frequently acts maliciously, which is less helpful or even hinders the consensus of the blockchain (hindering the consensus in the Internet of Things system means hindering the transmission of data in the Internet of Things system), then it should be less likely to be selected as a member of the consensus committee. Therefore, during the consensus process, if a node discovers obvious malicious behavior of other nodes, then the node can initiate a removal request (for example, if node A discovers that node a has malicious behavior, then node A will request other nodes B and C in the Internet of Things system to delete node a. Deleting node a means informing nodes B and C not to send this block of data to node a anymore), and then a consensus will be made on whether the malicious node should be removed (it is jointly decided by nodes A, B, and C whether to delete node a in the Internet of Things system). If 2 / 3 of the nodes vote to resolve, then the corresponding committee member (for example, deleting node a from the committee list) will be removed from the committee list.
[0067] S200, generate a first random number corresponding to the block according to the hash value of the current block of the Internet of Things blockchain and the current stage number of the Internet of Things blockchain.
[0068] In this embodiment, a block includes three parts: a block header, a data part, and a signature. The block header includes the consensus phase number when the block is released (in the Internet of Things, this phase number represents the number of times the blockchain of the Internet of Things initiates the consensus phase of the block, that is, the first execution of the blockchain consensus, which is a monotonically increasing integer that increases with time), the hash value of the previous block header to which the block is connected, and the hash value calculated from the data part of the block; the data part is composed of one request / data to be stored in the Internet of Things; the signature is generally the signature of the block generator (for example, when the Internet of Things blockchain A sends a block A to the Internet of Things blockchain B, the Internet of Things blockchain A is the generator of the block A, and there is the signature of the Internet of Things blockchain in the block A), which is used to verify the correctness of the block.
[0069] In the Internet of Things blockchain, the block to be broadcast at the current moment is the current block. Since before broadcasting the block, each committee member has received the hash value in the block header, each committee member uses this hash value and the current phase number as a random source to jointly generate a random number (the first random number).
[0070] S300. According to the credibility of each of the committee nodes and the first random number, select a leader node from each of the committee nodes, where the credibility is used to measure the performance of the committee node in transmitting the block.
[0071] In one embodiment, step S300 includes the following steps S301 and S302:
[0072] S301. Generate a second random number according to the credibility of each of the committee nodes and the attribute information of each of the committee nodes.
[0073] In this embodiment, the attribute information is the ID1 number of the committee node. For example, if the credibility of a committee node c is 10, then ten random numbers s1ID1, s2ID1, s3ID1,..., s10ID1 (the second random number, and each random number contains the ID1 number of node c) can be jointly generated by the eleven numbers ID1, 1, 2, 3,..., 10. Save s1ID1, s2ID1, s3ID1,..., s10ID1 in the random number list, and the random number list records the corresponding relationship between the random numbers s1ID1, s2ID1, s3ID1,..., s10ID1 and node c.
[0074] Alternatively, if the credibility of a committee node d is 5, then five random numbers s1ID2, s2ID2, s3ID2, s4ID2, s5ID2 (the second random numbers, each of which contains the ID2 number of node d) can be generated jointly by the six numbers ID2, 1, 2, 3, 4, 5. Save s1ID2, s2ID2, s3ID2, s4ID2, s5ID2 in the random number list, and the random number list records the corresponding relationship between the random numbers s1ID2, s2ID2, s3ID2, s4ID2, s5ID2 and node d.
[0075] S302. According to the first random number and the second random number, elect a leader node from each of the committee nodes.
[0076] Find the second random number larger than the first random number from the random number list in step S301. If the second random number larger than the first random number is s1ID2, then the committee node d is the leader node.
[0077] In this embodiment, the generation of the consensus leader in each stage is more random, and it also conforms to the setting that the greater the credibility of the committee member, the greater the probability of being selected as the leader. The reason why the committee node with greater credibility has a greater probability of being called the leader node is that the greater the credibility of the node, the greater the number of the corresponding second random numbers, and the greater the number, the greater the probability that it is larger than the first random number. Selecting a node with high credibility as the leader node can improve the quality and performance of the entire Internet of Things blockchain broadcast block.
[0078] Steps S301 and S302 elect the leader node based on the following principle:
[0079] As Figure 5 shown, in each stage, the committee members will jointly generate a random number using the hash value generated from the data part of the latest confirmed block in the current blockchain and the current stage number as the random source. Then, using this random number, find the first random number larger than it from the maintained random number list, or if there is no number larger than it in this random number list, then find the smallest random number in the list. Then, based on the random number that meets the requirements in the list, obtain the corresponding committee member, and then make an equivalent judgment to determine whether the obtained committee member is itself, so as to determine whether it is the leader node in the current stage. In this way, the generation of the consensus leader in each stage is more random, and it also conforms to the setting that the greater the credibility of the committee member, the greater the probability of being selected as the leader.
[0080] In one embodiment, the random number list is generated in the following manner:
[0081] As Figure 6As shown, the nodes elected as committee members for a consensus epoch all have the opportunity to become the consensus leader during this consensus epoch. In the Internet of Things blockchain system, a relevant list of random numbers is maintained. These random numbers are random numbers jointly generated by the member IDs of the participating committee members and their credibility. The range of the sizes of these random numbers is from 0 to 2 to the 32nd power minus 1, i.e., [0 0 -1, 2 32 -1], and the numbers within the above range are arranged in ascending order.
[0082] For example: Suppose the ID of the current committee node A is a and its credibility is 10. Then, ten random numbers are jointly generated using its ID a and the numbers 1, 2... 10, and they are saved. At the same time, the corresponding relationship between them and the committee members is saved. This list is arranged in ascending order based on the size of the random numbers.
[0083] S400, the leader node broadcasts the block.
[0084] Through steps S100 to S300, a leader node is elected from the Internet of Things blockchain system. When Internet of Things blockchain A sends a block to Internet of Things blockchain B, it sends the block to the leader node of Internet of Things blockchain B. After receiving the block, the leader node then broadcasts (sends) the block to other nodes in Internet of Things blockchain B.
[0085] In one embodiment, step S400 includes the following steps S401, S402, and S403:
[0086] S401, the leader node screens out the target block from each of the original blocks according to the duration after the hash value of each original block is notarized. The notarization is the verification information of the committee nodes where the leader node is located for the hash value.
[0087] For example, the leader node of Internet of Things blockchain A successively receives blocks a, b, and c sent by Internet of Things blockchain B. The leader node broadcasts the hash value of block a, the hash value of block b, and the hash value of block c respectively among the committee nodes in Internet of Things blockchain A. Each committee node determines whether block a, block b, and block c pass notarization according to the Streamlet consensus protocol (Streamlet means thin stream) (if it passes notarization, it means that the data content contained in the block can be broadcast within Internet of Things blockchain A). If block a and block b pass notarization, and the duration after block b passes notarization is greater than the duration after block a passes notarization, then block b is the target block. Then, the leader node of Internet of Things blockchain A first broadcasts block b.
[0088] In S402, the leader node applies erasure coding technology to encode the target block into encoded content.
[0089] In one embodiment, step S402 encodes the target block into encoded content through the following process:
[0090] The leader node applies erasure coding technology to encode the data part of the target block into a block code; the leader node applies Merkle tree technology to generate a Merkle root from the hash value of the target block; the leader node generates the encoded content based on the block code and the Merkle root.
[0091] Generate a legal block containing a large amount of data / requests according to the above generation rules and utilize erasure coding technology. The encoded content includes not only the encoded block chunks, but also a hash value generated by using a hash function for all these encoded blocks, and the hash values of all encoded blocks. Using Merkle tree technology, the finally generated Merkle root is obtained. The Merkle root and the hash value of the encoded data are mainly used to determine whether the received data has been tampered with. As Figure 7 shown, then the leader node packs (encodes into encoded content) the encoded content, its own leader information, and the height information of this block (in the blockchain, ideally, there is only one branch of the blockchain. However, in the Internet of Things environment, due to the existence of networks and the possibility of malicious attacks, there may be multiple blocks extending from the same parent block, and these multiple blocks extending from the same parent block have the same height. That is, the height is used to represent a situation of block extension in the blockchain. For example, the height of the first block is 1, and if the second block extends from the first block, then the height of the second block is 2), and sends different data packets to different nodes respectively.
[0092] S403, the leader node broadcasts the encoded content to the committee nodes.
[0093] In one embodiment, the specific steps of step S403 are as follows: the leader node counts the total number of nodes formed by the committee nodes; the leader node divides the encoded content into several pieces of encoded content corresponding to the total number of nodes according to the total number of nodes; the leader node broadcasts the several pieces of encoded content to each of the committee nodes respectively.
[0094] For example, if there are six (total number of nodes) committee nodes, the leader node divides the encoded content into six pieces, and then sends these six pieces of encoded content to the six committee nodes respectively. After each of the six committee nodes receives one piece of encoded content, the six committee nodes exchange their respective encoded content with each other.
[0095] In one embodiment, after a non-leader node (a node other than the leader node among the committee nodes) receives the encoded data sent mutually by N - 2f non-leader nodes, it uses the Merkle root and the hash value of the encoded data to determine whether the data has been tampered with and whether it can form a complete block. If so, it decodes the encoded data.
[0096] If a certain node observes, during the process of attempting to combine a complete block, that there is a block in the blockchain system with the same height as the block to be combined and it has been confirmed, then the node will directly cancel the operation of attempting to combine the block.
[0097] In one embodiment, in each consensus phase, each node in the committee nodes determines that the data included in block f has not been tampered with. If block f has not been tampered with, as Figure 8 shown, using the generated random number list, as well as the hash value of the latest confirmed block in the current blockchain and the current phase number as random sources, it checks whether the publisher of block f is the leader (leader node) of this phase that it believes, and at the same time determines whether block f is the first block published by the leader in the current phase. If the requirements are met, the node will check whether the requests / operations included in block f are legal ( Figure 8 the judgment of whether a transaction is legal in it), and whether it is a sub-block of the notarized block with the maximum height observed locally. If so, then the node will send a vote for this block to other nodes. The vote represents that the node signs the hash value of this block using its private key. As Figure 9 shown, if the node receives votes for this block from more than 2 / 3 of the nodes, then the node will locally set this block as the notarized block.
[0098] If a node observes locally that the blocks f proposed by the consensus in three consecutive phases are on the same branch and all have been notarized, then the node will locally confirm the first two of these three consecutive blocks and the blocks in front of this branch.
[0099] In addition, considering that in some cases, the network is very good and none of the committee member nodes participating in the consensus have committed malicious acts, then in some cases, a node may receive votes on a certain block from all the committee members participating in the consensus. Then at this time, it can be proved that all the committee members have observed that the parent block of this block has been notarized. Then if at this time the consensus phase corresponding to the block for which all nodes vote is consecutive with the consensus phases of its parent block and grandparent block, and the grandparent block has been confirmed, then at this time the parent block corresponding to the current block f can be directly confirmed, so as to achieve the effect of "pipelining" consensus, and at the same time such a method will not affect the security of the consensus.
[0100] For example, the leader node in the Internet of Things blockchain system successively receives block d, block e, and block f. Block e is the parent block of block f, and block d is the grandparent block of block f. Each node in the committee nodes where the leader node is located receives votes from 2 / 3 of the other nodes indicating that the content carried by block f is legal. Then, block f can be considered as a block notarized by the committee nodes. If the grandparent block d has also been notarized, then there is no need to verify the notarization of the parent block e. That is, block e can be directly broadcast in the committee nodes.
[0101] In one embodiment, at the end stage of each consensus epoch, the consensus committee will reach a consensus on whether each node has misbehaved (misbehavior means that the node sends destructive data to other nodes) during the consensus process of this epoch. If a consensus is finally reached that a certain node has misbehaved, an operation of halving the credibility of the corresponding node will be performed to reduce its subsequent possibility of becoming a member of the consensus committee and the possibility of becoming a consensus leader. Nodes that have not misbehaved will receive corresponding rewards. At the same time, an operation of doubling the credibility of the corresponding node will be performed to increase its subsequent possibility of becoming a member of the consensus committee and the possibility of becoming a consensus leader.
[0102] For example, in the Internet of Things blockchain, in a consensus epoch, committee node g sends virus data to each other committee node. Then, the other committee nodes will judge committee node g as a misbehaving node and remove committee node g from the committee members (that is, in the next consensus epoch, the blocks received by the leader node will no longer be broadcast to committee node g).
[0103] In summary, the present invention first selects, according to the proof-of-stake consensus mechanism PoS, committee nodes for the Internet of Things blockchain from several Internet of Things nodes; then generates a first random number corresponding to the block according to the hash value of the current block of the Internet of Things blockchain and the current stage number of the Internet of Things blockchain;
[0104] Finally, a leader node is selected from each committee node according to the credibility of each committee node and the first random number. Since the proof-of-stake consensus mechanism is only associated with the credibility of each Internet of Things node and does not involve other data, it can save computing power.
[0105] In addition, the present invention first alleviates the performance requirements of nodes in the Internet of Things environment by using a method such as Proof of Stake (PoS) that does not require competing in computing power. At the same time, a mechanism such as PoS is used to select some nodes in the system to become members of the committee, thereby improving the scalability of the blockchain system applying the present invention. Meanwhile, in combination with the consistent hashing algorithm, the randomness of leader election is achieved, and the function that the probability of a committee member pledging more margin to become a leader member is higher is realized. At the same time, the present invention utilizes a novel consensus mechanism, Streamlet, which is simple enough and has no timeout switching mechanism to conform to the Internet of Things scenario. Meanwhile, compared with the traditional method of the leader node sending a complete block to each node, it is proposed to use erasure coding to divide the blocks, so that the leader node only needs to send different encoded blocks to each node to reduce the bandwidth load of the leader node. At the same time, the confirmation mechanism of Streamlet is adjusted to enable faster block confirmation in the case of good network and honest committee members, thereby improving the performance of the system.
[0106] Exemplary device
[0107] This embodiment also provides an Internet of Things leader election device based on blockchain consensus. The device includes the following components:
[0108] A first election module, configured to elect committee nodes of the Internet of Things blockchain from a number of Internet of Things nodes according to the Proof of Stake consensus mechanism;
[0109] A random number generation module, configured to generate a first random number corresponding to the block according to the hash value of the current block of the Internet of Things blockchain and the current stage number of the Internet of Things blockchain;
[0110] A second election module, configured to elect a leader node from each of the committee nodes according to the credibility of each of the committee nodes and the first random number, where the credibility is used to measure the performance of the committee node in transmitting blocks.
[0111] Based on the above embodiment, the present invention also provides a terminal device, and its principle block diagram can be as Figure 10As shown. The terminal device includes a processor, a memory, a network interface, a display screen, and a temperature sensor connected via a system bus. Among them, the processor of the terminal device is used to provide computing and control capabilities. The memory of the terminal device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the terminal device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, it implements an Internet of Things blockchain broadcast method. The display screen of the terminal device can be a liquid crystal display screen or an electronic ink display screen. The temperature sensor of the terminal device is pre-set inside the terminal device and is used to detect the operating temperature of the internal device.
[0112] Those skilled in the art can understand that Figure 10 the block diagram of the principle shown only shows the block diagram of the partial structure related to the solution of the present invention, and does not constitute a limitation on the terminal device to which the solution of the present invention is applied. The specific terminal device may include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0113] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the embodiments provided by the present invention can include non-volatile and / or volatile memories. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or an external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than limiting it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An Internet of Things leader election method based on blockchain consensus, characterized in that, Including: According to the proof-of-stake consensus mechanism, select the committee nodes of the Internet of Things blockchain from a number of Internet of Things nodes; Generate a first random number corresponding to the block according to the hash value of the current block of the Internet of Things blockchain and the current stage number of the Internet of Things blockchain, where the current stage number is the consensus stage number of the blockchain of the Internet of Things at the current moment; Select a leader node from each of the committee nodes according to the credibility of each of the committee nodes and the first random number, where the credibility is used to standardize the performance of the committee node in transmitting blocks; The step of selecting the committee nodes of the Internet of Things blockchain from a number of Internet of Things nodes according to the proof-of-stake consensus mechanism includes: Statistical information on the sabotage behavior data generated by the Internet of Things nodes, where the sabotage behavior data information is information that interferes with the Internet of Things blockchain; According to the proof-of-stake consensus mechanism, obtain the credibility mechanism in the proof-of-stake consensus mechanism; Select the committee nodes of the Internet of Things blockchain from a number of Internet of Things nodes according to the sabotage behavior data information and the credibility mechanism; The step of selecting a leader node from each of the committee nodes according to the credibility of each of the committee nodes and the first random number, where the credibility is used to standardize the performance of the committee node in transmitting blocks, includes: Generate a second random number according to the credibility of each of the committee nodes and the attribute information of each of the committee nodes, where the attribute information of the committee node is the ID number of the committee node; Select a leader node from each of the committee nodes according to the first random number and the second random number, that is, find the second random number larger than the first random number from the list of the second random numbers. If it exists, determine the committee node corresponding to the second random number as the leader node. If it does not exist, find the smallest second random number from the list of the second random numbers and determine the committee node corresponding to the second random number as the leader node.
2. An Internet of Things blockchain broadcasting method for the Internet of Things leader election method based on blockchain consensus as described in claim 1, characterized in that, Including: The leader node screens out the target block from each of the original blocks according to the duration after the hash value of each of the original blocks is notarized, where the notarization is the verification information of the committee node where the leader node is located for the hash value; The leader node applies the erasure code technology to encode the target block into encoded content; The leader node broadcasts the encoded content to the committee nodes.
3. The Internet of Things blockchain broadcasting method according to claim 2, wherein, The step that the leader node applies the erasure code technology to encode the target block into encoded content includes: The leader node applies the erasure code technology to encode the data part of the target block into a block code; The leader node applies the Merkle tree technology to generate a Merkle root from the hash value of the target block; The leader node generates the encoded content according to the block code and the Merkle root.
4. The Internet of Things blockchain broadcasting method according to claim 2, characterized in that, The step that the leader node broadcasts the encoded content to the committee nodes includes: The leader node counts the total number of nodes formed by the committee nodes; The leader node divides the encoded content into several pieces of encoded content corresponding to the total number of nodes according to the total number of nodes; The leader node broadcasts several pieces of the encoded content to each of the committee nodes respectively.
5. The Internet of Things blockchain broadcasting method according to claim 2, characterized in that, It further includes: The leader node notarizes the hash value of the original block according to the Streamlet consensus protocol.
6. An Internet of Things leader election device based on blockchain consensus, characterized in that, The device includes the following components: A first election module, configured to elect committee nodes of the Internet of Things blockchain from several Internet of Things nodes according to the proof-of-stake consensus mechanism; A random number generation module, configured to generate a first random number corresponding to the block according to the hash value of the current block of the Internet of Things blockchain and the current stage number of the Internet of Things blockchain, where the current stage number is the consensus stage number of the blockchain of the Internet of Things at the current moment; A second election module, configured to elect a leader node from each of the committee nodes according to the credibility of each of the committee nodes and the first random number, where the credibility is used to measure the performance of the committee node in transmitting blocks; The step of electing committee nodes of the Internet of Things blockchain from several Internet of Things nodes according to the proof-of-stake consensus mechanism includes: Counting the data information of the disruptive behaviors generated by the Internet of Things nodes, where the data information of the disruptive behaviors is information that interferes with the Internet of Things blockchain; Obtaining the credibility mechanism in the proof-of-stake consensus mechanism according to the proof-of-stake consensus mechanism; Electing committee nodes of the Internet of Things blockchain from several Internet of Things nodes according to the data information of the disruptive behaviors and the credibility mechanism; The step of electing a leader node from each of the committee nodes according to the credibility of each of the committee nodes and the first random number, where the credibility is used to measure the performance of the committee node in transmitting blocks, includes: Generating a second random number according to the credibility of each of the committee nodes and the attribute information of each of the committee nodes, where the attribute information of the committee node is the ID number of the committee node; Electing a leader node from each of the committee nodes according to the first random number and the second random number, that is, finding a second random number larger than the first random number from the list of the second random numbers. If it exists, the committee node corresponding to the second random number is determined as the leader node. If it does not exist, find the smallest second random number from the list of the second random numbers and determine the committee node corresponding to the second random number as the leader node.
7. A terminal device, characterized in that, The terminal device includes a memory, a processor, and an Internet of Things leader election program based on blockchain consensus stored in the memory and executable on the processor. When the processor executes the Internet of Things leader election program based on blockchain consensus, the steps of the Internet of Things leader election method according to any one of claims 1-3 are implemented.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores an Internet of Things leader election program based on blockchain consensus. When the Internet of Things leader election program based on blockchain consensus is executed by a processor, the steps of the Internet of Things leader election method based on blockchain consensus according to any one of claims 1-3 are implemented.
Citation Information
Patent Citations
Block chain consensus method with security perception and response strategy
CN115357660A
Block chain performance adaptive optimization method based on hierarchical consensus and reinforcement learning
CN115378788A