Consensus processing method and system of block chain network, electronic equipment and storage medium

By comparing and updating consensus status information between node devices in the blockchain network, the consensus stability problem caused by network packet loss is solved, the complete synchronization and efficient transmission of information is achieved, and the stability of Byzantine blockchain is improved. and processing efficiency.

CN118921156APending Publication Date: 2024-11-08TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310508103.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-06
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

Due to network packet loss or failure in the blockchain network, node devices cannot successfully transmit consensus messages, resulting in a decrease in consensus stability. The existing technology has failed to effectively improve the stability of Byzantine blockchain.

Method used

In the blockchain network, the node device receives the consensus status information generated by other nodes, compares and updates, and forwards the updated information to the unconnected node device to ensure that all node devices can synchronize the consensus status and avoid information loss. .

Benefits of technology

Through this method, the stability and efficiency of consensus processing are improved, consensus delay and information loss are prevented, and the overall activity and reliability of the blockchain network are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118921156A_ABST
    Figure CN118921156A_ABST
Patent Text Reader

Abstract

The invention provides a block chain network consensus processing method and system, electronic equipment and a storage medium. The method is applied to a first node device in a block chain network, the block chain network comprises a plurality of node devices including the first node device, the first node device is connected with a second node device and a third node device, and the third node device is not connected with the second node device. The method comprises: receiving second consensus state information generated by a second node device, the second consensus state information being sent by the second node device; comparing the generated first consensus state information with the second consensus state information, and updating the first consensus state information based on a first comparison result; and sending the updated first consensus state information to the third node equipment, so that the third node equipment updates third consensus state information of the third node equipment according to the updated first consensus state information. According to the invention, the stability of the Byzantine block chain can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to blockchain technology, and in particular to a consensus processing method, system, electronic device and storage medium for a blockchain network. Background Art

[0002] In the blockchain network, due to network packet loss or other failures, the consensus message sent by the node device to other node devices cannot be successfully reached. Or, the peer node of the node device fails and goes down, and the node device in the faulty state cannot receive the consensus message. When the faulty node device resumes working, there will be a lack of consensus message, resulting in a decrease in the stability of the consensus.

[0003] Among the related technologies, there is currently no better way to improve the stability of the Byzantine blockchain. Summary of the invention

[0004] The embodiments of the present application provide a consensus processing method, system, electronic device, computer-readable storage medium, and computer program product for a blockchain network, which can improve the stability of the Byzantine blockchain.

[0005] The technical solution of the embodiment of the present application is implemented as follows:

[0006] The embodiment of the present application provides a consensus processing method for a blockchain network, which is applied to a first node device in a blockchain network, wherein the blockchain network includes multiple node devices including the first node device, wherein the first node device is any node device in the blockchain system, and the multiple node devices connected to the first node device include at least a second node device and a third node device, and the third node device is not connected to the second node device;

[0007] The method comprises:

[0008] Receiving second consensus state information generated by a second node device, wherein the second consensus state information is sent by the second node device to the connected node device;

[0009] Comparing the generated first consensus state information with the second consensus state information, and updating the first consensus state information based on a first comparison result obtained by the comparison;

[0010] The updated first consensus state information is sent to the third node device so that

[0011] The third node device updates the third consensus state information generated by the third node device according to the updated first consensus state information.

[0012] The embodiment of the present application provides a consensus processing system of a blockchain network, wherein the blockchain network includes multiple node devices including a first node device, wherein the first node device is any node device in the blockchain system, and the multiple node devices connected to the first node device include at least a second node device and a third node device, and the third node device is not connected to the second node device;

[0013] The second node device is used to send the generated second consensus state information to the node devices connected in the blockchain network;

[0014] The first node device is used to receive the second consensus state information;

[0015] The first node device is used to compare the generated first consensus state information with the second consensus state information, and update the first consensus state information based on a first comparison result obtained by the comparison;

[0016] The first node device is used to send the updated first consensus state information to the third node device;

[0017] The third node device is used to update the third consensus state information generated by the third node device according to the updated first consensus state information.

[0018] An embodiment of the present application provides an electronic device, the electronic device comprising:

[0019] A memory for storing computer executable instructions;

[0020] The processor is used to implement the consensus processing method of the blockchain network provided in the embodiment of the present application when executing the computer executable instructions stored in the memory.

[0021] An embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions for implementing the consensus processing method of the blockchain network provided in the embodiment of the present application when executed by a processor.

[0022] An embodiment of the present application provides a computer program product, including a computer program or computer executable instructions. When the computer program or computer executable instructions are executed by a processor, the consensus processing method of the blockchain network provided in the embodiment of the present application is implemented.

[0023] The embodiments of the present application have the following beneficial effects:

[0024] The first node device is any node device in the blockchain network. The first node device receives the consensus status information of the connected node device, compares the received consensus status information with the consensus status information of the first node device itself, and updates the consensus status information of the first node device itself according to the comparison result, thereby avoiding the lack of consensus status information of the first node device compared with other node devices, and improving the stability of consensus processing. The first node device forwards the updated first consensus status information to the third node device, so that the third node device that is not connected to the second node device can obtain the consensus status information of the second node device, and updates the consensus status of the third node device itself based on the updated first consensus status information, thereby improving the stability of consensus processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 It is a schematic diagram of an application scenario of a blockchain network provided in an embodiment of the present application;

[0026] Figure 2A This is an optional schematic diagram of the block structure provided in the embodiment of the present application.

[0027] Figure 2B It is a functional architecture diagram of the blockchain network 200 provided in an embodiment of the present application;

[0028] Figure 2C It is a schematic diagram of the structure of an electronic device 400 serving as a node 210 in a blockchain network 200 provided in an embodiment of the present application;

[0029] FIG. 3A to FIG. 3C It is a flowchart of a consensus processing method for a blockchain network provided in an embodiment of the present application;

[0030] Figure 4A It is a schematic diagram of the consensus process provided by the embodiment of the present application;

[0031] Figure 4B It is a schematic diagram of the structure of the consensus status message provided in the embodiment of the present application;

[0032] Figure 4C It is a schematic diagram of message transmission between node devices provided in an embodiment of the present application;

[0033] Figure 5 It is a schematic diagram of the consensus message sending conditions provided in the embodiment of the present application;

[0034] FIG. 6A to FIG. 6C It is an optional flow chart of the consensus processing method of the blockchain network provided in the embodiment of the present application. DETAILED DESCRIPTION

[0035] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.

[0036] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0037] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0038] It should be pointed out that the collection and processing of relevant data in this application (for example, data stored in the blockchain) should be strictly in accordance with the requirements of relevant national laws and regulations when applied in practice, and the informed consent or separate consent of the personal information subject should be obtained. Subsequent data use and processing should be carried out within the scope of authorization of laws and regulations and the personal information subject.

[0039] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0040] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.

[0041] 1) Blockchain network: a system formed by multiple nodes connected through network communication; a blockchain network may also include clients. The specific content of messages in a blockchain network varies according to the actual business scenario. For example, a message may be a message record, an instruction for a node's state machine to execute, etc.

[0042] 2) Node: It is a connection point, representing a redistribution point or a communication endpoint (some terminal device): The definition of a node depends on the network and protocol layer mentioned. A physical network node is an active electronic device connected to the network, capable of sending, receiving or forwarding information through a communication channel.

[0043] 3) Opposite node: Opposite node is a relative concept. When the proximal node is the local node, the remote node is the opposite node.

