+

CN114095209A - Weight-incentive-based alliance chain consensus method and system for main node election - Google Patents

Weight-incentive-based alliance chain consensus method and system for main node election Download PDF

Info

Publication number
CN114095209A
CN114095209A CN202111258601.9A CN202111258601A CN114095209A CN 114095209 A CN114095209 A CN 114095209A CN 202111258601 A CN202111258601 A CN 202111258601A CN 114095209 A CN114095209 A CN 114095209A
Authority
CN
China
Prior art keywords
consensus
node
transaction
master node
nodes
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111258601.9A
Other languages
Chinese (zh)
Other versions
CN114095209B (en
Inventor
董力
肖恒辉
曾嘉炜
郑锐生
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhongtong Service Zhongrui Technology Co ltd
Guangdong Communications Services Co Ltd
Original Assignee
Zhongtong Service Zhongrui Technology Co ltd
Guangdong Communications Services Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhongtong Service Zhongrui Technology Co ltd, Guangdong Communications Services Co Ltd filed Critical Zhongtong Service Zhongrui Technology Co ltd
Priority to CN202111258601.9A priority Critical patent/CN114095209B/en
Publication of CN114095209A publication Critical patent/CN114095209A/en
Application granted granted Critical
Publication of CN114095209B publication Critical patent/CN114095209B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION 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
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/10Network architectures or network communication protocols for network security for controlling access to devices or network resources
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1441Countermeasures against malicious traffic

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Business, Economics & Management (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer And Data Communications (AREA)

Abstract

本发明提出一种基于权重激励主节点选举的联盟链共识方法及系统,涉及区块链共识的技术领域,客户端请求交易上链,联盟链中的所有节点接收请求并进行共识主节点校验及共识副节点校验,然后每个共识副节点验证校验结果的一致性,比较验证结果信息中回复内容的数量与恶意节点数量,结合共识主节点校验结果,确定交易是否写入区块,无恶意节点出现时,运行速度快、效率高,提高了联盟链的共识性能,出现恶意节点时,使用PBFT共识协议进行共识,提高联盟链的健壮性,但PBFT共识协议能容忍的恶意节点数也存在限度,结合视图更换协议,采用权重激励机制重新选举主共识节点,降低恶意节点选举成为主节点的可能性,进一步提高联盟链的共识性能。

Figure 202111258601

The present invention proposes a consortium chain consensus method and system based on weight incentives for master node election, and relates to the technical field of blockchain consensus. A client requests a transaction to be uploaded to the chain, and all nodes in the consortium chain receive the request and perform consensus master node verification. And the consensus secondary node verification, then each consensus secondary node verifies the consistency of the verification results, compares the number of reply content in the verification result information with the number of malicious nodes, and combines the consensus master node verification results to determine whether the transaction is written into the block. , when no malicious nodes appear, the operation speed is fast and the efficiency is high, which improves the consensus performance of the alliance chain. When malicious nodes appear, the PBFT consensus protocol is used for consensus to improve the robustness of the alliance chain, but the malicious nodes that the PBFT consensus protocol can tolerate There is also a limit to the number of nodes. Combined with the view replacement protocol, the weight incentive mechanism is used to re-elect the master consensus node, reducing the possibility of malicious nodes being elected as master nodes, and further improving the consensus performance of the alliance chain.

Figure 202111258601

Description

Weight-incentive-based alliance chain consensus method and system for main node election
Technical Field
The invention relates to the technical field of block chain consensus, in particular to a method and a system for block chain consensus based on weight incentive main node election.
Background
In the block chain technique, the consensus algorithm is an integral part of one of the cores. A federation chain refers to a blockchain in which several enterprises are jointly involved in management, each enterprise operating one or more nodes, wherein data only allows different enterprises in the system to read, write, and send transactions, and jointly records transaction data. Also referred to as "shared authenticated blockchains," in conventional federation chain blockchains, a PBFT (pragmatine fault tolerant) consensus algorithm or a variant PBFT consensus algorithm is typically employed to achieve consistent storage of data on the blockchain.
The traditional PBFT consensus algorithm operates by a state machine, including node states and message states, a main node leads other nodes to process messages in a unified and synchronous mode, whether the messages continuously migrate to the next state or not is judged, the nodes reach the same agreement, and finally the messages reach the processed state, which is totally divided into 5 stages: the method comprises the following steps that firstly, in a Request stage, a client sends a transaction uplink Request to a main node, the Request comprises transaction content, a transaction summary and a message signature, then the Pre-preamble stage is entered, the main node receives the transaction uplink Request of the client, the main node verifies whether the signature of the client Request message is correct, when no problem is verified, the Pre-preamble message is broadcasted to other auxiliary nodes, then the Pre-preamble stage is entered, the auxiliary nodes receive the Pre-preamble message of the main node, and the following verification is carried out: if the master node and the slave node receive the Commit message and check that 2f +1 Premate messages (f represents the number of malicious nodes) successfully, broadcasting the Commit message to other common node, and finally entering a Reply stage, if the master node and the slave node receive the Commit message and check that the Commit message signature is correct, operating the request operation of the client and returning the Commit message to the client.
Compared with the conventional PBFT consensus algorithm, on 18 th 6 th 2021, chinese patent publication No. CN112991066A discloses a consensus method, apparatus, and electronic device in a federation chain, which improves the conventional PBFT consensus algorithm, and proposes to add a broadcast stage between Request and Pre-prefix, so that a client can send a transaction uplink Request to any block chain consensus node, and then broadcast the transaction to all consensus nodes in the block chain by the node receiving the Request, and after receiving the broadcast message, the master node executes subsequent Pre-prefix, Commit, and Reply stages to avoid the occurrence of a situation where block chain consensus cannot be completed when the client and the master node have no network connection or the master node is a malicious node, and other stages are consistent with the conventional PBFT consensus algorithm, but the highest TPS (system throughput capacity) of the block chain system of the PBFT consensus algorithm is reached, the number of system processing per second) is generally more than 10000TPS, and as the number of consensus nodes increases, the highest TPS is attenuated in polynomial level, and at this time, the scheme may cause a problem that the block chain consensus efficiency is low and it is difficult to support normal operation of a service requiring high TPS. In the stage of Prepare and Commit, each consensus node performs summary calculation and message broadcasting, and the message complexity is O (n)2). When the number of the consensus nodes in the network increases, all the consensus nodes need to perform two-stage summary calculation and message broadcasting operation, so that the performance of the traditional PBFT consensus algorithm is rapidly reduced along with the increase of the number of the consensus nodes. When the federation chain performance degrades to a certain degree, it may cause the service running on that federation chain to be interrupted.
In addition, conventional PBFT consensus algorithms require periodic master node replacement, or replacement of the master node in the event of master node corruption. The master node replacement operation is calculated by a formula p ═ v MOD R (p is the master node number, v is the view number, R is the total number of the consensus nodes, and MOD is remainder operation), that is, when no consensus node is added or withdrawn in the federation chain, all the consensus nodes alternately act as master nodes according to the self-numbering sequence. All the consensus nodes are fair to all the nodes by taking the consensus nodes as the master nodes in turn, but the method has the defect that the probability that the election process fails and the election needs to be carried out again due to the fact that malicious nodes cannot be elected as the master nodes by the method.
Disclosure of Invention
In order to solve the problem that in the conventional PBFT consensus method of the alliance chain, the consensus performance is reduced along with the increase of the number of consensus nodes, the invention provides the alliance chain consensus method and system based on weight excitation main node election, so that the probability of electing a malicious node as a main node is reduced, and the consensus performance of the alliance chain is improved.
In order to achieve the technical effects, the technical scheme of the invention is as follows:
a federation chain consensus method based on weight incentive master node election comprises the following steps:
s1, calculating the number f of tolerable malicious nodes of a alliance chain, and determining an initial consensus main node and a consensus auxiliary node in the alliance chain nodes;
s2, a common identification main node and a common identification auxiliary node in the alliance chain receive a transaction uplink request message sent by a client side, and common identification main node verification and common identification auxiliary node verification are carried out;
s3, each consensus auxiliary node verifies the consistency of the consensus main node verification result and the node verification result to obtain verification result information, wherein the verification result information comprises reply content rACKOr reply to the content rnon-ACKEach consensus auxiliary node replies the verification result information to the consensus main node;
s4, setting reply content r in verification result informationACKOf alpha or reply contents rnon-ACKThe number of the common node is beta, when alpha is more than or equal to 2f or beta is less than or equal to f, if the common node verification is successful,allowing the transaction to be written into the latest block of the consensus main node, and the consensus main node replies a 'transaction success' message to the client; if the check of the consensus master node fails, transaction writing is refused, and the consensus master node replies a 'transaction failure' message of the client;
when f is less than or equal to alpha < 2f or f < beta < 2f, the consensus master node broadcasts to inform all consensus slave nodes to enter a PBFT consensus protocol, and performs consensus again on the transaction by using the PBFT consensus protocol;
and when the alpha is less than or equal to 0 and less than or equal to f or beta is more than or equal to 2f, the common identification master node informs all the common identification auxiliary nodes to trigger the view change protocol, all the common identification auxiliary nodes calculate the election weight of the node according to the record of the check of the common identification auxiliary nodes, elects the node with the highest weight to be a new common identification master node, and returns to the step S2 to perform the common identification again.
In the technical scheme, a traditional PBFT consensus algorithm is taken as a basic starting point, the nodes of the alliance chain are subjected to 'three-step walking' consensus, and for the trade uplink request of the client, a 'simple consensus protocol' is adopted: all nodes in the alliance chain receive requests and carry out consensus main node verification and consensus auxiliary node verification, then each consensus auxiliary node verifies the consistency of verification results, whether transactions are written into blocks is determined according to the comparison of the feedback quantity of reply contents in verification result information and the quantity of malicious nodes, the consensus main node verification result is combined, the algorithm complexity of a simple consensus protocol is O (n), the operation speed is high, the efficiency is high, the consensus performance of the alliance chain can be improved, when the malicious nodes appear, the feedback quantity of the reply contents in the verification result information and the quantity of the malicious nodes do not meet the simple consensus protocol, the security and the reliability of the alliance chain cannot be guaranteed, the PBFT consensus protocol is used for consensus, the robustness of the alliance chain is improved, but the number of the malicious nodes which can be tolerated by the PBFT consensus protocol has a limit, therefore, and by combining a view replacement protocol and adopting a weight incentive mechanism to reselect the main consensus node, the appropriate election of the main consensus node is ensured, the probability of malicious nodes is reduced, and the consensus performance of the alliance chain is further improved.
Preferably, the expression for calculating the number f of tolerable malicious nodes of the federation chain in step S1 is as follows:
Figure BDA0003324793970000031
wherein N represents the total number of the identified nodes in the federation chain;
Figure BDA0003324793970000032
indicating a rounding down.
Preferably, the message for requesting uplink transaction sent by the receiving client of the consensus primary node and the consensus secondary node in the alliance chain is set to msgrequest,msgrequestIncludes a transaction content m, a transaction summary D (m) and a client signature Signc
The checking of the consensus master node in step S2 includes:
the consensus main node calculates a summary D '(m) of the transaction content m, and the summary D' (m) is associated with a transaction uplink request message msg sent by the clientrequestThe transaction summary D (m) in (1) is checked, whether the two are equal is checked, and the check result is marked as rverificationForming a consensus master node check result message msgverificationVerification result message msgverificationComprises the following steps: check result flag rverificationTransaction content m, transaction summary D (m) and node signature Signnode k
The checking of the common recognition auxiliary node comprises the following steps: each consensus sub-node calculates a summary D '(m) of the transaction content m, and the summary D' (m) is associated with a transaction uplink request message msg sent by the clientrequestThe transaction summary D (m) in the node is checked, whether the transaction summary D (m) is equal to the transaction summary m is checked, and a node checking result message is formed.
Preferably, the consensus master node will check the result message msgverificationSending the result to each consensus secondary node, and each consensus secondary node receiving a check result message msgverificationVerifying the consistency of the checking result of the consensus master node and the checking result of the node to obtain verification result information;
if the verification result is consistent, the reply is carried outVolume rACKPackaging the verification result information, otherwise, replying the content rnon-ACKPackaging the verification result information; the verification result information also comprises transaction content m, transaction abstract D (m) and node signature Signnode k
Preferably, if the check result flag r is greater than or equal to 2f or β is less than or equal to f as stated in step S4verificationComprises the following steps:
D′(m)=D(m)
the consensus host node checks successfully and encapsulates the 'execute transaction' message msgsbft-commitAnd sent to all the consensus secondary nodes which receive the message msg of executing transactionsbft-commitDetermining to execute the transaction, writing the transaction into the latest block of the node, and replying a 'transaction success' message to the client by the consensus main node; if the verification result marks rverificationComprises the following steps:
D′(m)≠D(m)
the consensus master node fails the check and the consensus master node encapsulates a "do not execute transaction" message msgsbft-commitSent to all the consensus secondary nodes, and the consensus secondary nodes receive a 'do not execute transaction' message msgsbft-commitIf the transaction is not executed and the block is not written, the consensus master node replies to the client with a transaction failure message.
Here, after the consensus master node replies the "transaction success" message to the client or the consensus master node replies the "transaction failure" message to the client, the process still returns to step S2 to continue to execute the next round of consensus for the next uplink transaction request sent by the client.
Preferably, in step S4, when f ≦ α < 2f or f ≦ β ≦ 2f, the consensus master node broadcasts to notify all consensus secondary nodes to enter the PBFT consensus protocol, and the process of re-performing consensus on the transaction using the PBFT consensus protocol is as follows:
the client sends a transaction uplink request message to the consensus master node;
the consensus master node verifies the message sent by the client, and broadcasts a transaction Pre-prepare message to all consensus slave nodes after the verification is passed;
each consensus auxiliary node checks the received transaction Pre-Prepare message, and broadcasts the transaction Pre-Prepare message to other consensus auxiliary nodes and consensus main nodes except the consensus auxiliary node after the check is passed;
the consensus main node and the consensus auxiliary node verify the received trade prefix message, and when the verification is passed and the number of the passed consensus is more than or equal to 2f +1, the trade Commit message is broadcast to other consensus auxiliary nodes and the consensus main node except the consensus main node;
the common identification main node and the common identification auxiliary node verify the received transaction Commit message, when the correct number of Commit message verification results is more than or equal to 2f +1, the transaction is written into the latest block of the node, and a Reply message msg is returnedreplyAnd giving the client the result of the transaction success.
When f is more than or equal to alpha and less than 2f (or f is more than or equal to beta and less than or equal to 2f), malicious nodes appear, the feedback quantity of the reply content in the verification result information and the quantity of the malicious nodes do not meet basic consensus, the security and reliability of the alliance chain cannot be guaranteed, the PBFT consensus protocol is used for consensus, and the robustness of the alliance chain consensus is improved. In the return of Reply message msgreplyAfter "the transaction is successful" is sent to the ue, for the next uplink transaction request sent by the ue, the step S2 is still returned to continue to execute the next round of consensus; when the number Commit message check result is correct and the number of Commit message check results is correct and is less than 2f +1, returning a Reply message msgreplyIf the ue sends the next uplink transaction request, it returns to step S2 to continue executing the next round of consensus.
Preferably, when 0 ≦ α < f or β > 2f as described in step S4, the consensus master node broadcasts the message msgvcInforming all cognizant secondary nodes to trigger execution of a View Change protocol, message msgvcThe method comprises the following steps: view number v +1, last block number BS and node signature Signnode k(ii) a All the consensus secondary nodes receive the message msgvcThen, all the consensus auxiliary nodes calculate the election weight distribution P of the node k according to the record of the check of the consensus auxiliary nodesnode kThe process comprises the following steps:
1) calculating the accuracy, wherein the expression is as follows:
Figure BDA0003324793970000051
wherein, TkLThe latest transaction serial number verified for the k number consensus secondary node; tkOThe first transaction serial number verified for the k number consensus secondary node; tkEThe transaction sequence number set for checking errors of the k number consensus secondary node is represented as: tkE={Tk1,Tk2,Tk3,…,Tkn},E=1,2,3,…,n,Tk1For the first wrong checking transaction number, Tk, of the k-number consensus secondary nodenIdentifying the transaction serial number of the nth check error of the secondary node for the number k; when Correctness is more than 99 percent, the consensus auxiliary node is qualified to be elected as the consensus main node;
2) compute node base score PBThe expression is:
PB=A×Correctness
wherein A represents a modifiable weight-divided reference coefficient;
3) calculating continuously corrected prize PSCThe expression is:
Figure BDA0003324793970000061
4) calculating a check error history penalty PEHThe expression is:
Figure BDA0003324793970000062
5) calculating a continuous check error penalty PECThe expression is:
a=0.05×(TkL-TkO+1),C=1.57×A×a,x=Tkn-Tkn-1
Figure BDA0003324793970000063
wherein a and C both represent intermediate parameters;
6) calculating election weight distribution P of the node knode kThe expression is:
Pnode k=PB+PSC+PEH-PEC
wherein, Pnode kAnd showing the election weight distribution of the k-number consensus secondary node.
Preferably, the consensus secondary node calculates the election weight distribution P of the node k according to the record checked by the consensus secondary node in the step S2node kThen, P is addednode kEncapsulating into a reply message msgPre-voteBroadcast view switch-back message msgPre-voteTo the alliance chain, the message msgPre-voteIncluding the view number v +1, the last block number BS, and the election weight P of the nodenode kAnd node signature Signnode k
All the common identification nodes in the alliance chain receive the message msgPre-voteComparing each election weight score Pnode 1~Pnode NMaking an election, wherein N represents the total number of the common nodes in the alliance chain; each node in the alliance chain encapsulates the election result into an election message msgvoteBroadcasting election message msgvoteTo the alliance chain, election message msgvoteComprises the following steps: view number v +1, last block number BS that stably achieves consensus, election result voteresult, and node signature Signnode k
Each consensus node in the alliance chain receives election messages of other consensus nodes, the consensus node with the most votes is selected to become a new consensus main node, and the other consensus nodes send confirmation result messages msgpost-voteTo the new master node, message msgpost-voteComprises the following steps: view number v +1, last block number BS which stably achieves consensus, new consensus master node number node k and node signature Signnode k
In the new consensus main sectionMessage msg received by pointpost-voteWhen the number is more than or equal to 2f +1, replying a message msg confirming to become the new consensus main node to all the auxiliary consensus nodesvc-commitAll nodes are notified to synchronize the block to the last stable consensus block BS.
The main consensus node is reselected by adopting a weight excitation mechanism, the election weight score is calculated through a series of excitation and penalty formulas by combining the node verification accuracy, the verification success, the error history, the continuous verification success and the error record, the node with the highest weight score is selected as the main node, the election fitness of the main consensus node is ensured, the probability of occurrence of malicious nodes is reduced, and the consensus performance of the alliance chain is further improved.
Preferably, if the new co-recognizing master node receives the message msgpost-voteIf the quantity is less than 2f +1, the election fails, and the original consensus primary node informs all the consensus secondary nodes to re-trigger and execute the view change protocol.
The invention also provides a alliance chain consensus system based on weight incentive main node election, which comprises:
the malicious node calculation module is used for determining an initial consensus main node in the nodes of the alliance chain and calculating the number f of the tolerable malicious nodes of the alliance chain;
the request receiving and checking module is used for receiving the transaction uplink request message sent by the client by the common main node and the common auxiliary node in the alliance chain, and checking the common main node and the common auxiliary node;
and each consensus auxiliary node verifies the consistency of the consensus main node verification result and the node verification result to obtain verification result information, wherein the verification result information comprises reply content rACKOr reply to the content rnon-ACKEach consensus auxiliary node replies verification result information to the consensus main node;
a request response processing module for setting the reply content r in the verification result informationACKOf alpha or reply contents rnon-ACKThe number of the common identification master node is beta, when alpha is more than or equal to 2f or beta is less than or equal to f, if the common identification master node is successfully verified, the transaction is allowed to be written into the most common identification master nodeA new block, wherein the consensus master node replies a 'transaction success' message to the client; if the checking of the consensus main node fails, refusing the transaction writing, and replying a 'transaction failure' message of the client by the consensus main node;
when the f is more than or equal to alpha and less than 2f or the f is more than or equal to beta and less than or equal to 2f, the consensus main node broadcasts to inform all consensus auxiliary nodes to enter a PBFT consensus protocol, and the PBFT consensus protocol is used for carrying out consensus again on the transaction;
and when alpha is less than or equal to 0 and less than or equal to f or beta is more than or equal to 2f, the common identification master node informs all the common identification auxiliary nodes to trigger the execution of the view change protocol, all the common identification auxiliary nodes calculate the election weight division of the node according to the record of the verification of the common identification auxiliary nodes, the node with the highest weight division is elected as a new common identification master node, and the new common identification master node inputs a request receiving and verifying module and restarts common identification.
Compared with the prior art, the invention has the beneficial effects that:
the invention provides a coalition chain consensus method and a coalition chain consensus system based on weight incentive main node election, for a transaction uplink request of a client, all nodes in a coalition chain receive the request and perform consensus main node verification and consensus auxiliary node verification, then each consensus auxiliary node verifies the consistency of the verification result, according to the comparison of the feedback quantity of the reply content in the verification result information and the quantity of malicious nodes, and in combination with the verification result of the consensus main node, whether the transaction is written into a block is determined, when no malicious node appears, the method has low complexity, high operation speed and high efficiency, can improve the consensus performance of the coalition chain, provide higher TPS and support the service operation with high TPS requirements, but when the malicious node appears, the comparison result of the feedback quantity of the reply content in the verification result information and the quantity of the malicious nodes does not meet the original consensus requirements, and the security and reliability of the coalition chain cannot be ensured, the PBFT consensus protocol is used for consensus, the safety and the robustness of the alliance chain are improved, the number of malicious nodes which can be tolerated by the PBFT consensus protocol is limited, the view change protocol is combined, the main consensus node is reselected by adopting a weight incentive mechanism, the suitability of the main consensus node is ensured, the possibility that the malicious node becomes a main node is reduced, and the consensus performance of the alliance chain is further improved.
Drawings
Fig. 1 is a schematic flowchart of a federation chain consensus method based on weight-driven master node election according to embodiment 1 of the present invention;
fig. 2 is a diagram showing an entire structure of a federation chain consensus system based on weight-driven master node election proposed in embodiment 2 of the present invention.
Detailed Description
The drawings are for illustrative purposes only and are not to be construed as limiting the patent;
for better illustration of the present embodiment, certain parts of the drawings may be omitted, enlarged or reduced, and do not represent actual dimensions;
it will be understood by those skilled in the art that certain well-known descriptions of the figures may be omitted.
The positional relationships depicted in the drawings are for illustrative purposes only and are not to be construed as limiting the present patent;
the technical solution of the present invention is further described below with reference to the accompanying drawings and examples.
Example 1
Considering that the highest TPS (system throughput, which is the number of systems processed per second) of a block chain system of a federation chain by using a conventional PBFT consensus algorithm is generally over 10000TPS, and as the number of consensus nodes increases, the highest TPS is attenuated in a polynomial level, at this time, the block chain consensus efficiency is low, and it is difficult to support the problem that services with high TPS requirements are normally operated, that is, sometimes the PBFT consensus algorithm is not necessarily used immediately, and in the stage of Prepare and Commit, each consensus node needs to perform summary calculation and perform message broadcasting, and the message complexity is O (n) (n is the number of common nodes in the federation and the stage of Commit)2). When the number of the consensus nodes in the network increases, all the consensus nodes need to perform two-stage summary calculation and message broadcasting operation, which causes the performance of the traditional PBFT consensus algorithm to rapidly decrease with the increase of the number of the consensus nodes. In addition to the interruption of service running on the federation chain which may result when the performance of the federation chain degrades to a certain extent, conventional PBFT consensus algorithms require periodic replacement of the host node, or in the event of corruption by the host nodeThe master node will also be replaced. When the common node joining or quitting does not occur in the alliance chain, all the common nodes can take the main nodes in turn according to the self numbering sequence. All consensus nodes are fair to all nodes by taking the consensus nodes as master nodes in turn, but the method has the disadvantage that the method cannot avoid the possibility that malicious nodes are elected as the master nodes, which causes the election process to fail, and election needs to be performed again, and affects the efficiency and the overall performance of the alliance chain consensus, so that embodiment 1 of the present invention provides an alliance chain consensus method based on weight excitation master node election, a flow diagram of which is shown in fig. 1, and the method includes:
s1, calculating the number f of tolerable malicious nodes of a alliance chain, and determining an initial consensus main node and a consensus auxiliary node in the alliance chain nodes;
the expression for calculating the number f of tolerable malicious nodes of the alliance chain is as follows:
Figure BDA0003324793970000091
wherein N represents the total number of the identified nodes in the federation chain;
Figure BDA0003324793970000092
indicating a rounding down. In addition, in specific implementation, the selection of the initial consensus master node in the federation chain nodes is usually a node that is initially considered to be high reliability, and is not a tamper message.
S2, a common identification main node and a common identification auxiliary node in the alliance chain receive a transaction uplink request message sent by a client side, and common identification main node verification and common identification auxiliary node verification are carried out;
setting a message of transaction uplink request sent by a receiving client of a common-identity main node and a common-identity auxiliary node in a alliance chain as msgrequest,msgrequestIncludes a transaction content m, a transaction summary D (m) and a client signature Signc(ii) a Wherein, the consensus master node verification comprises:
the consensus main node calculates a summary D '(m) of the transaction content m and sends the summary D' (m) to the clientTransaction uplink request message msgrequestThe transaction summary D (m) in (1) is checked, whether the two are equal is checked, and the check result is marked as rverificationForming a consensus master node check result message msgverificationVerification result message msgverificationComprises the following steps: check result flag rverificationTransaction content m, transaction summary D (m) and node signature Signnode k
The checking of the common recognition auxiliary node comprises the following steps: each consensus sub-node calculates a summary D '(m) of the transaction content m, and the summary D' (m) is associated with a transaction uplink request message msg sent by the clientrequestThe transaction summary D (m) in the node is checked, whether the transaction summary D (m) is equal to the transaction summary m is checked, and a node checking result message is formed.
S3, each consensus auxiliary node verifies the consistency of the consensus main node verification result and the node verification result to obtain verification result information, wherein the verification result information comprises reply content rACKOr reply to the content rnon-ACKEach consensus auxiliary node replies the verification result information to the consensus main node;
the consensus master node sends a check result message msgverificationSending the message to each common identification secondary node, and each common identification secondary node receiving a verification result message msgverificationVerifying the consistency of the checking result of the consensus master node and the checking result of the node to obtain verification result information;
if the verification result is consistent, the content r is repliedACKPackaging the verification result information, otherwise, replying the content rnon-ACKPackaging the verification result information; the verification result information also comprises transaction content m, transaction abstract D (m) and node signature Signnode k
The steps from S1 to S3 are a simple consensus protocol, when no malicious node appears, the high efficiency of the consensus process is ensured, a higher TPS is provided, the service operation with high TPS requirements is supported, and then the reply content r in the verification result information is used as the basisACKOr rnon-ACKThe number of the malicious nodes is compared with the number of the malicious nodes, and whether the transaction is written into the block or not is determined by combining the checking result of the common identification main nodeStep S4 is executed, and with reference to fig. 1, in consideration of the fact that when a malicious node occurs, the security reliability of the federation chain cannot be guaranteed, the PBFT consensus protocol is used for consensus, so as to improve the robustness of federation chain consensus, but the number of malicious nodes that can be tolerated by the PBFT consensus protocol has a limit, so that, with reference to the view replacement protocol, a weight excitation mechanism is used to reselect the main consensus node, so as to ensure the suitability of election of the main consensus node, reduce the probability of occurrence of the malicious node, further improve the consensus performance of the federation chain, and execute step S4:
s4, setting reply content r in verification result informationACKOf alpha or reply contents rnon-ACKWhen alpha is more than or equal to 2f or beta is less than or equal to f, if the consensus master node is verified successfully, the transaction is allowed to be written into the latest block of the consensus master node, and the consensus master node replies a 'transaction success' message to the client; if the check of the consensus master node fails, transaction writing is refused, and the consensus master node replies a 'transaction failure' message of the client;
when the f is more than or equal to alpha and less than 2f or the f is more than or equal to beta and less than or equal to 2f, the consensus main node broadcasts to inform all consensus auxiliary nodes to enter a PBFT consensus protocol, and the PBFT consensus protocol is used for carrying out consensus again on the transaction;
and when alpha is more than or equal to 0 and less than f or beta is more than 2f, the consensus master node informs all the consensus auxiliary nodes to trigger the execution of the view change protocol, all the consensus auxiliary nodes calculate the election weight of the node according to the record of the check of the consensus auxiliary nodes, the node with the highest weight is elected as a new consensus master node, and the step S2 is returned to carry out consensus again.
At this time, three cases are divided:
(one) when alpha is more than or equal to 2f or beta is less than or equal to f, if the check result marks rverificationComprises the following steps:
D′(m)=D(m)
the consensus host node checks successfully and encapsulates the 'execute transaction' message msgsbft-commitAnd sent to all the consensus secondary nodes which receive the message msg of executing transactionsbft-commitDetermining to execute the transaction, writing the transaction into the latest block of the node, and the consensus master node replies 'transaction success' to the clientInformation; if the verification result marks rverificationComprises the following steps:
D′(m)≠D(m)
the consensus master node fails the check and the consensus master node encapsulates a "do not execute transaction" message msgsbft-commitSent to all the consensus secondary nodes, and the consensus secondary nodes receive a 'do not execute transaction' message msgsbft-commitIf the transaction is not executed and the block is not written, the consensus master node replies to the client with a transaction failure message. After the consensus master node replies the "successful transaction" message to the client or the consensus master node replies the "failed transaction" message to the client, the process returns to step S2 to continue to execute the next round of consensus for the next uplink transaction request sent by the client.
(II) when the f is more than or equal to alpha and less than 2f or the f is more than or equal to beta and less than or equal to 2f, the consensus master node broadcasts to inform all consensus secondary nodes to enter the PBFT consensus protocol, and the process of carrying out consensus again on the transaction by using the PBFT consensus protocol comprises the following steps:
the client sends a transaction uplink request message to the consensus master node;
the consensus master node verifies the message sent by the client, and broadcasts a transaction Pre-prepare message to all consensus slave nodes after the verification is passed;
each consensus auxiliary node checks the received transaction Pre-Prepare message, and broadcasts the transaction Pre-Prepare message to other consensus auxiliary nodes and consensus main nodes except the consensus auxiliary node after the check is passed;
the consensus main node and the consensus auxiliary node verify the received trade prefix message, and when the verification is passed and the number of the passed consensus is more than or equal to 2f +1, the trade Commit message is broadcast to other consensus auxiliary nodes and the consensus main node except the consensus main node;
the common identification main node and the common identification auxiliary node verify the received transaction Commit message, when the correct number of Commit message verification results is more than or equal to 2f +1, the transaction is written into the latest block of the node, and a Reply message msg is returnedreplyAnd giving the client the result of the transaction success.
The above-mentioned process of using the PBFT consensus protocol to perform consensus again specifically is:
a Request stage: client sends transaction uplink request message msg to consensus master noderequestMessage msgrequestComprises the following steps: transaction content m, transaction summary D (m) and client signature Signc
Pre-prepare stage: message msg of client received by consensus main noderequestConsensus master node verification message msgrequestClient-side signature Sign insidecWhether it is correct;
if the signature result of the client is verified to be correct, broadcasting a Pre-preamble message msg to other common identification nodespre-preparePre-preamble message msgpre-prepareComprises the following steps: transaction content m, transaction digest D (m), and consensus master signature Signnode k(ii) a If the signature result of the client is not correct, the common identification is marked as failure, and the transaction failure is sent to the client.
Stage Prepare: the consensus secondary node receives the message msg of the consensus primary nodepre-prepareAnd performing Prepare stage check: message msgpre-prepareConsensus master node signature Sign innode kWhether the summary D' (m) and msg of the transaction content m are correct or not is calculatedpre-prepareTransaction digests within D (m) are consistent.
If the verification result is consistent rprepareIf the node is consistent, i.e. D' (m) is consistent, a Prepare message msg is broadcast to other nodesprepareMessage msgprepareComprises the following steps: transaction content m, transaction digest D (m) and signature Sign of the common nodenode k(ii) a If the verification result is inconsistent r'prepareIf "disagreement", i.e. D' (m) ≠ D (m), it broadcasts a Prepare message msg to other consensus nodesprepare= <Transaction content m, transaction summary D (m), r'prepareThe signature Sign of the slave nodenode k>。
And a Commit stage: the consensus main node and the consensus auxiliary node receive the message msgprepareAnd carrying out Commit stage check:
checking msgprepareSecondary node signature Sign in (1)node kCorrect or not, msgprepareTransaction digests D (m) and msg in (1)pre-prepareIs consistent with the transaction summary d (m).
If the node Commit stage check result is consistent, and the received r isprepareIf the number is equal to or larger than 2f +1, broadcasting Commit message msg to other consensus nodescommitMessage msgcommitComprises the following steps: transaction content m, transaction summary D (m) and local node signature Signnode k(ii) a If the check result of the Commit stage of the node is consistent, and the received r is consistentprepareIf the number is consistent and less than 2f +1, the result is marked as consensus failure, and the result is sent to the client side.
A Reply stage: msg received by the consensus main node and the consensus auxiliary nodecommitChecking at Reply stage, and verifying msgcommitOwn node signature Sign in (1)node kWhether the signature is correct, if: msg received by node and verified by Reply stage to be correct in resultcommitIf the number is more than or equal to 2f +1, the transaction is written into the latest block of the node, and a Reply message msg is returnedreplyGiving the client the result of the transaction success; if the node receives the msg with correct result verified by the Reply stagecommitIf the quantity is less than 2f +1, the result is marked as consensus failure, and the transaction failure is sent to the client. And then returns a simple consensus protocol.
When f is more than or equal to alpha and less than 2f (or f is more than or equal to beta and less than or equal to 2f), malicious nodes appear, the feedback quantity of the reply content in the verification result information and the quantity of the malicious nodes do not meet basic consensus, the security and reliability of the alliance chain cannot be guaranteed, the PBFT consensus protocol is used for consensus, and the robustness of the alliance chain consensus is improved. In the return of Reply message msgreplyAfter "the transaction is successful" is sent to the ue, for the next uplink transaction request sent by the ue, the step S2 is still returned to continue to execute the next round of consensus; when the number Commit message check result is correct and the number of Commit message check results is correct and is less than 2f +1, returning a Reply message msgreplyIf the ue sends the next uplink transaction request, it returns to step S2 to continue executing the next round of consensus.
(III) inWhen alpha is more than or equal to 0 and less than f or beta is more than 2f, the consensus master node broadcasts message msgvcInforming all cognizant secondary nodes to trigger execution of a view Change protocol, message msgvcThe method comprises the following steps: view number v +1, last block number BS and node signature Signnode k(ii) a All the consensus secondary nodes receive the message msgvcThen, all the consensus auxiliary nodes calculate the election weight distribution P of the node k according to the record of the check of the consensus auxiliary nodesnode kThe process comprises the following steps:
1) calculating the accuracy, wherein the expression is as follows:
Figure BDA0003324793970000131
wherein, TkLThe latest transaction serial number verified for the k number consensus secondary node; tkOThe first transaction serial number verified for the k number consensus secondary node; tkEThe transaction sequence number set for checking errors of the k number consensus secondary node is represented as: tkE={Tk1,Tk2,Tk3,…,Tkn},E=1,2,3,…,n,Tk1For the first wrong checking transaction number, Tk, of the k-number consensus secondary nodenIdentifying the transaction serial number of the nth check error of the secondary node for the number k; when Correctness is more than 99 percent, the consensus auxiliary node is qualified to be elected as the consensus main node;
2) calculating a node basis score PB, wherein the expression is as follows:
PB=A×Correctness
wherein A represents a modifiable weight-divided reference coefficient;
3) calculating continuously corrected prize PSCThe expression is:
Figure BDA0003324793970000132
4) calculating a check error history penalty PEHThe expression is:
Figure BDA0003324793970000141
5) calculating a continuous check error penalty PECThe expression is:
Figure BDA0003324793970000142
wherein a and C both represent intermediate parameters;
6) calculating election weight distribution P of the node knode kThe expression is:
Pnode k=PB+PSC+PEH-PEC
wherein, Pnode kAnd showing the election weight distribution of the k-number consensus secondary node. The consensus secondary node calculates the election weight distribution P of the node k according to the record checked by the consensus secondary node in the step S2node kThen, P is addednode kEncapsulating in reply message msgPre-voteBroadcast View switch reply message msgPre-voteTo the alliance chain, the message msgPre-voteIncluding the view number v +1, the last stable consensus block number BS, the node election weight Pnode kAnd node signature Signnode k
All the common identification nodes in the alliance chain receive the message msgPre-voteComparing each election weight score Pnode 1~Pnode NMaking an election, wherein N represents the total number of the common nodes in the alliance chain; each node in the alliance chain encapsulates the election result into an election message msgvoteBroadcasting election message msgvoteTo the alliance chain, election message msgvoteComprises the following steps: view number v +1, last block number BS that stably achieves consensus, election result voteresult, and node signature Signnode k
Each consensus node in the alliance chain receives election messages of other consensus nodes, the consensus node with the most votes is selected to become a new consensus main node, and the other consensus nodes send confirmation result messages msgpost-voteTo the new master node, message msgpost-voteComprises the following steps: view number v +1, last block number BS which stably achieves consensus, new consensus master node number node k and node signature Signnode k
Message msg received at new co-recognizing master nodepost-voteWhen the number is more than or equal to 2f +1, replying a message msg confirming to become the new consensus main node to all the auxiliary consensus nodesvc-commitAll nodes are informed to synchronize the block to the last stable consensus block BS if the new consensus master receives message msgpost-voteIf the quantity is less than 2f +1, the election fails, and the original consensus primary node informs all the consensus secondary nodes to re-trigger and execute the view replacement protocol.
And re-electing the main consensus nodes by adopting a weight excitation mechanism, calculating election weight scores through a series of excitation and penalty formulas by combining node verification accuracy, verification success, error history, continuous verification success and error records, selecting the node with the highest weight score as a main node, ensuring the appropriate election of the main consensus nodes, reducing the occurrence probability of malicious nodes and further improving the consensus performance of the alliance chain.
Example 2
As shown in fig. 2, the present invention further provides a federation chain consensus system for master node election based on weight incentive, the system being used to implement the method described in embodiment 1, and referring to fig. 2, the system includes:
the malicious node calculation module 101 is configured to clarify an initial consensus master node in the alliance chain nodes and calculate the number f of the tolerable malicious nodes of the alliance chain;
a request receiving and checking module 102, wherein a common main node and a common auxiliary node in a alliance chain receive a transaction uplink request message sent by a client to perform common main node checking and common auxiliary node checking;
the verification result verification sending module 103 verifies the consistency of the verification result of the consensus primary node and the verification result of the node by each consensus secondary node to obtain verification result information, wherein the verification result information comprises reply content rACKOr reply to the content rnon-ACKEach of which is totallyThe identification auxiliary node replies the verification result information to the consensus main node;
the request/response processing module 104 sets the reply content r in the verification result informationACKOf alpha or reply contents rnon-ACKWhen alpha is more than or equal to 2f or beta is less than or equal to f, if the consensus master node is verified successfully, the transaction is allowed to be written into the latest block of the consensus master node, and the consensus master node replies a 'transaction success' message to the client; if the checking of the consensus main node fails, refusing the transaction writing, and replying a 'transaction failure' message of the client by the consensus main node;
when f is less than or equal to alpha < 2f or f < beta < 2f, the consensus master node broadcasts to inform all consensus slave nodes to enter a PBFT consensus protocol, and performs consensus again on the transaction by using the PBFT consensus protocol;
and when alpha is less than or equal to 0 and less than or equal to f or beta is more than or equal to 2f, the common identification master node informs all the common identification auxiliary nodes to trigger the execution of the view change protocol, all the common identification auxiliary nodes calculate the election weight division of the node according to the record of the verification of the common identification auxiliary nodes, the node with the highest weight division is elected as a new common identification master node, and the new common identification master node inputs a request receiving and verifying module and restarts common identification.
The positional relationships depicted in the drawings are for illustrative purposes only and are not to be construed as limiting the present patent;
it should be understood that the above-described embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. And are not intended to be exhaustive of all embodiments. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the claims of the present invention.

