Disclosure of Invention
The invention provides a Byzantine fault-tolerant consensus method and system based on node scoring, which aim to overcome the defects in the prior art.
S1, taking information including network, attribute and transaction on the nodes as scoring standards, setting corresponding weight for the scoring standards, and calculating the total score of each node according to the weight of the scoring standards of each node;
s2, initializing a system key and initializing node selection, wherein the initializing node selection comprises selecting a main node and a plurality of confirmation nodes through a verifiable random function, and the confirmation nodes form a confirmation node subset;
s3, when any node has view change, sorting the total scores of the nodes from big to small, then selecting a certain number of nodes in the front of the order, and reselecting the main node and the confirmation node among the certain number of nodes in the front of the order by running a verifiable random function;
s4, processing the request sent by the client by constructing a consistency protocol between the reselected main node and the confirmation node, wherein the consistency protocol verifies the correctness of all transactions based on the root of the Merkle tree in the request sent by the verification client;
and S5, establishing a main node view switching protocol and a confirmation node subset view switching protocol, and when the consensus of the main node or/and the confirmation node is abnormal, replacing the main node or/and the confirmation node which generates the abnormality according to the main node view switching protocol and the confirmation node subset view switching protocol.
In the whole process, the communication complexity is changed from all-to-all to all-to-c, the confirmed node subset is selected through node scoring, the communication complexity is reduced, the speed of achieving consensus is improved, and meanwhile more nodes can be supported to participate in consensus; in addition, a view change mechanism for the confirmation node subset is established, the purpose of confirming the view change of the node subset is to switch in time when the confirmation node subset has errors, and the scheme can work well in a network with more malicious nodes by combining a node grading mechanism.
In a specific embodiment, the S1 specifically includes:
step 1: for a certain node, constructing a hierarchical structure model of the node by taking the scoring standard as an element in a hierarchy based on a hierarchical analysis method, wherein the hierarchical structure model comprises the following components from high to low:
the first hierarchy represents a target layer, the target layer containing an element X;
the second level represents a standard layer comprising n elements, wherein n is a positive integer;
the third level represents a sub-standard layer, which comprises p elements, wherein p is a positive integer;
step 2: according to the importance of the elements in the standard layer to the elements in the target layer, the elements in the standard layer are compared in pairs, the comparison result is quantized into a numerical value, and normalization processing is carried out to obtain the weight of each element in the standard layer relative to the target layer
Wherein
Representing n elements in the standard layer;
and step 3: according to the importance of the elements in the sub-standard layer to the elements in the standard layer, the elements in the sub-standard layer are compared in pairs, the comparison result is quantized into a numerical value, and normalization processing is carried out to obtain the weight of each element in the sub-standard layer relative to the standard layer
Wherein
Representing p elements in the sub-standard layer;
and 4, step 4: total weight of each element in the sub-standard layer
Comprises the following steps:
wherein the content of the first and second substances,
represents the second of the sub-standard layers
The number of the elements is one,
represents the second in the standard layer
An element;
and 5: node point
kTotal score of (2)
The following were used:
wherein the content of the first and second substances,
representing nodes
kIn the elements
The score obtained in the above-mentioned manner,
presentation element
The weight of (c).
In a specific embodiment, the elements in the sub-standard layer include: network speed, number of failed messages, network bandwidth, number of error messages, number of times to become master, number of times to become a confirming node, computing power, number of sent transactions, and number of completed transactions.
In a specific embodiment, the initializing the system key in S2 specifically uses a threshold signature algorithm, and the specific steps include:
the nodes in the system are numbered, and a master key (MSK) and a Master Public Key (MPK) of the system and a public key and a private key corresponding to each node are generated through a BLS threshold signature algorithm, wherein each node stores the Master Public Key (MPK) of the system and public keys of other nodes.
In a specific embodiment, the S3 specifically includes:
reselecting the master node by running an authenticatable random function:
when the view of the master node is changed, sorting the total scores of all the nodes from large to small, selecting five nodes with the maximum total scores, confirming that the node subset runs a verifiable random function in the five nodes, and finally obtaining one node as the master node;
reselecting the confirmation node by running a verifiable random function:
when the view of the confirmation node subset changes, the total scores of all the nodes are sorted from large to small, the master node runs a verifiable random function on 2c nodes with the largest scores to finally obtain c nodes, and the c nodes are used as c confirmation nodes to form the confirmation node subset, wherein c is a positive integer.
From the above, the communication complexity of the scheme is global, so the consensus efficiency and the throughput of the scheme are higher than those of the PBFT, and the scheme can be well applied to networks with more nodes than the PBFT.
In a specific embodiment, the consistency protocol in S4 specifically includes:
the master node is one, the backup nodes are m, the confirmation nodes are c, and 1+ m + c = n = 3f +1, where m, c, n are positive integers, the adversary model of the consistency protocol is n = 3f +1, and the consistency protocol is implemented by four processes of requesting, preparing, submitting, and replying:
requesting:
the client packs the transaction information into a request in a Merkle tree form, and then sends the request to the main node;
preparing:
after receiving the request, the master node numbers the request, then performs hash processing and signs the request by using a private key of the master node, and finally sends < prepare, v, n, p, d (m) < σ p (d (m)), m > as a preparation message to all other nodes, wherein v is a view number, n is a sequence number of the request, d (m) is a summary of the request, σ p (d (m)) is a signature of the master node on the request by using the private key, and m is the content of the request;
submitting:
after receiving the preparation message, the backup node and the confirmation node respectively perform the following checks:
checking whether the digest of the request and the signature are correct;
checking whether the view v in the request is the same as the current view;
checking whether the current node receives other requests with the sequence number n;
checking whether the received request is within a current receive window;
if the above-mentioned check results are all yes, then will<submit, v, n, p, σi(m), i>Sending to the subset of validation nodes as a commit message, where σi(m) for the threshold signature of node i on the request, when the subset of validation nodes receives 2f +1 commit messages with the same request sequence number, the subset of validation nodes obtains all signatures (σ) of the 2f +1 commit messages with the same request sequence numberi(m) | 1 ≦ i ≦ n) and combined into the final signature σ (m), and finally the confirmation node subset sends the signature σ (m) to all other nodes<reply, v, n, σ(m)>As a reply message;
and (3) recovering:
when receiving at least
After the reply message is received, all nodes verify the signature sigma (m) by using a system Master Public Key (MPK), if the verification is successful, the reply message is written into a local log, and the state of the request with the sequence number n is set to be successful.
In a specific embodiment, the protocol for switching views of the master node in S5 specifically includes:
when the consensus of the main node is abnormal, the timer of the backup node i is overtime in the current view v, the backup node i triggers the view switching operation of the main node and switches the current view to the view v +1, and the method comprises the following four steps of requesting, distributing, converting and confirming:
requesting: when the timer in the backup node is overtime, the backup node sends a message requesting for switching the view of the main node to the confirmation node subset, and the format of the message requesting for switching the view of the main node is<primary-view-change-request,v+1,i, σi(p)>Where i is the sequence number of the backup node, σ i (p) is the threshold signature of the backup node i on the message, where p is the sequence number of the new primary node;
after the confirming node subset receives at least f +1 messages requesting for switching the view of the main node, threshold signatures of f +1 nodes corresponding to the messages are synthesized into a complete signature sigma (p), the confirming node subset reselects a new main node through S3, and then the confirming node subset sends a view distribution message to a backup node, wherein the view distribution message is in a format of < primary-view-assign, v +1, p, sigma (p) >, and p is a sequence number of the new main node;
conversion: when the backup node receives a message greater than or equal to
When the same view distribution messages exist, a system public key is used for verifying sigma (p), if the verification is successful, the sequence number of the main node is changed into p, and a confirmation message representing that the new main node is successfully verified is sent to a confirmation node subset;
confirming that all backup nodes have received the allocation view message and successfully change the sequence number of the master node to p when the confirming node subset receives 2f confirmation messages.
In a specific embodiment, the protocol for confirming the node subset view switching in S5 specifically includes:
when the backup node does not receive enough messages sent by the confirmation node subset within the designated time, the view of the confirmation node subset is changed, and the specific process comprises the following steps of requesting, allocating, converting, confirming, reconfirming and restarting:
requesting: when the timer in the backup node is overtime, the backup node sends a message for requesting to switch the view of the confirmation node subset to the main node, and the format of the message for requesting to switch the view of the confirmation node subset is<confirmed-node-view-change-request,v+1,i,σi(r)>Where i is the serial number of the backup node, σi(r) is the threshold signature of backup node i on the message;
when the master node receives the messages of requesting to switch the view of the subset of the confirmation nodes, which are more than or equal to f +1, the master node synthesizes the threshold signatures of the f +1 nodes corresponding to the messages into a complete signature sigma (R), the master node reselects a new subset of the confirmation nodes through S3, and then the master node sends a view distribution message to the backup nodes, wherein the view distribution message has a format of < fixed-node-view-assign, v +1, R, sigma (R) >, and R is the serial number of the new subset of the confirmation nodes;
conversion: after receiving the distribution view message sent by the main node, the backup node verifies sigma (r) by using a system public key, and if the verification is successful, a confirmation message representing that the new confirmation node subset is verified successfully is sent to the main node;
confirming that the master node indicates that the backup nodes all receive the sent view distribution message and successfully change the sequence number of the confirmed node subset into R when receiving 2f confirmation messages, and at the moment, the master node sends the preparation message which is not successfully executed in the previous view to the backup nodes and the new confirmed node subset;
and (4) confirming: after receiving the message containing the preparation message sent by the main node, the backup node and the new confirmation node subset send a re-confirmation message to the main node to indicate that the message sent by the main node is received;
restarting: and after receiving the reconfirmation messages of which the number is more than or equal to 2f, the main node sends an execution message to the new confirming node subset to start a new round of consensus.
According to a second aspect of the present invention, a computer-readable storage medium is proposed, on which a computer program is stored, which computer program, when being executed by a computer processor, carries out the above-mentioned method.
According to a third aspect of the present invention, a byzantine fault-tolerant consensus system based on node scores is provided, the system comprising:
the communication complexity is changed from all-to-all to all-to-c, the confirmed node subset is selected through node scoring, the communication complexity is reduced, the speed of achieving consensus is improved, and meanwhile more nodes can be supported to participate in consensus; in addition, a view change mechanism for the confirmation node subset is established, the purpose of confirming the view change of the node subset is to switch in time when the confirmation node subset has errors, and the scheme can work well in a network with more malicious nodes by combining a node grading mechanism.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 shows a flowchart of a node-scoring-based byzantine fault-tolerant consensus method according to an embodiment of the present invention. The method comprises the following steps:
and S1, taking information including network, attribute and transaction on the nodes as scoring standards, setting corresponding weights for the scoring standards, and calculating the total score of each node according to the weights of the scoring standards of each node.
In a specific embodiment, the scoring criteria and the weights in S1 specifically include:
(1) determining weights by analytic hierarchy process
When an analytic hierarchy process is applied to analyze a decision problem, the problem must be organized and layered to build a hierarchical model. The hierarchical model can be divided into three levels, a first level representing a target level, a second level representing a standard level (e.g., a factor level), and a third level representing a sub-standard level (e.g., an attribute level).
Each level of elements is compared in pairs based on their importance to the higher level elements. Starting from the top level of the hierarchy and going down, pairwise comparisons at a given level can be reduced to a series of squares
As follows:
wherein
Indicating the relative importance of the ith element compared to the jth element,
indicating the relative importance of the jth element compared to the ith element.
The matrices having reciprocal properties, i.e.
And
the relationship of (c) is as follows.
In the analytic hierarchy process, subjective pairwise comparisons were made from relative importance scales from 1 to 9.
In this example, according to the analytic hierarchy process,
and
the values of (a) are determined according to the following criteria:
after all the pairwise decision matrices are formed, the weight vectors are calculated according to an arithmetic mean-based method
. The weight calculation includes two steps, firstFirst, to the judgment matrix
Normalization processing is performed and then weights are calculated.
According to the hierarchical model, the object of the first level has only one element A, the second level is a standard level with n elements,
the third level, a sub-standard level, has p elements,
。
has a weight of
,
The weight of the upper level element of (1) is
. Total weight
Can be calculated by the following equation.
(2) Scoring attribute selection
The hierarchical model is divided into three levels. The first layer is a target layer, the second layer is a factor layer, and the third layer is an attribute layer. The elements of the attribute layer are network speed (C1), failure message number (C2), network bandwidth (C3), error message number (C4), master node forming number (C5), node forming confirmation number (C6), computing capacity (C7), transaction sending number (C8) and transaction completion number (C9), which are all important factors influencing node scoring.
(3) Total node score
To obtain the scores of the nodes, a scoring criteria table is constructed as shown in fig. 6. Based on the scoring criteria, we can obtain the final score of node i: (
),
Can be calculated by the following equation.
In the formula, the first and second sets of data are represented,
representing node i as an element
The score obtained in the above-mentioned manner,
presentation element
The weight of (c).
And S2, initializing the system key and initializing the node selection, wherein the initializing the node selection comprises selecting a main node and a plurality of confirmation nodes through a verifiable random function, and the confirmation nodes form a confirmation node subset.
In a specific embodiment, S2 specifically includes:
(1) key initialization
The key initialization process uses a threshold signature algorithm, and signature aggregation and key aggregation can be realized. It may merge all signatures and public keys in a transaction into one single signature and public key and the merging process is not visible. The system has N nodes, numbered N1, N2, N. And generating a master key (MSK) and a Master Public Key (MPK) of the system and a public key and a private key corresponding to each node through a BLS threshold signature algorithm. The private key and the public key of the node Ni (i is more than or equal to 1 and less than or equal to n) are respectively si and pi. Each node stores a system Master Public Key (MPK) and public keys of other nodes.
(2) Node selection initialization
The nodes in the system are divided into a primary node, c (c is a small constant) confirmation nodes and a plurality of backup nodes. The node selection mainly comprises main node selection and confirmation node selection, and when the system operates for the first time, the main node and c confirmation nodes (confirmation node subsets) are selected through a verifiable random function.
And S3, when the view of any node is changed, sorting the total scores of the nodes from large to small, then selecting a certain number of nodes in the front sorting, and reselecting the master node and the confirmation node among the certain number of nodes in the front sorting by running a verifiable random function.
In a specific embodiment, S3 specifically includes:
after the system completes the initialization operation of node selection, the nodes are selected by sorting the node scores to select a certain amount of nodes which are sorted at the top, and running verifiable random functions among the nodes to select the nodes.
(1) Master node selection
When the view of the main node is changed, the sub-set of the confirmed nodes obtains the score of each node through a formula, and the scores are ranked from large to small. And (4) confirming that the node subset runs the verifiable random function in the five nodes with the maximum scores to obtain a final node, wherein the node is the master node.
(2) Validating node subset selection
When the view of the node subset is confirmed to be changed, the main node calculates the score of each node through a formula, and then the scores are sorted from large to small. And then the master node runs a verifiable random function on the 2c nodes with the largest score to obtain c final nodes, and the confirmation nodes form a confirmation node subset.
S4: and processing the request sent by the client by constructing a consistency protocol between the reselected main node and the confirmation node, wherein the consistency protocol is used for verifying the correctness of all transactions based on the root of a Merkle tree in the request sent by the verification client.
Consistency agreement based on node scoring. The confirmed node subset is selected through node scoring, the communication complexity is reduced, the speed of achieving consensus is improved, and meanwhile more nodes can be supported to participate in consensus.
In a specific embodiment, fig. 2 shows a schematic diagram of a coherence protocol process of a specific embodiment of the present invention, and the coherence protocol in S4 shown in fig. 2 specifically includes:
the enemy model of the scheme is n = 3f + 1. In the scheme, only one main node, m backup nodes and c confirmation nodes (confirmation node subsets) satisfy 1+ m + c = n = 3f + 1. The scheme is mainly divided into four stages of requesting, preparing, submitting and replying. As shown in fig. 2, the scheme changes the communication complexity from all-to-all to all-to-c in the whole process. Because the communication complexity of the scheme is global, the consensus efficiency and the throughput of the scheme are higher than those of PBFT, and the scheme can be well applied to networks with more nodes than PBFT.
In this embodiment, the consistency protocol is implemented by four processes, specifically, request, preparation, submission, and reply:
(1) requesting:
the client packs the transaction information into a request in a Merkle tree form, and then sends the request to the main node;
(2) preparing:
after receiving the request, the master node numbers the request, then performs hash processing and signs the request by using a private key of the master node, and finally sends < prepare, v, n, p, d (m) < σ p (d (m)), m > as a preparation message to all other nodes, wherein v is a view number, n is a sequence number of the request, d (m) is a summary of the request, σ p (d (m)) is a signature of the master node on the request by using the private key, and m is the content of the request;
(3) submitting:
after receiving the preparation message, the backup node and the confirmation node respectively perform the following checks:
checking whether the digest of the request and the signature are correct;
checking whether the view v in the request is the same as the current view;
checking whether the current node receives other requests with the sequence number n;
checking whether the received request is within a current receive window;
if the above-mentioned check results are all yes, then will<submit, v, n, p, σi(m), i>Sending to the subset of validation nodes as a commit message, where σi(m) for the threshold signature of node i on the request, when the subset of validation nodes receives 2f +1 commit messages with the same request sequence number, the subset of validation nodes obtains all signatures (σ) of the 2f +1 commit messages with the same request sequence numberi(m) | 1 ≦ i ≦ n) and combined into the final signature σ (m), and finally the confirmation node subset sends the signature σ (m) to all other nodes<reply, v, n, σ(m)>As a reply message;
(4) and (3) recovering:
when receiving at least
After each reply message, all nodes use the systemAnd the Master Public Key (MPK) verifies the signature sigma (m), if the verification is successful, the reply message is written into a local log, and the state of the request with the sequence number n is set to be successful.
And S5, establishing a main node view switching protocol and a confirmation node subset view switching protocol, and when the consensus of the main node or/and the confirmation node is abnormal, replacing the main node or/and the confirmation node which generates the abnormality according to the main node view switching protocol and the confirmation node subset view switching protocol.
In a specific embodiment, the master node view switching protocol in S5 specifically includes:
when the consensus of the master node is abnormal, the timer of the backup node i times out in the current view v, the backup node i triggers the view switching operation of the master node to switch the current view to the view v +1, wherein the four steps include requesting, allocating, converting and confirming, fig. 3 shows a schematic diagram of a master node view switching protocol process of a specific embodiment of the present invention, and the specific steps are as follows:
(1) requesting: when the timer in the backup node is overtime, the backup node sends a message requesting for switching the view of the main node to the confirmation node subset, and the format of the message requesting for switching the view of the main node is<primary-view-change-request,v+1,i, σi(p)>Where i is the sequence number of the backup node, σ i (p) is the threshold signature of the backup node i on the message, where p is the sequence number of the new primary node;
(2) after the confirming node subset receives at least f +1 messages requesting for switching the view of the main node, threshold signatures of f +1 nodes corresponding to the messages are synthesized into a complete signature sigma (p), the confirming node subset reselects a new main node through S3, and then the confirming node subset sends a view distribution message to a backup node, wherein the view distribution message is in a format of < primary-view-assign, v +1, p, sigma (p) >, and p is a sequence number of the new main node;
(3) conversion: when the backup node receives a message greater than or equal to
When the same view distribution messages exist, a system public key is used for verifying sigma (p), if the verification is successful, the sequence number of the main node is changed into p, and a confirmation message representing that the new main node is successfully verified is sent to a confirmation node subset;
(4) confirming that all backup nodes have received the allocation view message and successfully change the sequence number of the master node to p when the confirming node subset receives 2f confirmation messages.
In a specific embodiment, the confirming of the node subset view switching protocol in S5 specifically includes:
when the backup node does not receive enough messages sent by the acknowledgement node subset within the specified time, the view of the acknowledgement node subset is changed, and the specific process includes requesting, allocating, converting, acknowledging, reconfirming, and restarting, fig. 4 shows a schematic diagram of a acknowledgement node subset view switching protocol process of a specific embodiment of the present invention, and the specific steps are as follows:
(1) requesting: when the timer in the backup node is overtime, the backup node sends a message for requesting to switch the view of the confirmation node subset to the main node, and the format of the message for requesting to switch the view of the confirmation node subset is<confirmed-node-view-change-request,v+1,i,σi(r)>Where i is the serial number of the backup node, σi(r) is the threshold signature of backup node i on the message;
(2) when the master node receives the messages of requesting to switch the view of the subset of the confirmation nodes, which are more than or equal to f +1, the master node synthesizes the threshold signatures of the f +1 nodes corresponding to the messages into a complete signature sigma (R), the master node reselects a new subset of the confirmation nodes through S3, and then the master node sends a view distribution message to the backup nodes, wherein the view distribution message has a format of < fixed-node-view-assign, v +1, R, sigma (R) >, and R is the serial number of the new subset of the confirmation nodes;
(3) conversion: after receiving the distribution view message sent by the main node, the backup node verifies sigma (r) by using a system public key, and if the verification is successful, a confirmation message representing that the new confirmation node subset is verified successfully is sent to the main node;
(4) confirming that the master node indicates that the backup nodes all receive the sent view distribution message and successfully change the sequence number of the confirmed node subset into R when receiving 2f confirmation messages, and at the moment, the master node sends the preparation message which is not successfully executed in the previous view to the backup nodes and the new confirmed node subset;
(5) and (4) confirming: after receiving the message containing the preparation message sent by the main node, the backup node and the new confirmation node subset send a re-confirmation message to the main node to indicate that the message sent by the main node is received;
(6) restarting: and after receiving the reconfirmation messages of which the number is more than or equal to 2f, the main node sends an execution message to the new confirming node subset to start a new round of consensus.
In a preferred embodiment, 10 cloud servers, numbered s1, s2, s3, s4, s5, s6, s7, s8, s9, s10 are used as experimental environments. Each server has a different configuration than the other servers. s1 server configuration (network bandwidth, CPU, memory) 1Mbit/s, 1CPU, 1 GB; the configuration of s2 is 1Mbit/s, 2CPU, 2 GB; the configuration of s3 is 2Mbit/s, 2CPU, 2 GB; the configuration of s4 is 2Mbit/s, 4CPU, 4 GB; the configuration of s5 is 5Mbit/s, 4CPU, 4 GB; the configuration of s6 is 5Mbit/s, 8CPU, 8 GB; the configuration of s7 is 1Mbit/s, 8CPU, 8 GB; the configuration of s8 is 2Mbit/s, 8CPU, 8 GB; the configuration of s9 is 5Mbit/s, 1CPU, 1 GB; the configuration of s10 is 5Mbit/s, 16CPU, 16 GB. The operating system of all servers is Ubuntu 16.04. We use Hyperridge fabric V2.0 as the underlying blockchain platform and deploy the consensus mechanism of this scheme on it. Each server simultaneously enables 50 different ports to simulate up to 500 nodes. In order to simulate a real network environment, the information transmission delay of each node on the same server ranges from 100ms to 200 ms. The present embodiment uses 90 million real transactions from the etherhouse to test the performance of the present solution. Each client sends requests by batching transactions into 12KB chunks (on average about 50 transactions per batch).
In a preferred embodiment, this experiment tested the effect of scoring different nodes. We randomly took four nodes from this system. The corresponding information of each node is shown in the table, and the attributes and scoring criteria of the node are described in fig. 6. Scoreprimary denotes the score of a node that wants to become the master node, and Scoreack denotes the score of a node that wants to become the confirmation node.
As can be seen from fig. 6, scorepliary, Scoreack for Node1, Node2, Node3, Node4 are 69.300, 54.870, 70.180, 71.440 and 60.225, 51.988, 63.694, 65.890, respectively. Since the attribute (number of error messages) has a large weight, the Node1 has a better attribute (network speed, network bandwidth, number of master nodes) than the Node3, but the Node3 has a higher score than the Node 1. If a node sends an error message, it is declared that the node is likely to be a malicious node, and therefore the node is lower in score than a node that does not send an error message. This ensures that both the master node and the confirmation node are good nodes as much as possible. Through the evaluation of the node network, the node with high network speed is selected, and the efficiency of the system is improved. Since the attribute (number of error messages) values of Node3 and Node4 are the same, but the network condition of Node4 is better than that of Node3, the final Scoreprimary and Scoreack values of Node4 are both higher than Node 3. The experimental result of node scoring accords with the actual situation, so the analytic hierarchy process is effective in the node scoring mechanism.
(1) Probability of malicious node becoming master node
The scheme is developed on the basis of PBFT and SBFT, so the experiment tests the probability that the malicious nodes in the scheme, the PBFT and the SBFT are the main nodes. As can be seen from FIG. 7, the probabilities of PBFT and SBFT fluctuate around 0.5. The reason is that there is no good mechanism to select which node is the master node. But the node is selected as the main node according to the scheme through the grade of the node. And calculating the node score through the node comprehensive condition. The score reflects whether the node is good or not and whether the network of nodes is fast or not. The probability of this scheme is less than 0.5. Moreover, as the system operates, the probability of the scheme gradually decreases to 0, but the probabilities of the PBFT and SBFT still fluctuate around 0.5. From experimental results, it can be seen that the scheme reduces the time for view change.
(2) Relationship between number of nodes and throughput
The performance of the PBFT is greatly affected by the number of nodes, and when the number of nodes exceeds a threshold, the system performance is significantly degraded. SBFT provides almost twice the throughput as PBFT protocol. This experiment evaluated the relationship between the number of nodes and throughput. We evaluated two cases, one without malicious nodes in the system and the other with 32 malicious nodes in the system.
In fig. 8, the left sub-graph is a relationship in the case of no malicious node, and the right sub-graph is a relationship in the case of 32 malicious nodes. As can be seen from fig. 8, the maximum throughput of the PBFT, SBFT and the present scheme is around 720, 2130 and 2800, respectively, in the absence of malicious nodes. The maximum throughput of the SBFT is more than 3 times of that of the PBFT, and the maximum throughput of the scheme is more than 4 times of that of the PBFT. With 32 malicious nodes, the maximum throughput for the PBFT, SBFT and the present scheme is around 320, 1900 and 2700, respectively. The maximum throughput of the SBFT is more than 6 times that of the PBFT, and the maximum throughput of the scheme is more than 8 times that of the PBFT. In both cases, the PBFT throughput is less than the SBFT throughput, and the SBFT throughput is less than the scheme. The throughput of this scheme is significantly greater than PBFT due to the presence of the subset of acknowledgement nodes. And due to the existence of a node scoring mechanism, the throughput of the scheme is greater than SBFT. As the number of malicious nodes increases to 32, the maximum throughput of the PBFT and SBFT decreases by 400 and 230, respectively. But the maximum throughput of the scheme remains substantially constant. Therefore, the scheme can work well in a system in which malicious nodes are easy to appear. The throughput of the PBFT, the SBFT and the scheme is maximum when the number of nodes is 150, 350 and 500 respectively, which shows that the scheme is suitable for operating in a system with the number of nodes larger than the PBFT and the SBFT.
(3) Relationship between runtime and throughput
This experiment evaluated the throughput over time. As can be seen in FIG. 9, the throughput of the PBFT fluctuates around 700 and the throughput of the SBFT fluctuates around 2030. Neither PBFT nor SBFT have a good mechanism for selecting nodes as master nodes, so their throughput remains stable. According to the scheme, the nodes are selected as the main nodes according to the scores of the nodes. The throughput of the present scheme is increasing over time. Since the communication between the nodes in the scheme is all-to-c, and the communication between the nodes in the PBFT is all-to-all, the throughput of the scheme is obviously higher than that of the PBFT. According to the scheme, the network and the computing power of the nodes are considered, and the nodes with high network speed and high computing power are selected as the main nodes. Therefore, the throughput of the scheme is also higher than the SBFT.
(4) Relationship between throughput and delay
FIG. 10 may yield the maximum throughput for this scheme, PBFT and SBFT. This experiment tested the delay in throughput from 0 to maximum throughput in the present scheme, PBFT and SBFT. As can be seen from fig. 10, the delay of the present scheme is lower than both PBFT and SBFT in both cases. As the number of malicious nodes in the system increases to 32, the delay of PBFT and SBFT increases significantly. The delay of the solution increases only slightly. Experimental results show that the consensus efficiency of the scheme is obviously higher than that of PBFT and SBFT.
Fig. 11 illustrates a block diagram of a byzantine fault-tolerant consensus system based on node scoring, according to an embodiment of the present invention. The system comprises a node scoring module 1101, a system initialization module 1102, a score-based node selection module 1103, a score-based consistency protocol module 1104 and a score-based view switching protocol module 1105.
In a specific embodiment, the node scoring module 1101 is configured to use information including networks, attributes, and transactions on nodes as scoring criteria, set corresponding weights for the scoring criteria, and calculate a total score of each node according to the weight of the scoring criteria of each node;
the system initialization module 1102 is configured to initialize a system key and initialize node selection, where initializing node selection includes selecting a master node and a plurality of acknowledgement nodes through a verifiable random function, and the plurality of acknowledgement nodes form an acknowledgement node subset;
the score-based node selection module 1103 is configured to select a certain number of nodes ranked in the front after ranking the total scores of the nodes from large to small when any node has a view change, and reselect a master node and a confirmation node among the certain number of nodes ranked in the front by running a verifiable random function;
the score-based consistency protocol module 1104 is configured to process the request sent by the client by constructing a consistency protocol between the reselected master node and the confirmation node, wherein the consistency protocol verifies the correctness of all transactions based on verifying the root of a Merkle tree in the request sent by the client;
the score-based view switching protocol module 1105 is configured to establish a master node view switching protocol and a confirmation node subset view switching protocol, and when the consensus of the master node or/and the confirmation node is abnormal, the master node or/and the confirmation node generating the abnormality is replaced according to the master node view switching protocol and the confirmation node subset view switching protocol.
Embodiments of the present invention also relate to a computer-readable storage medium having stored thereon a computer program which, when executed by a computer processor, implements the method above. The computer program comprises program code for performing the method illustrated in the flow chart. It should be noted that the computer readable medium of the present application can be a computer readable signal medium or a computer readable medium or any combination of the two.
According to the method, relevant important information of the nodes is used as a grading standard, each node is graded through an analytic hierarchy process, then on the basis of PBFT and SBFT, the communication complexity of the nodes is changed from all-to-all to all-to-c (c is a small constant) according to the node grading, a confirmed node subset is selected through the node grading, the communication complexity is reduced, the speed of achieving consensus is improved, and meanwhile more nodes can be supported to participate in consensus; in addition, a view change mechanism for the confirmation node subset is established, the purpose of confirming the view change of the node subset is to switch in time when the confirmation node subset has errors, and the scheme can work well in a network with more malicious nodes by combining a node scoring mechanism, so that resources are utilized well, and the communication complexity is reduced. The scheme can work well in a complex network which accords with reality, and also can work well in a network with more nodes.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the invention. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.