Method and apparatus for verifying election of a node, storage medium and device
By selecting super nodes and ordinary nodes as validators in the blockchain network, and using the amount of collateral as a reference, the problem of the inability to meet the Byzantine conditions in existing technologies is solved, thereby improving the activity of the blockchain network.
Patent Information
- Application Number
- CN202211156197.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-22
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2042-09-22
AI Technical Summary
In blockchain networks based on the Proof-of-Stake (PoS) consensus mechanism, existing election methods cannot meet the normal number of nodes required by the Byzantine Fault Tolerance (BFT) conditions, resulting in reduced blockchain network activity.
Nodes with a collateral amount greater than the target amount are selected as super nodes from the candidate nodes, and nodes with a collateral amount less than the target amount are selected as backup nodes. The target node is determined by random numbers and normalized probabilities. Finally, the super nodes and ordinary nodes are identified as verification nodes.
Ensure that the number of validating nodes meets the requirements of the consensus mechanism to improve the activity of the blockchain network.
Smart Images

Figure CN115578195B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of blockchains, and in particular to a method and device for electing a verification node, a storage medium and an apparatus. BACKGROUND
[0002] In a blockchain network based on a proof of stake (POS) consensus mechanism, all nodes that become verifiers (i.e., nodes participating in consensus verification, which can be referred to as verification nodes) can obtain the right to produce blocks (i.e., block production), i.e., each verification node can be elected as a block production node.
[0003] To ensure the security of the blockchain network, the probability of each node becoming a verification node is random. However, the number of normal verification nodes (i.e., verification nodes that do not strike during the block production node election period) obtained based on the existing election method cannot meet the number of normal nodes shown in the Byzantine condition in the consensus mechanism, resulting in a decrease in the activity of the blockchain network (so-called activity, i.e., each verification node can continuously reach consensus on new blocks, and honest nodes can confirm new blocks). SUMMARY
[0004] The present application provides a method and device for electing a verification node, a storage medium and an apparatus, which aims to improve the activity of the blockchain network.
[0005] To achieve the above-mentioned purpose, the present application provides the following technical solutions:
[0006] A method for electing a verification node, comprising:
[0007] Selecting, from each candidate node shown in a pledge contract, a candidate node with a pledge amount greater than and equal to a target amount as a supernode; the target amount is a ratio of a total pledge amount to n; the total pledge amount is the sum of the pledge amounts of all candidate nodes; n represents the number of normal nodes participating in the consensus verification process;
[0008] Identifying the supernode and the candidate node with a pledge amount less than the target amount as a backup node;
[0009] Repeating the target step multiple times to obtain multiple target nodes; the target step is: generating a random number, and identifying, as the target node, the backup node with the smallest absolute value of the difference between the normalized probability of each backup node and the random number; the normalized probability is calculated based on the pledge amount of the backup node;
[0010] Selecting, from each target node, a target node with a pledge amount less than the target amount as a normal node;
[0011] The super node and the normal node are both identified as a verification node.
[0012] Optionally, the super node is selected from the candidate nodes in the mortgage contract, and the candidate node with the mortgage amount greater than and equal to the target amount is selected as the super node, comprising:
[0013] After obtaining the mortgage contract uploaded to the blockchain network by the outside world, the mortgage contract is parsed to obtain a first node list; the first node list includes a plurality of candidate nodes, and the mortgage address and the mortgage amount of each candidate node;
[0014] The candidate node with the mortgage amount greater than and equal to the target amount is selected from the first node list as a candidate super node;
[0015] In the case that the penalty list does not record the mortgage address of the candidate super node, the candidate super node is identified as a super node; wherein the penalty list is used to record the mortgage address and the number of punishments of the candidate node meeting the fourth preset condition; the fourth preset condition is that the candidate node is not elected as a block node within a preset number of block node election cycles.
[0016] Optionally, the candidate super node is selected from the first node list, and the candidate node with the mortgage amount greater than and equal to the target amount is selected as the candidate super node, comprising:
[0017] The candidate node meeting the first preset condition in the first node list is deleted to obtain a second node list; the first preset condition is that the candidate node whose mortgage address is not recorded in the preset white list;
[0018] The candidate node meeting the second preset condition in the second node list is deleted to obtain a third node list; the second preset condition is that the candidate node whose mortgage address is recorded in the preset blacklist;
[0019] The candidate super node meeting the third preset condition in the third node list is identified; the third preset condition is that the candidate node with the mortgage amount greater than and equal to the target amount.
[0020] Optionally, it further comprises:
[0021] In the case that the penalty list records the mortgage address of the candidate super node, the number of punishments of the candidate super node recorded in the penalty list is adjusted to reduce the number of punishments of the candidate super node by one.
[0022] Optionally, the process of calculating the normalized probability of the backup node based on the mortgage amount of the backup node comprises:
[0023] The weighting value of each of the backup nodes is calculated by using the collateral amount of each of the backup nodes.
[0024] The normalized probability of each of the backup nodes is calculated by using the weighting value of each of the backup nodes.
[0025] Optionally, the target nodes with the collateral amount less than the target amount are selected from the target nodes as the ordinary nodes, and the method comprises the following steps of:
[0026] For each of the target nodes, the target node is identified as an ordinary node in a case that the collateral address of the target node is not recorded in a first preset list and a punishment list; the first preset list is used to store the collateral address of the supernode; the punishment list is used to record the collateral address and the number of punishments of the candidate node meeting a fourth preset condition; the fourth preset condition is that the candidate node is not elected as a block node in a preset number of block node election cycles.
[0027] Optionally, after the target node is identified as an ordinary node, the method further comprises the following steps of:
[0028] In a case that the collateral address of the target node is recorded in a second preset list, the equity of the target node is adjusted so that the equity of the target node is increased by one count unit; the second preset list is used to store the collateral address of the ordinary node.
[0029] In a case that the collateral address of the target node is not recorded in the second preset list, the collateral address of the target node is recorded in the second preset list, and the equity of the target node is adjusted so that the equity of the target node is changed by one count unit.
[0030] Optionally, after the target node is identified as an ordinary node, the method further comprises the following steps of:
[0031] The backup nodes meeting a fifth preset condition are deleted from the backup nodes, and k-m backup nodes are selected from the remaining backup nodes as the ordinary nodes; wherein the fifth preset condition is that the backup node whose collateral address is recorded in the punishment list, the first preset list and the second preset list; k represents the number of target nodes; m represents the total number of collateral addresses contained in the second preset list; the second preset list is used to store the collateral address of the ordinary node.
[0032] Optionally, the verification node comprises a master verification node and a slave verification node.
[0033] The supernode and the ordinary node are identified as the verification node, and the method comprises the following steps of:
[0034] sort the supernodes and the normal nodes according to preset sorting conditions, to obtain a node sequence; the preset sorting conditions are that the supernodes are arranged in front of the normal nodes in the node sequence;
[0035] identify the first n nodes in the node sequence as the primary verification nodes, and identify the other nodes except the first n nodes as the secondary verification nodes.
[0036] An election device of a verification node, comprising:
[0037] A first selecting unit is configured to select, from each candidate node shown in a mortgage contract, a candidate node with a mortgage amount greater than and equal to a target amount as a supernode; the target amount is a ratio of a total mortgage amount to n; the total mortgage amount is a sum of the mortgage amounts of all the candidate nodes; and n represents a number of normal nodes participating in a consensus verification process.
[0038] A first identifying unit is configured to identify the supernode and a candidate node with a mortgage amount less than the target amount as a backup node.
[0039] An executing unit is configured to repeatedly execute a target step to obtain a plurality of target nodes; the target step is to generate a random number and identify, as the target node, a backup node with a minimum absolute value of a difference between a normalized probability of each backup node and the random number; and the normalized probability is calculated based on the mortgage amount of the backup node.
[0040] A second selecting unit is configured to select, from each target node, a target node with a mortgage amount less than the target amount as a normal node.
[0041] A second identifying unit is configured to identify the supernode and the normal node as a verification node.
[0042] A computer readable storage medium, comprising a stored program, wherein the program executes the election method of the verification node.
[0043] An election device of a verification node, comprising a processor, a memory and a bus; the processor is connected with the memory through the bus;
[0044] The memory is configured to store a program, and the processor is configured to run the program, wherein the program runs to execute the election method of the verification node.
[0045] The technical scheme provided in the application selects, from each candidate node shown in a mortgage contract, a candidate node with a mortgage amount greater than or equal to a target amount as a super node. The super node and a candidate node with a mortgage amount less than the target amount are both identified as a backup node. The target step is repeatedly executed multiple times to obtain multiple target nodes. A target node with a mortgage amount less than the target amount is selected from each target node as a normal node. The super node and the normal node are both identified as a verification node. Compared with the prior art, the super node and the normal node are used as the verification node, the election of the verification node is based on the mortgage amount as a reference basis, so that the verification node has an interest relationship with the blockchain network, the number of normal verification nodes can meet the number of normal nodes shown in the Byzantine condition in the consensus mechanism, and the activity of the blockchain network is effectively improved. BRIEF DESCRIPTION OF DRAWINGS
[0046] In order to more clearly illustrate the technical schemes in the embodiments of the application or the prior art, the drawings needed in the embodiments or the prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.
[0047] Figure 1 A flowchart of a verification node election method provided by an embodiment of the application;
[0048] Figure 2 A flowchart of another verification node election method provided by an embodiment of the application;
[0049] Figure 3 An architecture diagram of a verification node election device provided by an embodiment of the application. DETAILED DESCRIPTION
[0050] The technical schemes in the embodiments of the application will be described clearly and completely below with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are only some of the embodiments of the application, not all the embodiments. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the application.
[0051] As shown in the flowchart of the verification node election method provided by an embodiment of the application, the method comprises the following steps: Figure 1
[0052] S101: After obtaining a mortgage contract uploaded to a blockchain network by an external environment, the mortgage contract is parsed to obtain a first node list.
[0053] The first node list includes a plurality of candidate nodes, and a mortgage address and a mortgage amount of each candidate node.
[0054] It should be noted that the candidate node is a node participating in the node election process in the blockchain network, and the mortgage addresses of the candidate nodes are different from each other.
[0055] S102: deleting a candidate node in the first node list that meets a first preset condition to obtain a second node list.
[0056] The first preset condition is that the candidate node whose mortgage address is not recorded in a preset whitelist.
[0057] S103: deleting a candidate node in the second node list that meets a second preset condition to obtain a third node list.
[0058] The second preset condition is that the candidate node whose mortgage address is recorded in a preset blacklist.
[0059] S104: identifying a candidate super node in the third node list that meets a third preset condition.
[0060] The third preset condition is that the candidate node whose mortgage amount is greater than or equal to a target amount. The target amount is a ratio of a total mortgage amount to n, the total mortgage amount is a sum of the mortgage amounts of all candidate nodes in the third node list, and n represents a number of normal nodes participating in the consensus verification process. Specifically, n = 3f + 1, and f represents a number of error nodes participating in the consensus verification process in the Byzantine condition.
[0061] S105: identifying a super node in the candidate super node in the case that a punishment list does not record a mortgage address of the candidate super node, and storing the mortgage address of the super node into a first preset list.
[0062] The punishment list is used to record a mortgage address and a number of punishments of a candidate node that meets a fourth preset condition. The fourth preset condition is that the candidate node is not elected as a block node in a preset number of block node election periods.
[0063] Optionally, in the case that the punishment list records the mortgage address of the candidate super node, the number of punishments of the candidate super node recorded in the punishment list is adjusted so that the number of punishments of the candidate super node is reduced by one.
[0064] It should be noted that for each candidate node in the punishment list, when the number of punishments of the candidate node is changed to 0, the mortgage address and the number of punishments of the candidate node are deleted from the punishment list.
[0065] S106: Identify the super node and the candidate nodes with the collateral amount less than the target amount as backup nodes.
[0066] S107: Calculate the weighted value of each backup node using the collateral amount of each backup node.
[0067] The specific implementation process of calculating the weighted value of each backup node using the collateral amount of each backup node can be seen in formula (1).
[0068] (1)
[0069] In formula (1), represents the weighted value, is a function for calculating the power of the collateral amount, represents the collateral amount, represents the specific value (i.e. ), represents the preset index of the power operation.
[0070] S108: Calculate the normalized probability of each backup node using the weighted value of each backup node.
[0071] The specific implementation process of calculating the normalized probability of each backup node using the weighted value of each backup node can be seen in formula (2).
[0072] (2)
[0073] In formula (2), represents the normalized probability of the backup node, represents the index of the backup node, represents the weighted value of the backup node, is a function for calculating the sum of the weighted values of each backup node, represents the total number of backup nodes.
[0074] S109: Repeat the target step r times to obtain multiple target nodes.
[0075] The target step is: generate a random number, and identify the backup node with the smallest absolute value of the difference between the normalized probability and the random number in each backup node as the target node. Generally, the specific implementation principle of generating a random number is the common knowledge familiar to those skilled in the art, and specifically, a random number algorithm can be used to generate a random number.
[0076] It should be noted that r is a positive integer, and the specific value of r can be set by the technician according to the actual situation. Specifically, r can be set to 1000, or r = the preset number of verification nodes - the total number of supernodes + the preset number of alternative verification nodes.
[0077] S110: For each target node, if the target node's collateral address is not recorded in the first preset list and the punishment list, the target node is identified as a normal node.
[0078] Optionally, in the case where the target node's collateral address is recorded in the first preset list, the target node's equity is adjusted so that the target node's equity increases by one count unit.
[0079] It should be noted that the initial value of the equity of each candidate node can be set to 0 by default. Accordingly, increasing the equity by one count unit is essentially adding one to the equity.
[0080] In the embodiments of the present application, the equity can be used as a reference basis for electing block nodes. The more equity a node has, the higher the chance of being elected as a block node. Conversely, the less equity a node has, the lower the chance of being elected as a block node.
[0081] Optionally, in the case where the target node's collateral address is not recorded in the first preset list and the target node's collateral address is recorded in the punishment list, the target node's equity is adjusted so that the target node's equity increases by one count unit.
[0082] Optionally, in the case where the target node's collateral address is recorded in the second preset list, the target node's equity is adjusted so that the target node's equity increases by one count unit. The second preset list is used to store the collateral addresses of normal nodes.
[0083] In the case where the target node's collateral address is not recorded in the second preset list, the target node's collateral address is recorded in the second preset list, and the target node's equity is adjusted so that the target node's equity changes to one count unit.
[0084] S111: Delete the backup nodes that meet the fifth preset condition from the backup nodes, and select k-m backup nodes from the remaining backup nodes as normal nodes.
[0085] The fifth preset condition is that the backup node's collateral address is recorded in the punishment list, the first preset list, and the second preset list. k represents the number of target nodes, and m represents the total number of collateral addresses contained in the second preset list.
[0086] Optionally, after the k-m backup nodes are selected as normal nodes, the collateral addresses of the k-m backup nodes can be stored in the second preset list, and the equity of the k-m backup nodes can be adjusted so that the equity of each of the k-m backup nodes is changed to one count unit.
[0087] It should be noted that the equity is changed to one count unit, which is essentially setting the equity to one.
[0088] S112: The super nodes and the normal nodes are sorted according to a preset sorting condition to obtain a node sequence.
[0089] The preset sorting condition is that the sequence position of the super nodes in the node sequence is before the sequence position of the normal nodes.
[0090] S113: The first n nodes in the node sequence are identified as master verification nodes, and the other nodes except the first n nodes are identified as slave verification nodes.
[0091] The master verification nodes and the slave verification nodes are both verification nodes, and the difference between them is that the master verification nodes are elected as block nodes earlier than the slave verification nodes.
[0092] It should be noted that in the subsequent block node election process, the slave verification nodes can be used to replace the on-strike master verification nodes when it is detected that the master verification nodes are on strike.
[0093] As described above, the super nodes with the collateral amount greater than or equal to the target amount are selected from the candidate nodes, and the normal nodes with the collateral amount less than the target amount are selected from the target nodes. Compared with the prior art, the super nodes and the normal nodes are used as verification nodes, and the election of the verification nodes is based on the collateral amount as a reference basis, so that the verification nodes have an interest relationship with the blockchain network, and the number of normal verification nodes can meet the number of normal nodes required by the Byzantine condition in the consensus mechanism, thereby effectively improving the activity of the blockchain network.
[0094] It should be noted that S101 mentioned in the above embodiments is an optional implementation of the verification node election method described in the present application. In addition, S113 mentioned in the above embodiments is also an optional implementation of the verification node election method described in the present application. Therefore, the process mentioned in the above embodiments can be summarized as Figure 2 The method.
[0095] As Figure 2 shown, another process of a verification node election method provided by an embodiment of the present application is shown, which includes the following steps:
[0096] S201: Select a super node from the candidate nodes shown in the collateral contract whose collateral amount is greater than or equal to the target amount.
[0097] Wherein, the target amount is the ratio of the total collateral amount to n; the total collateral amount is the sum of the collateral amounts of all participating nodes; and n represents the number of normal nodes participating in the consensus verification process.
[0098] S202: Super nodes and candidate nodes with collateral amounts less than the target amount will be marked as standby nodes.
[0099] S203: Repeat the target steps multiple times to obtain multiple target nodes.
[0100] The objective step is as follows: generate a random number, and identify the backup node with the smallest absolute value of the difference between the normalized probability and the random number among all backup nodes as the target node; the normalized probability is calculated based on the collateral amount of the backup node.
[0101] S204: Select target nodes from the target nodes whose collateral amount is less than the target amount, and use them as ordinary nodes.
[0102] S205: Mark both super nodes and ordinary nodes as verification nodes.
[0103] In summary, by selecting super nodes from among the candidate nodes whose collateral amount is greater than or equal to the target amount, and ordinary nodes from among the target nodes whose collateral amount is less than the target amount, compared to existing technologies, super nodes and ordinary nodes are used as validator nodes. The election of validator nodes is based on the collateral amount as a reference, so that validator nodes have a stake in the blockchain network. This ensures that the number of normal validator nodes can meet the normal node number required by the Byzantine condition in the consensus mechanism, effectively improving the activity of the blockchain network.
[0104] Corresponding to the verification node election method provided in the above embodiments of this application, the embodiments of this application also provide a verification node election device.
[0105] like Figure 3 The diagram shown is an architectural schematic of a verification node election device provided in an embodiment of this application, including:
[0106] The first selection unit 100 is used to select, from the participating nodes shown in the collateral contract, participating nodes whose collateral amount is greater than or equal to the target amount, as super nodes; the target amount is the ratio of the total collateral amount to n; the total collateral amount is the sum of the collateral amounts of all participating nodes; n represents the number of normal nodes participating in the consensus verification process.
[0107] The first selecting unit 100 is specifically configured to: after obtaining the staking contract uploaded to the blockchain network by the outside world, parse the staking contract to obtain a first node list; the first node list includes a plurality of candidate nodes, and the staking address and the staking amount of each candidate node; select a candidate node with a staking amount greater than and equal to the target amount from the first node list as a candidate supernode; in the case that the staking address of the candidate supernode is not recorded in the punishment list, mark the candidate supernode as a supernode; wherein the punishment list is used to record the staking address and the number of punishments of the candidate node meeting the fourth preset condition; the fourth preset condition is that the candidate node is not elected as a block node within a preset number of block node election periods.
[0108] The first selecting unit 100 is specifically configured to: delete a candidate node meeting a first preset condition in the first node list to obtain a second node list; the first preset condition is that the staking address of the candidate node is not recorded in the preset whitelist; delete a candidate node meeting a second preset condition in the second node list to obtain a third node list; the second preset condition is that the staking address of the candidate node is recorded in the preset blacklist; mark a candidate node meeting a third preset condition in the third node list as a candidate supernode; the third preset condition is that the staking amount of the candidate node is greater than and equal to the target amount.
[0109] The first selecting unit 100 is further configured to: in the case that the staking address of the candidate supernode is recorded in the punishment list, adjust the number of punishments of the candidate supernode recorded in the punishment list, so that the number of punishments of the candidate supernode is reduced by one.
[0110] The first identifying unit 200 is configured to mark the supernode and the candidate node with a staking amount less than the target amount as a backup node.
[0111] The first identifying unit 200 is specifically configured to: calculate the weighted value of each backup node by using the staking amount of each backup node; and calculate the normalized probability of each backup node by using the weighted value of each backup node.
[0112] The executing unit 300 is configured to repeatedly execute a target step to obtain a plurality of target nodes; the target step is: generating a random number, and marking a backup node with the smallest absolute value of the difference between the normalized probability and the random number in each backup node as a target node; the normalized probability is calculated based on the staking amount of the backup node.
[0113] The second selecting unit 400 is configured to select a target node with a staking amount less than the target amount from each target node as a normal node.
[0114] The second selecting unit 400 is specifically configured to: for each target node, in a case where the staking address of the target node is not recorded in the first preset list and the punishment list, identify the target node as a normal node; the first preset list is used to store the staking addresses of supernodes; the punishment list is used to record the staking addresses and the number of punishments of candidate nodes that meet a fourth preset condition; the fourth preset condition is that the candidate node is not elected as a block node in a preset number of block node election cycles.
[0115] The second selecting unit 400 is further configured to: in a case where the staking address of the target node is recorded in the second preset list, adjust the equity of the target node so that the equity of the target node increases by one count unit; the second preset list is used to store the staking addresses of normal nodes; in a case where the staking address of the target node is not recorded in the second preset list, record the staking address of the target node in the second preset list, and adjust the equity of the target node so that the equity of the target node changes by one count unit.
[0116] The second selecting unit 400 is further configured to: delete the backup nodes that meet a fifth preset condition from the backup nodes, and select k-m backup nodes from the remaining backup nodes as normal nodes; wherein the fifth preset condition is that the backup node has a staking address recorded in the punishment list, the first preset list and the second preset list; k represents the number of target nodes; m represents the total number of staking addresses contained in the second preset list; the second preset list is used to store the staking addresses of normal nodes.
[0117] The second identifying unit 500 is configured to identify the supernodes and the normal nodes as verification nodes.
[0118] The verification nodes include master verification nodes and slave verification nodes.
[0119] The second identifying unit 500 is specifically configured to: sort the supernodes and the normal nodes according to a preset sorting condition to obtain a node sequence; the preset sorting condition is that the supernodes are arranged in front of the normal nodes in the sequence of the node sequence; identify the first n nodes in the node sequence as master verification nodes, and identify the other nodes except the first n nodes as slave verification nodes.
[0120] In summary, the target nodes with the mortgage amount greater than or equal to the target amount are selected from the candidate nodes as super nodes, and the target nodes with the mortgage amount less than the target amount are selected from the candidate nodes as ordinary nodes, compared with the prior art, the super nodes and the ordinary nodes are used as verification nodes, the election of the verification nodes is based on the mortgage amount as a reference, so that the verification nodes have an interest relationship with the blockchain network, and the number of normal verification nodes can meet the number of normal nodes shown in the Byzantine condition in the consensus mechanism, thereby effectively improving the activity of the blockchain network.
[0121] The application further provides a computer-readable storage medium, which comprises a stored program, wherein the program executes the method for electing the verification node provided in the application.
[0122] The application further provides an election device for a verification node, comprising a processor, a memory and a bus. The processor is connected with the memory through the bus, the memory is used for storing a program, and the processor is used for running the program, wherein the program executes the method for electing the verification node provided in the application when running.
[0123] If the functions of the method provided in the embodiments of the application are realized in the form of software function units and sold or used as independent products, the functions can be stored in a computer device readable storage medium. Based on such understanding, the part of the prior art or the part of the technical solution of the embodiments of the application that makes contributions to the prior art can be embodied in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, a mobile computing device or a network device, etc.) to execute all or part of the steps of the method described in the embodiments of the application. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk and various media that can store program codes.
[0124] The embodiments in the specification are described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The same or similar parts of each embodiment can be referred to each other.
[0125] The above description of the disclosed embodiments enables a person skilled in the art to implement or use the application. Various modifications to the embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the application. Therefore, the application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for verifying election of a node, the method comprising: The method comprises the following steps: selecting, from each of the candidate nodes shown in the mortgage contract, a candidate node with a mortgage amount greater than and equal to a target amount as a super node; the target amount is a ratio of a total mortgage amount to n; the total mortgage amount is the sum of the mortgage amounts of all the candidate nodes; n represents the number of normal nodes participating in the consensus verification process; identifying each of the super nodes and the candidate nodes with a mortgage amount less than the target amount as a backup node; repeating the target step multiple times to obtain multiple target nodes; the target step is: generating a random number, and identifying the backup node with the smallest absolute value of the difference between the normalized probability of each backup node and the random number as the target node; the normalized probability is calculated based on the mortgage amount of the backup node; selecting, from each of the target nodes, a target node with a mortgage amount less than the target amount as a normal node; identifying each of the super nodes and the normal nodes as a verification node; the process of calculating the normalized probability of the backup node based on the mortgage amount of the backup node comprises: calculating the weighted value of each backup node using the mortgage amount of each backup node; calculating the normalized probability of each backup node using the weighted value of each backup node.
2. The method of claim 1, wherein, The method comprises the following steps: after obtaining the mortgage contract uploaded to the blockchain network by the outside world, analyzing the mortgage contract to obtain a first node list; the first node list includes multiple candidate nodes, and the mortgage address and mortgage amount of each candidate node; selecting, from the first node list, a candidate node with a mortgage amount greater than and equal to a target amount as a candidate super node; in the case where the mortgage address of the candidate super node is not recorded in the punishment list, identifying the candidate super node as a super node; wherein the punishment list is used to record the mortgage address and the number of punishments of the candidate node meeting the fourth preset condition; the fourth preset condition is that the candidate node is not elected as a block node within a preset number of block node election cycles.
3. The method of claim 2, wherein, The method comprises the following steps: deleting the candidate nodes meeting the first preset condition in the first node list to obtain a second node list; the first preset condition is that the candidate node with the mortgage address not recorded in the preset whitelist; deleting the candidate nodes meeting the second preset condition in the second node list to obtain a third node list; the second preset condition is that the candidate node with the mortgage address recorded in the preset blacklist; identifying the candidate nodes meeting the third preset condition in the third node list as candidate super nodes; the third preset condition is that the candidate node with a mortgage amount greater than and equal to a target amount.
4. The method of claim 2, wherein, The method further comprises the following steps: In a case where the punishment list records the pledge address of the candidate supernode, the number of punishments of the candidate supernode recorded in the punishment list is adjusted to reduce the number of punishments of the candidate supernode by one.
5. The method of claim 1, wherein, The target nodes with the pledge amount less than the target amount are selected from the target nodes as the normal nodes, and the method comprises the following steps of: For each target node, in a case where the pledge address of the target node is not recorded in a first preset list and a punishment list, the target node is identified as a normal node; the first preset list is used to store the pledge address of the supernode; the punishment list is used to record the pledge address and the number of punishments of the candidate node meeting a fourth preset condition; the fourth preset condition is that the candidate node is not elected as a block node in a preset number of block node election periods.
6. The method of claim 5, wherein, The method further comprises the following steps of: In a case where the pledge address of the target node is recorded in a second preset list, the equity of the target node is adjusted to increase the equity of the target node by one count unit; the second preset list is used to store the pledge address of the normal node; In a case where the pledge address of the target node is not recorded in the second preset list, the pledge address of the target node is recorded in the second preset list, and the equity of the target node is adjusted to change the equity of the target node to one count unit.
7. The method of claim 5, wherein, The method further comprises the following steps of: The backup nodes meeting a fifth preset condition are deleted from the backup nodes, and k-m backup nodes are selected from the remaining backup nodes as the normal nodes; the fifth preset condition is that the backup node is recorded in the punishment list, the first preset list and the second preset list; k represents the number of target nodes; m represents the total number of pledge addresses contained in the second preset list; the second preset list is used to store the pledge address of the normal node.
8. The method of claim 1, wherein, The verification nodes comprise master verification nodes and slave verification nodes; The method further comprises the following steps of: The supernodes and the normal nodes are sorted according to a preset sorting condition to obtain a node sequence; the preset sorting condition is that the supernodes are arranged in front of the normal nodes in the node sequence; The first n nodes in the node sequence are identified as the master verification nodes, and the other nodes except the first n nodes are identified as the slave verification nodes.
9. An apparatus for verifying election of a node, the apparatus comprising: The method comprises the following steps of: A first selecting unit is configured to select candidate nodes with a pledge amount greater than and equal to a target amount from the candidate nodes shown in a pledge contract as supernodes. The target amount is a ratio of a total pledge amount to n; the total pledge amount is the sum of the pledge amounts of all the candidate nodes; n represents the number of normal nodes participating in the consensus verification process. The first identification unit is configured to identify the super node and the candidate node with the mortgage amount less than the target amount as a backup node. The execution unit is configured to repeatedly execute a target step to obtain a plurality of target nodes. The target step is to generate a random number, and identify the backup node with the minimum absolute value of the difference between the normalized probability of each backup node and the random number as the target node. The normalized probability is calculated based on the mortgage amount of the backup node. The second selection unit is configured to select a target node with a mortgage amount less than the target amount from each target node as a common node. The second identification unit is configured to identify the super node and the common node as a verification node. The first identification unit is specifically configured to calculate the weighted value of each backup node using the mortgage amount of each backup node, and calculate the normalized probability of each backup node using the weighted value of each backup node.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium includes a stored program, wherein the program executes the verification node election method of any one of claims 1-8.
11. An election device for validating a node, characterized in that, It includes: A processor, a memory and a bus; The processor and the memory are connected through the bus; The memory is used to store programs, and the processor is used to run programs, wherein the program runs to execute the verification node election method of any one of claims 1-8.
Citation Information
Patent Citations
A node deployment and election method of a block chain
CN109426567A
Super node determination method and device based on block chain, and storage medium
CN114154994A