Consensus process control method and device of block chain node, medium and equipment

After the blockchain node is restarted, the consensus process of the nodes is controlled according to the consensus height of each node and the set threshold, the problem of proposals being outdated and invalid due to node backwardness is solved, and the consensus efficiency and accuracy of the blockchain are improved.

CN119892333APending Publication Date: 2025-04-25TENCENT CLOUD COMPUTING (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311381451.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-24
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

When a blockchain node restarts after a network or node goes down, it may cause the consensus status to fall behind, thereby generating outdated and invalid proposals, wasting system resources and affecting consensus efficiency.

Method used

After the node restarts, obtain the current consensus height of each node, calculate the number of nodes that meet the specific height conditions, and compare these numbers with the set threshold to decide whether to start or stop the node's consensus process to ensure that the consensus height of the node does not fall behind.

Benefits of technology

It effectively avoids the problem of outdated and invalid proposals generated due to backward nodes, improves the consensus efficiency and processing accuracy of blockchain, avoids waste of resources and affects the consensus and synchronization efficiency between nodes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119892333A_ABST
    Figure CN119892333A_ABST
Patent Text Reader

Abstract

The invention discloses a block chain node consensus process control method and device, a medium and equipment, and relates to the field of block chains, and the method comprises the steps: obtaining a first current consensus height corresponding to a first node and a second current consensus height corresponding to each second node in a block synchronization process after the first node is restarted; according to the first current consensus height and the second current consensus height, a first number is determined, and the first number is the number of second nodes meeting the first height condition; according to the first current consensus height and the second current consensus height, a second number is determined, and the second number is the number of second nodes meeting a second height condition; and when the first number is less than or equal to a first number threshold and the second number is greater than a second number threshold, starting a consensus process of the first node. According to the method and the device, the consensus process of the block chain node is subjected to start-stop control, so that the consensus effectiveness and the consensus processing efficiency of the block chain are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain, and specifically to consensus process control methods, devices, media and equipment for blockchain nodes. Background Art

[0002] Blockchain is a distributed decentralized network that provides immutability, privacy, security, and transparency. Although there is no central node to verify and validate transactions, every transaction in the blockchain is considered to be completely secure and verified, which relies on the consensus mechanism of the blockchain. That is, through a consensus process based on a consensus algorithm, all nodes of the blockchain network reach a common agreement on the current state of the blockchain, achieving the reliability of the blockchain network and establishing trust between unknown peers in a distributed computing environment.

[0003] If the consensus process of the failed node is stopped due to network or node downtime or restart, the consensus status of the node will lag behind other normal nodes. In the case of lag, if the consensus process of the node is directly restarted, if the node is selected as the master node to generate proposals, the generated proposals will be outdated and invalid because the current consensus height of the node is lagging behind the entire blockchain network, wasting system resources and affecting the consensus and synchronization efficiency between nodes. Summary of the invention

[0004] In order to avoid the waste of system resources and improve the consensus efficiency of blockchain, this application provides a consensus process control method, device, medium and equipment for blockchain nodes. The technical solution is as follows:

[0005] In a first aspect, the present application provides a consensus process control method for a blockchain node, the method comprising:

[0006] After restarting the first node, obtaining a first current consensus height corresponding to the first node and a second current consensus height corresponding to each of the at least one second node during the block synchronization process; the first node is any node among multiple nodes of the blockchain, and the at least one second node is a node among the multiple nodes other than the first node;

[0007] Determine a first number according to the first current consensus height and the second current consensus height, where the first number is the number of second nodes that meet a first height condition, where the first height condition is that the difference between the second current consensus height and the first current consensus height is greater than a height difference threshold;

[0008] Determine a second number according to the first current consensus height and the second current consensus height, where the second number is the number of second nodes that meet a second height condition, where the second height condition is that the difference between the second current consensus height and the first current consensus height is less than or equal to the height difference threshold;

[0009] When the first number is less than or equal to a first number threshold and the second number is greater than a second number threshold, the consensus process of the first node is started; wherein the first number threshold is a number critical value for indicating whether the first current consensus height lags behind the current height of the blockchain, and the second number threshold is a number critical value for indicating whether the first current consensus height is close to the current height of the blockchain.

[0010] Optionally, the method further includes:

[0011] When the first number is greater than the first number threshold, the consensus process of the first node is stopped.

[0012] Optionally, the method further includes:

[0013] When the first number is less than or equal to the first number threshold and the second number is less than or equal to the second number threshold, stop the consensus process of the first node.

[0014] Optionally, the method further includes:

[0015] determining a total number of the plurality of nodes;

[0016] Based on the Byzantine consensus algorithm and the total number, the first number threshold and the second number threshold are determined.

[0017] In a second aspect, the present application provides a consensus process control method for a blockchain node, the method comprising:

[0018] When a first node is in a consensus process, a third current consensus height corresponding to the first node and a fourth current consensus height corresponding to each of at least one second node are obtained; the first node is any node among multiple nodes of the blockchain, and the at least one second node is a node among the multiple nodes other than the first node;

[0019] Determine a third number according to the third current consensus height and the fourth current consensus height, where the third number is the number of second nodes that meet the first height condition, where the first height condition is that the difference between the fourth current consensus height and the third current consensus height is greater than a height difference threshold;

[0020] When the third number is greater than a first number threshold, the consensus process is terminated; the first number threshold is a critical value for indicating whether the third current consensus height lags behind the current height of the blockchain.

[0021] Optionally, the method further includes:

[0022] When the third number is less than or equal to the first number threshold, continue to execute the consensus process.

[0023] Optionally, the method further includes:

[0024] After terminating the consensus process, a block synchronization process is performed to update the third current consensus height corresponding to the first node and control the consensus process of the first node according to the updated third current consensus height.

[0025] In a third aspect, the present application provides a consensus process control device for a blockchain node, the device comprising:

[0026] A first acquisition module is used to acquire, after restarting the first node, a first current consensus height corresponding to the first node and a second current consensus height corresponding to each of the at least one second node during the block synchronization process; the first node is any node among multiple nodes of the blockchain, and the at least one second node is a node among the multiple nodes other than the first node;

[0027] A first quantity statistics module, configured to determine a first quantity according to the first current consensus height and the second current consensus height, wherein the first quantity is the quantity of second nodes that meet a first height condition, wherein the first height condition is that a difference between the second current consensus height and the first current consensus height is greater than a height difference threshold;

[0028] A second quantity statistics module, configured to determine a second quantity according to the first current consensus height and the second current consensus height, where the second quantity is the quantity of second nodes that meet a second height condition, where the second height condition is that the difference between the second current consensus height and the first current consensus height is less than or equal to the height difference threshold;

[0029] A first control module is configured to start a consensus process of the first node when the first number is less than or equal to a first number threshold and the second number is greater than a second number threshold; wherein the first number threshold is a number critical value for indicating whether the first current consensus height lags behind the current height of the blockchain, and the second number threshold is a number critical value for indicating whether the first current consensus height is approaching the current height of the blockchain.

[0030] In a fourth aspect, the present application provides a consensus process control device for a blockchain node, the device comprising:

[0031] A second acquisition module is used to acquire, when the first node is in the consensus process, a third current consensus height corresponding to the first node and a fourth current consensus height corresponding to each second node in at least one second node; the first node is any node among multiple nodes of the blockchain, and the at least one second node is a node among the multiple nodes other than the first node;

[0032] A third quantity statistics module, used for a module, used for determining a third quantity according to the third current consensus height and the fourth current consensus height, wherein the third quantity is the number of second nodes that meet the first height condition, and the first height condition is that the difference between the fourth current consensus height and the third current consensus height is greater than a height difference threshold;

[0033] The second control module is used to terminate the consensus process when the third number is greater than a first number threshold; the first number threshold is a critical value for indicating whether the third current consensus height lags behind the current height of the blockchain.

[0034] In a fifth aspect, the present application provides a computer-readable storage medium, wherein at least one instruction or at least one program is stored in the computer-readable storage medium, and the at least one instruction or at least one program is loaded and executed by a processor to implement a consensus process control method for a blockchain node as described in the first aspect or the second aspect.

[0035] In a sixth aspect, the present application provides a computer device, comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement a consensus process control method for a blockchain node as described in the first aspect or the second aspect.

[0036] In the seventh aspect, the present application provides a computer program product, which includes computer instructions, and when the computer instructions are executed by a processor, a consensus process control method for a blockchain node as described in the first aspect or the second aspect is implemented.

[0037] The consensus process control method, device, medium and equipment of blockchain nodes provided by this application have the following technical effects:

[0038] The solution provided by the present application can determine the first quantity and the second quantity according to the first current consensus height corresponding to the first node and the second current consensus height corresponding to each second node in at least one second node during the block synchronization process after restarting the first node, wherein the first quantity is the number of second nodes that meet the first height condition, and the first height condition is that the difference between the second current consensus height and the first current consensus height is greater than the height difference threshold, and the second quantity is the number of second nodes that meet the second height condition, and the second height condition is that the difference between the second current consensus height and the first current consensus height is less than or equal to the height difference threshold; and then, by comparing the size of the first quantity with the first quantity threshold, and the size of the second quantity with the second quantity threshold, it is determined that the first current consensus height is greater than the height difference threshold. Whether the previous consensus height lags behind the current height of the blockchain and whether the first current consensus height approaches the current height of the blockchain; in the scheme provided in the present application, the situation where the first number is less than or equal to the first number threshold and the second number is greater than the second number threshold corresponds to the situation where the first current consensus height is not behind the current height of the blockchain, and the first current consensus height approaches the current height of the blockchain. At this time, starting the consensus process of the first node can improve the consensus efficiency of the blockchain and the accuracy and effectiveness of the consensus processing, and can also avoid the consensus proposal generated by the first node being selected as the main node when it is lagging behind being timed out and invalid, that is, avoiding wasting system resources and affecting the consensus and synchronization efficiency between nodes.

[0039] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0041] Figure 1 It is a schematic diagram of an implementation environment of a consensus process control method for a blockchain node provided in an embodiment of the present application;

