A dual-committee consensus method and device
Through the dual-committee consensus method, verifiable random functions are used to select nodes and optimize message broadcasting, which solves the problems of low scalability and high communication overhead of the practical Byzantine fault-tolerant algorithm in the alliance chain, and improves the consensus efficiency of the alliance chain.
Patent Information
- Application Number
- CN202210391712.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-14
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2042-04-14
AI Technical Summary
Existing practical Byzantine fault-tolerant algorithms suffer from low scalability and high communication overhead in consortium chains, resulting in low consensus efficiency.
Adopting a dual-committee consensus method, through the initial committee election process and the dual-committee consensus process, verifiable random functions are used to select the first committee and second committee nodes, and broadcast pre-preparation, preparation, submission and synchronization messages between nodes to improve consensus efficiency.
It improves the consensus efficiency of the alliance chain, reduces the impact of single-committee full-node broadcasts and committee member updates on consensus efficiency, and reduces communication overhead.
Smart Images

Figure CN114928441B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and in particular to a dual-committee consensus method and device. Background Art
[0002] As the core technology of blockchain, consensus algorithm is used to solve the consistency problem of distributed systems. Through consensus algorithm, each node in the blockchain can reach a consensus on the order of transactions. In order to ensure security, the consensus algorithm in the public chain adopts consensus mechanisms such as proof of work and proof of stake based on computing power. However, the existing consensus algorithm is too resource-consuming and has low consensus efficiency, which is not suitable for alliance chain. In alliance chain, a certain efficiency needs to be ensured, so most consensus algorithms adopt distributed consistency algorithms based on practical Byzantine fault tolerance.
[0003] However, the inventors have found through research that although the Practical Byzantine Fault Tolerance (PBFT) algorithm can guarantee a certain degree of efficiency, it also has low scalability. Full-node broadcast not only greatly limits the efficiency of consensus, but also leads to high communication overhead. Therefore, it is necessary to optimize the original Practical Byzantine Fault Tolerance algorithm. Summary of the invention
[0004] In view of this, the present application provides a dual-committee consensus method and device to solve the problem that the practical Byzantine fault-tolerant algorithm has low scalability and the large broadcast of all nodes limits the efficiency of the committee consensus and also leads to high communication overhead. The specific scheme is as follows:
[0005] A dual-committee consensus method is applied to a target alliance chain, the method comprising: an initial committee election process and a dual-committee consensus process;
[0006] The initial committee election process includes: obtaining each node in the target alliance chain, each node having the same initial credibility score, selecting a first committee node and a second committee node from each node based on a verifiable random function, the first committee node belongs to the first committee, the second committee node belongs to the second committee, the number of nodes of the first committee is the same as the number of nodes of the second committee, and the sum of the number of nodes of the first committee and the number of nodes of the second committee does not exceed the number of nodes of the target alliance chain;
[0007] The dual-committee consensus process includes: a first master node broadcasts a first pre-preparation message to a first slave node, and the first slave node receives the first pre-preparation message sent by the first master node and performs a first verification;
[0008] The first master node is elected from the first committee nodes through the verifiable random function, the first slave nodes include: other nodes in the first committee nodes except the first master node, and the first pre-prepared message includes: a first block;
[0009] If the first verification passes, the first slave node sends a first prepare message to the first master node. After the first master node receives the first prepare message, the first master node broadcasts a first commit message to the first slave node and the second committee node, where the first commit message includes the first block.
[0010] After receiving the first submission message, the first slave node performs a second verification. If the second verification passes, the first slave node sends a second submission message to the first master node. After receiving the second submission message, the first master node performs a third verification. If the third verification passes, the first master node broadcasts a first synchronization message to the first slave node and non-committee nodes.
[0011] After the second master node receives the first commit message, the second master node broadcasts a second pre-prepare message to the second slave node, and the second slave node receives the second pre-prepare message sent by the second master node and performs a fourth verification;
[0012] The second master node is elected from the second committee nodes through the verifiable random function, the second slave nodes include other nodes in the second committee nodes except the second master node, and the second pre-prepared message includes: a second block;
[0013] If the fourth verification passes, the second slave node sends a second prepare message to the second master node. After the second master node receives the second prepare message, the second master node broadcasts a third commit message to the second slave node and the first committee node, where the third commit message includes the second block.
[0014] After receiving the third submission message, the second slave node performs a fifth verification. If the fifth verification passes, the second slave node sends a fourth submission message to the second master node. After receiving the fourth submission message, the second master node performs a sixth verification. If the sixth verification passes, the second master node broadcasts a second synchronization message to the second slave node and the non-committee node.
[0015] Preferably, the selecting the first committee node and the second committee node from the nodes based on the verifiable random function comprises:
[0016] All nodes in the target alliance chain generate a corresponding random output value output and a corresponding random proof value pi based on the verifiable random function VRF, where the output is a hash value;
[0017] The probability that a node in the target alliance chain is selected as a committee node is w, and the w value is specifically: w=2c / n, the number of nodes in the target alliance chain is n, and the number of nodes included in a committee is c;
[0018] Determine whether the z value is less than the w value;
[0019] The z value is specifically: z=output / 2 hashlen , the hashlen is the output length of the hash algorithm of the verifiable random function;
[0020] When the z value is less than the w value, the node in the target alliance chain is selected as the committee node, and the committee node broadcasts a committee request message to all nodes in the target alliance chain;
[0021] All nodes in the target alliance chain verify the committee request message;
[0022] If the verification is successful, the committee nodes are sorted in ascending order according to the z values of the committee nodes, and the first committee node and the second committee node are selected from the committee nodes.
[0023] Preferably, the first verification, the second verification, the third verification, the fourth verification, the fifth verification, and the sixth verification include:
[0024] The first verification includes: after the first slave node receives the first pre-preparation message sent by the first master node, determining whether first verification information is correct, if correct, the first verification is passed, and the first verification information includes: a signature of the first master node, a view number of the first master node, a height of the first block, and a hash value of the first block;
[0025] The message format of the first pre-preparation message Pre-Prepare1 is:
[0026] <Pre-Prepare1,v1,h1,BH1,CteTable1,type1,p1> σ p1 , B1;
[0027] in,<Pre-Prepare1,v1,h1,BH1,CteTable1,type1,p1> σp1 represents the signature of the master node p1 of the first committee in the first pre-prepare message, the v1 represents the view number of the first master node, the h1 represents the height of the first block, the BH1 represents the hash value of the first block, the CteTable1 represents the first committee node table, the p1 represents the number of the master node in the first committee node, the type1 represents the signal type, and the B1 represents the first block;
[0028] The second verification includes: after the first slave node receives the first submission message sent by the first master node, determining whether second verification information is correct, if correct, the second verification is passed, and the second verification information includes: the signature of the first master node, the view number of the first master node, the height of the first block, the hash value of the first block, and PG1;
[0029] The message format of the first commit message Commit1 is:
[0030] <Commit1,PG1,Score1,v1,h1,BH1,p1> σ p1 , B1;
[0031] in,<Commit1,PG1,Score1,v1,h1,BH1,p1> σ p1 represents the signature of the master node p1 of the first committee in the first submission message, the PG1 includes 2e+1 of the first preparation messages, the The Score1 is the credibility score of all nodes in the first committee node, and the B1 represents the first block;
[0032] The third verification includes: when the first master node receives 2e of the second submission messages, The third verification is passed;
[0033] The fourth verification includes: after the second slave node receives the second pre-preparation message sent by the second master node, determining whether fourth verification information is correct, if correct, the fourth verification is passed, and the fourth verification information includes: the signature of the second master node, the view number of the second master node, the height of the second block, and the hash value of the second block;
[0034] The message format of the second pre-prepare message Pre-Prepare2 is:
[0035] <Pre-Prepare2,v2,h2,BH2,CteTable2,type2,p2> σ p2, B2;
[0036] in,<Pre-Prepare2,v2,h2,BH2,CteTable2,type2,p2> σ p2 represents the signature of the master node p2 of the second committee in the second pre-prepare message, the v2 represents the view number of the second master node, the h2 represents the height of the second block, the BH2 represents the hash value of the second block, the CteTable2 represents the second committee node table, the p2 represents the number of the master node in the second committee, the type2 represents the signal type, and the B2 represents the second block;
[0037] The fifth verification includes: after the second slave node receives the third submission message sent by the second master node, determining whether fifth verification information is correct, if correct, the fifth verification is passed, and the fifth verification information includes: the signature of the second master node, the view number of the second master node, the height of the second block, the hash value of the second block and PG2;
[0038] The message format of the third commit message Commit3 is:
[0039] <Commit3,PG3,Score3,v2,h2,BH2,p2> σ p2 , B2;
[0040] in,<Commit3,PG3,Score3,v2,h2,BH2,p2> σ p2 represents the signature of the primary node p2 of the second committee in the third submission message, the PG3 includes 2e+1 of the second preparation messages, the Score3 is the credibility score of all nodes in the second committee node, the B2 represents the second block;
[0041] The sixth verification includes: when the second master node receives 2e of the fourth submission messages, The sixth verification is passed.
[0042] Preferably, the method further comprises: a first committee node update process and a second committee node update process;
[0043] The first committee node update process includes:
[0044] When the number of the block currently agreed upon by the first committee is the same as the number of nodes of the first committee, if the type value of the first pre-prepare message of the first committee is the preset second value, the normal dual-committee consensus process is performed, and after the second committee node receives the valid first submission message, the single-committee consensus is performed;
[0045] If the number of blocks on which the first committee has completed consensus is the same as the number of the first committee nodes, the first master node broadcasts a first reconfiguration message to the first committee nodes, and the first master node updates the first committee nodes according to the committee reconfiguration protocol;
[0046] When the type value of the first pre-prepared message is a preset second value, the second committee node executes a single committee consensus;
[0047] The second committee node update is as follows:
[0048] When the number of the block currently agreed upon by the second committee is the same as the number of nodes of the first committee, if the type value of the second pre-prepare message of the second committee is the preset second value, the normal dual-committee consensus process is performed, and after the first committee receives the valid third submission message, the single-committee consensus is performed;
[0049] If the number of blocks on which the second committee nodes have completed consensus is the same as the number of the second committee nodes, the second master node broadcasts a second reconfiguration message to the second committee nodes, and the second master node updates the second committee nodes according to the committee reconfiguration protocol;
[0050] When the type value of the second pre-prepared message is a preset second value, the first committee nodes execute a single committee consensus.
[0051] Preferably, the first master node updates the first committee node according to the committee reconfiguration protocol, including:
[0052] The first master node updates the first committee node according to the committee reconfiguration protocol, specifically:
[0053] The message format of the first reconfiguration message Reconfigure1 is:
[0054] <Reconfigure1,v1,mh1,mBH1,flag1,BD1,p1> σ p1 ;
[0055] in,<Reconfigure1,v1,mh1,mBH1,flag1,BD1,p1> σp1 Indicates the signature of the master node p1 of the first committee in the first reconfiguration message, the p1 indicates the number of the master node in the first committee node, the flag1 has two values, which are used to indicate two situations of node member update in the first committee, the flag1=1 indicates that the first committee node performs a normal node update process, the flag1=2 indicates that the first committee node performs an abnormal node update process, the v1 indicates the view number of the first master node, the BD1 is the number set of the first committee nodes to be replaced, the mh1 is the number of the first blocks that have completed the consensus, and the mBH1 is the hash value of the highest first block that has completed the consensus;
[0056] If flag1=1 in the first reconfiguration message, then verify whether there is an abnormal first committee node in the BD 1. If there is no abnormal first committee node, the verification is successful, and the first slave node sends a first reconfiguration reply message to the first master node;
[0057] The message format of the first reconfiguration reply message Rcf-Reply1 is:
[0058] <Rcf-Reply1,v1,mh1,mBH1,BD1,i1> σ i1 ;
[0059] in,<Rcf-Reply1,v1,mh1,mBH1,BD1,i1> σ i1 represents the signature of the slave node i1 of the first committee in the first reconfiguration reply message, wherein i1 represents the number of the slave node in the first committee node, v1 represents the view number of the first master node, BD1 is the set of numbers of the first committee nodes to be replaced, mh1 is the number of the first blocks that have completed the consensus, and mBH1 is the hash value of the highest first block that has completed the consensus;
[0060] When the first master node receives the first reconfiguration reply message sent by 2e first committee nodes and determines whether the first reconfiguration reply message is correct, if correct, the first master node calculates a first replacement node and updates the first committee node;
[0061] The first reconfiguration reply information includes: the signature of the slave node i1 of the first committee in the first reconfiguration reply message, the view number of the first master node, the number set of the first committee nodes to be replaced, the number of the first blocks that have completed the consensus, and the hash value of the highest first block that has completed the consensus;
[0062] The second master node updates the second committee node according to the committee reconfiguration protocol, specifically:
[0063] The message format of the second reconfiguration message Reconfigure2 is:
[0064] <Reconfigure2,v2,mh2,mBH2,flag2,BD2,p2> σ p2 ;
[0065] in,<Reconfigure2,v2,mh2,mBH2,flag2,BD2,p2> σ p2 represents the signature of the slave node i2 in the second committee in the second reconfiguration message, the i2 represents the number of the slave node in the second committee node, the flag2 has two values, which are used to represent two situations of node member update in the second committee, the flag2=1 represents the normal update process of the second committee node, the flag2=2 represents the abnormal update process of the second committee node, the v2 represents the view number of the second master node, the BD2 is the number set of the second committee nodes to be replaced, the mh2 is the number of the second blocks that have completed the consensus, and the mBH2 is the hash value of the highest second block that has completed the consensus;
[0066] If flag2=1 in the second reconfiguration message, verify whether there is an abnormal second committee node in BD 2. If there is no abnormal second committee node, the verification is successful, and the second slave node sends a second reconfiguration reply message to the second master node.
[0067] The message format of the second reconfiguration reply message Rcf-Reply2 is:
[0068] <Rcf-Reply2,v2,mh2,mBH2,BD2,i2> σ i2 ;
[0069] in,<Reconfigure2,v2,mh2,mBH2,flag2,BD2,p2> σ p2 represents the signature of the slave node i2 in the second committee in the second reconfiguration reply message, the i2 represents the number of the slave node in the second committee node, the v2 represents the view number of the second master node, the BD2 is the set of numbers of the second committee nodes to be replaced, the mh2 is the number of the second blocks that have completed the consensus, and the mBH2 is the hash value of the highest second block that has completed the consensus;
[0070] When the second master node receives the second reconfiguration reply message sent by the 2e second committee nodes and determines whether the second reconfiguration reply message is correct, if correct, the second master node calculates the second replacement node and updates the second committee node;
[0071] The second reconfiguration reply information includes: the signature of the slave node i2 in the second committee in the second reconfiguration reply message, the view number of the second master node, the set of numbers of the second committee nodes to be replaced, the number of the second blocks that have completed the consensus, and the hash value of the highest second block that has completed the consensus.
[0072] Preferably, the first master node calculates the first replacement node, and the second master node calculates the second replacement node, including:
[0073] The first master node calculates the first replacement node, specifically:
[0074] The first master node calculates a first random value z1 through a verifiable random function;
[0075] Where z1 = output / 2 hashlen ;
[0076] The first master node sorts the non-committee nodes according to the credibility scores from high to low;
[0077] If flag1 in the first reconfiguration message is 1, the first replacement node is determined to be the first node in the non-committee node sequence. Nodes and nodes;
[0078] Wherein, the number of non-committee nodes is en;
[0079] If flag1 in the first reconfiguration message is 2, then the first Nodes and A node is the first replacement node;
[0080] Wherein, gn represents the number of non-committee nodes whose credibility scores are ranked as top gn;
[0081] The second master node calculates the second replacement node, specifically:
[0082] The second master node calculates a second random value z2 through a verifiable random function;
[0083] Where z2 = output / 2 hashlen ;
[0084] The second master node sorts the non-committee nodes according to the credibility scores from high to low;
[0085] If flag2 in the second reconfiguration message is 1, the second replacement node is determined to be the first node in the non-committee node ranking. Nodes and nodes;
[0086] Wherein, the number of non-committee nodes is en;
[0087] If flag2 in the second reconfiguration message is 2, then the first node in the non-committee node ranking is Nodes and A node is the second replacement node;
[0088] Wherein, the gn represents the number of non-committee nodes whose credibility scores are ranked in the top gn.
[0089] Preferably, the method further comprises: a first committee node evaluation mechanism, and a second committee node evaluation mechanism;
[0090] The first committee node evaluation mechanism is specifically:
[0091] The first master node receives a second commit message sent by the first slave node;
[0092] If the number of the second submission messages received by the first master node is not less than 2e, the first master node obtains the credibility score reward in the following manner:
[0093] Ps2=Ps1+x;
[0094] Wherein, x is the credibility score reward, Ps1 is the credibility score of the first master node, and Ps2 is the credibility score of the first master node after the reward;
[0095] If the first view switching occurs, the newly generated first master node receives no less than 2e+1 of the first preparation messages, and the first master node receives the credibility score penalty, which is specifically:
[0096] Ps3 = Ps1 - d*x;
[0097] Wherein, d is a penalty parameter, and d is greater than 1, x is a credibility score reward, Ps1 is the credibility score of the first master node, and Ps3 is the credibility score of the first master node after the penalty;
[0098] If the first preparation message received by the newly generated first master node is less than 2e+1, the first credibility score of the first master node is halved. If the first credibility score is lower than the lower limit, the first master node loses the opportunity to participate in the consensus of the first committee node.
[0099] The second committee node evaluation mechanism is specifically as follows:
[0100] The second master node receives a third commit message sent by the second slave node;
[0101] If the number of the fourth submission messages received by the second master node is not less than 2e, the second master node obtains the credibility score reward, and the credibility score reward is specifically:
[0102] Ps5=Ps4+x;
[0103] Wherein, x is the credibility score reward, Ps4 is the credibility score of the second master node, and Ps5 is the credibility score of the second master node after the reward;
[0104] If the second view switching occurs, the newly generated second master node receives no less than 2e+1 second preparation messages, and the second master node receives the credibility score penalty, which is specifically:
[0105] Ps6 = Ps4 - d*x;
[0106] Wherein, d is a penalty parameter, and d is greater than 1, x is a credibility score reward, Ps4 is the credibility score of the second master node, and Ps6 is the credibility score of the second master node after the penalty;
[0107] If the newly generated second master node receives less than 2e+1 of the second preparation messages, the second credibility score of the second master node is halved. If the second credibility score is lower than the lower limit, the second master node loses the opportunity to participate in the consensus of the second committee node.
[0108] Preferably, the first view switching includes:
[0109] If the consensus of the first committee times out or the first master node fails, the first view switching is performed, and the first view switching includes:
[0110] When the second committee node has received the first submission message sent by the first master node, the first committee node broadcasts a first view switching message;
[0111] The message format of the first view switching message View-Change1 is:
[0112] <View-Change1,v1+1,h1,BH1,PR1,i1> σ i1 ;
[0113] in,<View-Change1,v1+1,h1,BH1,PR1,i1> σ i1 represents the signature of the slave node i1 of the first committee in the first view switching message, the i1 represents the number of the slave node in the first committee node, the v1 represents the first view number, the h1 represents the block height of the first block, the BH1 represents the hash value of the first block, and the PR1 represents the preparation message of the first block of the node i1 in the first committee node;
[0114] The newly generated first master node performs verification after receiving the first view switching message. When the newly generated first master node receives 2e+1 first view switching messages, the newly generated first master node broadcasts a first new view message to the first committee node;
[0115] The message format of the first new view message New-View1 is:
[0116] <New-View1,v1+1,V1,PG1,p3> σ p3 ;
[0117] in,<New-View1,v1+1,V1,PG1,p3> σ p3 represents the signature of the new primary node p3 of the first committee in the first new view message, the V1 represents the message set of the first view switch message, the PG1 represents the first preparation message set, and the p3 represents the first new primary node number;
[0118] When the first committee node broadcasts the first view switching message to the second committee node, if the second committee node has broadcast the second block to the first committee node, the second committee node adopts a dual-committee consensus;
[0119] When the first committee node broadcasts the first view switching message to the second committee node, if the second committee node has not broadcast the second block to the first committee node, and the second committee node receives 2e+1 valid first view switching messages, the second committee node adopts a single-committee consensus;
[0120] If the second committee consensus times out or the second master node fails, the second view switching is performed, and the second view switching includes:
[0121] When the first committee node has received the third submission message sent by the second master node, the second committee node broadcasts a second view switching message;
[0122] The message format of the second view switching message View-Change2 is:
[0123] <View-Change2,v2+1,h2,BH2,PR2,i2> σ i2 in,<View-Change2,v2+1,h2,BH2,PR2,i2> σ i2 represents the signature of the slave node i2 of the second committee in the second view switching message, i2 represents the number of the slave node in the second committee node, v2 represents the second view number, h2 represents the block height of the second block, BH2 represents the hash value of the second block, and PR2 represents the preparation message of the second block of the node i2 in the second committee node;
[0124] The newly generated second master node performs verification after receiving the second view switching message. When the newly generated second master node receives 2e+1 second view switching messages, the newly generated second master node broadcasts the second new view message to the second committee nodes;
[0125] The message format of the second new view message is:
[0126] <New-View2,v2+1,V2,PG2,p4> σ p4 ;
[0127] in,<New-View2,v2+1,V2,PG2,p4> σ p4 represents the signature of the new primary node p4 of the second committee in the second new view message, V2 represents the message set of the second view switch message, PG2 represents the second preparation message set, and p4 represents the second new primary node number;
[0128] When the second committee node broadcasts the second view switching message to the first committee node, if the first committee node has broadcast the first block to the second committee node, the first committee node adopts a dual-committee consensus;
[0129] When the second committee node broadcasts the second view switching message to the first committee node, if the first committee node has not broadcast the first block to the second committee node, and the first committee node receives 2e+1 valid second view switching messages, the first committee node adopts a single committee consensus.
[0130] A dual-committee consensus device, applied to a target alliance chain, comprising:
[0131] A committee election module, used to obtain each node in the target alliance chain, each node having the same initial credibility score, and select a first committee node and a second committee node from each node based on a verifiable random function, wherein the first committee node belongs to the first committee, the second committee node belongs to the second committee, the number of nodes of the first committee is the same as the number of nodes of the second committee, and the sum of the number of nodes of the first committee and the number of nodes of the second committee does not exceed the number of nodes of the target alliance chain;
[0132] A dual-committee consensus processing module broadcasts a first pre-preparation message to a first slave node through a first master node, and the first slave node receives the first pre-preparation message sent by the first master node and performs a first verification;
[0133] The first master node is elected from the first committee nodes through the verifiable random function, the first slave nodes include: other nodes in the first committee nodes except the first master node, and the first pre-prepared message includes: a first block;
[0134] If the first verification passes, the first slave node sends a first prepare message to the first master node. After the first master node receives the first prepare message, the first master node broadcasts a first commit message to the first slave node and the second committee node, where the first commit message includes the first block.
[0135] After receiving the first submission message, the first slave node performs a second verification. If the second verification passes, the first slave node sends a second submission message to the first master node. After receiving the second submission message, the first master node performs a third verification. If the third verification passes, the first master node broadcasts a first synchronization message to the first slave node and non-committee nodes.
[0136] After the second master node receives the first commit message, the second master node broadcasts a second pre-prepare message to the second slave node, and the second slave node receives the second pre-prepare message sent by the second master node and performs a fourth verification;
[0137] The second master node is elected from the second committee nodes through the verifiable random function, the second slave nodes include other nodes in the second committee nodes except the second master node, and the second pre-prepared message includes: a second block;
[0138] If the fourth verification passes, the second slave node sends a second prepare message to the second master node. After the second master node receives the second prepare message, the second master node broadcasts a third commit message to the second slave node and the first committee node, where the third commit message includes the second block.
[0139] After receiving the third submission message, the second slave node performs a fifth verification. If the fifth verification passes, the second slave node sends a fourth submission message to the second master node. After receiving the fourth submission message, the second master node performs a sixth verification. If the sixth verification passes, the second master node broadcasts a second synchronization message to the second slave node and the non-committee node.
[0140] Preferably, the selecting the first committee node and the second committee node from the nodes based on the verifiable random function comprises:
[0141] All nodes in the target alliance chain generate a corresponding random output value output and a corresponding random proof value pi based on the verifiable random function VRF, where the output is a hash value;
[0142] The probability that a node in the target alliance chain is selected as a committee node is w, and the w value is specifically: w=2c / n, the number of nodes in the target alliance chain is n, and the number of nodes included in a committee is c;
[0143] Determine whether the z value is less than the w value;
[0144] The z value is specifically: z=output / 2 hashlen , the hashlen is the output length of the hash algorithm of the verifiable random function;
[0145] When the z value is less than the w value, the node in the target alliance chain is selected as the committee node, and the committee node broadcasts a committee request message to all nodes in the target alliance chain;
[0146] All nodes in the target alliance chain verify the committee request message;
[0147] If the verification is successful, the committee nodes are sorted in ascending order according to the z values of the committee nodes, and the first committee node and the second committee node are selected from the committee nodes.
[0148] Compared with the prior art, this application has the following advantages:
[0149] The present application discloses a dual-committee consensus method and device, which are applied to a target alliance chain. The method includes: an initial committee election process and a dual-committee consensus process. The initial committee election process includes: obtaining each node in the target alliance chain, selecting a first committee node and a second committee node from each node; the dual-committee consensus process includes: the master node in the first committee broadcasts a pre-preparation message to the slave node, so that the slave node feeds back the preparation message to the master node, the master node then sends a submission message to the slave node and the second committee, the slave node feeds back to the master node after receiving the submission message, so that the master node broadcasts a synchronization message, after the second committee receives the submission message, the master node in the second committee sends a pre-preparation message to the slave node, so that the slave node feeds back the preparation message to the master node, the master node broadcasts the submission message to the slave node and the first committee node, the slave node feeds back to the master node after receiving the submission message, so that the master node broadcasts the synchronization message. In the above consensus process, by electing the first committee and the second committee and then reaching a consensus, the problems of low scalability and high communication overhead based on the practical Byzantine fault-tolerant algorithm are solved, and the influence of single-committee full-node broadcast, committee member update and view switching on the efficiency of single-committee consensus is reduced, and the efficiency of committee consensus is further improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0150] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and a person skilled in the art can also obtain other drawings based on these drawings.
[0151] Figure 1 A schematic diagram of a dual-committee consensus method provided in an embodiment of the present application;
[0152] Figure 2 A schematic diagram of a dual-committee consensus process provided in an embodiment of the present application;
[0153] Figure 3 A schematic diagram of a node update process provided in an embodiment of the present application;
[0154] Figure 4 A schematic diagram of a process flow of a dual-committee consensus device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0155] The present application provides a dual-committee consensus method and device, which improves the efficiency of committee consensus by electing a first committee and a second committee to reach a consensus.
[0156] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0157] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0158] A two-committee consensus method used in this application is described below. Figure 1 , Figure 1 A flowchart of a dual-committee consensus method provided in an embodiment of the present application, wherein the embodiment of the present application at least includes the following processes: an initial committee election process and a dual-committee consensus process;
[0159] S101. The initial committee election process includes: obtaining each node in the target alliance chain, each node having the same initial credibility score, selecting a first committee node and a second committee node from each node based on a verifiable random function, the first committee node belongs to the first committee, the second committee node belongs to the second committee, the number of nodes of the first committee is the same as the number of nodes of the second committee, and the sum of the number of nodes of the first committee and the number of nodes of the second committee does not exceed the number of nodes of the target alliance chain;
[0160] In an embodiment of the present application, each node in the target alliance chain is obtained, and the initial credibility score of each node is the same. Since the first committee node and the second committee node represent all the nodes in the alliance chain, the initial credibility score of each node in the target alliance chain is the same, which ensures the fairness of selecting the first committee node and the second committee node. Then, based on the verifiable random function, the first committee node and the second committee node are selected from each node. The first committee node belongs to the first committee, and the second committee node belongs to the second committee. The number of nodes of the first committee is the same as the number of nodes of the second committee, and the sum of the number of nodes of the first committee and the number of nodes of the second committee does not exceed the number of nodes of the target alliance chain. In this way, the fairness of selecting the first committee node and the second committee node is further improved through the verifiable random function.
[0161] Optionally, an implementation method of selecting the first committee node and the second committee node from the nodes based on the verifiable random function may be:
[0162] All nodes in the target alliance chain select the first committee node and the second committee node through the verifiable random function VRF. The status of the first committee node and the second committee node is equivalent. The specific selection process is as follows:
[0163] All nodes in the target alliance chain use the verifiable random function VRF formula (1) to generate the corresponding random output value output. The formula (1) is as follows:
[0164] output=VRF_hash(SK,randvalue)
[0165] All nodes in the target alliance chain use the Verifiable Random Function (VRF) formula (2) to generate the corresponding random proof value pi. The specific formula (2) is as follows:
[0166] pi=VRF_proof(SK,randvalue)
[0167] In formula (1) and formula (2), SK is the private key of the SK node, PK is the public key of the PK node, and output is the hash value, which ranges from [0, 2 hashlen -1], the random input randvalue is the hash value of the highest block in the current target alliance chain block (when the highest block is empty, the transaction hash value or a random value preset by the system can be used);
[0168] The highest block in the target alliance chain is specifically: when the first block in the target alliance chain completes consensus, the block height of the first block is 1, and after the second block completes consensus, the height of the second block is 2, and so on. Therefore, the highest block in the target alliance chain block is: the block in the target alliance chain that has completed consensus and has the highest block height.
[0169] Assume that the probability of a node in the target alliance chain being selected as a committee node is w, and the specific value of w is: w = 2c / n. The number of nodes in the target alliance chain is n, where the number of nodes included in a committee is c. Since output1 is a random hash value, then z (z = output1 / 2 hashlen , which is the output length of the hash algorithm of the verifiable random function) value must also be a random value, so the random value z and the random value w can be used to determine whether the node in the target alliance chain is selected as a committee node;
[0170] Determine whether the z value is less than the w value;
[0171] Among them, the specific z value is: z = output1 / 2 hashlen , hashlen is the output length of the hash algorithm of the verifiable random function;
[0172] When the z value is less than the w value, the node in the target alliance chain is selected as the committee node, and the selected target alliance chain node broadcasts the committee request message to all nodes in the target alliance chain; the message format of the committee request message Committee-Request is:
[0173] <Committee-Request,randvalue,pi,output1,i> σ i
[0174] Among them, the random input randvalue is the hash value of the highest block in the current target alliance chain block (when the highest block is empty, the transaction hash value or a random value preset by the system can be used).<Committee-Request,randvalue,pi,output1,i> σ i The signature of node i in the target alliance chain;
[0175] After all nodes in the target alliance chain receive the committee request message, all nodes in the target alliance chain verify whether the selected target alliance chain node is a legitimate committee node through the verifiable random function VRF, that is, the selected target alliance chain node is verified through formula (3) and formula (4). Formula (3) is specifically: output 1 = VRF_proof_to_hash(pi)
[0176] Formula (4) is specifically: VRF_verify(PK,randvalue,pi);
[0177] In formula (3) and formula (4), pi is the random proof value of node i, PK is the public key of PK node, and randvalue is the hash value of the highest block in the current target alliance chain block (when the highest block is empty, the transaction hash value or a random value preset by the system can be used);
[0178] All nodes in the target alliance chain receive pi sent by the selected target alliance chain node, and substitute pi into formula (3) to calculate the output1 value. If output1 is equal to output, the verification performed by formula (3) passes. When the return value of formula (4) is true, the verification performed by formula (4) passes. When the verifications of formula (3) and formula (4) (verifiable random function VRF verification) are both passed, it is determined again whether the z value of the selected target alliance chain node is less than the w value. If the z value of the selected target alliance chain node is less than the w value, the z value of the selected target alliance chain node is saved, and then the z values of all nodes in the committee node are evenly divided into two committees in the order of z value from small to large. The nodes with the smallest z value in the two committees are respectively used as the main nodes of the first consensus of each committee. After the election of the committee node is completed, the committee can start a new consensus. In this way, the selection of the committee node ensures the fairness of selecting the first committee node and the second committee node.
[0179] Dual Committee Consensus Process Reference Figure 2 , as shown in steps S102 to S107;
[0180] Figure 2 In the figure, committee 1 represents the first committee, committee 2 represents the second committee, and the identification process of the first committee and the identification process of the second committee are both divided into a pre-preparation phase (Pre-Prepare), a preparation phase (Prepare), a commit phase 1 (Commit1), a commit phase 2 (Commit2), and a broadcast synchronization phase (Synchronize);
[0181] The dual-committee consensus process includes the following steps S102 to S107:
[0182] S102: The first master node broadcasts a first pre-preparation message to the first slave node, and the first slave node receives the first pre-preparation message sent by the first master node and performs a first verification;
[0183] In the embodiment of the present application, the pre-preparation phase (Pre-Prepare) in the first committee is specifically as follows: the first master node in the first committee packages transactions to form a first block, and broadcasts a pre-preparation message to the first slave node, and the first slave node receives the first pre-preparation message sent by the first master node and performs a first verification;
[0184] The first master node is elected from the first committee nodes through a verifiable random function, the first slave nodes include: other nodes in the first committee nodes except the first master node, and the first pre-prepared message includes: the first block.
[0185] S103: If the first verification passes, the first slave node sends a first prepare message to the first master node. After the first master node receives the first prepare message, the first master node broadcasts a first commit message to the first slave node and the second committee node, where the first commit message includes the first block.
[0186] In the embodiment of the present application, the preparation phase (Prepare) of the first committee includes: if the first verification is passed, the first slave node in the first committee sends a first preparation message Prepare to the first master node, and when the first master node receives After a valid first prepare message consistent with the first pre-prepare is sent, the first master node broadcasts the first commit message to the first slave node and the second committee node, so that the second committee node synchronizes the credibility score of the first committee node according to Score1 in the first commit message, wherein the message format of the first prepare message Prepare1 is:
[0187] <Prepare1,v1,h1,BH1,type1,i1> σ i1 ;
[0188] in,<Prepare1,v1,h1,BH1,type1,i1> σ i1 represents the signature of the master node i1 of the first committee in the first prepare message, v1 represents the view number of the first master node, h1 represents the height of the first block, BH1 represents the hash value of the first block, and type1 represents the signal type;
[0189] The first submission message includes the first block. If the pre-preparation message received by the first slave node passes the verification, the first preparation message sent by the first slave node is a valid first preparation message. By sending the valid first preparation message, the security of the interaction between the master node and the slave node in the first committee is improved, and the efficiency of the node interaction is improved.
[0190] Optionally, the first verification may include:
[0191] After receiving the first pre-preparation message sent by the first master node, the first slave node determines whether the first verification information is correct. If correct, the first verification is passed. The first verification information includes: the signature of the first master node, the view number of the first master node, the height of the first block, and the hash value of the first block;
[0192] The message format of the first pre-prepare message Pre-Prepare1 is:
[0193] <Pre-Prepare1,v1,h1,BH1,CteTable1,type1,p1> σp1 , B1;
[0194] in,<Pre-Prepare1,v1,h1,BH1,CteTable1,p1> σ p1 represents the signature of the master node p1 of the first committee in the first pre-prepare message, v1 represents the view number of the first master node, h1 represents the height of the first block, BH1 represents the hash value of the first block, CteTable1 represents the first committee node table, p1 represents the number of the master node in the first committee node, type1 represents the signal type, and B1 represents the first block.
[0195] S104. After receiving the first submission message, the first slave node performs a second verification. If the second verification passes, the first slave node sends a second submission message to the first master node. After receiving the second submission message, the first master node performs a third verification. If the third verification passes, the first master node broadcasts a first synchronization message to the first slave node and non-committee nodes.
[0196] In an embodiment of the present application, the submission phase 1 (Commit1) of the first committee includes: after the first slave node receives the first submission message, the second verification is performed. If the second verification passes, the submission phase 2 (Commit2) of the first committee is performed. The submission phase 2 of the first committee includes: the first slave node sends the second submission message to the first master node. After the first master node receives the second submission message, the third verification is performed. If the third verification passes, the broadcast synchronization phase (Synchronize) of the first committee is performed. The broadcast synchronization phase of the first committee includes: the first master node broadcasts the first synchronization message to the first slave node and the non-committee node, and the synchronization message broadcast by the first master node to the non-committee node needs to be accompanied by the generated block, and the generated block is the first block.
[0197] The message format of the first synchronization message Synchronize1 is:
[0198] <Synchronize1,v1,h1,BH1,TG1,Prove1,p1> σ p1 ;
[0199] in,<Synchronize1,v1,h1,BH1,TG1,Prove1,p1> σ p1 It represents the signature of the master node p1 of the first committee in the first synchronization message, v1 represents the view number of the first master node, h1 represents the height of the first block, BH1 represents the hash value of the first block, TG1 represents the second submission message set, and Prove1 represents the proof that the second committee message has been received.
[0200] Optionally, a second verification may include:
[0201] After receiving the first submission message sent by the first master node, the first slave node determines whether the second verification information is correct. If it is correct, the second verification is passed. The second verification information includes: the signature of the first master node, the view number of the first master node, the height of the first block, the hash value of the first block and PG1;
[0202] The message format of the first commit message Commit1 is:
[0203] <Commit1,PG1,Score1,v1,h1,BH1,p1> σ p1 , B1;
[0204] in,<Commit1,PG1,Score1,type1,v1,h1,BH1,p1> σ p1 Indicates the signature of the master node p1 of the first committee in the first commit message. PG1 includes 2e+1 first prepare messages. Score1 is the credibility score of all nodes in the first committee node, and B1 represents the first block.
[0205] Optional, third verification, may include:
[0206] The third verification includes: when the first master node receives 2e second submission messages, The third verification passes, where the message format of the second commit message Commit2 is:
[0207] <Commit2,v1,h1,BH1,i1> σ i1 ;
[0208] in,<Commit2,v1,h1,BH1,i1> σ i1 represents the signature of the master node i1 of the first committee in the second submission message, v1 represents the view number of the first master node, h1 represents the height of the first block, and BH1 represents the hash value of the first block.
[0209] S105. After the second master node receives the first commit message, the second master node broadcasts a second pre-prepare message to the second slave node, and the second slave node receives the second pre-prepare message sent by the second master node and performs a fourth verification;
[0210] In an embodiment of the present application, the pre-preparation stage (Pre-Prepare) of the second committee includes: after the second master node receives the first submission message, the second committee starts consensus, the second master node in the second committee packages transactions to form a second block, and broadcasts the second pre-prepare message to the second slave node, and the second slave node receives the second pre-prepare message sent by the second master node and performs a fourth verification.
[0211] The second master node is elected from the second committee nodes through a verifiable random function, the second slave nodes include other nodes in the second committee nodes except the second master node, and the second pre-prepared message includes: a second block;
[0212] S106. If the fourth verification passes, the second slave node sends a second prepare message to the second master node. After the second master node receives the second prepare message, the second master node broadcasts a third commit message to the second slave node and the first committee node, where the third commit message includes the second block.
[0213] In the embodiment of the present application, the preparation phase (Prepare) of the second committee includes: if the fourth verification is passed, the second slave node in the second committee sends a second preparation message to the second master node, and when the second master node receives After a valid second prepare message consistent with the second prepare message, the second master node broadcasts a third commit message to the second slave node and the first committee node, so that the first committee node synchronizes the credibility score of the second committee node according to Score3 in the third commit message, wherein the message format of the second prepare message Prepare2 is:
[0214] <Prepare2,v2,h2,BH2,type2,i2> σ i2 ;
[0215] in,<Prepare2,v2,h2,BH2,type2,i2> σ i2 represents the signature of the master node i2 of the second committee in the second prepare message, v2 represents the view number of the second master node, h2 represents the second block height, BH2 represents the hash value of the second block, and type2 represents the signal type;
[0216] The second submission message includes the second block. If the pre-preparation message received by the second slave node passes the verification, the second preparation message sent by the second slave node is a valid second preparation message. By sending the valid second preparation message, the security of the interaction between the master node and the slave node in the second committee is improved, and the efficiency of the node interaction is improved.
[0217] Optionally, the fourth verification may include:
[0218] After receiving the second pre-preparation message sent by the second master node, the second slave node determines whether the fourth verification information is correct. If correct, the fourth verification is passed. The fourth verification information includes: the signature of the second master node, the view number of the second master node, the height of the second block, and the hash value of the second block;
[0219] The message format of the second pre-prepare message Pre-Prepare2 is:
[0220] <Pre-Prepare2,v2,h2,BH2,CteTable2,type2,p2> σ p2 , B2;
[0221] in,<Pre-Prepare2,v2,h2,BH2,CteTable2,type2,p2> σ p2 represents the signature of the master node p2 of the second committee in the second pre-prepare message, v2 represents the view number of the second master node, h2 represents the height of the second block, BH2 represents the hash value of the second block, CteTable2 represents the second committee node table, type2 represents the signal type, p2 represents the number of the master node in the second committee, and B2 represents the second block.
[0222] S107. After receiving the third submission message, the second slave node performs a fifth verification. If the fifth verification passes, the second slave node sends a fourth submission message to the second master node. After receiving the fourth submission message, the second master node performs a sixth verification. If the sixth verification passes, the second master node broadcasts a second synchronization message to the second slave node and the non-committee node.
[0223] In an embodiment of the present application, the submission phase 1 (Commit1) of the second committee includes: after the second slave node receives the third submission message, the fifth verification is performed. If the fifth verification passes, the submission phase 2 (Commit2) of the second committee is performed. The submission phase 2 of the second committee includes: the second slave node sends a fourth submission message to the second master node. After the second master node receives the fourth submission message, the sixth verification is performed. If the sixth verification passes, the broadcast synchronization phase (Synchronize) of the second committee is performed. The broadcast synchronization phase of the second committee includes: the second master node broadcasts the second synchronization message to the second slave node and the non-committee node, and the synchronization message broadcast by the second master node to the non-committee node needs to be accompanied by the generated block, and the generated block is the second block.
[0224] The message format of the second synchronization message Synchronize2 is:
[0225] <Synchronize2,v2,h2,BH2,TG2,Prove2,p2> σ p2 ;
[0226] in,<Synchronize2,v2,h2,BH2,TG2,Prove2,p2> σ p2 It represents the signature of the master node p2 of the second committee in the second synchronization message, v2 represents the view number of the second master node, h2 represents the height of the second block, BH2 represents the hash value of the second block, TG2 represents the fourth submission message set, and Prove2 represents the proof that the first committee message has been received.
[0227] Optionally, the fifth verification may include:
[0228] After receiving the third submission message sent by the second master node, the second slave node determines whether the fifth verification information is correct. If correct, the fifth verification is passed. The fifth verification information includes: the signature of the second master node, the view number of the second master node, the height of the second block, the hash value of the second block, and PG2;
[0229] The message format of the third commit message Commit3 is:
[0230] <Commit3,PG3,Score3,v2,h2,BH2,p2> σ p2 , B2;
[0231] in,<Commit3,PG3,Score3,v2,h2,BH2,p2> σ p2 It represents the signature of the primary node p2 of the second committee in the third submission message. PG3 includes 2e+1 second preparation messages. Score3 is the credibility score of all nodes in the second committee node. B2 represents the second block;
[0232] Optionally, the sixth verification may include:
[0233] When the second master node receives 2e fourth commit messages, The sixth verification passed;
[0234] The message format of the fourth commit message Commit4 is:
[0235] <Commit4,v2,h2,BH2,i2> σ i2 ;
[0236] in,<Commit4,v2,h2,BH2,i2> σ i2represents the signature of the master node i2 of the second committee in the fourth submission message, v2 represents the view number of the second master node, h2 represents the second block height, and BH2 represents the hash value of the second block; through the above verification, the security of the dual-committee consensus process can be improved.
[0237] Optionally, the dual-committee identification method in the present application may further include: a first committee node update process and a second committee node update process;
[0238] The first committee node update process includes:
[0239] When the number of the block currently agreed upon by the first committee is the same as the number of nodes of the first committee, if the type value of the first pre-prepared message of the first committee is the preset second value, the normal dual-committee consensus process is performed, and after the second committee node receives the valid first submission message, a single-committee consensus is performed, wherein after the first slave node receives the first submission message, a second verification is performed, and if the second verification passes, the first submission message is the valid first submission message;
[0240] If the number of blocks on which the first committee has completed consensus is the same as the number of the first committee nodes, the first master node broadcasts a first reconfiguration message to the first committee nodes, the first master node updates the first committee nodes according to the committee reconfiguration protocol, and when the type value of the first pre-prepared message is a preset second value, the second committee nodes execute a single committee consensus;
[0241] Furthermore, in the first committee node update process, the first master node updates the first committee node according to the committee reconfiguration protocol, referring to Figure 3 , as shown in steps S201 to S204;
[0242] S201, Reconfigure phase:
[0243] When the number of blocks in the first committee node reaches the same condition as the number of blocks in the first committee node, the first committee node needs to be updated. In order to ensure that the consensus in the second committee can continue, the first master node broadcasts the first reconfiguration message to the first committee node and sends the first submission message to the second committee node.
[0244] The message format of the first reconfiguration message Reconfigure1 is:
[0245] <Reconfigure1,v1,mh1,mBH1,flag1,BD1,p1> σp1 ;
[0246] in,<Reconfigure1,v1,mh1,mBH1,flag1,BD1,p1> σ p1 The signature of the master node p1 of the first committee in the first reconfiguration message is represented, the p1 represents the number of the master node in the first committee node, the flag1 has two values, which are used to represent two situations of node member update in the first committee, the flag1=1 represents that the first committee node performs a normal node update process, the flag1=2 represents that the first committee node performs an abnormal node update process, the v1 represents the view number of the first master node, the BD1 is the number set of the first committee nodes to be replaced, the mh1 is the number of the first blocks that have completed the consensus, and the mBH1 is the highest hash value of the first block that has completed the consensus.
[0247] S202, Reconfiguration reply phase (Rcf-Reply):
[0248] If flag1=1 in the first reconfiguration message, then verify whether there is an abnormal first committee node in the BD 1. If there is no abnormal first committee node, the verification is successful, and the first slave node sends a first reconfiguration reply message to the first master node;
[0249] The message format of the first reconfiguration reply message Rcf-Reply1 is:
[0250] <Rcf-Reply1,v1,mh1,mBH1,BD1,i1> σ i1 ;
[0251] in,<Rcf-Reply1,v1,mh1,mBH1,BD1,i1> σ i1 represents the signature of the slave node i1 of the first committee in the first reconfiguration reply message, wherein i1 represents the number of the slave node in the first committee node, v1 represents the view number of the first master node, BD1 is the set of numbers of the first committee nodes to be replaced, mh1 is the number of the first blocks that have completed the consensus, and mBH1 is the hash value of the highest first block that has completed the consensus;
[0252] When the first master node receives the first reconfiguration reply message sent by 2e first committee nodes, and determines whether the first reconfiguration reply information is correct;
[0253] The first reconfiguration reply information includes: the signature of the slave node i1 of the first committee in the first reconfiguration reply message, the view number of the first master node, the set of numbers of the first committee nodes to be replaced, the number of the first blocks that have completed the consensus, and the hash value of the highest first block that has completed the consensus.
[0254] S203, Reconfiguration Commit Phase (Rcf-Commit):
[0255] If the first reconfiguration reply information is correct, the first master node calculates a first replacement node;
[0256] Optionally, the first master node calculating the first replacement node may include:
[0257] The first master node calculates a first random value z1 through a verifiable random function VRF;
[0258] Where z1 = output / 2 hashlen , outout represents the random output hash value generated by VRF, and hashlen represents the output length of the VRF hash algorithm;
[0259] The first master node sorts the non-committee nodes according to the credibility scores from high to low;
[0260] If flag1 in the first reconfiguration message is 1, the first replacement node is determined to be the first node in the non-committee node sequence. Nodes and nodes;
[0261] Wherein, the number of non-committee nodes is en;
[0262] If flag1 in the first reconfiguration message is 2, then the first Nodes and A node is the first replacement node;
[0263] Wherein, gn represents the number of non-committee nodes whose credibility scores are ranked as top gn;
[0264] Next, the master node in the first committee broadcasts a first reconfiguration commit message Rcf-Commit1 to all nodes in the alliance chain. The message format of the first reconfiguration commit message is:
[0265] <Rcf-Commit1,v1,RV1,output1,pi1,BD1,GD1,p> σ p ,
[0266] in,<Rcf-Commit,v1,RV1,output1,pi1,BD1,GD1,p1> σ p1 represents the signature of the first master node p1 of the first committee in the first reconfiguration submission message, RV1 is the received Rcf-Reply message set (including the Reconfigure1 message of the first master node), GD1 is the number set of the first replacement node, the BD1 is the number set of the first committee node to be replaced, output, pi is: the first master node generates the corresponding random output value output1 and the corresponding random proof value pi1 based on the verifiable random function VRF, and v1 represents the view number of the first master node;
[0267] After receiving the first reconfiguration submission message, the nodes in the alliance chain need to verify whether the first reconfiguration information is correct. If the first reconfiguration information is correct, the update phase (Update) is carried out;
[0268] The first reconfiguration information includes: the signature of the first master node p1, GD1 calculated by the first master node, and RV1 and BD1.
[0269] S204, Update phase (Update):
[0270] The first replacement node in GD1 sends the first update message (Update1) to the first committee node to request to join the first committee. The format of the first update message is<Update1,v1,GD1,j1> σ j1 ,
[0271] in,<Update1,v1,GD1,j1> σ j1 The signature of the first replacement node j1 in the first update message is represented. The first committee node verifies whether the first update message is correct. If correct, the first replacement node joins the first committee successfully and the first committee node update is completed. In this way, the first committee node is updated to ensure the security of the first committee.
[0272] The Second Committee update process includes:
[0273] When the number of the block currently agreed upon by the second committee is the same as the number of nodes of the first committee, if the type value of the second pre-prepare message of the second committee is the preset second value, the normal dual-committee consensus process is performed, and after the first committee receives the valid third submission message, a single-committee consensus is performed, wherein after the second slave node receives the third submission message, a fifth verification is performed, and if the fifth verification passes, the third submission message is a valid third submission message;
[0274] If the number of blocks on which the second committee has completed consensus is the same as the number of the second committee nodes, the second master node broadcasts a second reconfiguration message to the second committee nodes, and the second master node updates the second committee nodes according to the committee reconfiguration protocol. When the type value of the second pre-prepared message is a preset second value, the first committee nodes execute a single committee consensus.
[0275] Furthermore, in the second committee node update process, the second master node updates the second committee node according to the committee reconfiguration protocol, as shown in steps S301 to S304;
[0276] S301, Reconfigure phase:
[0277] When the number of blocks in the second committee node reaches the same condition as the number of the second committee nodes, the second committee node needs to be updated. In order to ensure that the consensus in the second committee can continue, the second master node broadcasts the second reconfiguration message to the second committee node and sends the third submission message to the first committee node.
[0278] The message format of the second reconfiguration message Reconfigure2 is:
[0279] <Reconfigure2,v2,mh2,mBH2,flag2,BD2,p2> σ p2 ;
[0280] in,<Reconfigure2,v2,mh2,mBH2,flag2,BD2,p2> σ p2 The signature of the master node p2 of the second committee in the second reconfiguration message is represented, the p2 represents the number of the master node in the second committee node, the flag2 has two values, which are used to represent two situations of node member updates in the second committee, the flag2=1 represents that the second committee node performs a normal node update process, the flag2=2 represents that the second committee node performs an abnormal node update process, the v2 represents the view number of the second master node, the BD2 is the number set of the second committee nodes to be replaced, the mh2 is the number of the second blocks that have completed the consensus, and the mBH2 is the hash value of the highest second block that has completed the consensus.
[0281] S202, Reconfiguration reply phase (Rcf-Reply):
[0282] If flag2=2 in the second reconfiguration message, verify whether there is an abnormal second committee node in the BD 2. If there is no abnormal second committee node, the verification is successful, and the second slave node sends a second reconfiguration reply message to the second master node.
[0283] The message format of the second reconfiguration reply message Rcf-Reply2 is:
[0284] <Rcf-Reply2,v2,mh2,mBH2,BD2,i2> σ i2 ;
[0285] in,<Rcf-Reply2,v2,mh2,mBH2,BD2,i2> σ i2 represents the signature of the slave node i2 of the second committee in the second reconfiguration reply message, wherein i2 represents the number of the slave node in the second committee node, v2 represents the view number of the second master node, BD2 is the set of numbers of the second committee nodes to be replaced, mh2 is the number of the second blocks that have completed the consensus, and mBH2 is the hash value of the highest second block that has completed the consensus;
[0286] When the second master node receives the second reconfiguration reply message sent by 2e second committee nodes, and determines whether the second reconfiguration reply information is correct;
[0287] The second reconfiguration reply information includes: the signature of the slave node i2 of the second committee in the second reconfiguration reply message, the view number of the second master node, the set of numbers of the second committee nodes to be replaced, the number of the second blocks that have completed the consensus, and the hash value of the highest second block that has completed the consensus.
[0288] S203, Reconfiguration Commit Phase (Rcf-Commit):
[0289] If the second reconfiguration reply information is correct, the second master node calculates a second replacement node;
[0290] Optionally, the second master node calculates the second replacement node, which may include:
[0291] The second master node calculates a second random value z2 through a verifiable random function VRF;
[0292] Where z2 = output / 2 hashlen , outout represents the random output hash value generated by VRF, and hashlen represents the output length of the VRF hash algorithm;
[0293] The second master node sorts the non-committee nodes according to the credibility scores from high to low;
[0294] If flag2 in the second reconfiguration message is 1, the second replacement node is determined to be the first node in the non-committee node ranking. Nodes and nodes;
[0295] Wherein, the number of non-committee nodes is en;
[0296] If flag2 in the second reconfiguration message is 2, then the first node in the non-committee node ranking is Nodes and A node is the second replacement node;
[0297] Wherein, gn represents the number of non-committee nodes whose credibility scores are ranked as top gn;
[0298] Next, the master node in the second committee broadcasts a second reconfiguration commit message Rcf-Commit2 to all nodes in the alliance chain. The message format of the second reconfiguration commit message is:
[0299] <Rcf-Commit2,v2,RV2,output2,pi2,BD2,GD2,p> σ p ,
[0300] in,<Rcf-Commit,v2,RV2,output2,pi2,BD2,GD2,p2> σ p2 represents the signature of the second master node p2 of the second committee in the second reconfiguration submission message, RV2 is the received Rcf-Reply message set (including the Reconfigure2 message of the second master node), GD2 is the number set of the second replacement node, the BD2 is the number set of the second committee node to be replaced, output, pi is: the second master node generates the corresponding random output value output2 and the corresponding random proof value pi2 based on the verifiable random function VRF, and v2 represents the view number of the second master node;
[0301] After receiving the second reconfiguration submission message, the nodes in the alliance chain need to verify whether the second reconfiguration information is correct. If the second reconfiguration information is correct, the update phase (Update) is carried out;
[0302] The second reconfiguration information includes: the signature of the second master node p2, GD2 calculated by the second master node, and RV2 and BD2.
[0303] S204, Update phase (Update):
[0304] The second replacement node in GD2 sends a second update message (Update2) to the second committee node to request to join the second committee. The format of the second update message is<Update2,v2,GD2,j2> σ j2 ,
[0305] in,<Update2,v2,GD2,j2> σ j2 The signature of the second replacement node j2 in the second update message is represented. The second committee node verifies whether the second update message is correct. If correct, the second replacement node joins the second committee successfully, and the second committee node update is completed. In this way, the first committee node is updated to ensure the security of the first committee.
[0306] Optionally, the dual-committee identification method in the present application may further include: a first committee node evaluation mechanism, and a second committee node evaluation mechanism;
[0307] The first committee node evaluation mechanism includes:
[0308] The first master node receives a second commit message sent by the first slave node;
[0309] If the number of the second submission messages received by the first master node is not less than 2e, the first master node obtains the credibility score reward in the following manner:
[0310] Ps2=Ps1+x;
[0311] Wherein, x is the credibility score reward, Ps1 is the credibility score of the first master node, and Ps2 is the credibility score of the first master node after the reward;
[0312] If the first view switching occurs, the newly generated first master node receives no less than 2e+1 of the first preparation messages, and the first master node receives the credibility score penalty, which is specifically:
[0313] Ps3 = Ps1 - d*x;
[0314] Wherein, d is a penalty parameter, and d is greater than 1, x is a credibility score reward, Ps1 is the credibility score of the first master node, and Ps3 is the credibility score of the first master node after the penalty;
[0315] If the first block consensus in the first master node fails, the first master node performs a first view switch. When performing the first view switch, the first slave node in the first committee sends a first preparation message to the first master node. If the number of the first preparation messages received by the first master node is not less than 2e+1, then the first pre-preparation phase of the first master node is not wrong, but the first block consensus of the first master node times out, and the first master node is still penalized by the credibility score;
[0316] If the first master node and the newly generated first master node receive less than 2e+1 of the first preparation messages, it means that the consensus of the first master node fails and the credibility score of the first master node is halved. If the credibility score of the first master node is lower than the lower limit, the first master node will be marked as an abnormal node and will not be allowed to participate in subsequent consensus. The first master node will be replaced through the first committee reconfiguration protocol.
[0317] The second committee node evaluation mechanism is specifically as follows:
[0318] The second master node receives a third commit message sent by the second slave node;
[0319] If the number of the fourth submission messages received by the second master node is not less than 2e+1, the second master node obtains the credibility score reward, and the credibility score reward is specifically:
[0320] Ps5=Ps4+x;
[0321] Wherein, x is the credibility score reward, Ps4 is the credibility score of the second master node, and Ps5 is the credibility score of the second master node after the reward;
[0322] If the second view switching occurs, the newly generated second master node receives no less than 2e+1 second preparation messages, and the second master node receives the credibility score penalty, which is specifically:
[0323] Ps6 = Ps4 - d*x;
[0324] Wherein, d is a penalty parameter, and d is greater than 1, x is a credibility score reward, Ps4 is the credibility score of the second master node, and Ps6 is the credibility score of the second master node after the penalty;
[0325] If the second block consensus in the second master node fails, the second master node performs a second view switch. When performing the second view switch, the second slave node in the second committee sends a second preparation message to the second master node. If the number of the second preparation messages received by the second master node is not less than 2e+1, then the second pre-preparation phase of the second master node is not wrong, but the second block consensus of the second master node times out, and the credibility score penalty is still imposed on the second master node;
[0326] If the number of second submission messages received by the second master node for the second time is less than 2e+1, it means that the consensus of the second master node fails, and the credibility score of the second master node is halved. If the credibility score of the second master node is lower than the lower limit, the second master node will be marked as an abnormal node and will not be allowed to participate in subsequent consensus. The second master node will be replaced through the second committee reconfiguration protocol.
[0327] Although the nodes in the alliance chain have a high degree of credibility, the existence of malicious nodes cannot be ruled out. In the dual-committee consensus process, the master node plays a very important role. If the master node fails, the consensus will definitely fail. In order to further improve the credibility and consensus success rate of the first and second committees.
[0328] Optionally, in this embodiment, in the dual-committee recognition method, the first view switching and the second view switching may include:
[0329] If the consensus of the first committee nodes times out or the first master node fails, the first view switching is performed. The first view switching process is:
[0330] When the second committee node has received the first submission message sent by the first master node, it indicates that the first master node in the first committee has completed the preparation phase, and the first block can be confirmed. If the first committee node broadcasts the first view switching message, the view switching in the first committee will not affect the legitimacy of the newly generated block of the first master node.
[0331] The message format of the first view switching message View-Change1 is:
[0332] <View-Change1,v1+1,h1,BH1,PR1,i1> σ i1 ;
[0333] in,<View-Change1,v1+1,h1,BH1,PR1,i1> σ i1represents the signature of the slave node i1 of the first committee in the first view switching message, the i1 represents the number of the slave node in the first committee node, the v1 represents the first view number, the h1 represents the block height of the first block, the BH1 represents the hash value of the first block, and the PR1 represents the preparation message of the first block of the node i1 in the first committee node;
[0334] The newly generated first master node performs verification after receiving the first view switching message. When the newly generated first master node receives 2e+1 first view switching messages, the newly generated first master node broadcasts a first new view message New-View to the first committee node;
[0335] The message format of the first new view message New-View1 is:
[0336] <New-View1,v1+1,V1,PG1,p3> σ p3 ;
[0337] in,<New-View1,v1+1,V1,PG1,p3> σ p3 represents the signature of the new primary node p3 of the first committee in the first new view message, the V1 represents the message set of the first view switch message, the PG1 represents the first preparation message set, and the p3 represents the first new primary node number;
[0338] When the first committee node broadcasts the first view switching message to the second committee node, if the second committee node has broadcast the second block to the first committee node, the second committee node adopts a dual-committee consensus;
[0339] When the first committee node broadcasts the first view switching message to the second committee node, if the second committee node has not broadcast the second block to the first committee node, and the second committee node receives 2e+1 valid first view switching messages, the second committee node adopts a single committee consensus, and if the newly generated first master node performs verification after receiving the first view switching message and the verification passes, the first view switching message is a valid first view switching message;
[0340] In addition, when the second committee node conducts a new round of second committee node consensus, generates a new second block and broadcasts it to the first committee node, and when the first committee node is able to receive the new second block broadcast by the second committee node, the two committee nodes adopt a dual-committee consensus;
[0341] Furthermore, when the second committee node does not receive the first submission message, it means that the first master node in the first committee has not generated the first block, and the first master node in the first committee has not completed the preparation stage. The first preparation message in PG1 is basically empty. The newly generated first master node needs to re-perform the first committee node consensus, and the first committee node will not broadcast the first view switching message to the second committee node. The second committee node waits for the newly generated first master node to send the newly generated first submission message before performing a dual-committee consensus.
[0342] If the second committee consensus times out or the second master node fails, the second view switching is performed, and the second view switching includes:
[0343] When the first committee node has received the third commit message sent by the second master node, it indicates that the second master node in the second committee has completed the preparation phase, and the second block can be confirmed. If the second committee node broadcasts the first view switching message, the view switching in the second committee will not affect the legitimacy of the newly generated block of the second master node.
[0344] The message format of the second view switching message View-Change2 is:
[0345] <View-Change2,v2+1,h2,BH2,PR2,i2> σ i2 in,<View-Change2,v2+1,h2,BH2,PR2,i2> σ i2 represents the signature of the slave node i2 of the second committee in the second view switching message, i2 represents the number of the slave node in the second committee node, v2 represents the second view number, h2 represents the block height of the second block, BH2 represents the hash value of the second block, and PR2 represents the preparation message of the second block of the node i2 in the second committee node;
[0346] The newly generated second master node performs verification after receiving the second view switching message. When the newly generated second master node receives 2e+1 second view switching messages, the newly generated second master node broadcasts the second new view message to the second committee nodes;
[0347] The message format of the second new view message is:
[0348] <New-View2,v2+1,V2,PG2,p4> σ p4 ;
[0349] in,<New-View2,v2+1,V2,PG2,p4> σp4 represents the signature of the new primary node p4 of the second committee in the second new view message, V2 represents the message set of the second view switch message, PG2 represents the second preparation message set, and p4 represents the second new primary node number;
[0350] When the second committee node broadcasts the second view switching message to the first committee node, if the first committee node has broadcast the first block to the second committee node, the first committee node adopts a dual-committee consensus;
[0351] When the second committee node broadcasts the second view switching message to the first committee node, if the first committee node has not broadcast the first block to the second committee node, and the first committee node receives 2e+1 valid second view switching messages, the first committee node adopts a single-committee consensus, and if the newly generated second master node performs verification after receiving the second view switching message and the verification passes, the second view switching message is a valid second view switching message.
[0352] In addition, when the first committee node conducts a new round of first committee node consensus, generates a new first block and broadcasts it to the second committee node, and when the second committee node is able to receive the new first block broadcast by the first committee node, the two committee nodes adopt a dual-committee consensus;
[0353] Furthermore, when the first committee node does not receive the third submission message, it means that the second master node in the second committee has not generated the second block, and the second master node in the second committee has not completed the preparation stage. The second preparation message in PG3 is basically empty. The newly generated second master node needs to re-perform the second committee node consensus, and the second committee node will not broadcast the second view switching message to the first committee node. The first committee node waits for the newly generated second master node to send the newly generated third submission message before performing a dual-committee consensus.
[0354] In this way, the above-mentioned first view switching and second view switching are performed, ensuring the activity of the first committee and the second committee.
[0355] like Figure 4 As shown, it is a structural schematic diagram of a dual-committee consensus device provided in an embodiment of the present application. A dual-committee consensus device will be introduced below. For related contents, please refer to the above method embodiment. The dual-committee consensus device includes:
[0356] The above embodiment of the present application provides a dual-committee consensus method based on the above. Next, a dual-committee consensus device also provided in the embodiment of the present application is described, which executes the above Figure 1 Next, the function of the dual-committee consensus device is described. The structural block diagram of the dual-committee consensus device is as follows: Figure 4 As shown, including:
[0357] The dual-committee consensus device is applied to the target alliance chain, and the device includes:
[0358] The committee election module 401 is used to obtain each node in the target alliance chain, each node has the same initial credibility score, and select a first committee node and a second committee node from each node based on a verifiable random function, the first committee node belongs to the first committee, the second committee node belongs to the second committee, the number of nodes of the first committee is the same as the number of nodes of the second committee, and the sum of the number of nodes of the first committee and the number of nodes of the second committee does not exceed the number of nodes of the target alliance chain;
[0359] The dual-committee consensus processing module 402 broadcasts a first pre-preparation message to a first slave node through a first master node, and the first slave node receives the first pre-preparation message sent by the first master node and performs a first verification;
[0360] The first master node is elected from the first committee nodes through the verifiable random function, the first slave nodes include: other nodes in the first committee nodes except the first master node, and the first pre-prepared message includes: a first block;
[0361] If the first verification passes, the first slave node sends a first prepare message to the first master node. After the first master node receives the first prepare message, the first master node broadcasts a first commit message to the first slave node and the second committee node, where the first commit message includes the first block.
[0362] After receiving the first submission message, the first slave node performs a second verification. If the second verification passes, the first slave node sends a second submission message to the first master node. After receiving the second submission message, the first master node performs a third verification. If the third verification passes, the first master node broadcasts a first synchronization message to the first slave node and non-committee nodes.
[0363] After the second master node receives the first commit message, the second master node broadcasts a second pre-prepare message to the second slave node, and the second slave node receives the second pre-prepare message sent by the second master node and performs a fourth verification;
[0364] The second master node is elected from the second committee nodes through the verifiable random function, the second slave nodes include other nodes in the second committee nodes except the second master node, and the second pre-prepared message includes: a second block;
[0365] If the fourth verification passes, the second slave node sends a second prepare message to the second master node. After the second master node receives the second prepare message, the second master node broadcasts a third commit message to the second slave node and the first committee node, where the third commit message includes the second block.
[0366] After receiving the third submission message, the second slave node performs a fifth verification. If the fifth verification passes, the second slave node sends a fourth submission message to the second master node. After receiving the fourth submission message, the second master node performs a sixth verification. If the sixth verification passes, the second master node broadcasts a second synchronization message to the second slave node and the non-committee node.
[0367] Optionally, the committee election module 401 may include:
[0368] The selecting a first committee node and a second committee node from each of the nodes based on a verifiable random function comprises:
[0369] All nodes in the target alliance chain generate a corresponding random output value output and a corresponding random proof value pi based on the verifiable random function VRF, where the output is a hash value;
[0370] The probability that a node in the target alliance chain is selected as a committee node is w, and the w value is specifically: w=2c / n, the number of nodes in the target alliance chain is n, and the number of nodes included in a committee is c;
[0371] Determine whether the z value is less than the w value;
[0372] The z value is specifically: z=output / 2 hashlen , the hashlen is the output length of the hash algorithm of the verifiable random function;
[0373] When the z value is less than the w value, the node in the target alliance chain is selected as the committee node, and the committee node broadcasts a committee request message to all nodes in the target alliance chain;
[0374] All nodes in the target alliance chain verify the committee request message;
[0375] If the verification is successful, the committee nodes are sorted in ascending order according to the z values of the committee nodes, and the first committee node and the second committee node are selected from the committee nodes.
[0376] Optionally, the dual-committee consensus processing module 402 may include: a verification module;
[0377] The verification module may include:
[0378] The first verification, the second verification, the third verification, the fourth verification, the fifth verification, and the sixth verification may include:
[0379] The first verification includes: after the first slave node receives the first pre-preparation message sent by the first master node, determining whether first verification information is correct, if correct, the first verification is passed, and the first verification information includes: a signature of the first master node, a view number of the first master node, a height of the first block, and a hash value of the first block;
[0380] The message format of the first pre-preparation message Pre-Prepare1 is:
[0381] <Pre-Prepare1,v1,h1,BH1,CteTable1,type1,p1> σ p1 , B1;
[0382] in,<Pre-Prepare1,v1,h1,BH1,CteTable1,p1> σ p1 represents the signature of the master node p1 of the first committee in the first pre-prepare message, the v1 represents the view number of the first master node, the h1 represents the height of the first block, the BH1 represents the hash value of the first block, the CteTable1 represents the first committee node table, the type1 represents the signal type, the p1 represents the number of the master node in the first committee node, and the B1 represents the first block;
[0383] The second verification includes: after the first slave node receives the first submission message sent by the first master node, determining whether second verification information is correct, if correct, the second verification is passed, and the second verification information includes: the signature of the first master node, the view number of the first master node, the height of the first block, the hash value of the first block, and PG1;
[0384] The message format of the first commit message Commit1 is:
[0385] <Commit1,PG1,Score1,v1,h1,BH1,p1> σ p1 , B1;
[0386] in,<Commit1,PG1,Score1,v1,h1,BH1,p1> σ p1 represents the signature of the master node p1 of the first committee in the first submission message, the PG1 includes 2e+1 of the first preparation messages, the The Score1 is the credibility score of all nodes in the first committee node, and the B1 represents the first block;
[0387] The third verification includes: when the first master node receives 2e of the second submission messages, The third verification is passed;
[0388] The fourth verification includes: after the second slave node receives the second pre-preparation message sent by the second master node, determining whether fourth verification information is correct, if correct, the fourth verification is passed, and the fourth verification information includes: the signature of the second master node, the view number of the second master node, the height of the second block, and the hash value of the second block;
[0389] The message format of the second pre-prepare message Pre-Prepare2 is:
[0390] <Pre-Prepare2,v2,h2,BH2,CteTable2,type2,p2> σ p2 , B2;
[0391] in,<Pre-Prepare2,v2,h2,BH2,CteTable2,type2,p2> σ p2represents the signature of the master node p2 of the second committee in the second pre-prepare message, the v2 represents the view number of the second master node, the h2 represents the height of the second block, the BH2 represents the hash value of the second block, the CteTable2 represents the second committee node table, the type2 represents the signal type, the p2 represents the number of the master node in the second committee, and the B2 represents the second block;
[0392] The fifth verification includes: after the second slave node receives the third submission message sent by the second master node, determining whether fifth verification information is correct, if correct, the fifth verification is passed, and the fifth verification information includes: the signature of the second master node, the view number of the second master node, the height of the second block, the hash value of the second block and PG2;
[0393] The message format of the third commit message Commit3 is:
[0394] <Commit3,PG3,Score3,v2,h2,BH2,p2> σ p2 , B2;
[0395] in,<Commit3,PG3,Score3,v2,h2,BH2,p2> σ p2 represents the signature of the primary node p2 of the second committee in the third submission message, the PG3 includes 2e+1 of the second preparation messages, the Score3 is the credibility score of all nodes in the second committee node, the B2 represents the second block;
[0396] The sixth verification includes: when the second master node receives 2e of the fourth submission messages, The sixth verification is passed.
[0397] Optionally, the dual-committee consensus device may include: an update module:
[0398] The update module may include:
[0399] First Committee Node Update Process and Second Committee Node Update Process;
[0400] The first committee node update process includes:
[0401] When the number of the block currently agreed upon by the first committee is the same as the number of nodes of the first committee, if the type value of the first pre-prepared message of the first committee is the preset second value, the normal dual-committee consensus process is performed, and after the second committee node receives the valid first submission message, a single-committee consensus is performed, wherein after the first slave node receives the first submission message, a second verification is performed, and if the second verification passes, the first submission message is the valid first submission message;
[0402] If the number of blocks on which the first committee has completed consensus is the same as the number of the first committee nodes, the first master node broadcasts a first reconfiguration message to the first committee nodes, and the first master node updates the first committee nodes according to the committee reconfiguration protocol;
[0403] When the type value of the first pre-prepared message is a preset second value, the second committee node executes a single committee consensus;
[0404] The second committee node update is as follows:
[0405] When the number of the block currently agreed upon by the second committee is the same as the number of nodes of the first committee, if the type value of the second pre-prepare message of the second committee is the preset second value, the normal dual-committee consensus process is performed, and after the first committee receives the valid third submission message, a single-committee consensus is performed, wherein after the second slave node receives the third submission message, a fifth verification is performed, and if the fifth verification passes, the third submission message is a valid third submission message;
[0406] If the number of blocks on which the second committee nodes have completed consensus is the same as the number of the second committee nodes, the second master node broadcasts a second reconfiguration message to the second committee nodes, and the second master node updates the second committee nodes according to the committee reconfiguration protocol;
[0407] When the type value of the second pre-prepared message is a preset second value, the first committee nodes execute a single committee consensus.
[0408] Optionally, the update module may include:
[0409] The first master node updates the first committee node according to the committee reconfiguration protocol, including:
[0410] The first master node updates the first committee node according to the committee reconfiguration protocol, specifically:
[0411] The message format of the first reconfiguration message Reconfigure1 is:
[0412] <Reconfigure1,v1,mh1,mBH1,flag1,BD1,p1> σ p1 ;
[0413] in,<Reconfigure1,v1,mh1,mBH1,flag1,BD1,p1> σ p1 Indicates the signature of the master node p1 of the first committee in the first reconfiguration message, the p1 indicates the number of the master node in the first committee node, the flag1 has two values, which are used to indicate two situations of node member update in the first committee, the flag1=1 indicates that the first committee node performs a normal node update process, the flag1=2 indicates that the first committee node performs an abnormal node update process, the v1 indicates the view number of the first master node, the BD1 is the number set of the first committee nodes to be replaced, the mh1 is the number of the first blocks that have completed the consensus, and the mBH1 is the hash value of the highest first block that has completed the consensus;
[0414] If flag1=1 in the first reconfiguration message, then verify whether there is an abnormal first committee node in the BD 1. If there is no abnormal first committee node, the verification is successful, and the first slave node sends a first reconfiguration reply message to the first master node;
[0415] The message format of the first reconfiguration reply message Rcf-Reply1 is:
[0416] <Rcf-Reply1,v1,mh1,mBH1,BD1,i1> σ i1 ;
[0417] in,<Rcf-Reply1,v1,mh1,mBH1,BD1,i1> σ i1 represents the signature of the slave node i1 of the first committee in the first reconfiguration reply message, wherein i1 represents the number of the slave node in the first committee node, v1 represents the view number of the first master node, BD1 is the set of numbers of the first committee nodes to be replaced, mh1 is the number of the first blocks that have completed the consensus, and mBH1 is the hash value of the highest first block that has completed the consensus;
[0418] When the first master node receives the first reconfiguration reply message sent by 2e first committee nodes and determines whether the first reconfiguration reply message is correct, if correct, the first master node calculates a first replacement node and updates the first committee node;
[0419] The first reconfiguration reply information includes: the signature of the slave node i1 of the first committee in the first reconfiguration reply message, the view number of the first master node, the number set of the first committee nodes to be replaced, the number of the first blocks that have completed the consensus, and the hash value of the highest first block that has completed the consensus;
[0420] The second master node updates the second committee node according to the committee reconfiguration protocol, specifically:
[0421] The message format of the second reconfiguration message Reconfigure2 is:
[0422] <Reconfigure2,v2,mh2,mBH2,flag2,BD2,p2> σ p2 ;
[0423] in,<Reconfigure2,v2,mh2,mBH2,flag2,BD2,p2> σ p2 represents the signature of the slave node i2 in the second committee in the second reconfiguration message, the i2 represents the number of the slave node in the second committee node, the flag2 has two values, which are used to represent two situations of node member update in the second committee, the flag2=1 represents the normal update process of the second committee node, the flag2=2 represents the abnormal update process of the second committee node, the v2 represents the view number of the second master node, the BD2 is the number set of the second committee nodes to be replaced, the mh2 is the number of the second blocks that have completed the consensus, and the mBH2 is the hash value of the highest second block that has completed the consensus;
[0424] If flag2=1 in the second reconfiguration message, verify whether there is an abnormal second committee node in BD 2. If there is no abnormal second committee node, the verification is successful, and the second slave node sends a second reconfiguration reply message to the second master node.
[0425] The message format of the second reconfiguration reply message Rcf-Reply2 is:
[0426] <Rcf-Reply2,v2,mh2,mBH2,BD2,i2> σ i2 ;
[0427] in,<Reconfigure2,v2,mh2,mBH2,flag2,BD2,p2> σ p2 represents the signature of the slave node i2 in the second committee in the second reconfiguration reply message, the i2 represents the number of the slave node in the second committee node, the v2 represents the view number of the second master node, the BD2 is the set of numbers of the second committee nodes to be replaced, the mh2 is the number of the second blocks that have completed the consensus, and the mBH2 is the hash value of the highest second block that has completed the consensus;
[0428] When the second master node receives the second reconfiguration reply message sent by the 2e second committee nodes and determines whether the second reconfiguration reply message is correct, if correct, the second master node calculates the second replacement node and updates the second committee node;
[0429] The second reconfiguration reply information includes: the signature of the slave node i2 in the second committee in the second reconfiguration reply message, the view number of the second master node, the set of numbers of the second committee nodes to be replaced, the number of the second blocks that have completed the consensus, and the hash value of the highest second block that has completed the consensus.
[0430] Optionally, the update module may include:
[0431] The first master node calculates a first replacement node, and the second master node calculates a second replacement node, including:
[0432] The first master node calculates the first replacement node, specifically:
[0433] The first master node calculates a first random value z1 through a verifiable random function;
[0434] Where z1 = output / 2 hashlen ;
[0435] The first master node sorts the non-committee nodes according to the credibility scores from high to low;
[0436] If flag1 in the first reconfiguration message is 1, the first replacement node is determined to be the first node in the non-committee node sequence. Nodes and nodes;
[0437] Wherein, the number of non-committee nodes is en;
[0438] If flag1 in the first reconfiguration message is 2, then the first Nodes and A node is the first replacement node;
[0439] Wherein, gn represents the number of non-committee nodes whose credibility scores are ranked as top gn;
[0440] The second master node calculates the second replacement node, specifically:
[0441] The second master node calculates a second random value z2 through a verifiable random function;
[0442] Where z2 = output / 2 hashlen ;
[0443] The second master node sorts the non-committee nodes according to the credibility scores from high to low;
[0444] If flag2 in the second reconfiguration message is 1, the second replacement node is determined to be the first node in the non-committee node ranking. Nodes and nodes;
[0445] Wherein, the number of non-committee nodes is en;
[0446] If flag2 in the second reconfiguration message is 2, then the first node in the non-committee node ranking is Nodes and A node is the second replacement node;
[0447] Wherein, the gn represents the number of non-committee nodes whose credibility scores are ranked in the top gn.
[0448] Optionally, the dual-committee consensus device may include: a node evaluation module;
[0449] The node evaluation module may include:
[0450] The first committee node evaluation mechanism, and the second committee node evaluation mechanism;
[0451] The first committee node evaluation mechanism is specifically:
[0452] The first master node receives a second commit message sent by the first slave node;
[0453] If the number of the second submission messages received by the first master node is not less than 2e, the first master node obtains the credibility score reward in the following manner:
[0454] Ps2=Ps1+x;
[0455] Wherein, x is the credibility score reward, Ps1 is the credibility score of the first master node, and Ps2 is the credibility score of the first master node after the reward;
[0456] If the first view switching occurs, the number of the first preparation messages received by the newly generated first master node is no less than 2e+1, and the first master node obtains the credibility score penalty, which is specifically:
[0457] Ps3 = Ps1 - d*x;
[0458] Wherein, d is a penalty parameter, and d is greater than 1, x is a credibility score reward, Ps1 is the credibility score of the first master node, and Ps3 is the credibility score of the first master node after the penalty;
[0459] If, when the first view switching occurs, the newly generated first master node receives less than 2e+1 of the first preparation messages, the first credibility score of the first master node is halved. If the first credibility score is lower than the lower limit, the first master node loses the opportunity to participate in the consensus of the first committee nodes.
[0460] The second committee node evaluation mechanism is specifically as follows:
[0461] The second master node receives a third commit message sent by the second slave node;
[0462] If the number of the fourth submission messages received by the second master node is not less than 2e, the second master node obtains the credibility score reward, and the credibility score reward is specifically:
[0463] Ps5=Ps4+x;
[0464] Wherein, x is the credibility score reward, Ps4 is the credibility score of the second master node, and Ps5 is the credibility score of the second master node after the reward;
[0465] If the second view switching occurs, the newly generated second master node receives no less than 2e+1 second preparation messages, and the second master node receives the credibility score penalty, which is specifically:
[0466] Ps6 = Ps4 - d*x;
[0467] Wherein, d is a penalty parameter, and d is greater than 1, x is a credibility score reward, Ps4 is the credibility score of the second master node, and Ps6 is the credibility score of the second master node after the penalty;
[0468] If the newly generated second master node receives less than 2e+1 of the second preparation messages, the second credibility score of the second master node is halved. If the second credibility score is lower than the lower limit, the second master node loses the opportunity to participate in the consensus of the second committee node.
[0469] Optionally, the dual-committee consensus device may include: a view switching module;
[0470] The view switching module includes:
[0471] Switching between a first view and a second view;
[0472] If the consensus of the first committee node times out or the first master node fails, the first view switching is performed, and the first view switching includes:
[0473] When the second committee node has received the first submission message sent by the first master node, the first committee node broadcasts a first view switching message to the first committee and the second committee;
[0474] The message format of the first view switching message View-Change1 is:
[0475] <View-Change1,v1+1,h1,BH1,PR1,i1> σ i1 ;
[0476] in,<View-Change1,v1+1,h1,BH1,PR1,i1> σ i1 represents the signature of the slave node i1 of the first committee in the first view switching message, the i1 represents the number of the slave node in the first committee node, the v1 represents the first view number, the h1 represents the block height of the first block, the BH1 represents the hash value of the first block, and the PR1 represents the preparation message of the first block of the node i1 in the first committee node;
[0477] The newly generated first master node performs verification after receiving the first view switching message. When the newly generated first master node receives 2e+1 first view switching messages, the newly generated first master node broadcasts a first new view message to the first committee node;
[0478] The message format of the first new view message New-View1 is:
[0479] <New-View1,v1+1,V1,PG1,p3> σ p3 ;
[0480] in,<New-View1,v1+1,V1,PG1,p3> σ p3 represents the signature of the new primary node p3 of the first committee in the first new view message, the V1 represents the message set of the first view switch message, the PG1 represents the first preparation message set, and the p3 represents the first new primary node number;
[0481] When the first committee node broadcasts the first view switching message to the second committee node, if the second committee node has broadcast the second block to the first committee node, the second committee node adopts a dual-committee consensus;
[0482] When the first committee node broadcasts the first view switching message to the second committee node, if the second committee node has not broadcast the second block to the first committee node, and the second committee node receives 2e+1 valid first view switching messages, the second committee node adopts a single committee consensus, and if the newly generated first master node performs verification after receiving the first view switching message and the verification passes, the first view switching message is a valid first view switching message;
[0483] If the second master node does not broadcast the second synchronization message to the second slave node and the first committee node, the second view switching is performed, and the second view switching includes:
[0484] When the first committee node has received the third submission message sent by the second master node, the second committee node broadcasts a second view switching message to the first committee and the second committee;
[0485] The message format of the second view switching message View-Change2 is:
[0486] <View-Change2,v2+1,h2,BH2,PR2,i2> σ i2 in,<View-Change2,v2+1,h2,BH2,PR2,i2> σ i2 represents the signature of the slave node i2 of the second committee in the second view switching message, i2 represents the number of the slave node in the second committee node, v2 represents the second view number, h2 represents the block height of the second block, BH2 represents the hash value of the second block, and PR2 represents the preparation message of the second block of the node i2 in the second committee node;
[0487] The newly generated second master node performs verification after receiving the second view switching message. When the newly generated second master node receives 2e+1 second view switching messages, the newly generated second master node broadcasts the second new view message to the second committee nodes;
[0488] The message format of the second new view message is:
[0489] <New-View2,v2+1,V2,PG2,p4> σ p4 ;
[0490] in,<New-View2,v2+1,V2,PG2,p4> σ p4 represents the signature of the new primary node p4 of the second committee in the second new view message, V2 represents the message set of the second view switch message, PG2 represents the second preparation message set, and p4 represents the second new primary node number;
[0491] When the newly generated second master node broadcasts the second new view message to the first committee node, if the first committee node has broadcast the first block to the second committee node, the first committee node adopts a dual-committee consensus;
[0492] When the newly generated second master node broadcasts the second new view message to the first committee node, if the first committee node has not broadcast the first block to the second committee node, and the first committee node receives 2e+1 valid second view switching messages, the first committee node adopts a single committee consensus, and if the newly generated second master node performs verification after receiving the second view switching message and the verification passes, the second view switching message is a valid second view switching message.
[0493] The present application discloses a dual-committee consensus method and device, which are applied to a target alliance chain. The method includes: an initial committee election process and a dual-committee consensus process. The initial committee election process includes: obtaining each node in the target alliance chain, selecting a first committee node and a second committee node from each node; the dual-committee consensus process includes: the master node in the first committee broadcasts a pre-preparation message to the slave node, so that the slave node feeds back the preparation message to the master node, the master node then sends a submission message to the slave node and the second committee, the slave node feeds back to the master node after receiving the submission message, so that the master node broadcasts a synchronization message, after the second committee receives the submission message, the master node in the second committee sends a pre-preparation message to the slave node, so that the slave node feeds back the preparation message to the master node, the master node broadcasts the submission message to the slave node and the first committee node, the slave node feeds back to the master node after receiving the submission message, so that the master node broadcasts the synchronization message. In the above consensus process, the problems of low scalability and high communication overhead based on the practical Byzantine fault-tolerant algorithm are solved, and the influence of single-committee full-node broadcast, committee member update and view switching on the efficiency of single-committee consensus is reduced, and the efficiency of committee consensus is further improved.
[0494] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0495] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A two-committee consensus method, characterized in that Applied to the target alliance chain, the method includes: an initial committee election process and a dual-committee consensus process; The initial committee election process includes: obtaining each node in the target alliance chain, each node having the same initial credibility score, selecting a first committee node and a second committee node from each node based on a verifiable random function, the first committee node belongs to the first committee, the second committee node belongs to the second committee, the number of nodes of the first committee is the same as the number of nodes of the second committee, and the sum of the number of nodes of the first committee and the number of nodes of the second committee does not exceed the number of nodes of the target alliance chain; The dual-committee consensus process includes: a first master node broadcasts a first pre-preparation message to a first slave node, and the first slave node receives the first pre-preparation message sent by the first master node and performs a first verification; The first master node is elected from the first committee nodes through the verifiable random function, the first slave nodes include: other nodes in the first committee nodes except the first master node, and the first pre-prepared message includes: a first block; If the first verification passes, the first slave node sends a first prepare message to the first master node. After the first master node receives the first prepare message, the first master node broadcasts a first commit message to the first slave node and the second committee node, where the first commit message includes the first block. After receiving the first submission message, the first slave node performs a second verification. If the second verification passes, the first slave node sends a second submission message to the first master node. After receiving the second submission message, the first master node performs a third verification. If the third verification passes, the first master node broadcasts a first synchronization message to the first slave node and non-committee nodes. After the second master node receives the first commit message, the second master node broadcasts a second pre-prepare message to the second slave node, and the second slave node receives the second pre-prepare message sent by the second master node and performs a fourth verification; The second master node is elected from the second committee nodes through the verifiable random function, the second slave nodes include other nodes in the second committee nodes except the second master node, and the second pre-prepared message includes: a second block; If the fourth verification passes, the second slave node sends a second prepare message to the second master node. After the second master node receives the second prepare message, the second master node broadcasts a third commit message to the second slave node and the first committee node, where the third commit message includes the second block. After receiving the third submission message, the second slave node performs a fifth verification. If the fifth verification passes, the second slave node sends a fourth submission message to the second master node. After receiving the fourth submission message, the second master node performs a sixth verification. If the sixth verification passes, the second master node broadcasts a second synchronization message to the second slave node and the non-committee node.
2. The method according to claim 1, characterized in that The selecting a first committee node and a second committee node from each of the nodes based on a verifiable random function comprises: All nodes in the target alliance chain generate a corresponding random output value output and a corresponding random proof value pi based on the verifiable random function VRF, where the output is a hash value; The probability that a node in the target alliance chain is selected as a committee node is w, and the w value is specifically: w=2c / n, the number of nodes in the target alliance chain is n, and the number of nodes included in a committee is c; Determine whether the z value is less than the w value; The z value is specifically: z=output / 2 hashlen , the hashlen is the output length of the hash algorithm of the verifiable random function; When the z value is less than the w value, the node in the target alliance chain is selected as the committee node, and the committee node broadcasts a committee request message to all nodes in the target alliance chain; All nodes in the target alliance chain verify the committee request message; If the verification is successful, the committee nodes are sorted in ascending order according to the z values of the committee nodes, and the first committee node and the second committee node are selected from the committee nodes.
3. The method according to claim 1, characterized in that The first verification, the second verification, the third verification, the fourth verification, the fifth verification, and the sixth verification include: The first verification includes: after the first slave node receives the first pre-preparation message sent by the first master node, determining whether first verification information is correct, if correct, the first verification is passed, and the first verification information includes: a signature of the first master node, a view number of the first master node, a height of the first block, and a hash value of the first block; The message format of the first pre-preparation message Pre-Prepare1 is: <Pre-Prepare1,v1,h1,BH1,CteTable1,type1,p1>σ p1 ,B1; in,<Pre-Prepare1,v1,h1,BH1,CteTable1,type1,p1> σ p1 represents the signature of the master node p1 of the first committee in the first pre-prepare message, the v1 represents the view number of the first master node, the h1 represents the height of the first block, the BH1 represents the hash value of the first block, the CteTable1 represents the first committee node table, the p1 represents the number of the master node in the first committee node, the type1 represents the signal type, and the B1 represents the first block; The second verification includes: after the first slave node receives the first submission message sent by the first master node, determining whether second verification information is correct, if correct, the second verification is passed, and the second verification information includes: the signature of the first master node, the view number of the first master node, the height of the first block, the hash value of the first block, and PG1; The message format of the first commit message Commit1 is: <Commit1,PG1,Score1,v1,h1,BH1,p1>σ p1 ,B1; in,<Commit1,PG1,Score1,v1,h1,BH1,p1> σ p1 represents the signature of the primary node p1 of the first committee in the first commit message, the PG1 includes 2e+1 of the first prepare messages, the The Score1 is the credibility score of all nodes in the first committee node, and the B1 represents the first block; The third verification includes: when the first master node receives 2e of the second submission messages, The third verification is passed; The fourth verification includes: after the second slave node receives the second pre-preparation message sent by the second master node, determining whether fourth verification information is correct, if correct, the fourth verification is passed, and the fourth verification information includes: the signature of the second master node, the view number of the second master node, the height of the second block, and the hash value of the second block; The message format of the second pre-prepare message Pre-Prepare2 is: <Pre-Prepare2,v2,h2,BH2,CteTable2,type2,p2>σ p2 ,B2; in,<Pre-Prepare2,v2,h2,BH2,CteTable2,type2,p2> σ p2 represents the signature of the master node p2 of the second committee in the second pre-prepare message, the v2 represents the view number of the second master node, the h2 represents the height of the second block, the BH2 represents the hash value of the second block, the CteTable2 represents the second committee node table, the p2 represents the number of the master node in the second committee, the type2 represents the signal type, and the B2 represents the second block; The fifth verification includes: after the second slave node receives the third submission message sent by the second master node, determining whether fifth verification information is correct, if correct, the fifth verification is passed, and the fifth verification information includes: the signature of the second master node, the view number of the second master node, the height of the second block, the hash value of the second block and PG2; The message format of the third commit message Commit3 is: <Commit3,PG3,Score3,v2,h2,BH2,p2>σ p2 ,B2; in,<Commit3,PG3,Score3,v2,h2,BH2,p2> σ p2 represents the signature of the primary node p2 of the second committee in the third submission message, the PG3 includes 2e+1 of the second preparation messages, the Score3 is the credibility score of all nodes in the second committee node, the B2 represents the second block; The sixth verification includes: when the second master node receives 2e of the fourth submission messages, The sixth verification is passed.
4. The method according to claim 1, characterized in that: The method further includes: a first committee node update process and a second committee node update process; The first committee node update process includes: When the number of the block currently agreed upon by the first committee is the same as the number of nodes of the first committee, if the type value of the first pre-prepare message is the preset second value, the dual-committee consensus process is performed, and after the second committee node receives the valid first submission message, the single-committee consensus is performed; If the number of blocks on which the first committee has completed consensus is the same as the number of the first committee nodes, the first master node broadcasts a first reconfiguration message to the first committee nodes, and the first master node updates the first committee nodes according to the committee reconfiguration protocol; The second committee node update is as follows: When the number of the block currently agreed upon by the second committee is the same as the number of nodes of the first committee, if the type value of the second pre-prepare message is the preset second value, the dual-committee consensus process is performed, and after the first committee receives the valid third submission message, the single-committee consensus is performed; If the number of blocks on which the second committee nodes have completed consensus is the same as the number of the second committee nodes, the second master node broadcasts a second reconfiguration message to the second committee nodes, and the second master node updates the second committee nodes according to the committee reconfiguration protocol.
5. The method according to claim 4, characterized in that The first master node updates the first committee node according to the committee reconfiguration protocol, including: The first master node updates the first committee node according to the committee reconfiguration protocol, specifically: The message format of the first reconfiguration message Reconfigure1 is: <Reconfigure1,v1,mh1,mBH1,flag1,BD1,p1>s p1 ; in,<Reconfigure1,v1,mh1,mBH1,flag1,BD1,p1> σ p1 Indicates the signature of the master node p1 of the first committee in the first reconfiguration message, the p1 indicates the number of the master node in the first committee node, the flag1 has two values, which are used to indicate two situations of node member update in the first committee, the flag1=1 indicates that the first committee node performs a normal node update process, the flag1=2 indicates that the first committee node performs an abnormal node update process, the v1 indicates the view number of the first master node, the BD1 is the number set of the first committee nodes to be replaced, the mh1 is the number of the first blocks that have completed the consensus, and the mBH1 is the hash value of the highest first block that has completed the consensus; If flag1=1 in the first reconfiguration message, then verify whether there is an abnormal first committee node in the BD 1. If there is no abnormal first committee node, the verification is successful, and the first slave node sends a first reconfiguration reply message to the first master node; The message format of the first reconfiguration reply message Rcf-Reply1 is: <Rcf-Reply1,v1,mh1,mBH1,BD1,i1>s i1 ; in,<Rcf-Reply1,v1,mh1,mBH1,BD1,i1> σ i1 represents the signature of the slave node i1 of the first committee in the first reconfiguration reply message, wherein i1 represents the number of the slave node in the first committee node, v1 represents the view number of the first master node, BD1 is the number set of the first committee nodes to be replaced, mh1 is the number of the first blocks that have completed the consensus, and mBH1 is the hash value of the highest first block that has completed the consensus; When the first master node receives the first reconfiguration reply message sent by 2e first committee nodes and determines whether the first reconfiguration reply message is correct, if correct, the first master node calculates a first replacement node and updates the first committee node; The first reconfiguration reply information includes: the signature of the slave node i1 of the first committee in the first reconfiguration reply message, the view number of the first master node, the number set of the first committee nodes to be replaced, the number of the first blocks that have completed the consensus, and the hash value of the highest first block that has completed the consensus; The second master node updates the second committee node according to the committee reconfiguration protocol, specifically: The message format of the second reconfiguration message Reconfigure2 is: <Reconfigure2,v2,mh2,mBH2,flag2,BD2,p2>s p2 ; in,<Reconfigure2,v2,mh2,mBH2,flag2,BD2,p2> σ p2 represents the signature of the slave node i2 in the second committee in the second reconfiguration message, the i2 represents the number of the slave node in the second committee node, the flag2 has two values, which are used to represent two situations of node member update in the second committee, the flag2=1 represents the normal update process of the second committee node, the flag2=2 represents the abnormal update process of the second committee node, the v2 represents the view number of the second master node, the BD2 is the number set of the second committee nodes to be replaced, the mh2 is the number of the second blocks that have completed the consensus, and the mBH2 is the hash value of the highest second block that has completed the consensus; If flag2=1 in the second reconfiguration message, verify whether there is an abnormal second committee node in BD 2. If there is no abnormal second committee node, the verification is successful, and the second slave node sends a second reconfiguration reply message to the second master node. The message format of the second reconfiguration reply message Rcf-Reply2 is: <Rcf-Reply2,v2,mh2,mBH2,BD2,i2>s i2 ; in,<Reconfigure2,v2,mh2,mBH2,flag2,BD2,p2> σ p2 represents the signature of the slave node i2 in the second committee in the second reconfiguration reply message, the i2 represents the number of the slave node in the second committee node, the v2 represents the view number of the second master node, the BD2 is the set of numbers of the second committee nodes to be replaced, the mh2 is the number of the second blocks that have completed the consensus, and the mBH2 is the hash value of the highest second block that has completed the consensus; When the second master node receives the second reconfiguration reply message sent by the 2e second committee nodes and determines whether the second reconfiguration reply message is correct, if correct, the second master node calculates the second replacement node and updates the second committee node; The second reconfiguration reply information includes: the signature of the slave node i2 in the second committee in the second reconfiguration reply message, the view number of the second master node, the set of numbers of the second committee nodes to be replaced, the number of the second blocks that have completed the consensus, and the hash value of the highest second block that has completed the consensus.
6. The method according to claim 5, characterized in that The first master node calculates a first replacement node, and the second master node calculates a second replacement node, including: The first master node calculates the first replacement node, specifically: The first master node calculates a first random value z1 through a verifiable random function; Where z1 = output / 2 hashlen ; The first master node sorts the non-committee nodes according to the credibility scores from high to low; If flag1 in the first reconfiguration message is 1, the first replacement node is determined to be the first node in the non-committee node sequence. Nodes and nodes; Wherein, the number of non-committee nodes is en; If flag1 in the first reconfiguration message is 2, then the first Nodes and A node is the first replacement node; Wherein, gn represents the number of non-committee nodes whose credibility scores are ranked as top gn; The second master node calculates the second replacement node, specifically: The second master node calculates a second random value z2 through a verifiable random function; Where z2 = output / 2 hashlen ; The second master node sorts the non-committee nodes according to the credibility scores from high to low; If flag2 in the second reconfiguration message is 1, the second replacement node is determined to be the first node in the non-committee node ranking. Nodes and nodes; Wherein, the number of non-committee nodes is en; If flag2 in the second reconfiguration message is 2, then the first node in the non-committee node ranking is Nodes and A node is the second replacement node; Wherein, the gn represents the number of non-committee nodes whose credibility scores are ranked in the top gn.
7. The method according to claim 1, characterized in that The method further includes: a first committee node evaluation mechanism, and a second committee node evaluation mechanism; The first committee node evaluation mechanism is specifically: The first master node receives a second commit message sent by the first slave node; If the number of the second submission messages received by the first master node is not less than 2e, the first master node obtains the credibility score reward in the following manner: Ps2=Ps1+x; Wherein, x is the credibility score reward, Ps1 is the credibility score of the first master node, and Ps2 is the credibility score of the first master node after the reward; If the first view switching occurs, the newly generated first master node receives no less than 2e+1 of the first preparation messages, and the first master node receives the credibility score penalty, which is specifically: Ps3 = Ps1 - d*x; Wherein, d is a penalty parameter, and d is greater than 1, x is a credibility score reward, Ps1 is the credibility score of the first master node, and Ps3 is the credibility score of the first master node after the penalty; If the first preparation message received by the newly generated first master node is less than 2e+1, the first credibility score of the first master node is halved. If the first credibility score is lower than the lower limit, the first master node loses the opportunity to participate in the consensus of the first committee node. The second committee node evaluation mechanism is specifically as follows: The second master node receives a third commit message sent by the second slave node; If the number of the fourth submission messages received by the second master node is not less than 2e, the second master node obtains the credibility score reward, and the credibility score reward is specifically: Ps5=Ps4+x; Wherein, x is the credibility score reward, Ps4 is the credibility score of the second master node, and Ps5 is the credibility score of the second master node after the reward; If the second view switching occurs, the newly generated second master node receives no less than 2e+1 second preparation messages, and the second master node receives the credibility score penalty, which is specifically: Ps6 = Ps4 - d*x; Wherein, d is a penalty parameter, and d is greater than 1, x is a credibility score reward, Ps4 is the credibility score of the second master node, and Ps6 is the credibility score of the second master node after the penalty; If the newly generated second master node receives less than 2e+1 of the second preparation messages, the second credibility score of the second master node is halved. If the second credibility score is lower than the lower limit, the second master node loses the opportunity to participate in the consensus of the second committee node.
8. The method according to claim 7, characterized in that The first view switching includes: If the consensus of the first committee nodes times out or the first master node fails, the first view switching is performed, and the first view switching includes: When the second committee node has received the first submission message sent by the first master node, the first committee node broadcasts a first view switching message; The message format of the first view switching message View-Change1 is: <View-Change1,v1+1,h1,BH1,PR1,i1>s i1 ; in,<View-Change1,v1+1,h1,BH1,PR1,i1> σ i1 represents the signature of the slave node i1 of the first committee in the first view switching message, the i1 represents the number of the slave node in the first committee node, the v1 represents the first view number, the h1 represents the block height of the first block, the BH1 represents the hash value of the first block, and the PR1 represents the preparation message of the first block of the node i1 in the first committee node; The newly generated first master node performs verification after receiving the first view switching message. When the newly generated first master node receives 2e+1 first view switching messages, the newly generated first master node broadcasts a first new view message to the first committee node; The message format of the first new view message New-View1 is: <New-View1,v1+1,V1,PG1,p3>s p3 ; in,<New-View1,v1+1,V1,PG1,p3> σ p3 represents the signature of the new primary node p3 of the first committee in the first new view message, the V1 represents the message set of the first view switch message, the PG1 represents the first preparation message set, and the p3 represents the first new primary node number; When the first committee node broadcasts the first view switching message to the second committee node, if the second committee node has broadcast the second block to the first committee node, the second committee node adopts a dual-committee consensus; When the first committee node broadcasts the first view switching message to the second committee node, if the second committee node has not broadcast the second block to the first committee node, and the second committee node receives 2e+1 valid first view switching messages, the second committee node adopts a single-committee consensus; If the second committee node consensus times out or the second master node fails, the second view switching is performed, and the second view switching includes: When the first committee node has received the third submission message sent by the second master node, the second committee node broadcasts a second view switching message; The message format of the second view switching message View-Change2 is: <View-Change2,v2+1,h2,BH2,PR2,i2>σ i2 in,<View-Change2,v2+1,h2,BH2,PR2,i2> σ i2 represents the signature of the slave node i2 of the second committee in the second view switching message, i2 represents the number of the slave node in the second committee node, v2 represents the second view number, h2 represents the block height of the second block, BH2 represents the hash value of the second block, and PR2 represents the preparation message of the second block of the node i2 in the second committee node; The newly generated second master node performs verification after receiving the second view switching message. When the newly generated second master node receives 2e+1 second view switching messages, the newly generated second master node broadcasts the second new view message to the second committee nodes; The message format of the second new view message is: <New-View2,v2+1,V2,PG2,p4>s p4 ; in,<New-View2,v2+1,V2,PG2,p4> σ p4 represents the signature of the new primary node p4 of the second committee in the second new view message, V2 represents the message set of the second view switch message, PG2 represents the second preparation message set, and p4 represents the second new primary node number; When the second committee node broadcasts the second view switching message to the first committee node, if the first committee node has broadcast the first block to the second committee node, the first committee node adopts a dual-committee consensus; When the second committee node broadcasts the second view switching message to the first committee node, if the first committee node has not broadcast the first block to the second committee node, and the first committee node receives 2e+1 valid second view switching messages, the first committee node adopts a single committee consensus.
9. A dual-committee consensus device, characterized in that: Applied to the target alliance chain, the device includes: A committee election module, used to obtain each node in the target alliance chain, each node having the same initial credibility score, and select a first committee node and a second committee node from each node based on a verifiable random function, wherein the first committee node belongs to the first committee, the second committee node belongs to the second committee, the number of nodes of the first committee is the same as the number of nodes of the second committee, and the sum of the number of nodes of the first committee and the number of nodes of the second committee does not exceed the number of nodes of the target alliance chain; A dual-committee consensus processing module broadcasts a first pre-preparation message to a first slave node through a first master node, and the first slave node receives the first pre-preparation message sent by the first master node and performs a first verification; The first master node is elected from the first committee nodes through the verifiable random function, the first slave nodes include: other nodes in the first committee nodes except the first master node, and the first pre-prepared message includes: a first block; If the first verification passes, the first slave node sends a first prepare message to the first master node. After the first master node receives the first prepare message, the first master node broadcasts a first commit message to the first slave node and the second committee node, where the first commit message includes the first block. After receiving the first submission message, the first slave node performs a second verification. If the second verification passes, the first slave node sends a second submission message to the first master node. After receiving the second submission message, the first master node performs a third verification. If the third verification passes, the first master node broadcasts a first synchronization message to the first slave node and non-committee nodes. After the second master node receives the first commit message, the second master node broadcasts a second pre-prepare message to the second slave node, and the second slave node receives the second pre-prepare message sent by the second master node and performs a fourth verification; The second master node is elected from the second committee nodes through the verifiable random function, the second slave nodes include other nodes in the second committee nodes except the second master node, and the second pre-prepared message includes: a second block; If the fourth verification passes, the second slave node sends a second prepare message to the second master node. After the second master node receives the second prepare message, the second master node broadcasts a third commit message to the second slave node and the first committee node, where the third commit message includes the second block. After receiving the third submission message, the second slave node performs a fifth verification. If the fifth verification passes, the second slave node sends a fourth submission message to the second master node. After receiving the fourth submission message, the second master node performs a sixth verification. If the sixth verification passes, the second master node broadcasts a second synchronization message to the second slave node and the non-committee node.
10. The device according to claim 9, characterized in that The selecting a first committee node and a second committee node from each of the nodes based on a verifiable random function comprises: All nodes in the target alliance chain generate a corresponding random output value output and a corresponding random proof value pi based on the verifiable random function VRF, where the output is a hash value; The probability that a node in the target alliance chain is selected as a committee node is w, and the w value is specifically: w=2c / n, the number of nodes in the target alliance chain is n, and the number of nodes included in a committee is c; Determine whether the z value is less than the w value; The z value is specifically: z=output / 2 hashlen , the hashlen is the output length of the hash algorithm of the verifiable random function; When the z value is less than the w value, the node in the target alliance chain is selected as the committee node, and the committee node broadcasts a committee request message to all nodes in the target alliance chain; All nodes in the target alliance chain verify the committee request message; If the verification is successful, the committee nodes are sorted in ascending order according to the z values of the committee nodes, and the first committee node and the second committee node are selected from the committee nodes.
