An improved PBFT consensus algorithm for blockchain
By using smart contracts in the blockchain to sort and verify transaction information, the network message transmission in the PBFT consensus algorithm is reduced, the problem of low performance of the PBFT consensus algorithm is solved, and a more efficient blockchain node consensus process is achieved.
Patent Information
- Application Number
- CN202210359591.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-06
- Publication Date
- 2024-08-30
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the blockchain system, due to excessive network message transmission, the performance of the PBFT consensus algorithm is not high and the network overhead is large, which affects the system performance.
By establishing a smart contract for sorting transaction information and a smart contract for verifying information statistics in the blockchain, it replaces the master node in sorting transaction information, and verifies node signature information through hash values, reducing the network message transmission phase, thereby reducing network overhead.
It improves the network performance of the blockchain node consensus process, reduces network overhead, makes the sorting process more secure, and improves system performance.
Smart Images

Figure CN114745131B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to an improved PBFT consensus algorithm for blockchain. Background Art
[0002] Blockchain technology is a distributed ledger technology that is integrated based on P2P protocol, asymmetric encryption algorithm, consensus mechanism and distributed storage technology. Blockchain relies on P2P protocol to transmit transaction information between nodes and point-to-point transmission, relies on asymmetric encryption algorithm to ensure the security and reliability of transaction information during the transmission process, relies on consensus mechanism to ensure the consistency of blockchain node ledgers and the stable generation of new blocks, and relies on distributed storage technology to store transaction information.
[0003] The consensus algorithm is the core algorithm of the blockchain consensus mechanism. It can also be said that the blockchain consensus mechanism is composed of consensus algorithms. For example, the consensus algorithms commonly used in public chains are: Proof of Work (POW), Proof of Stake (POS) and Decentralized Proof of Stake (DPOS), etc. Each algorithm has its advantages and disadvantages.
[0004] The PBFT consensus algorithm is a consensus algorithm based on the alliance chain to select bookkeepers. The process of the PBFT consensus algorithm is as follows:
[0005] (1) A master node is elected from all nodes in the network, and the master node is responsible for generating new blocks.
[0006] (2) Each node broadcasts the new transaction to the entire network. The master node sorts the multiple transactions collected from the network that need to be included in the new block and stores them in a list, and broadcasts the list to the entire network.
[0007] (3) After receiving the transaction list, each node executes the transaction according to the sorting simulation; after all transactions are executed, the hash summary of the new block is calculated based on the transaction results and broadcast to the entire network.
[0008] (4) If a node receives 2f (f is the tolerable number of malicious nodes) summaries from other nodes that are the same as its own, it broadcasts a commit message to the entire network.
[0009] (5) If a node receives 2f+1 commit messages, it can formally submit the new block and its transactions to the local blockchain and status database.
[0010] Each block in the PBFT consensus process is generated by a unique master node, so there is no possibility of forking; however, in the algorithm, too many network messages need to be transmitted in steps 3 and 4, which will cause a lot of network overhead; therefore, the performance of the blockchain system based on the PBFT consensus algorithm is not high. Summary of the invention
[0011] The purpose of the present invention is to overcome the above problems existing in the prior art and to greatly improve the technical effect based on the original technology; to this end, the present invention provides a PBFT improved consensus algorithm for blockchain.
[0012] In order to achieve the above-mentioned purpose, the technical solution of the first aspect of the present invention provides a PBFT improved consensus algorithm for blockchain, which is applicable to consortium chains, including:
[0013] Establishing a smart contract for sorting blockchain transaction information and a smart contract for verifying information statistics, sorting the transaction information obtained within a specific time in the blockchain by activating the smart contract for sorting transaction information, and determining the legitimacy of the transaction information verified by each node of the blockchain by activating the smart contract for verifying information statistics;
[0014] Each node on the blockchain calculates the total hash value of the sorted transaction information and sends the calculation result to the blockchain network system;
[0015] Activate the smart contract for blockchain verification information statistics, verify the node signature information, compare the hash value converted by each node from the sorted transaction information with the actual hash value of the sorted transaction information, and statistically verify whether the relationship between the number of nodes with consistent hash values and the total number of nodes meets the upper limit of the number of malicious nodes that the blockchain can tolerate;
[0016] The blockchain sends transaction information with a consistent hash value to each node, and each node in the blockchain sends the received information with a consistent hash value to other nodes. The node that first receives the information with a consistent hash value sent by all other nodes will be the account keeper of the blockchain.
[0017] Furthermore, the smart contract for sorting blockchain transaction information includes: activating the smart contract, obtaining legal transaction information of the blockchain within a period of time, and temporarily storing the legal transaction information in a transaction pool, which is a virtual storage structure of the blockchain, used to store legal transaction information verified by nodes.
[0018] Furthermore, the smart contract for sorting blockchain transaction information also includes: randomly sorting the acquired transaction information, converting the sorted transaction information into hash values, and storing the converted hash values in a transaction pool control group.
[0019] Furthermore, the smart contract for verifying information statistics includes: when the smart contract is activated, the number of nodes whose hash values converted by the statistical nodes from the sorted transaction information are the same as the hash values of the control group in the transaction pool is the same.
[0020] Furthermore, the smart contract for verifying information statistics also includes: whether the number of nodes whose hash values converted from the sorted transaction information are the same as the hash values of the control group in the transaction pool meets the upper limit of the number of malicious nodes that the blockchain can tolerate, and the upper limit of the number of malicious nodes that the blockchain can tolerate is: 3f+1<n, where f is the number of malicious nodes and n is the total number of nodes in the blockchain that participate in verifying transaction information.
[0021] Furthermore, each node on the blockchain performs a total hash value calculation on the sorted transaction information, including: each node on the blockchain uses the SHA256 algorithm to calculate the total hash value of the received sorted transaction information, and sends the calculation result to the blockchain system.
[0022] Furthermore, verifying the node signature information includes: when the blockchain system receives the total hash value of the transaction information sent by the first node, activating the smart contract for blockchain verification information statistics; activating the smart contract, first verifying the signature information of each node.
[0023] Furthermore, verifying the node signature information also includes: determining the identity information of each node in the blockchain and counting the number of nodes participating in the hash operation by counting the signature information of each node in the blockchain.
[0024] Furthermore, whether the relationship between the number of hash value nodes and the total number of nodes that are consistent with the statistical verification meets the upper limit of the number of malicious nodes that the blockchain can tolerate includes: whether the relationship between the number of hash value nodes and the total number of nodes that are consistent with the verification meets the upper limit of the number of malicious nodes that the blockchain can tolerate, it is considered that the blockchain system has reached a consensus on the transaction information, and the information on the consensus on the transaction information is broadcast in the blockchain and fed back to each node of the blockchain.
[0025] Furthermore, the node that first receives the information with the same hash value sent by all other nodes is used as the bookkeeper of the blockchain, which also includes: at the same time as the bookkeeper is generated, the blockchain generates a new block, and the selected bookkeeping node writes other information in the transaction pool except the control group transaction information into the newly formed block.
[0026] Beneficial Effects of the Invention
[0027] The present invention replaces PBFT with a master node to sort transaction information by establishing a smart contract for sorting blockchain transaction information, making the sorting process safer. At the same time, the smart contract for activating verification information statistics is used to perform consensus statistics on the transaction information verified by each node. In the node consensus process, the excessive amount of network messages transmitted in the two stages of the PBFT consensus algorithm, which leads to excessive overhead, is reduced to one stage, thereby reducing the network overhead of the PBFT node consensus process. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The above advantages and some hidden advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0029] Figure 1 :A flowchart of the PBFT improved consensus algorithm for blockchain. DETAILED DESCRIPTION
[0030] In order to more clearly understand the above-mentioned objects, features and advantages of the present invention, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0031] It should be noted that many specific details are set forth in the following description to facilitate a full understanding of the present invention. However, the present invention may also have other implementations and variations thereof. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0032] like Figure 1 As shown, a flowchart of a PBFT improved consensus algorithm of a blockchain according to the present invention is applicable to a consortium chain, including: step S200, establishing a smart contract for blockchain transaction information sorting and a smart contract for verification information statistics, sorting the transaction information obtained within a specific time in the blockchain by activating the smart contract for transaction information sorting, and judging the legitimacy of the transaction information verified by each node of the blockchain by activating the smart contract for verification information statistics; step S201, each node on the blockchain performs a total hash value calculation on the sorted transaction information, and sends the calculation result to the blockchain network system; step S202, activating the smart contract for blockchain verification information statistics, comparing the hash value converted by each node from the sorted transaction information and the actual hash value of the sorted transaction information by verifying the node signature information, and statistically verifying whether the relationship between the number of nodes with consistent hash values and the total number of nodes meets the upper limit of the number of malicious nodes that the blockchain can tolerate; step S203, the blockchain sends information that the transaction information hash value is consistent to each node, and each node of the blockchain sends the received hash value consistent information to other nodes, and the node that first receives the information with consistent hash values sent by all other nodes is used as the accountant of the blockchain.
[0033] In this embodiment, specifically, by establishing a smart contract for sorting transaction information and a smart contract for verifying information statistics in the blockchain, the smart contract is written into the blockchain, the transaction information obtained within a specific time in the blockchain is sorted by activating the smart contract for sorting transaction information, and the legitimacy of the transaction information verified by each node of the blockchain is determined by activating the smart contract for verifying information statistics; after sorting the transaction information obtained within a specific time in the blockchain, the transaction information is sent to each node of the blockchain, each node on the blockchain performs a total hash value calculation on the sorted transaction information, and sends the calculation result to the blockchain network system; then, the smart contract for blockchain verification information statistics is activated, and by verifying the node signature information, the hash value converted by each node from the sorted transaction information and the actual hash value of the sorted transaction information are compared to see whether they are consistent, and the relationship between the number of nodes with consistent hash values and the total number of nodes is statistically verified to see whether it meets the upper limit of the number of malicious nodes that the blockchain can tolerate; if the conditions are met, the blockchain sends information that the hash value of the transaction information is consistent to each node, and each node of the blockchain sends the received hash value consistent information to other nodes, and the node that first receives the information with consistent hash values sent by all other nodes is used as the accountant of the blockchain.
[0034] Step S200, establishing a smart contract for sorting blockchain transaction information and a smart contract for verifying information statistics, sorting the transaction information obtained within a specific time in the blockchain by activating the smart contract for sorting transaction information, and judging the legitimacy of the transaction information verified by each node of the blockchain by activating the smart contract for verifying information statistics; specifically, adding codes containing the smart contract for sorting blockchain transaction information and the smart contract for verifying information statistics to the blockchain code; activating the smart contract by meeting certain conditions for activating the smart contract; respectively, sorting the transaction information obtained within a specific time in the blockchain by activating the smart contract for sorting transaction information, and judging the legitimacy of the transaction information verified by each node of the blockchain by activating the smart contract for verifying information statistics.
[0035] Specifically, activating the smart contract for sorting blockchain transaction information obtains legal transaction information of the blockchain within a period of time and temporarily stores the legal transaction information in a transaction pool, which is a virtual storage structure of the blockchain for storing legal transaction information verified by nodes.
[0036] In the above technical solution, specifically, the smart contract for activating blockchain transaction information sorting randomly sorts the acquired transaction information, converts the sorted transaction information into a hash value, and saves the converted hash value in the transaction pool control group.
[0037] In the above technical solution, the smart contract for verifying information statistics is activated, and the number of nodes whose hash values converted by the statistical nodes for the sorted transaction information are the same as the hash values of the control group in the transaction pool is counted; in addition, the nodes whose hash values converted by the nodes for the sorted transaction information are different from the hash values of the control group in the transaction pool are called malicious nodes.
[0038] Subsequently, the number of nodes whose hash values converted from the sorted transaction information are the same as the hash values of the control group in the transaction pool is counted to see whether they meet the upper limit of the number of malicious nodes that the blockchain can tolerate. The upper limit of the number of malicious nodes that the blockchain can tolerate is: 3f+1<n, where f is the number of malicious nodes and n is the total number of nodes in the blockchain that participate in verifying transaction information.
[0039] In step S201, each node on the blockchain calculates the total hash value of the sorted transaction information and sends the result of the calculation to the blockchain network system; specifically, each node on the blockchain receives the sorted transaction information sent by the blockchain system, calculates the total transaction information hash value, and broadcasts the calculated total transaction information hash value throughout the blockchain network.
[0040] Preferably, each node on the blockchain performs a method for calculating the total hash value of the sorted transaction information: each node on the blockchain uses the SHA256 algorithm to calculate the total hash value of the received sorted transaction information, and sends the calculation result to the blockchain system.
[0041] Step S202, activate the smart contract for blockchain verification information statistics, compare whether the hash value converted by each node from the sorted transaction information is consistent with the actual hash value of the sorted transaction information by verifying the node signature information, and statistically verify whether the relationship between the number of nodes with consistent hash values and the total number of nodes meets the upper limit of the number of malicious nodes that the blockchain can tolerate; specifically, by activating the smart contract for blockchain verification information statistics, first, activate the smart contract to identify the node identity by verifying the node signature information; compare whether the hash value converted by each node from the sorted transaction information is consistent with the actual hash value of the sorted transaction information, and statistically verify whether the relationship between the number of nodes with consistent hash values and the total number of nodes meets the upper limit of the number of malicious nodes that the blockchain can tolerate.
[0042] Specifically, the condition for activating the smart contract for blockchain verification information statistics is: when the blockchain system receives the total hash value of the transaction information sent by the first node, the smart contract for blockchain verification information statistics is activated; to activate the smart contract, the signature information of each node is first verified.
[0043] In the above technical solution, the signature information of each node in the blockchain is counted to determine the identity information of each node in the blockchain, and the number of nodes participating in the hash operation is counted.
[0044] In the above technical solution, whether the relationship between the number of hash value nodes and the total number of nodes that are consistent in statistical verification meets the upper limit of the number of malicious nodes that the blockchain can tolerate includes: whether the relationship between the number of hash value nodes and the total number of nodes that are consistent in the verification meets the upper limit of the number of malicious nodes that the blockchain can tolerate, and then the blockchain system reaches a consensus on the transaction information, and broadcasts the information on the consensus on the transaction information in the blockchain, and feeds back to each node of the blockchain.
[0045] In the above technical solution, if the relationship between the number of hash value nodes that verify the consistency and the total number of nodes meets the upper limit of the number of malicious nodes that the blockchain can tolerate, that is, it meets: 3f+1<n, where f is the number of malicious nodes and n is the total number of nodes in the blockchain that participate in verifying transaction information, then all nodes are considered legal; if the relationship between the number of hash value nodes that verify the consistency and the total number of nodes does not meet the upper limit of the number of malicious nodes that the blockchain can tolerate, that is, it does not meet: 3f+1<n, where f is the number of malicious nodes and n is the total number of nodes in the blockchain that participate in verifying transaction information, then all nodes are considered illegal and this round of consensus is terminated.
[0046] S203, the blockchain sends information with a consistent hash value of transaction information to each node, and each node of the blockchain sends information with a consistent hash value received to other nodes, and the node that first receives information with a consistent hash value sent by all other nodes is used as the account keeper of the blockchain; specifically, the blockchain sends information with a consistent hash value of transaction information to each node, and each node of the blockchain sends information with a consistent hash value received to other nodes, and each node of the blockchain counts information with a consistent hash value sent from other nodes, and the node that first counts information with a consistent hash value of all other nodes is used as the account keeper of the blockchain.
[0047] In the above technical solution, specifically, the node that first receives the information with the same hash value sent by all other nodes is used as the account keeper of the blockchain: the blockchain node receives the information with the same hash value sent by other nodes, and counts and summarizes the signature information of other nodes; when a node first receives and counts the information with the same hash value sent by all other online nodes, the node is regarded as the winner of this round, that is, the node becomes the accounting node of this round.
[0048] Preferably, the blockchain generates a new block at the same time as the bookkeeper generates it, and the selected bookkeeping node writes other information in the transaction pool except the control group transaction information into the newly formed block.
[0049] It should be understood that the above-mentioned embodiments are one or more embodiments of the present invention, and there are many other embodiments and variations thereof based on the present invention; the variations and modifications made by ordinary technicians in this industry through the present invention without making pioneering innovations all fall within the scope of protection of the present invention.
Claims
1. A PBFT improved consensus method for blockchain, It is characterized in that The consensus method includes: Establish a smart contract for blockchain transaction information sorting and a smart contract for verification information statistics, sort the transaction information obtained within a specific time in the blockchain by activating the smart contract for transaction information sorting, and determine the legitimacy of the transaction information verified by each node of the blockchain by activating the smart contract for verification information statistics; the specific time includes: the period during which the smart contract for transaction information sorting is activated, and the legal transaction information of the blockchain obtained during the period during which the smart contract for transaction information sorting is activated; temporarily store the legal transaction information in a transaction pool, which is a virtual storage structure of the blockchain for storing transaction information verified as legal by nodes; Each node on the blockchain calculates the total hash value of the sorted transaction information and sends the calculation result to the blockchain network system; Activate the smart contract for blockchain verification information statistics, verify the node signature information, compare the hash value converted by each node from the sorted transaction information with the actual hash value of the sorted transaction information, and statistically verify whether the relationship between the number of nodes with consistent hash values and the total number of nodes meets the upper limit of the number of malicious nodes that the blockchain can tolerate; The blockchain sends transaction information with a consistent hash value to each node, and each node in the blockchain sends the received information with a consistent hash value to other nodes. The node that first receives the information with a consistent hash value sent by all other nodes will be the account keeper of the blockchain.
2. According to the PBFT improved consensus method of a blockchain according to claim 1, It is characterized in that The smart contract for sorting blockchain transaction information also includes: randomly sorting the acquired transaction information, converting the sorted transaction information into hash values, and storing the converted hash values in a transaction pool control group.
3. According to the PBFT improved consensus method of a blockchain according to claim 1, It is characterized in that The smart contract for verifying information statistics includes: when the smart contract is activated, the number of nodes whose hash values converted by the statistical nodes from the sorted transaction information are the same as the hash values of the control group in the transaction pool.
4. According to the PBFT improved consensus method of a blockchain according to claim 1, It is characterized in that The smart contract for verifying information statistics also includes: whether the number of nodes whose hash values converted from the sorted transaction information are the same as the hash values of the control group in the transaction pool meets the upper limit of the number of malicious nodes that the blockchain can tolerate, and the upper limit of the number of malicious nodes that the blockchain can tolerate is: , where f is the number of malicious nodes and n is the total number of nodes in the blockchain participating in verifying transaction information.
5. According to the PBFT improved consensus method of a blockchain according to claim 1, It is characterized in that The calculation of the total hash value of the sorted transaction information by each node on the blockchain includes: each node on the blockchain uses the SHA256 algorithm to calculate the total hash value of the received sorted transaction information, and sends the calculation result to the blockchain system.
6. According to the PBFT improved consensus method of a blockchain according to claim 1, It is characterized in that The verification of the node signature information includes: when the blockchain system receives the total hash value of the transaction information sent by the first node, activating the smart contract for blockchain verification information statistics; activating the smart contract, first verifying the signature information of each node.
7. According to the PBFT improved consensus method of a blockchain according to claim 1, It is characterized in that The verifying node signature information also includes: determining the identity information of each node in the blockchain and counting the number of nodes participating in the hash operation by counting the signature information of each node in the blockchain.
8. According to the PBFT improved consensus method of a blockchain according to claim 1, It is characterized in that Whether the relationship between the number of hash value nodes and the total number of nodes that are consistent with the statistical verification meets the upper limit of the number of malicious nodes that the blockchain can tolerate includes: If the relationship between the number of hash value nodes and the total number of nodes that are verified to be consistent meets the upper limit of the number of malicious nodes that the blockchain can tolerate, it is considered that the blockchain system has reached a consensus on the transaction information, and the information on the consensus on the transaction information is broadcast in the blockchain and fed back to each node of the blockchain.
9. According to the PBFT improved consensus method of a blockchain according to claim 1, It is characterized in that The node that first receives the information with the same hash value sent by all other nodes as the bookkeeper of the blockchain also includes: at the same time as the bookkeeper is generated, the blockchain generates a new block, and the selected bookkeeping node writes other information in the transaction pool except the control group transaction information into the newly formed block.
Citation Information
Patent Citations
A decentralized chip research and development transaction data storage method and system based on a block chain
CN109684519A
Block chain data archiving method and device and computer readable storage medium
CN111209346A