[0042] Figure 2 It is a flowchart of a consensus process control method of a blockchain node provided in an embodiment of the present application;

[0043] Figure 3 It is a flowchart of another consensus process control method of blockchain nodes provided in an embodiment of the present application;

[0044] Figure 4It is a flowchart of another consensus process control method of blockchain nodes provided in an embodiment of the present application;

[0045] Figure 5 It is a schematic diagram of a consensus process provided by an embodiment of the present application;

[0046] Figure 6 It is a flowchart of a consensus process control method of a blockchain node based on a Byzantine consensus algorithm provided in an embodiment of the present application;

[0047] Figure 7 It is a schematic diagram of node height difference provided in an embodiment of the present application;

[0048] Figure 8 It is a flowchart of another consensus process control method of a blockchain node based on a Byzantine consensus algorithm provided in an embodiment of the present application;

[0049] Fig. 9 It is a flowchart of a consensus process control method of blockchain nodes in a block synchronization process provided by an embodiment of the present application;

[0050] Fig.10 This is a schematic diagram of the height difference of each node in a block synchronization provided by an embodiment of the present application;

[0051] Fig.11 It is a flowchart of a consensus process control method of a blockchain node in a consensus process provided by an embodiment of the present application;

[0052] Fig.12 It is a schematic diagram of the height difference of each node in a consensus process provided by an embodiment of the present application;

[0053] Fig.13 It is a schematic diagram of a consensus process control device of a blockchain node provided in an embodiment of the present application;

[0054] Fig.14 It is a schematic diagram of another consensus process control device of a blockchain node provided in an embodiment of the present application;

[0055] Fig.15 It is a schematic diagram of the hardware structure of a device for implementing a consensus process control method for a blockchain node provided in an embodiment of the present application. DETAILED DESCRIPTION

[0056] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work belong to the scope of protection of this application. Examples of the embodiments are shown in the drawings, where the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions.

[0057] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0058] It is understandable that in the specific implementation of this application, related data such as user information is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

[0059] The consensus process control method of the blockchain node in the embodiment of the present application involves blockchain technology. Blockchain is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods, each of which contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.