[0044] 4) Consensus: In a blockchain network, a node verifies the correctness of messages sent by other nodes. If the verification is successful, a confirmation is sent to the node that sent the message, and the message is persistently stored to support subsequent message queries. Mechanisms for achieving consensus include Proof of Work (PoW), Proof of Stake (PoS), Delegated Proof-of-Stake (DPoS), Proof of Elapsed Time (PoET), etc.

[0045] For example, in a blockchain network, a node verifies the validity of a new block submitted by other nodes. If the verification is successful, a confirmation is sent to the node that submitted the new block, and the new block is added to the end of the blockchain stored by the corresponding node.

[0046] 5) Byzantine consensus: The full name is Byzantine Fault Tolerance (BFT) consensus algorithm, which is a consensus algorithm derived from the Byzantine Generals Problem. There are three versions of the Byzantine Fault Tolerance consensus algorithm: Practical Byzantine Fault Tolerance (PBFT), Federated Byzantine Agreement (FBA), and Delegated Byzantine Fault Tolerance (dBFT).

[0047] 6) Alliance chain: a blockchain that uses members of a specific group and a limited number of third parties as access parties and provides services. The alliance chain specifies multiple pre-selected nodes as nodes for running consensus algorithms and blockchains. The generation of each block is jointly determined by all pre-selected nodes. Other access nodes may not participate in the consensus and blockchain storage process. Other third parties can perform limited queries on the blockchain through the blockchain's open application programming interface (API).

[0048] 7) Consensus status information, generated by the node device, is used to characterize the current consensus status of the node device. The consensus status information includes the following parameters: node device identification, proposal hash code (hash), the current consensus stage of the node device, consensus height (block height), and the voting set consisting of the votes received by the node device.

[0049] 8) Proposal: Any information that can be agreed upon is a proposal. The meaning of proposal in distributed systems is very broad, such as the order of events, the value corresponding to a key, etc. Consensus is the process of reaching a consensus on a proposal. For example, a proposal is the result of a transaction execution. In a blockchain system, consensus is the process of each consensus node reaching a consensus on the result of a transaction execution.

[0050] 9) Voting: Node devices verify the proposal. The Byzantine consensus algorithm assigns an incremental index or height to each block. There is only one valid block at a certain height. The blockchain starts from the Genesis block with a height of 0. Multiple node devices vote as validators to generate the next block. Each node device as a validator has its own public key identifier.

[0051] During the Byzantine consensus process of the blockchain, due to network packet loss or other failures, the consensus status message sent by the node device may not reach other node devices, resulting in the lack of proposals and votes for other node devices. During the Byzantine consensus process, if the node device does not receive (2 / 3+1 of the total number of nodes) votes participating in the consensus, the consensus processing process will be delayed until a sufficient number of consensus messages are received, affecting the stability of the consensus processing.

[0052] The embodiments of the present application provide a consensus processing method for a blockchain network, a consensus processing device for a blockchain network, an electronic device, a computer-readable storage medium, and a computer program product, which can improve the stability of the Byzantine blockchain.

[0053] The following describes an exemplary application of the electronic device provided by the embodiment of the present application. The electronic device provided by the embodiment of the present application can be implemented as a laptop, a tablet computer, a desktop computer, a set-top box, a mobile device (for example, a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, a portable gaming device), a vehicle terminal, a virtual reality (VR) device, an augmented reality (AR) device, and other types of user terminals), and can also be implemented as a server. Below, an exemplary application when the node device is implemented as a terminal device or a server will be described.

[0054] The blockchain network involved in the embodiments of the present application is formed by connecting a client and multiple nodes (any form of computing devices in the access network, such as a server and a user terminal) through network communication.

[0055] See also Figure 1 , Figure 1It is an optional structural diagram of the blockchain network 200 provided in an embodiment of the present application, which is formed by multiple nodes 210 (any form of computing device in the access network, such as a server, a user terminal) and a client 300, and a peer-to-peer (P2P) network is formed between the nodes 210. The P2P protocol is an application layer protocol running on the Transmission Control Protocol (TCP) protocol.

[0056] See also Figure 1 The functions of each node 210 in the blockchain network shown include:

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

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

[0059] 2) Applications are deployed in the blockchain to implement specific businesses based on actual business needs, record messages related to the implementation of functions, carry digital signatures in messages to indicate the source, and send messages to other nodes in the blockchain network for other nodes to add messages to temporary blocks when they successfully verify the source and integrity of the messages.

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

[0061] 2.1) Shared ledger, used to provide functions such as storage, query and modification of messages (carrying data), and send messages about operations on messages to other nodes in the blockchain network. After other nodes verify the validity of the message, they will store the message in a temporary block as a response to acknowledge the validity of the message, and can also send confirmation to the node that initiated the operation.

[0062] 2.2) Smart contracts are computerized protocols that can execute the terms of a contract. They are implemented through code deployed on a shared ledger that is executed when certain conditions are met. The code is used to complete automated message processing based on actual business needs, such as: querying the logistics status of the goods purchased by the buyer, and transferring the buyer's payment to the merchant's account after the buyer signs for the goods.

[0063] 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 messages submitted by the nodes in the blockchain network.

[0064] See also Figure 2A , Figure 2AThis is an optional schematic diagram of the block structure provided by the embodiment of the present application. Each block includes the hash value of the message record stored in this block (the hash value of this block) and the hash value of the previous block. Each block is connected by the hash value to form a blockchain. In addition, the block can also include information such as the timestamp when the block was generated.

[0065] The following describes an exemplary functional architecture of the blockchain network provided by the embodiments of the present application. Figure 2B , Figure 2B It is a functional architecture diagram of the blockchain network 200 provided in an embodiment of the present application, including an application layer 201, a consensus layer 202, a network layer 203, a data layer 204 and a resource layer 205, which are described below respectively.

[0066] The resource layer 205 encapsulates the computing resources, storage resources, and communication resources of each node 210 in the blockchain network 200, such as the computing resources, storage resources, and communication resources in computers, servers / clusters, and clouds, abstracts them, and provides a unified interface to the data layer 204 to shield the differences in the underlying hardware that implements the resource layer 205.

[0067] Computing resources include various forms of processors, such as central processing units (CPUs), application specific integrated circuits (ASICs), application specific integrated circuits, and various forms of processors such as field-programmable gate arrays (FPGAs).

[0068] The storage resources include various types of storage media such as various volatile memories and non-volatile memories. The communication resources include various links for communication between nodes 210 of the blockchain network and between the blockchain network 200 and business entities.

[0069] The data layer 204 encapsulates various data structures for implementing the ledger, including the blockchain implemented as files in the file system, the key-value state database, and the existence proof.

[0070] The network layer 203 encapsulates the functions of point-to-point (P2P) network protocol, data transmission mechanism and data verification mechanism, access authentication mechanism and business subject identity management.

[0071] Among them, the P2P network protocol realizes the communication between the nodes 210 in the blockchain network 200, the data propagation mechanism ensures the propagation of messages in the blockchain network 200, and the data verification mechanism is used to realize the reliability of data transmission between the nodes 210 based on cryptographic methods (such as digital certificates, digital signatures, public / private key pairs); the access authentication mechanism is used to authenticate the identity of the business subject joining the blockchain network 200 according to the actual business scenario, and grant the business subject the right to access the blockchain network 200 when the authentication is passed; the business subject identity management is used to store the identity of the business subject allowed to access the blockchain network 200, and the authority (such as the type of message that can be initiated).

[0072] The consensus layer 202 encapsulates the mechanism by which the nodes 210 in the blockchain network 200 reach consensus on blocks (i.e., the consensus mechanism), message management, and ledger management functions.

[0073] The consensus mechanism includes consensus algorithms such as POS, POW and DPOS, and supports pluggable consensus algorithms.

