Disclosure of Invention
The embodiment of the invention aims to provide a method for realizing a network extensible block chain, which is used for solving the technical problem that the traditional public block chain network is very weak in extensibility.
In order to achieve the above object, an embodiment of the present invention provides a method for implementing a network scalability block chain, where the method includes: all verification nodes are distributed to different groups to form a plurality of fragments when each round of consensus period starts; each fragment elects a leader according to the reputation integral generated by the historical behavior of the nodes in the corresponding group with positive correlation probability; a transaction initiator sends a transaction to a fragment responsible for processing the transaction, and then the fragment runs a consensus synchronization algorithm based on fragment leadership to generate a transaction block and a credit block; based on the behaviors of all verifiers in consensus, all network verification nodes perform credit score calculation through a credit evaluation mechanism and achieve consensus aiming at the credit scores; after the reputation score calculation is completed, the network verification node uses the common signature to generate the reputation block, wherein the reputation block comprises the reputation score, a list of confirmed transaction blocks, previous reputation blocks and the common signature; and when each consensus period is finished, each fragment group generates a state block, records of the transaction block chain and the credit block chain are packaged, then the network verification node synchronizes and updates the stored credit value based on the state blocks from all the fragments, and the next consensus period is started after the completion.
Preferably, the authentication node uses the hash value of the state chunk of the previous consensus period to generate a random number to introduce randomness, and then the authentication node is randomly assigned to the respective shards.
Preferably, in the election mechanism of the leader, the verification nodes higher than the median of the reputation score ranking become segment leaders with the probability that the reputation scores are positively correlated.
Preferably, each transaction has a unique identifier, an input UTXO list and an output UTXO list; all network authentication nodes send transactions to the patch responsible for inputting the UTXO and output the UTXO listed in these transactions.
Preferably, in the sharded leader-based consensus synchronization algorithm, for shard i, a transaction with i is verified after the remainder of the transaction ID divided by the number of sharded groups is added by 1.
Preferably, for on-chip trading, the slice-leader-based consensus synchronization algorithm comprises: the leader in the slice sends a list signature containing the transaction ID to all nodes in the slice; each network verification node checks the transaction ID in the transaction list and decides whether to accept, reject or not confirm the transaction; the network verification nodes transmit the determined signatures to the leader in the chip; the leader generates a transaction block after collecting the decisions of the verification nodes, wherein the transaction block comprises the signatures of all the network verifiers and the signature of the leader; each network verification node checks the information of the relevant block; if more than half of verification nodes send out an alarm, the leader in the slice is removed from the network, and the leader is generated again in the slice; when a plurality of transaction blocks are generated and no alarm is received, the network verification node calculates the reputation value of the corresponding node, and generates a reputation block after common signature.
Preferably, for cross-slice trading, in the slice-leader-based consensus synchronization algorithm, an input slice transmits a trading list and a trading decision list to a related output slice and a further input slice.
Preferably, the transaction decision list of the network verification node comprises a plurality of signatures, each signature being used to sign a subset of the transaction list, the transactions in a subset being sent to the same output slice to reduce bandwidth costs.
Preferably, the consensus synchronization algorithm based on segment leader adopts a parallel processing mode, and if different transactions do not conflict with each other, the transactions are processed in different blocks in parallel; the parallel processing method comprises the following steps: each transaction list, transaction decision list and transaction block contains a number of iterations for indicating the round of consensus period; and the leader may send a new list of trades upon receiving all of the trade decisions of the previous round from the network verification node.
Preferably, the reputation score calculation is formulated as:
wherein, l is the transaction quantity generated after the credit block of the previous credit evaluation period is generated; t (j) is the transaction amount of transaction j; s (j) is a scaling factor of transaction j, and is used for differentially rewarding or punishing the behavior of the verification node; different scaling factors are set for different behaviors in the credit score calculation, so that punishment of dishonest behaviors is larger than reward of dishonest behaviors, and for unknown decisions, a network verification node can not obtain credit scores or lose credit scores.
The embodiment of the invention has the following advantages:
1) the embodiment of the invention provides a parallel chain structure, which separates transaction and consensus into two chains so as to improve the expandability of a block chain network; the consensus part is carried out in a credit chain, the credit chain network pays attention to the safety and supports the high-speed transaction of the transaction chain network at a proper speed;
2) the embodiment of the invention uses a credit evaluation mechanism to enhance the safety of the block chain network and improve the excitation, and on one hand, the credit consensus mechanism based on the historical performance of the nodes screens out the network nodes with excellent honesty and processing performance, and simultaneously gives more expected network contributions and rewards to the network nodes; on the other hand, potential network disruptors and malicious nodes are more easily found and removed from the network in time, and the safety of the block chain network is ensured.
3) Based on various advantages of a credit evaluation mechanism, the embodiment of the invention provides a network fragmentation method based on the credit evaluation mechanism, and after network fragmentation, nodes with excellent integrity and performance have higher probability to become fragmentation leaders, so that the safety of a block chain network is not reduced while the high throughput of the network is realized.
Example 1
The fragmentation technique is one of the most promising ways to improve the scalability of the blockchain. By dividing the transactions on the network into different fragments, each node on the network only needs to process a small part of transactions and verify the transactions in parallel with other network nodes, and a large amount of work can be completed. The current fragmentation technology mainly comprises the following steps: network fragmentation refers to that a network randomly extracts nodes to form fragments by utilizing randomness so as to prevent malicious nodes from excessively filling a single fragment; transaction fragmentation, in a UTXO-based system, the system allocates a fragment according to the address of the sender to ensure that two double-flower transactions are verified in the same fragment, and the system can easily detect the double-flower transactions without any cross-fragment communication; state fragmentation, in which each fragment only retains a part of the state, is one of the most difficult schemes to implement in the fragmentation technique.
Referring to fig. 1, a method for implementing a network scalability block chain according to an embodiment of the present invention includes: the method comprises the steps of fragmentation and leader election, consensus synchronization based on fragmentation leader, a reputation evaluation mechanism and a global synchronization algorithm. The embodiment of the invention constructs a consensus mechanism through a credit evaluation mechanism, and carries out network fragmentation based on the consensus mechanism, thereby improving the expandability of the block chain network and the transaction processing speed of the network.
Referring to fig. 2, a block chain network system structure diagram of a network scalability block chain implementation method according to an embodiment of the present invention is shown. Firstly, carrying out fragmentation and leader election, then realizing consensus synchronization, and simultaneously containing the two parts in a reputation mechanism designed by the embodiment of the invention; and finishing consensus, and finally, globally and synchronously packaging related transactions into a block chain network.
And (4) slicing and leader election, wherein all verification nodes are distributed to different groups to form a plurality of slices at the beginning of each round of consensus period, and each slice group selects the leader of the group. The specific process is as follows: when a new consensus period e begins, all verification nodes are assigned to different groups and leaders are elected with positive correlation probability according to reputation scores generated by the nodes in the groups by historical behavior. In particular, the verifying node introduces randomness using the hash value of the previous state chunk to generate a random number, and then the nodes are randomly assigned to the respective shards.
Further, the verifying nodes ensure that the total reputation value of each fragment is substantially equal through a fragmentation algorithm in the process of being randomly allocated, and the fragmentation algorithm includes:
inputting:
random sequence:
wherein e represents the e-th consensus period, SBH represents the hash value of each verification node state block, and k represents the k-th verification node;
accumulating a set of reputation scores:
wherein w represents the accumulated reputation score calculation period, r represents the accumulated reputation score of each verification node, and k represents the kth verification node;
and (3) outputting:
a fragment member collection: c ═ C1,c2,…,cnN represents the nth slice, and c represents the member set of each slice;
slice leading and gathering: l ═ L1,l2,…,lnN represents the nth fragment, and l represents the leader of each fragment;
the initialization is carried out in such a way that,
wherein i cycles from 1 to n;
circulating by SeedeIs a random generator RNG;
will accumulate a set of reputation scores R
wElement (1) of
Forming an accumulated credit score sequencing set R by sequencing from big to small
sort:
Where sort represents the set of cumulative reputation scores R
wElement (1) of
Sorting according to the sequence from big to small;
for RsortEach of ri sortAnd executing:
looking for a sequence t
1,t
2,…,t
jForm a subset of C
And satisfies the following conditions:
generating a random integer x from the random generator RNG;
will be associated with each r
i sortCorresponding verification node v
gIs assigned to
Wherein the remainder of dividing x by j + 1;
the loop ends until all verification nodes are randomly assigned.
In addition, in the design of the election mechanism of the leader, the verification nodes higher than the median of the credit score sorting become segment leaders according to the probability that the credit scores are positively correlated. Specifically, the leader election algorithm of the leader election mechanism includes:
for each element C in the aggregate C of shard membersnAnd executing:
rm is contained in cnThe median of the accumulated credit scores of all verification nodes in the database;
for inclusion in cnEach verification node v injAnd executing:
if it is not,
Then, a random floating point number is generated from random generator RNG:
if the number of the first and second antennas is greater than the predetermined number,
then, p
i,j=+∞
When p isi,m=(pi,1,pi,2,…pi,j) At the minimum value of ln=vm;
A cnThe execution is finished;
until each element in the fragment member total set C is traversed, the fragment member total set C finishes executing circulation;
the leader election algorithm ends the loop.
Based on the consensus synchronization of the segment leader, a transaction initiator sends a transaction (tx) to a segment responsible for processing the transaction, and then the segment runs a consensus synchronization algorithm based on the segment leader to generate a transaction block and a reputation block; in addition, for cross-slice transactions, an atomic cross-slice mechanism is adopted in the embodiment of the invention to ensure that double flowers do not appear.
Referring to fig. 4, similar to bitcoins, each transaction (tx) will have a unique identification, an input UTXO list and an output UTXO list in embodiments of the present invention; all network verification nodes send transactions to the fragments responsible for inputting the UTXO and output the UTXO listed in the transactions, wherein the UTXO (UnpendTransactionOutputs) is a basic unit of bit currency transactions, is an uneconomical transaction output and is a core concept of bit currency transaction generation and verification. For fragment i, in an embodiment of the present invention, it will be used to verify a transaction with i after the remainder of the transaction ID divided by the number of fragment groups is added to 1. Since the input to the UTXO may come from different slices, implementations related to embodiments of the present invention are capable of handling both on-chip and cross-chip transactions.
Referring to fig. 4, for on-chip trading, the slice-leader-based consensus synchronization algorithm comprises: leader within slice (slice leader |)
j) The list signature containing the transaction ID (TxList,
leader for sharding
jSignature of) to all nodes within a slice (slice member V)
i) (ii) a Each network verification node checks the transaction ID in the transaction list and decides whether to accept, reject or not confirm the transaction; the network verifying nodes sign their decisions (TxDec, Sig)
iVerifying the signature of the node for each network) and then transmitting the signature to the leader in the chip; the leader, after collecting the validation node's decisions, generates a transaction block that contains the signatures (sig) of all network validators
1、sig
2…sig
i…sig
m) And signature of leader
Each network verification node checks the information of the relevant block; referring to FIG. 3, if more than half of the verification nodes send out an alarm, the leader in the slice is removed from the network, and the slice generates the leader again; when a plurality of transaction blocks are generated and no alarm is received, the network verification node calculates the reputation value of the corresponding node, and generates a reputation block after common signature.
Referring to fig. 4, for a cross-slice transaction, in the slice-leader-based consensus synchronization algorithm, an input slice sends a transaction list (TxList) and a transaction decision list (txdcset) to a related output slice and another input slice.
It is worth mentioning that, whether it is an on-chip transaction or an off-chip transaction, the transaction decision list (txdcset) of the network authentication node contains a plurality of signature sigs1、sig2…sigi…sigmEach signature is used to sign a subset of the transaction list, the transactions in a subset being sent to the same output slice to reduce bandwidth costs; for a certain cross-chip fragmented transaction, if the associated UTXO is not used orLocking, the fragment will be accepted, otherwise the transaction will be rejected; the input fragment and the output fragment are locked with the related UTXO; when receiving the acceptance certification of the transaction decision list containing the input UTXO from all the related input fragments, the output fragments add the transaction on the transaction block; when the input fragment receives the acceptance certification from other related input fragments, the related transaction and the UTXO thereof are released; and if one of the input slices rejects the transaction, the relevant input and output slices will abort the transaction.
In order to further improve the transaction processing capacity of the implementation method disclosed by the embodiment of the invention, the piece leader-based consensus synchronization algorithm adopts a parallel processing mode, and if different transactions do not conflict with each other, the transactions are processed in different blocks in parallel; more specifically, the parallel processing method includes: each transaction list, transaction decision list and transaction block contains a number of iterations for indicating the round of consensus period; and the leader may send a new list of trades upon receiving all of the trade decisions of the previous round from the network verification node. Reviewing the consensus protocol in embodiments of the present invention, due to the synchronization protocol, it ensures that most honest nodes have completed sending the previous round of the list of trade decisions to the leader before receiving the current round of the list of trades. Thus, the network authentication node may determine whether the new transaction list is valid.
And the reputation evaluation mechanism powerfully supports the fragmentation and consensus synchronization scheme. Based on the behavior of all verifiers in consensus, all network verification nodes perform reputation score calculation through a reputation evaluation mechanism and achieve consensus on reputation scores. By accumulating reputation evaluations, the sharding and leader election mechanisms can be safer and more efficient. For one on-chip transaction, after the consensus period is over, the reputation scores in the segments can be calculated individually and consistently by all segment members according to a transaction conclusion set and a transaction block, a mechanism of the reputation scores can be designed in a pluggable manner as required, and the reputation score calculation formula is as follows:
wherein, l is the transaction quantity generated after the credit block of the previous credit evaluation period is generated; t (j) is the transaction amount of transaction j; s (j) is a scaling factor for transaction j for differentially rewarding or penalizing behavior of the verification node.
Different scaling factors are set for different behaviors in the credit score calculation, so that the punishment of the dishonest behavior is greater than the reward of the honest behavior. Since illegal transactions are more dangerous to pass than to be discarded, if some network authentication node gives "yes" and most others give "no", the network authentication node will be given more penalty. For "unknown" decisions, the network verification nodes neither obtain nor lose reputation scores because these verification nodes typically have lower performance and cannot communicate in time (CPU, hard disk, bandwidth, etc.).
Referring to fig. 3, in the figure:
is the slice c of the e-1 st consensus period
1The reputation block of (a) is selected,
is the slice c of the e-th consensus period
1The honest node reputation blocks of (a) are,
is the slice c of the e-th consensus period
1The malicious node/potentially malicious node reputation block of (a),
is divided into pieces c
1The honest node status blocks of (a) are,
is divided into pieces c
1The malicious node/potential malicious node status block of (1), TB is an honest node transaction block, TB' is a malicious node/potential malicious node transaction block, and Nonce is only one in cryptographyAnd after the reputation score calculation is completed, the network verification node uses the common signature to generate the reputation block, wherein the reputation block comprises the reputation score, the confirmed transaction block list, the previous reputation block and the common signature. In particular, the generation of the reputation block is run by the block leader and network verification nodes for two consecutive rounds, including publishing and committing, challenging and responding to hashed message signatures of previous cycles of the reputation block, these signatures containing the number and identity information of verifiers who agreed to the block, additional segments checking the collective signature, accepting the transaction block if more than half of the network verification nodes signed on the block; the reputation block provides evidence that more than half of the network authentication nodes accept the transaction block. In a consensus period, a partition packs reputation blocks into a reputation chain.
And (3) a global synchronization algorithm, wherein each fragment group generates a state block at the end of each consensus period, records of a transaction block chain and a credit block chain are packaged, then the network verification node synchronizes and updates the stored credit value based on the state blocks from all the fragments, and the next consensus period is started after the end. In order to reduce the huge network overhead of mutual communication of the chain nodes of the whole block, the network verification node generates the state block by using a multi-party signature mode, and the network verification node generates random numbers in the state block by using a workload proving mode for fragmentation and leader election of the next consensus period.
Although the invention has been described in detail above with reference to a general description and specific examples, it will be apparent to one skilled in the art that modifications or improvements may be made thereto based on the invention. Accordingly, such modifications and improvements are intended to be within the scope of the invention as claimed.