[0060] The underlying blockchain platform can include processing modules such as user management, basic services, smart contracts, and operational detection. Among them, the user management module is responsible for the identity information management of all blockchain participants. Including maintaining public and private key generation (account management), key management, and maintaining the correspondence between the user's real identity and the blockchain address (authority management), etc., and under authorization, supervising and auditing the transactions of certain real identities, and providing risk control rule configuration (risk control audit): The basic service module is deployed on all blockchain node devices to verify the validity of business requests, and record the valid requests to the storage after consensus is reached. For a new business request, the basic service first adapts the interface to parse and authenticate (interface adaptation), and then encrypts the business information through the consensus algorithm (consensus management), and transmits the complete and consistent information after encryption. The smart contract module is responsible for the registration and issuance of contracts, as well as contract triggering and contract execution. Developers can define the contract logic in a programming language and publish it to the blockchain (contract registration). According to the logic of the contract terms, the key or other events are called to trigger the execution and complete the contract logic. It also provides the function of contract upgrade and cancellation. The operation detection module is mainly responsible for the deployment, configuration modification, contract setting, cloud adaptation and real-time status visualization output of the product during the product release process, such as alarm, network status detection, node equipment health status detection, etc.

[0061] The platform product service layer provides the basic capabilities and implementation framework of typical applications. Developers can superimpose business features based on these basic capabilities to complete the blockchain implementation of business logic. The application service layer provides application services based on blockchain solutions for business participants to use.

[0062] See also Figure 1 , which is a schematic diagram of the implementation environment of a consensus process control method for a blockchain node provided in an embodiment of the present application, such as Figure 1 As shown, the implementation environment is a distributed system 100 based on blockchain technology, which may include at least a first node 200, at least one second node 300 and a client 400. The first node 200, at least one second node 300 and the client 400 are connected in the form of network communication. Among them, the node is any form of computing device in the access network, such as a server, a user terminal, etc. The nodes are formed based on a point-to-point protocol. The point-to-point protocol is an application layer protocol running on the Transmission Control Protocol (TCP) protocol. In a distributed system, any machine such as a server or a terminal can join and become a node, and the node includes a hardware layer, an intermediate layer, an operating system layer and an application layer.

[0063] See also Figure 1 The functions of each node in the blockchain system shown include:

[0064] 1) Routing: a basic function of a node, used to support communication between nodes.

[0065] In addition to the routing function, the node can also have the following functions:

[0066] 2) Applications are deployed in the blockchain to implement specific businesses based on actual business needs, record data related to the implementation of functions to form record data, carry digital signatures in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system for other nodes to add the record data to a temporary block when they successfully verify the source and integrity of the record data.

[0067] For example, the services implemented by the application include:

[0068] 2.1) Wallet, used to provide the function of conducting electronic currency transactions, including initiating transactions (i.e., sending the transaction record of the current transaction to other nodes in the blockchain system. After the other nodes successfully verify the transaction, as a response to acknowledge the validity of the transaction, the transaction record data is stored in the temporary block of the blockchain; of course, the wallet also supports querying the remaining electronic currency in the electronic currency address;

[0069] 2.2) Shared ledger, which is used to provide functions such as storage, query and modification of account data. The record data of the operation on the account data is sent to other nodes in the blockchain system. After other nodes verify the validity, as a response to acknowledging the validity of the account data, the record data is stored in a temporary block, and a confirmation can also be sent to the node that initiated the operation.

[0070] 2.3) Smart contracts are computerized protocols that can execute the terms of a contract. They are implemented by deploying code on a shared ledger that is executed when certain conditions are met. The code is used to complete automated transactions based on actual business needs, such as querying the logistics status of the goods purchased by the buyer and transferring the buyer's electronic currency to the merchant's address after the buyer signs for the goods. Of course, smart contracts are not limited to executing contracts for transactions, but can also execute contracts for processing received information.

[0071] 3) Blockchain, including a series of blocks that are connected to each other in the order of their generation. Once a new block is added to the blockchain, it will not be removed. The block records the record data submitted by the nodes in the blockchain system.

[0072] When implementing a consensus process control method for a blockchain node provided in the present application, the first node 200 may be a node that is restarted after fault recovery, and a block synchronization process is performed between the first node 200 and at least one second node 300. According to the first current consensus height corresponding to the first node 200 and the second current consensus height corresponding to each second node 300 in the block synchronization process, a first quantity and a second quantity are determined, the first quantity being the number of second nodes that meet the first height condition, the first height condition being that the difference between the second current consensus height and the first current consensus height is greater than a height difference threshold, the second quantity being the number of second nodes that meet the second height condition, the second height condition being that the difference between the second current consensus height and the first current consensus height is less than or equal to the height difference threshold; when the first quantity is less than or equal to the first quantity threshold and the second quantity is greater than the second quantity threshold, the consensus process of the first node 200 is started, the first quantity threshold is a quantity critical value for indicating whether the first current consensus height lags behind the current height of the blockchain, and the second quantity threshold is a quantity critical value for indicating whether the first current consensus height is approaching the current height of the blockchain. At this time, it can be reliably guaranteed that the first node 200 is not lagging behind the entire blockchain system. After starting the consensus process of the first node 200, if the first node 200 is selected as the main node, the proposal generated by the first node 200 for the exchange submitted by the client 400 will not time out or be invalid, thereby avoiding wasting the resources of the distributed system 100, while improving the efficiency of the consensus processing and ensuring the effectiveness of the consensus processing.

[0073] The embodiments of the present application can also be implemented in combination with cloud technology. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software and network in a wide area network or a local area network to realize the calculation, storage, processing and sharing of data. It can also be understood as a general term for network technology, information technology, integration technology, management platform technology and application technology based on the cloud computing business model application. Cloud technology needs to be supported by cloud computing. Cloud computing is a computing model that distributes computing tasks on a resource pool composed of a large number of computers, so that various application systems can obtain computing power, storage space and information services as needed. The network that provides resources is called a "cloud". Specifically, the first node 100 and each second node 200 are located in the cloud, and the first node 100 and each second node 200 can be a physical machine or a virtualized machine.

[0074] The following introduces a consensus process control method for a blockchain node provided by this application. Figure 2It is a flowchart of a consensus process control method for a blockchain node provided in an embodiment of the present application. The present application provides method operation steps as described in the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the steps among many orders, and does not represent the only order of execution. When the actual system or server product is executed, it can be executed in sequence or in parallel (for example, in a parallel processor or multi-threaded processing environment) according to the method shown in the embodiment or the accompanying drawings. Please refer to Figure 2 , a consensus process control method of a blockchain node provided in an embodiment of the present application may include the following steps:

[0075] S210: After restarting the first node, obtain a first current consensus height corresponding to the first node and a second current consensus height corresponding to each of the at least one second node during the block synchronization process; the first node is any node among the multiple nodes of the blockchain, and the at least one second node is a node other than the first node.

[0076] It is understandable that blockchain is a distributed decentralized network that provides immutability, privacy, security, and transparency. Although there is no central node to verify and validate transactions, every transaction in the blockchain is considered to be completely secure and verified, which relies on the consensus mechanism of the blockchain. That is, through the consensus process based on the consensus algorithm, all nodes of the blockchain network reach a common agreement on the current state of the blockchain, achieving the reliability of the blockchain network and establishing trust between unknown peers in the distributed computing environment.

[0077] If the consensus process of the faulty node is stopped due to network or node downtime, the consensus status of the node will lag behind other normal nodes. In the case of lag, if the consensus process of the node is directly started, that is, participating in the consensus processing of the entire blockchain network, if the node is selected as the master node to generate proposals, the generated proposals will be outdated and invalid because the current consensus height of the node is lagging behind the entire blockchain network, wasting system resources and affecting the consensus and synchronization efficiency between nodes.

[0078] In order to solve this problem, the embodiment of the present application determines whether the node is lagging behind the entire blockchain before starting the consensus process. Among them, the first node can be a node after failure recovery, and at least one second node is a node in the blockchain other than the first node. The embodiment of the present application does not limit the status of the second node. In the embodiment of the present application, the block synchronization process of the blockchain is the process in which all nodes of the blockchain verify the generated blocks. The block height determined after the verification is passed is the consensus height corresponding to the node and the current height of the blockchain. In the embodiment of the present application, by broadcasting the consensus status of the node, each node can obtain the consensus height of other nodes in a relatively timely manner.

[0079] S220: Determine a first quantity according to the first current consensus height and the second current consensus height, where the first quantity is the number of second nodes that meet a first height condition, and the first height condition is that the difference between the second current consensus height and the first current consensus height is greater than a height difference threshold.

[0080] In an embodiment of the present application, the height difference between each second node and the first node can be calculated respectively according to the first current consensus height corresponding to the first node and the second current consensus height corresponding to each second node in at least one second node; the second nodes are traversed and the height difference between the second node and the first node is compared with the height difference threshold. If the height difference between the second node and the first node is greater than the height difference threshold, the first number is increased by 1, and the final first number can be determined at the end of the traversal.

[0081] In one embodiment of the present application, the height difference threshold represents an acceptable consensus height difference, which may be an empirical value, such as 10, or may be another value in actual applications, which is not limited in the present application.

[0082] It should be noted that the difference between the second current consensus height and the first current consensus height corresponds to the result of subtracting the first current consensus height from the second current consensus height, and the same applies to the subsequent ones.

[0083] S230: Determine a second number based on the first current consensus height and the second current consensus height, where the second number is the number of second nodes that meet a second height condition, and the second height condition is that the difference between the second current consensus height and the first current consensus height is less than or equal to a height difference threshold.

[0084] In an embodiment of the present application, the height difference between each second node and the first node can be calculated respectively according to the first current consensus height corresponding to the first node and the second current consensus height corresponding to each second node in at least one second node; the second nodes are traversed and the height difference between the second node and the first node is compared with the height difference threshold; if the height difference between the second node and the first node is less than or equal to the height difference threshold, the second number is increased by 1, and the final second number can be determined at the end of the traversal.

[0085] S240: When the first number is less than or equal to a first number threshold and the second number is greater than a second number threshold, start a consensus process of the first node.

[0086] In an embodiment of the present application, the first quantity threshold is a quantity critical value for indicating whether the first current consensus height lags behind the current height of the blockchain, and the second quantity threshold is a quantity critical value for indicating whether the first current consensus height is approaching the current height of the blockchain. The first quantity threshold can be determined based on the total number of multiple nodes in the blockchain and the first credibility threshold corresponding to the consensus algorithm, and the second quantity threshold can be determined based on the total number of multiple nodes in the blockchain and the second credibility threshold corresponding to the consensus algorithm. The first credibility threshold and the second credibility threshold may be the same or different, so the first quantity threshold and the second quantity threshold may also be the same or different.

[0087] In one embodiment of the present application, based on the Byzantine consensus algorithm, the first credibility threshold and the second credibility threshold can both be 1 / 3, and the first quantity threshold and the second quantity threshold are also the same, which is 1 / 3 of the total number of multiple nodes in the blockchain. The consensus process control method of blockchain nodes based on the Byzantine consensus algorithm can refer to the specific description of the subsequent embodiments.

[0088] In one embodiment of the present application, when the first number is greater than the first number threshold, the consensus process of the first node is stopped, that is, after restarting the first node, the consensus process of the first node is temporarily not started, and the consensus processing of the entire blockchain is not participated in. It can be understood that the first number is greater than the first number threshold, indicating that there are second nodes exceeding the first number threshold, and these second nodes meet the first height condition, that is, the difference between the second current consensus height corresponding to these second nodes and the first current consensus height is greater than the height difference threshold, then it can be considered that the first current consensus height of the first node is lagging behind relative to the current height of the entire blockchain network. In this case, the first node is regarded as a lagging node, and the consensus process of the first node can be temporarily not started, waiting for the synchronization of the block and re-judging according to the new current consensus heights during the block synchronization process, so as to avoid directly starting the consensus process of the first node and generating outdated and invalid consensus proposals, avoid occupying system resources, and avoid reducing the accuracy and effectiveness of the consensus process of other nodes.

[0089] In the embodiment of the present application, the first number is less than or equal to the first number threshold, indicating that there is no second node exceeding the first number threshold, and these second nodes meet the first height condition, then it can be considered that the first current consensus height corresponding to the first node is not in a backward state relative to the entire blockchain network. However, in general, the first current consensus height of the first node is not in a backward state relative to the entire blockchain network, which cannot be completely equivalent to the first current consensus height of the first node approaching the current height of the entire blockchain network. Exemplarily, in the case where the first number is less than or equal to the first number threshold, although it can be considered that the first current consensus height of the first node is not in a backward state relative to the entire blockchain network, since the blockchain network can execute the consensus process based on other nodes, the current height of the blockchain network will continue to increase. At the next moment, it is possible that the first current consensus height of the first node will be in a backward state relative to the entire blockchain network, that is, there may be a trend that the first current consensus height of the first node will lag behind the current height of the blockchain. At this time, if the consensus process of the first node is directly started, there will also be the possibility of generating outdated and invalid proposals. Therefore, it is also necessary to further check whether the first current consensus height of the first node is approaching the current height of the blockchain when the first number is less than or equal to the first number threshold, so as to further ensure that the first node is not in a backward state.