[0074] Message management is used to verify the digital signature carried in the message received by the verification node 210, verify the identity information of the business subject, and determine whether it has the authority to send messages based on the identity information (read relevant information from the business subject identity management); for business subjects that have obtained authorization to access the blockchain network 200, they all have digital certificates issued by the certification center. The business subject uses the private key in its own digital certificate to sign the submitted message, thereby declaring its legal identity.

[0075] Ledger management: used to maintain the blockchain and state database. For the blocks that have reached consensus, they are appended to the end of the blockchain; the messages in the blocks that have reached consensus are executed, and when the message includes an update operation, the key-value pairs in the state database are updated; when the message includes a query operation, the key-value pairs in the state database are queried and the query results are returned to the business entity. Supports query operations on the state database in multiple dimensions, including: querying blocks based on block serial numbers (such as the hash value of the message); querying blocks based on block hash values; querying blocks based on message serial numbers; querying messages based on message serial numbers; querying business subject account data based on the business subject's account number (serial number); querying the blockchain in the channel based on the channel name.

[0076] The application layer 201 encapsulates various services that can be implemented in the blockchain network, including message traceability, evidence storage, and verification.

[0077] In some embodiments, the node device may be a server, which may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The electronic device may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal device and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present invention.

[0078] The following describes an exemplary structure of an electronic device for running a node of a blockchain network provided in an embodiment of the present application, see Figure 2C , Figure 2C It is a structural diagram of an electronic device 400 as a node 210 in a blockchain network 200 provided in an embodiment of the present application. The electronic device may be a terminal (such as a PC), a server or a server cluster. The electronic device provides a virtualized environment for the operation of the node 210 in the blockchain network 200 and provides resources for the operation of the node 210 (including computing resources, storage resources and communication resources). Figure 2C The electronic device 400 shown includes: at least one processor 410, a memory 450 and at least one network interface 420. The various components in the electronic device 400 are coupled together via a bus system 440. It is understood that the bus system 440 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 440 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 440 is not described in detail. Figure 2C Various buses are labeled as bus system 440 .

[0079] Processor 410 may be an integrated circuit chip having signal processing capabilities. Memory 450 may be removable, non-removable, or a combination thereof. Memory 450 includes volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. In some embodiments, memory 450 is capable of storing data to support various operations, examples of which include programs, modules, and data structures, or subsets or supersets thereof, as exemplified below.

[0080] The operating system 451 includes system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic businesses and processing hardware-based tasks; a network communication module 452 is used to reach other computing devices via one or more (wired or wireless) network interfaces 420. Exemplary network interfaces 420 include: Bluetooth, wireless compatibility certification (WiFi), and a universal serial bus (USB, Universal Serial Bus), etc.

[0081] In some embodiments, the consensus processing device of the blockchain network provided in the embodiments of the present application can be implemented in software. Figure 2C The consensus processing device 455 of the blockchain network stored in the memory 450 is shown, which can be software in the form of programs and plug-ins, including the following software modules: receiving model 4551, updating module 4552, sending model 4553, these modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be explained below.

[0082] The consensus processing method of the blockchain network provided in the embodiment of the present application will be explained in combination with the exemplary application and implementation of the electronic device provided in the embodiment of the present application.

[0083] The following describes the consensus processing method of the blockchain network provided by the embodiment of the present application. As mentioned above, the electronic device used as the node device in the consensus processing method of the blockchain network implemented in the embodiment of the present application can be a terminal or a server. The embodiment of the present application is applied to the first node device in the blockchain network. The blockchain network includes multiple node devices participating in the consensus, including the first node device. The first node device is described as the execution subject. Therefore, the execution subject of each step will not be repeated below.

[0084] In order to facilitate understanding of the consensus processing method of the blockchain network provided in the embodiment of the present application, the principle of consensus processing is explained, and reference is made to Figure 4A , Figure 4A It is a schematic diagram of the consensus process provided by the embodiment of the present application; Figure 4A Each horizontal line in the figure represents a different node device, for example: node device 1, node device 2, node device 3, node device 4. Node device 1 is used as the master node device, and other node devices are used as slave node devices. Consensus includes three stages: proposal stage, pre-voting stage, and pre-commit stage. The consensus process includes the following processing:

[0085] (1) When all node devices enter the proposal phase, the proposal phase timer is started. The master node device packages and generates proposals and broadcasts the proposals to the slave node devices so that the slave node devices can verify the proposals. If the master node device does not generate a proposal and the proposal phase timer is reached, the pre-voting phase is entered.

[0086] (2) For each slave node device, the slave node device receives a proposal and enters the pre-voting stage, and initiates a pre-voting stage vote for the received proposal. If the slave node device does not receive a proposal within the timing of the proposal stage timer, it will also enter the pre-voting stage and initiate a pre-voting stage vote for an empty proposal, and broadcast the generated pre-voting stage vote to other node devices.

[0087] (3) Assume that the total number of node devices participating in the consensus is f. If a node device receives more than (2f / 3+1) votes in the pre-voting phase (possibly including votes corresponding to empty proposals), it will enter the pre-submission phase, generate pre-submission phase votes (possibly including votes for empty proposals), and broadcast the consensus information to other node devices.

[0088] (4) When the node device receives (2f / 3+1) votes in the pre-commit phase, it performs the commit operation.

[0089] See also Figure 3A , Figure 3A This is a flow chart of the consensus processing method of the blockchain network provided in the embodiment of the present application. Based on the above consensus processing principle, Figure 3A The steps shown are explained.

[0090] In step 301, second consensus state information generated by a second node device is received.

[0091] Here, the blockchain network includes multiple node devices participating in the consensus including the first node device. The first node device is any node device in the blockchain system. The multiple node devices connected to the first node device include at least a second node device and a third node device. The third node device is not connected to the second node device.

[0092] For example, consensus status information is information used to characterize the current consensus status of the node device, including the node device identifier, the proposal hash code (hash), the current consensus stage of the node device, the consensus height (block height), and the voting set consisting of the votes received by the node device. If the node device does not receive a proposal, the proposal hash code is an empty code and the proposal is an empty proposal. If no vote is received, the voting set is an empty set. The voting set for each stage includes: the identifier of the node device that performs the voting operation, and the vote associated with the identifier of the node device.

[0093] For example, the second consensus status information is generated by the second node device and sent to the connected node device, and the sending method may be a broadcast method. The third node device not being connected to the second node device means that the third node device is not currently connected to the second node device, for example: the communication line between the third node device and the second node device is faulty. No communication is established between the third node device and the second node device. The embodiment of the present application is described by taking the case where multiple node devices participating in the consensus of the blockchain network are in the same round of consensus processing as an example.

[0094] In some embodiments, the first node device stores a consensus state map, which is used to store the node device identification and consensus state information of each node device connected to the first node device in the form of a key-value pair, where the consensus state information is the value in the key-value pair, and the node device identification is the key in the key-value pair.

[0095] Assuming that the identifier of a node device is "node device ID", the key-value pair in the consensus state graph, for example: node device ID = {consensus state information}, can specifically be: node device ID = {proposal hash code, consensus height, node device is currently in the proposal stage, voting set in the pre-voting stage, voting set in the pre-voting stage}.

[0096] After step 301, the first node device extracts the node device identification of the second node device from the received second consensus state information; based on the node device identification of the second node device, queries the recorded consensus state information of the second node device in the consensus state map; based on the received second consensus state information, replaces the recorded consensus state information of the second node device.

