CN115720227A - Election method and device for consensus nodes of block chain and electronic equipment - Google Patents

Election method and device for consensus nodes of block chain and electronic equipment Download PDF

Info

Publication number
CN115720227A
CN115720227A CN202211430967.4A CN202211430967A CN115720227A CN 115720227 A CN115720227 A CN 115720227A CN 202211430967 A CN202211430967 A CN 202211430967A CN 115720227 A CN115720227 A CN 115720227A
Authority
CN
China
Prior art keywords
election
game
numbers
group
node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211430967.4A
Other languages
Chinese (zh)
Inventor
王家恒
江毅恒
乐煜炜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Tidu Technology Co ltd
Original Assignee
Hangzhou Tidu Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Tidu Technology Co ltd filed Critical Hangzhou Tidu Technology Co ltd
Priority to CN202211430967.4A priority Critical patent/CN115720227A/en
Publication of CN115720227A publication Critical patent/CN115720227A/en
Pending legal-status Critical Current

Links

Images

Abstract

The embodiment of the specification provides an election method and device for consensus nodes of a block chain and electronic equipment. The nodes in the block chain are divided into a plurality of groups, and each group comprises a main node and a plurality of sub-nodes; the method comprises the following steps: taking N blocks as a billing period, acquiring a master node selected from each group of nodes in the previous billing period in a competitive mode, taking the master node in each group as a consensus node of the current billing period, and packing block chain data to be uplinked into blocks by the consensus node based on a consensus algorithm; in the generation process of the first N1 blocks in the current accounting period, obtaining game election numbers reported by each sub-node in each group of nodes and used for election of a main node in the next accounting period; and in the process of generating the (N1) th to N (N) th blocks, selecting a target game competition selection number from the game competition selection numbers in each group, and taking a sub-node corresponding to the target game competition selection number selected in each group as a main node in the next accounting period.

Description

