Method and device for selecting block in block chain, equipment and storage medium
By determining the standard weights based on multiple standard factors of blockchain nodes in the DPoS consensus mechanism and verifying the benefits of verification blocks, the fairness damage caused by node incentive problems is solved, and the higher fairness of the blockchain network is achieved Sex and dispersibility.
Patent Information
- Application Number
- CN202411566672.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-11
AI Technical Summary
In the DPoS consensus mechanism, the node incentive problem causes the node to make decisions based on the best interests of the entire network, destroying the fairness of the network.
After the consensus mechanism is triggered, the standard weights of each node are determined based on multiple standard factors of the blockchain node, the dispersion of production nodes is improved, and the benefits verification of the verification blocks are verified to ensure the added blocks in the blockchain Make decisions in the best interests of the entire network.
It effectively avoids blockchain nodes being driven by interests, improves the fairness and decentralization of the blockchain network, and ensures that the block selection process in the blockchain is more fair and transparent.
Smart Images

Figure CN119415600A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and in particular to a method, device, equipment and storage medium for selecting blocks in a blockchain. Background Art
[0002] The consensus mechanism is a key mechanism in the blockchain distributed system, which is used to ensure that all nodes in the network reach a consensus on the state of the data.
[0003] Currently, DPoS (Delegated Proof of Stake) is an efficient, secure consensus mechanism with good governance characteristics, which maintains fairness among peer nodes by using a voting mechanism of stakeholders. However, in terms of node incentives in DPoS, representative nodes are often driven by interests and do not make decisions based on the best interests of the entire network, thus undermining the fairness of the network.
[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of this application is to provide a method for selecting blocks in a blockchain, aiming to solve the technical problem that the consensus mechanism does not make decisions based on the best interests of the entire network and undermines the fairness of the network.
[0006] To achieve the above purpose, the present application proposes a method for selecting blocks in a blockchain, the method comprising:
[0007] After the consensus mechanism is triggered, the standard weight of each blockchain node in the blockchain is determined according to each standard factor of the blockchain node;
[0008] Based on the standard weight, selecting a production node for producing a block from the blockchain nodes;
[0009] Obtaining verification results of each of the blockchain nodes on the block to be verified produced by the production node;
[0010] If it is determined that the verification result is passed, the block to be verified is determined to be a target block that needs to be added to the blockchain.
[0011] In one embodiment, the step of determining the standard weight of each blockchain node according to each standard factor of the blockchain node in the blockchain includes:
[0012] Get the standard factors of each blockchain node in the blockchain;
[0013] Dividing the standard factors into a preset number of spatial clusters;
[0014] Based on a preset multi-region search algorithm, the initial weights of the spatial clusters are converged to determine the optimal weight set of the spatial clusters;
[0015] Based on the optimal weight set of each of the spatial clustering clusters, a standard weight of each blockchain node in the spatial clustering cluster is determined.
[0016] In one embodiment, the step of converging the initial weights of each of the spatial clustering clusters based on a preset multi-region search algorithm and determining the optimal weight set of each of the spatial clustering clusters includes:
[0017] Based on a preset multi-region search algorithm, determine the gradient vector between the blockchain nodes in each of the spatial clusters;
[0018] Based on the gradient vector, the blockchain nodes in the corresponding spatial clustering cluster are moved to find the optimal solution of the spatial clustering cluster until the movement number of the blockchain node meets the preset strategy movement number, and the optimal solution is determined to be the optimal weight set of the spatial clustering cluster.
[0019] In one embodiment, the step of dividing the standard factors into a preset number of spatial clusters includes:
[0020] Selecting a preset number of central factors from the standard factors;
[0021] respectively determining the similarity between each of the standard factors and each of the central factors;
[0022] Based on the similarity, the standard factors are divided into spatial clusters centered on the central factor.
[0023] In one embodiment, the step of determining the standard weight of each blockchain node in the spatial cluster based on the optimal weight set of each spatial cluster includes:
[0024] Performing dispersion evaluation on the optimal weight set of each of the spatial clustering clusters to determine the dispersion of each of the spatial clustering clusters;
[0025] Selecting a standard weight set from each of the optimal weight sets according to the dispersion;
[0026] The initial weights of each of the spatial clusters identified by the standard weight set are converged again until the number of convergences meets the preset maximum number of convergences, and the last obtained standard weight set is marked as the standard weight of each blockchain node in each spatial cluster.
[0027] In one embodiment, the step of obtaining the verification result of each of the blockchain nodes on the block to be verified produced by the production node includes:
[0028] Based on a preset order, receiving the blocks to be verified from the production nodes in sequence;
[0029] Broadcasting the block to be verified to each of the blockchain nodes;
[0030] Receive the verification results of each of the blockchain nodes on the transactions and signatures of the block to be verified.
[0031] In addition, to achieve the above purpose, the present application also proposes a device for selecting a block in a blockchain, and the device for selecting a block in a blockchain includes:
[0032] A weight optimization module, which is used to determine the standard weight of each blockchain node according to the standard factors of the blockchain nodes in the blockchain after the consensus mechanism is triggered;
[0033] A node selection module, configured to select a production node for producing a block from the blockchain nodes based on the standard weight;
[0034] A verification module, used to obtain the verification result of each blockchain node on the block to be verified produced by the production node;
[0035] The output module is used to determine that the block to be verified is a target block that needs to be added to the blockchain if it is determined that the verification result is passed.
[0036] In addition, to achieve the above-mentioned purpose, the present application also proposes a device for selecting blocks in a blockchain, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the method for selecting blocks in a blockchain as described above.
[0037] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the method for selecting blocks in the blockchain as described above are implemented.
[0038] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the method for selecting blocks in the blockchain as described above.
[0039] One or more technical solutions proposed in this application have at least the following technical effects:
[0040] After the consensus mechanism is triggered, according to the rules of the consensus mechanism, the standard weight of each blockchain node is first determined based on multiple standard factors of the blockchain nodes in the blockchain to improve the dispersion of production nodes and prevent blockchain nodes from being driven by interests. As the reference standard factors increase, the complexity of blockchain node selection will increase. Therefore, by determining the standard weight of each blockchain node, the speed of processing standard factors is improved, thereby ensuring the rate of selecting production nodes. After the production node is selected, in order to ensure the availability of the production node in the blockchain, it is necessary to verify the interests of the blocks to be verified produced by the production node. After the interest verification of each blockchain node, the block to be verified is determined as the target block that needs to be added to the blockchain. Therefore, the blocks added to the blockchain can make decisions based on the best interests of the entire network to ensure the fairness of the entire network. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0042] 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0043] Figure 1 A flowchart of the first embodiment of the method for selecting a block in the blockchain of the present application;
[0044] Figure 2 A schematic diagram of the block production process provided for the method of selecting blocks in the blockchain of this application;
[0045] Figure 3 A flowchart of the second embodiment of the method for selecting a block in the blockchain of the present application is provided;
[0046] Figure 4 A flowchart of the third embodiment of the method for selecting a block in the blockchain of the present application;
[0047] Figure 5 This is a schematic diagram of the module structure of a block selection device in a blockchain embodiment of the present application;
[0048] Figure 6 This is a schematic diagram of the device structure of the hardware operating environment involved in the method for selecting blocks in the blockchain in an embodiment of the present application.
[0049] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0050] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0051] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0052] The main solution of the embodiment of the present application is: after the consensus mechanism of the blockchain management platform is triggered, the standard weight of each blockchain node in the blockchain is determined according to each standard factor of the blockchain node; based on the standard weight, a production node for producing blocks is selected from the blockchain nodes;
[0053] Obtain the verification result of each blockchain node on the block to be verified produced by the production node; if it is determined that the verification result passes the verification, determine that the block to be verified is a target block that needs to be added to the blockchain.
[0054] In this embodiment, for ease of description, the following description is made with the blockchain management platform as the execution entity.
[0055] Since DPoS is currently an efficient, secure consensus mechanism with good governance characteristics, it maintains fairness among peer nodes by using a voting mechanism of stakeholders. However, in terms of node incentives in DPoS, representative nodes are often driven by interests and do not make decisions based on the best interests of the entire network, thus undermining the fairness of the network.
[0056] The present application provides a solution. After the consensus mechanism is triggered, according to the rules of the consensus mechanism, the standard weight of each blockchain node is first determined according to multiple standard factors of the blockchain nodes in the blockchain to improve the dispersion of the production nodes and avoid the blockchain nodes being driven by interests. Since the complexity of blockchain node selection will increase after the reference standard factors increase, the speed of processing standard factors is increased by determining the standard weight of each blockchain node, thereby ensuring the selection rate of production nodes. After the production node is selected, in order to ensure the availability of the production node in the blockchain, it is necessary to verify the interests of the blocks to be verified produced by the production node. After the interest verification of each blockchain node, the block to be verified is determined as the target block that needs to be added to the blockchain. Therefore, the blocks added to the blockchain can make decisions based on the best interests of the entire network to ensure the fairness of the entire network.
[0057] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a blockchain management platform, etc. The following takes the blockchain management platform as an example to illustrate this embodiment and the following embodiments.
[0058] Based on this, the present application embodiment provides a method for selecting a block in a blockchain, referring to Figure 1 , Figure 1 This is a flowchart of the first embodiment of the method for selecting blocks in the blockchain of the present application.
[0059] In this embodiment, the method for selecting a block in the blockchain includes steps S10 to S40:
[0060] Step S10, after the consensus mechanism is triggered, the standard weight of each blockchain node in the blockchain is determined according to each standard factor of the blockchain node;
[0061] It should be noted that the consensus mechanism can ensure that all nodes in the network can fairly participate in the transaction verification process and reach a consensus in a relatively short time, thereby avoiding the occurrence of double payments and other problems. Blockchain uses new application modes of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. to achieve openness, transparency, non-tampering, non-forgeability and traceability of data. Blockchain nodes can include full nodes, lightweight nodes and super nodes. Standard factors can be contribution, reliability and correctness, etc. Standard weight can be the weight of each standard factor of each blockchain node.
[0062] In addition, it should be noted that full nodes are complete nodes in the blockchain network, which download, verify and store the data of the entire blockchain. Lightweight nodes can download Blockheader and summary information of specific transactions, but cannot download the complete blockchain data. Super nodes are high-performance nodes in the blockchain network, which are usually located in data centers and have faster hardware and bandwidth.
[0063] It is understandable that since DPoS only uses a single factor to determine the node that produces the block, in order to achieve the personalized operability brought by the single factor, after the consensus mechanism is triggered, multiple standard factors of each blockchain node are obtained to measure the active utility function from multiple dimensions, improve scalability, and increase the dispersion of production nodes, thereby avoiding weight concentration and ensuring the fairness of the entire network.
[0064] It is understandable that as the number of standard factors for reference in selecting production nodes increases, the complexity of evaluating each de-blockchain node tends to increase. In order to ensure that the rate of blockchain node evaluation does not increase while the production nodes are dispersed, the standard weight of each blockchain node can be determined based on each standard factor. This reduces the time required to subsequently select production nodes from each blockchain node based on each standard factor and standard weight, thereby ensuring the evaluation rate of blockchain nodes.
[0065] Step S20, selecting a production node for producing a block from the blockchain nodes based on the standard weight;
[0066] It should be noted that a production node can be a node that produces blocks to ensure that all nodes in the blockchain network reach a consensus on the status of the data.
[0067] It is understandable that the production nodes can be selected through standard weights to refer to multiple standard factors, and because the reference weights of each standard factor are different, it is possible to avoid the selected production nodes being biased towards a certain blockchain node by modifying one or part of the standard factors, thereby increasing the fairness of selecting production nodes.
[0068] Optionally, in order to maintain fault tolerance for peer nodes and data, after the production nodes are determined, the production nodes can be made to generate blocks in sequence according to a set order.
[0069] Step S30, obtaining the verification result of each of the blockchain nodes on the block to be verified produced by the production node;
[0070] It should be noted that the verification result may be the result of a blockchain node other than a production node verifying the block to be verified produced by the production node.
[0071] It can be understood that by verifying the blocks to be verified by each blockchain node, it can be ensured that the blocks to be verified can fairly participate in the transaction process of each blockchain node, avoiding the production nodes from producing blocks for their own interests.
[0072] Furthermore, step S30 further includes:
[0073] Based on a preset order, receiving the blocks to be verified from the production nodes in sequence;
[0074] Broadcasting the block to be verified to each of the blockchain nodes;
[0075] Receive the verification results of each of the blockchain nodes on the transactions and signatures of the block to be verified.
[0076] It should be noted that transaction verification can ensure that all transactions are authorized and legal. Signature verification can be a process based on public key encryption and hash functions, ensuring the integrity of the transaction and the identity of the sender.
[0077] It can be understood that the legitimacy of the block to be verified can be ensured through verification by each blockchain node.
[0078] Step S40: If it is determined that the verification result is passed, the block to be verified is determined to be a target block that needs to be added to the blockchain.
[0079] It is understandable that in order to ensure the fairness of transactions in the blockchain network, after ensuring the fairness of the block obtained through step S30, the block is added to the blockchain, thereby ensuring the fairness of the blockchain network.
[0080] In specific implementation, a weighted election production node method based on multi-standard factor evaluation and an indicator utility function is used to select k production nodes from the blockchain nodes; the selected production nodes take turns to produce blocks in a predetermined order, and ensure the order of block generation through the time interval of each block production (at any given time, there is only one block producer), thereby maintaining fault tolerance for peer nodes and data; after the production node produces a block, it broadcasts it to the network; after other nodes receive the block, they verify it to check whether the transactions in the block are legal, whether the signature is valid, etc.; if the block passes the verification, other nodes will confirm the block and add it to the blockchain.
[0081] In the specific implementation, the weighted election production node method based on multi-standard factor evaluation and the indicator utility function can be used to select k production nodes from the blockchain nodes: in each round of election, k candidate nodes are set as the number of nodes that can create blocks. These nodes are called block producers. When all production nodes have taken turns to create blocks, a new round of elections will begin. The time interval between the creation of two blocks is Δt seconds. The selection process of k block producers must ensure that the selected nodes are trustworthy to other nodes in the network. That is, the credibility of the selected nodes indicates that these are production nodes rather than malicious nodes. In this consensus mechanism, the credibility standard can be met through a voting mechanism, in which all nodes establish trust through voting behavior.
[0082] Furthermore, the blockchain network runs the voting process and the block producer selection process for each round in parallel for all nodes in the network at any given time.
[0083] The voting process of all nodes in the running network is as follows: to determine the data related to the voting criteria, including the total number of votes received, the number of voting nodes that voted for a node, the value of the voting shares that the node voted for a node, and the number of nodes that voted for a node. All voting information is recorded as a transaction and stored uniformly in the block.
[0084] The process of selecting block producers in each round is as follows: first, the transaction activity is evaluated based on the node contribution, and then k block producers are selected based on the standard weight set and standard value generated by the k-cluster hunting mode heuristic algorithm.
[0085] In the specific implementation, refer to Figure 2 First, normalize the evaluation factor values of all nodes in the network, because different factors have different value ranges in their respective fields. In this step, all node standard values should be normalized to the range of [0,1] so that each factor has the same influence. The specific calculation method is shown in the formula:
[0086]
[0087] Among them, criteria ij Indicates the value of the i-th standard factor of the j-th node, min(criteria i ) and min(criteria i ) represent the minimum and maximum values of the ith standard factor of all nodes on the network.
[0088] The transaction ranking value calculation formula is used to determine the transaction ranking values of all nodes on the entire network, and then the top n active nodes with the highest transaction ranking values are selected from the entire network. The calculation formula for the transaction ranking value is:
[0089]
[0090] Select k nodes as production nodes. These k nodes are selected from the first n active nodes in step 2. The selection is based on evaluating the standard combination weighted value of each node and sorting them. The first k largest nodes are the output results. In order to measure the standard factor weighted value of each node, the following formula is proposed:
[0091]
[0092] Where criteria_total_value represents the standard factor value of each node. This standard value shows the possibility of a node becoming a block producer in a certain round.
[0093] This embodiment provides a method for selecting blocks in a blockchain. After the consensus mechanism is triggered, according to the rules of the consensus mechanism, the standard weight of each blockchain node is first determined according to multiple standard factors of the blockchain nodes in the blockchain to improve the dispersion of the production nodes and prevent the blockchain nodes from being driven by interests. Since the complexity of blockchain node selection will increase after the reference standard factors increase, the speed of processing the standard factors is increased by determining the standard weight of each blockchain node, thereby ensuring the selection rate of the production node. After the production node is selected, in order to ensure the availability of the production node in the blockchain, it is necessary to perform interest verification on the block to be verified produced by the production node. After the interest verification of each blockchain node, the block to be verified is determined as the target block that needs to be added to the blockchain. Therefore, the block added to the blockchain can make decisions based on the best interests of the entire network to ensure the fairness of the entire network.
[0094] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can refer to the above introduction, and will not be repeated later. Figure 3 , step S10 also includes steps S11 to S14:
[0095] Step S11, obtaining standard factors of each blockchain node in the blockchain;
[0096] Step S12, dividing the standard factors into a preset number of spatial clusters;
[0097] Step S13, based on a preset multi-region search algorithm, converge the initial weights of each of the spatial clustering clusters, and determine the optimal weight set of each of the spatial clustering clusters;
[0098] Step S14, based on the optimal weight set of each of the spatial clustering clusters, determining the standard weight of each blockchain node in the spatial clustering cluster.
[0099] It should be noted that the spatial clustering cluster can be a cluster divided by the standard factors through the K-means algorithm. The optimal weight set is the best weight value assigned to each standard factor. The standard weight is used for all nodes to use the standard weight and the corresponding standard value to evaluate and select the new block producer for the next round.
[0100] It is understandable that the increase in standard factors increases the complexity of weight combinations, which in turn increases the complexity of optimizing decentralization. In order to converge quickly and effectively optimize the decentralization level when the number of standard factors increases significantly, a set of optimal standard weights can be determined to maximize the fairness and democracy of block producer selection in the network.
[0101] Further, step S13 includes:
[0102] Based on a preset multi-region search algorithm, determine the gradient vector between the blockchain nodes in each of the spatial clusters;
[0103] Based on the gradient vector, the blockchain nodes in the corresponding spatial clustering cluster are moved to find the optimal solution of the spatial clustering cluster until the movement number of the blockchain node meets the preset strategy movement number, and the optimal solution is determined to be the optimal weight set of the spatial clustering cluster.
[0104] It should be noted that the gradient vector can approximately calculate the local minimum of each spatial clustering cluster.
[0105] It can be understood that in order to make the distance between each spatial clustering cluster as close as possible, the blockchain nodes in each spatial clustering cluster are close to each other, so that the blockchain nodes with higher similarity can be calculated by applying the gradient approximation.
[0106] It is understandable that the HPIS algorithm inspired by natural hunting can solve the problem of how to iteratively find the optimal solution for the evaluation criteria and weight factors of block producers. While increasing the number of evaluation criteria, the algorithm complexity is effectively controlled and the algorithm convergence speed is improved.
[0107] In the specific implementation, the search standard factor weight set is taken as the problem space, and all subsequent steps are centered around finding the optimal solution in this problem space. First, the search problem space is initialized by encoding the weight of each standard factor into a solution. The solution W of each problem space is an h-dimensional vector [w1, w2, ...w h ], where h is the number of standard factors and Wi is the weight of the i-th standard factor.
[0108] Furthermore, since the approach speed of nodes of different factors in each group is different, it can be accelerated or decelerated according to environmental factors.
[0109] In the specific implementation, you can use kl mul and kl div The parameters adjust the movement speed, which can be increased or decreased appropriately to help the algorithm quickly achieve local optimization. At the same time, a probability parameter is determined to avoid being trapped in a small local area. In addition, two acceleration parameters (r1 and r2) are used to adjust kl respectively. mul and kl divThe acceleration parameters (r1 and r2) help tune the processing speed of the algorithm, changing faster in areas of high variability, thus allowing for faster exploration of the search space. However, the sensitivity of these two parameters when changing the domain space is very large and there is no single fixed value. Therefore, evaluating many different benchmarks makes it very difficult to choose fixed values for these two parameters. In the present invention, these two parameters (r1 and r2) are chosen to be small and fixed values to avoid too much bias. moves The value of has a significant impact on the running time of the algorithm, n moes Generally, it can be set to a larger value, because the iteration speed can be increased exponentially by adjusting the numerical parameters r1 and r2.
[0110] Through the convergence calculation of the above HPIS algorithm, the target solution W can be finally obtained, that is, [w1, w2, ...w h ] A set of standard factor weights. Assume that we have a population of N groups. D is the problem dimension and the maximum algebra is g max , the cost of the fitness function is C. Set the algorithm to use n moves The number of moves is used to find the local optimal solution in the gradient approximation. In this step, the number of function evaluations is N*n move / G size During the repopulation phase, the algorithm uses only common transformation operators. The number of evaluations for this step is 2N / G size Therefore, the average complexity of the HPIS algorithm proposed in this invention is estimated to be O(gmax*N*n move *C).
[0111] Based on the first and second embodiments of the present application, in the third embodiment of the present application, the same or similar contents as those in the above embodiments can be referred to the above introduction, and will not be described in detail later. Figure 4 , step S12 also includes steps S01 to S03:
[0112] Step S01, selecting a preset number of central factors from the standard factors;
[0113] Step S02, respectively determining the similarity between each of the standard factors and each of the central factors;
[0114] Step S03: based on the similarity, the standard factors are divided into spatial clusters centered on the central factor.
[0115] It should be noted that the similarity can be the Euclidean distance between two central factors.
[0116] It is understandable that by pre-setting the number of central factors, the data dimensions that need to be processed can be reduced, thereby reducing the computational complexity and improving the efficiency of the algorithm. By calculating the similarity, the relationship between the standard factors can be quantified, providing a basis for subsequent clustering. Through clustering, the inherent structure and patterns in the data set can be revealed, helping to discover hidden relationships and trends, which not only improves the practicality of the algorithm, but also enhances the interpretability and application value of the results.
[0117] In the specific implementation, all the optimal solutions of target weights in the problem space can be regarded as prey in the hunting process, and the hunter is the current distribution status of the weight value of each standard factor. Based on this, the model is established, assuming that the current set of standard factors is represented by v i = {v i1 , v i2 , …, v in}, i = {1, 2, ..., p}, represents the coordinate value of the i-th factor in the n-dimensional feature space, then the distance matrix V of all factors can be expressed as:
[0118]
[0119] The similarity between two factors is expressed as Euclidean distance:
[0120]
[0121] The K-means algorithm is used to divide the factor set into K clusters. Each cluster is represented by v i In each round of iteration, each cluster has a cluster center factor ci, and the set of all cluster center factors is represented by c = {c1, c2, ..., c k}.
[0122] According to the algorithm process, randomly in the factor set v i Select K factors as the initial cluster centers. According to the principle that factors belonging to the same cluster have high similarity and factors in other clusters have low similarity, assign the remaining nodes to the corresponding cluster centers. Repeat the iteration until the cluster center does not change. When the iteration converges, divide the on-chain factor set into K groups according to the clustering results generated by the iteration. After the master node is elected in each group, the other nodes serve as slave factor nodes, and the master nodes of all groups constitute the central factor node of the cluster group.
[0123] Furthermore, step S14 further includes:
[0124] Performing dispersion evaluation on the optimal weight set of each of the spatial clustering clusters to determine the dispersion of each of the spatial clustering clusters;
[0125] Selecting a standard weight set from each of the optimal weight sets according to the dispersion;
[0126] The initial weights of each of the spatial clusters identified by the standard weight set are converged again until the number of convergences meets the preset maximum number of convergences, and the last obtained standard weight set is marked as the standard weight of each blockchain node in each spatial cluster.
[0127] It should be noted that the decentralization assessment can be to assess the degree of decentralization of each blockchain node.
[0128] It is understandable that the data evaluation module can be used to evaluate the dispersion of the optimal weight set, wherein the data evaluation module includes two components: a standard data collection component and a dispersion level evaluation component, and each set of weights in the search space is evaluated by the standard data collection component.
[0129] In the specific implementation, the output of the standard data collection component is an m-dimensional vector [N1, N2, ...N m ], where m is the number of blockchain nodes, N i is the number of times node i has become a block producer. Then, this vector is normalized to the interval [0, 1] using the formula, which will serve as the input of the dispersion level assessment component. The formula is:
[0130]
[0131] The evaluation criteria of the decentralization level evaluation component are based on two main factors: the number of nodes that become block producers and the variance between the number of times all nodes in the network become block producers within a certain number of rounds. Therefore, when the number of nodes that become block producers is larger, the decentralization level is higher; the variance value between the number of times all nodes become block producers within a certain round represents whether the node is evaluated fairly. In order to transform this problem into a maximization optimization problem, the formula for evaluating the decentralization level is:
[0132]
[0133] The decentralized_level value is in the interval [0, 1]. If the value is equal to 1, HDPoS will reach the maximum decentralization and all nodes will become leaders. On the contrary, the smaller the value of decentralization, the lower the degree of decentralization of the network. Therefore, the optimization mechanism of the decentralization level is described by Formula 12. Specifically, this is the process of finding the optimal standard weight set W when the decentralization is maximized. The calculation formula of the optimal standard weight set W is:
[0134] W * =argmax(decentralized_level)
[0135] The algorithm converges after the number of convergences reaches the maximum number of convergences, and finally completes the calculation and outputs the optimal set of standard factor weights.
[0136] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the method for selecting blocks in the blockchain of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0137] This application also provides a device for selecting blocks in a blockchain, please refer to Figure 5 , the block selection device in the blockchain includes:
[0138] The weight optimization module 10 is used to determine the standard weight of each blockchain node according to each standard factor of the blockchain node in the blockchain after the consensus mechanism is triggered;
[0139] A node selection module 20, configured to select a production node for producing a block from the blockchain nodes based on the standard weight;
[0140] A verification module 30, used to obtain the verification result of each blockchain node on the block to be verified produced by the production node;
[0141] The output module 40 is used to determine that the block to be verified is a target block that needs to be added to the blockchain if it is determined that the verification result is passed.
[0142] Optionally, the weight optimization module 10 is also used to obtain the standard factors of each blockchain node in the blockchain; divide the standard factors into a preset number of spatial clustering clusters; based on a preset multi-region search algorithm, converge the initial weights of each of the spatial clustering clusters, and determine the optimal weight set of each of the spatial clustering clusters; based on the optimal weight set of each of the spatial clustering clusters, determine the standard weight of each blockchain node in the spatial clustering cluster.
[0143] Optionally, the weight optimization module 10 is further used to determine the gradient vector between the blockchain nodes in each of the spatial clustering clusters based on a preset multi-region search algorithm; move the blockchain nodes in the corresponding spatial clustering cluster based on the gradient vector to find the optimal solution of the spatial clustering cluster until the number of movements of the blockchain node meets the preset strategy movement number, and determine that the optimal solution is the optimal weight set of the spatial clustering cluster.
[0144] Optionally, the weight optimization module 10 is further used to select a preset number of central factors from the standard factors; respectively determine the similarity between each of the standard factors and each of the central factors; and based on the similarity, divide the standard factors into spatial clusters centered on the central factors.
[0145] Optionally, the weight optimization module 10 is further used to evaluate the dispersion of the optimal weight set of each of the spatial clustering clusters to determine the dispersion of each of the spatial clustering clusters; select a standard weight set from each of the optimal weight sets according to the dispersion; use the standard weight set to identify the initial weights of each of the spatial clustering clusters and converge again until the number of convergences meets the preset maximum number of convergences, and mark the last obtained standard weight set as the standard weight of each blockchain node in each spatial clustering cluster.
[0146] Optionally, the verification module 30 is also used to receive the blocks to be verified of the production node in sequence based on a preset order; broadcast the blocks to be verified to each of the blockchain nodes; and receive the verification results of the transactions and signatures of the blocks to be verified by each of the blockchain nodes.
[0147] The device for selecting blocks in a blockchain provided by the present application adopts the method for selecting blocks in a blockchain in the above-mentioned embodiment, which can solve the technical problem that the consensus mechanism does not make decisions based on the best interests of the entire network and undermines the fairness of the network. Compared with the prior art, the beneficial effects of the device for selecting blocks in a blockchain provided by the present application are the same as the beneficial effects of the method for selecting blocks in a blockchain provided by the above-mentioned embodiment, and the other technical features of the device for selecting blocks in a blockchain are the same as the features disclosed in the above-mentioned embodiment method, which will not be described in detail here.
[0148] The present application provides a device for selecting blocks in a blockchain, the device for selecting blocks in a blockchain comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for selecting blocks in the blockchain in the first embodiment above.
[0149] Reference below Figure 6 , which shows a schematic diagram of the structure of a device for selecting blocks in a blockchain suitable for implementing an embodiment of the present application. The device for selecting blocks in a blockchain in an embodiment of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The block selection device in the blockchain shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0150] like Figure 6 As shown, the block selection device in the blockchain may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM: Read Only Memory) 1002 or the program loaded from the storage device 1003 to the random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the block selection device in the blockchain are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other via a bus 1005. The input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 can allow the selection device of a block in the blockchain to communicate wirelessly or wired with other devices to exchange data. Although the figure shows a selection device of a block in the blockchain with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have alternatively.
[0151] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0152] The device for selecting blocks in the blockchain provided by the present application adopts the method for selecting blocks in the blockchain in the above embodiment, which can solve the technical problem that the consensus mechanism does not make decisions based on the best interests of the entire network and undermines the fairness of the network. Compared with the prior art, the beneficial effects of the device for selecting blocks in the blockchain provided by the present application are the same as the beneficial effects of the method for selecting blocks in the blockchain provided by the above embodiment, and the other technical features of the device for selecting blocks in the blockchain are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0153] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0154] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0155] The present application provides a computer-readable storage medium having computer-readable program instructions (i.e., computer programs) stored thereon, and the computer-readable program instructions are used to execute the method for selecting blocks in the blockchain in the above-mentioned embodiment.
[0156] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0157] The computer-readable storage medium may be included in a block selection device in a blockchain; or may exist independently without being assembled into a block selection device in a blockchain.
[0158] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by a block selection device in a blockchain, the block selection device in the blockchain: after the consensus mechanism is triggered, determines the standard weight of each blockchain node according to each standard factor of the blockchain node in the blockchain; based on the standard weight, selects a production node for producing blocks from the blockchain nodes; obtains the verification results of each blockchain node on the block to be verified produced by the production node; if it is determined that the verification result is passed, determines that the block to be verified is a target block that needs to be added to the blockchain.
[0159] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0160] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0161] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0162] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned method for selecting blocks in the blockchain, and can solve the technical problem that the consensus mechanism does not make decisions based on the best interests of the entire network and undermines the fairness of the network. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the method for selecting blocks in the blockchain provided in the above-mentioned embodiment, and will not be repeated here.
[0163] The present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the method for selecting a block in a blockchain as described above.
[0164] The computer program product provided by this application can solve the technical problem that the consensus mechanism does not make decisions based on the best interests of the entire network and undermines the fairness of the network. Compared with the prior art, the beneficial effects of the computer program product provided by this application are the same as the beneficial effects of the method for selecting blocks in the blockchain provided by the above embodiment, and will not be repeated here.
[0165] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A method for selecting blocks in a blockchain, characterized in that: The method includes: After the consensus mechanism is triggered, the standard weight of each blockchain node in the blockchain is determined according to each standard factor of the blockchain node; Based on the standard weight, selecting a production node for producing a block from the blockchain nodes; Obtaining verification results of each of the blockchain nodes on the block to be verified produced by the production node; If it is determined that the verification result is passed, the block to be verified is determined to be a target block that needs to be added to the blockchain.
2. The method according to claim 1, characterized in that The step of determining the standard weight of each blockchain node according to each standard factor of the blockchain node in the blockchain includes: Get the standard factors of each blockchain node in the blockchain; Dividing the standard factors into a preset number of spatial clusters; Based on a preset multi-region search algorithm, the initial weights of the spatial clusters are converged to determine the optimal weight set of the spatial clusters; Based on the optimal weight set of each of the spatial clustering clusters, a standard weight of each blockchain node in the spatial clustering cluster is determined.
3. The method according to claim 2, characterized in that The step of converging the initial weights of each of the spatial clustering clusters based on a preset multi-region search algorithm and determining the optimal weight set of each of the spatial clustering clusters comprises: Based on a preset multi-region search algorithm, determine the gradient vector between the blockchain nodes in each of the spatial clusters; Based on the gradient vector, the blockchain nodes in the corresponding spatial clustering cluster are moved to find the optimal solution of the spatial clustering cluster until the movement number of the blockchain node meets the preset strategy movement number, and the optimal solution is determined to be the optimal weight set of the spatial clustering cluster.
4. The method according to claim 2, characterized in that The step of dividing the standard factors into a preset number of spatial clustering clusters comprises: Selecting a preset number of central factors from the standard factors; respectively determining the similarity between each of the standard factors and each of the central factors; Based on the similarity, the standard factors are divided into spatial clusters centered on the central factor.
5. The method according to claim 2, characterized in that The step of determining the standard weight of each blockchain node in the spatial cluster based on the optimal weight set of each spatial cluster includes: Performing dispersion evaluation on the optimal weight set of each of the spatial clustering clusters to determine the dispersion of each of the spatial clustering clusters; Selecting a standard weight set from each of the optimal weight sets according to the dispersion; The initial weights of each of the spatial clusters identified by the standard weight set are converged again until the number of convergences meets the preset maximum number of convergences, and the last obtained standard weight set is marked as the standard weight of each blockchain node in each spatial cluster.
6. The method according to claim 1, characterized in that The step of obtaining the verification result of each blockchain node on the block to be verified produced by the production node includes: Based on a preset order, receiving the blocks to be verified from the production nodes in sequence; Broadcasting the block to be verified to each of the blockchain nodes; Receive the verification results of each of the blockchain nodes on the transactions and signatures of the block to be verified.
7. A device for selecting blocks in a blockchain, characterized in that: The device comprises: A weight optimization module, which is used to determine the standard weight of each blockchain node according to the standard factors of the blockchain nodes in the blockchain after the consensus mechanism is triggered; A node selection module, configured to select a production node for producing a block from the blockchain nodes based on the standard weight; A verification module, used to obtain the verification result of each blockchain node on the block to be verified produced by the production node; The output module is used to determine that the block to be verified is a target block that needs to be added to the blockchain if it is determined that the verification result is passed.
8. A device for selecting blocks in a blockchain, characterized in that: The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the method for selecting a block in a blockchain as described in any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the method for selecting a block in a blockchain as described in any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, which, when executed by a processor, implements the steps of the method for selecting a block in a blockchain as described in any one of claims 1 to 6.