[0097] As an example of replacing the recorded consensus state information of the second node device based on the received second consensus state information, for example: a parameter in the received second consensus state information of the second node device is different from the second consensus state information parameter of the second node device in the consensus state graph stored in the first node device, the stored consensus state information {proposal hash code, consensus height, node device is currently in the proposal stage, voting set in the pre-voting stage, voting set in the pre-voting stage}, the different parameters in the received consensus state information are: the node device is currently in the pre-submission stage, and the corresponding parameters in the stored consensus state information are replaced with the different parameters to obtain the updated consensus state information of the second node device, {proposal hash code, consensus height, node device is currently in the pre-submission stage, voting set in the pre-voting stage, voting set in the pre-voting stage}.

[0098] In an embodiment of the present application, by maintaining a consensus state map in a node device and updating the map based on received information, the activity of information in the blockchain network is improved and the effectiveness of the consensus information stored in the first node device is improved.

[0099] In step 302, the generated first consensus state information is compared with the second consensus state information.

[0100] For example, each parameter included in the first consensus state information and the second consensus state information is compared. The consensus state information includes: node device identification, consensus height, the current consensus stage of the node device, proposal hash code, and voting set; wherein the voting set includes the votes received by the node device.

[0101] In some embodiments, reference Figure 3B , Figure 3A Step 302 in the above example can be accomplished by: Figure 3B Steps 3021 to 3022 in are implemented as described in detail below.

[0102] In step 3021, the second proposal hash code in the second consensus state information is compared with the first proposal hash code in the first consensus state information.

[0103] For example, the second proposal hash code is extracted from the second consensus state information, the first proposal hash code is extracted from the first consensus state information, and the second proposal hash code is compared with the first proposal hash code to see if they are the same.

[0104] In step 3022, the second voting set of the second node device in the second consensus state information is compared with the first voting set of the first node device in the first consensus state information to obtain a first comparison result.

[0105] For example, a voting set is a set of votes received by a node device. Depending on the consensus stage in which the votes are received, the types of voting sets include: voting sets in the pre-voting stage and voting sets in the pre-submission stage. The types of voting include: voting in the pre-voting stage and voting in the pre-submission stage.

[0106] In some embodiments, 3022 can be implemented by: comparing the votes of each pre-voting stage in the second voting set with the votes of each pre-voting stage in the first voting set; comparing the votes of each pre-submission stage in the second voting set with the votes of each pre-submission stage in the first voting set.

[0107] For example, the comparison method for voting at different stages is the same, and the comparison voting is achieved in the following way: for any consensus stage, count the number of votes received by the first node device at that stage and the node device corresponding to each vote; count the number of votes received by the second node device at that stage and the node device corresponding to each vote, and compare whether the number of votes received by the two node devices is the same and whether the node devices corresponding to each vote match. Combine the comparison results of the proposal hash code and the comparison results of the vote to obtain the first comparison result.

[0108] In the embodiment of the present application, by comparing each parameter in the consensus state information and the parameters at different stages, the comparison result is made more comprehensive, and then the first consensus state information is updated based on the comparison result, which can make the consensus state information more complete, improve the stability of the blockchain network, avoid consensus processing delays, save the time consumed by consensus processing, and improve consensus processing efficiency.

[0109] Continue to refer Figure 3A In step 303, the first consensus state information is updated based on the first comparison result obtained by comparison.

[0110] For example, based on the first comparison result, it can be determined that the first node device is missing parameters compared to the second node device, and the corresponding parameters in the second consensus state of the second node device are added to the first consensus state information of the first node device to update the first consensus state information.

[0111] In some embodiments, reference Figure 3C , Figure 3A Step 303 in the above example can be accomplished by: Figure 3B Steps 3031 to 3032 in are implemented as described in detail below.

[0112] In step 3031, in response to the first comparison result indicating that the first proposal hash code is a null code, the null code is replaced based on the second proposal hash code.

[0113] For example, assuming that the first consensus status information is {null code, consensus height height, node device is currently in the pre-submission stage, voting set in the pre-voting stage, voting set in the pre-voting stage}, the updated first consensus status information is {second proposal hash code, consensus height, node device is currently in the pre-submission stage, voting set in the pre-voting stage, voting set in the pre-voting stage}.

[0114] In step 3032 , in response to the first comparison result indicating that the first voting set is missing votes compared to the second voting set, the missing votes of the first voting set are extracted from the second voting set, and the missing votes are added to the first voting set.

[0115] For example, the first voting set is a set composed of voting sets of different stages, and the missing votes in each consensus stage are extracted from the second voting set respectively and added to the voting set corresponding to each consensus stage.

[0116] In some embodiments, step 3032 is implemented in the following manner: in response to the first comparison result characterizing that the first voting set lacks votes in the pre-voting stage compared to the second voting set, extracting the votes in the pre-voting stage that are missing from the first voting set from the second voting set, and adding the missing votes in the pre-voting stage to the first voting set; in response to the first comparison result characterizing that the first voting set lacks votes in the pre-submission stage compared to the second voting set, extracting the votes in the pre-submission stage that are missing from the first voting set from the second voting set, and adding the missing votes in the pre-submission stage to the first voting set.

[0117] In an embodiment of the present application, the number of votes of the first node device can be increased by supplementing the missing votes in the voting set, thereby avoiding delays in consensus processing while the node device is waiting to receive sufficient votes (two-thirds of the total number of nodes plus one vote).

[0118] Continue to refer Figure 3A In step 304, the updated first consensus state information is sent to the third node device, so that the third node device updates the third consensus state information generated by the third node device according to the updated first consensus state information.

[0119] For example, the first node device is any node device in the blockchain network, and the operations performed by the first node device are also applicable to the second node device and the third node device. The updated first consensus state information includes at least part of the original first consensus state information and at least part of the second consensus state information. The third node device receives the updated first consensus state information and updates the generated third consensus state information, so that the consensus state information of the third node device can be synchronized with the consensus state information of the unconnected second node device.

[0120] In some embodiments, the first node device sends the first consensus state information to other node devices in the following manner: in response to a change in the consensus stage currently in which the first node device is located, the first consensus state information of the first node device is sent to the node device to which the first node device is connected.

[0121] Here, the types of consensus phases include: proposal phase, pre-voting phase, and pre-commit phase.

[0122] For example, the first consensus state information is the consensus information of the consensus stage that the first node device is currently in. For example: the consensus stage that the first node device is in changes from the proposal stage to the pre-voting stage, then the first consensus state information of the pre-voting stage is different from the first consensus state information of the proposal stage, and the proposal hash code of the proposal stage is an empty code, while the proposal hash code of the pre-voting stage is not an empty code. That is, as the consensus stage changes, the first consensus state information also changes. After the consensus stage changes, the first consensus state information of the current consensus stage is sent to other node devices.

[0123] In the embodiment of the present application, after a change occurs in the consensus phase, the first node device synchronizes the changed first consensus status information to other node devices, thereby improving the information consistency and effectiveness between the node devices and improving the consensus efficiency.

[0124] In some embodiments, the first node device sends the first consensus status information to other node devices in the following manner: calling the timer of the first node device to count; in response to the current timing duration of the timer reaching a duration threshold, sending the current first consensus status information of the first node device to the node device to which the first node device is connected, and calling the timer of the first node device to count again.

[0125] For example, the duration threshold can be preconfigured according to actual needs, for example, the duration threshold is set to 1 second. The duration threshold can also be dynamically adjusted according to the network status of the node device, for example, if the network delay is greater than the preset delay and the duration is greater than the preconfigured duration, the duration threshold corresponding to the timer is extended.