Claims (10)

1.一种基于权重激励主节点选举的联盟链共识方法,其特征在于,包括:1. A consortium chain consensus method based on weight incentive master node election, characterized in that it comprises: S1.计算联盟链可容忍恶意节点的数量f,明确联盟链节点中的初始共识主节点和共识副节点;S1. Calculate the number f of malicious nodes that the alliance chain can tolerate, and specify the initial consensus master node and consensus secondary node in the alliance chain nodes; S2.联盟链中的共识主节点和共识副节点接收客户端发送的交易上链请求消息,进行共识主节点校验及共识副节点校验;S2. The consensus master node and consensus slave node in the alliance chain receive the transaction on-chain request message sent by the client, and perform the consensus master node verification and consensus slave node verification; S3.每个共识副节点验证共识主节点校验结果与本节点校验结果的一致性,得到验证结果信息,验证结果信息中包括回复内容rACK或回复内容rnon-ACK,每个共识副节点将验证结果信息回复至共识主节点;S3. Each consensus secondary node verifies the consistency of the consensus master node's verification result and the verification result of its own node, and obtains the verification result information. The verification result information includes the reply content r ACK or the reply content r non-ACK . The node replies the verification result information to the consensus master node; S4.设验证结果信息中回复内容rACK的数量为α或回复内容rnon-ACK的数量为β,在α≥2f或β≤f时,若共识主节点校验成功,允许交易写入共识主节点的最新区块,共识主节点向客户端回复“交易成功”消息;若共识主节点校验失败,则拒绝交易写入,共识主节点回复客户端“交易失败”消息;S4. Let the number of reply content r ACK in the verification result information be α or the number of reply content r non-ACK be β, when α≥2f or β≤f, if the consensus master node verification is successful, the transaction is allowed to be written into the consensus For the latest block of the master node, the consensus master node will reply to the client with a "transaction successful"message; if the consensus master node fails to verify, the transaction will be rejected, and the consensus master node will reply to the client with a "transaction failed"message; 在f≤α<2f或f<β≤2f时,共识主节点广播通知所有共识副节点进入PBFT共识协议,对交易使用PBFT共识协议重新进行共识;When f≤α<2f or f<β≤2f, the consensus master node broadcasts a notification to all consensus secondary nodes to enter the PBFT consensus protocol, and uses the PBFT consensus protocol to re-consensus the transaction; 在0≤α<f或β>2f时,共识主节点通知所有共识副节点触发执行视图更换协议,所有共识副节点根据共识副节点校验的记录,计算本节点选举权重分,将权重分最高的节点选举为新的共识主节点,返回步骤S2进行重新共识。When 0≤α<f or β>2f, the consensus master node notifies all the consensus sub-nodes to trigger the execution of the view replacement protocol, and all the consensus sub-nodes calculate the election weight score of this node according to the records verified by the consensus sub-nodes, and assign the highest weight score The node is elected as the new consensus master node, and returns to step S2 for re-consensus. 2.根据权利要求1所述的基于权重激励主节点选举的联盟链共识方法,其特征在于,步骤S1中所述的计算联盟链可容忍恶意节点的数量f的表达式为:2. The consortium chain consensus method based on weight incentive master node election according to claim 1, characterized in that, the expression for calculating the number f of malicious nodes that can be tolerated by the consortium chain described in step S1 is:
Figure FDA0003324793960000011
Figure FDA0003324793960000011
其中,N表示联盟链中共识节点的总数;
Figure FDA0003324793960000012
表示向下取整。
Among them, N represents the total number of consensus nodes in the alliance chain;
Figure FDA0003324793960000012
Indicates rounded down.
3.根据权利要求1所述的基于权重激励主节点选举的联盟链共识方法,其特征在于,3. The consortium chain consensus method based on weight incentive master node election according to claim 1, is characterized in that, 设联盟链中的共识主节点和共识副节点接收客户端发送的交易上链请求消息为msgrequest,msgrequest中包含交易内容m,交易摘要D(m)及客户端签名SigncSuppose the consensus master node and consensus slave node in the alliance chain receive the transaction on-chain request message sent by the client as msg request , and the msg request contains the transaction content m, the transaction summary D(m) and the client's signature Sign c ; 步骤S2中所述的共识主节点校验包括:The consensus master node verification described in step S2 includes: 共识主节点计算交易内容m的摘要D′(m),将摘要D′(m)与客户端发送的交易上链请求消息msgrequest中的交易摘要D(m)进行校验,校验二者是否相等,并将校验结果标记为rverification,形成共识主节点校验结果消息msgverification,校验结果消息msgverification中包括:校验结果标记rverification、交易内容m、交易摘要D(m)及节点签名SignnodekThe consensus master node calculates the summary D'(m) of the transaction content m, and verifies the summary D'(m) with the transaction summary D(m) in the transaction on-chain request message msg request sent by the client. Whether they are equal, mark the verification result as r verification , and form the consensus master node verification result message msg verification . The verification result message msg verification includes: verification result mark r verification , transaction content m, transaction summary D(m) and the node signature Sign nodek ; 共识副节点校验包括:每个共识副节点计算交易内容m的摘要D′(m),将摘要D′(m)与客户端发送的交易上链请求消息msgrequest中的交易摘要D(m)进行校验,校验二者是否相等,形成本节点校验结果消息。The verification of the consensus secondary nodes includes: each consensus secondary node calculates the summary D'(m) of the transaction content m, and compares the summary D'(m) with the transaction summary D(m) in the transaction upload request message msg request sent by the client. ) to check whether the two are equal, and form the check result message of this node. 4.根据权利要求3所述的基于权重激励主节点选举的联盟链共识方法,其特征在于,共识主节点将校验结果消息msgverification发送给每个共识副节点,每个共识副节点收到校验结果消息msgverification,验证共识主节点校验结果与本节点校验结果的一致性,得到验证结果信息;4. The consortium chain consensus method based on weight-incentivized master node election according to claim 3, characterized in that, the consensus master node sends the verification result message msg verification to each consensus slave node, and each consensus slave node receives the message msg verification. The verification result message msg verification verifies the consistency between the verification result of the consensus master node and the verification result of this node, and obtains the verification result information; 若验证结果一致,将回复内容rACK封装进验证结果信息,否则,将回复内容rnon-ACK封装进验证结果信息;验证结果信息中还包括交易内容m、交易摘要D(m)及节点签名SignnodekIf the verification results are consistent, encapsulate the reply content r ACK into the verification result information, otherwise, encapsulate the reply content r non-ACK into the verification result information; the verification result information also includes the transaction content m, the transaction digest D(m) and the node signature Sign nodek . 5.根据权利要求3所述的基于权重激励主节点选举的联盟链共识方法,其特征在于,步骤S4中所述的在α≥2f或β≤f时,若校验结果标记rverification为:5. The consortium chain consensus method based on weight-based incentive master node election according to claim 3, characterized in that, when α≥2f or β≤f described in step S4, if the verification result mark r verification is: D′(m)=D(m)D'(m)=D(m) 则共识主节点校验成功,共识主节点封装“执行交易”消息msgsbft-commit,并发送给所有共识副节点,共识副节点收到“执行交易”消息msgsbft-commit,决定执行交易,并将交易写入本节点的最新区块,共识主节点向客户端回复“交易成功”消息;若校验结果标记ruerification为:Then the consensus master node verification is successful, the consensus master node encapsulates the "execute transaction" message msg sbft-commit , and sends it to all consensus slave nodes. The consensus slave node receives the "execute transaction" message msg sbft-commit , decides to execute the transaction, and Write the transaction into the latest block of this node, and the consensus master node will reply to the client with a "transaction successful"message; if the verification result is marked as r uerification : D′(m)≠D(m)D′(m)≠D(m) 则共识主节点校验失败,共识主节点封装“不执行交易”消息msgsbft-commit,发送给所有共识副节点,共识副节点收到“不执行交易”消息msgsbft-commit,不执行交易且不写入区块,共识主节点回复客户端“交易失败”消息。Then the consensus master node verification fails, the consensus master node encapsulates the "do not execute transaction" message msg sbft-commit , and sends it to all consensus slave nodes, the consensus slave node receives the "do not execute transaction" message msg sbft-commit , does not execute the transaction and Without writing the block, the consensus master node replies to the client with a "transaction failed" message. 6.根据权利要求3所述的基于权重激励主节点选举的联盟链共识方法,其特征在于,步骤S4中所述的在f≤α<2f或f<β≤2f时,共识主节点广播通知所有共识副节点进入PBFT共识协议,对交易使用PBFT共识协议重新进行共识的过程为:6. The consortium chain consensus method based on the weight-incentivized master node election according to claim 3, wherein the consensus master node broadcasts a notification when f≤α≤2f or f≤β≤2f as described in step S4 All consensus sub-nodes enter the PBFT consensus protocol, and the process of re-consensus using the PBFT consensus protocol for transactions is as follows: 客户端向共识主节点发送交易上链请求消息;The client sends a transaction on-chain request message to the consensus master node; 共识主节点对客户端发送的消息进行校验,在校验通过后,向所有共识副节点广播交易Pre-prepare消息;The consensus master node verifies the message sent by the client, and after the verification passes, broadcasts the transaction Pre-prepare message to all consensus secondary nodes; 每个共识副节点对接收到的交易Pre-prepare消息进行校验,在校验通过后,向除本身之外的其它共识副节点及共识主节点广播交易Prepare消息;Each consensus secondary node verifies the received transaction Pre-prepare message, and after the verification passes, broadcasts the transaction Prepare message to other consensus secondary nodes and consensus master nodes except itself; 共识主节点和共识副节点对收到的交易Prepare消息进行校验,校验通过后且通过一致的数量≥2f+1时,向除本身之外的其它共识副节点及共识主节点广播交易Commit消息;The consensus master node and consensus slave node verify the received transaction Prepare message. After the verification is passed and the number of passes is ≥ 2f+1, broadcast the transaction Commit to other consensus slave nodes and consensus master nodes except itself. information; 共识主节点和共识副节点对收到的交易Commit消息进行校验,Commit消息校验结果正确的数量≥2f+1时,将交易写入该节点的最新区块,并返回Reply消息msgreply=“交易成功”给客户端。The consensus master node and the consensus slave node verify the received transaction Commit message. When the number of correct commit message verification results is ≥ 2f+1, the transaction is written into the latest block of the node, and the Reply message msg reply = "Successful transaction" to the client. 7.根据权利权利要求3所述的基于权重激励主节点选举的联盟链共识方法,其特征在于,步骤S4所述的在0≤α<f或β>2f时,共识主节点通过广播消息msgvc通知所有共识副节点触发执行视图更换协议;所有共识副节点接收到消息msgvc后,所有共识副节点根据共识副节点校验的记录,计算本节点k的选举权重分Pnodek的过程为:7. The consortium chain consensus method based on weight-based incentive master node election according to claim 3, characterized in that, when 0≤α<f or β>2f described in step S4, the consensus master node broadcasts the message msg by vc notifies all consensus sub-nodes to trigger the execution of the view replacement protocol; after all consensus sub-nodes receive the message msg vc , all consensus sub-nodes calculate the election weight of this node k and divide P nodek according to the records verified by the consensus sub-nodes as follows: 1)计算正确率,表达式为:1) Calculate the correct rate, the expression is:
Figure FDA0003324793960000031
Figure FDA0003324793960000031
其中,TkL为k号共识副节点校验的最新交易序号;TkO为k号共识副节点节点校验的首个交易序号;TkE为k号共识副节点校验错误的交易序号集合,表示为:TkE={Tk1,Tk2,Tk3,…,Tkn},E=1,2,3,…,n,Tk1为k号共识副节点第一个校验错误的交易序号,Tkn为k号共识副节点第n个校验错误的交易序号;在Correctness>99%时,共识副节点才有资格选举成为共识主节点;Among them, Tk L is the latest transaction sequence number verified by the consensus sub-node k; Tk O is the first transaction sequence number verified by the consensus sub-node k; Tk E is the set of transaction sequence numbers that are incorrectly verified by the consensus sub-node k, It is expressed as: Tk E = {Tk 1 , Tk 2 , Tk 3 , ..., Tk n }, E = 1, 2, 3, ..., n, Tk 1 is the first transaction of the k consensus secondary node with an error check Serial number, Tk n is the transaction serial number of the nth verification error of the consensus sub-node k; when Correctness>99%, the consensus sub-node is eligible to be elected as the consensus master node; 2)计算节点基础分PB,表达式为:2) Calculate the node base score P B , the expression is: PB=A×CorrectnessP B =A×Correctness 其中,A表示能修改的权重分参考系数;Among them, A represents the weight sub-reference coefficient that can be modified; 3)计算连续校正正确的奖励PSC,表达式为:3) Calculate the correct reward P SC for continuous correction, the expression is:
Figure FDA0003324793960000032
Figure FDA0003324793960000032
4)计算校验错误历史惩罚PEH,表达式为:4) Calculate the check error history penalty P EH , the expression is:
Figure FDA0003324793960000041
Figure FDA0003324793960000041
5)计算连续校验错误惩罚PEC,表达式为:5) Calculate the continuous check error penalty P EC , the expression is: a=0.05×(TkL-TkO+1),C=1.57×A×a,x=Tkn-Tkn-1 a=0.05×(Tk L −Tk O +1), C=1.57×A×a, x=Tk n −Tk n−1
Figure FDA0003324793960000042
Figure FDA0003324793960000042
其中,a、C均表示中间参数;Among them, a and C both represent intermediate parameters; 6)计算本节点k的选举权重分Pnodek,表达式为:6) Calculate the election weight P nodek of this node k, the expression is: Pnodek=PB+PSC+PEH-PEC P nodek =P B +P SC +P EH -P EC 其中,Pnodek表示k号共识副节点的选举权重分。Among them, P nodek represents the election weight of the k consensus sub-node.
8.根据权利要求7所述的基于权重激励主节点选举的联盟链共识方法,其特征在于,共识副节点根据步骤S2中共识副节点校验的记录,计算本节点k的选举权重分Pnodek后,将Pnodek封装进回复消息msgPre-vote,广播视图切换回复消息msgPre-vote至联盟链中;8. The consortium chain consensus method based on weight-based incentive master node election according to claim 7, characterized in that, the consensus secondary node calculates the election weight P nodek of this node k according to the record verified by the consensus secondary node in step S2. Then, encapsulate the P nodek into the reply message msg Pre-vote , and switch the broadcast view to the reply message msg Pre-vote to the alliance chain; 联盟链中所有共识节点收到消息msgPre-vote,对比每个选举权重分Pnode1~Pnode N作出选举,N表示联盟链中共识节点的总数;联盟链中每一个节点将选举结果封装进选举消息msgvote,广播选举消息msgvote至联盟链中;All consensus nodes in the alliance chain receive the message msg Pre-vote , and compare each election weight to P node1 ~ P node N to make an election, where N represents the total number of consensus nodes in the alliance chain; each node in the alliance chain encapsulates the election results into Election message msg vote , broadcast election message msg vote to the alliance chain; 联盟链中的每一个共识节点收到其他共识节点的选举消息,选择获得选票最多的共识节点成为新的共识主节点,其他共识节点发送确认结果消息msgpost-vote给新的主节点;Each consensus node in the alliance chain receives the election message of other consensus nodes, selects the consensus node with the most votes to become the new consensus master node, and other consensus nodes send confirmation result message msg post-vote to the new master node; 在新的共识主节点收到的消息msgpost-vote数量≥2f+1时,向所有副共识节点回复确认成为新共识主节点的消息msgvc-commit,通知所有节点将区块同步至最后一个稳定达成共识的区块BS。When the number of messages msg post-vote received by the new consensus master node is greater than or equal to 2f+1, the message msg vc-commit confirming becoming the new consensus master node will be replied to all secondary consensus nodes, and all nodes will be notified to synchronize the block to the last one Stable consensus block BS. 9.根据权利要求8所述的基于权重激励主节点选举的联盟链共识方法,其特征在于,若新的共识主节点收到的消息msgpost-vote数量<2f+1,则选举失败,原共识主节点通知所有共识副节点重新触发执行视图更换协议。9. The consortium chain consensus method based on weight-incentivized master node election according to claim 8, characterized in that, if the number of msg post-vote received by the new consensus master node is less than 2f+1, the election fails, and the original The consensus master node notifies all consensus slave nodes to retrigger the execution of the view change protocol. 10.一种基于权重激励主节点选举的联盟链共识系统,其特征在于,所述系统包括:10. A consortium chain consensus system based on weight incentives for master node election, characterized in that the system comprises: 恶意节点计算模块,用于明确联盟链节点中的初始共识主节点,计算联盟链可容忍恶意节点的数量f;The malicious node calculation module is used to specify the initial consensus master node in the consortium chain nodes, and calculate the number f of malicious nodes that the consortium chain can tolerate; 请求接收校验模块,联盟链中的共识主节点和共识副节点接收客户端发送的交易上链请求消息,进行共识主节点校验及共识副节点校验;The request receiving verification module, the consensus master node and consensus slave node in the alliance chain receive the transaction on-chain request message sent by the client, and perform consensus master node verification and consensus slave node verification; 校验结果验证发送模块,每个共识副节点验证共识主节点校验结果与本节点校验结果的一致性,得到验证结果信息,验证结果信息中包括回复内容rACK或回复内容rnon-ACK,每个共识副节点将验证结果信息回复至共识主节点;Verification result verification sending module, each consensus secondary node verifies the consistency of the consensus master node verification result and the verification result of this node, and obtains verification result information, which includes the reply content r ACK or the reply content r non-ACK , each consensus secondary node will reply the verification result information to the consensus primary node; 请求应答处理模块,设验证结果信息中回复内容rACK的数量为α或回复内容rnon-ACK的数量为β,在α≥2f或β≤f时,若共识主节点校验成功,允许交易写入共识主节点的最新区块,共识主节点向客户端回复“交易成功”消息;若共识主节点校验失败,则拒绝交易写入,共识主节点回复客户端“交易失败”消息;Request response processing module, set the number of r ACKs in the verification result information as α or the number of r non-ACKs as β, when α≥2f or β≤f, if the consensus master node verification is successful, the transaction is allowed Write the latest block of the consensus master node, and the consensus master node will reply to the client with a "transaction successful"message; if the consensus master node fails to verify the transaction, the transaction will be rejected, and the consensus master node will reply to the client with a "transaction failed"message; 在f≤α﹤2f或f﹤β≤2f时,共识主节点广播通知所有共识副节点进入PBFT共识协议,对交易使用PBFT共识协议重新进行共识;When f≤α﹤2f or f﹤β≤2f, the consensus master node broadcasts a notification to all consensus secondary nodes to enter the PBFT consensus protocol, and uses the PBFT consensus protocol to re-consensus the transaction; 在0≤α﹤f或β﹥2f时,共识主节点通知所有共识副节点触发执行视图更换协议,所有共识副节点根据共识副节点校验的记录,计算本节点选举权重分,将权重分最高的节点选举为新的共识主节点,新的共识主节点输入请求接收校验模块,重新开始共识。When 0≤α﹤f or β﹥2f, the consensus master node notifies all the consensus sub-nodes to trigger the execution of the view replacement protocol, and all the consensus sub-nodes calculate the election weight score of this node according to the records verified by the consensus sub-nodes, and assign the highest weight score The new consensus master node is elected as the new consensus master node, and the new consensus master node inputs the request to receive the verification module and restarts the consensus.
CN202111258601.9A 2021-10-27 2021-10-27 A consortium chain consensus method and system based on weighted incentive master node election Active CN114095209B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111258601.9A CN114095209B (en) 2021-10-27 2021-10-27 A consortium chain consensus method and system based on weighted incentive master node election

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111258601.9A CN114095209B (en) 2021-10-27 2021-10-27 A consortium chain consensus method and system based on weighted incentive master node election

