WO2023045972A1 - 一种区块链系统的共识方法及装置 - Google Patents
一种区块链系统的共识方法及装置 Download PDFInfo
- Publication number
- WO2023045972A1 WO2023045972A1 PCT/CN2022/120220 CN2022120220W WO2023045972A1 WO 2023045972 A1 WO2023045972 A1 WO 2023045972A1 CN 2022120220 W CN2022120220 W CN 2022120220W WO 2023045972 A1 WO2023045972 A1 WO 2023045972A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- node
- election
- proof
- master node
- consensus
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 50
- 238000012795 verification Methods 0.000 claims abstract description 110
- 238000004422 calculation algorithm Methods 0.000 claims abstract description 84
- 230000007246 mechanism Effects 0.000 claims abstract description 30
- 230000008520 organization Effects 0.000 claims description 116
- 238000012545 processing Methods 0.000 claims description 15
- 230000008569 process Effects 0.000 abstract description 10
- 238000004364 calculation method Methods 0.000 abstract description 6
- 238000010586 diagram Methods 0.000 description 10
- 238000005516 engineering process Methods 0.000 description 8
- 238000004590 computer program Methods 0.000 description 7
- 230000002159 abnormal effect Effects 0.000 description 4
- 230000006870 function Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 230000008859 change Effects 0.000 description 1
- 230000001010 compromised effect Effects 0.000 description 1
- 238000012790 confirmation Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000001568 sexual effect Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 230000001131 transforming effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q20/00—Payment architectures, schemes or protocols
- G06Q20/38—Payment protocols; Details thereof
- G06Q20/382—Payment protocols; Details thereof insuring higher security of transaction
- G06Q20/3825—Use of electronic signatures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q20/00—Payment architectures, schemes or protocols
- G06Q20/38—Payment protocols; Details thereof
- G06Q20/40—Authorisation, e.g. identification of payer or payee, verification of customer or shop credentials; Review and approval of payers, e.g. check credit lines or negative lists
- G06Q20/401—Transaction verification
Definitions
- the present invention relates to the field of financial technology (Fintech), in particular to a consensus method and device for a block chain system.
- the blockchain system is a non-centered open distributed system, which can be used to register and issue digital assets, property rights certificates, points, etc., and transfer, pay and trade in a point-to-point manner.
- the blockchain system has the advantages of being completely open, tamper-resistant, and preventing multiple payments, and does not rely on any trusted third party.
- the blockchain system needs to design a mechanism to achieve consensus on the order of transactions that occur within a similar period of time. This algorithm for reaching a consensus on the sequence of transactions within a time window is called a "consensus mechanism".
- the network complexity of the PBFT consensus algorithm is proportional to the square of the node size (for example, the network complexity is the square of the number of nodes), the supported blockchain network scale is limited, and the amount of calculation in the consensus process is large, which limits the blockchain system. scalability.
- Embodiments of the present invention provide a consensus method and device for a blockchain system, which are used to reduce the calculation amount of the consensus process in the blockchain system, reduce the complexity of the PBFT consensus algorithm network, and increase the supportable blockchain network scale. Improve the scalability of the blockchain system.
- an embodiment of the present invention provides a consensus method of a blockchain system, the blockchain system includes a plurality of node organizations, and each node organization has a plurality of nodes; the method includes:
- the first master node in the node organization For at least one node organization, the first master node in the node organization generates an election certificate and sends it to the first election node in the node organization; the first master node is each node in the node organization based on Raft Determined by the consensus algorithm;
- the first master node generates an election proof transaction based on the received multiple election proof signatures and the election proof; certified to be signed;
- the first master node serves as the PBFT consensus node of the blockchain system after the blockchain system determines that the election proves that the transaction consensus is successful based on the PBFT consensus algorithm.
- the first master node is equivalent to the leader of the master node voted by the election nodes in the node organization when the blockchain system is initialized; through the consensus nodes participating in the PBFT consensus algorithm in the node organization of the blockchain system Selection, all nodes in the blockchain system are not used as consensus nodes participating in the PBFT consensus algorithm, thereby reducing the number of consensus nodes participating in the PBFT consensus algorithm, thereby reducing the amount of calculations in the consensus process in the blockchain system and reducing the PBFT
- the complexity of the consensus algorithm network increases the supportable blockchain network scale and improves the scalability of the blockchain system; and the data consistency in the blockchain system is guaranteed by participating in the PBFT consensus algorithm nodes, because participating
- the consensus node of the PBFT consensus algorithm is the master node selected according to the Raft consensus algorithm in the node organization.
- the master node is used to send the block consensus results to the election nodes in the node organization, thus ensuring the data consistency of each node in the node organization.
- the PBFT consensus node of the blockchain system also includes:
- the first master node receives the first consensus information packet
- the first master node determines that the sender of the first information packet to be consensus is the consensus node in the system consensus node record
- consensus is performed on the first information packet to be consensus based on the PBFT consensus algorithm.
- the first master node after the first master node is used as the PBFT consensus node of the blockchain system, it is equivalent to that the first master node has been verified by each node of the blockchain system, ensuring the security of the first master node.
- the node writes the first master node into the local system consensus node record of each node, so that when the first master node is not switched, it only needs to determine that the first master node is the consensus node in the system consensus node record, then
- the first master node is used as the PBFT consensus node of the blockchain system to avoid operations such as repeated generation of election certificates by the first master node every time a block to be consensus is agreed upon, thereby reducing computational overhead.
- the first master node in the node organization generates an election certificate, including:
- the first master node in the node mechanism determines the sequence number of the block with the largest block height in the block chain system
- the first master node generates a first verification sequence number based on the sequence number of the block with the largest block height
- the first master node signs the first verification sequence number and the identity of the first master node to obtain a first election signature
- the first master node generates the election certificate according to the first verification sequence number, the identifier of the first master node and the first election signature;
- the first verification requirements include:
- the identity of the node in the election certificate is consistent with the identity of the master node in the node organization
- the election signature in the election certificate is valid.
- the first verification sequence number is used to ensure that each election certificate is unique, preventing malicious nodes from replaying the election certificate.
- the first master node generates an election proof transaction based on the received multiple election proof signatures and the election proof, including:
- the first master node determines that the number of received election proof signatures is not less than half of the number of nodes in the node organization, it synthesizes the received election proof signatures into a signature list;
- the first master node generates an election proof transaction based on the signature list and the election proof.
- the signature list is generated when the first master node confirms that the number of election certificate signatures received is not less than half of the number of nodes in the node organization. Based on the Raft consensus algorithm, the minority obeys the majority, ensuring the first The security and accuracy of the master node in the node organization.
- the election proves that the transaction consensus is successful, including:
- the method also includes:
- the second master node After the first master node of the node organization is rotated to be the second master node, the second master node generates a switching certificate and sends it to the second election node in the node organization; the second master node is the Each node in the node organization is determined based on the Raft consensus algorithm; the second election node is each node in the node organization except the second master node;
- the second master node generates handover proof information based on the received multiple handover proof signatures and the handover proof;
- the handover proof signature is the handover certificate after the second election node determines that the handover proof satisfies the first verification requirement. certified to be signed;
- the second master node performs consensus on the second message packet to be agreed based on the PBFT consensus algorithm in the blockchain system.
- the second master node is equivalent to the new master node Leader that is rotated after the first master node is abnormal; after the master node in the node mechanism is switched, by generating switching proof information and sending the switching proof information to to each consensus node in the block system, so that each node in the block chain system determines that the second master node after the switch can be used as a consensus node that uses the PBFT consensus algorithm to carry out consensus on the second message package to be consensus, which improves the present invention Flexibility of technical solutions.
- the method also includes:
- the second master node After the first master node of the node organization is rotated to be the second master node, the second master node generates a switching certificate and sends it to the second election node in the node organization; the second master node is the node Each node in the organization is determined based on the Raft consensus algorithm; the second election node is each node in the node organization except the second master node;
- the second master node generates a handover proof transaction based on the received multiple handover proof signatures and the handover proof;
- the handover proof signature is a transaction for the handover proof after the second election node determines that the handover proof satisfies the first verification requirement. certified to be signed;
- the second master node serves as the PBFT consensus node of the blockchain system after the blockchain system determines that the switching proof transaction consensus is successful based on the PBFT consensus algorithm.
- a switch certificate transaction is generated, which is equivalent to using the switch certificate information as a transaction, which is issued by the blockchain system
- Each node conducts a consensus. If the consensus is successful, the second master node will be written into the local system consensus node record of each node, so as to avoid sending the switching proof information every time it participates in the PBFT consensus, and prevent the second master node after switching.
- the repeated consensus of nodes reduces the complexity of computing resources and consensus verification, and improves consensus efficiency.
- the second master node generates a switching certificate, including:
- the second master node determines the serial number of the block with the largest block height in the blockchain system, and generates a second verification serial number based on the serial number of the block with the largest block height;
- the second master node signs the second verification sequence number and the identity of the second master node to obtain a second election signature
- the second master node generates a switching certificate according to the second verification sequence number, the identifier of the first master node, the identifier of the second master node, and the second election signature;
- the second verification requirement includes:
- the identity of the first master node in the handover proof information is recorded in the system consensus node record;
- the second verification sequence number in the switching certification information and the sequence number of the block with the largest block height meet a preset condition
- the second election signature of the handover proof in the handover proof information is valid
- the number of handover proof signatures in the signature list in the handover proof information is not less than half of the number of nodes in the node organization
- Each switching certification signature in the signature list in the switching certification information is valid.
- an embodiment of the present invention provides a consensus device of a blockchain system, the blockchain system includes a plurality of node organizations, and each node organization has a plurality of nodes; the device includes:
- a generating module for at least one node organization, generating the election certificate of the first master node in the node organization and sending it to the first election node in the node organization; the first master node is the node organization Each node in is determined based on the Raft consensus algorithm;
- a receiving module configured to receive a plurality of election certificate signatures and the election certificate
- a processing module configured to generate an election proof transaction based on the received multiple election proof signatures and the election proof;
- the election proof signature is a transaction for the election proof after the first election node determines that the election proof satisfies the first verification requirement obtained by signing;
- the blockchain system After the blockchain system determines that the election proves that the transaction consensus is successful based on the PBFT consensus algorithm, it serves as the PBFT consensus node of the blockchain system.
- processing module is also used for:
- the generating module is specifically used for:
- the first verification requirements include:
- the identity of the node in the election certificate is consistent with the identity of the master node in the node organization
- the election signature in the election certificate is valid.
- processing module is specifically used for:
- the received election proof signatures are synthesized into a signature list
- a proof of election transaction is generated.
- the election proves that the transaction consensus is successful, including:
- the generating module is also used for:
- the second master node is determined by each node in the node organization based on the Raft consensus algorithm; the second election node is the node organization Each node in except the second master node;
- the processing module is also used to:
- the handover proof signature is obtained by signing the handover proof after the second election node determines that the handover proof satisfies the first verification requirement;
- the second master node performs consensus on the second message packet to be agreed based on the PBFT consensus algorithm in the blockchain system.
- the generation module is used to:
- the second master node is determined by each node in the node organization based on the Raft consensus algorithm; the second election node is the node organization Each node in except the second master node;
- the processing module is used for:
- the handover proof signature is obtained by signing the handover proof after the second election node determines that the handover proof satisfies the first verification requirement;
- the block chain system After the block chain system determines that the handover proves that the transaction consensus is successful based on the PBFT consensus algorithm, it serves as the PBFT consensus node of the block chain system.
- the generating module is specifically used for:
- the second verification requirement includes:
- the identity of the first master node in the handover proof information is recorded in the system consensus node record;
- the second verification sequence number in the switching certification information and the sequence number of the block with the largest block height meet a preset condition
- the second election signature of the handover proof in the handover proof information is valid
- the number of handover proof signatures in the signature list in the handover proof information is not less than half of the number of nodes in the node organization
- Each switching certification signature in the signature list in the switching certification information is valid.
- an embodiment of the present invention also provides a computer device, including:
- the processor is used to call the program instructions stored in the memory, and execute the above-mentioned consensus method of the blockchain system according to the obtained program.
- the embodiment of the present invention also provides a computer-readable storage medium, the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable the computer to execute the above-mentioned blockchain system consensus method.
- FIG. 1 is a schematic diagram of a system architecture provided by an embodiment of the present invention
- FIG. 2 is a schematic flow diagram of a consensus method for a blockchain system provided by an embodiment of the present invention
- Fig. 3 is a schematic structural diagram of a consensus device of a blockchain system provided by an embodiment of the present invention.
- consensus algorithms for blockchain include Raft, PBFT, POW (Proof of Work, proof of workload), POS (Proof of Stake, proof of equity), DPOS (Delegated Proof of Stake, authorized proof of equity) wait.
- the PBFT consensus algorithm can reach a consensus in the scenario where a small number of nodes do evil (such as forged messages).
- PBFT uses cryptographic algorithms such as signatures, signature verification, and hashing to ensure tamper-proof, anti-forgery, and non-repudiation in the process of message delivery.
- cryptographic algorithms such as signatures, signature verification, and hashing to ensure tamper-proof, anti-forgery, and non-repudiation in the process of message delivery.
- reducing the complexity of the Byzantine fault-tolerant algorithm from the exponential level to the polynomial level in a system composed of (3*f+1) nodes, as long as there are no less than (2*f+1) non-malicious nodes working normally , the system can reach consensus, for example, in a 7-node blockchain system, 2 nodes are allowed to have Byzantine errors.
- the network complexity of the PBFT consensus algorithm is proportional to the square of the node size (for example, the network complexity is the square of the number of nodes), the supported blockchain network scale is limited, and the amount of calculation in the consensus process is large, which limits the blockchain system. scalability.
- the Raft consensus algorithm is a consensus algorithm for managing replica logs. Such as Leader (leader) election, log copy, security, and state machine. Raft also provides a new mechanism to change cluster members to ensure security. The Raft consensus algorithm can tolerate no more than half of non-Byzantine errors.
- the embodiment of the present invention provides A consensus method for a blockchain system that combines the Raft consensus algorithm and the PBFT consensus algorithm.
- FIG. 1 exemplarily shows a system architecture to which the embodiment of the present invention is applicable.
- the system architecture includes multiple node mechanisms, and each node mechanism has multiple nodes.
- Fig. 1 only exemplarily shows three node mechanisms, namely node mechanism 1, node mechanism 2 and node mechanism 3, each node mechanism includes 3 nodes, including 1 master node and two election nodes; the node organization determines the master node according to the Raft consensus algorithm, and the PBFT consensus algorithm is used between the master nodes of each node organization to agree on the consensus block.
- FIG. 1 is only an example, which is not limited in this embodiment of the present invention.
- FIG. 2 exemplarily shows a schematic flowchart of a consensus method of a blockchain system provided by an embodiment of the present invention, and the process can be executed by a consensus device of the blockchain system.
- the process specifically includes:
- Step 210 for at least one node organization, the first master node in the node organization generates an election certificate and sends it to the first election node in the node organization.
- the first master node is determined by each node in the node organization based on the Raft consensus algorithm.
- Step 220 the first master node generates an election certification transaction based on the received multiple election certification signatures and the election certification.
- the election certificate signature is obtained by signing the election certificate after the first election node determines that the election certificate meets the first verification requirement.
- Step 230 the first master node acts as a PBFT consensus node of the blockchain system after the blockchain system determines that the election proves that the transaction consensus is successful based on the PBFT consensus algorithm.
- the consensus conditions for election certification transactions include: the verification serial number of the election certification in the election certification transaction, the number of election certification signatures in the signature list in the election certification transaction, and the validity of each election certification signature in the signature list in the election certification transaction.
- Sexual consensus the verification serial number of the election certification in the election certification transaction, the number of election certification signatures in the signature list in the election certification transaction, and the validity of each election certification signature in the signature list in the election certification transaction.
- the node organization when the blockchain system is initialized, for any node organization in the blockchain system, the node organization includes multiple election nodes, and the election nodes are equivalent to the Follower (crowd) state in the Raft consensus algorithm, and then through Voting, electing the only first master node, the first master node is equivalent to the Leader state in the Raft consensus algorithm, the first election node is equivalent to other nodes in the node organization to which the first master node belongs, the first election node participates In order to elect the first master node.
- the election mechanism meets the preset election conditions (such as the heartbeat request sent by the Leader has not been received after exceeding the election timer), a new master node needs to be re-elected, which is equivalent to the implementation of the present invention.
- the second election node is equivalent to other nodes in the node organization to which the second master node belongs, and the second election node participated in the election of the second master node.
- step 210 before the first master node generates an election certificate and sends it to the first election node in the node organization, each node organization runs the Raft consensus algorithm independently to elect the first master node Leader.
- a voting request is sent to other nodes in the node organization, and when a node receives votes from half of the nodes in the node organization, it is determined that the node is the leader of the node.
- the first master node After the first master node is determined, the first master node generates an election certificate, wherein the election certificate is generated based on the serial number of the block and the identity of the first master node; the incremented serial number in the blockchain prevents malicious Nodes replay election proofs.
- the first master node in the node mechanism determines the sequence number of the block with the largest block height in the blockchain system; the first master node generates the block based on the sequence number of the block with the largest block height The first verification sequence number; the first master node signs the first verification sequence number and the identity of the first master node to obtain a first election signature; the first master node according to the first verification The serial number, the identifier of the first master node and the first election signature generate the election certificate.
- the first master node uses its own private key to sign the identity of the first master node (such as Leader Node ID 1 ) and the first verification sequence number (nonce 1 +1) to obtain the first election signature; for example, the first election signature It is sig(Leader Node ID 1 , nonce 1 +1).
- the first master node After determining the election certificate, the first master node sends the election certificate to other election nodes of the node organization to which the first master node belongs, that is, each first election node in the node organization.
- each first election node verifies the election certificate of the first master node before the first master node signs the multiple election certificates received.
- the proof satisfies the first verification condition, use its own private key to sign the election certificate, obtain the signature of the election certificate, and return to the first master node.
- the first verification requirement includes three conditions, specifically:
- the identity of the node in the election certificate is consistent with the identity of the master node in the node organization; the verification serial number in the election certificate and the serial number of the block with the largest block height meet the preset conditions; The election signature is valid.
- the first verification serial number, the identity of the first master node and the first election signature in the election certificate are respectively verified.
- the first election node obtains the sequence number nonce ⁇ of the block with the largest block height from the blockchain system, and if it is determined that the first verification sequence number (nonce 1 +1) is greater than the sequence number nonce ⁇ , then the The verification sequence number is verified; in an implementable manner, the difference value can also be determined according to the nonce ⁇ and (nonce 1 +1), if the difference is equal to the preset value (such as 1), then the first verification sequence is determined No. verification passed.
- the first election node determines whether the identity of the first master node (Leader Node ID 1 ) is the master node Node ID elected by the affiliated node organization according to the Raft consensus algorithm, and if so, the verification of the identity of the first master node passes.
- the first election node uses the public key of the first master node to decrypt the first election signature sig(Leader Node ID 1 , nonce 1 +1), and if the decryption is successful, it is determined that the verification of the first election signature is passed.
- the node organization switches the master node; if the first election node passes the verification of the election proof, the first election node uses its own private key to verify the election proof Vote Proof ⁇ Leader Node ID 1 , nonce 1 +1, sig(Leader Node ID 1 , nonce 1 +1) ⁇ to sign, get the election proof signature, and send it to the first master node.
- the first master node needs to combine the received election certificate signatures into a signature list when the number of received election certificate signatures is not less than half of the number of nodes in the node organization; it is used to represent the first master node It is the master node determined by the node organization according to the Raft consensus algorithm to ensure the security of the master node election, and then generate election proof transactions according to the signature list.
- the first master node determines that the number of received election certificate signatures is not less than half of the number of nodes in the node organization, it synthesizes the received election certificate signatures into a signature list; based on the signature list and election certificates, an election certificate is generated trade.
- the first master node aggregates multiple election proof signatures together to generate a signature list (Vote Proof SigList), and then aggregates the signature list (Vote Proof SigList) and election proof (Vote Proof) to generate an election proof Transaction (Trigger Leader Vote).
- step 230 the consensus on the election proof transaction is reached by each node in the blockchain system, that is, after the first master node generates the election proof transaction, it needs to broadcast the election proof transaction to the blockchain
- the election proof transaction is packaged into the first consensus information packet of the block to be consensus, and then the first consensus information packet is broadcast to the blockchain system; nodes in the blockchain system get the first consensus information packet Following the election proof transaction in the consensus packet, consensus is performed on the election proof transaction.
- the node determines that the election proof transaction meets the following conditions, it determines that the election proof transaction consensus is successful.
- condition 2 when it is determined that the number of election proof signatures in the signature list in the election proof transaction is not less than half of the number of nodes in the node organization to which the first master node belongs, it is determined that the first master node is the master elected by the node organization according to the Raft consensus algorithm. node, so the verification passes.
- the node uses the public key of the first election node corresponding to the election certificate signature to decrypt the election certificate signature. If the decryption is successful, it is determined that the election certificate signature is verified.
- the blockchain After confirming that the election proves that the transaction consensus is successful, write the identity of the first master node into the local system consensus node record; to determine the first master node based on the PBFT consensus algorithm The first consensus node to perform consensus on the consensus information packet.
- the system consensus node record is also used to verify the node of the parameter PBFT consensus, specifically, the first master node receives the first information packet to be consensus; the sender of the first information packet to be consensus is determined as the After the consensus node in the system consensus node record, consensus is performed on the first information packet to be consensus based on the PBFT consensus algorithm.
- the first master node determines that the sender of the first information packet to be consensus is not a consensus node in the system consensus node record, it rejects the first information packet to be consensus.
- the first master node after the first master node receives the first consensus information packet, in addition to verifying whether the sender of the first consensus information packet is the consensus node in the system consensus node record, it will also The sender's public key verifies the signature of the information packet in the first consensus information packet, and if the verification fails, the first consensus information packet is rejected.
- the information packet signature is obtained after the sender uses its own private key to sign the hash value of the first consensus information packet.
- the node can be used as The PBFT consensus node of the blockchain system avoids operations such as repeated generation of election certificates and election certificate transactions by the first master node, and improves the consensus efficiency of the blockchain system.
- the first master node in the node organization may be in an abnormal state due to reasons such as network disconnection, machine downtime, and being compromised by malicious attackers.
- the present invention proposes a master node rotation mechanism, that is, when the first master node of a certain node organization is abnormal, a new The master node (second master node) continues to participate in the PBFT consensus as a consensus node.
- the second master node After the first master node of the node organization is rotated to be the second master node, the second master node generates a switching certificate and sends it to the second election node in the node organization; the second master node It is determined by each node in the node organization based on the Raft consensus algorithm; the second election node is each node in the node organization except the second master node.
- the second master node generates handover proof information based on a plurality of handover proof signatures and the handover proof received; signed;
- the second master node performs consensus on the second message packet to be agreed based on the PBFT consensus algorithm in the blockchain system.
- the difference between the second master node and the first master node is that the handover certificate generated by the second master node includes the identity of the first master node.
- the second master node determines the serial number of the block with the largest block height in the blockchain system, and generates a second verification serial number based on the serial number of the block with the largest block height; the second master node Signing the second verification sequence number and the identity of the second master node to obtain a second election signature; the second master node according to the second verification sequence number, the identity of the first master node, generating a switching certificate with the second election signature;
- the second master node uses its own private key to sign the identity of the second master node (such as New Leader ID) and the first verification sequence number (nonce 2 +1) to obtain the second election signature; for example, the second election signature is sig (New Leader ID, nonce 2 +1).
- the handover proof is Hand Over Proof ⁇ Last Leader ID(Leader Node ID 1 ), New Leader ID, nonce 2 +1, sig(New Leader ID, nonce 2 +1) ⁇ .
- the second master node After the second master node determines the switching certificate, it sends the switching certificate to other election nodes of the node organization to which the second master node belongs, that is, each second election node in the node organization.
- the second election node verifies the switching certificate of the second master node, and when it is determined that the switching certificate of the second master node satisfies the first verification condition, it signs the switching certificate with its own private key, Get the switching proof signature and return to the second master node.
- the first verification condition is as above, so I won’t go into details here. That is to say, the handover certificate is similar to the election certificate, that is, the second verification sequence number, the identity of the second master node and the second election signature in the handover certificate authenticating.
- the second election node passes the verification of the handover proof, then the second election node uses its own private key to sign the handover proof Hand Over Proof, obtains the handover proof signature, and sends it to the second master node.
- the second master node will combine the received handover proof signatures into a signature list (Hand Over Proof SignList) when the number of received handover proof signatures is not less than half of the number of nodes in the node organization to which the second master node belongs ; It is used to represent that the second master node is the new master node determined by the node organization according to the Raft consensus algorithm.
- a signature list Hand Over Proof SignList
- each consensus node that needs to participate in the PBFT consensus needs to verify the switching proof information of the second master node. When it is determined that the switching proof information meets the second verification condition, it is determined that the switching proof information has passed the verification; after the verification is passed , allowing the second master node to participate in the PBFT consensus.
- the second verification requirement includes the following conditions:
- Condition 1 The identity of the first master node in the switching proof information is recorded in the system consensus node record.
- the number of handover proof signatures in the signature list in the handover proof information is not less than half of the number of nodes in the node organization
- each node will add the handover proof information Hand Over Info to the new block to verify the second consensus Node legitimacy.
- the feature of the above method is that every time the second master node participates in the PBFT consensus, it needs to send switching proof information to ensure the security and correctness of the second master node.
- the second master node determines the switching proof, it generates a switching proof transaction and broadcasts the switching proof transaction to the blockchain system; the nodes in the blockchain system determine the switching proof transaction consensus After success, write the second master node into the system consensus node record, which is equivalent to replacing the first master node with the second master node, so that when participating in the PBFT consensus in the future, there is no need to send switching proof information, reducing consensus verification.
- the complexity of the test and the consensus efficiency of the blockchain system are improved.
- the second master node After the first master node of the node organization is rotated to the second master node, the second master node generates a switching certificate and sends it to the second election node in the node organization; where the second master node is each node in the node organization Determined based on the Raft consensus algorithm; the second election node is each node in the node organization except the second master node.
- the second master node generates a handover proof transaction based on the received multiple handover proof signatures and handover proofs; wherein, the handover proof signature is obtained by signing the handover proof after the second election node confirms that the handover proof satisfies the first verification requirement.
- the second master node will serve as the PBFT consensus node of the blockchain system after the blockchain system determines that the switching proves that the transaction consensus is successful based on the PBFT consensus algorithm.
- FIG. 3 exemplarily shows a schematic structural diagram of a consensus device of a blockchain system provided by an embodiment of the present invention, and the device can execute the flow of the consensus method of the blockchain system.
- the block chain system includes a plurality of node mechanisms, and each node mechanism has a plurality of nodes; as shown in Figure 3, the device specifically includes:
- the generation module 310 is used for at least one node organization, generating the election certificate of the first master node in the node organization and sending it to the first election node in the node organization; the first master node is the node Each node in the organization is determined based on the Raft consensus algorithm;
- a receiving module 320 configured to receive a plurality of election certificate signatures and the election certificate
- the processing module 330 is configured to generate an election proof transaction based on the received multiple election proof signatures and the election proof; the election proof signature is a transaction for the election after the first election node determines that the election proof satisfies the first verification requirement. certified to be signed;
- the blockchain system After the blockchain system determines that the election proves that the transaction consensus is successful based on the PBFT consensus algorithm, it serves as the PBFT consensus node of the blockchain system.
- processing module 330 is also used for:
- the generating module 310 is specifically used for:
- the first verification requirements include:
- the identity of the node in the election certificate is consistent with the identity of the master node in the node organization
- the election signature in the election certificate is valid.
- processing module 330 is specifically configured to:
- the received election proof signatures are synthesized into a signature list
- a proof of election transaction is generated.
- the election proves that the transaction consensus is successful, including:
- the generating module 310 is further configured to:
- the second master node is determined by each node in the node organization based on the Raft consensus algorithm; the second election node is the node organization Each node in except the second master node;
- the processing module 330 is also used for:
- the handover proof signature is obtained by signing the handover proof after the second election node determines that the handover proof satisfies the first verification requirement;
- the second master node performs consensus on the second message packet to be agreed based on the PBFT consensus algorithm in the blockchain system.
- the generation module 310 is used to:
- the second master node is determined by each node in the node organization based on the Raft consensus algorithm; the second election node is the node organization Each node in except the second master node;
- the processing module 330 is used for:
- the handover proof signature is obtained by signing the handover proof after the second election node determines that the handover proof satisfies the first verification requirement;
- the block chain system After the block chain system determines that the handover proves that the transaction consensus is successful based on the PBFT consensus algorithm, it serves as the PBFT consensus node of the block chain system.
- the generating module 310 is specifically used for:
- the second verification requirement includes:
- the identity of the first master node in the handover proof information is recorded in the system consensus node record;
- the second verification sequence number in the switching certification information and the sequence number of the block with the largest block height meet a preset condition
- the second election signature of the handover proof in the handover proof information is valid
- the number of handover proof signatures in the signature list in the handover proof information is not less than half of the number of nodes in the node organization
- Each switching certification signature in the signature list in the switching certification information is valid.
- the embodiment of the present invention also provides a computer device, including:
- the processor is used to call the program instructions stored in the memory, and execute the above-mentioned consensus method of the blockchain system according to the obtained program.
- the embodiment of the present invention also provides a computer-readable storage medium, the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to make the computer execute the above-mentioned block chain system consensus method.
- the embodiments of the present application may be provided as methods, systems, or computer program products. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
- computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
- These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions
- the device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
Landscapes
- Business, Economics & Management (AREA)
- Engineering & Computer Science (AREA)
- Accounting & Taxation (AREA)
- Computer Security & Cryptography (AREA)
- Finance (AREA)
- Strategic Management (AREA)
- Physics & Mathematics (AREA)
- General Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
Abstract
本发明公开了一种区块链系统的共识方法及装置,区块链系统中包括多个节点机构,每个节点机构具有多个节点;方法包括:针对至少一个节点机构,节点机构中的第一主节点生成选举证明并发送给节点机构中的第一选举节点;第一主节点是节点机构中的各节点基于Raft共识算法确定的;基于接收的多个选举证明签名和选举证明,生成选举证明交易;选举证明签名是第一选举节点确定选举证明满足第一验证要求后对选举证明进行签名得到的;第一主节点在区块链系统基于PBFT共识算法确定选举证明交易共识成功后,作为区块链系统的PBFT共识节点。降低区块链系统中共识过程的计算量,降低PBFT共识算法网络的复杂度,提高区块链系统的可扩展性。
Description
相关申请的交叉引用
本申请要求在2021年09月27日提交中国专利局、申请号为202111138341.1、申请名称为“一种区块链系统的共识方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本发明涉及金融科技(Fintech)领域,尤其涉及一种区块链系统的共识方法及装置。
随着计算机技术的发展,越来越多的技术(例如:区块链、云计算或大数据)应用在金融领域,传统金融业正在逐步向金融科技转变,大数据技术也不例外,但由于金融、支付行业的安全性、实时性要求,也对大数据技术中区块链系统的共识提出了更高的要求。
现有技术中,区块链系统是一个无中心的开放式的分布式系统,它可以用于登记和发行数字化资产、产权凭证、积分等,并以点对点的方式进行转账、支付和交易。区块链系统与传统的中心化账本系统相比,具有完全公开、不可篡改、防止多重支付等优点,并且不依赖于任何的可信第三方。
由于点对点网络下存在较高的网络延迟,各个节点所观察到的事务先后顺序大多不完全一致。因此区块链系统需要设计一种机制对在差不多时间内发生的事务的先后顺序进行共识。这种对一个时间窗口内的事务的先后顺序达成共识的算法被称为“共识机制”。
目前,因为PBFT(Practical Byzantine Fault Tolerance,实用拜占庭容错算法)共识算法安全性高、可解决拜占庭问题,具有吞吐量高、交易确认时延低达秒级、有最终一致性保证等特点,适用于区块链系统安全可靠的共识算法,因而被各区块链系统所采用。
但是,PBFT共识算法网络复杂度与节点规模的平方成正比(如网络复杂度为节点数量的平方)、可支撑的区块链网络规模有限、共识过程中计算量大、限制了区块链系统的可扩展性。
发明内容
本发明实施例提供一种区块链系统的共识方法及装置,用于降低区块链系统中共识过程的计算量,降低PBFT共识算法网络的复杂度,提升可支撑的区块链网络规模,提高区块链系统的可扩展性。
第一方面,本发明实施例提供一种区块链系统的共识方法,所述区块链系统中包括多个节点机构,每个节点机构具有多个节点;所述方法包括:
针对至少一个节点机构,所述节点机构中的第一主节点生成选举证明并发送给所述节点机构中的第一选举节点;所述第一主节点是所述节点机构中的各节点基于Raft共识算法确定的;
所述第一主节点基于接收的多个选举证明签名和所述选举证明,生成选举证明交易;所述选举证明签名是第一选举节点确定所述选举证明满足第一验证要求后对所述选举证明进行签名得到的;
所述第一主节点在所述区块链系统基于PBFT共识算法确定所述选举证明交易共识成功后,作为所述区块链系统的PBFT共识节点。
上述技术方案中,第一主节点相当于区块链系统初始化时,节点机构中各选举节点投票选出来的主节点Leader;通过将参与PBFT共识算法的共识节点在区块链系统的节点机构中选择,未将区块链系统中所有节点作为参与PBFT共识算法的共识节点,以此减少了参与PBFT共识算法的共识节点数量,从而降低了区块链系统中共识过程的计算量,降低了PBFT共识算法网络的复杂度,提升了可支撑的区块链网络规模,提高了区块链系统的可扩展性;且通过参与PBFT共识算法的节点保证了区块链系统中数据一致性,因为参与PBFT共识算法的共识节点是节点机构中根据Raft共识算法选择的主节点,主节点用于向节点机构中的选举节点发送区块共识结果,因此保证了节点机构中各节点的数据一致性。
可选的,作为所述区块链系统的PBFT共识节点之后,还包括:
将所述第一主节点的标识写入系统共识节点记录中;
所述第一主节点接收第一待共识信息包;
所述第一主节点确定所述第一待共识信息包的发送者为所述系统共识节点记录中的共识节点后,基于PBFT共识算法对所述第一待共识信息包进行共识。
上述技术方案中,在第一主节点作为区块链系统的PBFT共识节点之后,相当于第一主节点已经由区块链系统的各节点验证通过,保证了第一主节点的安全性,各节点将第一主节点写入至各节点本地的系统共识节点记录中,以使在第一主节点未切换的情况下,只需要确定第一主节点为系统共识节点记录中的共识节点,则将第一主节点作为所述区块链系统的PBFT共识节点,避免每次共识待共识区块时,第一主节点重复生成选举证明等操作,减少计算开销。
可选的,所述节点机构中的第一主节点生成选举证明,包括:
所述节点机构中的第一主节点确定所述区块链系统中区块高度最大的区块的序列号;
所述第一主节点基于所述区块高度最大的区块的序列号生成第一验证序列号;
所述第一主节点对所述第一验证序列号和所述第一主节点的标识进行签名,得到第一选举签名;
所述第一主节点根据所述第一验证序列号、所述第一主节点的标识和所述第一选举签名生成所述选举证明;
所述第一验证要求包括:
选举证明中节点的标识与节点机构中的主节点的标识一致;
所述选举证明中的验证序列号与所述区块高度最大的区块的序列号满足预设条件;
所述选举证明中的选举签名有效。
上述技术发案中,通过第一验证序列号保证每个选举证明都是唯一的,防止恶意的节点重放选举证明。
可选的,所述第一主节点基于接收的多个选举证明签名和所述选举证明,生成选举证明交易,包括:
所述第一主节点在确定接收的选举证明签名的数量不少于所述节点机构中节点数量的一半时,将接收的选举证明签名合成签名列表;
所述第一主节点基于所述签名列表和所述选举证明,生成选举证明交易。
上述技术方案中,签名列表是在第一主节点在确定接收的选举证明签名的数量不少于节点机构中节点数量的一半时生成的,基于Raft共识算法少数服从多数的特点,保证了第一主节点在节点机构中的安全性、准确性。
可选的,基于PBFT共识算法确定所述选举证明交易共识成功,包括:
确定所述选举证明交易中选举证明的验证序列号与区块高度最大的区块的序列号满足预设条件;
确定所述选举证明交易中签名列表的选举证明签名数量不少于所述节点机构中节点数量的一半;
确定所述选举证明交易中签名列表的各选举证明签名有效。
可选的,所述方法还包括:
在所述节点机构的第一主节点轮换为第二主节点后,所述第二主节点生成切换证明并发送给所述节点机构中的第二选举节点;所述第二主节点是所述节点机构中的各节点基于Raft共识算法确定的;所述第二选举节点为所述节点机构中除所述第二主节点之外的各节点;
所述第二主节点基于接收的多个切换证明签名和所述切换证明,生成切换证明信息;所述切换证明签名是第二选举节点确定所述切换证明满足第一验证要求后对所述切换证明进行签名得到的;
若所述切换证明信息满足第二验证要求,则所述第二主节点在所述区块链系统中基于PBFT共识算法对所述第二待共识消息包进行共识。
上述技术方案中,第二主节点相当于在第一主节点发生异常后轮换的新主节点Leader;在节点机构中的主节点切换后,通过生成切换证明信息,并将所述切换证明信息发送至区块系统中各共识节点,以使区块链系统中各节点确定切换后的第二主节点可以作为使用PBFT共识算法对所述第二待共识消息包进行共识的共识节点,提升本发明技术方案的灵活性。
可选的,所述方法还包括:
所述节点机构的第一主节点轮换为第二主节点后,所述第二主节点生成 切换证明并发送给所述节点机构中的第二选举节点;所述第二主节点是所述节点机构中的各节点基于Raft共识算法确定的;所述第二选举节点为所述节点机构中除所述第二主节点之外的各节点;
所述第二主节点基于接收的多个切换证明签名和所述切换证明,生成切换证明交易;所述切换证明签名是第二选举节点确定所述切换证明满足第一验证要求后对所述切换证明进行签名得到的;
所述第二主节点在所述区块链系统基于PBFT共识算法确定所述切换证明交易共识成功后,作为所述区块链系统的PBFT共识节点。
上述技术方案中,对于切换后的第二主节点,基于接收的多个切换证明签名和所述切换证明,生成切换证明交易,相当于将切换证明信息作为一笔交易,由区块链系统中各节点进行共识,若共识成功,则将第二主节点写入至各节点本地的系统共识节点记录中,以此避免每次参与PBFT共识均发送切换证明信息,防止对于切换后的第二主节点的重复共识,减少了计算资源和共识校验的复杂度,提升了共识效率。
可选的,所述第二主节点生成切换证明,包括:
所述第二主节点确定所述区块链系统中区块高度最大的区块的序列号,基于所述区块高度最大的区块的序列号生成第二验证序列号;
所述第二主节点对所述第二验证序列号和所述第二主节点的标识进行签名,得到第二选举签名;
所述第二主节点根据所述第二验证序列号、所述第一主节点的标识、所述第二主节点的标识和所述第二选举签名生成切换证明;
所述第二验证要求包括:
切换证明信息中第一主节点的标识记录在系统共识节点记录中;
所述切换证明信息中的第二验证序列号与所述区块高度最大的区块的序列号满足预设条件;
所述切换证明信息中切换证明的第二选举签名有效;
所述切换证明信息中签名列表的切换证明签名数量不少于节点机构中节点数量的一半;
所述切换证明信息中签名列表的各切换证明签名有效。
第二方面,本发明实施例提供一种区块链系统的共识装置,所述区块链系统中包括多个节点机构,每个节点机构具有多个节点;所述装置包括:
生成模块,用于针对至少一个节点机构,在所述节点机构中生成第一主节点的选举证明并发送给所述节点机构中的第一选举节点;所述第一主节点是所述节点机构中的各节点基于Raft共识算法确定的;
接收模块,用于接收的多个选举证明签名和所述选举证明;
处理模块,用于基于接收的多个选举证明签名和所述选举证明,生成选举证明交易;所述选举证明签名是第一选举节点确定所述选举证明满足第一验证要求后对所述选举证明进行签名得到的;
在所述区块链系统基于PBFT共识算法确定所述选举证明交易共识成功后,作为所述区块链系统的PBFT共识节点。
可选的,所述处理模块还用于:
作为所述区块链系统的PBFT共识节点之后,将所述第一主节点的标识写入系统共识节点记录中;
控制接收模块接收第一待共识信息包;
确定所述第一待共识信息包的发送者为所述系统共识节点记录中的共识节点后,基于PBFT共识算法对所述第一待共识信息包进行共识。
可选的,所述生成模块具体用于:
确定所述区块链系统中区块高度最大的区块的序列号;
基于所述区块高度最大的区块的序列号生成第一验证序列号;
对所述第一验证序列号和所述第一主节点的标识进行签名,得到第一选举签名;
根据所述第一验证序列号、所述第一主节点的标识和所述第一选举签名生成所述选举证明;
所述第一验证要求包括:
选举证明中节点的标识与节点机构中的主节点的标识一致;
所述选举证明中的验证序列号与所述区块高度最大的区块的序列号满足预设条件;
所述选举证明中的选举签名有效。
可选的,所述处理模块具体用于:
在确定接收的选举证明签名的数量不少于所述节点机构中节点数量的一半时,将接收的选举证明签名合成签名列表;
基于所述签名列表和所述选举证明,生成选举证明交易。
可选的,基于PBFT共识算法确定所述选举证明交易共识成功,包括:
确定所述选举证明交易中选举证明的验证序列号与区块高度最大的区块的序列号满足预设条件;
确定所述选举证明交易中签名列表的选举证明签名数量不少于所述节点机构中节点数量的一半;
确定所述选举证明交易中签名列表的各选举证明签名有效。
可选的,还包括:
在所述节点机构的第一主节点轮换为第二主节点后,所述生成模块还用于:
生成切换证明并发送给所述节点机构中的第二选举节点;所述第二主节点是所述节点机构中的各节点基于Raft共识算法确定的;所述第二选举节点为所述节点机构中除所述第二主节点之外的各节点;
所述处理模块还用于:
基于接收的多个切换证明签名和所述切换证明,生成切换证明信息;所述切换证明签名是第二选举节点确定所述切换证明满足第一验证要求后对所述切换证明进行签名得到的;
若所述切换证明信息满足第二验证要求,则所述第二主节点在所述区块链系统中基于PBFT共识算法对所述第二待共识消息包进行共识。
可选的,还包括:
所述节点机构的第一主节点轮换为第二主节点后,所述生成模块用于:
生成切换证明并发送给所述节点机构中的第二选举节点;所述第二主节点是所述节点机构中的各节点基于Raft共识算法确定的;所述第二选举节点为所述节点机构中除所述第二主节点之外的各节点;
所述处理模块用于:
基于接收的多个切换证明签名和所述切换证明,生成切换证明交易;所述切换证明签名是第二选举节点确定所述切换证明满足第一验证要求后对所述切换证明进行签名得到的;
在所述区块链系统基于PBFT共识算法确定所述切换证明交易共识成功后,作为所述区块链系统的PBFT共识节点。
所述生成模块具体用于:
确定所述区块链系统中区块高度最大的区块的序列号,基于所述区块高度最大的区块的序列号生成第二验证序列号;
对所述第二验证序列号和所述第二主节点的标识进行签名,得到第二选举签名;
根据所述第二验证序列号、所述第一主节点的标识、所述第二主节点的标识和所述第二选举签名生成切换证明;
所述第二验证要求包括:
切换证明信息中第一主节点的标识记录在系统共识节点记录中;
所述切换证明信息中的第二验证序列号与所述区块高度最大的区块的序列号满足预设条件;
所述切换证明信息中切换证明的第二选举签名有效;
所述切换证明信息中签名列表的切换证明签名数量不少于节点机构中节点数量的一半;
所述切换证明信息中签名列表的各切换证明签名有效。
第三方面,本发明实施例还提供一种计算机设备,包括:
存储器,用于存储程序指令;
处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行上述区块链系统的共识方法。
第四方面,本发明实施例还提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可执行指令,所述计算机可执行指令用于使计算机执行上述区块链系统的共识方法。
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种系统架构示意图;
图2为本发明实施例提供的一种区块链系统的共识方法的流程示意图;
图3为本发明实施例提供的一种区块链系统的共识装置的结构示意图。
为了使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明作进一步地详细描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。
现有技术中,对于区块链的共识算法包括Raft、PBFT、POW(Proof of Work,工作量证明)、POS(Proof of Stake,权益证明)、DPOS(Delegated Proof of Stake,授权的权益证明)等。
其中,PBFT共识算法可以在少数节点作恶(如伪造消息)场景中达成共识,PBFT采用签名、签名验证、哈希等密码学算法确保消息传递过程中的防篡改性、防伪造性、不可抵赖性,将拜占庭容错算法复杂度从指数级降低到多项式级别,在一个由(3*f+1)个节点构成的系统中,只要有不少于(2*f+1)个非恶意节点正常工作,该系统就能达成一致性,如:7个节点的区块链系统中允许2个节点出现拜占庭错误。
但是,PBFT共识算法网络复杂度与节点规模的平方成正比(如网络复杂度为节点数量的平方)、可支撑的区块链网络规模有限、共识过程中计算量大、限制了区块链系统的可扩展性。
Raft共识算法是一个管理副本日志的共识算法。例如Leader(领导者)选举,日志副本,安全,和状态机。Raft同时提供了一种新的机制来改变集群成员,以此来保证安全性,Raft共识算法可容忍不超过一半的非拜占庭错误。
但是,Raft共识算法无法防止拜占庭问题。
因此,为了降低区块链系统中共识过程的计算量,降低PBFT共识算法网络的复杂度,提升可支撑的区块链网络规模,提高区块链系统的可扩展性,本发明实施例提供了一种将Raft共识算法和PBFT共识算法相结合的区块链系统的共识方法。
图1示例性的示出了本发明实施例所适用的一种系统架构,该系统架构包括多个节点机构,每个节点机构具有多个节点。
本发明实施例中,图1仅示例性的示出了3个节点机构,分别为节点机构1、节点机构2和节点机构3,每个节点机构包括3个节点,其中,包括1个主节点和2个选举节点;节点机构中根据Raft共识算法确定主节点,各节点机构的主节点之间,使用PBFT共识算法对待共识区块进行共识。
需要说明的是,上述图1所示的结构仅是一种示例,本发明实施例对此不做限定。
基于上述描述,图2示例性的示出了本发明实施例提供的一种区块链系统的共识方法的流程示意图,该流程可由区块链系统的共识装置执行。
如图2所示,该流程具体包括:
步骤210,针对至少一个节点机构,所述节点机构中的第一主节点生成选举证明并发送给所述节点机构中的第一选举节点。
本发明实施例中,第一主节点是所述节点机构中的各节点基于Raft共识算法确定的。
步骤220,所述第一主节点基于接收的多个选举证明签名和所述选举证明,生成选举证明交易。
本发明实施例中,所述选举证明签名是第一选举节点确定所述选举证明满足第一验证要求后对所述选举证明进行签名得到的。
步骤230,所述第一主节点在所述区块链系统基于PBFT共识算法确定所述选举证明交易共识成功后,作为所述区块链系统的PBFT共识节点。
本发明实施例中,选举证明交易共识的条件包括:选举证明交易中选举证明的验证序列号、选举证明交易中签名列表的选举证明签名数量和选举证明交易中签名列表的各选举证明签名的有效性的共识。
为了更好的阐述本发明的技术方案,下面对一些出现的名词进行解释:
本发明实施例中,区块链系统初始化时,针对区块链系统中任一节点机构,节点机构中包括多个选举节点,选举节点相当于Raft共识算法中的Follower(群众)状态,然后经过投票选举,选出唯一的第一主节点,第一主节点相当于Raft共识算法中的Leader状态,第一选举节点相当于在第一主节点所属节点机构中的其他节点,第一选举节点参与了选举第一主节点。
在Raft共识算法中,若选举机制满足预设选举条件(如超过选举定时器的时间以后一直没有收到Leader发送的心跳请求等),需要重新选举出一个新的主节点,相当于本发明实施例所述的第二主节点,第二选举节点相当于在第二主节点所属节点机构中的其他节点,第二选举节点参与了选举第二主节点。
在步骤210中,第一主节点生成选举证明并发送给所述节点机构中的第一选举节点之前,每个节点机构独立运行Raft共识算法,选举出第一主节点Leader。
举例来说,针对任一节点机构中的任一节点,向节点机构中的其他节点发送投票请求,在某一节点得到节点机构中一半节点数量的投票时,则确定该节点为主节点Leader。
在确定出第一主节点之后,第一主节点生成选举证明,其中,选举证明是根据区块的序列号和第一主节点的标识生成的;通过区块链中递增的序列号防止恶意的节点重放选举证明。
具体的,节点机构中的第一主节点确定所述区块链系统中区块高度最大的区块的序列号;所述第一主节点基于所述区块高度最大的区块的序列号生成第一验证序列号;所述第一主节点对所述第一验证序列号和所述第一主节点的标识进行签名,得到第一选举签名;所述第一主节点根据所述第一验证 序列号、所述第一主节点的标识和所述第一选举签名生成所述选举证明。
举例来说,第一主节点从区块链系统中确定区块高度最大的区块,也就是最新的区块,基于该区块的nonce值(序列号),增加预设值(如1、2等)确定第一验证序列号,如第一验证序列号=nonce
1+1;在一种可实施的方式中,也可以将nonce值乘以预设值确定第一验证序列号,在此不做具体限定。
然后第一主节点使用自身的私钥对第一主节点的标识(如Leader Node ID
1)和第一验证序列号(nonce
1+1)进行签名,得到第一选举签名;如第一选举签名为sig(Leader Node ID
1,nonce
1+1)。
再结合第一验证序列号、第一主节点的标识和第一选举签名生成选举证明;如选举证明为Vote Proof{Leader Node ID
1,nonce
1+1,sig(Leader Node ID
1,nonce
1+1)}。
第一主节点在确定出选举证明之后,将选举证明发送至第一主节点所属节点机构的其他选举节点,也就是节点机构中的各第一选举节点。
在步骤220中,第一主节点基于接收的多个选举证明签名之前,由各第一选举节点对第一主节点的选举证明进行验证,任一第一选举节点在确定第一主节点的选举证明满足第一验证条件时,使用自身的私钥对选举证明进行签名,得到选举证明签名,并返回至第一主节点。
其中,第一验证要求包括三个条件,具体为:
选举证明中节点的标识与节点机构中的主节点的标识一致;所述选举证明中的验证序列号与所述区块高度最大的区块的序列号满足预设条件;所述选举证明中的选举签名有效。
举例来说,针对任一第一选举节点,在得到选举证明之后,分别对选举证明中的第一验证序列号、第一主节点的标识和第一选举签名进行验证。
具体的,第一选举节点从区块链系统中获取区块高度最大的区块的序列号nonce`,若确定第一验证序列号(nonce
1+1)大于序列号nonce`,则确定第一验证序列号验证通过;在一种可实施的方式中,也可以根据nonce`和(nonce
1+1)确定出差值,若差值等于预设值(如1),则确定第一验证序列号验证通过。
第一选举节点确定第一主节点的标识(Leader Node ID
1)是否为所属节点机构根据Raft共识算法选举出的主节点Node ID,若是,则第一主节点的标识验证通过。
第一选举节点使用第一主节点的公钥对第一选举签名sig(Leader Node ID
1,nonce
1+1)进行解密,若解密成功,则确定第一选举签名验证通过。
本发明实施例中,若上述任一验证条件验证为通过,则节点机构切换主节点;若第一选举节点对选举证明验证通过,则第一选举节点使用自身的私钥对选举证明Vote Proof{Leader Node ID
1,nonce
1+1,sig(Leader Node ID
1,nonce
1+1)}进行签名,得到选举证明签名,并发送至第一主节点。
第一主节点基于Raft共识算法特点,需要在接收的选举证明签名的数量不少于所述节点机构中节点数量的一半时,将接收的选举证明签名合成签名列表;用以表征第一主节点为节点机构根据Raft共识算法确定的主节点,以 保证主节点选举的安全性,然后根据签名列表生成选举证明交易。
具体的,第一主节点在确定接收的选举证明签名的数量不少于所述节点机构中节点数量的一半时,将接收的选举证明签名合成签名列表;基于签名列表和选举证明,生成选举证明交易。
举例来说,第一主节点将多个选举证明签名聚合在一起,生成签名列表(Vote Proof SigList),然后将签名列表(Vote Proof SigList)和选举证明(Vote Proof)聚合在一起,生成选举证明交易(Trigger Leader Vote)。
在步骤230中,对于选举证明交易的共识,是由区块链系统中各节点进行共识的,也就是说,第一主节点在生成选举证明交易之后,需要将选举证明交易广播至区块链系统中,如将选举证明交易打包进待共识区块的第一待共识信息包中,然后将第一待共识信息包广播至区块链系统;区块链系统中的节点在得到第一待共识信息包中的选举证明交易之后,对选举证明交易进行共识。
其中,节点若确定选举证明交易满足如下条件,则确定选举证明交易共识成功。
条件1、确定选举证明交易中选举证明的验证序列号与区块高度最大的区块的序列号满足预设条件;
条件2、确定选举证明交易中签名列表的选举证明签名数量不少于节点机构中节点数量的一半;
条件3、确定选举证明交易中签名列表的各选举证明签名有效。
对于条件1,如上述对第一验证要求的陈述,在此不做赘述。
对于条件2,在确定选举证明交易中签名列表的选举证明签名数量不少于第一主节点所属节点机构中节点数量的一半时,确定第一主节点为节点机构根据Raft共识算法选举出的主节点,因此验证通过。
对于条件3,针对签名列表中任一选举证明签名,节点使用选举证明签名对应的第一选举节点的公钥对选举证明签名进行解密,若解密成功,则确定选举证明签名验证通过。
针对区块链中任一节点,在确定选举证明交易共识成功后,将第一主节点的标识写入本地的系统共识节点记录中;以表征确定第一主节点为基于PBFT共识算法对所述第一待共识信息包进行共识的共识节点。
其中,系统共识节点记录还用于对参数PBFT共识的节点进行验证,具体的,所述第一主节点接收第一待共识信息包;确定所述第一待共识信息包的发送者为所述系统共识节点记录中的共识节点后,基于PBFT共识算法对所述第一待共识信息包进行共识。
也就是说,第一主节点若确定第一待共识信息包的发送者不是系统共识节点记录中的共识节点,则拒绝该第一待共识信息包。
示例性的,第一主节点接收第一待共识信息包之后,除了验证第一待共识信息包的发送者是否为系统共识节点记录中的共识节点之外,还会根据第一待共识信息包的发送者的公钥验证第一待共识信息包中的信息包签名,若验证未通过,则拒绝该第一待共识信息包。其中,信息包签名是发送者使用 自身私钥对第一待共识信息包的哈希值签名后得到的。
本发明实施例中,针对已经记录在系统共识节点记录中的第一主节点,在后续的PBFT共识之前,只需要通过确定系统共识节点记录中记录有该节点的标识,就可以将该节点作为所述区块链系统的PBFT共识节点,避免第一主节点重复生成选举证明、选举证明交易等操作,提升了区块链系统的共识效率。
在一种应用场景中,节点机构中的第一主节点可能会因为网络断连、机器宕机、被恶意攻击者攻破等原因而处于异常状态,为保障区块链系统的一致性和可靠性,使得区块链系统在第一主节点异常的情况下仍可正常共识,本发明提出了主节点轮换机制,也就是说,当某节点机构的第一主节点异常时,可重新选取新的主节点(第二主节点)作为共识节点继续参与PBFT共识。
具体的,在所述节点机构的第一主节点轮换为第二主节点后,所述第二主节点生成切换证明并发送给所述节点机构中的第二选举节点;所述第二主节点是所述节点机构中的各节点基于Raft共识算法确定的;所述第二选举节点为所述节点机构中除所述第二主节点之外的各节点。
第二主节点基于接收的多个切换证明签名和所述切换证明,生成切换证明信息;所述切换证明签名是第二选举节点确定所述切换证明满足第一验证要求后对所述切换证明进行签名得到的;
若所述切换证明信息满足第二验证要求,则所述第二主节点在所述区块链系统中基于PBFT共识算法对所述第二待共识消息包进行共识。
本发明实施例中,第二主节点与第一主节点不同的是,第二主节点生成的切换证明包括第一主节点的标识。
进一步地,第二主节点确定所述区块链系统中区块高度最大的区块的序列号,基于所述区块高度最大的区块的序列号生成第二验证序列号;第二主节点对所述第二验证序列号和所述第二主节点的标识进行签名,得到第二选举签名;第二主节点根据第二验证序列号、第一主节点的标识、第二主节点的标识和所述第二选举签名生成切换证明;
举例来说,第二主节点从区块链系统中确定区块高度最大的区块,也就是最新的区块,基于该区块的nonce值(序列号),增加预设值(如1、2等)确定第一验证序列号,如第一验证序列号=nonce
2+1。
第二主节点使用自身的私钥对第二主节点的标识(如New Leader ID)和第一验证序列号(nonce
2+1)进行签名,得到第二选举签名;如第二选举签名为sig(New Leader ID,nonce
2+1)。
再结合第而验证序列号、第一主节点的标识、第二主节点的标识和第一选举签名生成切换证明;如切换证明为Hand Over Proof{Last Leader ID(Leader Node ID
1),New Leader ID,nonce
2+1,sig(New Leader ID,nonce
2+1)}。
第二主节点在确定出切换证明之后,将切换证明发送至第二主节点所属节点机构的其他选举节点,也就是节点机构中的各第二选举节点。
针对任一第二选举节点,第二选举节点对第二主节点的切换证明进行验证,在确定第二主节点的切换证明满足第一验证条件时,使用自身的私钥对 切换证明进行签名,得到切换证明签名,并返回至第二主节点。其中,第一验证条件如上所述,在此不做赘述,也就是说,切换证明类似于选举证明,即对切换证明中的第二验证序列号、第二主节点的标识和第二选举签名进行验证。
第二选举节点对切换证明验证通过,则第二选举节点使用自身的私钥对切换证明Hand Over Proof进行签名,得到切换证明签名,并发送至第二主节点。
第二主节点基于Raft共识算法特点,在接收的切换证明签名的数量不少于第二主节点所属节点机构中节点数量的一半时,将接收的切换证明签名合成签名列表(Hand Over Proof SignList);用以表征第二主节点为节点机构根据Raft共识算法确定的新主节点。
第二主节点再将签名列表Hand Over Proof SignList和切换证明Hand Over Proof聚合在一起,生成切换证明信息Hand Over Info;也就是说,Hand Over Info={Hand Over Proof SignList,Hand Over Proof}。
在进行PBFT共识之前,需要参与PBFT共识的各共识节点需要对第二主节点的切换证明信息进行验证,在确定切换证明信息满足第二验证条件时,确定切换证明信息验证通过;在验证通过后,允许第二主节点参与PBFT共识。
其中,第二验证要求包括如下条件:
条件1、切换证明信息中第一主节点的标识记录在系统共识节点记录中。
条件2、切换证明信息中的第二验证序列号与区块高度最大的区块的序列号满足预设条件。
条件3、切换证明信息中切换证明的选举签名有效。
条件4、切换证明信息中签名列表的切换证明签名数量不少于节点机构中节点数量的一半;
条件5、切换证明信息中签名列表的各切换证明签名有效。
具体验证方法与上述验证方法雷同,在此不做详细赘述。本发明实施例中,第二主节点在参与PBFT共识,且新区块共识成功后,各节点对新区块上链时,将切换证明信息Hand Over Info添加到新区块中,以校验第二共识节点的合法性。
上述方法的特点在于,第二主节点在每次参与PBFT共识时,需要发送切换证明信息,保证第二主节点的安全性和正确性。
在一种可实施的方式中,第二主节点在确定出切换证明后,生成切换证明交易,将切换证明交易广播至区块链系统中;区块链系统种的节点在确定切换证明交易共识成功后,将第二主节点写入系统共识节点记录中,相当于将第一主节点替换为第二主节点,以此实现在后续参与PBFT共识时,不需要发送切换证明信息,降低共识校验的复杂度、提升区块链系统的共识效率。
具体的,节点机构的第一主节点轮换为第二主节点后,第二主节点生成切换证明并发送给节点机构中的第二选举节点;其中,第二主节点是节点机构中的各节点基于Raft共识算法确定的;第二选举节点为所述节点机构中除所述第二主节点之外的各节点。
第二主节点基于接收的多个切换证明签名和切换证明,生成切换证明交易;其中,切换证明签名是第二选举节点确定切换证明满足第一验证要求后对切换证明进行签名得到的。
第二主节点在区块链系统基于PBFT共识算法确定切换证明交易共识成功后,作为区块链系统的PBFT共识节点。
基于相同的技术构思,图3示例性的示出了本发明实施例提供的一种区块链系统的共识装置的结构示意图,该装置可以执行区块链系统的共识方法的流程。
所述区块链系统中包括多个节点机构,每个节点机构具有多个节点;如图3所示,该装置具体包括:
生成模块310,用于针对至少一个节点机构,在所述节点机构中生成第一主节点的选举证明并发送给所述节点机构中的第一选举节点;所述第一主节点是所述节点机构中的各节点基于Raft共识算法确定的;
接收模块320,用于接收的多个选举证明签名和所述选举证明;
处理模块330,用于基于接收的多个选举证明签名和所述选举证明,生成选举证明交易;所述选举证明签名是第一选举节点确定所述选举证明满足第一验证要求后对所述选举证明进行签名得到的;
在所述区块链系统基于PBFT共识算法确定所述选举证明交易共识成功后,作为所述区块链系统的PBFT共识节点。
可选的,所述处理模块330还用于:
作为所述区块链系统的PBFT共识节点之后,将所述第一主节点的标识写入系统共识节点记录中;
控制接收模块320接收第一待共识信息包;
确定所述第一待共识信息包的发送者为所述系统共识节点记录中的共识节点后,基于PBFT共识算法对所述第一待共识信息包进行共识。
可选的,所述生成模块310具体用于:
确定所述区块链系统中区块高度最大的区块的序列号;
基于所述区块高度最大的区块的序列号生成第一验证序列号;
对所述第一验证序列号和所述第一主节点的标识进行签名,得到第一选举签名;
根据所述第一验证序列号、所述第一主节点的标识和所述第一选举签名生成所述选举证明;
所述第一验证要求包括:
选举证明中节点的标识与节点机构中的主节点的标识一致;
所述选举证明中的验证序列号与所述区块高度最大的区块的序列号满足预设条件;
所述选举证明中的选举签名有效。
可选的,所述处理模块330具体用于:
在确定接收的选举证明签名的数量不少于所述节点机构中节点数量的一半时,将接收的选举证明签名合成签名列表;
基于所述签名列表和所述选举证明,生成选举证明交易。
可选的,基于PBFT共识算法确定所述选举证明交易共识成功,包括:
确定所述选举证明交易中选举证明的验证序列号与区块高度最大的区块的序列号满足预设条件;
确定所述选举证明交易中签名列表的选举证明签名数量不少于所述节点机构中节点数量的一半;
确定所述选举证明交易中签名列表的各选举证明签名有效。
可选的,还包括:
在所述节点机构的第一主节点轮换为第二主节点后,所述生成模块310还用于:
生成切换证明并发送给所述节点机构中的第二选举节点;所述第二主节点是所述节点机构中的各节点基于Raft共识算法确定的;所述第二选举节点为所述节点机构中除所述第二主节点之外的各节点;
所述处理模块330还用于:
基于接收的多个切换证明签名和所述切换证明,生成切换证明信息;所述切换证明签名是第二选举节点确定所述切换证明满足第一验证要求后对所述切换证明进行签名得到的;
若所述切换证明信息满足第二验证要求,则所述第二主节点在所述区块链系统中基于PBFT共识算法对所述第二待共识消息包进行共识。
可选的,还包括:
所述节点机构的第一主节点轮换为第二主节点后,所述生成模块310用于:
生成切换证明并发送给所述节点机构中的第二选举节点;所述第二主节点是所述节点机构中的各节点基于Raft共识算法确定的;所述第二选举节点为所述节点机构中除所述第二主节点之外的各节点;
所述处理模块330用于:
基于接收的多个切换证明签名和所述切换证明,生成切换证明交易;所述切换证明签名是第二选举节点确定所述切换证明满足第一验证要求后对所述切换证明进行签名得到的;
在所述区块链系统基于PBFT共识算法确定所述切换证明交易共识成功后,作为所述区块链系统的PBFT共识节点。
所述生成模块310具体用于:
确定所述区块链系统中区块高度最大的区块的序列号,基于所述区块高度最大的区块的序列号生成第二验证序列号;
对所述第二验证序列号和所述第二主节点的标识进行签名,得到第二选举签名;
根据所述第二验证序列号、所述第一主节点的标识、所述第二主节点的标识和所述第二选举签名生成切换证明;
所述第二验证要求包括:
切换证明信息中第一主节点的标识记录在系统共识节点记录中;
所述切换证明信息中的第二验证序列号与所述区块高度最大的区块的序列号满足预设条件;
所述切换证明信息中切换证明的第二选举签名有效;
所述切换证明信息中签名列表的切换证明签名数量不少于节点机构中节点数量的一半;
所述切换证明信息中签名列表的各切换证明签名有效。
基于相同的技术构思,本发明实施例还提供一种计算机设备,包括:
存储器,用于存储程序指令;
处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行上述区块链系统的共识方法。
基于相同的技术构思,本发明实施例还提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可执行指令,所述计算机可执行指令用于使计算机执行上述区块链系统的共识方法。
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本申请是参照根据本申请的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。
Claims (10)
- 一种区块链系统的共识方法,其特征在于,所述区块链系统中包括多个节点机构,每个节点机构具有多个节点;所述方法包括:针对至少一个节点机构,所述节点机构中的第一主节点生成选举证明并发送给所述节点机构中的第一选举节点;所述第一主节点是所述节点机构中的各节点基于Raft共识算法确定的;所述第一主节点基于接收的多个选举证明签名和所述选举证明,生成选举证明交易;所述选举证明签名是第一选举节点确定所述选举证明满足第一验证要求后对所述选举证明进行签名得到的;所述第一主节点在所述区块链系统基于PBFT共识算法确定所述选举证明交易共识成功后,作为所述区块链系统的PBFT共识节点。
- 如权利要求1所述的方法,其特征在于,作为所述区块链系统的PBFT共识节点之后,还包括:将所述第一主节点的标识写入系统共识节点记录中;所述第一主节点接收第一待共识信息包;所述第一主节点确定所述第一待共识信息包的发送者为所述系统共识节点记录中的共识节点后,基于PBFT共识算法对所述第一待共识信息包进行共识。
- 如权利要求1所述的方法,其特征在于,所述节点机构中的第一主节点生成选举证明,包括:所述节点机构中的第一主节点确定所述区块链系统中区块高度最大的区块的序列号;所述第一主节点基于所述区块高度最大的区块的序列号生成第一验证序列号;所述第一主节点对所述第一验证序列号和所述第一主节点的标识进行签名,得到第一选举签名;所述第一主节点根据所述第一验证序列号、所述第一主节点的标识和所述第一选举签名生成所述选举证明;所述第一验证要求包括:选举证明中节点的标识与节点机构中的主节点的标识一致;所述选举证明中的验证序列号与所述区块高度最大的区块的序列号满足预设条件;所述选举证明中的选举签名有效。
- 如权利要求1所述的方法,其特征在于,所述第一主节点基于接收的多个选举证明签名和所述选举证明,生成选举证明交易,包括:所述第一主节点在确定接收的选举证明签名的数量不少于所述节点机构中节点数量的一半时,将接收的选举证明签名合成签名列表;所述第一主节点基于所述签名列表和所述选举证明,生成选举证明交易。
- 如权利要求4所述的方法,其特征在于,基于PBFT共识算法确定所述选举证明交易共识成功,包括:确定所述选举证明交易中选举证明的验证序列号与区块高度最大的区块的序列号满足预设条件;确定所述选举证明交易中签名列表的选举证明签名数量不少于所述节点机构中节点数量的一半;确定所述选举证明交易中签名列表的各选举证明签名有效。
- 如权利要求1至5任一项所述的方法,其特征在于,所述方法还包括:在所述节点机构的第一主节点轮换为第二主节点后,所述第二主节点生成切换证明并发送给所述节点机构中的第二选举节点;所述第二主节点是所述节点机构中的各节点基于Raft共识算法确定的;所述第二选举节点为所述节点机构中除所述第二主节点之外的各节点;所述第二主节点基于接收的多个切换证明签名和所述切换证明,生成切换证明信息;所述切换证明签名是第二选举节点确定所述切换证明满足第一验证要求后对所述切换证明进行签名得到的;若所述切换证明信息满足第二验证要求,则所述第二主节点在所述区块链系统中基于PBFT共识算法对所述第二待共识消息包进行共识。
- 如权利要求1至5任一项所述的方法,其特征在于,所述方法还包括:所述节点机构的第一主节点轮换为第二主节点后,所述第二主节点生成切换证明并发送给所述节点机构中的第二选举节点;所述第二主节点是所述节点机构中的各节点基于Raft共识算法确定的;所述第二选举节点为所述节点机构中除所述第二主节点之外的各节点;所述第二主节点基于接收的多个切换证明签名和所述切换证明,生成切换证明交易;所述切换证明签名是第二选举节点确定所述切换证明满足第一验证要求后对所述切换证明进行签名得到的;所述第二主节点在所述区块链系统基于PBFT共识算法确定所述切换证明交易共识成功后,作为所述区块链系统的PBFT共识节点。
- 如权利要求6所述的方法,其特征在于,所述第二主节点生成切换证明,包括:所述第二主节点确定所述区块链系统中区块高度最大的区块的序列号,基于所述区块高度最大的区块的序列号生成第二验证序列号;所述第二主节点对所述第二验证序列号和所述第二主节点的标识进行签名,得到第二选举签名;所述第二主节点根据所述第二验证序列号、所述第一主节点的标识、所述第二主节点的标识和所述第二选举签名生成切换证明;所述第二验证要求包括:切换证明信息中第一主节点的标识记录在系统共识节点记录中;所述切换证明信息中的第二验证序列号与所述区块高度最大的区块的序列号满足预设条件;所述切换证明信息中切换证明的第二选举签名有效;所述切换证明信息中签名列表的切换证明签名数量不少于节点机构中节点数量的一半;所述切换证明信息中签名列表的各切换证明签名有效。
- 一种区块链系统的共识装置,其特征在于,所述区块链系统中包括多个节点机构,每个节点机构具有多个节点;所述装置包括:生成模块,用于针对至少一个节点机构,在所述节点机构中生成第一主节点的选举证明并发送给所述节点机构中的第一选举节点;所述第一主节点是所述节点机构中的各节点基于Raft共识算法确定的;接收模块,用于接收的多个选举证明签名和所述选举证明;处理模块,用于基于接收的多个选举证明签名和所述选举证明,生成选举证明交易;所述选举证明签名是第一选举节点确定所述选举证明满足第一验证要求后对所述选举证明进行签名得到的;在所述区块链系统基于PBFT共识算法确定所述选举证明交易共识成功后,作为所述区块链系统的PBFT共识节点。
- 一种计算机设备,其特征在于,包括:存储器,用于存储程序指令;处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行权利要求1至8任一项所述的方法。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111138341.1A CN113837758B (zh) | 2021-09-27 | 2021-09-27 | 一种区块链系统的共识方法及装置 |
CN202111138341.1 | 2021-09-27 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2023045972A1 true WO2023045972A1 (zh) | 2023-03-30 |
Family
ID=78970667
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/120220 WO2023045972A1 (zh) | 2021-09-27 | 2022-09-21 | 一种区块链系统的共识方法及装置 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN113837758B (zh) |
WO (1) | WO2023045972A1 (zh) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113837758B (zh) * | 2021-09-27 | 2024-09-24 | 深圳前海微众银行股份有限公司 | 一种区块链系统的共识方法及装置 |
CN114710504A (zh) * | 2022-03-31 | 2022-07-05 | 蚂蚁区块链科技(上海)有限公司 | 区块链系统中共识节点的轮换方法、节点和区块链系统 |
CN114745131B (zh) * | 2022-04-06 | 2024-08-30 | 南京识骥信息技术有限公司 | 一种区块链的pbft改进共识算法 |
CN114745135A (zh) * | 2022-04-19 | 2022-07-12 | 西南石油大学 | 一种基于V-raft共识算法进行能源交易的区块链系统 |
CN115208578B (zh) * | 2022-07-07 | 2024-06-25 | 西安电子科技大学 | 一种基于区块链的无人机集群信息一致性共享方法 |
CN118118188B (zh) * | 2024-04-29 | 2024-07-09 | 湖南湘江树图信息科技创新中心有限公司 | 共识效率优化方法及系统 |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110474986A (zh) * | 2019-08-20 | 2019-11-19 | 深圳前海微众银行股份有限公司 | 一种基于区块链系统的共识方法、装置及系统 |
WO2020042792A1 (zh) * | 2018-08-31 | 2020-03-05 | 阿里巴巴集团控股有限公司 | 基于区块链的交易共识处理方法及装置、电子设备 |
CN111371877A (zh) * | 2020-02-28 | 2020-07-03 | 桂林电子科技大学 | 一种异构联盟链的共识方法 |
CN111464349A (zh) * | 2020-03-30 | 2020-07-28 | 南京中诚区块链研究院有限公司 | 区块链Raft+PBFT的混合共识网络算法及系统 |
CN111539726A (zh) * | 2020-04-20 | 2020-08-14 | 中国工商银行股份有限公司 | 区块链共识系统及方法 |
CN113837758A (zh) * | 2021-09-27 | 2021-12-24 | 深圳前海微众银行股份有限公司 | 一种区块链系统的共识方法及装置 |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106878071B (zh) * | 2017-01-25 | 2020-09-15 | 上海钜真金融信息服务有限公司 | 一种基于Raft算法的区块链共识机制 |
CN106789095B (zh) * | 2017-03-30 | 2020-12-08 | 腾讯科技(深圳)有限公司 | 分布式系统及消息处理方法 |
CN110162511B (zh) * | 2018-02-08 | 2023-09-01 | 华为技术有限公司 | 一种日志传输方法及相关设备 |
CN109039713B (zh) * | 2018-07-16 | 2021-06-18 | 夸克链科技(深圳)有限公司 | 一种区块链共识装置与算法 |
CN112132579B (zh) * | 2020-09-30 | 2022-08-12 | 深圳前海微众银行股份有限公司 | 一种区块链共识节点更新方法及装置 |
CN112714177B (zh) * | 2020-12-24 | 2022-11-29 | 天津科技大学 | 一种具有线性消息复杂度的pbft改进算法 |
-
2021
- 2021-09-27 CN CN202111138341.1A patent/CN113837758B/zh active Active
-
2022
- 2022-09-21 WO PCT/CN2022/120220 patent/WO2023045972A1/zh unknown
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2020042792A1 (zh) * | 2018-08-31 | 2020-03-05 | 阿里巴巴集团控股有限公司 | 基于区块链的交易共识处理方法及装置、电子设备 |
CN110474986A (zh) * | 2019-08-20 | 2019-11-19 | 深圳前海微众银行股份有限公司 | 一种基于区块链系统的共识方法、装置及系统 |
CN111371877A (zh) * | 2020-02-28 | 2020-07-03 | 桂林电子科技大学 | 一种异构联盟链的共识方法 |
CN111464349A (zh) * | 2020-03-30 | 2020-07-28 | 南京中诚区块链研究院有限公司 | 区块链Raft+PBFT的混合共识网络算法及系统 |
CN111539726A (zh) * | 2020-04-20 | 2020-08-14 | 中国工商银行股份有限公司 | 区块链共识系统及方法 |
CN113837758A (zh) * | 2021-09-27 | 2021-12-24 | 深圳前海微众银行股份有限公司 | 一种区块链系统的共识方法及装置 |
Non-Patent Citations (1)
Title |
---|
HUANG DONGYAN, LANG LI, BIN CHEN, BO WANG: "RBFT: a new Byzantine fault-tolerant consensus mechanism based on Raft cluster", JOURNAL ON COMMUNICATIONS, RENMIN YOUDIAN CHUBANSHE, BEIJING, CN, vol. 42, no. 3, 31 March 2021 (2021-03-31), CN , pages 209 - 2019, XP093054249, ISSN: 1000-436X, DOI: 10.11959/j.issn.1000−436x.2021043 * |
Also Published As
Publication number | Publication date |
---|---|
CN113837758A (zh) | 2021-12-24 |
CN113837758B (zh) | 2024-09-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2023045972A1 (zh) | 一种区块链系统的共识方法及装置 | |
US11411721B2 (en) | Systems and methods for selecting and utilizing a committee of validator nodes in a distributed system | |
US10944624B2 (en) | Changing a master node in a blockchain system | |
US11283627B2 (en) | Method and apparatus for generating blockchain transaction | |
EP3619668B1 (en) | Performing parallel execution of transactions in a distributed ledger system | |
TW202023232A (zh) | 分布式網路中進行主節點變更的系統 | |
JP2020511807A (ja) | 分散システムにおけるネットワークノード間のコンセンサスを実現すること | |
JP2020516105A (ja) | 分散システムにおけるネットワークノードに対する回復処理の実行 | |
CN112507393B (zh) | 一种保障区块链跨链事务一致性的方法 | |
WO2021258549A1 (zh) | 一种流水线友好的签名和验签方法、设备及存储介质 | |
CA2995772A1 (en) | A method of block building based on byzantine consensus via four rounds of communication | |
WO2022141700A1 (zh) | 分布式节点设备的共识方法、节点设备及分布式网络 | |
CN116132118B (zh) | 一种基于区块链技术的加密通讯方法和系统 | |
CN112118231B (zh) | 一种基于区块链技术的可信身份管理方法 | |
Zhang et al. | An efficient and robust committee structure for sharding blockchain | |
CN113328854B (zh) | 基于区块链的业务处理方法及系统 | |
Tian et al. | Vssb-raft: a secure and efficient zero trust consensus algorithm for blockchain | |
WO2024159804A1 (zh) | 基于区块链的密钥生成方法、装置、电子设备、计算机可读存储介质及计算机程序产品 | |
Freitas et al. | Deterministic or probabilistic?-A survey on Byzantine fault tolerant state machine replication | |
US20220300916A1 (en) | Internetwork swapping of assets | |
CN115941164A (zh) | 一种区块链上实现分布式密钥生成的方法、系统和节点 | |
Xie et al. | A raft algorithm with byzantine fault-tolerant performance | |
CN112633890B (zh) | 一种基于区块链的隐匿权益证明的验证方法及装置 | |
Ding et al. | Genuine On-Chain and Off-Chain Collaboration: Achieving Secure and Non-Repudiable File Sharing in Blockchain Applications | |
CN117811744A (zh) | 一种基于智能合约和加强型共识协议的取证方法和系统 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 22872018 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 03/07/2024) |