[0126] In the embodiment of the present application, the time interval for sending consensus status information by the node device is configured by a timer, thereby avoiding frequent sending of consensus status information to occupy network resources and reduce consensus processing efficiency. The timer duration threshold is dynamically adjusted according to the network status to reduce network resource occupation, so that other functions of the first node device that require network resources can operate normally.

[0127] In some embodiments, the first node device sends the first consensus status information to other node devices in the following manner: calling the timer of the first node device to start timing; in response to a change in the consensus stage currently in which the first node device is located, sending the current first consensus status information of the first node device to the node device to which the first node device is connected, and resetting the current timing duration of the timer to zero, wherein the types of consensus stages include: proposal stage, pre-voting stage, and pre-submission stage; in response to the timing duration of the timer reaching a duration threshold, sending the current first consensus status information of the first node device to the node device to which the first node device is connected, and calling the timer of the first node device to restart timing.

[0128] For example, the duration threshold of the timer has been explained above and will not be repeated here. The timer of the first node device is called to start timing. If the timing duration has not reached the duration threshold, the consensus stage currently in which the first node device is located changes. The first node device sends the first consensus status information to other node devices, and clears the current timing duration of the timer to 0, and starts timing again from 0.

[0129] refer to Figure 5 , Figure 5 It is a schematic diagram of the consensus message sending conditions provided in the embodiment of the present application; Figure 5 The horizontal axis is time, and the vertical axis is the consensus stage. The timer is turned on at 0 seconds; there is no change in the consensus stage at 0 seconds, and the timer is triggered at 1 second, sending a consensus status message; at 1.5 seconds, the consensus stage of the node changes, and a consensus status message is sent at 1.5 seconds, and the timer is reset, and the timer returns to 0; after 0.8 seconds at 2.3 seconds, the consensus state of the node device changes again, and a consensus status message is also sent at 2.3 seconds, and the timer is reset at the same time; there is no change in the consensus stage afterwards, and the timer sends the node's consensus state to other nodes at 3.3 seconds and 4.3 seconds, with a time interval of 1 second.

[0130] In the embodiment of the present application, by resetting the timer when the consensus stage changes, conflicts between the sending of consensus status information triggered by the timer and the sending of consensus status information triggered by the consensus stage change are avoided, and frequent sending of consensus status information is avoided to occupy network resources and reduce consensus processing efficiency.

[0131] In some embodiments, after step 302, in response to the first comparison result indicating that the second consensus state information is missing compared to the first consensus state information, the first consensus state information is sent to the second node device so that the second node device updates the second consensus state information generated by the second node device according to the first consensus state information, wherein the content updated by the second node device includes at least one of the following: a proposal hash code and a voting set.

[0132] For example, the principle of the second node device updating the second consensus state information is the same as the principle of the first node device updating the first consensus state information, which will not be repeated here. The first node device sends the first consensus state information to the second node device, which can be triggered according to the timer above, or immediately sent when it is determined that the first comparison result indicates that the second consensus state information is missing compared to the first consensus state information.

[0133] In some embodiments, after step 302, in response to the first comparison result indicating that the second consensus state information is missing compared to the first consensus state information, the missing content of the second consensus state information is sent to the second node device, so that the second node device updates the second consensus state information generated by the second node device according to the missing content, wherein the content updated by the second node device includes at least one of the following: a proposal hash code, a voting set.

[0134] For example, the principle of the second node device updating the second consensus state information is the same as the principle of the first node device updating the first consensus state information, which will not be repeated here. The first node device determines the missing content of the second node device by comparison, and only sends the missing content to the second node device, which saves data transmission time compared to sending the entire first consensus state information, and saves the time required for the second node device to update the second consensus state information.

[0135] An embodiment of the present application also proposes a consensus processing system for a blockchain network, wherein the blockchain network includes multiple node devices participating in the consensus, including a first node device, wherein the first node device is any node device in the blockchain system, and the multiple node devices connected to the first node device include at least a second node device and a third node device, and the third node device is not connected to the second node device.

[0136] The second node device is used to send the generated second consensus state information to the node devices connected in the blockchain network by broadcasting.

[0137] For example, the first node device, the second node device, and the third node device can all run the consensus processing method of the blockchain network provided in the embodiment of the present application.

[0138] The first node device is used to receive second consensus state information.

[0139] The first node device is used to compare the generated first consensus state information with the second consensus state information, and update the first consensus state information based on a first comparison result obtained by the comparison.

[0140] The first node device is used to send the updated first consensus state information to the third node device.

[0141] The third node device is used to update the third consensus state information generated by the third node device according to the updated first consensus state information.

[0142] In an embodiment of the present application, the first node device receives the consensus status information of the connected node device, which is any node device in the blockchain network, and compares the received consensus status information with the consensus status information of the first node device itself, and updates the consensus status information of the first node device itself according to the comparison result, thereby avoiding the lack of consensus status information of the first node device compared to other node devices, and improving the stability of consensus processing. The first node device forwards the updated first consensus status information to the third node device, so that the third node device that is not connected to the second node device can obtain the consensus status information of the second node device, and updates the consensus status of the third node device itself based on the updated first consensus status information, thereby improving the stability of consensus processing. By sending the consensus status information at a regular interval, the frequency of consensus status information synchronization is maintained, while avoiding the occupation of network resources caused by frequent sending.

[0143] Below, an exemplary application of the consensus processing method of the blockchain network of an embodiment of the present application in an actual application scenario will be described.

[0144] In order to facilitate understanding of the consensus processing method of the blockchain network provided in the embodiment of the present application, the principle of consensus processing is explained. Figure 4A , Figure 4A It is a schematic diagram of the consensus process provided by the embodiment of the present application; Figure 4A Each horizontal line in the figure represents a different node device, for example: node device 1, node device 2, node device 3, node device 4. The node devices are referred to as nodes below, node device 1 is the master node, and other nodes are slave nodes. Consensus includes three stages: proposal stage, pre-voting stage, and pre-commit stage. The consensus process includes the following processing:

[0145] (1) When all nodes enter the proposal phase, the timer starts. The master node packages and generates proposals and broadcasts them to the slave nodes for verification. If the master node does not generate a proposal, it will time out and enter the pre-voting phase.

[0146] (2) A slave node receives a proposal and enters the pre-voting phase, and initiates a pre-voting phase vote for the received proposal. If a slave node does not receive a proposal within the proposal phase timer, it will also enter the pre-voting phase and initiate a pre-voting phase vote for an empty proposal, and broadcast the generated pre-voting phase vote to other nodes.

[0147] (3) Assume that the total number of nodes participating in the consensus is f. If a node receives more than (2f / 3+1) votes in the pre-voting phase (possibly including votes corresponding to empty proposals), it will enter the pre-submission phase, generate pre-submission votes (possibly including votes for empty proposals), and broadcast the consensus message to other nodes.

[0148] (4) When a node receives (2f / 3+1) votes from the pre-commit phase, it performs the commit operation.

[0149] According to the above principle, in a complete consensus process of Byzantine consensus, consensus messages need to be broadcast in all three stages. In the pre-voting stage and the pre-committing stage, nodes broadcast voting messages to each other. If (2f / 3+1) votes are not received in these two stages, the consensus processing will be delayed until (2f / 3+1) votes are received, and the consensus will continue to run. For consensus messages, if due to network reasons, the peer node may not collect enough consensus messages, and the peer node's consensus status message may be missing.

