Blockchain-based data processing method, apparatus, electronic device and storage medium
By dividing network areas in the blockchain network and selecting nodes with higher reputation values as consensus nodes, the problem of inefficiency of consensus is solved, and faster block chaining and more efficient consensus process is achieved.
Patent Information
- Application Number
- CN202210622305.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-02
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2042-06-02
AI Technical Summary
In blockchain networks, consensus algorithms are inefficient due to too many participating nodes, resulting in too long consensus on transaction data, and may even lead to consensus failure.
By dividing the blockchain network into multiple network areas, each network area selects a blockchain node as the consensus node during the current term, and rotates according to the reputation value of the nodes to reduce the number of nodes participating in the consensus.
Improve consensus efficiency, shorten the time for blocks to be on the chain, and avoid consensus failures caused by too slow consensus or timeout.
Smart Images

Figure CN115118733B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of blockchain technology, and in particular, to a data processing method, apparatus, electronic device, and storage medium based on blockchain. Background Art
[0002] In the field of blockchain technology, each transaction data needs to be consensus-approved before being written to the blockchain. In the related consensus algorithms (divided into Byzantine and non-Byzantine types), all blockchain nodes in the blockchain network participate in the consensus. In the case of a large number of blockchain nodes in the blockchain network (for example, when applying the above consensus algorithm to a public chain), if each blockchain node participates in the consensus processing of transaction data, on the one hand, the consensus algorithms in the related technologies will be slow due to too many blockchain nodes participating in the consensus, resulting in a long time required for each transaction data to be consensus-approved and written to the blockchain. Even, the consensus may fail due to too slow consensus or timeout. On the other hand, the pure network communication part will become the main factor hindering the consensus. Summary of the Invention
[0003] Embodiments of the present disclosure provide a data processing method, apparatus, electronic device, and storage medium based on blockchain, thereby at least to some extent solving the problem of low consensus efficiency existing in the related technologies.
[0004] Embodiments of the present disclosure propose a data processing method based on blockchain. The blockchain network includes a first network area, and the first network area includes a first blockchain node. Wherein, the method is executed by the first blockchain node, and the method includes: determining that the first blockchain node belongs to the first network area in the blockchain network; determining, according to the current credit value of the blockchain nodes in the first network area, that the first blockchain node is the first consensus node of the first network area in the current term; during the current term, performing the consensus of the block in the current term in the blockchain corresponding to the blockchain network; updating the current credit value of the blockchain nodes in the first network area to determine the next credit value of the blockchain nodes in the first network area; determining, according to the next credit value of the blockchain nodes in the first network area, the first consensus node of the first network area in the next term. Wherein, the first consensus node in the next term is used to perform the consensus of the block in the next term in the blockchain corresponding to the blockchain network during the next term.
[0005] An embodiment of the present disclosure provides a data processing device based on a blockchain. The blockchain network includes a first network area, and the first network area includes a first blockchain node. Wherein, the device is executed by the first blockchain node, and the device includes: a determination module, configured to determine that the first blockchain node belongs to the first network area in the blockchain network; the determination module is further configured to determine, according to the current reputation value of the blockchain nodes in the first network area, that the first blockchain node is the first consensus node of the first network area in the current term; a processing module, configured to, in the current term, perform consensus on the blocks in the current term of the blockchain corresponding to the blockchain network; the determination module is further configured to update the current reputation value of the blockchain nodes in the first network area and determine the next reputation value of the blockchain nodes in the first network area; the determination module is further configured to determine, according to the next reputation value of the blockchain nodes in the first network area, the first consensus node of the first network area in the next term; wherein, the first consensus node in the next term is configured to, in the next term, perform consensus on the blocks in the next term of the blockchain corresponding to the blockchain network.
[0006] In some exemplary embodiments of the present disclosure, the blockchain network further includes a second network area. The determination module is configured to obtain first probe node information of the first network area and second probe node information of the second network area; obtain a first network delay between the first blockchain node and a first probe node corresponding to the first probe node information, and a second network delay between the first blockchain node and a second probe node corresponding to the second probe node information; determine, according to the first network delay and the second network delay, that the first blockchain node belongs to the first network area; and assign the first network address of the first blockchain node to the first area identifier of the first network area.
[0007] In some exemplary embodiments of the present disclosure, the device further includes: an acquisition module, configured to obtain the number of currently created network areas and the number of current blockchain nodes in the blockchain network; the determination module is further configured to determine the creation of the first network area according to the number of currently created network areas and the number of current blockchain nodes; and determine the first probe node of the first network area according to the currently created network area information.
[0008] In some exemplary embodiments of the present disclosure, the determination module is configured to, if the number of currently created network areas is n and the number of current blockchain nodes is m n , then determine the creation of the first network area; where n is a positive integer greater than or equal to 1, and m is a positive integer greater than or equal to 2.
[0009] In some exemplary embodiments of the present disclosure, the currently created network area information includes information of the blockchain node with the highest network latency in each currently created network area; wherein, the determining module is configured to determine the first detection node of the first network area according to the information of the blockchain node with the highest network latency in each currently created network area.
[0010] In some exemplary embodiments of the present disclosure, the determining module is configured to obtain the configuration file of the blockchain network; generate a first area identifier of the first network area according to the configuration file, and determine that the first blockchain node belongs to the first network area; assign the first network address of the first blockchain node to the first area identifier.
[0011] In some exemplary embodiments of the present disclosure, the determining module is further configured to, if the first blockchain node is the first blockchain node in the first network area, use the first blockchain node as the first detection node of the first network area.
[0012] In some exemplary embodiments of the present disclosure, the determining module is configured to exclude blockchain nodes in the first network area whose current reputation value is lower than the reputation value threshold; determine the first blockchain node as the first consensus node in the current term according to a positive correlation between the current reputation value and the probability that the blockchain node in the corresponding first network area is elected as the first consensus node in the current term.
[0013] In some exemplary embodiments of the present disclosure, the blockchain network further includes a second network area; wherein, the processing module is configured to determine the first blockchain node as the primary node in the current term; receive a transaction sent by a client, and store the received transaction in the first transaction pool of the first blockchain node; extract a target transaction from the first transaction pool, and package the target transaction into a block; send a proposal message of the block to the second consensus node in the second network area in the current term to complete the consensus of the block; the apparatus further includes a synchronization module configured to synchronize the transactions in the first transaction pool to the primary node in the next term when the current term expires.
[0014] In some exemplary embodiments of the present disclosure, the blockchain network further includes a second network area; wherein, the processing module is configured to send a network connection message to the second consensus node in the second network area in the current term, and the network connection message is used to instruct the second consensus node to establish a peer-to-peer network connection with the first blockchain node; when a predetermined proportion of the consensus nodes in the blockchain network complete the peer-to-peer network connection in the current term, perform the consensus of the block in the current term in the blockchain corresponding to the blockchain network.
[0015] In some exemplary embodiments of the present disclosure, the synchronization module is further configured to synchronize the current block to the remaining blockchain nodes in the first network area except the first blockchain node when the current block in the current term is chained to the first blockchain node.
[0016] In some exemplary embodiments of the present disclosure, the second synchronization module is further configured to receive a synchronization request from a non-consensus node in the first network area; and synchronize the current block to the remaining blockchain nodes in the first network area except the first blockchain node when the current block in the current term is chained to the first blockchain node according to the synchronization request.
[0017] In some exemplary embodiments of the present disclosure, the second synchronization module is configured to obtain preset number of first target blockchain node information according to the index of the blockchain nodes in the first network area when the current block is chained to the first blockchain node; and send a synchronization instruction to the first target blockchain nodes corresponding to the first target blockchain node information, where the synchronization instruction is used to synchronize the current block to the first target blockchain nodes and instruct the first target blockchain nodes to synchronize the current block to the preset number of second target blockchain nodes.
[0018] In some exemplary embodiments of the present disclosure, the third determination module is configured to obtain the historical reputation value increase / decrease information and / or the initial reputation value of the first blockchain node; if it is determined that the first blockchain node has completed the consensus of the block in the current term, increase the current reputation value according to the historical reputation value increase / decrease information and / or the initial reputation value to obtain the next reputation value of the first blockchain node; if it is determined that the first blockchain node has not completed the consensus of the block in the current term, decrease the current reputation value of the first blockchain node according to the historical reputation value increase / decrease information and / or the initial reputation value to obtain the next reputation value of the first blockchain node.
[0019] In some exemplary embodiments of the present disclosure, the fourth determination module is configured to start a timer for the term duration when it is determined that the first blockchain node is the first consensus node of the first network area in the current term; and determine whether the duration for which the first blockchain node has been the first consensus node of the first network area in the current term exceeds the term duration through the timer each time the consensus of the block in the current term is completed; if it exceeds the term duration, determine the first consensus node of the first network area in the next term according to the next reputation value of the blockchain nodes in the first network area.
[0020] In some exemplary embodiments of the present disclosure, the fourth determination module is configured to obtain the number of term blocks; record the previous block height when determining that the first blockchain node is the first consensus node of the first network area during the current term; and when the consensus of the blocks during the current term is completed each time, determine whether the difference between the current block height of the first blockchain node and the previous block height is not less than the number of term blocks; if it is not less than the number of term blocks, determine the first consensus node of the first network area during the next term according to the next reputation value of the blockchain nodes in the first network area.
[0021] An embodiment of the present disclosure provides an electronic device, including: at least one processor; a storage device configured to store at least one program, and when the at least one program is executed by the at least one processor, the at least one processor is caused to implement the blockchain-based data processing method as described in the above embodiments.
[0022] An embodiment of the present disclosure provides a computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, the blockchain-based data processing method as described in the above embodiments is implemented.
[0023] An embodiment of the present disclosure provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the blockchain-based data processing method provided in the above various optional implementation manners.
[0024] In the technical solutions provided by some embodiments of the present disclosure, on the one hand, the blockchain network is divided into a first network area, then the first blockchain node belonging to the first network area is determined, and the first blockchain node is determined as the first consensus node of the first network area during the current term, so that the first blockchain node executes the consensus process of the block in the current term in the blockchain corresponding to the blockchain network during the current term. That is, the consensus node in the current term is determined by means of network area division, and it is not necessary for all blockchain nodes in the blockchain network to participate in the consensus, which greatly reduces the number of blockchain nodes participating in the consensus. Therefore, the consensus efficiency can be improved, the speed of block chain-on is accelerated, and the consensus failure caused by too slow or timeout of consensus is avoided. On the other hand, after determining that the first blockchain node belongs to the first network area, the current reputation value of the blockchain nodes in the first network area is obtained, and the first blockchain node is determined as the first consensus node of the first network area during the current term according to the current reputation value of the blockchain nodes in the first network area. After that, the first blockchain node elected as the first consensus node of the first network area during the current term participates in the consensus of the blocks in the blockchain during the current term, and updates the current reputation value of the blockchain nodes in the first network area after the end of the current term. According to the next reputation value of the blockchain nodes in the first network area after the update, the first consensus node of the next term is determined. That is, by means of selecting the first consensus node of the first network area in each term (including the current term and the next term) through the reputation value (including the above current reputation value and the next reputation value), the interference of human factors in determining the first consensus node in each term is avoided, making the election of the first consensus node more fair.
[0025] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure. Obviously, the accompanying drawings in the following description are only some embodiments of the present disclosure, and those of ordinary skill in the art can obtain other drawings without creative efforts based on these drawings.
[0027] Figure 1 It is a schematic diagram of the system structure provided by the embodiments of the present disclosure.
[0028] Figure 2 It schematically shows a flowchart of a data processing method based on blockchain according to an embodiment of the present disclosure.
[0029] Figure 3Schematically shows a schematic diagram of the relationship between the number of blockchain nodes and the number of network regions in an embodiment of the present disclosure.
[0030] Figure 4 Schematically shows a schematic diagram of newly added blockchain nodes being assigned to corresponding network regions in an embodiment of the present disclosure.
[0031] Figure 5 Schematically shows a schematic diagram of the relationship between the first consensus node and each blockchain node in the first network region in an embodiment of the present disclosure.
[0032] Figure 6 Schematically shows a schematic diagram of the relationship between the probability of a blockchain node being elected as the first consensus node and the reputation value in an embodiment of the present disclosure.
[0033] Figure 7 Schematically shows a schematic diagram of the peer-to-peer connection between the first blockchain node, the third consensus node, and the fourth consensus node in an embodiment of the present disclosure.
[0034] Figure 8 Schematically shows a schematic diagram of the sending process of the proposal message of a block in an embodiment of the present disclosure.
[0035] Figure 9 Schematically shows a schematic diagram of a client sending a transaction to a transaction pool when the blockchain network adopts the Raft type of consensus algorithm in an embodiment of the present disclosure.
[0036] Figure 10 Schematically shows a schematic diagram of a client sending a transaction to a transaction pool when the blockchain network adopts the BFT type of consensus algorithm in an embodiment of the present disclosure.
[0037] Figure 11 Schematically shows a schematic diagram of the sending process of a synchronization instruction in an embodiment of the present disclosure.
[0038] Figure 12 Schematically shows a schematic diagram of the change of the reputation value of a blockchain node in an embodiment of the present disclosure.
[0039] Figure 13 Schematically shows a flowchart for determining whether the term of the first blockchain node as the first consensus node has ended in an embodiment of the present disclosure.
[0040] Figure 14 Schematically shows a block diagram of a data processing device based on a blockchain according to an embodiment of the present disclosure.
[0041] Figure 15 Shows a schematic structural diagram of an electronic device suitable for implementing the embodiments of the present disclosure. Detailed implementation
[0042] Example embodiments will now be described more fully with reference to the accompanying drawings. However, the example embodiments can be implemented in various forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art.
[0043] In addition, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of the embodiments of the present disclosure. However, those skilled in the art will realize that the technical solutions of the present disclosure can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be employed. In other cases, well-known methods, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the present disclosure.
[0044] The block diagrams shown in the drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software form, or implemented in at least one hardware module or integrated circuit, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0045] The flowcharts shown in the drawings are merely illustrative and not necessarily include all of the content and operations / steps, nor are they necessarily executed in the order described. For example, some operations / steps can be decomposed, while some operations / steps can be combined or partially combined, so the actual execution order may change according to the actual situation.
[0046] The embodiments of the present disclosure are applied to blockchain technology. For example, the system involved in the embodiments of the present disclosure can be a system formed by connecting a client and multiple blockchain nodes (any form of computing device accessing the network, such as a server, user terminal) through network communication.
[0047] See Figure 1 , Figure 1 is a schematic diagram of the system structure provided by the embodiments of the present disclosure. The system can include a blockchain network and a client 120, where the blockchain network can include multiple blockchain nodes 110 (which can also be simply referred to as nodes and can be any form of computing device accessing the network, such as a server, user terminal).
[0048] Figure 1 In the embodiments, the blockchain network can be divided into at least one network area, for example Figure 1The network regions 1 to n shown in the figure, where n is a positive integer greater than or equal to 1. Each network region may include at least one node. For example, it is assumed that network region 1 includes nodes 1, 2 to k, where k is a positive integer greater than or equal to 1, and network region n includes nodes L, L + 1 to L + H, where L is a positive integer greater than K and H is a positive integer greater than or equal to 1.
[0049] In some embodiments of the present disclosure, the number of network regions may be positively correlated with the number of nodes. Exemplarily, if the current number of blockchain nodes (i.e., the number of nodes that have currently joined the blockchain network) is m n , then the currently created number of network regions (i.e., the number of network regions that have currently been created) is n. Wherein, m is a positive integer greater than or equal to 2, and n is a positive integer greater than or equal to 1.
[0050] Each network region 130 corresponds to a consensus node that conducts consensus on transactions within the current term. Communication connections can be achieved between consensus nodes based on a peer-to-peer (P2P) network. The P2P protocol is an application layer protocol running on top of the Transmission Control Protocol (TCP). Communication connections can be achieved between the nodes included in each network region based on an infection network. The connection between the consensus node and other non-consensus nodes (also referred to as remaining blockchain nodes) in the network region belongs to the connection between the network region nodes.
[0051] In Figure 1 the system shown, the client 120 can send a transaction request to the consensus node or the primary node in the node 110 through the network. Among them, the primary node is a consensus node selected from the consensus nodes, which is used to package the transaction into a block and broadcast the proposal of the block to other consensus nodes.
[0052] Among them, the network used by the client 120 to send transaction requests can be a wireless network or a wired network using standard communication technologies and / or protocols. The network is usually the Internet, but can also be any network, including but not limited to any combination of a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a private network or a virtual private network). In some embodiments, technologies and / or formats including Hyper Text Mark-up Language (HTML), Extensible Markup Language (XML), etc. are used to represent the data exchanged through the network. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec), etc. can be used to encrypt all or some of the links. In other embodiments, custom and / or dedicated data communication technologies can also be used to replace or supplement the above data communication technologies.
[0053] The client 120 can be an electronic device capable of sending transaction requests to the consensus node or the master node. The electronic device can be a smart phone, a computer, a server, etc., and the embodiments of the present disclosure do not limit this.
[0054] Figure 2 Schematically shown is a flowchart of a blockchain-based data processing method according to an embodiment of the present disclosure. The blockchain-based data processing method provided by the embodiments of the present disclosure can be processed by any electronic device with computing and processing capabilities. For example, the electronic device with computing and processing capabilities is Figure 1 any one of the nodes included in any one of the network regions 130. Among them, any one of the nodes executing the blockchain-based data processing method can be called a first blockchain node, and the network region where the first blockchain node is located is the first network region.
[0055] As Figure 2 shown, the blockchain-based data processing method provided by the embodiments of the present disclosure can include the following steps S201 to step S205.
[0056] Step S201, determine that the first blockchain node belongs to the first network region in the blockchain network.
[0057] In the embodiments of the present disclosure, a network area is a group obtained by dividing the blockchain nodes included in a blockchain network, and includes a certain number of blockchain nodes. The first network area can be any network area in the blockchain network.
[0058] For example, assume that the blockchain network includes a total of 100 blockchain nodes. After dividing the 100 blockchain nodes into 5 network areas, each network area includes a part of the blockchain nodes.
[0059] In some embodiments of the present disclosure, creating a network area includes generating a network area identifier (identity, ID) corresponding to the network area. The network area ID can adopt any identification method, such as any one or more of numbers, letters, symbols, etc. The present disclosure does not limit this, as long as each network area can be uniquely distinguished.
[0060] Among them, when a certain blockchain node is divided into a certain network area, the network address of the blockchain node (for example, the IP (Internet Protocol) address) can be assigned under the network area identifier of the network area, that is, the blockchain node is registered under the network area to indicate that the blockchain node is assigned to the network area.
[0061] In some embodiments of the present disclosure, during initialization, network areas can be created based on the configuration file of the blockchain network. Initially, when the first batch of blockchain nodes is started, each blockchain node will load the same configuration file, and each blockchain node can create the initial network areas specified in the configuration file according to the configuration file, and divide each blockchain node in the first batch of blockchain nodes into the corresponding network areas.
[0062] For example, assume that the configuration file of the blockchain network specifies that initially, two initial network areas, Network Area 1 and Network Area 2, are created, and the first blockchain node and the second blockchain node are divided into Network Area 1, and the third blockchain node and the fourth blockchain node are divided into Network Area 2.
[0063] In the embodiments of the present disclosure, the configuration file of the blockchain network may include a network area control algorithm, and the network area control algorithm can be used to create n network areas when the number of blockchain nodes is m n ; when the number of current blockchain nodes is m n , and a new blockchain node is added, create n + 1 network areas. Where n is a positive integer greater than or equal to 1, and m is a positive integer greater than or equal to 2.
[0064] In the following examples, m is configured as 2 for illustration, but the present disclosure is not limited thereto.
[0065] For example, when the number of blockchain nodes joining the blockchain network is 5, which is greater than 2, at this time, the number of network regions that have been created according to the configuration file of the blockchain network is 2, then a new network region can be created, which can be called network region 3.
[0066] In some other embodiments of the present disclosure, according to the configuration file, the number of initial network regions corresponding to the number of the first batch of started blockchain nodes can be created, and a blockchain node is respectively designated from the first batch of started blockchain nodes as the detection node of the corresponding initial network region. Then, according to the detection nodes of each initial network region, among the first batch of started blockchain nodes, other blockchain nodes except the detection nodes of each initial network region are respectively allocated to each initial network region.
[0067] For example, assume that m is configured as 2 and the number of the first batch of started blockchain nodes is 4, then the number of initial network regions created is 2, assumed to be network region 1 and network region 2 respectively. In the configuration file, node 1 is respectively used as the detection node of network region 1, and node 3 is used as the detection node of network region 2. Then, node 2 can send detection packets to node 1 and node 3 respectively, detect the network latency between node 2 and node 1, and between node 2 and node 3, and divide node 2 into network region 1 corresponding to node 1 with a smaller network latency. Node 4 can send detection packets to node 1 and node 3 respectively, detect the network latency between node 4 and node 1, and between node 4 and node 3, and divide node 4 into network region 2 corresponding to node 2 with a smaller network latency.
[0068] In some other embodiments of the present disclosure, through the configuration file, the first blockchain node joining a certain network region can be used as the detection node of this network region. For example, network region 1 can be created first, and the first blockchain node is designated and allocated to network region 1, and the first blockchain node is used as the detection node of network region 1. Then, the second blockchain node is allocated to network region 1. When the third blockchain node is started, according to the configuration file, since 3 is greater than 2 1 , then network region 2 is created, and the second blockchain node is added to network region 2, and the second blockchain node is used as the detection node of network region 2. Then, blockchain node 3 and blockchain node 4 are respectively added to network region 1 or network region 2 according to the network latency.
[0069] The detection node in the embodiments of the present disclosure refers to the blockchain node in each network region for detecting the network latency of the blockchain nodes newly joining the blockchain network.
[0070] In some further embodiments of the present disclosure, through the network area control algorithm, in each blockchain node that joins a certain network area, the information of the blockchain node with the highest network latency can be recorded under the network area identifier corresponding to the network area for determining the probing node of the newly created network area.
[0071] For example, assume that the current number of created network areas is 4, which are respectively called network area 1, network area 2, network area 3, and network area 4. Network area 1 includes node 1 and node 2, network area 2 includes node 3 and node 4, network area 3 includes node 5, node 6, node 7, and node 8, network area 4 includes node 9, node 10, node 11, node 12, node 13, node 14, node 15, and node 16. Assume that the probing node of network area 1 is node 1, the probing node of network area 2 is assumed to be node 3, the probing node of network area 3 is assumed to be node 5, and the probing node of network area 4 is assumed to be node 9. Record that the network latency from node 2 to node 1 is 10 ms, the network latency from node 4 to node 3 is 20 ms. Node 7 is the node with the highest network latency between node 5 in network area 3, and this network latency is 25 ms. Node 12 is the node with the highest network latency between node 9 in network area 4, and this network latency is 30 ms. Then when creating a new network area 5, use this node 12 as the probing node of network area 5, and delete node 12 from network area 4 and add it to network area 5.
[0072] After generating the initial network area according to the configuration file of the blockchain network, when there are newly added blockchain nodes subsequently, it is possible to determine when to create a new network area based on the network area control algorithm, and how to configure network area identifiers for each network area. The blockchain nodes are all assigned to the corresponding network areas based on the network area control algorithm.
[0073] In some embodiments of the present disclosure, in addition to including a first network area, the blockchain network may further include a second network area, and the second network area may be any network area other than the first network area.
[0074] Among them, determining that the first blockchain node belongs to the first network area in the blockchain network may include: obtaining the first probing node information of the first network area and the second probing node information of the second network area; obtaining the first network latency between the first blockchain node and the first probing node corresponding to the first probing node information, and the second network latency between the first blockchain node and the second probing node corresponding to the second probing node information; determining that the first blockchain node belongs to the first network area according to the first network latency and the second network latency; and assigning the first network address of the first blockchain node to the first area identifier of the first network area.
[0075] Among them, the first blockchain node may store the detection node information of the detection nodes in each network area included in the blockchain network. The detection node information can be used to uniquely determine each detection node and know which network area the detection node belongs to. For example, it may include the IP address and / or node ID of each detection node, and the network area ID of the network area to which the detection node belongs. The detection node information may include first detection node information and second detection node information.
[0076] In the embodiments of the present disclosure, the first detection node refers to the detection node in the first network area. The first detection node information may include the IP address and / or node ID of the first detection node, and the first network area ID of the first network area to which the first detection node belongs. The second detection node refers to the detection node in the second network area. The second detection node information may include the IP address and / or node ID of the second detection node, and the second network area ID of the second network area to which the second detection node belongs.
[0077] In some embodiments of the present disclosure, obtaining the first network delay between the first blockchain node and the first detection node corresponding to the first detection node information, and the second network delay between the first blockchain node and the second detection node corresponding to the second detection node information may include: The first blockchain node sends a first detection message for detecting network delay to the first detection node according to the network address of the first detection node, and records the sending time of the first detection message. After receiving the first feedback message of the first detection node, according to the time difference between the sending time of the first detection message and the receiving time of the first feedback message, obtain the first network delay between the first blockchain node and the first detection node; The first blockchain node sends a second detection message for detecting network delay to the second detection node according to the network address of the second detection node, and records the sending time of the second detection message. After receiving the second feedback message of the second detection node, according to the time difference between the sending time of the second detection message and the receiving time of the second feedback message, obtain the second network delay between the first blockchain node and the second detection node.
[0078] The network delay in the embodiments of the present disclosure can be detected by RTT (Round Trip Time), but the present disclosure does not limit the detection method of network delay.
[0079] In some embodiments of the present disclosure, determining that the first blockchain node belongs to the first network area according to the first network delay and the second network delay may include: comparing the magnitudes of the first network delay and the second network delay, and determining that the first blockchain node belongs to the first network area when the first network delay is less than the second network delay.
[0080] Since the transmission path between two nodes that are farther apart physically is usually longer and the network latency is greater, the method of assigning the first blockchain node to the network area corresponding to the smaller network latency can enable the first blockchain node to be assigned to the network area corresponding to the probing node that is closer physically. Further, in each network area, the blockchain nodes are more concentrated physically.
[0081] After determining that the first blockchain node belongs to the first network area, assign the first network address of the first blockchain node to the first area identifier of the first network area. In some embodiments of the present disclosure, assigning a blockchain node to a corresponding network area may include: assigning the network address of the blockchain node to the network area identifier of the corresponding network area. When the network address of a certain blockchain node is included under the network area identifier of the network area, it indicates that the certain blockchain node belongs to the network area.
[0082] It should be noted that the number of second network areas can be multiple, and there are multiple corresponding second probing nodes. Correspondingly, the second network latency may include the network latency between the first blockchain node and the multiple second probing nodes. In some embodiments of the present disclosure, the number of second network areas is determined based on the number of network areas included in the blockchain network. For example, the blockchain network includes network areas 1-3, where network area 1 is the first network area, then network areas 2 and 3 are both second network areas.
[0083] In some embodiments of the present disclosure, before determining that the first blockchain node belongs to the first network area in the blockchain network, it may further include: obtaining the number of currently created network areas and the number of current blockchain nodes in the blockchain network; determining to create the first network area according to the number of currently created network areas and the number of current blockchain nodes; determining the first probing node of the first network area according to the currently created network area information.
[0084] In the embodiments of the present disclosure, each blockchain node stores the number of currently created network areas and the number of current blockchain nodes in the blockchain network.
[0085] In some embodiments of the present disclosure, determining to create the first network area according to the number of currently created network areas and the number of current blockchain nodes may include: if the number of currently created network areas is n and the number of current blockchain nodes is m n , then determine to create the first network area; where n is a positive integer greater than or equal to 1, and m are all positive integers greater than or equal to 2. For example, if the number of currently created network areas is 3 and the number of current blockchain nodes is 2 3 , then determine to create the first network area.
[0086] Exemplarily, as Figure 3 shown, when m is 2 and the number of blockchain nodes is 4, the blockchain network includes 2 network regions; when the number of blockchain nodes is 8, the blockchain network includes 3 network regions; when the number of blockchain nodes is 16, the blockchain network includes 3 network regions; when the number of blockchain nodes is 2 32 = 4,294,967,296, the blockchain network includes 32 network regions.
[0087] In some embodiments of the present disclosure, the currently created network region information includes the information of the blockchain node with the highest network latency in each currently created network region. Determining the first detection node of the first network region according to the currently created network region information includes: determining the first detection node of the first network region according to the information of the blockchain node with the highest network latency in each currently created network region.
[0088] For example, the currently created network region information indicates that 3 network regions have been currently created. The highest network latency between the blockchain nodes and the corresponding detection nodes in the first network region is 10 ms (milliseconds), the highest network latency between the blockchain nodes and the corresponding detection nodes in the second network region is 15 ms, and the highest network latency between the blockchain nodes and the corresponding detection nodes in the first network region is 5 ms. Then, the blockchain node with the highest network latency in each currently created network region is the blockchain node in the second network region with a network latency of 15 ms with the corresponding detection node. The information of the blockchain node with the highest network latency in each currently created network region is the information of the blockchain node corresponding to the 15 ms. It is determined that the blockchain node corresponding to the 15 ms is the detection node of the newly created fourth network region. In some embodiments of the present disclosure, the information of the blockchain node corresponding to the 15 ms is the network address and / or node ID of the blockchain node.
[0089] In some embodiments of the present disclosure, after determining the first detection node of the first network region according to the information of the blockchain node with the highest network latency in each currently created network region, it further includes: removing the information of the blockchain node with the highest network latency from the region identifier of the corresponding network region and adding it to the region identifier of the first network region.
[0090] In some embodiments of the present disclosure, determining that the first blockchain node belongs to the first network region in the blockchain network may include: obtaining the configuration file of the blockchain network; generating the first region identifier of the first network region according to the configuration file, and determining that the first blockchain node belongs to the first network region; allocating the first network address of the first blockchain node to the first region identifier.
[0091] Each blockchain node included in the blockchain network stores a configuration file. In some embodiments of the present disclosure, obtaining the configuration file of the blockchain network includes: obtaining the configuration file of the blockchain network from local storage.
[0092] In some embodiments of the present disclosure, determining that the first blockchain node belongs to the first network area may include: the configuration file directly indicates that the first blockchain node belongs to the first network area, or, by comparing the network latency between the first blockchain node and the detection nodes of each network area, when the network latency between the detection nodes corresponding to the first network area is the smallest, it is determined that the first blockchain node belongs to the first network area.
[0093] In some embodiments of the present disclosure, after the first network address of the first blockchain node is assigned to the first area identifier, that is, the assignment of the first blockchain node to the first network area is completed. If the first blockchain node is the first blockchain node in the first network area, then the first blockchain node is used as the first detection node of the first network area.
[0094] To facilitate understanding of how to assign a newly added blockchain node to the corresponding network area after adding a blockchain node to the blockchain network, the following takes the blockchain network including 5 network areas as an example for illustration. As Figure 4 shown, the network latencies between the newly added blockchain node and the detection nodes of the 5 network areas are 1ms, 10ms, 15ms, 20ms, and 100ms respectively. According to the network latency, the newly added blockchain node is assigned to network area 1, and the network latency of the newly added blockchain node is recorded as 1ms. It should be noted that assigning the newly added blockchain node to network area 1 means adding the network address of the newly added blockchain node to the area identifier of network area 1.
[0095] In some embodiments of the present disclosure, there is no limit on the number of blockchain nodes that can be accommodated in any network area included in the blockchain network.
[0096] Step S202, determine that the first blockchain node is the first consensus node of the first network area during the current term according to the current reputation value of the blockchain nodes in the first network area.
[0097] The relationship between the first consensus node and each blockchain node in the first network area is as Figure 5 shown, and the first consensus node is selected from each blockchain node in the first network area.
[0098] When each blockchain node joins the blockchain network, it will be assigned an initial reputation value. The size of the initial reputation value is set according to experience, and the embodiments of the present disclosure do not limit this. Exemplarily, the initial reputation value of each blockchain node when joining the blockchain network is 1024. The reputation value of a blockchain node is positively correlated with the probability of the blockchain node being selected as a consensus node.
[0099] In some embodiments of the present disclosure, determining that the first blockchain node is the first consensus node of the first network area in the current term according to the current reputation value of the blockchain nodes in the first network area includes: excluding the blockchain nodes in the first network area whose current reputation value is lower than the reputation value threshold; determining that the first blockchain node is the first consensus node in the current term according to that the current reputation value is positively correlated with the probability of the corresponding blockchain node in the first network area being elected as the first consensus node in the current term.
[0100] In the blockchain network, during the term of a blockchain node as a consensus node, a certain reputation value will be increased or decreased based on the performance of the blockchain node. When the reputation value of a blockchain node is lower than the reputation value threshold, it is considered that the blockchain node has performed poorly during its previous term as a consensus node. Therefore, it is stipulated that when the reputation value of a blockchain node is lower than the reputation value threshold, it cannot participate in the election of consensus nodes. Wherein, the reputation value threshold is a set value, and the embodiments of the present disclosure do not limit this. Exemplarily, the reputation value threshold is 0.
[0101] In some embodiments of the present disclosure, determining that the first blockchain node is the first consensus node in the current term according to that the current reputation value is positively correlated with the probability of the corresponding blockchain node in the first network area being elected as the first consensus node in the current term includes: calculating the sum of the current reputation values of the blockchain nodes in the first network area, taking the ratio of the current reputation value of each blockchain node in the first network area to the sum of the current reputation values of the blockchain nodes in the first network area as the probability of each blockchain node in the first network area being elected as the first consensus node; according to the probabilities corresponding to each blockchain node in the first network area; when the selected blockchain node according to the probability of each blockchain node in the first network area being elected as the first consensus node is the first blockchain node, determining that the first blockchain node is the first consensus node of the first network area in the current term.
[0102] Exemplarily, such as Figure 6As shown, the first network area includes blockchain nodes 1-4. The reputation values of blockchain nodes 1-3 are all 1024, and the reputation value of blockchain node 4 is 512. Then the sum of the reputation values of blockchain nodes 1-4 is 1024*3 + 512 = 3584. The ratio of the reputation values of blockchain nodes 1-3 to the sum of the reputation values of blockchain nodes 1-4 is 2 / 7, and the ratio of the reputation value of blockchain node 4 to the sum of the reputation values of blockchain nodes 1-4 is 1 / 7. Correspondingly, the probability that blockchain nodes 1-3 are elected as the first consensus nodes in the current term of the first network area is 2 / 7, and the probability that blockchain node 4 is elected as the first consensus node in the current term of the first network area is 1 / 7.
[0103] Step S203, in the current term, perform the consensus of the blocks in the current term of the blockchain corresponding to the blockchain network.
[0104] Generally, the number of network areas included in the blockchain network is small. Correspondingly, the number of consensus nodes corresponding to the network area is also small. In this case, the peer-to-peer connection method among the consensus nodes can more efficiently complete the consensus of the blocks.
[0105] In some embodiments of the present disclosure, in addition to the first network area, the blockchain network further includes a second network area. In the current term, performing the consensus of the blocks in the current term of the blockchain corresponding to the blockchain network includes: sending a network connection message to the second consensus node or the second detection node in the current term of the second network area, where the network connection message is used to instruct the second consensus node to establish a peer-to-peer network connection with the first blockchain node; when a predetermined proportion of the consensus nodes in the blockchain network complete the peer-to-peer network connection in the current term, perform the consensus of the blocks in the current term of the blockchain corresponding to the blockchain network. Wherein, the predetermined proportion is a set value and can be determined according to the consensus algorithm adopted by the blockchain network. For example, when the consensus algorithm adopted by the blockchain network is the Byzantine consensus algorithm, the predetermined proportion is usually 2 / 3. Wherein, the number of the second network areas can be one or more.
[0106] In some embodiments, sending a network connection message to a second consensus node in a second network area during the current term, where the network connection message is used to instruct the second consensus node to establish a peer-to-peer network connection with a first blockchain node, includes: when consensus nodes are first elected in each network area corresponding to the blockchain network, the first blockchain node, which is the first consensus node in the first network area, sends a message to a second detection node to query the information of the second consensus node in the second network area for the current term. Alternatively, when there are consensus nodes in the previous term in each network area corresponding to the blockchain network, the first blockchain node, which is the first consensus node in the first network area, sends a message to the consensus node in the previous term corresponding to the second network area to query the information of the second consensus node in the second network area for the current term. After receiving the message with the information of the second consensus node in feedback, the first blockchain node sends a P2P network connection based on TLS (Transport Layer Security) to the second consensus node for the current term according to the network address of the second consensus node for the current term included in the information of the second consensus node, and maintains this network connection in the connection pool of the first blockchain node. Furthermore, the first blockchain node realizes a peer-to-peer connection with the second consensus node for the current term.
[0107] Among them, each blockchain node in the blockchain network stores the information of blockchain nodes in each network area. According to the second detection node indicated by the information of the blockchain nodes, or the network address of the consensus node in the previous term in the second network area, the first blockchain node can send a network connection message to the second detection node or the consensus node in the previous term in the second network area.
[0108] For example, the blockchain network includes three second network areas, and the corresponding consensus nodes are the second consensus node, the third consensus node, and the fourth consensus node respectively. At this time, the peer-to-peer connections between the first blockchain node and the third consensus node and the fourth consensus node are as Figure 7 shown.
[0109] In some embodiments of the present disclosure, in addition to including the first network area, the blockchain network further includes a second network area. During the current term, performing the consensus of the block in the current term in the blockchain corresponding to the blockchain network includes: determining the first blockchain node as the primary node in the current term; receiving a transaction sent by a client and storing the received transaction in the first transaction pool of the first blockchain node; extracting a target transaction from the first transaction pool, packaging the target transaction into a block; and sending a proposal message of the block to the second consensus node in the second network area during the current term to complete the consensus of the block.
[0110] The embodiments of the present disclosure do not limit the method for determining the first blockchain node as the primary node within the current term. Any method that can select a primary node from multiple nodes can be applied here.
[0111] In some embodiments, sending a proposal message of a block to the second consensus nodes in the second network area within the current term to complete the consensus of the block includes: sending a proposal message of a block to the second consensus nodes in the second network area within the current term based on the P2P network to complete the consensus of the block.
[0112] In some embodiments, there are multiple network areas corresponding to the second network area. Correspondingly, there are multiple consensus nodes corresponding to the second consensus nodes. At this time, sending a proposal message of a block to the second consensus nodes in the second network area within the current term based on the P2P network includes: sending a proposal message of a block to some of the consensus nodes corresponding to the second consensus nodes. After receiving the proposal message, these some consensus nodes send the proposal message to the other consensus nodes among all the consensus nodes corresponding to the second consensus nodes except these some consensus nodes.
[0113] For example, the second network area includes network area 2, network area 3, network area 4, network area 5, network area 6, network area 7 to network area n. Correspondingly, the consensus nodes corresponding to each second network area are consensus node 2 to consensus node n. At this time, the sending process of the proposal message of the block can be as Figure 8 shown in the process. The blockchain node as the first consensus node sends the proposal message to consensus node 2, consensus node 3, and consensus node 4. After receiving the proposal message, consensus node 2 sends the proposal message to consensus node 5, consensus node 6, consensus node 7 to consensus node n. Among them, n is a positive integer greater than 7.
[0114] In some embodiments of the present disclosure, when the current term expires, synchronizing the transactions in the first transaction pool to the primary node in the next term includes: the primary node in the next term sends a transaction synchronization request to the first blockchain node as the primary node in the current term, so that after receiving the transaction synchronization request, the first blockchain node synchronizes the transactions in the first transaction pool to the transaction pool of the primary node in the next term.
[0115] Among them, exemplarily, as Figure 9 shown, when the blockchain network adopts the Raft type of consensus algorithm, the client only sends transactions to the transaction pool of the consensus node elected as the primary node. Exemplarily, as Figure 10 shown, when the blockchain network adopts the BFT type of consensus algorithm, the client sends transactions to the transaction pools of each consensus node, and the consensus node elected as the primary node is responsible for packing the transactions into blocks for proposal. From Figure 9 andFigure 10 As can be seen, whether the Raft type consensus algorithm or the BFT type consensus algorithm is adopted, the client does not send transactions to non-consensus nodes in the blockchain network, and the leader node of the next term is generated from all blockchain nodes in the blockchain network. Therefore, regardless of whether the blockchain network adopts the Raft type consensus algorithm or the BFT type consensus algorithm, the transactions in the transaction pool of the leader node of the next term may lag behind the transactions in the transaction pool of the leader node of the current term. Therefore, synchronizing the transactions in the first transaction pool to the leader node in the next term can better ensure that the transactions sent by the client are not missed.
[0116] After the proposal corresponding to any block is consensus by the consensus nodes in the blockchain network, the consensus nodes will chain the block that passes the consensus to the blockchain stored by the consensus nodes, and then, the consensus nodes will synchronize the block to the blockchains corresponding to other blockchain nodes in the network area where the consensus nodes are located.
[0117] In some embodiments of the present disclosure, when chaining the current block in the current term to the first blockchain node, synchronizing the current block to the remaining blockchain nodes in the first network area except the first blockchain node includes: after chaining the current block in the current term to the blockchain stored by the first blockchain node, synchronizing the current block to the blockchains stored by the remaining blockchain nodes in the first network area except the first blockchain node.
[0118] In some embodiments, the manner of synchronizing the current block to the blockchains stored by the remaining blockchain nodes in the first network area except the first blockchain node includes: active synchronization and passive synchronization.
[0119] Based on the passive synchronization method, synchronizing the current block to the blockchains stored by the remaining blockchain nodes in the first network area except the first blockchain node includes: receiving a synchronization request from a non-consensus node in the first network area; according to the synchronization request, when chaining the current block in the current term to the first blockchain node, synchronizing the current block to the remaining blockchain nodes in the first network area except the first blockchain node.
[0120] In some embodiments, the non-consensus nodes in the first network area periodically check the blockchain height of the consensus nodes in the first network area. When a non-consensus node determines that the height of the saved blockchain is lower than the height of the blockchain of the consensus node, the non-consensus node sends a synchronization request to the consensus node. For example, if the current blockchain height of the non-consensus node is 99 and the current blockchain height of the consensus node is 100, when the non-consensus node periodically checks the height of the blockchain of the consensus node, it determines that the height of the saved blockchain by itself is less than the height of the blockchain saved by the consensus node. At this time, the non-consensus node sends a synchronization request to the consensus node.
[0121] Based on the active synchronization method, synchronize the current block to the blockchains saved by the remaining blockchain nodes in the first network area except the first blockchain node, including: after the first blockchain node uploads the block passed through consensus to the saved blockchain, synchronize the block passed through consensus to other blockchain nodes in the first network area except the first blockchain node.
[0122] In some embodiments, after a blockchain node joins a network area, it will be assigned an index in that network area. For example, if there are already 30 blockchain nodes (including detection nodes) in the network area, then after a newly added blockchain node joins the network area, the assigned index can be 30 (the index starts from 0).
[0123] In some embodiments of the present disclosure, when uploading the current block in the current term to the first blockchain node, synchronize the current block to the remaining blockchain nodes in the first network area except the first blockchain node, including: when uploading the current block to the first blockchain node, obtain the information of a preset number of first target blockchain nodes according to the indexes of the blockchain nodes in the first network area; send a synchronization instruction to the first target blockchain nodes corresponding to the information of the first target blockchain nodes, where the synchronization instruction is used to synchronize the current block to the first target blockchain nodes and instruct the first target blockchain nodes to synchronize the current block to a preset number of second target blockchain nodes. Here, the preset number is a set value, and if the preset number is not set, the default value is used. Exemplarily, the default value can be 8.
[0124] In some embodiments, the synchronization instruction being used to synchronize the current block to the first target blockchain node means that the synchronization instruction is used to synchronize the current block to the blockchain saved by the first target blockchain node. In some embodiments, synchronizing the current block to a preset number of second target blockchain nodes means synchronizing the current block to the blockchains saved by a preset number of second target blockchain nodes. In the subsequent description, synchronizing a block to a blockchain node refers to synchronizing the block to the blockchain saved by the blockchain node.
[0125] In some embodiments, obtaining preset quantity of first target blockchain node information according to the indexes of blockchain nodes in the first network area includes: obtaining the first target blockchain node information with the first preset quantity of indexes from the first network area. For example, when the preset quantity is 8, the first target blockchain node information includes the information of the blockchain nodes with indexes 0-7 in the first network area.
[0126] Exemplarily, the sending process of the synchronization instruction is as Figure 11 shown. Still taking the preset quantity as 8 as an example, first, the first blockchain node sends a synchronization instruction to the blockchain nodes with indexes 0-7. After receiving the synchronization instruction, the blockchain nodes with indexes 0-7 synchronize the current block to the saved blockchain. Then, the blockchain nodes with indexes 0-7 send the synchronization instruction to the next batch of blockchain nodes. For example, the blockchain node with index 0 sends the synchronization instruction to the blockchain nodes with indexes 8-15; after receiving the synchronization instruction, the blockchain node with index 15 synchronizes the current block to the saved blockchain and sends the synchronization instruction to the blockchain nodes with indexes 128-135. By sending the synchronization instruction in an infectious manner, the blockchain nodes in the network area can complete the synchronization of the block faster.
[0127] The relationship between the blockchain node sending the synchronization instruction and the blockchain node receiving the synchronization instruction is: when the index of the blockchain node sending the synchronization instruction is x (x is a positive integer), the indexes of the blockchain nodes receiving the synchronization instruction correspond to [(1 + x) * preset quantity] to [(2 + x) * preset quantity - 1]. For example, when the preset quantity is 8, when the index number of the blockchain node sending the synchronization instruction is x, the index numbers of the blockchain nodes receiving the synchronization instruction are [(1 + x) * 8] to [(2 + x) * 8 - 1]. When the preset quantity is 8, when the index number of the blockchain node sending the synchronization instruction is 15, the index numbers of the blockchain nodes receiving the synchronization instruction are [(1 + 15) * 8] to [(2 + 15) * 8 - 1], that is, 128 to 135.
[0128] Step S204, updating the current reputation value of the blockchain nodes in the first network area and determining the next reputation value of the blockchain nodes in the first network area.
[0129] Among them, the current reputation value refers to the change amount of the reputation value of the blockchain nodes in the first network area during the tenure of the current consensus node. For example, the current reputation value is 0, that is, the change amount of the reputation value is 0. The next reputation value refers to the reputation value of the blockchain nodes in the first network area when electing the consensus node for the next tenure.
[0130] After a blockchain node is elected as a consensus node in the network area where it is located, it participates in the consensus of blocks within a term. After the term ends, the consensus node for the next term in this network area is re-determined. After the blockchain node first completes the consensus of blocks within a term as a consensus node, the blockchain node increases its reputation value by a first value. When the blockchain node secondarily completes the consensus of blocks within a term as a consensus node, the blockchain node increases its reputation value by a second value. After that, each time the blockchain node completes the consensus of blocks within a term as a consensus node in the network area where it is located, it increases the corresponding reputation value. Among them, the second value is less than the first value. Each time the blockchain node completes the consensus of the term block as a consensus node in the network area where it is located, the increased reputation value gradually decreases, and the minimum increased reputation value each time is 1. In some embodiments of the present disclosure, each time the blockchain node completes the consensus of blocks within a term as a consensus node, the increased reputation value is halved compared to the previous time, that is, the first value is equal to twice the second value. The size of the first value is set based on experience, and the embodiments of the present application do not limit this.
[0131] If, during the period when a blockchain node is a consensus node, it is first determined that its behavior is unreasonable, the blockchain node's reputation value is deducted by a third value. When it is secondarily determined that its behavior is unreasonable, the blockchain node's reputation value is deducted by a fourth value. During the subsequent period when the blockchain node is a consensus node, each time it is determined that its behavior is unreasonable, the corresponding value of the reputation value is deducted. As the number of times of being determined that the behavior is unreasonable increases, the deducted reputation value each time also gradually increases. In an embodiment of the present disclosure, the maximum deducted reputation value each time does not exceed the initial reputation value. Among them, the fourth value is greater than the third value. In some embodiments of the present disclosure, the fourth value is equal to twice the third value. During the subsequent period when the blockchain node is a consensus node, the number of times it is determined that the behavior is unreasonable is the number of times the reputation value corresponding to the multiple of the third value is deducted. For example, when it is determined that the behavior is unreasonable for the fourth time, the reputation value deducted is four times the third value.
[0132] Exemplarily, the change in the reputation value of the blockchain node is as Figure 12 shown. The initial reputation value is 1024. After the blockchain node first completes the consensus of blocks within a term as a consensus node, the increased reputation value is 512. After the second time it completes the consensus of blocks within a term as a consensus node, the increased reputation value is 256. After the third time it completes the consensus of blocks within a term as a consensus node, the increased reputation value is 128. During the period when the blockchain node is a consensus node, when it is first determined that its behavior is unreasonable, 128 reputation values are deducted. When it is secondarily determined that its behavior is unreasonable, 256 reputation values are deducted. When it is thirdly determined that its behavior is unreasonable, 512 reputation values are deducted.
[0133] In some embodiments of the present disclosure, if a blockchain node is determined to have unreasonable behavior during its tenure as a consensus node, then after the tenure of the blockchain node as a consensus node ends, it is considered that there are blocks in the tenure of the blockchain node as a consensus node that have not completed consensus. That is to say, it is considered that the blockchain node has not completed the consensus of the blocks during its tenure, and after the current tenure ends, the reputation value of the blockchain node is not increased.
[0134] For example, 2 reputation values are deducted when being determined to have unreasonable behavior for the first time, and the reputation value deducted each subsequent time being determined to have unreasonable behavior doubles. 8 reputation values are added for completing the first tenure, and the reputation value added each subsequent time for completing a tenure is halved. The initial reputation value is 1024. Blockchain node A participates in consensus twice as a consensus node in the network area it belongs to. During the first tenure, it is determined to have unreasonable behavior twice. During the second tenure, it is not determined to have unreasonable behavior. Then the change in the reputation value of blockchain node A is that 2 reputation values are deducted when being determined to have unreasonable behavior for the first time, and 4 reputation values are deducted when being determined to have unreasonable behavior for the second time. Since there are two times when blockchain node A is determined to have unreasonable behavior during its first tenure as a consensus node, it is considered that blockchain node A has not completed the consensus of the blocks during its first tenure as a consensus node. Therefore, the reputation value of blockchain node A after the end of its first tenure as a consensus node is 1024 - 2 - 4 = 1018. Since there is no determination of unreasonable behavior for blockchain node A during its second tenure as a consensus node, it is considered that blockchain node A has completed the consensus of the blocks during its second tenure as a consensus node. Therefore, the reputation value of blockchain node A after the end of its second tenure as a consensus node is 1018 + 8 = 1026.
[0135] Regarding which behaviors of a blockchain node during its tenure as a consensus node will be determined to be unreasonable, the embodiments of this application do not make restrictions, and it can be determined according to the consensus algorithm used by the blockchain network. For example, in the case where the consensus algorithm used by the blockchain network is a BFT - type consensus algorithm, if the block submitted by the consensus node is an empty block (that is, there is not a single transaction in the created block), or the signature verification of the block submitted by the consensus node fails, then it is determined that the behavior of the consensus node submitting the block is unreasonable.
[0136] In some embodiments of the present disclosure, during the tenure of a blockchain node as a consensus node, due to communication anomalies, when the blockchain node conducts consensus on a proposal, the abnormal behaviors that occur will also be determined to be unreasonable. For example, due to communication anomalies, the blockchain node serving as a consensus node is unable to receive the proposal sent by the primary node, which in turn causes the blockchain node to be unable to participate in the consensus of the block. At this time, the blockchain node will be determined to have unreasonable behavior.
[0137] In some embodiments of the present disclosure, the current reputation value of the blockchain node in the first network area is updated, and the next reputation value of the blockchain node in the first network area is determined, including: obtaining historical reputation value increase and decrease information and / or an initial reputation value of the first blockchain node; if it is determined that the first blockchain node has completed the consensus of the block within the current term, then according to the historical reputation value increase and decrease information and / or the initial reputation value, the current reputation value is increased to obtain the next reputation value of the first blockchain node; if it is determined that the first blockchain node has not completed the consensus of the block within the current term, then according to the historical reputation value increase and decrease information and / or the initial reputation value, the current reputation value of the first blockchain node is reduced to obtain the next reputation value of the first blockchain node.
[0138] In the blockchain network, each blockchain node records the historical reputation value increase and decrease information and initial reputation value of the reputation value of each blockchain node in the network area. In some embodiments, obtaining the historical reputation value increase and decrease information and / or the initial reputation value of the first blockchain node includes: the first blockchain node obtains the historical reputation value increase and decrease information and / or the initial reputation value of the first blockchain node from local storage. If the first blockchain node participates in the consensus as a consensus node for the first time, there is no historical reputation value increase and decrease information for the first blockchain node.
[0139] If it is determined that the first blockchain node has completed the consensus of the blocks in the current term, the current reputation value is the reputation value that the first blockchain node should increase for completing the term. For example, if the blockchain node completes the consensus of the blocks in the term for the first time as a consensus node, the increased reputation value is 8, and each subsequent time it completes the consensus of the blocks in the term as a consensus node, the increased reputation value is halved, and the minimum increased reputation value is not less than 1 each time, and the first blockchain node completes the consensus of the blocks in the current term as a consensus node for the second time, then the current reputation value is 4.
[0140] If it is determined that the first blockchain node has not completed the consensus of the block in the current term, the current reputation value is the reputation value that should be reduced during the current term of the first blockchain node. For example, when a blockchain node is judged to have unreasonable behavior as a consensus node for the first time, the reputation value subtracted is 2. Each subsequent time it is judged to have unreasonable behavior as a consensus node, the reduced reputation value doubles, and the maximum reputation value reduced each time is not greater than the initial reputation value.
[0141] For example, the historical reputation value increase and decrease information of the first blockchain node includes: the first time it completes the consensus of the block within its term as a consensus node, the reputation value increases by 8; the second time it completes the consensus of the block within its term as a consensus node, the reputation value increases by 4. The current reputation value is the third time it completes the consensus of the block within its term as a consensus node, the reputation value increases by 2, and the initial reputation value is 1024, then the next reputation value of the first blockchain node is 1024+8+4+2=1038.
[0142] In some embodiments, the reputation value of a blockchain node only changes when it is a consensus node. Therefore, after the term of the first blockchain node as a consensus node ends, the reputation values of other blockchain nodes in the first network area except the first blockchain node remain unchanged.
[0143] Step S205: Determine the first consensus node in the first network area during the next term according to the next reputation value of the blockchain nodes in the first network area.
[0144] In some embodiments of the present disclosure, before determining the first consensus node in the first network area during the next term according to the next reputation value of the blockchain nodes in the first network area, it is necessary to determine whether the term of the first blockchain node as the first consensus node has ended. Exemplarily, as Figure 13 shown, after each block consensus is completed by the first blockchain node, it is judged whether the term of the first blockchain node as the first consensus node has ended. If the term has not ended, continue to perform the consensus on the block; if the term has ended, remove the first consensus node.
[0145] In some embodiments of the present disclosure, determining the first consensus node in the first network area during the next term according to the next reputation value of the blockchain nodes in the first network area includes: when determining that the first blockchain node is the first consensus node in the first network area during the current term, start a timer for the term duration; when each block consensus in the current term is completed, use the timer to judge whether the duration of the first blockchain node becoming the first consensus node in the first network area during the current term exceeds the term duration; if it exceeds the term duration, determine the first consensus node in the first network area during the next term according to the next reputation value of the blockchain nodes in the first network area.
[0146] Among them, the term duration is a set value, and the embodiments of the present disclosure do not limit this, and it can be set according to experience. For example, the term duration is 1 week.
[0147] In some embodiments, if it exceeds the term duration, the method of determining the first consensus node in the first network area during the next term according to the next reputation value of the blockchain nodes in the first network area is the same as the method of determining the first blockchain node as the first consensus node in the first network area during the current term in step S202, and will not be elaborated here.
[0148] In some other embodiments of the present disclosure, determining the first consensus node of the first network area in the next term according to the next reputation value of the blockchain nodes in the first network area includes: obtaining the number of term blocks; when determining that the first blockchain node is the first consensus node of the first network area in the current term, recording the previous block height; when the consensus of the blocks in the current term is completed each time, determining whether the difference between the current block height of the first blockchain node and the previous block height is not less than the number of term blocks; if it is not less than the number of term blocks, determining the first consensus node of the first network area in the next term according to the next reputation value of the blockchain nodes in the first network area.
[0149] Wherein, the number of term blocks refers to the number of blocks that the first blockchain node should participate in the consensus as a consensus node. For example, if the number of term blocks is 1000, when the number of blocks that the first blockchain node participates in the consensus as a consensus node reaches 1000, it is considered that the term of the first blockchain node as a consensus node in this time has ended.
[0150] In some embodiments, if it is not less than the number of term blocks, the method for determining the first consensus node of the first network area in the next term according to the next reputation value of the blockchain nodes in the first network area is the same as the method for determining the first blockchain node as the first consensus node of the first network area in the current term in step S202, which will not be elaborated here.
[0151] The first consensus node in the next term is used to execute the consensus of the blocks in the next term in the blockchain corresponding to the blockchain network in the next term.
[0152] In the technical solutions provided by some embodiments of the present disclosure, on the one hand, the blockchain network is divided into including the first network area, then the first blockchain node belonging to the first network area is determined, and the first blockchain node is determined as the first consensus node of the first network area in the current term, so that the first blockchain node executes the consensus process of the blocks in the current term in the blockchain corresponding to the blockchain network in the current term, that is, the consensus node in the current term is determined by the way of network area division, and not all blockchain nodes in the blockchain network need to participate in the consensus, which greatly reduces the number of blockchain nodes participating in the consensus. Therefore, the consensus efficiency can be improved, the speed of block chain-up can be accelerated, and the consensus failure caused by too slow or timeout of the consensus can be avoided.
[0153] On the other hand, after determining that the first blockchain node belongs to the first network area, obtain the current reputation value of the blockchain nodes in the first network area, so as to determine the first blockchain node as the first consensus node in the current term of the first network area according to the current reputation value of the blockchain nodes in the first network area. After that, the first blockchain node elected as the first consensus node in the current term of the first network area participates in the consensus of the blocks in the blockchain during the current term, and updates the current reputation value of the blockchain nodes in the first network area after the end of the current term. According to the next reputation value of the blockchain nodes in the updated first network area, determine the first consensus node of the next term, that is, by means of selecting the first consensus node of the first network area in each term (including the above-mentioned current term and the next term) through the reputation value (including the above-mentioned current reputation value and the next reputation value), the interference of human factors in determining the first consensus node in each term is avoided, making the election of the first consensus node more fair.
[0154] In addition, in the method provided by the embodiments of the present disclosure, the first consensus node in the current term determines the first consensus node in the next term of the first network area, rather than all blockchain nodes in the first network area voting to elect the first consensus node in the next term. Thus, the election method of the first consensus node in each term of the first network area is greatly simplified, further improving the consensus efficiency. At the same time, there is a possibility that the first consensus node in the next term cannot be determined by the voting election method, while using the method provided by the embodiments of the present disclosure can ensure that the first consensus node in each term is successfully elected, thereby ensuring the normal operation of the consensus mechanism.
[0155] Figure 14 A block diagram of a blockchain-based data processing device according to an embodiment of the present disclosure is schematically shown. The blockchain network includes a first network area, and the first network area includes a first blockchain node; wherein, the device is executed by the first blockchain node.
[0156] Refer to Figure 14 As shown, a blockchain-based data processing device according to an embodiment of the present disclosure may include:
[0157] A determination module 1401 is configured to determine that the first blockchain node belongs to a first network area in the blockchain network; the determination module 1401 is further configured to determine, according to the current reputation value of the blockchain nodes in the first network area, that the first blockchain node is the first consensus node of the first network area in the current term; a processing module 1402 is configured to, in the current term, perform consensus on the blocks in the current term in the blockchain corresponding to the blockchain network; the determination module 1401 is further configured to update the current reputation value of the blockchain nodes in the first network area and determine the next reputation value of the blockchain nodes in the first network area; the determination module 1401 is further configured to determine, according to the next reputation value of the blockchain nodes in the first network area, the first consensus node of the first network area in the next term; wherein, the first consensus node in the next term is configured to perform consensus on the blocks in the next term in the blockchain corresponding to the blockchain network in the next term.
[0158] In some exemplary embodiments of the present disclosure, the blockchain network further includes a second network area; the determination module 1401 is configured to obtain first probe node information of the first network area and second probe node information of the second network area; obtain a first network delay between the first blockchain node and a first probe node corresponding to the first probe node information, and a second network delay between the first blockchain node and a second probe node corresponding to the second probe node information; determine, according to the first network delay and the second network delay, that the first blockchain node belongs to the first network area; and allocate the first network address of the first blockchain node to the first area identifier of the first network area.
[0159] In some exemplary embodiments of the present disclosure, the apparatus further includes: an acquisition module 1403 configured to obtain the number of currently created network areas and the number of current blockchain nodes in the blockchain network; the determination module 1401 is further configured to determine to create the first network area according to the number of currently created network areas and the number of current blockchain nodes; and determine the first probe node of the first network area according to the information of the currently created network areas.
[0160] In some exemplary embodiments of the present disclosure, the determination module 1401 is configured to, if the number of currently created network areas is n and the number of current blockchain nodes is m n , then determine to create the first network area; wherein, n is a positive integer greater than or equal to 1, and m is a positive integer greater than or equal to 2.
[0161] In some exemplary embodiments of the present disclosure, the information of the currently created network areas includes the information of the blockchain nodes with the highest network delay in each of the currently created network areas; wherein, the determination module 1401 is configured to determine the first probe node of the first network area according to the information of the blockchain nodes with the highest network delay in each of the currently created network areas.
[0162] In some exemplary embodiments of the present disclosure, a determination module 1401 is configured to obtain a configuration file of a blockchain network; generate a first area identifier for a first network area according to the configuration file, and determine that a first blockchain node belongs to the first network area; and assign a first network address of the first blockchain node to the first area identifier.
[0163] In some exemplary embodiments of the present disclosure, the determination module 1401 is further configured to, if the first blockchain node is the first blockchain node in the first network area, use the first blockchain node as a first detection node of the first network area.
[0164] In some exemplary embodiments of the present disclosure, the determination module 1401 is configured to exclude blockchain nodes in the first network area whose current reputation value is lower than a reputation value threshold; and determine the first blockchain node as a first consensus node in the current term according to a positive correlation between the current reputation value and the probability that a blockchain node in the corresponding first network area is elected as the first consensus node in the current term.
[0165] In some exemplary embodiments of the present disclosure, the blockchain network further includes a second network area; wherein, a processing module 1402 is configured to determine the first blockchain node as a primary node in the current term; receive a transaction sent by a client, and store the received transaction in a first transaction pool of the first blockchain node; extract a target transaction from the first transaction pool, package the target transaction into a block; and send a proposal message of the block to a second consensus node in the second network area in the current term to complete the consensus of the block; the apparatus further includes a synchronization module 1404 configured to synchronize the transactions in the first transaction pool to a primary node in the next term when the current term expires.
[0166] In some exemplary embodiments of the present disclosure, the blockchain network further includes a second network area; wherein, the processing module 1402 is configured to send a network connection message to a second consensus node or a second detection node in the second network area in the current term, and the network connection message is used to instruct the second consensus node to establish a peer-to-peer network connection with the first blockchain node; when a predetermined proportion of consensus nodes in the blockchain network in the current term complete the peer-to-peer network connection, perform the consensus of the block in the current term in the blockchain corresponding to the blockchain network.
[0167] In some exemplary embodiments of the present disclosure, the synchronization module 1404 is further configured to synchronize the current block to the remaining blockchain nodes in the first network area except the first blockchain node when the current block in the current term is chained to the first blockchain node.
[0168] In some exemplary embodiments of the present disclosure, the synchronization module 1404 is further configured to receive a synchronization request from a non-consensus node in the first network area; according to the synchronization request, when uploading the current block in the current term to the first blockchain node, synchronize the current block to the remaining blockchain nodes in the first network area except the first blockchain node.
[0169] In some exemplary embodiments of the present disclosure, the synchronization module 1404 is configured to, when uploading the current block to the first blockchain node, obtain preset number of first target blockchain node information according to the indexes of the blockchain nodes in the first network area; send a synchronization instruction to the first target blockchain nodes corresponding to the first target blockchain node information, where the synchronization instruction is used to synchronize the current block to the first target blockchain node and instruct the first target blockchain node to synchronize the current block to a preset number of second target blockchain nodes.
[0170] In some exemplary embodiments of the present disclosure, the determination module 1401 is configured to obtain the historical reputation value increase and decrease information and / or the initial reputation value of the first blockchain node; if it is determined that the first blockchain node has completed the consensus of the block in the current term, increase the current reputation value according to the historical reputation value increase and decrease information and / or the initial reputation value to obtain the next reputation value of the first blockchain node; if it is determined that the first blockchain node has not completed the consensus of the block in the current term, decrease the current reputation value of the first blockchain node according to the historical reputation value increase and decrease information and / or the initial reputation value to obtain the next reputation value of the first blockchain node.
[0171] In some exemplary embodiments of the present disclosure, the determination module 1401 is configured to start a timer for the term duration when determining that the first blockchain node is the first consensus node in the first network area in the current term; when each block consensus in the current term is completed, determine whether the duration of the first blockchain node being the first consensus node in the first network area in the current term exceeds the term duration through the timer; if it exceeds the term duration, determine the first consensus node in the first network area in the next term according to the next reputation value of the blockchain nodes in the first network area.
[0172] In some exemplary embodiments of the present disclosure, the determination module 1401 is configured to obtain the number of blocks in the term; record the previous block height when determining that the first blockchain node is the first consensus node in the first network area in the current term; when each block consensus in the current term is completed, determine whether the difference between the current block height of the first blockchain node and the previous block height is not less than the number of blocks in the term; if it is not less than the number of blocks in the term, determine the first consensus node in the first network area in the next term according to the next reputation value of the blockchain nodes in the first network area.
[0173] For other content of the data processing device based on blockchain according to the embodiments of the present disclosure, reference may be made to the above embodiments.
[0174] It should be noted that although several units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more of the above-mentioned units may be embodied in one unit. Conversely, the features and functions of one unit described above may be further divided and embodied by multiple units.
[0175] Figure 15 The structural schematic diagram of the electronic device suitable for implementing the embodiments of the present disclosure is shown. It should be noted that Figure 15 The shown electronic device is only an example and should not impose any limitation on the functions and usage scope of the embodiments of the present disclosure.
[0176] As Figure 15 shown, the electronic device includes a central processing unit (CPU) 1501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1502 or the program loaded from the storage section 1508 into the random access memory (RAM) 1503. In the RAM 1503, various programs and data required for system operation are also stored. The CPU 1501, ROM 1502, and RAM 1503 are connected to each other through a bus 1504. The input / output (I / O) interface 1505 is also connected to the bus 1504.
[0177] The following components are connected to the I / O interface 1505: an input section 1506 including a keyboard, a mouse, etc.; an output section 1507 including such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage section 1508 including a hard disk, etc.; and a communication section 1509 including a network interface card such as a LAN card, a modem, etc. The communication section 1509 performs communication processing via a network such as the Internet. A drive 1510 is also connected to the I / O interface 1505 as needed. A removable medium 1511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1510 as needed so that the computer program read from it can be installed into the storage section 1508 as needed.
[0178] Specifically, according to the embodiments of the present disclosure, the processes described below with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes instructions for performing Figure 2Program code of the method shown. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 1509, and / or installed from the removable medium 1511. When the computer program is executed by the central processing unit (CPU) 1501, various functions defined in the system of the present application are executed.
[0179] It should be noted that the computer-readable medium shown in the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection having at least one wire, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. And in the present disclosure, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries the computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0180] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a part of code that contains at least one executable instruction for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, as well as combinations of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0181] The modules and / or units and / or subunits involved in the embodiments described in the present disclosure can be implemented in software or in hardware, and the described modules and / or units and / or subunits can also be provided in a processor. Among them, the names of these modules and / or units and / or subunits do not, in some cases, constitute a limitation on the modules and / or units and / or subunits themselves.
[0182] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiments; or may exist separately without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the one or more programs are executed by an electronic device, the electronic device is caused to implement the methods in the following embodiments.
[0183] It should be noted that although several modules or units or subunits of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of the two or more modules or units or subunits described above can be embodied in one module or unit or subunit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units or subunits.
[0184] Those skilled in the art can easily understand from the description of the above embodiments that the example embodiments described herein can be implemented by software or by a combination of software and necessary hardware. Therefore, the technical solutions according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (such as a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
Claims
1. A blockchain-based data processing method, characterized in that, The blockchain network includes network regions 1 to n, where n is a positive integer greater than 1. Each network region corresponds to a consensus node that reaches a consensus on transactions during the current term. The consensus nodes between different network regions are connected through a peer-to-peer network, and the nodes within each network region are connected through an epidemic network. Network regions 1 to n include a first network region and a second network region, and the first network region includes a first blockchain node. Wherein, the method is executed by the first blockchain node, and the method includes: Determine that the first blockchain node belongs to the first network region in the blockchain network; Based on the current reputation value of the blockchain nodes in the first network region, determine that the first blockchain node is the first consensus node of the first network region during the current term; During the current term, perform the consensus of the blocks in the current term in the blockchain corresponding to the blockchain network, which includes: sending a network connection message to the second consensus node or the second probing node of the second network region during the current term, where the network connection message is used to instruct the second consensus node to establish a peer-to-peer network connection with the first blockchain node; when a predetermined proportion of the consensus nodes in the blockchain network complete the peer-to-peer network connection during the current term, perform the consensus of the blocks in the current term in the blockchain corresponding to the blockchain network; Update the current reputation value of the blockchain nodes in the first network region and determine the next reputation value of the blockchain nodes in the first network region; Based on the next reputation value of the blockchain nodes in the first network region, determine the first consensus node of the first network region during the next term; Wherein, the first consensus node during the next term is used to perform the consensus of the blocks in the next term in the blockchain corresponding to the blockchain network during the next term.
2. The method according to claim 1, characterized in that, Determining that the first blockchain node belongs to the first network region in the blockchain network includes: Obtain the first probing node information of the first network region and the second probing node information of the second network region; Obtain the first network latency between the first blockchain node and the first probing node corresponding to the first probing node information, and the second network latency between the first blockchain node and the second probing node corresponding to the second probing node information; Based on the first network latency and the second network latency, determine that the first blockchain node belongs to the first network region; Assign the first network address of the first blockchain node to the first region identifier of the first network region.
3. The method according to claim 2, characterized in that, It also includes: Obtain the current number of created network regions and the current number of blockchain nodes in the blockchain network; Determine to create the first network region based on the current number of created network regions and the current number of blockchain nodes; Determine the first probing node of the first network region based on the current information of the created network regions.
4. The method according to claim 3, characterized in that, Determining to create the first network region based on the current number of created network regions and the current number of blockchain nodes includes: If the current number of created network regions is n and the current number of blockchain nodes is m n , then determine to create the first network region; Wherein, n is a positive integer greater than or equal to 1, and m is a positive integer greater than or equal to 2.
5. The method according to claim 3, characterized in that, The currently created network area information includes the information of the blockchain node with the highest network latency in each currently created network area; Wherein, determining the first detection node of the first network area according to the currently created network area information includes: Determining the first detection node of the first network area according to the information of the blockchain node with the highest network latency in each currently created network area.
6. The method according to claim 1, characterized in that, Determining that the first blockchain node belongs to the first network area in the blockchain network includes: Obtaining the configuration file of the blockchain network; Generating a first area identifier of the first network area according to the configuration file, and determining that the first blockchain node belongs to the first network area; Allocating the first network address of the first blockchain node to the first area identifier.
7. The method according to claim 6, characterized in that, It further includes: If the first blockchain node is the first blockchain node in the first network area, then use the first blockchain node as the first detection node of the first network area.
8. The method according to claim 1, characterized in that, Determining that the first blockchain node is the first consensus node of the first network area in the current term according to the current reputation value of the blockchain nodes in the first network area includes: Excluding the blockchain nodes in the first network area whose current reputation value is lower than the reputation value threshold; Determining that the first blockchain node is the first consensus node in the current term according to the fact that the current reputation value is positively correlated with the probability that the corresponding blockchain node in the first network area is elected as the first consensus node in the current term.
9. The method according to claim 1, characterized in that,In the current term, performing the consensus of the block in the current term in the blockchain corresponding to the blockchain network includes: Determining that the first blockchain node is the primary node in the current term; Receiving the transactions sent by the client, and storing the received transactions in the first transaction pool of the first blockchain node; Extracting target transactions from the first transaction pool, and packaging the target transactions into blocks; Sending a proposal message of the block to the second consensus node of the second network area in the current term to complete the consensus of the block; Wherein, the method further includes: When the current term expires, synchronizing the transactions in the first transaction pool to the primary node in the next term.
10. The method according to claim 1, characterized in that, It further includes: When uploading the current block in the current term to the first blockchain node, synchronizing the current block to the remaining blockchain nodes in the first network area except the first blockchain node.
11. The method according to claim 1, characterized in that, It further includes: Receiving the synchronization request of the non-consensus node in the first network area; According to the synchronization request, when uploading the current block in the current term to the first blockchain node, synchronizing the current block to the remaining blockchain nodes in the first network area except the first blockchain node.
12. The method according to claim 10 or 11, characterized in that, When uploading the current block in the current term to the first blockchain node, synchronizing the current block to the remaining blockchain nodes in the first network area except the first blockchain node includes: When uploading the current block to the first blockchain node, obtain preset quantity of first target blockchain node information according to the indexes of the blockchain nodes in the first network area; Send a synchronization instruction to the first target blockchain node corresponding to the first target blockchain node information, where the synchronization instruction is used to synchronize the current block to the first target blockchain node and instruct the first target blockchain node to synchronize the current block to the preset quantity of second target blockchain nodes.
13. The method according to claim 1, characterized in that, Update the current credit value of the blockchain nodes in the first network area and determine the next credit value of the blockchain nodes in the first network area, including: Obtain the historical credit value increase and decrease information and / or the initial credit value of the first blockchain node; If it is determined that the first blockchain node has completed the consensus of the blocks within the current term, increase the current credit value according to the historical credit value increase and decrease information and / or the initial credit value to obtain the next credit value of the first blockchain node; If it is determined that the first blockchain node has not completed the consensus of the blocks within the current term, decrease the current credit value of the first blockchain node according to the historical credit value increase and decrease information and / or the initial credit value to obtain the next credit value of the first blockchain node.
14. The method according to claim 1, characterized in that, Determine the first consensus node of the first network area in the next term according to the next credit value of the blockchain nodes in the first network area, including: When determining that the first blockchain node is the first consensus node of the first network area in the current term, start a timer for the term duration; Each time the consensus of the blocks within the current term is completed, use the timer to determine whether the duration for which the first blockchain node has been the first consensus node of the first network area in the current term exceeds the term duration; If it exceeds the term duration, determine the first consensus node of the first network area in the next term according to the next credit value of the blockchain nodes in the first network area.
15. The method according to claim 1, characterized in that, Determine the first consensus node of the first network area in the next term according to the next credit value of the blockchain nodes in the first network area, including: Obtain the number of term blocks; When determining that the first blockchain node is the first consensus node of the first network area in the current term, record the previous block height; Each time the consensus of the blocks within the current term is completed, determine whether the difference between the current block height of the first blockchain node and the previous block height is not less than the number of term blocks; If it is not less than the number of term blocks, determine the first consensus node of the first network area in the next term according to the next credit value of the blockchain nodes in the first network area.
16. A data processing device based on a blockchain, characterized in that, The blockchain network includes network regions 1 to n, where n is a positive integer greater than 1. Each network region corresponds to a consensus node that reaches a consensus on transactions during the current term. Communication connections are established between the consensus nodes in different network regions based on a peer-to-peer network, and communication connections between the nodes included in each network region are established based on an infection-style network; among network regions 1 to n, there are a first network region and a second network region, and the first network region includes a first blockchain node; wherein, the device is executed by the first blockchain node, and the device includes: A determination module, configured to determine that the first blockchain node belongs to the first network region in the blockchain network; The determination module is further configured to determine, according to the current reputation value of the blockchain nodes in the first network region, that the first blockchain node is the first consensus node of the first network region during the current term; A processing module, configured to, during the current term, perform the consensus on the block in the current term in the blockchain corresponding to the blockchain network, which includes: sending a network connection message to the second consensus node or the second detection node in the second network region during the current term, where the network connection message is used to instruct the second consensus node to establish a peer-to-peer network connection with the first blockchain node; when a predetermined proportion of the consensus nodes in the blockchain network complete the peer-to-peer network connection during the current term, perform the consensus on the block in the current term in the blockchain corresponding to the blockchain network; The determination module is further configured to update the current reputation value of the blockchain nodes in the first network region and determine the next reputation value of the blockchain nodes in the first network region; The determination module is further configured to determine, according to the next reputation value of the blockchain nodes in the first network region, the first consensus node of the first network region during the next term; Wherein, the first consensus node during the next term is configured to, during the next term, perform the consensus on the block in the next term in the blockchain corresponding to the blockchain network.
17. The device according to claim 16, wherein The determination module is configured to: obtain the first detection node information of the first network region and the second detection node information of the second network region; obtain the first network delay between the first blockchain node and the first detection node corresponding to the first detection node information, and the second network delay between the first blockchain node and the second detection node corresponding to the second detection node information; determine, according to the first network delay and the second network delay, that the first blockchain node belongs to the first network region; and allocate the first network address of the first blockchain node to the first region identifier of the first network region.
18. The device according to claim 17, wherein An acquisition module is configured to: obtain the number of currently created network regions and the number of current blockchain nodes in the blockchain network; determine the creation of the first network region according to the number of currently created network regions and the number of current blockchain nodes; Determine the first detection node of the first network region according to the currently created network region information.
19. The device according to claim 18, wherein The determination module is used to: if the current number of created network regions is n and the current number of blockchain nodes is m n , then determine to create the first network region; Wherein, n is a positive integer greater than or equal to 1, and m is a positive integer greater than or equal to 2.
20. The device according to claim 18, wherein The currently created network area information includes the information of the blockchain node with the highest network latency in each currently created network area; Wherein, the determination module is configured to: determine the first detection node of the first network area according to the information of the blockchain node with the highest network latency in each currently created network area.
21. The device according to claim 16, wherein The determination module is configured to: obtain the configuration file of the blockchain network; generate the first area identifier of the first network area according to the configuration file, and determine that the first blockchain node belongs to the first network area; allocate the first network address of the first blockchain node to the first area identifier.
22. The device according to claim 21, wherein The determination module is further configured to: if the first blockchain node is the first blockchain node in the first network area, then use the first blockchain node as the first detection node of the first network area.
23. The device according to claim 16, wherein The determination module is configured to: exclude the blockchain nodes in the first network area whose current reputation value is lower than the reputation value threshold; determine the first blockchain node as the first consensus node in the current term according to the positive correlation between the current reputation value and the probability that the blockchain node in the corresponding first network area is elected as the first consensus node in the current term.
24. The device according to claim 16, wherein The processing module is configured to: determine the first blockchain node as the primary node in the current term; receive the transactions sent by the client, and store the received transactions in the first transaction pool of the first blockchain node; Extract the target transaction from the first transaction pool, package the target transaction into a block; send a proposal message of the block to the second consensus node of the second network area in the current term to complete the consensus of the block; Wherein, the device further includes: a synchronization module, configured to synchronize the transactions in the first transaction pool to the primary node in the next term when the current term expires.
25. The device according to claim 16, wherein Further includes: A synchronization module, configured to synchronize the current block to the remaining blockchain nodes in the first network area except the first blockchain node when the current block in the current term is chained to the first blockchain node.
26. The device according to claim 16, wherein Further includes: A synchronization module, configured to receive the synchronization request of the non-consensus node in the first network area; according to the synchronization request, synchronize the current block to the remaining blockchain nodes in the first network area except the first blockchain node when the current block in the current term is chained to the first blockchain node.
27. The device according to claim 25 or 26, wherein The synchronization module is configured to: when chaining the current block to the first blockchain node, obtain the information of a preset number of first target blockchain nodes according to the indexes of the blockchain nodes in the first network area; Send a synchronization instruction to the first target blockchain node corresponding to the first target blockchain node information, where the synchronization instruction is used to synchronize the current block to the first target blockchain node and instruct the first target blockchain node to synchronize the current block to the preset number of second target blockchain nodes.
28. The device according to claim 16, wherein The determining module is configured to: obtain the historical reputation value increase / decrease information and / or the initial reputation value of the first blockchain node; if it is determined that the first blockchain node has completed the consensus of the blocks within the current term, increase the current reputation value according to the historical reputation value increase / decrease information and / or the initial reputation value to obtain the next reputation value of the first blockchain node; if it is determined that the first blockchain node has not completed the consensus of the blocks within the current term, decrease the current reputation value of the first blockchain node according to the historical reputation value increase / decrease information and / or the initial reputation value to obtain the next reputation value of the first blockchain node.
29. The device according to claim 16, wherein The determining module is configured to: start a timer for the term duration when it is determined that the first blockchain node is the first consensus node of the first network area within the current term; when the consensus of the blocks within the current term is completed each time, determine, through the timer, whether the duration for which the first blockchain node has been the first consensus node of the first network area within the current term exceeds the term duration. If it exceeds the term duration, determine the first consensus node of the first network area in the next term according to the next reputation value of the blockchain nodes in the first network area.
30. The device according to claim 16, wherein The determining module is configured to: obtain the number of term blocks; record the previous block height when it is determined that the first blockchain node is the first consensus node of the first network area within the current term. When the consensus of the blocks within the current term is completed each time, determine whether the difference between the current block height of the first blockchain node and the previous block height is not less than the number of term blocks. If it is not less than the number of term blocks, determine the first consensus node of the first network area in the next term according to the next reputation value of the blockchain nodes in the first network area.
31. An electronic device, wherein Comprising: At least one processor; A storage device for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the blockchain-based data processing method according to any one of claims 1-15.
32. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the blockchain-based data processing method according to any one of claims 1-15.
33. A computer program product comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the blockchain-based data processing method according to any one of claims 1-15.
Citation Information
Patent Citations
PBFT consensus system and method based on reputation value
CN110784346A
Data processing method and device based on blockchain
CN113132401A
Fragmentation method and device for block chain system
CN113395357A