Consensus method and device for wireless block chain network
By dynamically adjusting the competition window and forwarding probability in the consensus process of wireless blockchain network, the problem of low channel resource utilization and broadcast collision in wireless PBFT consensus is solved, and network operation efficiency and consensus success rate are improved.
Patent Information
- Application Number
- CN202411186012.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-27
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2044-08-27
AI Technical Summary
In the existing wireless PBFT consensus process, the size of the competition window cannot adapt to the dynamic characteristics of the node, resulting in low channel resource utilization and intensified broadcast message collisions. Traditional forwarding strategies cannot adapt to the consensus characteristics of wireless blockchain networks, affecting the consensus success rate.
In the consensus process of wireless blockchain network, the competition window parameters of the second consensus round are updated according to the competition window parameters of the first consensus round in the pre-prepare stage, and the forwarding is adjusted according to the redundant data counted by the counter array. Probability, dynamically adjust the forwarding probability of pre-prepare messages to ensure that the broadcast and verification of prepare messages in the prepare and commit stages are successful.
It effectively balances the network load, improves channel resource utilization, and improves the operation efficiency and consensus success rate of wireless blockchain networks.
Smart Images

Figure CN119316882A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a consensus method and device for a wireless blockchain network. Background Art
[0002] In the future, the exchange of massive amounts of information will rely on wireless communications. Wireless communications are limited by unstable wireless channels and scarce spectrum resources, which will affect the consensus of wireless blockchain networks. The PBFT (Practical Byzantine Fault Tolerance) algorithm commonly used in consortium chains uses the minimum contention window and the highest possible forwarding probability to broadcast messages in the traditional broadcast mode in wireless environments, which will generate a large number of message collisions and resource consumption, leading to the failure of consensus in wireless blockchain networks.
[0003] In the related technology, the existing wireless PBFT consensus process uses a fixed contention window size that cannot adapt to the dynamic characteristics of nodes. For example, a larger contention window will lead to lower channel resource utilization, while a smaller contention window will lead to serious message collision problems when the number of nodes increases. In addition, traditional forwarding strategies cannot adapt to the consensus characteristics of wireless blockchain networks. For example, a higher forwarding probability will waste channel resources and cause broadcast collisions, while a lower forwarding probability will affect the propagation of consensus messages and cause consensus failure. Summary of the invention
[0004] The present invention provides a consensus method and device for a wireless blockchain network, which are used to solve the problems in the prior art that the competition window size adopted in the wireless PBFT consensus process cannot adapt to the dynamic characteristics of the nodes, and the forwarding strategy adopted cannot adapt to the consensus characteristics of the wireless blockchain network, resulting in low channel resource utilization and aggravated broadcast message collisions, thereby improving the operating efficiency of the wireless blockchain network.
[0005] The present invention provides a consensus method of a wireless blockchain network, which is applied to a wireless blockchain network. The wireless blockchain network includes a master node and multiple replica nodes. Broadcasting is used to communicate between the nodes. Different nodes set counter arrays for different blocks in the wireless blockchain network. The counter arrays are used to count the redundancy between the corresponding consensus information of all nodes. The method includes: In the pre-prepare stage of the consensus process executed by the wireless blockchain network, the contention window parameters of the block corresponding to the second consensus round are updated according to the contention window parameters corresponding to the block corresponding to the first consensus round, and the forwarding probability of all nodes of the block corresponding to the second consensus round when broadcasting the pre-prepare message is adjusted according to the redundant data counted by the counter array of the block corresponding to the first consensus round, so as to obtain a prepare message; wherein the block corresponding to the first consensus round executes the consensus process before the block corresponding to the second consensus round; the pre-prepare message includes the consensus view number corresponding to the second consensus round, the number of the block corresponding to the second consensus round, the summary information of the block, the content of the contention window parameters, the key signature information and the content of the block; When the prepare message passes the broadcast and verification of the prepare phase and the commit phase of the consensus process in sequence, it is determined that the honest nodes have successfully reached consensus in the second consensus round, and the blocks corresponding to the second consensus round are linked to the wireless blockchain network, and the honest nodes belong to all the nodes.
[0006] According to a consensus method for a wireless blockchain network provided by the present invention, the blocks corresponding to the first consensus round include blocks where the master node consensus succeeds or blocks where the master node consensus fails; The updating of the contention window parameters of the blocks corresponding to the second consensus round according to the contention window parameters corresponding to the blocks corresponding to the first consensus round includes: In a case where the block corresponding to the first consensus round is a block on which the master node consensus succeeds, reducing the contention window size corresponding to the block corresponding to the first consensus round according to a first ratio to obtain a contention window for the block corresponding to the second consensus round; In the case where the block corresponding to the first consensus round is a block for which the master node consensus fails, the contention window size corresponding to the block corresponding to the first consensus round is enlarged according to a second ratio to obtain the contention window of the block corresponding to the second consensus round.
[0007] According to a consensus method for a wireless blockchain network provided by the present invention, the contention window size corresponding to the block corresponding to the first consensus round is reduced according to a first ratio to obtain the contention window size corresponding to the block corresponding to the second consensus round, including: ; in, is the contention window size of the block corresponding to the second consensus round, is the minimum value of the contention window size of each block, M is a positive integer; The step of enlarging the contention window size corresponding to the block corresponding to the first consensus round according to a second ratio to obtain the contention window size corresponding to the block of the second consensus round includes: ; in, is the contention window size of the block corresponding to the second consensus round, is the maximum value of the contention window size of each block, Is a positive integer.
[0008] According to a consensus method of a wireless blockchain network provided by the present invention, the forwarding probability of all nodes corresponding to the block of the second consensus round broadcasting the pre-prepare message according to the redundant data counted by the counter array of the block corresponding to the first consensus round includes: When the average value of the redundant data is greater than the redundant threshold, the forwarding probability is adjusted according to the following formula: ; in, p is the forwarding probability, Adjust the step size for the probability; When the average value of the redundant data is less than or equal to the redundant threshold, the forwarding probability is adjusted according to the following formula: .
[0009] According to a consensus method of a wireless blockchain network provided by the present invention, when the prepare message is broadcast and verified in the prepare phase and the commit phase of the consensus process in sequence, determining that the honest node has successfully reached consensus in the second consensus round includes: When the wireless blockchain network executes the prepare phase of the consensus process, and the honest nodes of the blocks corresponding to the second consensus round receive and verify the prepare messages sent by the first number of replica nodes, a commit message is generated, and the commit message is forwarded through the forwarding probability corresponding to the second consensus round; wherein the first number is determined based on the number of multiple nodes; When the wireless blockchain network executes the commit phase of the consensus process, and the honest nodes of the block corresponding to the second consensus round receive the commit messages sent by the second number of replica nodes and pass the verification, it is determined that the master node consensus of the block corresponding to the second consensus round is successful; wherein the second number is greater than the first number.
[0010] According to a consensus method of a wireless blockchain network provided by the present invention, after obtaining the prepare message, the method further includes: In a case where the prepare message fails to pass the broadcast and verification in any one of the prepare phase and the commit phase of the consensus process, it is determined that the master node consensus of the block corresponding to the second consensus round has failed.
[0011] The present invention also provides a consensus device for a wireless blockchain network, comprising: A configuration module, used for executing the pre-prepare phase of the consensus process in the wireless blockchain network, updating the contention window parameters of the block corresponding to the second consensus round according to the contention window parameters of the block corresponding to the first consensus round, and adjusting the forwarding probability of broadcasting the pre-prepare message of all nodes corresponding to the block of the second consensus round according to the redundant data counted by the counter array of the block corresponding to the first consensus round, to obtain a prepare message; The block corresponding to the first consensus round executes the consensus process before the block corresponding to the second consensus round; the pre-prepare message includes the consensus view number corresponding to the second consensus round, the number of the block corresponding to the second consensus round, the summary information of the block, the competition window parameters, the key signature information and the block content; the wireless blockchain network includes a master node and multiple replica nodes, and the nodes communicate with each other using broadcasting. Different nodes set counter arrays for different blocks in the wireless blockchain network, and the counter arrays are used to count the redundancy between the consensus information corresponding to all nodes; A consensus module is used to determine that the honest nodes have successfully reached consensus in the second consensus round when the prepare message passes through the broadcast and verification of the prepare phase and the commit phase of the consensus process in sequence, and to link the blocks corresponding to the second consensus round to the wireless blockchain network, and the honest nodes belong to all the nodes.
[0012] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, a consensus method for a wireless blockchain network as described above is implemented.
[0013] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a consensus method for a wireless blockchain network as described in any one of the above.
[0014] The present invention also provides a computer program product, comprising a computer program, which, when executed by a processor, implements a consensus method for a wireless blockchain network as described in any one of the above.
[0015] The consensus method and device of the wireless blockchain network provided by the present invention, in the pre-prepare stage of the consensus process, updates the contention window parameters of the block corresponding to the second consensus round according to the contention window parameters of the block corresponding to the first consensus round, adjusts the forwarding probability of all nodes corresponding to the block of the second consensus round when broadcasting the pre-prepare message according to the redundant data counted by the counter array of the block corresponding to the first consensus round, obtains the prepare message, and when the prepare message passes the broadcast and verification of the prepare stage and the commit stage of the consensus process in turn, determines that the honest node consensus is successful, and links the block corresponding to the second consensus round to the wireless blockchain network. The PBFT consensus process of the present invention automatically adjusts the size of the contention window and the forwarding probability in the network each time a new block is generated, effectively balances the network load, ensures the wireless PBFT consensus while ensuring the channel resource utilization, and improves the network operation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 This is one of the flow charts of the consensus method of the wireless blockchain network provided by the present invention.
[0018] Figure 2 This is the second flow chart of the consensus method of the wireless blockchain network provided by the present invention.
[0019] Figure 3 It is a structural schematic diagram of the consensus device of the wireless blockchain network provided by the present invention.
[0020] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0022] It should be noted that the consensus process executed by the wireless blockchain network includes the request phase, pre-prepare phase, prepare phase, commit phase and reply phase.
[0023] Among them, in the request stage, the client initiates a request, and after the master node receives the client's request, it will trigger the core consensus process.
[0024] In the pre-prepare phase, the master node receives the request sent by the client and constructs a pre-prepare message for it (or puts it in the cache waiting to batch construct a pre-prepare message). After receiving the pre-prepare message sent by the master node, the node verifies the signature and checks the request. After passing, it enters the prepare phase. After receiving the pre-prepare message sent by the master node, the node checks the following aspects: (1) the signature is correct, the message is correct; (2) the node is consistent with the master node in the pre-prepare message; there are no other pre-prepare messages that conflict with the pre-prepare message, etc.
[0025] In the prepare stage, after receiving the pre-prepare message sent by the master node, the node verifies the signature and checks the request. If passed, it constructs a prepare message and broadcasts it to other nodes (since the pre-prepare message is sent by the master node, the master node no longer participates in sending prepare messages, and each node receives the prepare message from the master node by default); after receiving the prepare message sent by other nodes, the node verifies the signature and checks whether the master node, sequence number and summary in the prepare message are consistent. If they are consistent, the message is prepared in this node, and the node enters the commit stage for this message.
[0026] In the commit phase, a commit message is constructed and broadcasted to other nodes, and commit messages sent by other nodes are received. After receiving commits sent by different nodes (including its own), the signature is verified and checked for commit messages. If the check passes, the client request corresponding to the message containing its own message is submitted and executed.
[0027] In the reply phase, after the node is executed, it constructs a reply message with the execution result and returns it to the client that sent the request; if the client receives multiple identical reply messages, it means that the request it sent is successfully executed.
[0028] Combine the following Figure 1-Figure 3 The consensus method and device of the wireless blockchain network of the present invention are described.
[0029] Figure 1 This is one of the flow charts of the consensus method of the wireless blockchain network provided by the present invention, such as Figure 1 As shown, the consensus method of the wireless blockchain network is applied to the wireless blockchain network. The wireless blockchain network includes a master node and multiple replica nodes. Broadcasting is used to communicate between the nodes. Different nodes set counter arrays for different blocks in the wireless blockchain network. The counter array is used to count the redundancy between the corresponding consensus information of all nodes. The method includes the following steps: Step 110, in the pre-prepare stage of executing the consensus process in the wireless blockchain network, the contention window parameters of the block corresponding to the second consensus round are updated according to the contention window parameters of the block corresponding to the first consensus round, and the forwarding probability of broadcasting the pre-prepare message by all nodes of the block corresponding to the second consensus round is adjusted according to the redundant data counted by the counter array of the block corresponding to the first consensus round to obtain a prepare message; wherein, the block corresponding to the first consensus round executes the consensus process before the block corresponding to the second consensus round; the pre-prepare message includes the consensus view number corresponding to the second consensus round, the number of the block corresponding to the second consensus round, the summary information of the block, the contention window parameters, the key signature information and the block content.
[0030] In this step, the contention window parameter includes the number of contention windows.
[0031] In this embodiment, the master node can be set according to user needs. For example, the master node of the current consensus round can be determined by view rotation.
[0032] In this embodiment, the IEEE 802.11 protocol is deployed in the wireless blockchain network, and nodes are set to communicate using broadcast; wherein each node sets a counter array for the block , used to count the redundancy of consensus information received from all nodes.
[0033] In this embodiment, if the block corresponding to the first consensus round is the first block to execute the consensus process, the contention window parameter in the pre-prepare message of the block corresponding to the first consensus round can be set according to user needs, and other information is determined by the attributes of the current consensus round and the current block; if the block corresponding to the first consensus round is not the first block to execute the consensus process, the contention window parameter in the block corresponding to the first consensus round and the message forwarding probability of the current block can be determined by the contention window parameter of the block corresponding to the previous consensus round and the redundant data counted by the counter array of the corresponding block; based on this, the contention window parameter and the message forwarding probability of the block corresponding to the second consensus round can be determined by the contention window parameter of the block corresponding to the first consensus round and the redundant data counted by the counter array.
[0034] In this embodiment, when entering the consensus process, the wireless blockchain network initialization parameters are first set, which include the number of nodes , transmit power, initial forwarding probability , forwarding probability adjustment step and redundancy threshold Etc.; Incorporate the above competition window information into the consensus process and ensure the credibility of the message through digital signatures.
[0035] In this embodiment, the pre-prepare message may be formatted as: ; in, Number the consensus view, is the block number, is the summary information of the block, Represents the set contention window size, Indicates that the master node key is used for signing. The content of the block.
[0036] In this embodiment, in the pre-prepare stage, the master node packages transactions to form a block corresponding to the second consensus round. The contention window size required for the block corresponding to the second consensus round is set. A pre-prepare message is generated after signing with its own key and the pre-prepare message is broadcast to other replica nodes. After the node receiving the block message verifies the legitimacy of the message (including the legitimacy of the signature and the legitimacy of the transaction), the contention window CW in the pre-prepare is set to the corresponding value in the message.
[0037] In this embodiment, the contention window of the block corresponding to the second consensus round may be the contention window corresponding to the block corresponding to the first consensus round adjusted according to the established rules; in this way, the master node of the next block stage adjusts the size of the contention window used for the next stage of consensus according to its own consensus situation, ensuring that the current contention windows of different blocks are sufficient to complete the consensus task, thereby adapting to the dynamic characteristics of the node and improving the consensus efficiency.
[0038] In this embodiment, the forwarding probability of the message in the block corresponding to the second consensus round can also be adjusted according to the redundant data counted by the counter array of the block corresponding to the first consensus round. For example, when the redundant data counted by the counter array of the block corresponding to the first consensus round is large, the forwarding probability is reduced. If the redundant data is small, the forwarding probability is increased, thereby improving the utilization rate of channel resources and reducing resource waste.
[0039] Step 120: When the prepare message passes through the broadcast and verification of the prepare phase and the commit phase of the consensus process in sequence, it is determined that the honest nodes have successfully reached consensus in the second consensus round, and the corresponding blocks of the second consensus round are linked to the wireless blockchain network. The honest nodes belong to all nodes.
[0040] In this step, in the PBFT algorithm, the honest node is a non-Byzantine node.
[0041] In this embodiment, in the prepare stage of the consensus process executed by the wireless blockchain network, after other replica nodes of the corresponding block of the second consensus round receive the pre-prepare message sent by the master node, they verify the signature and check the request. After the verification is passed, the prepare message is broadcast to other nodes; after the honest node receives the prepare message sent by other nodes, it verifies the signature and checks whether the master node, sequence number and summary in the prepare message are consistent. If they are consistent, the node enters the commit stage; in the commit stage, the commit message is broadcast to other nodes, and the commit messages sent by other replica nodes are received; after receiving the commit sent by different nodes (including its own), the signature is verified and the commit message is checked. After the check is passed, the client request corresponding to the message including its own is submitted for execution.
[0042] It should be noted that honest nodes include multiple nodes, and the nodes in the current stage must meet a certain number of message verification successes before entering the next stage.
[0043] In this embodiment, after obtaining the prepare message, the method further includes: if the prepare message fails to pass the broadcast and verification of any one of the prepare phase and the commit phase of the consensus process, determining that the honest nodes have failed to reach consensus in the second consensus round.
[0044] The consensus method of the wireless blockchain network provided by the embodiment of the present invention updates the contention window parameters of the block corresponding to the second consensus round according to the contention window parameters of the block corresponding to the first consensus round in the pre-prepare stage of the consensus process, adjusts the forwarding probability of all nodes corresponding to the block of the second consensus round when broadcasting the pre-prepare message according to the redundant data counted by the counter array of the block corresponding to the first consensus round, obtains the prepare message, and when the prepare message passes the broadcast and verification of the prepare stage and the commit stage of the consensus process in turn, determines that the honest node consensus is successful, and links the block corresponding to the second consensus round to the wireless blockchain network. The PBFT consensus process of the present invention automatically adjusts the size of the contention window and the forwarding probability in the network each time a new block is generated, effectively balances the network load, ensures the wireless PBFT consensus while ensuring the channel resource utilization, and improves the network operation efficiency.
[0045] In some embodiments, the block corresponding to the first consensus round includes a block on which the master node consensus succeeds or a block on which the master node consensus fails; updating the contention window parameters of the block corresponding to the second consensus round according to the contention window corresponding to the block corresponding to the first consensus round includes: when the block corresponding to the first consensus round is a block on which the master node consensus succeeds, reducing the contention window size corresponding to the block corresponding to the first consensus round by a first ratio to obtain the contention window of the block corresponding to the second consensus round; when the block corresponding to the first consensus round is a block on which the master node consensus fails, expanding the contention window size corresponding to the block corresponding to the first consensus round by a second ratio to obtain the contention window of the block corresponding to the second consensus round.
[0046] In this embodiment, if the master node consensus of the block corresponding to the first consensus round succeeds (the commit phase is completed), it is considered that the wireless environment is stable and the current contention window is sufficient to complete the consensus task, and the contention window of the block corresponding to the second consensus round is set to be reduced by a certain proportion to improve the consensus efficiency; if the master node consensus fails, it is considered that the message collision in the channel is serious and the current contention window is insufficient to complete the consensus task, and the contention window of the block corresponding to the second consensus round is set to be increased by a certain proportion.
[0047] Specifically, reducing the contention window corresponding to the block corresponding to the first consensus round according to the first ratio to obtain the contention window of the block corresponding to the second consensus round includes: ; in, is the competition window size of the block corresponding to the second consensus round, is the minimum value of the contention window size of each block, Mis a positive integer; the contention window corresponding to the block corresponding to the first consensus round is enlarged according to the second ratio, and the contention window corresponding to the block corresponding to the second consensus round includes: ; in, is the competition window size of the block corresponding to the second consensus round, is the maximum value of the contention window size of each block, Is a positive integer.
[0048] In this embodiment, under the IEEE 802.11 protocol The master node packages transactions into blocks, signs them with the key, and broadcasts the blocks and CW, starting the next stage of consensus.
[0049] The consensus method of the wireless blockchain network provided by the embodiment of the present invention reduces the contention window size corresponding to the block corresponding to the first consensus round according to a first ratio when the block corresponding to the first consensus round is a block on which the master node consensus succeeds; and expands the contention window size corresponding to the block corresponding to the first consensus round according to a second ratio when the block corresponding to the first consensus round is a block on which the master node consensus fails, thereby ensuring that the current contention windows of different blocks are sufficient to complete the consensus task, thereby further improving the consensus efficiency.
[0050] In some embodiments, adjusting the forwarding probability of the master node of the block corresponding to the second consensus round when broadcasting the pre-prepare message according to the redundant data counted by the counter array of the block corresponding to the first consensus round includes: when the average value of the redundant data is greater than the redundant threshold, adjusting the forwarding probability according to the following formula: ; in, p is the forwarding probability, Adjust the step size for the probability; When the average value of redundant data is less than or equal to the redundant threshold, the forwarding probability is adjusted according to the following formula: .
[0051] In this embodiment, the format of the prepare message is ,in Number the node itself, Indicates that the node key is used for signing.
[0052] The consensus method of the wireless blockchain network provided by the embodiment of the present invention can effectively improve the utilization rate of channel resources by improving the forwarding probability of the node itself when the consensus fails due to insufficient consensus data; and dynamically adjusting the forwarding probability according to the redundancy of the consensus data received by the node when the node consensus succeeds.
[0053] In some embodiments, when the prepare message passes the broadcast and verification of the prepare stage and the commit stage of the consensus process in sequence, determining that the honest nodes have successfully reached consensus in the second consensus round includes: when the wireless blockchain network executes the prepare stage of the consensus process, and the honest nodes of the blocks corresponding to the second consensus round receive the prepare messages sent by the first number of replica nodes and pass the verification, generating a commit message, and forwarding the commit message through the forwarding probability corresponding to the second consensus round; wherein the first number is determined based on the number of multiple nodes; when the wireless blockchain network executes the commit stage of the consensus process, and the honest nodes of the blocks corresponding to the second consensus round receive the commit messages sent by the second number of replica nodes and pass the verification, determining that the honest nodes have successfully reached consensus in the second consensus round; wherein the second number is greater than the first number.
[0054] In this embodiment, the first quantity can be obtained by the following formula: ,in ; Where N is the number of nodes, is the floor sign; the second quantity is equal to +1.
[0055] In this embodiment, the format of the commit message can be expressed as: In this embodiment, in the prepare phase, when the node receives ( ) other replica nodes send prepare messages for the corresponding blocks of the second consensus round and verify them, with probability Forward the first received prepare message; if the node receives Prepare messages from different replica nodes, the node (including the master node) enters the commit phase and generates a commit message for broadcast; if a node receives If the commit messages for the block corresponding to the second consensus round from different nodes (including the node itself) are verified and passed, the block consensus is considered successful, and the node will put the block corresponding to the second consensus round on the chain.
[0056] The consensus method of the wireless blockchain network provided by the embodiment of the present invention generates a commit message and forwards the commit message through the forwarding probability corresponding to the second consensus round when the honest nodes of the blocks corresponding to the second consensus round receive the prepare messages sent by the first number of replica nodes and pass the verification during the prepare stage of the consensus process executed by the wireless blockchain network, and determines that the honest node consensus is successful when the honest nodes of the blocks corresponding to the second consensus round receive the commit messages sent by the second number of replica nodes and pass the verification during the commit stage of the consensus process executed by the wireless blockchain network, thereby forming a closed loop of the consensus process executed by each block in the wireless blockchain network, and ensuring that the blocks corresponding to the nodes that have successfully reached consensus can be put on the chain, thereby improving the security of block on the chain.
[0057] Figure 2 This is the second flow chart of the consensus method of the wireless blockchain network provided by the present invention. Figure 2 In the illustrated embodiment, in the pre-prepare stage, the network initialization parameters are first set, and the master node broadcasts the pre-prepare message. The node sets the contention window of the current block according to the contention window of the previous block, and adjusts the message forwarding probability of the current block according to the redundant data counted by the counter array of the previous block to generate the corresponding prepare message. When other nodes verify the prepare message, The prepare message is forwarded to the replica node, and the replica node broadcasts the prepare message. In the prepare stage, when the current node receives 2f prepare messages, each node enters the commit stage, generates a commit message and broadcasts it by all nodes. In the commit stage, when the current node receives 2f+1 commit messages, it determines that the current block consensus is successful and puts the current block on the chain. Then it determines whether there is a next block to execute the consensus process. If so, adjust the contention window corresponding to the master node, and use the adjusted contention window as the contention window in the pre-prepare message of the next block. If the prepare message fails to pass the broadcast and verification of any of the prepare and commit stages of the consensus process, it is determined that the master node consensus of the corresponding block of the second consensus round has failed.
[0058] The consensus device of the wireless blockchain network provided by the present invention is described below. The consensus device of the wireless blockchain network described below and the consensus method of the wireless blockchain network described above can be referenced to each other.
[0059] Figure 3 It is a schematic diagram of the structure of the consensus device of the wireless blockchain network provided by the present invention, such as Figure 3As shown, the consensus device of the wireless blockchain network includes: a configuration module 310 and a consensus module 320.
[0060] Configuration module 310, used for executing the pre-prepare phase of the consensus process in the wireless blockchain network, updating the contention window parameters of the block corresponding to the second consensus round according to the contention window parameters of the block corresponding to the first consensus round, and adjusting the forwarding probability of broadcasting the pre-prepare message of all nodes corresponding to the block of the second consensus round according to the redundant data counted by the counter array of the block corresponding to the first consensus round, to obtain a prepare message; wherein the block corresponding to the first consensus round executes the consensus process before the block corresponding to the second consensus round; the pre-prepare message includes the consensus view number corresponding to the second consensus round, the number of the block corresponding to the second consensus round, the summary information of the block, the content of the contention window parameters, the key signature information and the content of the block; the wireless blockchain network includes a master node and multiple replica nodes, and the nodes communicate with each other by broadcasting, and different nodes set counter arrays for different blocks in the wireless blockchain network, and the counter arrays are used to count the redundancy between the consensus information corresponding to all nodes; The consensus module 320 is used to determine that the honest nodes have successfully reached consensus in the second consensus round when the prepare message passes through the broadcast and verification of the prepare phase and the commit phase of the consensus process in sequence, and to link the corresponding block of the second consensus round to the wireless blockchain network. The honest nodes belong to all nodes.
[0061] The consensus device of the wireless blockchain network provided by the embodiment of the present invention updates the contention window parameters of the block corresponding to the second consensus round according to the contention window parameters of the block corresponding to the first consensus round in the pre-prepare stage of the consensus process, adjusts the forwarding probability of all nodes corresponding to the block of the second consensus round when broadcasting the pre-prepare message according to the redundant data counted by the counter array of the block corresponding to the first consensus round, obtains the prepare message, and after the prepare message passes the broadcast and verification of the prepare stage and the commit stage of the consensus process in turn, determines that the master node consensus of the block corresponding to the second consensus round is successful, and links the block corresponding to the second consensus round to the wireless blockchain network. The PBFT consensus process of the present invention automatically adjusts the size of the contention window and the forwarding probability in the network each time a new block is generated, effectively balances the network load, ensures the wireless PBFT consensus while ensuring the utilization of channel resources, and improves the network operation efficiency.
[0062] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4As shown, the electronic device may include: a processor 410, a communications interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communications interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the consensus method of the wireless blockchain network, which is applied to the wireless blockchain network. The wireless blockchain network includes a master node and multiple replica nodes. The nodes communicate using broadcasting. Different nodes set counter arrays for different blocks in the wireless blockchain network. The counter array is used to count the redundancy between the consensus information corresponding to all nodes, including: in the pre-prepare stage of the consensus process executed by the wireless blockchain network, the contention window parameters of the blocks corresponding to the second consensus round are updated according to the contention window parameters of the blocks corresponding to the first consensus round, and the contention window parameters of the blocks corresponding to the first consensus round are adjusted according to the redundant data counted by the counter array of the blocks corresponding to the first consensus round. All nodes of the corresponding block broadcast the forwarding probability of the pre-prepare message to obtain the prepare message; wherein, the block corresponding to the first consensus round executes the consensus process before the block corresponding to the second consensus round; the pre-prepare message includes the consensus view number corresponding to the second consensus round, the number of the block corresponding to the second consensus round, the summary information of the block, the competition window parameters, the key signature information and the block content; when the prepare message passes the broadcast and verification of the prepare stage and the commit stage of the consensus process in turn, it is determined that the honest node succeeds in the second consensus round, and the block corresponding to the second consensus round is chained to the wireless blockchain network, and the honest node belongs to all nodes.
[0063] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0064] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the consensus method of the wireless blockchain network provided by the above methods. The method is applied to a wireless blockchain network. The wireless blockchain network includes a master node and multiple replica nodes. The nodes communicate using broadcasting. Different nodes are used to set counter arrays for different blocks in the wireless blockchain network. The counter array counts the redundancy between the corresponding consensus information of all nodes, including: in the pre-prepare stage of executing the consensus process in the wireless blockchain network, the contention window parameters of the blocks corresponding to the second consensus round are updated according to the contention window parameters of the blocks corresponding to the first consensus round, and According to the redundant data counted by the counter array of the block corresponding to the first consensus round, the forwarding probability of broadcasting the pre-prepare message of all nodes corresponding to the block of the second consensus round is adjusted to obtain the prepare message; wherein, the block corresponding to the first consensus round executes the consensus process before the block corresponding to the second consensus round; the pre-prepare message includes the consensus view number corresponding to the second consensus round, the number of the block corresponding to the second consensus round, the summary information of the block, the competition window parameters, the key signature information and the block content; when the prepare message passes the broadcast and verification of the prepare stage and the commit stage of the consensus process in sequence, it is determined that the honest node succeeds in the second consensus round of consensus, and the block corresponding to the second consensus round is chained to the wireless blockchain network, and the honest node belongs to all nodes.
[0065] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the consensus method of the wireless blockchain network provided by the above methods, the method being applied to the wireless blockchain network, the wireless blockchain network comprising a master node and multiple replica nodes, the nodes communicating with each other using broadcast, different nodes setting counter arrays for different blocks in the wireless blockchain network, the counter arrays being used to count the redundancy between the consensus information corresponding to all nodes, including: in the pre-prepare stage of executing the consensus process in the wireless blockchain network, updating the contention window parameters of the blocks corresponding to the second consensus round according to the contention window parameters of the blocks corresponding to the first consensus round, and updating the contention window parameters of the blocks corresponding to the first consensus round according to the counters of the blocks corresponding to the first consensus round; The redundant data counted by the counter array adjusts the forwarding probability of broadcasting the pre-prepare message by all nodes of the block corresponding to the second consensus round to obtain the prepare message; wherein, the block corresponding to the first consensus round executes the consensus process before the block corresponding to the second consensus round; the pre-prepare message includes the consensus view number corresponding to the second consensus round, the number of the block corresponding to the second consensus round, the summary information of the block, the competition window parameters, the key signature information and the block content; when the prepare message passes the broadcast and verification of the prepare stage and the commit stage of the consensus process in turn, it is determined that the honest node succeeds in the second consensus round, and the block corresponding to the second consensus round is chained to the wireless blockchain network, and the honest node belongs to all nodes.
[0066] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0067] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0068] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A consensus method for a wireless blockchain network, characterized in that: Applied to a wireless blockchain network, the wireless blockchain network includes a master node and multiple replica nodes, the nodes communicate using broadcasting, different nodes set counter arrays for different blocks in the wireless blockchain network, the counter arrays are used to count the redundancy between the corresponding consensus information of all nodes, the method includes: In the pre-prepare stage of the consensus process executed by the wireless blockchain network, the contention window parameters of the block corresponding to the second consensus round are updated according to the contention window parameters of the block corresponding to the first consensus round, and the forwarding probability of broadcasting the pre-prepare message of all nodes corresponding to the block of the second consensus round is adjusted according to the redundant data counted by the counter array of the block corresponding to the first consensus round, so as to obtain a prepare message; wherein the block corresponding to the first consensus round executes the consensus process before the block corresponding to the second consensus round; the pre-prepare message includes the consensus view number corresponding to the second consensus round, the number of the block corresponding to the second consensus round, the summary information of the block, the contention window parameters, the key signature information and the block content; When the prepare message passes the broadcast and verification of the prepare phase and the commit phase of the consensus process in sequence, it is determined that the honest nodes have successfully reached consensus in the second consensus round, and the blocks corresponding to the second consensus round are linked to the wireless blockchain network, and the honest nodes belong to all the nodes.
2. The consensus method of the wireless blockchain network according to claim 1, characterized in that: The blocks corresponding to the first consensus round include blocks where the master node consensus succeeds or blocks where the master node consensus fails; The updating of the contention window parameters of the blocks corresponding to the second consensus round according to the contention window parameters of the blocks corresponding to the first consensus round includes: In a case where the block corresponding to the first consensus round is a block on which the master node consensus succeeds, reducing the contention window size corresponding to the block corresponding to the first consensus round according to a first ratio to obtain a contention window for the block corresponding to the second consensus round; In the case where the block corresponding to the first consensus round is a block for which the master node consensus fails, the contention window size corresponding to the block corresponding to the first consensus round is enlarged according to a second ratio to obtain the contention window of the block corresponding to the second consensus round.
3. The consensus method of the wireless blockchain network according to claim 2, characterized in that: The step of reducing the contention window size corresponding to the block corresponding to the first consensus round according to a first ratio to obtain the contention window size corresponding to the block of the second consensus round includes: ; in, is the contention window size of the block corresponding to the second consensus round, is the minimum value of the contention window size of each block, M is a positive integer; The step of enlarging the contention window size corresponding to the block corresponding to the first consensus round according to a second ratio to obtain the contention window size corresponding to the block of the second consensus round includes: ; in, is the contention window size of the block corresponding to the second consensus round, is the maximum value of the contention window size of each block, Is a positive integer.
4. The consensus method of the wireless blockchain network according to claim 1, characterized in that: The step of adjusting the forwarding probability of all nodes of the block corresponding to the second consensus round broadcasting the pre-prepare message according to the redundant data counted by the counter array of the block corresponding to the first consensus round includes: When the average value of the redundant data is greater than the redundant threshold, the forwarding probability is adjusted according to the following formula: ; in, p is the forwarding probability, Adjust the step size for the probability; When the average value of the redundant data is less than or equal to the redundant threshold, the forwarding probability is adjusted according to the following formula: 。 5. The consensus method of the wireless blockchain network according to claim 1, characterized in that: When the prepare message passes through the broadcast and verification of the prepare phase and the commit phase of the consensus process in sequence, determining that the honest nodes have successfully reached consensus in the second consensus round includes: When the wireless blockchain network executes the prepare phase of the consensus process, and the honest nodes of the blocks corresponding to the second consensus round receive and verify the prepare messages sent by the first number of replica nodes, a commit message is generated, and the commit message is forwarded through the forwarding probability corresponding to the second consensus round; wherein the first number is determined based on the number of multiple nodes; When the wireless blockchain network executes the commit phase of the consensus process, and the honest nodes of the blocks corresponding to the second consensus round receive the commit messages sent by the second number of replica nodes and pass the verification, it is determined that the honest nodes have successfully reached consensus in the second consensus round; wherein the second number is greater than the first number.
6. The consensus method of the wireless blockchain network according to claim 1, characterized in that: After obtaining the prepare message, the method further includes: In a case where the prepare message fails to pass the broadcast and verification in any one of the prepare phase and the commit phase of the consensus process, it is determined that the master node consensus of the block corresponding to the second consensus round has failed.
7. A consensus device for a wireless blockchain network, characterized in that: include: A configuration module, used for executing the pre-prepare phase of the consensus process in the wireless blockchain network, updating the contention window parameters of the block corresponding to the second consensus round according to the contention window parameters of the block corresponding to the first consensus round, and adjusting the forwarding probability of broadcasting the pre-prepare message of all nodes corresponding to the block of the second consensus round according to the redundant data counted by the counter array of the block corresponding to the first consensus round, to obtain a prepare message; The block corresponding to the first consensus round executes the consensus process before the block corresponding to the second consensus round; the pre-prepare message includes the consensus view number corresponding to the second consensus round, the number of the block corresponding to the second consensus round, the summary information of the block, the competition window parameters, the key signature information and the block content; the wireless blockchain network includes a master node and multiple replica nodes, and the nodes communicate with each other using broadcasting. Different nodes set counter arrays for different blocks in the wireless blockchain network, and the counter arrays are used to count the redundancy between the consensus information corresponding to all nodes; A consensus module is used to determine that the honest nodes have successfully reached consensus in the second consensus round when the prepare message passes through the broadcast and verification of the prepare phase and the commit phase of the consensus process in sequence, and to link the blocks corresponding to the second consensus round to the wireless blockchain network, and the honest nodes belong to all the nodes.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the consensus method of the wireless blockchain network as described in any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, a consensus method for a wireless blockchain network as described in any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, a consensus method for a wireless blockchain network as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Block chain consensus method
CN115278604A
Online dynamic adaptive practical Byzantine consensus protocol implementation method
CN116722986A
Double auction method for wireless block chain transaction forwarding and verification in complex network
CN117217879A
Block chain parameter self-adaption method and device, computer equipment and storage medium
CN117240861A