[0150] The consensus processing method of the blockchain network of the embodiment of the present application broadcasts its own consensus status to each other. The nodes regularly analyze their own consensus status and the status of other nodes they maintain, and compare the difference between the two consensus statuses. If it is found that the peer node lacks a certain consensus message, it will be reissued. In this way, the lost consensus message can be reissued. When the connection between the two nodes is disconnected, the consensus message can be forwarded through the intermediate node, so that the node that lacks the message can receive the consensus message again, thereby improving the activity and stability of the Byzantine blockchain.

[0151] refer to Fig. 6A as well as Figure 6B , FIG. 6A to FIG. 6B It is an optional flow chart of the consensus processing method of the blockchain network provided in the embodiment of the present application. Fig. 6A and Figure 6B Connect through node A, Fig. 6A After step 606A in Figure 6B In step 607A, the following description is given with the first node device in the above text as the execution subject, and the first node device is used as the current node.

[0152] In step 601A, a consensus status message is sent.

[0153] For example, each node broadcasts its consensus status message to other nodes. Figure 4B , Figure 4BThis is a schematic diagram of the structure of the consensus status message provided by the embodiment of the present application; the consensus status message includes: node identification, consensus height, the current consensus stage (proposal stage, pre-voting stage, pre-submission stage), proposal hash code (if no proposal hash code is received, it is null), pre-submission stage voting set, pre-voting stage voting set. The voting set includes: pre-voting stage votes and pre-submission stage votes received by the node.

[0154] For example, this node sends consensus status messages to connected node devices according to the timer. Figure 4C , Figure 4C It is a schematic diagram of message transmission between node devices provided in an embodiment of the present application; node device 1, node device 2, node device 3, and node device 4 are respectively node devices connected in the blockchain network, and each node device synchronizes consensus status messages with each other.

[0155] For example, considering that the consensus status message may be lost, for each node, the node synchronizes the consensus status message to other nodes, including: each node sends the node consensus status message to other nodes at a regular interval; in response to the node's status entering a new consensus stage (the three consensus stages described above, the consensus entering the proposal stage, entering the pre-voting stage, entering the pre-submission stage is called entering a new consensus stage or called a consensus stage change), the node sends its own consensus status message to other nodes.

[0156] In order to avoid the impact of too many consensus status messages on the consensus performance due to the occupation of network bandwidth, the consensus status messages cannot be broadcast too frequently. The messages can be broadcasted in the following ways: set a timer for each node, send a consensus status message every 1 second, send a consensus status message in response to the node entering a new stage, reset the timer, and avoid sending consensus status messages too frequently, occupying network resources and computing resources, and causing consensus performance to decrease.

[0157] refer to Figure 5 , Figure 5 It is a schematic diagram of the consensus message sending conditions provided in the embodiment of the present application; Figure 5 The horizontal axis is time, and the vertical axis is the consensus stage. The timer is turned on at 0 seconds; there is no change in the consensus stage at 0 seconds, and the timer is triggered at 1 second, sending a consensus status message; at 1.5 seconds, the consensus stage of the node changes, and a consensus status message is sent at 1.5 seconds, and the timer is reset, and the timer returns to 0; after 0.8 seconds at 2.3 seconds, the consensus state of the node device changes again, and a consensus status message is also sent at 2.3 seconds, and the timer is reset at the same time; there is no change in the consensus stage afterwards, and the timer sends the node's consensus state to other nodes at 3.3 seconds and 4.3 seconds, with a time interval of 1 second.

[0158] In the embodiment of the present application, by broadcasting consensus status messages to each other, each node can know what messages are missing from other nodes so as to resend the consensus messages.

[0159] In step 602A, the consensus status message of the peer node is obtained.

[0160] For example, each node device in the blockchain network periodically sends a consensus status message to the connected node devices. This node receives the consensus status message from the peer node to obtain the content of the consensus status message.

[0161] For example, each consensus node maintains a consensus map locally. The key of the consensus map is the node ID of other nodes, and the value is the consensus status message. After receiving the consensus status message from other nodes, the consensus status message recorded in the consensus map is determined according to the node ID in the consensus status message, and the recorded consensus status message in the consensus map is updated.

[0162] For example, this node compares the difference between the consensus status message of the peer node and its own consensus status message of the received consensus status information, so as to reissue the votes or proposals that are missing from the peer node. In response to receiving a consensus status message from a certain node, this node detects whether the received consensus status message includes the content that is missing from the current node, and extracts the required content from the consensus status message. The consensus status message basically includes all the consensus descriptions of the current state of a node. The peer node can determine whether certain consensus messages are missing based on the consensus status of this node, and synchronize the missing consensus messages. In the embodiment of the present application, the lack of proposals, voting in the pre-voting stage, and voting in the pre-submission stage are used as examples for explanation, and the following steps are explained in sequence.

[0163] In step 603A, it is determined whether this node has a proposal.

[0164] If the judgment result of step 603A is yes, step 604A is executed to determine whether the hash code of the peer node proposal is empty. If the judgment result of step 603A is no, it means that there is no need to reissue the proposal, and step 606A is executed to obtain the voting set of the peer node pre-voting stage.

[0165] For example, the proposal hash code in the consensus status message of this node is obtained. If the proposal hash code is null, the judgment result of step 603A is no, and this node has no proposal.

[0166] In step 604A, it is determined whether the hash code of the peer node proposal is empty.

[0167] If the judgment result of step 604A is yes, step 605A is executed to reissue the proposal. If the judgment result of step 604A is no, it means that there is no need to reissue the proposal, and step 606A is executed to obtain the voting set of the peer node in the pre-voting stage.

[0168] For example, the way to resend proposals can be to send only the missing proposals, or to send the complete consensus status information.

[0169] Steps 601A to 605A can be summarized as: check whether the current node has generated a proposal. If so, determine whether the peer node has received the proposal based on the consensus status message of the peer node. If the current node has generated a proposal and the peer node has not received it, resend the proposal to the peer node.

[0170] In step 606A, the voting set of the peer node in the pre-voting phase is obtained, and step 607A is performed after step 606A.

[0171] For example, extract the voting set of the peer node in the pre-voting phase from the consensus status message.

[0172] In step 607A, it is determined whether the node has generated a vote in the pre-voting phase.

[0173] If the result of step 607A is no, it means that the current node does not have a vote in the pre-voting phase, and there is no pre-voting phase vote that can be reissued to other nodes, and step 610A is executed to obtain the voting set of the pre-submission phase of the peer node. If the result of step 607A is yes, step 608A is executed to determine whether the peer node has a pre-voting phase vote generated by the current node.

[0174] If the result of step 608A is yes, it means that there is no need to resend the votes of the pre-voting stage to the peer node, and step 610A is executed to obtain the voting set of the pre-submission stage of the peer node. If the result of step 608A is no, step 609A is executed to resend the votes of the pre-voting stage generated by the node.

[0175] For example, steps 606A to 609A can be summarized as: analyzing whether the current node has generated a pre-voting phase vote, determining whether the opposite node has received the pre-voting phase vote of the current node based on the consensus status message of the opposite node obtained, and if the current node has generated a pre-voting phase vote and the opposite node has not received the pre-voting phase vote generated by the current node, resending the pre-voting phase vote to the opposite node.

[0176] After step 610A, step 611A is executed to determine whether the node generates a vote in the pre-submission phase.

[0177] If the result of step 611A is no, it means that the node does not have a pre-submission stage vote, and there is no pre-submission stage vote that can be reissued to other nodes, and the process ends. If the result of step 611A is yes, step 612A is executed to determine whether the peer node has a pre-submission stage vote generated by the node.

[0178] If the result of step 612A is yes, it means that there is no need to resend the pre-submission stage vote to the peer node, and the process ends. If the result of step 612A is no, step 613A is executed to resend the pre-submission stage vote generated by the current node.