Election method and device for consensus nodes of block chain and electronic equipment
Technical Field
The embodiment of the specification relates to the technical field of block chains, in particular to an election method and device for consensus nodes of a block chain and electronic equipment.
Background
The block chain technology, also called distributed ledger technology, is an emerging technology in which several computing devices participate in "accounting" together, and a complete distributed database is maintained together. The blockchain technology has characteristics of decentralization, public transparency, participation of each computing device in database recording, and rapid data synchronization among the computing devices, so that the blockchain technology is widely applied in many fields.
In the blockchain technology, the consensus mechanism is a mechanism that a consensus node in a blockchain achieves a network-wide consensus on the blockchain information, and only the blockchain information that is agreed by the consensus mechanism can be added to the blockchain and linked to the blockchain.
In the related consensus mechanism, there is a link of selecting a consensus node. And the selection of the consensus node generally depends on the digital asset scale of the node, and if the digital asset scale of the node is larger, the probability that the node is selected as the consensus node is also larger. The selection mode is biased to the nodes with large digital asset scale, so that the fairness of selecting the consensus node is influenced.
Disclosure of Invention
An embodiment of the specification provides an election method and device for consensus nodes of a block chain and electronic equipment.
According to a first aspect of embodiments of the present specification, there is provided a method for election of consensus nodes of a blockchain, where nodes in the blockchain are divided into a plurality of groups, each group including a master node and a plurality of child nodes; the method comprises the following steps:
taking N blocks as a billing period, acquiring a main node selected by competition from each group of nodes in the last billing period, taking the main node in each group as a consensus node of the current billing period, and packaging the block chain data to be uplinked into the blocks by the consensus node based on a consensus algorithm;
in the generation process of the first N1 blocks in the current accounting period, game election numbers reported by each sub-node in each group of nodes and used for election of a main node in the next accounting period are obtained;
in the process of generating the (N1) th to N (N) th blocks, selecting a target game competition number from the game competition numbers in each group, and taking a sub-node corresponding to the target game competition number selected in each group as a main node in the next accounting period; wherein N and N1 are positive integers, and N1 is less than N.
Optionally, after obtaining the game election numbers reported by each child node in each group of nodes, the method further includes:
in the process of generating the (N1) th to (N2) th blocks, checking each reported game election number, and deleting game election numbers which do not pass the checking; wherein N2 is a positive integer, and N2 is less than N and greater than N1;
correspondingly, in the process of generating the (N1) th to N th blocks, selecting a target game election number from the game election numbers in each group, including:
and in the process of generating the N2 th to N blocks, selecting a target game competition number from the game competition numbers in each group.
Optionally, the verification includes validity verification, and the reported game election numbers include game election numbers signed by a private key corresponding to the child node;
the step of verifying each reported game election number comprises the following steps:
checking the game election numbers reported by the child nodes according to the public key corresponding to the private key of each child node;
and deleting the game election numbers which fail to check the game.
Optionally, the verification includes authenticity verification, and the reported game election numbers include a first hash value obtained by performing hash calculation on the game election numbers in the plaintext and the hash value of the current accounting period in the block header;
the checking of each reported game election number comprises the following steps:
carrying out Hash calculation on the game election number of the plaintext and the Hash value of the current accounting period in the block head to obtain a second Hash value;
and deleting the game election numbers of which the second hash value is inconsistent with the first hash value.
Optionally, the selecting a target game election number from the game election numbers in each group includes:
sorting the game election numbers in each group;
and based on a preset rule, selecting a target game election number from the game election numbers sequenced in each group.
Optionally, the preset rule includes selecting a median or selecting an average;
when the preset rule is a selection median, selecting a target game election number from the game election numbers sequenced in each group based on the preset rule, wherein the selecting step comprises the following steps:
selecting a game election number with a median from the game election numbers sequenced in each group;
determining the game election number of the median as a target game election number;
when the preset rule is a selection average number, selecting a target game election number from the game election numbers sequenced in each group based on the preset rule, wherein the step of selecting the target game election number comprises the following steps:
calculating the average number of the sorted game election numbers in each group;
and selecting the target game election number closest to the average number from the game election numbers sequenced in each group.
Optionally, the game election numbers are generated after a preset number of digital assets are pledged by the sub-nodes.
Optionally, the method further includes:
and if the number of the selected target game election numbers in any one group is more than 1, taking the main node in the group in the current accounting period as the main node in the next accounting period.
Optionally, the betting election numbers include real numbers between 0 and 100.
According to a second aspect of the embodiments of the present specification, there is provided an election device for consensus nodes of a blockchain, where nodes in the blockchain are divided into a plurality of groups, each group including a master node and a plurality of child nodes; the device comprises:
a block output unit, which takes the N blocks as a billing period, obtains the master nodes selected by the last billing period from each group of nodes, takes the master nodes in each group as the consensus nodes of the current billing period, and packs the block chain data to be linked into the blocks by the consensus nodes based on the consensus algorithm;
the acquiring unit is used for acquiring game election numbers which are reported by each sub-node in each group of nodes and are used for election of a main node in the next accounting period in the first N1 block generating process in the current accounting period;
the competition selection unit selects a target game competition selection number from the game competition selection numbers in each group in the generation process of the (N1) th to N (N) th blocks, and takes a sub-node corresponding to the target game competition selection number selected in each group as a main node in the next accounting period; wherein N and N1 are positive integers, and N1 is less than N.
Optionally, after the obtaining unit, the method further includes:
the checking unit is used for checking each reported game election number in the generation processes of the (N1) th to (N2) th blocks and deleting game election numbers which do not pass the checking; wherein N2 is a positive integer, and N2 is less than N and greater than N1;
correspondingly, the election unit selects a target game election number from the game election numbers in each group in the process of generating the N2 th to N blocks.
Optionally, the verification includes validity verification, and the reported game election numbers include game election numbers signed by a private key corresponding to the child node;
the verification unit comprises:
the legality checking subunit checks the game election numbers reported by the child nodes according to the public key corresponding to the private key of each child node; and deleting the game election numbers which fail to check the game.
Optionally, the verification includes authenticity verification, and the reported game election number includes a first hash value obtained by performing hash calculation on a game election number in a plaintext and a hash value of a current accounting period in a block header;
the verification unit includes:
the authenticity check subunit performs hash calculation on the game election number of the plaintext and the hash value of the current accounting period in the block head to obtain a second hash value; and deleting the game election numbers with the second hash value inconsistent with the first hash value.
Optionally, the election unit includes:
the sorting subunit sorts the game election numbers in each group;
and the selecting subunit selects a target game election number from the game election numbers sequenced in each group based on a preset rule.
Optionally, the preset rule includes selecting a median or selecting an average;
the selecting subunit is further used for selecting a game election number of the median from the game election numbers sequenced in each group when the preset rule is that the median is selected; determining the game election number of the median as a target game election number; or when the preset rule is the average number, calculating the average number of the sorted game election numbers in each group, and selecting the target game election number closest to the average number from the sorted game election numbers in each group.
Optionally, the game election numbers are generated after a preset number of digital assets are pledged by the sub-nodes.
Optionally, the election unit is further configured to select, in any one of the groups, a number of the betting numbers of the target game greater than 1, and use the master node in the group in the current accounting period as the master node in the next accounting period.
Optionally, the game election numbers include real numbers between 0 and 100.
According to a third aspect of embodiments herein, there is provided an electronic apparatus including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured as an election method of a consensus node of any one of the above block chains.
The embodiment of the specification provides an election scheme of consensus nodes of a block chain, the consensus nodes are selected through game election numbers reported by all sub-nodes, and the game election numbers are generated and are irrelevant to the digital asset scale of the nodes, so that the probability that the game election numbers reported by all the nodes are selected is the same, and fairness in the election process of the consensus nodes is ensured.
Drawings
Fig. 1 is a schematic diagram of a node grouping in a block chain according to an embodiment of the present disclosure;
fig. 2 is a flowchart of an election method of a consensus node of a block chain according to an embodiment of the present disclosure;
fig. 3 is a schematic diagram of consensus node election in a billing period according to an embodiment of the present disclosure;
FIG. 4 is a block diagram according to an embodiment of the present disclosure;
fig. 5 is a hardware structure diagram of an election device of a consensus node of a blockchain according to an embodiment of the present disclosure;
fig. 6 is a block diagram of an election device of a consensus node of a blockchain according to an embodiment of the present disclosure.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with this description. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the specification, as detailed in the appended claims.
The terminology used in the description herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the description. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, the first information may also be referred to as second information, and similarly, the second information may also be referred to as first information, without departing from the scope of the present specification. The word "if," as used herein, may be interpreted as "at \8230; \8230when" or "when 8230; \823030when" or "in response to a determination," depending on the context.
The Blockchain described in this specification may specifically include a Public chain (Public Blockchain), a Private chain (Private Blockchain), a federation chain (Consortium Blockchain), and the like. In addition, there may be a combination of the above types, such as private chain + federation chain, federation chain + public chain, and so on. The present specification is not particularly limited.
Among them, the most decentralized is the public chain. Participants who join the public chain in the public chain (also referred to as nodes in the blockchain) can read data records on the chain, participate in transactions, compete for accounting rights for new blocks, and the like. Moreover, each node can freely join or leave the network and perform related operations.
Private chains are the opposite, with the write rights of the private chain controlled by an organization or organization and the read rights of the data specified by the organization. Briefly, a private chain may be a weakly centralized system with strict restrictions on nodes and a small number of nodes. This type of blockchain is more suitable for use within a particular establishment.
A federation chain is a block chain between a public chain and a private chain, and "partial decentralization" can be achieved. Each node in a federation chain typically has a physical organization or organization corresponding to it; the nodes are authorized to join the network and form a benefit-related alliance, and block chain operation is maintained together.
Based on the basic characteristics of a block chain, the block chain is usually composed of several blocks. The time stamps corresponding to the creation time of the block are recorded in the blocks respectively, and all the blocks form a time-ordered data chain according to the time stamps recorded in the blocks strictly.
The real data generated by the physical world can be constructed into a standard transaction (transaction) format supported by a block chain, then is issued to the block chain, the received transaction is identified and processed by the nodes in the block chain, and after the identification is achieved, the transaction is packaged into a block by the nodes serving as accounting nodes in the block chain, and persistent evidence storage is carried out in the block chain.
It should be noted that the Transaction (Transaction) described in this specification refers to a piece of data that is created by a client of the blockchain and needs to be finally distributed to the data storage system of the blockchain.
Transactions in a blockchain, generally have a narrow sense of transaction and a broad sense of transaction score. A narrowly defined transaction refers to a transfer of value issued by a user to a blockchain; for example, in a conventional blockchain network, a transaction may be a transfer initiated by a user in the blockchain. The generalized transaction refers to a piece of business data with business intention, which is issued to the blockchain by a user; for example, an operator may build a federation chain based on actual business requirements, relying on the federation chain to deploy some other types of online business unrelated to value transfer (e.g., broadly classified as query business, call business, etc.), and in such federation chain, the transaction may be a business message or business request with a business intent issued by a user in the federation chain.
The client may include any type of upper layer application that uses the bottom layer service data stored in the blockchain as a data support to implement a specific service function.
In this specification, the consensus algorithm supported in the block chain may include:
a first kind of consensus algorithm (certificate-based consensus algorithm), that is, a consensus algorithm in which nodes need to contend for accounting for each round of accounting period; consensus algorithms such as Proof of Work (POW), proof of entitlement (POS), proof of entitlement (Delegated Proof of entitlement (DPOS), etc.;
a second kind of consensus algorithm (voting-based consensus algorithm), namely a consensus algorithm for contesting billing nodes for each billing period in advance (without contesting for billing right); for example, a consensus algorithm such as a Practical Byzantine Fault Tolerance (PBFT) is used.
In a blockchain network employing a first type of consensus algorithm, nodes competing for billing rights can execute a transaction upon receipt. One of the nodes competing for the accounting right can win the process of competing for the accounting right in the current round, and the node becomes the accounting node. The accounting node may package the received transaction with other transactions to generate a candidate block and send the generated candidate block or a block header of the candidate block to other nodes for consensus.
In the block chain network adopting the second type consensus algorithm, the nodes with the accounting right are agreed before the accounting of the current round. Thus, after receiving the transaction, the node may send the transaction to the accounting node if it is not the accounting node for its turn. For the accounting node of the current round, the transaction may be executed during or before packaging it with other transactions to generate candidate blocks. After generating the candidate block, the accounting node may send the candidate block or a block header of the candidate block to other nodes for consensus.
As described above, regardless of which consensus algorithm is used in the blockchain, the accounting node in the current round may pack the received transaction to generate a candidate block, and send the generated candidate block or the block header of the candidate block to other nodes for consensus verification. If no problem is verified after the other node receives the candidate block or the block header of the candidate block, the candidate block can be added to the end of the original block chain as the latest block, thereby completing the accounting process of the block chain. The transaction contained in the block may also be performed during the verification of a new block or block header from the accounting node by other nodes.
The consensus node is required to participate in any block chain by adopting the consensus algorithm shown above, the selection of the consensus node generally depends on the digital asset scale of the node, and if the digital asset scale of the node is larger, the probability that the node is selected as the consensus node is also larger. The selection mode is biased to the nodes with large digital asset scale, so that the fairness of selecting the consensus node is influenced.
In order to solve the above problems, the present specification aims to provide an election scheme for consensus nodes of a block chain, where the consensus nodes are selected through game election numbers reported by each child node, and because the generation of the game election numbers is not related to the scale of digital assets of the nodes, the probability that the game election numbers reported by each node are selected is the same, thereby ensuring fairness in the election process of the consensus nodes.
Please refer to the schematic diagram of the node grouping in the block chain shown in fig. 1. In this specification, the nodes in the blockchain may be divided into several groups (e.g., group 1, group 2, group 3, and group 4 in fig. 1), each group including a master node (e.g., "master" in fig. 1) and several child nodes (e.g., "child" in fig. 1).
In the creation stage of the block chain, a first block, i.e., a creation block, may be generated according to the initial configuration information of the block chain.
And after the created block is generated, entering a first accounting period, in each accounting period, taking the main node in each group as a common identification node, packing the block chain data to be chained into blocks by the common identification nodes based on a common identification algorithm in the block chain, and adding the blocks passing through the common identification as the latest blocks to the tail of the original block chain, thereby completing the accounting process of the block chain.
In addition, main nodes in the next accounting period group can be selected by competition among the sub-nodes in each group in each accounting period.
The block chain network can be formed by an upper layer network and a lower layer network through the grouping, the upper layer network formed by the main nodes in each group can be used for operating a consensus mechanism, and the number of the consensus nodes is known and controllable (equal to the number of the groups), so that the block chain network maintenance complexity can be reduced, the network redundancy can be reduced, and the network performance can be improved no matter which consensus scheme is used. And the lower layer network formed by the sub-nodes in each group can be used for competing for the main node in each accounting period to obtain the block chain maintenance right and the incentive benefit.
In the following, a related embodiment is described with reference to a flowchart of an election method for consensus nodes of a blockchain provided in this specification shown in fig. 2, where nodes in the blockchain are divided into a plurality of groups, and each group includes a master node and a plurality of child nodes; the method comprises the following steps:
step 210: taking N blocks as a billing period, acquiring a master node selected from each group of nodes in the previous billing period in a competitive mode, taking the master node in each group as a consensus node of the current billing period, and packaging block chain data to be uplinked into blocks by the consensus node based on a consensus algorithm;
step 220: in the generation process of the first N1 blocks in the current accounting period, game election numbers reported by each sub-node in each group of nodes and used for election of a main node in the next accounting period are obtained;
step 230: in the process of generating the (N1) th to N (N) th blocks, selecting a target game competition number from the game competition numbers in each group, and taking a sub-node corresponding to the target game competition number selected in each group as a main node in the next accounting period; wherein N and N1 are positive integers, and N1 is less than N.
In this specification, the consensus node required by the consensus mechanism in each accounting period may be a master node in each group after the node grouping, and the master node may be selected among the child nodes in the node grouping in the previous accounting period.
Similarly, election needs to be performed again between child nodes in each group in the current accounting period to elect a master node in the group for the next accounting period.
In this specification, the election process can be divided into two links of game election digital uploading and game election digital winning.
Wherein the game election number upload may correspond to the aforementioned step 220. In the generation process of the first N1 blocks in the current accounting period, each child node in each group of nodes can generate a game election number, and the generated game election numbers are uploaded to a block chain maintained by the main nodes of each group.
The game election number may be a real number between 0-100. It should be noted that the master node in the current accounting period cannot participate in the election of the master node for the next accounting period.
In this specification, in order to avoid malicious participation of child nodes in election, each child node may generate game election numbers only after a preset number of digital assets are pledged, and the digital assets of the pledge are lost after the child nodes are not pledged as a master node. Correspondingly, if the child node is selected as the main node, the child node can be used as the main node to obtain the incentive benefit related to the accounting period in the next accounting period.
In implementations, the child node may generate game election numbers by invoking game election number generation logic declared in an intelligent contract deployed in the blockchain. The game election number generation logic may be preset, for example, game election numbers are randomly generated based on a random algorithm, and this specification is not limited thereto.
The game winning digit may correspond to step 230 described above. In the process of generating the (N1) th to N th blocks in the current accounting period, selecting a target game competition number from the game competition numbers in each group, and taking the sub-node corresponding to the target game competition number selected in each group as a main node in the next accounting period.
In an exemplary embodiment, the selecting a targeted gaming number from the gaming numbers in each group may include:
sorting the game election numbers in each group;
and based on a preset rule, selecting a target game election number from the game election numbers sequenced in each group.
In this specification, the predetermined rules may include, but are not limited to, rules of picking median, picking average, picking position numbers at a specific percentage, etc. to pick a target game number from the plurality of game numbers sorted in each group.
Correspondingly, when the preset rule is the median of selection, selecting a target game election number from the game election numbers sorted in each group based on the preset rule may include:
selecting a game election number with a median from the game election numbers sequenced in each group;
and determining the game election number of the median as a target game election number.
For example, assuming that game election numbers reported by 5 child nodes in a certain packet are 42, 13, 75, 39, and 55, the game election numbers are sorted into 13, 39, 42, 55, and 75, wherein the median is 42, and thus the finally selected target game election number is 42. Further, the child node corresponding to the betting number 42 will be referred to as the master node in the next accounting period of the group.
Taking an example that the preset rule includes a selection average, correspondingly, when the preset rule is the selection average, selecting a target game election number from the game election numbers sorted in each group based on the preset rule may include:
calculating the average number of the sorted game election numbers in each group;
and selecting the target game election number closest to the average number from the game election numbers sequenced in each group.
For example, assuming that game election numbers reported by 5 child nodes in a certain packet are 42, 13, 75, 39 and 55 respectively, the game election numbers are sorted into 13, 39, 42, 55 and 75, and the calculated average number is (13 +39+42+55+ 75)/5 =44.8; of these 5 betting numbers 42 is the closest average 44.8 and the final winning betting number is therefore 42. Further, the child node corresponding to the betting number 42 will be referred to as the master node in the next accounting period of the group.
It should be noted that, when selecting the average, in addition to selecting the value closest to the average, a value closest to a combination of an arbitrary coefficient and the average, for example, a value closest to 2/3 of the average, may be selected.
The selection modes are only examples, and any selection mode can be adopted to construct the preset rule in practical application, and since all the selection modes cannot be exhausted in the specification one by one, the embodiments in the specification can be applied as long as the mode of fairly selecting the target game election number from the plurality of game election numbers.
In this specification, if the number of target game election numbers elected from a group is only 1, the master node of the current accounting period of the group may broadcast the elected child node to the blockchain network, so that the child node serves as the master node in the next accounting period of the group.
And if the number of the selected target game election numbers in any one group is more than 1, the main node of the group in the current accounting period can broadcast the main node to the block chain network, so that the main node in the group in the current accounting period can be continuously used as the main node of the next accounting period.
Through the method, in the current accounting period, the next accounting period is selected from each node group to become the child node of the main node.
In this specification, when the election process is divided into two loops of game election number reporting and game election number winning, since the reported game election number is plaintext, there may be a certain risk, for example, for a child node reporting the game election number later, a game election number that better meets a preset rule can be generated by referring to the previously reported game election number, thereby increasing the probability of self-election.
Therefore, in order to improve the security and fairness of the game election, a link of the game election digital verification can be added before the game election digital wins, namely, the election process can be divided into three links of game election digital reporting, game election digital verification and game election digital wining.
In an exemplary embodiment, after obtaining the game election numbers reported by the child nodes in each group of nodes in the step 220, the method may further include:
in the process of generating the (N1) th to (N2) th blocks, checking each reported game election number, and deleting game election numbers which do not pass the checking; wherein N2 is a positive integer, and N2 is smaller than N and larger than N1 (i.e., N1, N2, and N are positive integers, N1 is smaller than N2, and N2 is smaller than N).
Accordingly, the step 230 of selecting a targeted game number from the game numbers in each group in the N1 th to N th tile generation processes may include:
and in the process of generating the N2 th to N blocks, selecting a target game competition number from the game competition numbers in each group.
In the specification, the reported game election numbers are checked so as to ensure fairness and justice of election. The verification method may include, but is not limited to, validity verification, authenticity verification, and the like.
The following is a schematic diagram of the consensus node election introduced by taking 7 nodes in group 1 in the kth billing cycle as an example, as shown in fig. 3.
The group 1 includes 7 nodes, i.e., a, B, C, D, E, F, and G, where G is the master node and the others are the slave nodes.
In the first N1 block generation processes in the kth stage, 6 child nodes can generate respective game election numbers through the pledge digital assets, and then the generated game election numbers and the hash value of the current accounting period in the block head are combined and then subjected to hash calculation to obtain a first hash value. Take the Hash (63 + StageHash) reported by child node A in FIG. 3 as an example, where 63 is the game election number in plaintext, stageHash is the Hash value of the current accounting period, and Hash () is the Hash function, so Hash (63 + StageHash) represents the Hash value that is Hash-calculated after 63 and StageHash are combined.
Besides the hash calculation, the child node can use its own private key to sign the calculated first hash value and then report the signed first hash value.
Wherein the hash value of the current accounting period may be a parameter in a block header of a block, as shown in the block diagram of fig. 4. The block specific structure may include a block body and a block header, where the block header includes data such as a current block chain version, a timestamp, a hash value of a previous block, a hash value of a current accounting period, and a hash value of the block body corresponding to a block number of the current accounting period. The hash value of the current accounting period can be used for avoiding the double-flower problem, so that the security of game election in each accounting period is guaranteed. Specifically, even if the child node reports a plurality of game election numbers in the first N block generation processes, the hash values of the current accounting periods in the plurality of game election numbers are the same, so that the situation of reporting the plurality of game election numbers can be found.
In the process of generating the (N1-N2) th blocks, game election numbers reported by the 6 child nodes A, B, C, D, E and F need to be checked. Once the verification fails, the child node will lose the qualification of the election master node and the pledge's digital assets.
In an exemplary embodiment, when the verification includes validity verification, the reported game election numbers include game election numbers signed by a private key corresponding to the child node;
correspondingly, the verifying each reported game election number includes:
according to a public key corresponding to a private key of each child node, checking the game election numbers reported by the child nodes;
and deleting the game election numbers which fail to verify the lotteries.
In the example, the validity of the game election number is verified, so that only the game election nodes reported by the real child nodes are valid.
Because the private key is only known by the node, and the data signed by the private key can be successfully verified only by using the public key uniquely corresponding to the private key, the game election numbers reported by the malicious nodes simulating the legal child nodes cannot pass verification due to the lack of the private key signature.
In an exemplary embodiment, when the verification includes authenticity verification, the reported game election numbers include a game election number in a plaintext and a hash value of a current accounting period in a block header, and a first hash value is obtained through hash calculation;
correspondingly, the verifying each reported game election number includes:
carrying out hash calculation on the game election number of the plaintext and the hash value of the current accounting period in the block head to obtain a second hash value;
and deleting the game election numbers with the second hash value inconsistent with the first hash value.
In this example, whether the game election numbers are tampered is judged by comparing whether hash values obtained by two hash calculations are consistent. Once the game election number is tampered with, the corresponding hash value changes, and a result that the first hash value and the second hash value are identical is not obtained.
As shown in fig. 3, since the game election number verified by the child node F is 17 and the game election number reported by the child node F is 16, the game election number and the game election number are not consistent and cannot pass verification, the child node F loses the qualification of the election master node.
In the process of generating the (N2-N) th blocks, because the game election numbers reported by the child node F are deleted, the target game election numbers are elected from the remaining game election numbers A, B, C, D and E.
Firstly, the rest game election numbers are sorted, and the node sequence from small number to large number is E < B < D < A < C. Assuming that the preset rule is a selection median, the sorted median (game competition figure 42.7) corresponds to the child node D and the situation that the median corresponds to a plurality of child nodes does not occur, so that the child node D wins the game competition of the current round and becomes a master node in the group when the substitute node G becomes the next accounting period (k + 1).
In this specification, the consensus algorithm supported by the blockchain may include a certificate-based consensus algorithm or a vote-based consensus algorithm.
For example, when the blockchain adopts a certification-based consensus algorithm such as workload certification POW, the sub-nodes can complete consensus without the power of splicing, so that the resource consumption (power and electricity) of the consensus mechanism is reduced, the flow of the consensus mechanism is simplified, and the period of consensus is shortened.
For another example, when the block chain adopts a certification-based consensus algorithm such as a rights and interests certification POS or a voting-based consensus algorithm such as a byzantine fault-tolerant PBFT, since the consensus node selection no longer depends on the digital asset scale of the node, the probability that the high-asset node and the low-asset node become the consensus node is the same, so that the consensus mechanism of the block chain is more fair.
In summary, in the embodiments provided by the present specification, the consensus node is selected through the game election numbers reported by the sub-nodes, and because the generation of the game election numbers is not related to the digital asset scale of the nodes, the probability of the game election numbers reported by each node being selected is the same, thereby ensuring fairness in the process of selecting the consensus node.
Corresponding to the aforementioned embodiment of the election method for consensus nodes of a blockchain, the present specification further provides an embodiment of an election device for consensus nodes of a blockchain. The device embodiments may be implemented by software, or by hardware, or by a combination of hardware and software. The software implementation is taken as an example, and is formed by reading a corresponding computer program in the nonvolatile memory into the memory for running through a processor of the device where the software implementation is located as a logical means. In terms of hardware, as shown in fig. 5, the hardware structure diagram of the device where the election apparatus of the common node of the block chain is located in this specification is a hardware structure diagram, and besides the processor, the network interface, the memory, and the nonvolatile memory shown in fig. 5, the device where the apparatus is located in the embodiment may also include other hardware according to the actual election function of the common node of the block chain, which is not described again.
Referring to fig. 6, a block diagram of an election device for consensus nodes of a block chain according to an embodiment of the present disclosure is shown, where the device corresponds to the embodiment shown in fig. 6, and nodes in the block chain are divided into a plurality of groups, where each group includes a master node and a plurality of child nodes; the device comprises:
a block output unit, which takes the N blocks as a billing period, obtains the master nodes selected by the last billing period from each group of nodes, takes the master nodes in each group as the consensus nodes of the current billing period, and packs the block chain data to be linked into the blocks by the consensus nodes based on the consensus algorithm;
the acquisition unit is used for acquiring game election numbers which are reported by each sub-node in each group of nodes and used for election of a main node in the next accounting period in the generation process of the first N1 blocks in the current accounting period;
the competition selection unit selects a target game competition selection number from the game competition selection numbers in each group in the generation process of the (N1) th to N (N) th blocks, and takes a sub-node corresponding to the target game competition selection number selected in each group as a main node in the next accounting period; wherein N and N1 are positive integers, and N1 is less than N.
Optionally, after the obtaining unit, the method further includes:
the checking unit is used for checking each reported game election number in the generation process of the (N1) th to (N2) th blocks and deleting the game election numbers which do not pass the checking; wherein N2 is a positive integer, and N2 is less than N and greater than N1;
correspondingly, the election unit selects a target game election number from the game election numbers in each group in the process of generating the N2 th to N blocks.
Optionally, the verification includes validity verification, and the reported game election numbers include game election numbers signed by a private key corresponding to the child node;
the verification unit includes:
the legality checking subunit checks the game election numbers reported by the child nodes according to the public key corresponding to the private key of each child node; and deleting the game election numbers which fail to check the game.
Optionally, the verification includes authenticity verification, and the reported game election numbers include a first hash value obtained by performing hash calculation on the game election numbers in the plaintext and the hash value of the current accounting period in the block header;
the verification unit includes:
the authenticity check subunit performs hash calculation on the game election number of the plaintext and the hash value of the current accounting period in the block head to obtain a second hash value; and deleting the game election numbers with the second hash value inconsistent with the first hash value.
Optionally, the election unit includes:
the sorting subunit sorts the game election numbers in each group;
and the selecting subunit selects a target game election number from the game election numbers sequenced in each group based on a preset rule.
Optionally, the preset rule includes selecting a median or selecting an average;
the selecting subunit is further used for selecting the game election numbers with the median from the game election numbers sequenced in each group when the preset rule is that the median is selected; determining the game election number of the median as a target game election number; or when the preset rule is the average number, calculating the average number of the sorted game election numbers in each group, and selecting the target game election number closest to the average number from the sorted game election numbers in each group.
Optionally, the game election numbers are generated by a preset number of digital assets of a child node pledge.
Optionally, the election unit is further configured to select a target game election number greater than 1 from any one of the groups, and use the master node in the group in the current billing period as the master node in the next billing period.
Optionally, the betting election numbers include real numbers between 0 and 100.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, laptop, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
The specific details of the implementation process of the functions and actions of each unit in the above device are the implementation processes of the corresponding steps in the above method, and are not described herein again.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution in the specification. One of ordinary skill in the art can understand and implement it without inventive effort.
Fig. 6 above describes internal functional modules and a structural schematic of an election device of a consensus node of a block chain, and an implementation subject of the internal functional modules and the structural schematic may be an electronic device, including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to execute an embodiment of the election method of a consensus node of any one of the above blockchains.
In the above embodiments of the electronic device, it should be understood that the Processor may be a CPU, and may also be other general-purpose processors, digital Signal Processors (DSP), application Specific Integrated Circuits (ASIC), and so on. The general-purpose processor may be a microprocessor, or the processor may be any conventional processor, and the aforementioned memory may be a read-only memory (ROM), a Random Access Memory (RAM), a flash memory, a hard disk, or a solid state disk. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in a processor.
Additionally, this specification also provides a computer-readable storage medium, where instructions of the computer-readable storage medium, when executed by a processor of an electronic device, may enable the electronic device to perform an embodiment of an election method for a consensus node of any one of the above block chains.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the embodiment of the electronic device, since it is substantially similar to the embodiment of the method, the description is simple, and for the relevant points, reference may be made to part of the description of the embodiment of the method.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This specification is intended to cover any variations, uses, or adaptations of the specification following the general principles of the specification and including such departures from the present disclosure as come within known or customary practice in the art to which the specification pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the specification being indicated by the following claims.
It will be understood that the present description is not limited to the precise arrangements that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the description is limited only by the appended claims.

Claims (10)

1. A method for election of consensus nodes of a block chain is disclosed, wherein the nodes in the block chain are divided into a plurality of groups, and each group comprises a main node and a plurality of sub-nodes; the method comprises the following steps:
taking N blocks as a billing period, acquiring a master node selected from each group of nodes in the previous billing period in a competitive mode, taking the master node in each group as a consensus node of the current billing period, and packaging block chain data to be uplinked into blocks by the consensus node based on a consensus algorithm;
in the generation process of the first N1 blocks in the current accounting period, obtaining game election numbers reported by each sub-node in each group of nodes and used for election of a main node in the next accounting period;
in the process of generating the (N1) th to N (N) th blocks, selecting a target game competition number from the game competition numbers in each group, and taking a sub-node corresponding to the target game competition number selected in each group as a main node in the next accounting period; wherein N and N1 are positive integers, and N1 is less than N.
2. The method according to claim 1, further comprising, after the obtaining the game election numbers reported by the respective child nodes in each group of nodes:
in the process of generating the (N1) th to (N2) th blocks, checking each reported game election number, and deleting game election numbers which do not pass the checking; wherein N2 is a positive integer, and N2 is less than N and greater than N1;
correspondingly, in the process of generating the N1 th to N th blocks, selecting a target game election number from the game election numbers in each group includes:
and in the generation process of the (N2) th to N (N) th blocks, selecting a target game competition number from the game competition numbers in each group.
3. The method of claim 2, wherein the verification comprises a validity verification, and the reported game election numbers comprise game election numbers signed by a private key corresponding to the child node;
the checking of each reported game election number comprises the following steps:
checking the game election numbers reported by the child nodes according to the public key corresponding to the private key of each child node;
and deleting the game election numbers which fail to verify the lotteries.
4. The method according to claim 2, wherein the verification comprises authenticity verification, and the reported game election number comprises a first hash value obtained by performing hash calculation on a plaintext game election number and a hash value of a current accounting period in a block header;
the step of verifying each reported game election number comprises the following steps:
carrying out Hash calculation on the game election number of the plaintext and the Hash value of the current accounting period in the block head to obtain a second Hash value;
and deleting the game election numbers with the second hash value inconsistent with the first hash value.
5. The method of claim 1, wherein selecting a targeted gaming number from the gaming numbers in each set comprises:
sorting the game election numbers in each group;
and based on a preset rule, selecting a target game election number from the game election numbers sequenced in each group.
6. The method of claim 5, wherein the predetermined rule comprises selecting a median or selecting an average;
when the preset rule is a selection median, selecting a target game election number from the game election numbers sequenced in each group based on the preset rule, wherein the selecting step comprises the following steps:
selecting a game election number of a median from the game election numbers sequenced in each group;
determining the game election number of the median as a target game election number;
when the preset rule is a selection average number, selecting a target game election number from the game election numbers sequenced in each group based on the preset rule, wherein the step of selecting the target game election number comprises the following steps:
calculating the average number of the sorted game election numbers in each group;
and selecting a target game election number closest to the average number from the ranked game election numbers in each group.
7. The method of claim 1, wherein the game election numbers are generated by a child node pledging a predetermined number of digital assets.
8. The method of claim 1, further comprising:
and if the number of the selected target game election numbers in any one group is more than 1, taking the main node in the group in the current accounting period as the main node in the next accounting period.
9. An election device for consensus nodes of a block chain is characterized in that the nodes in the block chain are divided into a plurality of groups, and each group comprises a main node and a plurality of sub-nodes; the device comprises:
a block output unit, which takes the N blocks as a billing period, obtains the master nodes selected by the last billing period from each group of nodes, takes the master nodes in each group as the consensus nodes of the current billing period, and packs the block chain data to be linked into the blocks by the consensus nodes based on the consensus algorithm;
the acquisition unit is used for acquiring game election numbers which are reported by each sub-node in each group of nodes and used for election of a main node in the next accounting period in the generation process of the first N1 blocks in the current accounting period;
the competition selection unit selects a target game competition selection number from the game competition selection numbers in each group in the generation process of the (N1) th to N (N) th blocks, and takes a sub-node corresponding to the selected target game competition selection number in each group as a main node in the next accounting period; wherein N and N1 are positive integers, and N1 is less than N.
10. An electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the method of any of the preceding claims 1-8.
CN202211430967.4A 2022-11-15 2022-11-15 Election method and device for consensus nodes of block chain and electronic equipment Pending CN115720227A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211430967.4A CN115720227A (en) 2022-11-15 2022-11-15 Election method and device for consensus nodes of block chain and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211430967.4A CN115720227A (en) 2022-11-15 2022-11-15 Election method and device for consensus nodes of block chain and electronic equipment

Publications (1)

Publication Number Publication Date
CN115720227A true CN115720227A (en) 2023-02-28

Family

ID=85255241

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211430967.4A Pending CN115720227A (en) 2022-11-15 2022-11-15 Election method and device for consensus nodes of block chain and electronic equipment

Country Status (1)

Country Link
CN (1) CN115720227A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117834656A (en) * 2024-03-06 2024-04-05 广州优刻谷科技有限公司 Edge computing cross-domain synchronization method and system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117834656A (en) * 2024-03-06 2024-04-05 广州优刻谷科技有限公司 Edge computing cross-domain synchronization method and system

Similar Documents

Publication Publication Date Title
Bano et al. SoK: Consensus in the age of blockchains
CN109165945B (en) Representative node device election method and device, computer device and storage medium
CN110580653B (en) Block chain consensus mechanism based on transaction
US11734260B2 (en) Methods and apparatus for a distributed database within a network
EP3399446B1 (en) Methods and apparatus for distributed database within a network
CN111382456B (en) Proposal message processing method, device, equipment and storage medium
CN111865587B (en) Data processing method, block link point device, electronic device, and computer program
CN109118214A (en) The method and apparatus for running intelligent contract
Singh et al. A survey and taxonomy of consensus protocols for blockchains
CN109481936A (en) A kind of block chain accounting nodes selection method, device and computer readable storage medium
US20230315891A1 (en) Transaction data processing method and apparatus, computer device and storage medium
CN108831001B (en) Block chain-based node random selection method, system, node and electronic equipment
CN114281888A (en) Block chain consensus method, device, equipment and storage medium
Lev et al. Convergence of iterative scoring rules
WO2020082213A1 (en) Network expandability blockchain implementation method
CN115720227A (en) Election method and device for consensus nodes of block chain and electronic equipment
CN114039733B (en) Certificate storage service transfer method, device and equipment for alliance chains
Drakatos et al. Adrestus: Secure, scalable blockchain technology in a decentralized ledger via zones
Hsueh et al. EPoW: Solving blockchain problems economically
US11831749B1 (en) Method and system for utilizing the infrastructure of a blockchain to enhance the degree of reliability of another blockchain
CN112995167A (en) Kafka mechanism-based power utilization information acquisition method, block chain network and user side
CN112131602B (en) Method, device and related product for quickly expanding trust relationship between nodes based on trusted computing
CN109395392B (en) Forecast guess game deployment method and game method, equipment and storage medium
Nezhadsistani et al. Blockchain consensus algorithms: Past, present, and future trends
Han Scaling permissionless blockchains via sharding

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination