Node selection method, blockchain consensus method and device, system, and equipment
By adopting node selection method and blockchain consensus method in blockchain technology, the problems of wasted computing resources, low transaction throughput or high latency in the existing technology are solved, and the goal of integrating cloud computing services into blockchain technology is achieved, improving the efficiency and scalability of the system.
Patent Information
- Application Number
- CN201911175950.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-11-26
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2039-11-26
AI Technical Summary
Consensus algorithms in existing blockchain technology lead to waste of computing resources, low transaction throughput or high latency, and the inability to directly integrate cloud computing services into blockchain technology.
Through a node selection method, the block hash value of the current latest block in the blockchain is obtained, and the candidate node is determined based on the account address of the node in the consistent hash ring, and whether it meets the preset conditions. If it is satisfied, it will be broadcast as the target node, otherwise a new candidate node will be selected. At the same time, a blockchain consensus method is provided, which judges the legitimacy by receiving pending transactions sent by the working node, and links the legitimate transactions to the blockchain after verification by the consensus node.
It reduces the waste of computing resources, improves transaction throughput and response speed, can dynamically adjust the block generation speed according to network pressure, and integrates cloud computing services into blockchain technology.
Smart Images

Figure CN112953981B_ABST
Abstract
Description
Background Art
[0002] In current blockchain technology, most consensus algorithms require all nodes to participate in a computational game to find a specified random number to prove that they have spent enough computing resources. The winner of the game can obtain the right to keep accounts and obtain certain benefits. This consensus method wastes a huge amount of computing resources and electricity. At the same time, the speed of generating blocks is slow, which is prone to low transaction throughput or high latency. It is also impossible to dynamically adjust the block generation speed according to the real-time network pressure. This restricts the development of blockchain in public networks for low-latency, high-concurrency, and fast-response business scenarios.
[0003] In addition, the existing blockchain technology lacks solutions for cloud computing-type resource services, and cloud computing services cannot be directly integrated into blockchain technology.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] The purpose of the present disclosure is to provide a node selection method, a blockchain consensus method, a node selection device, a blockchain consensus device, a blockchain consensus system, an electronic device and a computer-readable storage medium, thereby at least to a certain extent overcoming the problems of existing formula methods that easily cause waste of computing resources, low transaction throughput or high latency, and cannot directly integrate cloud computing services into blockchain technology.
[0006] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present invention.
[0007] According to a first aspect of the present disclosure, a node selection method is provided, including: obtaining a block hash value of the current latest block in the blockchain, and obtaining an initial account address of each node in a consistent hash ring; determining a current candidate node from the consistent hash ring according to the block hash value and the initial account address; judging whether the current candidate node meets a preset condition; if so, taking the current candidate node as a target node, and having the target node broadcast a node selection message in the blockchain network; if not, selecting a new candidate node as the current candidate node.
[0008] Optionally, the above method also includes: determining the node to be entered and the initial account address of the node to be entered; wherein, the node to be entered is a node with resource service capabilities; determining the account address of the node to be entered based on the initial account address to form a new working node and join it to the consistent hash working ring composed of working nodes.
[0009] Optionally, the account address of the node to be entered is determined based on the initial account address, including: determining the node public key of the node to be entered, and performing a hash function operation on the node public key to obtain the initial account address; adding a version number and a checksum code to the initial account address to generate an intermediate account address; and performing an encoding operation on the intermediate account address to obtain the account address.
[0010] Optionally, the above method also includes: receiving a pending request sent by the user terminal and determining the request type of the pending request; determining the reward information of the pending request according to the request type, and the target node generates a pending transaction according to the reward information.
[0011] According to a second aspect of the present disclosure, a blockchain consensus method is provided, including: receiving a pending transaction sent by a working node, and determining whether the pending transaction meets a preset legal judgment condition; if so, adding a legal identification to the pending transaction to generate an initial legal transaction, and storing the initial legal transaction in a target block; other consensus nodes in the blockchain network verify the legality of the target block and determine a verification result; if the verification result is a legal result, linking the target block to the blockchain.
[0012] Optionally, the above method also includes: if not, adding an illegal identifier to the transaction to be processed to generate an illegal transaction and an illegal transaction message; and broadcasting the illegal transaction message in the blockchain network.
[0013] Optionally, the above method also includes: determining the amount of resources and service time corresponding to the working node, and determining the initial contribution of the working node based on the amount of resources and service time; sorting the initial contribution to obtain a sorting result, and determining a preset number of working nodes based on the sorting result; and adjusting the determined working nodes to new consensus nodes in the blockchain network according to a preset period.
[0014] Optionally, the above method also includes: determining the accounting deduction coefficient and the penalty deduction coefficient of the consensus node; adjusting the initial contribution to the current contribution according to the accounting deduction coefficient and the penalty deduction coefficient; and sorting the current contribution to replace the consensus node in the blockchain network according to the sorting result.
[0015] According to a third aspect of the present disclosure, a node selection device is provided, including: an address acquisition module, used to obtain the block hash value of the current latest block in the blockchain, and obtain the initial account address of each node in the consistent hash ring; a node determination module, used to determine the current candidate node from the consistent hash ring according to the block hash value and the initial account address; a judgment module, used to judge whether the current candidate node meets the preset conditions; a node selection module, used to, if so, take the current candidate node as the target node, and the target node broadcasts the node selection message in the blockchain network; a candidate node selection module, used to, if not, select a new candidate node as the current candidate node.
[0016] Optionally, the node determination module includes a node adding unit, which is used to determine the node to be entered and the initial account address of the node to be entered; wherein, the node to be entered is a node with resource service capabilities; the account address of the node to be entered is determined according to the initial account address to form a new working node and join it to the consistent hash working ring composed of working nodes.
[0017] Optionally, the node adding unit includes an address determination subunit, which is used to determine the node public key of the node to be entered, and perform a hash function operation on the node public key to obtain an initial account address; add a version number and a verification code to the initial account address to generate an intermediate account address; and perform an encoding operation on the intermediate account address to obtain an account address.
[0018] Optionally, the node selection device also includes a transaction generation module, which is used to receive the pending request sent by the user terminal and determine the request type of the pending request; determine the reward information of the pending request according to the request type, and the target node generates a pending transaction according to the reward information.
[0019] According to a fourth aspect of the present disclosure, a blockchain consensus device is provided, including: a transaction judgment module, used to receive a pending transaction sent by a working node, and judge whether the pending transaction meets a preset legal judgment condition; a block generation module, used to add a legal identification to the pending transaction to generate an initial legal transaction, and store the initial legal transaction in a target block; a verification module, used to verify the legality of the target block by other consensus nodes in the blockchain network, and determine the verification result; a transaction storage module, used to link the target block to the blockchain if the verification result is a legal result.
[0020] Optionally, the blockchain consensus device also includes a message broadcast module, which is used to add an illegal identifier to the transaction to be processed to generate an illegal transaction and an illegal transaction message; and broadcast the illegal transaction message in the blockchain network.
[0021] Optionally, the blockchain consensus device also includes a node replacement module, which is used to determine the amount of resources and service time corresponding to the working node, and determine the initial contribution of the working node based on the amount of resources and service time; sort the initial contribution to obtain a sorting result, and determine a preset number of working nodes based on the sorting result; and adjust the determined working nodes to new consensus nodes in the blockchain network according to a preset period.
[0022] Optionally, the node replacement module includes a node replacement unit, which is used to determine the accounting deduction coefficient and the penalty deduction coefficient of the consensus node; adjust the initial contribution to the current contribution according to the accounting deduction coefficient and the penalty deduction coefficient; and sort the current contribution to replace the consensus node in the blockchain network according to the sorting result.
[0023] According to a fifth aspect of the present disclosure, a blockchain consensus system is provided, including: a working node, used to receive pending requests sent by a user terminal, and generate corresponding pending transactions for the pending requests; a consensus node, used to judge the legality of the pending transactions, determine the pending transactions that meet the legality as legal transactions and store them in blocks; a block, used to store transaction information of legal transactions.
[0024] According to a sixth aspect of the present disclosure, there is provided an electronic device, comprising: a processor; and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the node selection method and / or blockchain consensus method described in any one of the above items is implemented.
[0025] According to a seventh aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the node selection method and / or blockchain consensus method described in any one of the above items is implemented.
[0026] The technical solution provided by the present disclosure may have the following beneficial effects:
[0027] The node selection method in the exemplary embodiment of the present disclosure obtains the block hash value of the current latest block, and determines the current candidate node from the consistent hash ring according to the account address of the node in the consistent hash ring, and determines whether the current candidate node meets the preset conditions. If the current candidate node meets the preset conditions, the current candidate node is used as the target node, otherwise, a new node is selected from the consistent hash ring as the current candidate node to determine the target node. Through the node selection method disclosed in the present disclosure. On the one hand, the account address of the node in the consistent hash ring is generated by a cryptographically secure hash algorithm. Therefore, the generated account address has good anti-collision performance, and ensures the uniformity of many account addresses in the entire network, so that the selection of working nodes is random and fair. On the other hand, the account address of the node in the consistent hash ring cannot be changed, so the position of the node in the consistent hash ring cannot be changed, which reduces the risk of cheating in the network. On the other hand, by utilizing the randomness of block generation in the blockchain, the target node can be selected from the blockchain network quickly, fairly and randomly, avoiding useless consumption caused by a large amount of useless calculations due to consensus.
[0028] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure, and together with the specification, are used to explain the principles of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0030] Figure 1 A flowchart of a node selection method according to an exemplary embodiment of the present disclosure is schematically shown;
[0031] Figure 2 The structure diagram of the blockchain network according to the exemplary embodiment of the present disclosure is schematically shown;
[0032] Figure 3 The data structure diagram of a block in a blockchain according to an exemplary embodiment of the present disclosure is schematically shown;
[0033] Figure 4 The following schematically shows a flowchart of implementing a blockchain node joining a blockchain network according to an exemplary embodiment of the present disclosure;
[0034] Figure 5The flowchart of the algorithm for generating the account addresses of various types of nodes according to the exemplary embodiment of the present disclosure is schematically shown;
[0035] Figure 6 The following schematically shows the structural intent of consistent hashing selection averaging according to an exemplary embodiment of the present disclosure;
[0036] Figure 7 The following schematically shows a flowchart of selecting a blockchain function node according to a block hash according to an exemplary embodiment of the present disclosure;
[0037] Figure 8 The transaction structure diagram in the blockchain according to an exemplary embodiment of the present disclosure is schematically shown;
[0038] Fig. 9 A flowchart of a blockchain consensus method according to an exemplary embodiment of the present disclosure is schematically shown;
[0039] Fig.10 A block diagram schematically shows a node selection device according to an exemplary embodiment of the present disclosure;
[0040] Fig.11 Schematically shows a block diagram of a blockchain consensus device according to an exemplary embodiment of the present disclosure;
[0041] Fig.12 The structure diagram of the blockchain consensus system according to the exemplary embodiment of the present disclosure is schematically shown;
[0042] Fig.13 A block diagram schematically shows an electronic device according to an exemplary embodiment of the present disclosure;
[0043] Fig.14 A schematic diagram of a computer-readable storage medium according to an exemplary embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0044] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be comprehensive and complete and will fully convey the concepts of the example embodiments to those skilled in the art. The same reference numerals in the figures represent the same or similar parts, and thus their repeated description will be omitted.
[0045] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known structures, methods, devices, implementations, materials or operations are not shown or described in detail to avoid blurring the various aspects of the present disclosure.
[0046] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or these functional entities or parts of functional entities may be implemented in one or more software hardened modules, or these functional entities may be implemented in different networks and / or processor devices and / or microcontroller devices.
[0047] In the current blockchain consensus method, all nodes in the blockchain jointly participate in the computational game of finding a specified random number. The winner of the game can obtain the right to keep accounts and obtain certain benefits. This consensus method wastes a huge amount of computing resources and electricity. At the same time, the speed of generating blocks is slow, which is prone to low transaction throughput or high latency. It is also impossible to dynamically adjust the block generation speed according to the real-time network pressure. In addition, the existing blockchain technology lacks solutions for cloud computing type resource services, and it is impossible to directly integrate cloud computing services into blockchain technology.
[0048] Based on this, in this example embodiment, firstly, a node selection method is provided, and any node in the blockchain can be used to implement the node selection method of the present disclosure. Specifically, the node in the blockchain can be a server or a terminal device, that is, the server can be used to implement the node selection method of the present disclosure, and the terminal device can also be used to implement the method described in the present disclosure. The terminals described in the present disclosure may include mobile terminals such as mobile phones, tablet computers, laptops, PDAs, and personal digital assistants (PDAs), as well as fixed terminals such as desktop computers. Figure 1 The following is a schematic diagram schematically showing the node selection method flow according to some embodiments of the present disclosure. Figure 1 , the node selection method may include the following steps:
[0049] Step S110, obtain the block hash value of the latest block in the blockchain, and obtain the initial account address of each node in the consistent hash ring.
[0050] Step S120, determine the current candidate node from the consistent hash ring according to the block hash value and the initial account address.
[0051] Step S130, determining whether the current candidate node meets a preset condition.
[0052] Step S140: If yes, the current candidate node is used as the target node, and the target node broadcasts the node selection message in the blockchain network.
[0053] Step S150: If not, a new candidate node is selected as the current candidate node.
[0054] According to the node selection method in this example embodiment, on the one hand, the account address of the node in the consistent hash ring is generated using a cryptographically secure hash algorithm, so the generated account address has good anti-collision properties, and ensures the uniformity of many account addresses in the entire network, so that the selection of working nodes is random and fair. On the other hand, the account address of the node in the consistent hash ring cannot be changed, so the position of the node in the consistent hash ring cannot be changed, reducing the risk of cheating in the network. On the other hand, by utilizing the randomness of block generation in the blockchain, the target node can be selected from the blockchain network quickly, fairly, and randomly, avoiding useless consumption caused by a large amount of useless calculations due to consensus.
[0055] The node selection method in this exemplary embodiment will be further described below.
[0056] In step S110, the block hash value of the latest block in the blockchain is obtained, and the initial account address of each node in the consistent hash ring is obtained.
[0057] In some exemplary embodiments of the present disclosure, a blockchain network may include blockchain nodes and blocks. Blockchain nodes may include working nodes and consensus nodes. Blocks are used to store generated transaction information. The current latest block may be the latest block currently generated in the blockchain network. Figure 2 , Figure 2 The block chain network 200 schematically shows an organizational structure diagram of the block chain network. In the block chain network 200, it can include a consistent working ring 210 composed of working nodes, a consistent hashing ring 220 composed of 2 consensus nodes, and a block 230. The block hash value can be the information contained in the block in the block chain, and the block hash value of the current node is part of the block data structure. Figure 3 , Figure 3The data structure diagram of the block in the blockchain is schematically shown. The block data structure in this exemplary embodiment may include two parts: a block header and a block body. Among them, the block header 310 may include, but is not limited to, a version number, a block height, a timestamp, a block hash, a previous block hash, a number of transactions, and a Merkle tree root; a transaction set may be stored in the block body 320. Specifically, the block hash value may be generated by calculating the block header using the Secure Hash Algorithm (SHA) and the RACE Integrity Primitives Evaluation Message Digest (RIPEMD) algorithm. For example, in this exemplary embodiment, the block hash value may be generated by calculating the block header using the SHA256 algorithm and the RIPEMD160 algorithm, i.e., block hash = RIPEMD160 (SHA256 (block header)).
[0058] The consistent hash ring can be a virtual ring composed of nodes in the blockchain that is constructed using a consistent hash algorithm. When a service node in cloud computing enters the blockchain network, it can locate a node with a length of 2 according to the value of its initial account address. 160 Since the account address of a node cannot be changed before it exits the network, its position in the consistent hash ring cannot be changed either, which reduces the risk of cheating in the network.
[0059] Each working node generates an account address when entering the blockchain network, which is used for positioning in the network. The account address generation algorithm uses a cryptographically secure hash algorithm. The output length of the algorithm is 160 bits, which ensures that it has good anti-collision performance and prevents two different nodes from generating the same account address. At the same time, the algorithm encodes the account address to ensure that it has a certain readability when used. At the same time, the algorithm ensures the uniformity of many account addresses in the entire network, so that the selection of working nodes is random and fair.
[0060] According to some exemplary embodiments of the present disclosure, the node to be entered and the initial account address of the node to be entered are determined; wherein the node to be entered is a node with resource service capabilities; the account address of the node to be entered is determined according to the initial account address to form a new working node and join the consistent hash working ring composed of working nodes. The node to be entered can be a service node with resource service capabilities in cloud computing. When these service nodes are willing to provide services to users, they can be added to the blockchain network. The cloud computing service node before joining the blockchain network can be called the node to be entered. The initial account address can be the account address generated when the node to be entered enters the blockchain network. The initial account address is used for positioning in the network and is used in the system content. It is the core element for node selection. The account address can be the address used by the node in the blockchain network for user input, transfer and other operations. The working node can be a node in the blockchain network that has a certain computing power and can provide services to users in the network. At the same time, the network environment where the working node is located meets the requirements of high availability, high network bandwidth and low latency.
[0061] Before a cloud computing service node becomes a working node in the blockchain network, it can announce the available resources to the entire blockchain network and pay the corresponding property as collateral, so that if the service node generates malicious behavior, it will be punished; and when the service node exits the network, the remaining collateral will be returned. Figure 4 , Figure 4 The schematic diagram shows the implementation flow chart of the cloud service node joining the blockchain network. In steps S410 to S420, when the blockchain is connected to the blockchain network, the initial account address of the node to be entered can be determined; in steps S430 to S440, a certain point on the consistent hash ring can be located according to the initial account address of the node to be entered, and the initial account address, IP address and available resources are broadcast to all nodes in the blockchain network. In addition, after the node to be entered is connected to the blockchain, the corresponding account address can be determined according to the initial account address, and the node to be entered that generates the account address can be added to the consistent hash working ring as a new working node to receive new user requests.
[0062] According to another exemplary embodiment of the present disclosure, the node public key of the node to be entered is determined, and a hash function operation is performed on the node public key to obtain an initial account address; a version number and a check code are added to the initial account address to generate an intermediate account address; and an encoding operation is performed on the intermediate account address to obtain an account address. The node public key may be a public key corresponding to the node to be entered, wherein the node public key is provided by the node itself. The hash function operation may be an operation process performed on the node public key. The version number may be a field added to the initial account address, and by adding the version number to the initial account address, forward and backward compatibility may be achieved. The check code may be an encoding result obtained after an operation is performed on the initial account address to which the version number is added. The hash function operation is performed on the initial account address to which the version number is added, and some fields in the operation result may be provided as a check code. The intermediate account address may be an account address generated after adding the version number and the check code to the initial account address. The encoding operation may be an encoding operation performed on the intermediate account address.
[0063] refer to Figure 5 , Figure 5 The flowchart of the algorithm for generating the initial account addresses and account addresses of various nodes in the blockchain network is schematically shown. In this exemplary embodiment, first, in steps S511 to S514, after obtaining the node public key of the node to be entered, the node public key can be subjected to a secure hash algorithm operation (such as SHA256 operation) and an information digest algorithm operation (such as RIPEMD160 operation) to obtain an initial account address 412 of 160 bits (i.e., 20 bytes); wherein SHA256 can be a cryptographic hash function with good anti-collision performance, and the length of the output result is 256 bits; RIPEMD160 can also be a cryptographic hash function, and the output length is 160 bits. Secondly, adding a version number 511 before the initial account address can achieve forward and backward compatibility. In steps S521 to S522, two SHA256 operations can be performed on the basis of the initial account address with the version number, and the first 4 bytes are taken from the operation result as the checksum 513 (i.e., the checksum code) and added to the end of the initial account address to form an intermediate account address. Again, in step S523 to step S524, the intermediate account address including the version number and the checksum is encoded (such as Base58 encoding) to generate the account address; wherein, the Base58 encoding is a verification function created by Bitcoin, which has the functions of easy readability, error checking, and preventing incorrect input.
[0064] It should be noted that both the initial account address and the account address can uniquely represent a certain node, and the two can be converted into each other. Figure 5Steps S531 to S533 in the above diagram may represent the process of converting the account address to generate the initial account address. The account address may be decoded by Base58, and then the checksum at the end and the version number at the head may be removed to obtain the initial account address.
[0065] Furthermore, since the SHA256+RIPEMD160 algorithm is not specially designed for consistent hashing, it may lead to uneven distribution of nodes on the ring, and the hit rate and uniformity cannot be guaranteed when selecting based on block hash, resulting in a decrease in the fairness of the system. To solve this problem, the Ketama algorithm can be used for optimization. The Ketama algorithm is an algorithm designed in the MemCache system to solve distributed problems. The Ketama algorithm adopts the idea of virtual nodes, breaks up the original hash value into multiple ones, and uses them as virtual node keys in turn, mapping them to the ring, with a higher node hit rate and more uniform node distribution.
[0066] refer to Figure 6 , Figure 6 It is a schematic diagram of the schematic consistent hash selection averaging structure. The detailed optimization method is: in step S610 to step S630, the obtained public key is calculated using the secure hash algorithm and the information digest algorithm, and then the calculation result is calculated using the Ketama algorithm in step S640. Specifically, the original MD5 algorithm in the Ketama algorithm can be converted to the SHA256 algorithm to increase the coding space, and each node entering the network and each time the block 610 is selected based on the block hash, it is pre-processed by the Ketama algorithm.
[0067] In step S120, the current candidate node is determined from the consistent hash ring according to the block hash value and the initial account address.
[0068] In some exemplary embodiments of the present disclosure, the current candidate node may be a node determined from a consistent hash ring based on a block hash value. By determining the block hash value of the latest block and the account address of the node in the blockchain, the current candidate node can be determined from the consistent hash ring. Node selection in the blockchain network is performed at regular intervals, and the execution interval is determined by the block generation speed. The following describes the process of selecting a working node or an accounting node based on a block hash, refer to Figure 2 and Figure 7 , Figure 7The implementation flow chart of selecting blockchain function nodes according to block hash is schematically shown. The specific process of selecting a working node or an accounting node may be: in steps S710 to S720, the block hash value of the current latest block, that is, the block hash value of block #47, may be first obtained, and the account addresses of all nodes on the consistent hash ring 210 may be obtained according to the account information broadcast when the node enters the network. In steps S730 to S740, the block hash value is used to locate a specific position on the consistent hash ring, such as position 211, and the search is performed in a clockwise direction. The first node found, such as node 212, is a candidate working node. It should be noted that the position located in the consistent hash ring according to the block hash value may contain nodes or may not contain nodes. If the position does not contain a node, continue to search for nodes in the consistent hash ring in a clockwise direction. In steps S750 to S760, it can be determined whether the node can provide the corresponding service based on the user's resource requirements and the actual situation of the resources that the node can provide; if the remaining resources of the node cannot provide the corresponding service, continue to search for the next node clockwise and repeat step S730. In steps S770 to S790, if it is determined that the remaining resources of the node can provide resource services, the selected working node can broadcast the information that the working node has been found to all nodes and users, without continuing to search for the working node; after the broadcast is issued, the user submits a complete resource requirement request to the selected working node, and the selected working node generates a transaction and joins it in the transaction pool 240. In addition, the selected working node locks the resources required by the user, and broadcasts the updated available resource situation to all nodes and users for subsequent services. Similarly, the process of selecting a consensus node is also completed through the above steps.
[0069] In step S130, it is determined whether the current candidate node meets a preset condition.
[0070] In some exemplary embodiments of the present disclosure, the preset condition may be a condition for determining whether the current candidate node can provide resources required to complete the current processing operation. After determining the current candidate node based on the consistent hash ring, it may be determined whether the current candidate node meets the preset condition, so as to determine whether to select the current candidate node based on the determination result.
[0071] In step S140, if yes, the current candidate node is used as the target node, and the target node broadcasts the node selection message in the blockchain network.
[0072] In some exemplary embodiments of the present disclosure, the target node may be a node determined from a consistent hash ring according to a block hash value and a preset condition. The node selection message may be a message corresponding to when a node in the blockchain is selected as a target node. If the current candidate node meets the conditions for providing service resources, the current candidate node is used as the target node, and the node selection message that the node is selected as the target node is broadcast in the blockchain network through the target node.
[0073] In step S150 , if not, a new candidate node is selected as the current candidate node.
[0074] In some exemplary embodiments of the present disclosure, the new candidate node may be a node determined from the consistent hash ring. If the candidate node determined in the consistent hash ring does not meet the preset conditions, continue to search for a new candidate node in the hash ring in a clockwise direction, use the first node found as the current candidate node, and continue to perform the corresponding judgment steps.
[0075] According to some exemplary embodiments of the present disclosure, blocks in a blockchain network are generated by consensus nodes at fixed intervals. The block contains a block hash field, and its generation algorithm is consistent with the generation algorithm of the working node account address. Therefore, the block hash can be used to determine which working node completes the work in the current time period. Among them, the current time period indicates that it starts from the generation of the latest block and ends when the next block is generated. When using blocks to select working nodes, first locate the corresponding position of the consistent hash ring according to the hash of the latest block; then search for working nodes in a clockwise direction, and the first working node found will take over all work tasks in the current time period. When a new block is generated, repeat the above process.
[0076] According to another exemplary embodiment of the present disclosure, a pending request sent by a user terminal is received, and the request type of the pending request is determined; the remuneration information of the pending request is determined according to the request type, and the target node generates a pending transaction according to the remuneration information. The pending request may be a request submitted by a user to a blockchain node through a user terminal, and the pending request may include a resource computing request, a resource storage request, etc. The request type may be a type corresponding to the pending request. The remuneration information may be relevant information of the remuneration paid by the user according to the pending request. The target node may be a selected node determined from the blockchain network, and the target node is used to receive the pending request sent by the user terminal. The pending transaction may be a transaction corresponding to the pending request generated by a working node in the blockchain network after receiving the pending request sent by the user and the remuneration paid.
[0077] After receiving a pending request from a user and receiving the payment from the user, the target node can generate a transaction and put the transaction into the transaction pool to wait for the consensus node to process it. The pending transaction has a corresponding transaction data format, see Figure 8 , Figure 8 The data structure diagram of the transaction in the blockchain is schematically shown. Each transaction may include two parts: a transaction header 810 and a transaction body 820. Specifically, the transaction header 810 may include, but is not limited to, a version number, a transaction type, a timestamp, a transaction identifier (ID), an input account signature, and an output account signature. Among them, the version number can be used to achieve forward and backward compatibility; the transaction type can be used to distinguish types such as resource application, resource update, and resource return; the timestamp can be the time when the target node creates this transaction; the input account signature is the digital signature of the user, and the output account signature is the digital signature of the target node. The transaction body 820 may include, but is not limited to, the input account address, the output account address, the output amount, the resource type, and the resource detailed information. Specifically, the input account may be the user; the output account is the target node; the output amount may be the remuneration paid by the user to the working node, and the output amount may be determined by factors such as the resource type, the number of resources, and the application duration; the resource type is used to distinguish the types of resources required for the application, for example, it may include computing resources, storage resources, etc.; the resource detailed information may include the detailed name of the resource applied by the user, the number of resources, and the application duration.
[0078] After the target node receives the pending request sent by the user and the remuneration paid by the user, it can generate a pending transaction corresponding to the pending request according to the request type of the pending request, and can put the generated pending transaction into the transaction pool so that the consensus node can perform consensus processing on the pending transaction.
[0079] In another example embodiment, a blockchain consensus method is also provided, and a consensus node in a blockchain may be used to implement the blockchain consensus method of the present disclosure, and the consensus node may be a node selected from a working node. Fig. 9 The following is a schematic diagram of the blockchain consensus method process according to some embodiments of the present disclosure. Fig. 9 , the blockchain consensus method may include the following steps:
[0080] Step S910, receiving the pending transaction sent by the working node, and determining whether the pending transaction meets the preset legal determination conditions.
[0081] Step S920: If yes, add a legal identifier to the transaction to be processed to generate an initial legal transaction, and store the initial legal transaction in the target block.
[0082] In step S930, other consensus nodes in the blockchain network verify the legitimacy of the target block and determine the verification result.
[0083] Step S940: If the verification result is a legal result, the target block is linked to the blockchain.
[0084] According to the blockchain consensus method in this example embodiment, on the one hand, the pending request is generated into a pending transaction through the working node, and the legality of the pending transaction is preliminarily judged. If the pending transaction meets the preset legal judgment conditions, the pending transaction is stored in the block, and other consensus nodes conduct legality verification on the received pending transaction through the accounting node. Distinguishing the specific functional responsibilities of the working node and the consensus node can avoid the useless consumption caused by a large amount of useless calculations in the blockchain network due to consensus. On the other hand, every service provided by the working node to the user can be recorded in the blockchain in the form of a transaction, so that the transaction record can be traced and cannot be tampered with, which improves the trustworthiness of the service.
[0085] Next, the blockchain consensus method in this example embodiment will be further described.
[0086] In step S910, a pending transaction sent by a working node is received, and it is determined whether the pending transaction meets a preset legal determination condition.
[0087] In some exemplary embodiments of the present disclosure, the preset legal judgment condition may be a judgment condition used to judge whether the pending transaction is legal. The working node or accounting node that receives the pending transaction can be determined by the above-mentioned node selection method. In the blockchain network, a few points can be selected from the consensus nodes as accounting nodes. The specific job responsibilities of the accounting nodes may be: sorting and packaging the transactions in the current transaction pool, and verifying the legality of these transactions. The legality verification may include, for example, the input amount is greater than the output amount, the correctness of the data structure, the correctness of the digital signature, double spending detection, the correctness of the unlocking script, etc. Only verified transactions can be packaged into the block.
[0088] In step S920, if yes, a legal identifier is added to the transaction to be processed to generate an initial legal transaction, and the initial legal transaction is stored in the target block.
[0089] In some exemplary embodiments of the present disclosure, the legal identification may be an identification added to a pending transaction that meets the preset legal judgment condition after the initial legal judgment condition is determined. The initial legal transaction may be a transaction generated after adding a legal identification to a pending transaction that meets the preset legal judgment condition. If it is determined that the pending transaction meets the initial legal judgment condition, a legal identification is added to the pending transaction, and an initial legal transaction is generated, so as to perform consensus processing on the generated initial legal transaction.
[0090] In step S930, other consensus nodes in the blockchain network verify the legitimacy of the target block and determine the verification result.
[0091] In some exemplary embodiments of the present disclosure, other consensus nodes in the blockchain network may be all other consensus nodes in the blockchain network except the selected accounting node. The verification result may be the result obtained after other consensus nodes verify the legitimacy of the block content in the target block. The consensus operation of other consensus nodes on the target block is similar to the Delegated Proof of Stake (DPoS), that is, the accounting node broadcasts and authenticates the newly generated block to all consensus nodes, and the authentication content may include the legitimacy of the block data, whether the accounting node is a legal node, the legitimacy of the transaction data, etc. Other consensus nodes perform authentication processing on the authentication content in the target block and determine the verification result of the target block.
[0092] In step S940, if the verification result is a legal result, the target block is linked to the blockchain.
[0093] In some exemplary embodiments of the present disclosure, the legal result may be the verification result of the target block by other consensus nodes. The latest block may be a block containing the data content of the pending transaction corresponding to the pending request. If more than half of the other consensus nodes in the blockchain network believe that the target block can pass the authentication, the block is judged to be legal and valid, and can be appended to the end of the current longest chain as the latest block, and broadcast to all working nodes and users to start the next accounting cycle.
[0094] According to some exemplary embodiments of the present disclosure, if not, an illegal identification is added to the pending transaction to generate an illegal transaction and an illegal transaction message; the illegal transaction message is broadcast in the blockchain network. The illegal identification can be a corresponding identification added to the pending transaction when the pending transaction is determined to be an illegal transaction. The illegal transaction message can be a transaction message corresponding to the illegal transaction generated after the illegal identification is added to the pending transaction. When the accounting node determines that the pending transaction is an illegal transaction, an illegal identification can be added to the pending transaction to generate a corresponding illegal transaction message, and the generated illegal transaction message can be broadcast in the blockchain network.
[0095] According to another exemplary embodiment of the present disclosure, the amount of resources and service time corresponding to the working node are determined, and the initial contribution of the working node is determined according to the amount of resources and service time; the initial contribution is sorted to obtain a sorting result, and a preset number of working nodes is determined based on the sorting result; and the determined working node is adjusted to a new consensus node in the blockchain network according to a preset period. The amount of resources may be the total amount of resources provided by the working nodes in the blockchain network to the blockchain network. The service time may be the time corresponding to the service provided by the working node to the user. The initial contribution, also known as the resource age, may be a value determined according to the amount of resources and service time of the working node. The sorting result may be a sequence result determined by sorting the initial contribution of the working nodes in the blockchain network in a high to low or low to high order. The preset number may be a preset value, and n may be used to represent the preset number. After obtaining the sorting result of the initial contribution of the working node, a preset number of working nodes may be selected from the sorting result. The preset period, i.e., the consensus period, may be a preset time period, and the consensus nodes in the blockchain network may be adjusted according to the preset period.
[0096] In this example embodiment, the resource age of the working node can be determined, and a preset number of working nodes with the highest resource age can be automatically determined, and the consensus operation can be completed by them within a preset period. In this example embodiment, the resource age can be represented by A, and the definition of resource age A can be the sum of the product of the resource amount d provided by the working node and the service time t as of the current time, that is, After calculating the resource age of each working node, the resource age of each node can be stored in the blockchain network in the form of a key-value pair and synchronized by each node; the format of the key-value pair can be (node ID, resource age). When selecting a consensus node, the resource age of all working nodes in the blockchain network can be updated first, and then the n nodes with the highest resource age can be selected from all working nodes as consensus nodes. The consensus task is executed within a consensus cycle, and resource service work is no longer provided, and the working cycle is exited.
[0097] In order to prevent malicious nodes from serving as consensus nodes for a long time and undermining system security, and to meet the requirements of system decentralization and trustworthiness, consensus nodes can be rotated after a consensus cycle T, and other nodes continue to perform consensus tasks. The replaced consensus nodes can re-enter the working ring to continue to provide resource services. The number of consensus nodes n and the consensus cycle T can be system preset values. For example, n can be set to 101, T can be set to 24 hours, etc. For example, when n is set to 101, the working nodes whose resource age ranks in the top 101 in the entire network can be selected as the selected consensus nodes.
[0098] According to another exemplary embodiment of the present disclosure, the accounting deduction coefficient and the penalty deduction coefficient of the consensus node are determined; the initial contribution is adjusted to the current contribution according to the accounting deduction coefficient and the penalty deduction coefficient; the current contribution is sorted to replace the consensus node in the blockchain network according to the sorting result. The accounting deduction coefficient can be a deduction coefficient for the resource age corresponding to the accounting operation of the consensus node during the consensus cycle. The penalty deduction coefficient can be a deduction coefficient for the resource age in order to avoid cheating by some malicious nodes in the consensus node. The current contribution can be the contribution of the consensus node obtained by deducting the initial contribution according to the accounting deduction coefficient and the penalty deduction coefficient.
[0099] In order to ensure the fairness of the system and avoid the excessive concentration of the right of consensus operation in the blockchain network on nodes that joined the network early and have a higher resource age, other nodes can also become consensus nodes. Therefore, the resource age of the consensus node after completing the consensus task can be processed, for example, the resource age of the consensus node can be appropriately deducted. The specific solution is to set i as the node number of the consensus node and j as the accounting number; before a consensus cycle occurs, the resource age of each consensus node is A i ; After the consensus cycle is completed, each consensus node is selected s times i , the number of blocks produced by each consensus node is b i Under normal circumstances, after a consensus node is selected once, it should complete a block, that is, s i =b i However, since the operation of packaging blocks requires additional computing costs compared to general consensus operations, malicious nodes may refuse to package, that is, s i <b i Therefore, the deduction of resource age can be divided into two parts: bookkeeping deduction and penalty deduction. Specifically, the bookkeeping deduction coefficient can be set to d and the penalty deduction coefficient to p. Then, after a round of consensus cycle, the resource age of node i becomes For example, the accounting deduction coefficient can be set to 1 (1 unit of resource age is deducted for each block produced), and the penalty deduction coefficient can be set to s i-b i (The more times you cheat, the greater the penalty), then the final resource age change formula is A i '=A i -b i -(s i -b i ) 2 .
[0100] In summary, the node selection method disclosed in the present invention determines the current candidate node from the consistent hash ring according to the block hash value in the latest block and the account address of the node in the consistent hash ring in the blockchain network, and selects a node as the target node according to the current candidate node to process the pending request sent by the user end. Through this node selection method, on the one hand, the cloud computing service node can be integrated with the blockchain network node. While the cloud computing node provides resource services to the outside, it uses the decentralized characteristics of the blockchain to achieve distributed autonomy. On the other hand, by utilizing the randomness of block generation in the blockchain and the dynamic nature of consistent hashing, the node that actually provides the service in each node set can be selected and a consensus can be provided to meet the characteristics of randomization, fairness, and speed. On the other hand, the working node can record each service provided to the user in the form of a transaction in the blockchain, so that the transaction record can be traced and cannot be tampered with, and the trustworthiness of the service is improved; further, the blockchain consensus method disclosed in the present invention determines the legitimacy of the pending transaction through the accounting node. If the pending transaction is considered to be legal, a legal identification is added to the pending transaction and stored in the latest block in the blockchain network, and the legitimacy of the block is judged by other consensus nodes in the blockchain. If the block content of the target block is judged to be legal, the target block is linked to the end of the blockchain as the latest block. In each preset cycle, the resource age of the consensus node is calculated and sorted, and the consensus node can be replaced in combination with the sorting result, and the node with higher contribution is selected from the working node as the new consensus node. The method of selecting the consensus node in the network according to the sorting result of the resource age is fast and efficient, and the rotation after a certain period of time can avoid being attacked by malicious nodes, thereby improving the security of the network.
[0101] It should be noted that, although the steps of the method of the present invention are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0102] In addition, in this exemplary embodiment, a node selection device is also provided. Fig.10The node selection device 1000 may include: an address acquisition module 1010, a node determination module 1020, a judgment module 1030, a node selection module 1040 and a candidate node selection module 1050.
[0103] Specifically, the address acquisition module 1010 can be used to obtain the block hash value of the current latest block in the blockchain, and obtain the initial account address of each node in the consistent hash ring; the node determination module 1020 can be used to determine the current candidate node from the consistent hash ring according to the block hash value and the initial account address; the judgment module 1030 can be used to determine whether the current candidate node meets the preset conditions; the node selection module 1040 can be used to, if so, take the current candidate node as the target node, and the target node broadcasts the node selection message in the blockchain network; the candidate node selection module 1050 can be used to, if not, select a new candidate node as the current candidate node.
[0104] The node selection device 1000 can determine the current candidate node from the consistent hash ring according to the block hash value of the acquired block and the account addresses of all nodes in the consistent hash ring, and judge whether the current candidate node meets the preset conditions. If the current candidate node meets the preset conditions, the current candidate node is used as the target node, otherwise, a new candidate node is selected to determine whether it can be used as the target node. The account address of the node in the consistent hash ring cannot be changed, so the position of the node in the consistent hash ring cannot be changed, which reduces the risk of cheating in the network. In addition, by utilizing the randomness of block generation in the blockchain, the target node can be selected from the blockchain network quickly, fairly and randomly, avoiding useless consumption caused by a large amount of useless calculations due to consensus, which is an effective node selection method.
[0105] In an exemplary embodiment of the present disclosure, based on the aforementioned scheme, the node determination module includes a node adding unit, and the node adding unit is configured to: determine the node to be entered and the initial account address of the node to be entered; wherein the node to be entered is a node with resource service capabilities; determine the account address of the node to be entered based on the initial account address to form a new working node and join it to the consistent hash working ring composed of the working nodes.
[0106] In an exemplary embodiment of the present disclosure, based on the aforementioned scheme, the node adding unit includes an address determination subunit, and the address determination subunit is configured to: determine the node public key of the node to be entered, and perform a hash function operation on the node public key to obtain an initial account address; add a version number and a checksum code to the initial account address to generate an intermediate account address; perform an encoding operation on the intermediate account address to obtain an account address.
[0107] In an exemplary embodiment of the present disclosure, based on the aforementioned scheme, the node selection device also includes a transaction generation module, which is configured to: receive a pending request sent by a user terminal, and determine the request type of the pending request; determine the reward information of the pending request according to the request type, and the target node generates a pending transaction according to the reward information.
[0108] In another exemplary embodiment, a blockchain consensus device is also provided. Fig.11 The blockchain consensus device 1100 may include: a transaction judgment module 1110, a block generation module 1120, a verification module 1130 and a storage module 1140.
[0109] Specifically, the transaction judgment module 1110 can be used to receive pending transactions sent by the working node, and judge whether the pending transactions meet the preset legal judgment conditions; the block generation module 1120 can be used to add a legal identification to the pending transaction to generate an initial legal transaction, and store the initial legal transaction in the target block; the verification module 1130 can be used to verify the legality of the target block by other consensus nodes in the blockchain network, and determine the verification result; the transaction storage module 1140 can be used to link the target block to the blockchain if the verification result is a legal result.
[0110] After receiving the pending transaction, the blockchain consensus device 1100 can judge the legality of the pending transaction through the accounting node. If it is determined that the pending transaction meets the preset legal judgment conditions, it is determined to be a legal transaction and stored in the block. Other consensus nodes in the blockchain network can judge the legality of the block. If it is judged to be legal, the target block is linked to the end of the blockchain as the latest block.
[0111] In an exemplary embodiment of the present disclosure, based on the aforementioned scheme, the blockchain consensus device also includes a message broadcast module, and the message broadcast module is configured to: if not, add an illegal identifier to the transaction to be processed to generate an illegal transaction and an illegal transaction message; broadcast the illegal transaction message in the blockchain network.
[0112] In an exemplary embodiment of the present disclosure, based on the aforementioned scheme, the blockchain consensus device also includes a node replacement module, and the node replacement module is configured to: determine the amount of resources and service time corresponding to the working node, and determine the initial contribution of the working node based on the amount of resources and service time; sort the initial contribution to obtain a sorting result, and determine a preset number of working nodes based on the sorting result; adjust the determined working nodes to new consensus nodes in the blockchain network according to a preset period.
[0113] In an exemplary embodiment of the present disclosure, based on the aforementioned scheme, the node replacement module includes a node replacement unit, and the node replacement unit is configured to: determine the accounting deduction coefficient and the penalty deduction coefficient of the consensus node; adjust the initial contribution to the current contribution according to the accounting deduction coefficient and the penalty deduction coefficient; sort the current contribution to replace the consensus node in the blockchain network according to the sorting result.
[0114] The specific details of each virtual node selection device or virtual blockchain consensus device module mentioned above have been described in detail in the corresponding node selection method, so they will not be repeated here.
[0115] It should be noted that although several modules or units of the node selection device or blockchain consensus device are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be concretized in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units for concretization.
[0116] In addition, in an exemplary embodiment of the present disclosure, a blockchain consensus system capable of implementing the above method is also provided. Fig.12 , the blockchain consensus system 1200 may include: a working node 1210, a consensus node 1220 and a block 1230.
[0117] Specifically, the working node 1210 can be used to receive pending requests sent by the user end, and generate corresponding pending transactions for the pending requests; the consensus node 1220 can be used to judge the legality of the pending transactions, determine the pending transactions that meet the legality as legal transactions and store them in the block; the block 1230 can be used to store the transaction information of the legal transactions.
[0118] The blockchain consensus system 1200 may include a consistent hash working ring and a consistent hash consensus ring composed of working nodes and consensus nodes respectively. The working nodes generate pending transactions, and the consensus nodes judge the legitimacy of pending transactions and block contents, thereby combining the service nodes in cloud computing with the nodes in the blockchain network to build a trusted distributed resource service network. By utilizing the randomness of block generation in the blockchain and the dynamic nature of consistent hashing, the nodes that actually provide services in each node set are selected to meet the purposes of randomization, fairness, and speed. Each service provided by the node to the user is recorded in the blockchain in the form of a transaction, which can be traced and cannot be tampered with, thereby improving the trustworthiness of the service. In addition, the consensus nodes in the network are selected according to the resource age of the nodes, which is fast and efficient, and are rotated after a certain period of time to avoid being attacked by malicious nodes, thereby improving the security of the network.
[0119] In addition, in an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0120] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as systems, methods or program products. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: complete hardware embodiments, complete software embodiments (including firmware, microcode, etc.), or embodiments combining hardware and software aspects, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0121] Refer to the following Fig.13 13 to 14. An electronic device 1300 according to such an embodiment of the present invention is described. Fig.13 The electronic device 1300 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0122] like Fig.13 As shown, the electronic device 1300 is in the form of a general computing device. The components of the electronic device 1300 may include, but are not limited to: at least one processing unit 1310, at least one storage unit 1320, a bus 1330 connecting different system components (including the storage unit 1320 and the processing unit 1310), and a display unit 1340.
[0123] The storage unit stores program codes, which can be executed by the processing unit 1310, so that the processing unit 1310 executes the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification.
[0124] The storage unit 1320 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 1321 and / or a cache memory unit 1322 , and may further include a read-only memory unit (ROM) 1323 .
[0125] The storage unit 1320 may also include a program / utility 1324 having a set (at least one) of program modules 1325, such program modules 1325 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0126] Bus 1330 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0127] The electronic device 1300 may also communicate with one or more external devices 1370 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1300, and / or communicate with any device that enables the electronic device 1300 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 1350. Furthermore, the electronic device 1300 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 1360. As shown, the network adapter 1360 communicates with other modules of the electronic device 1300 via a bus 1330. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1300, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0128] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the embodiment of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiment of the present disclosure.
[0129] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible embodiments, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to perform the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.
[0130] refer to Fig.14 As shown, a program product 1400 for implementing the above method according to an embodiment of the present invention is described, which can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0131] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0132] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0133] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0134] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0135] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0136] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
[0137] It should be understood that the present disclosure is not limited to the exact structures 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 present disclosure is limited only by the appended claims.
Claims
1. A node selection method, It is characterized in that Nodes used in blockchain networks include: Determine a node to be entered and an initial account address of the node to be entered; wherein the node to be entered is a node with resource service capability; Determine the account address of the node to be entered according to the initial account address to form a new working node and add it to the consistent hash working ring composed of the working nodes; Get the block hash value of the latest block in the blockchain, and get the initial account address of each node in the consistent hash ring; Determine a current candidate node from the consistent hash ring according to the block hash value and the account address; Determine whether the current candidate node meets a preset condition, wherein the preset condition is a condition for determining whether the current candidate node can provide resources required to complete the current processing operation; If yes, the current candidate node is used as the target node, and the target node broadcasts a node selection message in the blockchain network; If not, a new candidate node is selected as the current candidate node; The determining the account address of the node to be entered according to the initial account address includes: Determine the node public key of the node to be entered, and perform a hash function operation on the node public key to obtain the initial account address; Adding a version number and a verification code to the initial account address to generate an intermediate account address; An encoding operation is performed on the intermediate account address to obtain the account address.
2. The node selection method according to claim 1, It is characterized in that The method further comprises: Receiving a pending request sent by a user terminal, and determining a request type of the pending request; The reward information of the pending request is determined according to the request type, and the target node generates a pending transaction according to the reward information.
3. A blockchain consensus method, It is characterized in that Consensus nodes used in blockchain networks include: Receiving a pending transaction sent by the working node according to claim 1, and determining whether the pending transaction meets a preset legal determination condition; If yes, then add a legal identification to the pending transaction to generate an initial legal transaction, and store the initial legal transaction in the target block; The other consensus nodes in the blockchain network verify the legitimacy of the target block and determine the verification result; If the verification result is a legal result, the target block is linked to the blockchain.
4. The blockchain consensus method according to claim 3, It is characterized in that The method further comprises: If not, an illegal mark is added to the initial legal transaction to generate an illegal transaction and an illegal transaction message; The illegal transaction message is broadcasted in the blockchain network.
5. The blockchain consensus method according to claim 3, It is characterized in that The method further comprises: Determine the resource amount and service time corresponding to the working node, and determine the initial contribution of the working node according to the resource amount and the service time; Sorting the initial contribution degrees to obtain a sorting result, and determining a preset number of working nodes based on the sorting result; The determined working nodes are adjusted to new consensus nodes in the blockchain network according to a preset period.
6. The blockchain consensus method according to claim 5, It is characterized in that The method further comprises: Determine the accounting deduction coefficient and penalty deduction coefficient of the consensus node; Adjusting the initial contribution to the current contribution according to the accounting deduction coefficient and the penalty deduction coefficient; The current contribution is sorted to replace the consensus node in the blockchain network according to the sorting result.
7. A node selection device, It is characterized in that include: The address acquisition module is used to obtain the block hash value of the latest block in the blockchain and obtain the initial account address of each node in the consistent hash ring; A node determination module, configured to determine a current candidate node from the consistent hash ring according to the block hash value and the account address; A judgment module, used to judge whether the current candidate node meets a preset condition, wherein the preset condition is a condition for judging whether the current candidate node can provide resources required to complete the current processing operation; A node selection module, configured to, if yes, use the current candidate node as a target node, and have the target node broadcast a node selection message in the blockchain network; A candidate node selection module, for selecting a new candidate node as the current candidate node if no; The node determination module is further used to determine the node to be entered and the initial account address of the node to be entered; wherein the node to be entered is a node with resource service capability; Determine the account address of the node to be entered according to the initial account address to form a new working node and add it to the consistent hash working ring composed of the working nodes; The determining the account address of the node to be entered according to the initial account address includes: determining the node public key of the node to be entered, and performing a hash function operation on the node public key to obtain the initial account address; adding a version number and a checksum code to the initial account address to generate an intermediate account address; and performing an encoding operation on the intermediate account address to obtain the account address.
8. A blockchain consensus device, It is characterized in that include: A transaction judgment module, configured to receive a pending transaction sent by the working node according to claim 1, and judge whether the pending transaction satisfies a preset legal judgment condition; A block generation module, configured to, if yes, add a legal identification to the pending transaction to generate an initial legal transaction, and store the initial legal transaction in a target block; A verification module, used for other consensus nodes in the blockchain network to verify the legitimacy of the target block and determine the verification result; The transaction storage module is used to link the target block to the blockchain if the verification result is a legal result.
9. A blockchain consensus system, It is characterized in that include: A working node, used for receiving a pending request sent by a user terminal, and generating a corresponding pending transaction from the pending request, wherein the working node is generated based on the node selection method described in any one of claims 1 to 2; The consensus node is used to judge the legitimacy of the pending transaction, determine the pending transaction that meets the legitimacy as a legal transaction and store it in the block; Block, used to store transaction information of the legal transaction.
10. An electronic device, It is characterized in that include: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the one or more processors to implement the node selection method as described in any one of claims 1 to 2, or implement the blockchain consensus method as described in any one of claims 3 to 6.
11. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, it implements the node selection method as described in any one of claims 1 to 2, or implements the blockchain consensus method as described in any one of claims 3 to 6.
Citation Information
Patent Citations
Block chain consensus method and system
CN108122165A
Block chain consensus method and system
CN108737375A