Publications (2)

Publication Number Publication Date
CN114095209A true CN114095209A (en) 2022-02-25
CN114095209B CN114095209B (en) 2025-01-10

Family

ID=80297885

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111258601.9A Active CN114095209B (en) 2021-10-27 2021-10-27 A consortium chain consensus method and system based on weighted incentive master node election

Country Status (1)

Country Link
CN (1) CN114095209B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114928441A (en) * 2022-04-14 2022-08-19 中国科学技术大学 Dual committee consensus method and device
CN115208578A (en) * 2022-07-07 2022-10-18 西安电子科技大学 Unmanned aerial vehicle cluster information consistency sharing method based on block chain
CN116170155A (en) * 2023-02-21 2023-05-26 西安理工大学 Consortium Blockchain Consensus Method Based on PBFT Improvement

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110493198A (en) * 2019-07-26 2019-11-22 北京工业大学 A method of it is attacked based on Sybil in PBFT algorithm defence block chain is improved
WO2019232789A1 (en) * 2018-06-08 2019-12-12 北京大学深圳研究生院 Voting-based consensus method
CN112039964A (en) * 2020-08-24 2020-12-04 大连理工大学 Node reputation consensus method based on block chain
CN112883114A (en) * 2021-02-24 2021-06-01 中国工商银行股份有限公司 Transaction processing method and device applied to block chain

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019232789A1 (en) * 2018-06-08 2019-12-12 北京大学深圳研究生院 Voting-based consensus method
CN110493198A (en) * 2019-07-26 2019-11-22 北京工业大学 A method of it is attacked based on Sybil in PBFT algorithm defence block chain is improved
CN112039964A (en) * 2020-08-24 2020-12-04 大连理工大学 Node reputation consensus method based on block chain
CN112883114A (en) * 2021-02-24 2021-06-01 中国工商银行股份有限公司 Transaction processing method and device applied to block chain

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114928441A (en) * 2022-04-14 2022-08-19 中国科学技术大学 Dual committee consensus method and device
CN115208578A (en) * 2022-07-07 2022-10-18 西安电子科技大学 Unmanned aerial vehicle cluster information consistency sharing method based on block chain
CN116170155A (en) * 2023-02-21 2023-05-26 西安理工大学 Consortium Blockchain Consensus Method Based on PBFT Improvement