[0179] For example, steps 610A to 613A can be summarized as follows: analyzing whether the current node has generated a pre-submission phase vote, determining whether the opposite node has received the pre-submission phase vote generated by the current node based on the consensus status message of the opposite node obtained, and if the current node has generated a pre-submission phase vote and the opposite node has not received the pre-submission phase vote generated by the current node, resending the pre-submission phase vote to the opposite node.

[0180] In some embodiments, reference Figure 6C , Figure 6C It is an optional flow chart of the consensus processing method of the blockchain network provided in the embodiment of the present application.

[0181] In step 601B, a consensus status message is received.

[0182] In step 602B, the local node updates the state map of the peer node that it maintains.

[0183] For example, the maintenance method of the state map has been described in step 602A above.

[0184] In step 603B, the voting set of the pre-voting phase in the consensus status message is obtained.

[0185] In step 604B, it is determined whether there are any votes in the pre-voting phase that the node has not received.

[0186] If the result of step 604B is yes, step 605B is executed to obtain the pre-voting phase votes of other nodes that have not been received. If the result of step 604B is no, step 606B is executed to obtain the pre-commit phase vote set in the consensus status message.

[0187] Step 606B is also executed after step 605B, and step 607B is executed after step 606B.

[0188] In step 607B, it is determined whether there are any votes in the pre-commit phase that the node has not received.

[0189] If the judgment result of step 607B is yes, step 608B is executed to obtain the pre-submission phase votes of other nodes that have not been received, and the process ends after step 608B. If the judgment result of step 607B is no, the process ends.

[0190] For example, through Figure 6C In the steps, when the node updates the received node status message, it can receive the voting set of other nodes. After updating the consensus status of the peer node, it obtains the pre-voting stage votes and pre-commit stage votes received from other nodes from the consensus status message. Even if the two nodes are not linked to each other, but there is an intermediate node, one of the nodes sends the vote to this intermediate node, then the other node receives the consensus status message of the intermediate node and can also obtain the votes of the nodes that are not directly connected. For example: Node A and Node B are not directly connected, but Node A and Node B have established connections with Node C. The votes or proposals generated by Node A can be forwarded to Node B through Node C.

[0191] In the embodiment of the present application, in the case where some nodes are disconnected from each other and there are intermediate nodes between the nodes, the consensus message can reach the peer node in a non-direct manner. The embodiment of the present application can fully improve the consensus activity of the blockchain. The embodiment of the present application can achieve the following effects:

[0192] 1. Resend lost consensus messages to improve the activity and stability of the Byzantine blockchain.

[0193] 2. When there is no direct connection between two nodes, but there is a network path between the nodes, the missing consensus message can also reach the node that lacks the message through indirect transmission.

[0194] 3. Consensus status information is sent regularly to avoid the degradation of consensus performance caused by large amounts of consensus status information being sent frequently.

[0195] The following is an explanation of the exemplary structure of the consensus processing device 455 of the blockchain network provided in the embodiment of the present application implemented as a software module. In some embodiments, Figure 2CAs shown, the software modules in the consensus processing device 455 of the blockchain network stored in the memory 450 may include: a receiving module 4551, configured to receive second consensus state information generated by a second node device, wherein the second consensus state information is sent by the second node device to the connected node device; an updating module 4552, configured to compare the generated first consensus state information with the second consensus state information, and update the first consensus state information based on a first comparison result obtained by the comparison; a sending module 4553, configured to send the updated first consensus state information to the third node device, so that the third node device updates the third consensus state information generated by the third node device according to the updated first consensus state information.

[0196] In some embodiments, the sending module 4553 is configured to send the current first consensus state information of the first node device to the node device to which the first node device is connected in response to a change in the consensus stage currently in which the first node device is located, wherein the types of the consensus stages include: proposal stage, pre-voting stage and pre-submission stage.

[0197] In some embodiments, the sending module 4553 is configured to call the timer of the first node device for timing; in response to the current timing duration of the timer reaching a duration threshold, the current first consensus state information of the first node device is sent to the node device to which the first node device is connected, and the timer of the first node device is called to re-time.

[0198] In some embodiments, the sending module 4553 is configured to call the timer of the first node device for timing; in response to a change in the consensus stage currently in which the first node device is located, send the first consensus status information of the first node device to the node device to which the first node device is connected, and reset the current timing duration of the timer to zero, wherein the types of consensus stages include: proposal stage, pre-voting stage and pre-submission stage; in response to the timing duration of the timer reaching a duration threshold, send the first consensus status information of the first node device to the node device to which the first node device is connected, and call the timer of the first node device to re-time.

[0199] In some embodiments, the consensus state information includes: a proposal hash code and a voting set; wherein the voting set includes the votes received by the node device; the update module 4552 is configured to compare the second proposal hash code in the second consensus state information with the first proposal hash code in the first consensus state information, and compare the second voting set of the second node device in the second consensus state information with the first voting set of the first node device in the first consensus state information to obtain a first comparison result.

[0200] In some embodiments, the update module 4552 is configured to, in response to the first comparison result characterizing that the first proposal hash code is an empty code, replace the empty code based on the second proposal hash code; in response to the first comparison result characterizing that the first voting set is missing votes compared to the second voting set, extract the missing votes from the first voting set from the second voting set, and add the missing votes to the first voting set.

[0201] In some embodiments, the types of voting include: voting in the pre-voting stage and voting in the pre-submission stage; the update module 4552 is configured to compare each vote in the pre-voting stage in the second voting set with each vote in the pre-voting stage in the first voting set; and compare each vote in the pre-submission stage in the second voting set with each vote in the pre-submission stage in the first voting set.

[0202] In some embodiments, the update module 4552 is configured to, in response to the first comparison result characterizing that the first voting set lacks votes in the pre-voting stage compared to the second voting set, extract the pre-voting stage votes that are missing from the first voting set from the second voting set, and add the missing pre-voting stage votes to the first voting set; in response to the first comparison result characterizing that the first voting set lacks votes in the pre-submission stage compared to the second voting set, extract the pre-submission stage votes that are missing from the first voting set from the second voting set, and add the missing pre-submission stage votes to the first voting set.

[0203] In some embodiments, the update module 4552 is configured to, after comparing the generated first consensus state information with the second consensus state information, send the first consensus state information to the second node device in response to the first comparison result indicating that the second consensus state information is missing compared to the first consensus state information, so that the second node device updates the second consensus state information generated by the second node device according to the first consensus state information, wherein the content updated by the second node device includes at least one of the following: proposal hash code, voting set.

[0204] In some embodiments, the update module 4552 is configured to, after comparing the generated first consensus state information with the second consensus state information, send the missing content of the second consensus state information to the second node device in response to the first comparison result indicating that the second consensus state information is missing compared to the first consensus state information, so that the second node device updates the second consensus state information generated by the second node device according to the missing content, wherein the content updated by the second node device includes at least one of the following: a proposal hash code and a voting set.

[0205] In some embodiments, the first node device stores a consensus state map, and the consensus state map is used to store the node device identification and consensus state information of each of the node devices connected to the first node device in the form of a key-value pair, the consensus state information is the value in the key-value pair, and the node device identification is the key in the key-value pair; the receiving module 4551 is configured to extract the node device identification of the second node device from the second consensus state information after receiving the second consensus state information generated by the second node device; based on the node device identification of the second node device, query the recorded consensus state information of the second node device in the consensus state map; based on the received second consensus state information, replace the recorded consensus state information of the second node device.