[0090] The test condition provided by the embodiment of the present application is to determine whether the second number is greater than the second number threshold, that is, to determine whether there are second nodes exceeding the second number threshold, and these second nodes meet the second height condition, that is, the difference between the second current consensus height corresponding to these second nodes and the first current consensus height is less than or equal to the height difference threshold. If the second number is greater than the second number threshold, it can be considered that the first current consensus height of the first node is close to the current height of the blockchain. In this case, the first node is regarded as a normal node, and the consensus process of the first node can be started, so that the first node can participate in the consensus processing of the entire blockchain, thereby improving the consensus efficiency.

[0091] In one embodiment of the present application, when the first number is less than or equal to the first number threshold and the second number is less than or equal to the second number threshold, the consensus process of the first node is stopped, that is, after restarting the first node, the consensus process of the first node is temporarily not started, and the consensus processing of the entire blockchain is not participated in. It can be understood that the first number is less than or equal to the first number threshold and the second number is less than or equal to the second number threshold. It can be considered that the first current consensus height of the first node is not lagging behind the entire blockchain network, but there is a trend that the first current consensus height of the first node will lag behind the current height of the blockchain. At this time, if the consensus process of the first node is directly started, there is also the possibility that the proposal is outdated and invalid. Therefore, the consensus process of the first node is not started temporarily, which can avoid the generation of outdated and invalid consensus proposals after starting the consensus process of the first node, thereby avoiding occupying system resources and better ensuring the effectiveness of the consensus of the blockchain network.

[0092] The following introduces another consensus process control method for blockchain nodes provided by this application. Figure 3 It is a flowchart of another consensus process control method for blockchain nodes provided by an embodiment of the present application. The present application provides method operation steps as described in the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the steps among many orders, and does not represent the only order of execution. When the actual system or server product is executed, it can be executed in sequence or in parallel according to the method shown in the embodiment or the accompanying drawings (for example, in a parallel processor or multi-threaded processing environment). Please refer to Figure 3 Another consensus process control method of a blockchain node provided in an embodiment of the present application may include the following steps:

[0093] S310: When the first node is in the consensus process, obtain a third current consensus height corresponding to the first node and a fourth current consensus height corresponding to each second node in at least one second node; the first node is any node among multiple nodes of the blockchain, and the at least one second node is a node of the multiple nodes other than the first node.

[0094] It is understandable that in the consensus process, no matter whether the first node is a master node or a slave node, a new block will be generated for the new proposal, and the calculated block height will be updated to the third current consensus height corresponding to the first node, and the same applies to the second node. If the block height calculated by the first node lags behind the block height calculated by other second nodes, and the block synchronization process has not synchronized the consensus heights of each node in time, there will be a situation where the third current consensus height of the first node lags behind the current height of the blockchain. Therefore, in the consensus process, it is also necessary to control the start and stop of the consensus process by judging whether the current consensus height lags behind the current height of the blockchain.

[0095] S320: Determine a third number based on the third current consensus height and the fourth current consensus height corresponding to each second node, where the third number is the number of second nodes that meet the first height condition, and the first height condition is that the difference between the fourth current consensus height and the third current consensus height is greater than the height difference threshold.

[0096] Step S320 is similar to step S220 and will not be described in detail here.

[0097] S330: When the third number is greater than the first number threshold, the consensus process is terminated; the first number threshold is a critical value for indicating whether the third current consensus height lags behind the current height of the blockchain.

[0098] In the above embodiment, when the first node is in the consensus process, if the third number is greater than the second node of the first number threshold, it can be considered that the first node is in a backward state relative to the entire blockchain network. In the backward situation, if the consensus process of the first node continues to be executed, when the first node is selected as the main node to generate a proposal, the generated proposal will be outdated and invalid because the third current consensus height of the first node is backward relative to the entire blockchain network. Therefore, terminating the consensus process of the first node at this time can allow the first node to exit the consensus processing of the entire blockchain network, avoid wasting system resources, and ensure the accuracy and effectiveness of the consensus processing. After terminating the consensus process of the first node, the blockchain network can perform consensus processing based on other second nodes.

[0099] In one embodiment of the present application, after the consensus process is terminated, the block synchronization process is executed or waited to update the third current consensus height corresponding to the first node and control the consensus process of the first node according to the updated third current consensus height, that is, after step S330, the start and stop of the consensus process of the first node can be controlled according to the embodiment shown in steps S210 to S240 to ensure the effective use of system resources and consensus efficiency. Specifically, the relevant contents of steps S210 to S240 in the aforementioned embodiment can be referred to, and will not be repeated here.

[0100] In one embodiment of the present application, based on step S310 and step S320, the method may further include: when the third number is less than or equal to the first number threshold, continue to execute the consensus process. It is understandable that at this time, the first node is in the consensus process, and the start and stop of the consensus process of the first node can be controlled only by the third number and the first number threshold. For the first node in the consensus process, it is no longer necessary to check whether the third current consensus height is close to the current height of the blockchain, which can ensure the relative stability of the number of nodes participating in the consensus in the blockchain.

[0101] In one embodiment of the present application, Figure 4 As shown, the above method may include: after restarting the first node, obtaining a first current consensus height corresponding to the first node and a second current consensus height corresponding to each second node in at least one second node during the block synchronization process; determining a first quantity according to the first current consensus height and the second current consensus height; when the first quantity is greater than a first quantity threshold, stopping the consensus process of the first node, and waiting for the block synchronization process to re-judge and control; when the first quantity is less than or equal to the first quantity threshold, determining the second quantity according to the first current consensus height and the second current consensus height; when the first quantity is less than or equal to the first quantity threshold and the second quantity is greater than the second quantity threshold, starting the consensus process of the first node; when the first quantity is less than or equal to the first quantity threshold and the second quantity is less than or equal to the second quantity threshold, stopping the consensus process of the first node, and waiting for the block synchronization process to re-judge and control.