Also Published As

Publication number Publication date
CN114095209B (en) 2025-01-10

Similar Documents

Publication Publication Date Title
CN114095209A (en) Weight-incentive-based alliance chain consensus method and system for main node election
US10922195B2 (en) Consensus system downtime recovery
US10671599B2 (en) Consensus system and method
US10725843B2 (en) System and method for ending view change protocol
CA3058233C (en) Consensus system downtime recovery
US20200028947A1 (en) System and method for ending view change protocol
CN113676541B (en) Improved PBFT consensus method
CN110677485A (en) Dynamic layered Byzantine fault-tolerant consensus method based on credit
US10938750B2 (en) Consensus system downtime recovery
CN113660125B (en) A consensus method and device based on a random trusted committee
CN111555858B (en) Practical Byzantine fault-tolerant consensus method based on block chain type storage
CN111556133A (en) Block chain consensus method and system, computer storage medium and electronic equipment
CN112019599A (en) Method and device for synchronizing processing messages during block chain consensus processing
CN118054981A (en) Multi-leader block consensus method, device and storage medium suitable for block chain
CN117375794A (en) A cloud-blockchain hybrid consensus method based on Internet of Vehicles
CN116319277B (en) A Raft leader selection method and system in a heterogeneous environment
CN115334088A (en) Domain name system data synchronization method, device and system based on block chain
CN119299463B (en) Enhanced Byzantine consensus method, device and readable storage medium in a distributed system
AU2019101610A4 (en) Consensus system downtime recovery
AU2019101612A4 (en) Consensus system downtime recovery
CN118473640B (en) Cloud-protogenesis-oriented block chain consensus method and system
CN114928441B (en) Dual committee consensus method and device
CN115842767A (en) Internet of things equipment cluster cooperation method and system based on consensus algorithm
KR20240134441A (en) System for consensus process optimization through improving of consensus stage
WO2023176586A1 (en) Blockchain system, node, and program

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载