[0206] The embodiment of the present application provides a computer program product, which includes a computer program or a computer executable instruction, and the computer program or the computer executable instruction is stored in a computer-readable storage medium. The processor of the electronic device reads the computer executable instruction from the computer-readable storage medium, and the processor executes the computer executable instruction, so that the electronic device executes the consensus processing method of the blockchain network described in the embodiment of the present application.

[0207] The embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions or computer programs are stored. When the computer-executable instructions or computer programs are executed by a processor, the processor will execute the consensus processing method of the blockchain network provided in the embodiment of the present application, for example, Figure 3A The consensus processing method of the blockchain network shown.

[0208] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various devices including one or any combination of the above memories.

[0209] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.

[0210] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file storing other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).

[0211] As an example, the executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.

[0212] In summary, through the embodiments of the present application, the first node device receives the consensus status information of the connected node device, the first node device is any node device in the blockchain network, and compares the received consensus status information with the consensus status information of the first node device itself, and updates the consensus status information of the first node device itself according to the comparison result, thereby avoiding the lack of consensus status information of the first node device compared to other node devices, and improving the stability of consensus processing. The first node device forwards the updated first consensus status information to the third node device, so that the third node device that is not connected to the second node device can obtain the consensus status information of the second node device, and updates the consensus status of the third node device itself based on the updated first consensus status information, thereby improving the stability of consensus processing.

[0213] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims

1. A consensus processing method for a blockchain network, characterized in that: A first node device applied to a blockchain network, wherein the blockchain network includes multiple node devices including the first node device, wherein the first node device is any node device in the blockchain system, and the multiple node devices connected to the first node device include at least a second node device and a third node device, and the third node device is not connected to the second node device; The method comprises: Receiving second consensus state information generated by a second node device, wherein the second consensus state information is sent by the second node device to the connected node device; Comparing the generated first consensus state information with the second consensus state information, and updating the first consensus state information based on a first comparison result obtained by the comparison; The updated first consensus state information is sent to the third node device so that The third node device updates the third consensus state information generated by the third node device according to the updated first consensus state information.

2. The method according to claim 1, characterized in that The method further comprises: In response to a change in the consensus stage currently located by the first node device, the current first consensus state information of the first node device is sent to the node device to which the first node device is connected, wherein the types of the consensus stages include: a proposal stage, a pre-voting stage, and a pre-submission stage.

3. The method according to claim 1, characterized in that The method further comprises: Calling the timer of the first node device to start timing; In response to the current timing duration of the timer reaching the duration threshold, the current first consensus state information of the first node device is sent to the node device to which the first node device is connected, and the timer of the first node device is called to re-time.

4. The method according to claim 1, characterized in that: The method further comprises: Calling the timer of the first node device to start timing; In response to a change in the consensus stage currently in which the first node device is located, sending the first consensus state information of the first node device to the node device to which the first node device is connected, and resetting the current timing duration of the timer to zero, wherein the types of the consensus stage include: proposal stage, pre-voting stage and pre-submission stage; In response to the timing duration of the timer reaching a duration threshold, the current first consensus state information of the first node device is sent to the node device to which the first node device is connected, and the timer of the first node device is called to re-time.

5. The method according to claim 1, characterized in that The consensus state information includes: a proposal hash code and a voting set; wherein the voting set includes the votes received by the node device; The comparing the generated first consensus state information with the second consensus state information includes: Compare the second proposal hash code in the second consensus state information with the first proposal hash code in the first consensus state information, and compare the second voting set of the second node device in the second consensus state information with the first voting set of the first node device in the first consensus state information to obtain a first comparison result.

6. The method according to claim 5, characterized in that The types of voting include: voting in the pre-voting stage and voting in the pre-submission stage; The comparing the second voting set of the second node device in the second consensus state information with the first voting set of the first node device in the first consensus state information includes: Comparing the votes of each of the pre-voting stages in the second voting set with the votes of each of the pre-voting stages in the first voting set; The votes of each pre-commit stage in the second voting set are compared with the votes of each pre-commit stage in the first voting set.

7. The method according to claim 5, characterized in that The updating of the first consensus state information based on the first comparison result obtained by comparison includes: In response to the first comparison result indicating that the first proposal hash code is a null code, replacing the null code based on the second proposal hash code; In response to the first comparison result indicating that the first voting set is missing votes compared to the second voting set, the missing votes of the first voting set are extracted from the second voting set, and the missing votes are added to the first voting set.

8. The method according to claim 7, characterized in that In response to the first comparison result indicating that the first voting set is missing votes compared to the second voting set, extracting the missing votes from the first voting set from the second voting set, and adding the missing votes to the first voting set, comprises: In response to the first comparison result indicating that the first voting set lacks votes in the pre-voting stage compared with the second voting set, extracting the votes in the pre-voting stage that are missing from the first voting set from the second voting set, and adding the missing votes in the pre-voting stage to the first voting set; In response to the first comparison result indicating that the first voting set is missing votes in the pre-submission stage compared to the second voting set, the pre-submission stage votes missing from the first voting set are extracted from the second voting set, and the missing pre-submission stage votes are added to the first voting set.

9. The method according to claim 5, characterized in that After comparing the generated first consensus state information with the second consensus state information, the method further includes: In response to the first comparison result indicating that the second consensus state information is missing compared to the first consensus state information, the first consensus state information is sent to the second node device so that The second node device updates the second consensus state information generated by the second node device according to the first consensus state information, wherein the content updated by the second node device includes at least one of the following: a proposal hash code and a voting set.

10. The method according to claim 5, characterized in that After comparing the generated first consensus state information with the second consensus state information, the method further includes: In response to the first comparison result indicating that the second consensus state information is missing compared to the first consensus state information, the missing content of the second consensus state information is sent to the second node device so that The second node device updates the second consensus state information generated by the second node device according to the missing content, wherein the content updated by the second node device includes at least one of the following: a proposal hash code and a voting set.

11. The method according to any one of claims 1 to 10, characterized in that: The first node device stores a consensus state map, and the consensus state map is used to store the node device identification and consensus state information of each node device connected to the first node device in the form of a key-value pair, wherein the consensus state information is a value in the key-value pair, and the node device identification is a key in the key-value pair; After receiving the second consensus state information generated by the second node device, the method further includes: Extracting a node device identifier of the second node device from the second consensus state information; Based on the node device identifier of the second node device, querying the consensus state information of the second node device recorded in the consensus state map; Based on the received second consensus status information, replace the recorded consensus status information of the second node device.

12. A consensus processing system for a blockchain network, characterized in that: The blockchain network includes a plurality of node devices including a first node device, wherein the first node device is any node device in the blockchain system, and the plurality of node devices connected to the first node device include at least a second node device and a third node device, and the third node device is not connected to the second node device; The second node device is used to send the generated second consensus state information to the node devices connected in the blockchain network; The first node device is used to receive the second consensus state information; The first node device is used to compare the generated first consensus state information with the second consensus state information, and update the first consensus state information based on a first comparison result obtained by the comparison; The first node device is used to send the updated first consensus state information to the third node device; The third node device is used to update the third consensus state information generated by the third node device according to the updated first consensus state information.

13. An electronic device, characterized in that: The electronic device comprises: A memory for storing computer executable instructions; The processor is used to implement the consensus processing method of the blockchain network described in any one of claims 1 to 11 when executing the computer executable instructions or computer programs stored in the memory.

14. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that: When the computer executable instructions or computer program are executed by a processor, the method according to any one of claims 1 to 11 is implemented.

15. A computer program product comprising computer executable instructions or a computer program, characterized in that When the computer executable instructions or computer program are executed by a processor, the method according to any one of claims 1 to 11 is implemented.