[0102] After starting the consensus process of the first node, that is, the first node is in the consensus process, obtain the third current consensus height corresponding to the first node and the fourth current consensus height corresponding to each second node; determine the third quantity according to the third current consensus height and the fourth current consensus height corresponding to each second node; when the third quantity is greater than the first quantity threshold, terminate the consensus process of the first node, and wait for the block synchronization process to re-judge and control; when the third quantity is less than or equal to the first quantity threshold, continue to execute the consensus process of the first node, and re-judge and control according to the current consensus heights updated by the new round of consensus process. It should be noted that the control method provided in the embodiment of the present application is independent of the block synchronization process and the consensus process. The consensus process is intervened only when the above conditions are met to control the start and stop of the consensus process.

[0103] In one embodiment of the present application, the consensus process based on the Byzantine consensus algorithm can be as follows: Figure 5As shown, taking four nodes as an example, assuming that node 1 is selected as the master node, and nodes 2, 3, and 4 are selected as slave nodes; the master node packages and generates a proposal (Proposal), and then broadcasts the proposal to the slave node for verification. After receiving the proposal, the slave node enters the pre-voting (Prevote) stage, initiates a pre-voting, and broadcasts the voting results of this node to other nodes. The master node and the slave node collect the pre-voting results of other nodes in this stage. If the pre-voting results received by each node are more than (2 / 3 of the total number of nodes) + 1 are consistent (consistency can be expressed as the difference in the height of the new block calculated by the node is less than the preset height difference threshold), it enters the pre-commit stage, generates the pre-commit results, and each node broadcasts the pre-commit results of this node to other nodes. If the pre-commit results received by each node are more than (2 / 3 of the total number of nodes) + 1 are consistent, a formal commit is performed. In order to ensure fairness and security, in the next round of consensus process, other nodes are selected as master nodes to perform the above steps again.

[0104] In one embodiment of the present application, at least one second node in the current blockchain has reached the above-mentioned Byzantine consensus, such as Figure 6 As shown, the control method for the consensus process of the first node can be simplified as follows:

[0105] S410: When restarting the first node, obtain a first current consensus height corresponding to the first node and a second current consensus height corresponding to each of the at least one second node during the block synchronization process; the first node is any node among multiple nodes of the blockchain, and the at least one second node is a node other than the first node.

[0106] S420: Determine a first quantity according to the first current consensus height and the second current consensus height, where the first quantity is the number of second nodes that meet a first height condition, and the first height condition is that the difference between the second current consensus height and the first current consensus height is greater than a height difference threshold.

[0107] S430: Determine a second number based on the first current consensus height and the second current consensus height, where the second number is the number of second nodes that meet a second height condition, and the second height condition is that the difference between the second current consensus height and the first current consensus height is less than or equal to a height difference threshold.

[0108] S440: When the first number is greater than a first number threshold, stop the consensus process of the first node.

[0109] S450: When the second number is greater than a second number threshold, start a consensus process of the first node.

[0110] The total number N of multiple nodes can be determined, and then the first number threshold and the second number threshold can be determined based on the Byzantine consensus algorithm and the total number N. Specifically, the first number threshold and the second number threshold are both N, where It is the trusted ratio threshold in the Byzantine consensus algorithm.

[0111] Taking the height difference threshold of 10 as an example, if the first number is greater than the first number threshold, the height difference between the height of the second node, which is more than 1 / 3 of the total number of nodes, and the height of the first node is greater than 10, which means that the current height of the entire blockchain network is greater than the height of the first node by the height difference threshold, and the possibility of the first node participating in the consensus is very small. Therefore, the consensus process can be ignored and the synchronization of blocks can be waited for.

[0112] The second number is greater than the second number threshold, which corresponds to the second nodes that have more than 1 / 3 of the total number of nodes and the height difference between the height of the first node is less than or equal to 10. This indicates that the first node has been synchronized to a height that is close to the current height of the entire blockchain network. The first node is about to become a consensus node that can normally participate in consensus. At this time, starting the consensus process of the first node can avoid generating meaningless proposals that affect the synchronization and consensus of blocks. At the same time, after the first node becomes a normal node, it can participate in consensus to improve consensus efficiency.

[0113] In the above real-time example, based on the premise that at least one second node in the current blockchain has reached a Byzantine consensus, the situation corresponding to the first number being less than or equal to the first number threshold is actually equivalent to the situation corresponding to the second number being greater than the second number threshold, and there is no situation where both the first number being less than or equal to the first number threshold and the second number being less than or equal to the second number threshold are satisfied. In other words, the start and stop control of the consensus process of the first node can be achieved according to any of the first and second numbers. When the first node is in the consensus process, the consensus process of the first node can also continue to be controlled according to steps S420 to S450.

[0114] In a specific exemplary embodiment, during the block synchronization process, each node broadcasts its consensus status to each other every 1 second, so each node can know the current height of other nodes. The block synchronization process and the current height can be as follows: Figure 7 As shown, the first node is node 4 after the failure is recovered, and the height of the first node is 10, which is the height of the first node before the failure occurs; the second nodes are normal nodes node 1, node 2 and node 3, and the second nodes do not fail and continue to execute their respective consensus processes. After the first node is recovered, the height of the second nodes has increased to 100.

[0115] When the first node node4 restarts, it cannot directly start the consensus process. Instead, it needs to calculate and judge based on its own height and the height of other second nodes, and then decide whether to start the consensus process of the first node. The process can be as follows: Figure 8 As shown. Figure 7 The height of each node is shown. At this time, if the height of the second node, which accounts for more than 1 / 3 of the total number of nodes, is greater than the height of the first node by more than the height difference threshold of 10, the consensus process will not be started first, and the block synchronization will be waited for.

[0116] The block synchronization process can be as follows Fig. 9 As shown in the figure, each time a block is synchronized, the height difference between the second node and the first node needs to be calculated to determine whether the conditions for starting the consensus process are met. If not, continue synchronization. If yes, start the consensus process. Assume that after synchronizing a certain number of blocks, the heights of the four nodes are updated to Fig.10 As shown in , the height of the first node node4 is synchronized to 95. At the same time, according to the status of the synchronized second nodes, it is found that the heights of the three second nodes are all 105, and the height difference satisfies the height difference threshold of 10. Therefore, it means that the height of the first node is about to catch up with the status of the entire blockchain network and will soon become a normal consensus node, so the consensus process of the first node can be started.

[0117] When the first node is in the consensus process, if it encounters network failure or other reasons, causing the first node to be forced to terminate the consensus process and the height no longer continues to increase, the heights of the other three second nodes continue to increase, or the block height calculated by the first node lags behind the other second nodes, causing the height difference between the second node and the first node to exceed the height difference threshold, and the number of such second nodes is greater than 1 / 3 of the total number of nodes, then it is necessary to suspend the consensus process of the first node and wait for block synchronization. The process can be as follows Fig.11 As shown. Fig.12 For example, after starting the consensus process of the first node node4, the heights of the four nodes can be as follows Fig.12 As shown, the consensus process of node4 needs to be suspended at this time, and the other three nodes continue to perform consensus processing.

[0118] It can be seen from the above embodiments that the solution provided by the present application can determine the first quantity and the second quantity according to the first current consensus height corresponding to the first node and the second current consensus height corresponding to each second node in at least one second node during the block synchronization process after restarting the first node, the first quantity being the number of second nodes that meet the first height condition, the first height condition being that the difference between the second current consensus height and the first current consensus height is greater than the height difference threshold, the second quantity being the number of second nodes that meet the second height condition, the second height condition being that the difference between the second current consensus height and the first current consensus height is less than or equal to the height difference threshold; and then by comparing the size of the first quantity with the first quantity threshold, and the size of the second quantity with the second quantity threshold, it is determined Determine whether the first current consensus height lags behind the current height of the blockchain and whether the first current consensus height is approaching the current height of the blockchain; in the scheme provided in the present application, the situation where the first number is less than or equal to the first number threshold and the second number is greater than the second number threshold corresponds to the situation where the first current consensus height is not behind the current height of the blockchain, and the first current consensus height is approaching the current height of the blockchain. At this time, starting the consensus process of the first node can improve the consensus efficiency of the blockchain and the accuracy and effectiveness of the consensus processing, and can also avoid the consensus proposal generated by the first node being timed out and invalid after being selected as the main node when it lags behind, that is, avoiding wasting system resources and affecting the consensus and synchronization efficiency between nodes.

[0119] The present application embodiment also provides a consensus process control device 1300 of a blockchain node, such as Fig.13 As shown, the device 1300 may include:

[0120] A first acquisition module 1310 is used to acquire, after restarting the first node, a first current consensus height corresponding to the first node and a second current consensus height corresponding to each of the at least one second node during the block synchronization process; the first node is any node among multiple nodes of the blockchain, and the at least one second node is a node among the multiple nodes other than the first node;

[0121] A first quantity statistics module 1320 is configured to determine a first quantity according to the first current consensus height and the second current consensus height, where the first quantity is the number of second nodes that meet a first height condition, where the first height condition is that the difference between the second current consensus height and the first current consensus height is greater than a height difference threshold;

[0122] A second quantity statistics module 1330 is configured to determine a second quantity according to the first current consensus height and the second current consensus height, where the second quantity is the quantity of second nodes that meet a second height condition, where the second height condition is that the difference between the second current consensus height and the first current consensus height is less than or equal to the height difference threshold;

[0123] The first control module 1340 is used to start the consensus process of the first node when the first number is less than or equal to a first number threshold and the second number is greater than a second number threshold; wherein the first number threshold is a number critical value used to indicate whether the first current consensus height lags behind the current height of the blockchain, and the second number threshold is a number critical value used to indicate whether the first current consensus height is close to the current height of the blockchain.

[0124] In one embodiment of the present application, the apparatus 1300 may further include:

[0125] A first control unit is configured to stop the consensus process of the first node when the first number is greater than the first number threshold.

[0126] In one embodiment of the present application, the apparatus 1300 may further include:

[0127] A second control unit is used to stop the consensus process of the first node when the first number is less than or equal to the first number threshold and the second number is less than or equal to the second number threshold.

[0128] In one embodiment of the present application, the apparatus 1300 may further include:

[0129] A total number determining unit, used to determine the total number of the plurality of nodes;

[0130] A quantity threshold determination unit is used to determine the first quantity threshold and the second quantity threshold based on a Byzantine consensus algorithm and the total quantity.

[0131] It should be noted that the device provided in the above embodiment, when implementing its functions, is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0132] The present application embodiment also provides another consensus process control device 1400 of a blockchain node, such as Fig.14As shown, the device 1400 may include:

[0133] The second acquisition module 1410 is used to acquire, when the first node is in the consensus process, a third current consensus height corresponding to the first node and a fourth current consensus height corresponding to each second node in at least one second node; the first node is any node among multiple nodes of the blockchain, and the at least one second node is a node among the multiple nodes other than the first node;

[0134] A third quantity statistics module 1420, for a module, for determining a third quantity according to the third current consensus height and the fourth current consensus height, wherein the third quantity is the number of second nodes that meet a first height condition, wherein the first height condition is that the difference between the fourth current consensus height and the third current consensus height is greater than a height difference threshold;

[0135] The second control module 1430 is used to terminate the consensus process when the third number is greater than a first number threshold; the first number threshold is a critical value for indicating whether the third current consensus height lags behind the current height of the blockchain.

[0136] In one embodiment of the present application, the device 1400 may further include:

[0137] A third control unit is used to continue executing the consensus process when the third number is less than or equal to the first number threshold.

[0138] In one embodiment of the present application, the device 1400 may further include:

[0139] The first updating unit is used to execute a block synchronization process after terminating the consensus process to update the third current consensus height corresponding to the first node and control the consensus process of the first node according to the updated third current consensus height.

[0140] It should be noted that the device provided in the above embodiment, when implementing its functions, is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0141] An embodiment of the present application provides a computer device, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement a consensus process control method for a blockchain node as provided in the above method embodiment.

[0142] Fig.15 A schematic diagram of the hardware structure of a device for implementing a consensus process control method of a blockchain node provided in an embodiment of the present application is shown, and the device may participate in or include the apparatus or system provided in an embodiment of the present application. Fig.15 As shown, the device 10 may include one or more (1002a, 1002b, ..., 1002n are used to illustrate) processors 1002 (the processor 1002 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 1004 for storing data, and a transmission device 1006 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Fig.15 The structure shown is for illustration only and does not limit the structure of the electronic device. Fig.15 More or fewer components as shown, or with Fig.15 Different configurations are shown.

[0143] It should be noted that the one or more processors 1002 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the device 10 (or mobile device). As involved in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0144] The memory 1004 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the methods in the embodiments of the present application. The processor 1002 executes various functional applications and data processing by running the software programs and modules stored in the memory 1004, that is, realizing the above-mentioned consensus process control method of a blockchain node. The memory 1004 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1004 may further include a memory remotely arranged relative to the processor 1002, and these remote memories may be connected to the device 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0145] The transmission device 1006 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the device 10. In one example, the transmission device 1006 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 1006 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0146] The display may be, for example, a touch screen liquid crystal display (LCD) that may enable a user to interact with a user interface of device 10 (or mobile device).

[0147] An embodiment of the present application also provides a computer-readable storage medium, which can be set in a server to store at least one instruction or at least one program related to a consensus process control method for a blockchain node in a method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement a consensus process control method for a blockchain node provided in the above method embodiment.

[0148] Optionally, in this embodiment, the storage medium may be located in at least one of the multiple network servers of the computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0149] The embodiment of the present invention also provides a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes a consensus process control method of a blockchain node provided in the above various optional embodiments.

[0150] It should be noted that the above-mentioned sequence of the embodiments of the present application is for description only and does not represent the advantages and disadvantages of the embodiments. The above-mentioned specific embodiments of the present application are described. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0151] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment and storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0152] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0153] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A consensus process control method for blockchain nodes, characterized in that: The method comprises: After restarting the first node, obtaining a first current consensus height corresponding to the first node and a second current consensus height corresponding to each of the at least one second node during the block synchronization process; the first node is any node among multiple nodes of the blockchain, and the at least one second node is a node among the multiple nodes except the first node; Determine a first number according to the first current consensus height and the second current consensus height, where the first number is the number of second nodes that meet a first height condition, where the first height condition is that a difference between the second current consensus height and the first current consensus height is greater than a height difference threshold; Determine a second number according to the first current consensus height and the second current consensus height, where the second number is the number of second nodes that meet a second height condition, where the second height condition is that the difference between the second current consensus height and the first current consensus height is less than or equal to the height difference threshold; When the first number is less than or equal to a first number threshold and the second number is greater than a second number threshold, the consensus process of the first node is started; wherein the first number threshold is a number critical value for indicating whether the first current consensus height lags behind the current height of the blockchain, and the second number threshold is a number critical value for indicating whether the first current consensus height is close to the current height of the blockchain.

2. The method according to claim 1, characterized in that The method further comprises: When the first number is greater than the first number threshold, the consensus process of the first node is stopped.

3. The method according to claim 1, characterized in that The method further comprises: When the first number is less than or equal to the first number threshold and the second number is less than or equal to the second number threshold, stop the consensus process of the first node.

4. The method according to claim 1, characterized in that: The method further comprises: determining a total number of the plurality of nodes; Based on the Byzantine consensus algorithm and the total number, the first number threshold and the second number threshold are determined.

5. A consensus process control method for blockchain nodes, characterized in that: The method further comprises: When a first node is in a consensus process, a third current consensus height corresponding to the first node and a fourth current consensus height corresponding to each of at least one second node are obtained; the first node is any node among multiple nodes of the blockchain, and the at least one second node is a node among the multiple nodes other than the first node; Determine a third number according to the third current consensus height and the fourth current consensus height, where the third number is the number of second nodes that meet the first height condition, where the first height condition is that the difference between the fourth current consensus height and the third current consensus height is greater than a height difference threshold; When the third number is greater than a first number threshold, the consensus process is terminated; the first number threshold is a critical value for indicating whether the third current consensus height lags behind the current height of the blockchain.

6. The method according to claim 5, characterized in that The method further comprises: When the third number is less than or equal to the first number threshold, continue to execute the consensus process.

7. The method according to claim 5, characterized in that The method further comprises: After terminating the consensus process, a block synchronization process is performed to update the third current consensus height corresponding to the first node and control the consensus process of the first node according to the updated third current consensus height.

8. A consensus process control device for a blockchain node, characterized in that: The device comprises: A first acquisition module is used to acquire, after restarting the first node, a first current consensus height corresponding to the first node and a second current consensus height corresponding to each of the at least one second node during the block synchronization process; the first node is any node among multiple nodes of the blockchain, and the at least one second node is a node among the multiple nodes other than the first node; A first quantity statistics module, configured to determine a first quantity according to the first current consensus height and the second current consensus height, wherein the first quantity is the quantity of second nodes that meet a first height condition, wherein the first height condition is that a difference between the second current consensus height and the first current consensus height is greater than a height difference threshold; A second quantity statistics module, configured to determine a second quantity according to the first current consensus height and the second current consensus height, where the second quantity is the quantity of second nodes that meet a second height condition, where the second height condition is that the difference between the second current consensus height and the first current consensus height is less than or equal to the height difference threshold; A first control module is configured to start a consensus process of the first node when the first number is less than or equal to a first number threshold and the second number is greater than a second number threshold; wherein the first number threshold is a number critical value for indicating whether the first current consensus height lags behind the current height of the blockchain, and the second number threshold is a number critical value for indicating whether the first current consensus height is approaching the current height of the blockchain.

9. A consensus process control device for a blockchain node, characterized in that: The device comprises: A second acquisition module is used to acquire, when the first node is in the consensus process, a third current consensus height corresponding to the first node and a fourth current consensus height corresponding to each second node in at least one second node; the first node is any node among multiple nodes of the blockchain, and the at least one second node is a node among the multiple nodes other than the first node; A third quantity statistics module, used for a module, used for determining a third quantity according to the third current consensus height and the fourth current consensus height, wherein the third quantity is the number of second nodes that meet the first height condition, and the first height condition is that the difference between the fourth current consensus height and the third current consensus height is greater than a height difference threshold; The second control module is used to terminate the consensus process when the third number is greater than a first number threshold; the first number threshold is a critical value for indicating whether the third current consensus height lags behind the current height of the blockchain.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement a consensus process control method for a blockchain node as described in any one of claims 1 to 7.

11. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement a consensus process control method for a blockchain node as described in any one of claims 1 to 7.