Parallel chain arbitration consensus method, computer device and storage medium

By generating random numbers and hash values ​​to process consensus transactions, identifying and arbitrating illegal nodes, and redefining consensus nodes, the high handling fee and low speed problems when multiple parachain nodes participate in consensus are solved, and efficient parachain consensus is achieved.

CN112948388BActive Publication Date: 2024-12-20林上煜
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110245527.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-05
Publication Date
2024-12-20
Estimated Expiration
2041-03-05

AI Technical Summary

Technical Problem

When multiple parachain nodes participate in consensus, the prior art leads to a large number of consensus transactions, resulting in an increase in handling fee overhead, and parachain nodes spend a lot of time when generating aggregate consensus transactions, reducing the speed of parachain consensus.

Method used

By generating random numbers and hash values, we can process consensus transactions, identify and arbitrate illegal nodes, redetermine consensus nodes, ensure the effectiveness and efficiency of consensus transactions, reduce handling fees, and ensure the consensus speed of the parachain.

Benefits of technology

It effectively reduces handling fees and overhead, and improves the consensus speed of the parachain, ensuring the normal operation and efficiency of the blockchain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112948388B_ABST
    Figure CN112948388B_ABST
Patent Text Reader

Abstract

The present invention provides a parallel chain arbitration consensus method, a computer device and a storage medium, the method comprising: generating a first random number in response to obtaining the first consensus transaction sending right of the first parallel chain block of the first height; generating a first consensus transaction of the first parallel chain block including the first hash value of the first random number; sending the first consensus transaction to the main chain; when the first consensus transaction is not successfully arbitrated, determining the first consensus node to send the second consensus transaction of the second parallel chain block of the first height plus one according to the second block data of the second main chain block corresponding to the first parallel chain block, the first random number, and the node IDs of each consensus node of the current parallel chain except the illegal nodes; and broadcasting the first random number to each consensus node, so that each consensus node can determine the first consensus node according to the second block data, the first random number, and each node ID. The present application not only reduces the handling fee, but also ensures the consensus speed of the parallel chain.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and specifically to a parallel chain arbitration consensus method, computer equipment, and storage medium. Background Art

[0002] In the prior art, each consensus node participating in the consensus needs to generate and send a consensus transaction to the main chain. When the number of parallel chain nodes is large, a large number of consensus transactions will be generated, which will cause the problem of increased transaction fees.

[0003] In response to the above problems, in the parallel chain mechanism proposed by the applicant (for details, please refer to the patent text applied for by the applicant, application number is 202010631494.9), by generating aggregate consensus transactions, the storage space consumed by the main chain blocks is reduced, and the handling fees for sending consensus transactions are reduced.

[0004] However, the above mechanism will cause parachain nodes to spend a lot of time communicating with each other to generate aggregate consensus transactions, which will in turn reduce the speed of parachain consensus. Summary of the invention

[0005] In view of the above-mentioned defects or deficiencies in the prior art, it is desired to provide a parallel chain arbitration consensus method, computer device and storage medium that can reduce handling fees and ensure the consensus speed of the parallel chain.

[0006] In a first aspect, the present invention provides a parallel chain arbitration consensus method applicable to a consensus node, the method comprising:

[0007] In response to obtaining a first consensus transaction sending right for a first parallel chain block at a first height, generating a first random number;

[0008] Generate a first consensus transaction for a first parachain block including a first hash value of a first random number;

[0009] Send the first consensus transaction to the main chain for each consensus node of the current parallel chain:

[0010] Execute the first consensus transaction to obtain the first execution result, and determine whether it is the same as the second execution result of the first height generated locally:

[0011] If yes, record the first hash value;

[0012] If not, a first arbitration transaction of the first height is generated and sent to the main chain for evidence storage;

[0013] Execute each arbitration transaction of the first height, and when each arbitration transaction passes consensus, determine the current node as an illegal node;

[0014] Determine whether the execution result of the first level has been saved locally:

[0015] If yes, then roll back the execution result of the first height, and re-determine the second consensus node that will send the first consensus transaction based on the first block data of the first main chain block corresponding to the third parallel chain block with the first height minus one, the second random number broadcasted by the consensus node that sent the third consensus transaction of the correct third parallel chain block, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes;

[0016] If not, the second consensus node is re-determined based on the first block data, the second random number, and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes;

[0017] When the first consensus transaction is not successfully arbitrated, the first consensus node to be used to send the second consensus transaction of the second parallel chain block with the first height plus one is determined according to the second block data of the second main chain block corresponding to the first parallel chain block, the first random number, and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes; and

[0018] The first random number is broadcast to each consensus node, so that each consensus node can determine the first consensus node according to the second block data, the first random number, and each node ID.

[0019] In a second aspect, the present invention also provides a device comprising one or more processors and a memory, wherein the memory contains instructions executable by the one or more processors so that the one or more processors execute the parallel chain arbitration consensus method provided according to various embodiments of the present invention.

[0020] In a fourth aspect, the present invention also provides a storage medium storing a computer program, which enables a computer to execute the parallel chain arbitration consensus method provided according to various embodiments of the present invention.

[0021] The parallel chain arbitration consensus method, computer device and storage medium provided by many embodiments of the present invention generate a first random number in response to obtaining the first consensus transaction sending right of the first parallel chain block of the first height; generate a first consensus transaction of the first parallel chain block including the first hash value of the first random number; send the first consensus transaction to the main chain; when the first consensus transaction is not successfully arbitrated, determine the first consensus node that will send the second consensus transaction of the second parallel chain block of the first height plus one according to the second block data of the second main chain block corresponding to the first parallel chain block, the first random number, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes; and broadcast the first random number to each consensus node so that each consensus node can determine the first consensus node according to the second block data, the first random number, and each node ID, which not only reduces the handling fee but also ensures the consensus speed of the parallel chain. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:

[0023] Figure 1 A flowchart of a parallel chain arbitration consensus method provided for one embodiment of the present invention.

[0024] Figure 2 A schematic diagram of the structure of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0025] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the invention are shown in the accompanying drawings.

[0026] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0027] Figure 1 A flowchart of a parallel chain arbitration consensus method provided by an embodiment of the present invention. Figure 1 As shown, in this embodiment, the present invention provides a parallel chain arbitration consensus method applicable to a consensus node, and the method includes:

[0028] S11: In response to obtaining the first consensus transaction sending right of the first parallel chain block of the first height, generating a first random number;

[0029] S13: Generate a first consensus transaction for a first parallel chain block including a first hash value of a first random number;

[0030] S15: Send the first consensus transaction to the main chain for each consensus node of the current parallel chain to:

[0031] Execute the first consensus transaction to obtain the first execution result, and determine whether it is the same as the second execution result of the first height generated locally:

[0032] If yes, record the first hash value;

[0033] If not, a first arbitration transaction of the first height is generated and sent to the main chain for evidence storage;

[0034] Execute each arbitration transaction of the first height, and when each arbitration transaction passes consensus, determine the current node as an illegal node;

[0035] Determine whether the execution result of the first level has been saved locally:

[0036] If yes, then roll back the execution result of the first height, and re-determine the second consensus node that will send the first consensus transaction based on the first block data of the first main chain block corresponding to the third parallel chain block with the first height minus one, the second random number broadcasted by the consensus node that sent the third consensus transaction of the correct third parallel chain block, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes;

[0037] If not, the second consensus node is re-determined based on the first block data, the second random number, and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes;

[0038] S17: When the first consensus transaction is not successfully arbitrated, determine the first consensus node that will send the second consensus transaction of the second parallel chain block with the first height plus one according to the second block data of the second main chain block corresponding to the first parallel chain block, the first random number, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes; and

[0039] S19: Broadcast the first random number to each consensus node, so that each consensus node can determine the first consensus node according to the second block data, the first random number, and each node ID.

[0040] Specifically, "redetermine the second consensus node to send the first consensus transaction based on the first block data of the first main chain block corresponding to the third parallel chain block of the first height minus one, the second random number broadcasted by the consensus node that sends the correct third consensus transaction of the third parallel chain block, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes", and "redetermine the second consensus node based on the first block data, the second random number, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes" includes: "generate the first data based on the first block data and the second random number; calculate the first XOR value based on the first data and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes; redetermine the consensus node with the smallest first XOR value as the second consensus node", "redetermine the second consensus node based on the second main chain block corresponding to the first parallel chain block "determine the first consensus node that will send the second consensus transaction of the second parallel chain block with the first height plus one according to the second block data, the first random number, and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes", and "determine the first consensus node according to the second block data, the first random number, and the node IDs of the consensus nodes" includes: "generate the second data according to the second block data and the first random number; calculate the second XOR value according to the second data and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes; determine the consensus node with the smallest second XOR value as the first consensus node", the first block data is a block hash as an example; assume that there are a main chain and a parallel chain parachain1 in the blockchain system, and there are n1 to n7 on the parachain, where n1 to n7 are all consensus nodes; there are no illegal nodes in n1 to n7 at this time;

[0041] In response to obtaining the consensus transaction sending right of the first parallel chain block block (10_p1) of the first height, n1 executes step S11 to generate a random number R_n1;

[0042] n1 executes step S13 to generate consensus transaction tx1 of block(10_p1)_n1 including hash(R_n1);

[0043] n1 executes step S15 and sends tx1 to the main chain;

[0044] The main chain node generates a main chain block packaged with tx1, assuming it is block(100_main);

[0045] n1~n7 obtain and execute tx1 from the main chain to obtain the execution result result_n1;

[0046] n2 executes the locally generated block(10_p1)_n2 to obtain result_n2;

[0047] n3 executes the locally generated block(10_p1)_n3 to obtain result_n3;

[0048] n4 executes the locally generated block(10_p1)_n4 to obtain result_n4;

[0049] n5 executes the locally generated block(10_p1)_n5 to obtain result_n5;

[0050] n6 executes the locally generated block(10_p1)_n6 to obtain result_n6;

[0051] n7 executes the locally generated block(10_p1)_n7 to obtain result_n7;

[0052] Since there is no illegal node in n1~n7 at this time, result_n2~result_n7 ​​are the same as result_n1, so n2~n7 record hash(R_n1);

[0053] When tx1 is not successfully arbitrated, n1 executes step S17, generates Hs according to block hash blockhash(100_main) and R_n1, Hs = (blockhash(100_main), R_n1); calculates XOR values ​​according to Hs and node IDs of n1 to n7, and determines the consensus node with the smallest XOR value (assuming it is n2) as the consensus node to send the consensus transaction of block(11_p1);

[0054] n1 executes step S19 and broadcasts R_n1 to n2 to n7;

[0055] n2~n7 generate Hs according to blockhash(100_main) and R_n1, calculate the XOR value according to Hs and the node IDs of n1~n7 respectively, and determine the consensus node with the smallest XOR value (assuming it is n2) to determine the consensus node that will send the consensus transaction of block(11_p1).

[0056] Assume that n2 is an illegal node at this time;

[0057] In response to obtaining the consensus transaction sending right of block(11_p1), n2 executes step S11 to generate a random number R_n2;

[0058] n2 executes step S13 to generate consensus transaction tx2 of block(11_p1)_n2 including hash(R_n2);

[0059] n2 executes step S15 and sends tx2 to the main chain;

[0060] The main chain node generates a main chain block packaged with tx2, assuming it is block(110_main);

[0061] n1~n7 obtain the execution result result_n2' by obtaining and executing tx2 from the main chain;

[0062] n1 executes the locally generated block (11_p1)_n1 to obtain result_n1';

[0063] n3 executes the locally generated block(11_p1)_n3 to obtain result_n3';

[0064] n4 executes the locally generated block(11_p1)_n4 to obtain result_n4';

[0065] n5 executes the locally generated block(11_p1)_n5 to obtain result_n5';

[0066] n6 executes the locally generated block(11_p1)_n6 to obtain result_n6';

[0067] n7 executes the locally generated block(11_p1)_n7 to obtain result_n7';

[0068] Since n2 is an illegal node at this time, result_n1', result_n3'~result_n7' are all different from result_n2'. n1, n3~n7 respectively generate arbitration transactions of block(11_p1) and send them to the main chain;

[0069] The main chain deposits n1, n3~n7 respectively generate arbitration transactions for block(11_p1);

[0070] n1~n7 obtain and execute the arbitration transaction of block (11_p1) generated by n1, n3~n7 respectively from the main chain. When consensus is reached, n2 is determined as an illegal node.

[0071] Since n1, n3~n7 do not save the execution result of block(11_p1) locally, Hs is generated according to blockhash(100_main) and R_n1, and the XOR values ​​are calculated according to Hs, n1, and the node IDs of n3~n7 respectively. The consensus node with the smallest XOR value (assuming it is n3) is determined to be the consensus node that will send the consensus transaction of block(11_p1).

[0072] In more embodiments, the first block data may also be configured as other parameters according to actual needs, such as being configured as a state hash, to achieve the same technical effect.

[0073] In more embodiments, "redetermine the second consensus node to send the first consensus transaction based on the first block data of the first main chain block corresponding to the third parallel chain block of the first height minus one, the second random number broadcasted by the consensus node that sends the correct third consensus transaction of the third parallel chain block, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes", and "redetermine the second consensus node based on the first block data, the second random number, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes" can also be configured according to actual needs, for example, configured to generate first data based on the first block data and the second random number; calculate the first XOR value based on the first data and the node IDs of each consensus node of the current parallel chain excluding illegal nodes; and redetermine the consensus node with the largest first XOR value as the second consensus node. Correspondingly, "determine the first consensus node that will send the second consensus transaction of the second parallel chain block with the first height plus one according to the second block data of the second main chain block corresponding to the first parallel chain block, the first random number, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes", and "determine the first consensus node according to the second block data, the first random number, and each node ID" should be configured as follows: generate the second data according to the second block data and the first random number; calculate the second XOR value according to the second data and the node IDs of each consensus node of the current parallel chain excluding illegal nodes; determine the consensus node with the largest second XOR value as the first consensus node, which can achieve the same technical effect.

[0074] Those skilled in the art should understand that the right to send consensus transactions for two consecutive blocks should not be obtained by the same consensus node to prevent the consensus node from generating random numbers for the purpose of obtaining benefits.

[0075] Those skilled in the art should understand that, assuming that result_n4' of n4 is consistent with result_n2', n4 will not generate an arbitration transaction, but save result_n4' or result_n2' as the correct execution result of block(11_p1); and n4 executes the arbitration transaction of block(11_p1) generated by n1 and n3 to n7 respectively, and when the consensus transaction passes the consensus, n4 should first roll back the saved execution result of block(11_p1), and then determine the consensus node to which the consensus transaction of block(11_p1) will be sent.

[0076] Those skilled in the art should understand that the above block(10_p1) represents a parachain block with a height of 10 of parachain1. Since each parachain node generates a parachain block, block(10_p1)_n1 represents a parachain block with a height of 10 of parachain1 generated locally by n1, and block(10_p1)_n2 represents a parachain block with a height of 10 of parachain1 generated locally by n2, and so on.

[0077] Those skilled in the art should understand that if more and more consensus nodes are listed as illegal nodes, the parallel chain will eventually be unable to operate normally. A corresponding mechanism for recovering illegal nodes to normal nodes should be configured. For example, after n1 pays a certain recovery fee, n2~n7 can determine n1 as a normal consensus node.

[0078] Those skilled in the art should understand that in addition to consensus nodes, non-consensus nodes, such as n8 to n10, may also be configured on a parallel chain. Like consensus nodes, non-consensus nodes will also generate parallel chain blocks, but will not generate consensus transactions for parallel chain blocks; similarly, non-consensus nodes will not generate arbitration transactions.

[0079] Those skilled in the art should understand that, in the present embodiment, consensus transactions and arbitration transactions are stored on the main chain; in more embodiments, consensus transactions and arbitration transactions can be configured as transaction types that the main chain nodes also need to execute according to actual needs, and then the consensus transactions and arbitration transactions will be executed by the main chain nodes at the same time.

[0080] Since most of the parallel chain consensus nodes are trusted nodes and are not prone to errors, the possibility of needing to execute the above method is very small; therefore, overall, the above embodiment reduces the number of consensus transactions to be sent for a parallel chain block, reduces transaction fees, and at the same time ensures the consensus speed of the parallel chain.

[0081] Preferably, determining the first consensus node according to the second block data, the first random number, and each node ID includes:

[0082] Performing a hash operation on the first random number to obtain a second hash value;

[0083] When the second hash value is the same as the first hash value, the first consensus node is determined according to the second block data, the first random number, and each node ID.

[0084] Preferably, the second consensus node to be sent the first consensus transaction is re-determined according to the first block data of the first main chain block corresponding to the third parallel chain block of the first height minus one, the second random number broadcasted by the consensus node that sends the third consensus transaction of the correct third parallel chain block, and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes, and the second consensus node is re-determined according to the first block data, the second random number, and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes, and includes:

[0085] Generate first data according to the first block data and the second random number;

[0086] Calculate the first XOR value according to the first data and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes;

[0087] Re-determine the consensus node with the smallest first XOR value as the second consensus node;

[0088] Determining the first consensus node that will send the second consensus transaction of the second parallel chain block with the first height plus one according to the second block data of the second main chain block corresponding to the first parallel chain block, the first random number, and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes, and determining the first consensus node according to the second block data, the first random number, and the node IDs includes:

[0089] Generate second data according to the second block data and the first random number;

[0090] Calculate the second XOR value according to the second data and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes;

[0091] The consensus node with the smallest second XOR value is determined as the first consensus node.

[0092] The parallel chain arbitration consensus principle of the above embodiment can be referred to Figure 1 The method shown will not be repeated here.

[0093] Preferably, the node ID of each parallel chain node is recorded on the main chain, and the second consensus node to send the first consensus transaction is re-determined according to the first block data of the first main chain block corresponding to the third parallel chain block of the first height minus one, the second random number broadcasted by the consensus node that sends the third consensus transaction of the correct third parallel chain block, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes, and the second consensus node is re-determined according to the first block data, the second random number, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes. The second consensus node is re-determined according to the first block data, the second random number, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes. The second consensus node includes:

[0094] Get the node ID of each consensus node of the current parallel chain from the main chain;

[0095] The second consensus node is re-determined based on the first block data, the second random number, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes.

[0096] Determining the first consensus node that will send the second consensus transaction of the second parallel chain block with the first height plus one according to the second block data of the second main chain block corresponding to the first parallel chain block, the first random number, and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes, and determining the first consensus node according to the second block data, the first random number, and the node IDs includes:

[0097] Get the node ID of each consensus node of the current parallel chain from the main chain;

[0098] The first consensus node is determined according to the second block data, the first random number, and each node ID.

[0099] In more embodiments, the consensus node can also obtain the node ID of each consensus node of the current parallel chain through other means; for example, obtaining the node ID of each consensus node of the current parallel chain through the first cloud platform can achieve the same technical effect.

[0100] Before generating a first consensus transaction of a first parallel chain block including a first hash value of a first random number, the method further includes:

[0101] Receive third random numbers generated by a first number of third consensus nodes and broadcast to the main chain; wherein the first number of third consensus nodes are determined according to a preconfigured random node determination rule and a first height;

[0102] Generating a first consensus transaction for a first parachain block including a first hash value of a first random number includes:

[0103] Generate a first consensus transaction for a first parallel chain block including a first hash value and a third hash value of each third random number;

[0104] Re-determining the second consensus node to send the first consensus transaction according to the first block data of the first main chain block corresponding to the third parallel chain block of the first height minus one, the second random number broadcasted by the consensus node that sends the third consensus transaction of the correct third parallel chain block, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes, and re-determining the second consensus node according to the first block data, the second random number, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes includes:

[0105] Re-determine the second consensus node according to the first block data, the second number of fourth random numbers, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes; wherein the second number of fourth random numbers are generated by the second number of fourth consensus nodes respectively, the second number of fourth consensus nodes are determined according to the random node determination rule and the first height minus one, the second random number is included in the first number of fourth random numbers, and the second number is equal to the first number plus one;

[0106] Determining the first consensus node that will send the second consensus transaction of the second parallel chain block with the first height plus one according to the second block data of the second main chain block corresponding to the first parallel chain block, the first random number, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes, and determining the first consensus node according to the second block data, the first random number, and each node ID includes:

[0107] The first consensus node that is to send the second consensus transaction of the second parallel chain block with the first height plus one is determined according to the second block data, the first random number, each third random number, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes.

[0108] The above embodiments and Figure 1 The embodiment shown differs in that Figure 1 In the embodiment shown, the consensus node that sends the consensus transaction of the next block height is generated based on a random number generated by the consensus node that sends the consensus transaction of the current block height. In this embodiment, the consensus node that sends the consensus transaction of the next block height is determined based on the consensus node that sends the consensus transaction of the current block height and the random numbers generated by several consensus nodes. Figure 1 Compared with the method shown in the embodiment, the method of this embodiment is more random, and the determination of the consensus node that sends the consensus transaction of the next block height is more random.

[0109] Further preferably, re-determining the second consensus node based on the first block data, the second number of fourth random numbers, and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes includes:

[0110] Generate third data according to the first block data and a second number of fourth random numbers;

[0111] Calculate the third XOR value according to the third data and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes;

[0112] The consensus node with the smallest third XOR value is re-determined as the second consensus node;

[0113] Selecting a second number of consensus nodes as consensus nodes for generating and broadcasting a fourth random number in ascending order of the third XOR values;

[0114] The first consensus node for sending the second consensus transaction of the second parallel chain block with the first height plus one is determined according to the second block data, the first random number, each third random number, and the node ID of each consensus node of the current parallel chain excluding the illegal nodes, including:

[0115] Generate fourth data according to the second block data, the first random number, and each third random number;

[0116] Calculate the fourth XOR value according to the fourth data and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes;

[0117] The consensus node with the smallest fourth XOR value is re-determined as the first consensus node;

[0118] Starting from the second smallest fourth XOR value, a first number of consensus nodes are selected according to the order of the fourth XOR values ​​from small to large as consensus nodes for generating and broadcasting the third random number.

[0119] Further preferably, the node ID of each parallel chain node is recorded on the main chain, and re-determining the second consensus node according to the first block data, the second number of fourth random numbers, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes includes:

[0120] Get the node ID of each consensus node of the current parallel chain from the main chain;

[0121] Re-determine the second consensus node according to the first block data, the second number of fourth random numbers, and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes;

[0122] The first consensus node for sending the second consensus transaction of the second parallel chain block with the first height plus one is determined according to the second block data, the first random number, each third random number, and the node ID of each consensus node of the current parallel chain excluding the illegal nodes, including:

[0123] Get the node ID of each consensus node of the current parallel chain from the main chain;

[0124] The first consensus node that is to send the second consensus transaction of the second parallel chain block with the first height plus one is determined according to the second block data, the first random number, each third random number, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes.

[0125] Figure 2 A schematic diagram of the structure of a computer device provided by an embodiment of the present invention.

[0126] like Figure 2 As shown, as another aspect, the present application also provides a computer device, including one or more central processing units (CPU) 201, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 202 or the program loaded from the storage part 208 to the random access memory (RAM) 203. In the RAM 203, various programs and data required for the operation of the computer device are also stored. The CPU 201, the ROM 202, and the RAM 203 are connected to each other via a bus 204. An input / output (I / O) interface 205 is also connected to the bus 204.

[0127] The following components are connected to the I / O interface 205: an input section 206 including a keyboard, a mouse, etc.; an output section 207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 208 including a hard disk, etc.; and a communication section 209 including a network interface card such as a LAN card, a modem, etc. The communication section 209 performs communication processing via a network such as the Internet. A drive 210 is also connected to the I / O interface 205 as needed. A removable medium 211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 210 as needed, so that a computer program read therefrom is installed into the storage section 208 as needed.

[0128] In particular, according to an embodiment of the present disclosure, the method described in any of the above embodiments can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program tangibly contained on a machine-readable medium, and the computer program includes a program code for executing any of the above methods. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 209, and / or installed from the removable medium 211.

[0129] As another aspect, the present application also provides a computer-readable storage medium, which may be the computer-readable storage medium included in the apparatus of the above embodiment; or may be a computer-readable storage medium that exists independently and is not assembled into a computer device. The computer-readable storage medium stores one or more programs, which are used by one or more processors to execute the method described in the present application.

[0130] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be realized by a dedicated hardware-based system that performs a specified function or operation, or can be realized by a combination of dedicated hardware and computer instructions.

[0131] The units or modules involved in the embodiments described in the present application may be implemented by software or by hardware. The units or modules described may also be arranged in a processor. For example, each of the units may be a software program arranged in a computer or a mobile smart device, or may be a separately configured hardware device. The names of these units or modules do not, in some cases, constitute limitations on the units or modules themselves.

[0132] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the concept of the present application. For example, the above features are replaced with the technical features with similar functions disclosed in the present application (but not limited to) to form a technical solution.

Claims

1. A parallel chain arbitration consensus method, characterized in that: Applicable to a consensus node, the method comprises: In response to obtaining a first consensus transaction sending right for a first parallel chain block at a first height, generating a first random number; Generate a first consensus transaction for the first parachain block including a first hash value of the first random number; Send the first consensus transaction to the main chain for each consensus node of the current parallel chain to: Execute the first consensus transaction to obtain a first execution result, and determine whether it is the same as the second execution result of the first height generated locally: If yes, record the first hash value; If no, then generate the first arbitration transaction of the first height and send it to the main chain for evidence storage; Execute each arbitration transaction of the first height, and when each arbitration transaction passes consensus, determine the current node as an illegal node; Determine whether the execution result of the first height has been saved locally: If yes, then roll back the execution result of the first height, and re-determine the second consensus node to send the first consensus transaction based on the first block data of the first main chain block corresponding to the third parallel chain block of the first height minus one, the second random number broadcasted by the consensus node that sent the correct third consensus transaction of the third parallel chain block, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes; If not, the second consensus node is re-determined according to the first block data, the second random number, and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes; When the first consensus transaction is not successfully arbitrated, the first consensus node that is to send the second consensus transaction of the second parallel chain block with the first height plus one is determined according to the second block data of the second main chain block corresponding to the first parallel chain block, the first random number, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes; and the first random number is broadcasted to each of the consensus nodes so that each of the consensus nodes can determine the first consensus node according to the second block data, the first random number, and each of the node IDs.

2. The method according to claim 1, characterized in that: Determining the first consensus node according to the second block data, the first random number, and each of the node IDs includes: Performing a hash operation on the first random number to obtain a second hash value; When the second hash value is the same as the first hash value, the first consensus node is determined according to the second block data, the first random number, and each of the node IDs.

3. The method according to claim 1, characterized in that The method of re-determining the second consensus node to send the first consensus transaction according to the first block data of the first main chain block corresponding to the third parallel chain block of the first height minus one, the second random number broadcasted by the consensus node that sends the correct third consensus transaction of the third parallel chain block, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes, and the method of re-determining the second consensus node according to the first block data, the second random number, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes includes: Generate first data according to the first block data and the second random number; calculate a first XOR value according to the first data and the node IDs of each consensus node of the current parallel chain excluding illegal nodes; Re-determine the consensus node with the smallest first XOR value as the second consensus node; The determining of the first consensus node to send the second consensus transaction of the second parallel chain block with the first height plus one according to the second block data of the second main chain block corresponding to the first parallel chain block, the first random number, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes, and the determining of the first consensus node according to the second block data, the first random number, and the node IDs includes: generating second data according to the second block data and the first random number; Calculate the second XOR value according to the second data and the node ID of each consensus node of the current parallel chain excluding illegal nodes; The consensus node with the smallest second XOR value is determined as the first consensus node.

4. The method according to any one of claims 1 to 3, characterized in that: The node ID of each parallel chain node is recorded on the main chain, and the second consensus node to be sent the first consensus transaction is re-determined according to the first block data of the first main chain block corresponding to the third parallel chain block of the first height minus one, the second random number broadcasted by the consensus node that sends the correct third consensus transaction of the third parallel chain block, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes, and the second consensus node is re-determined according to the first block data, the second random number, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes. The second consensus node is included: Get the node ID of each consensus node of the current parallel chain from the main chain; Re-determine the second consensus node according to the first block data, the second random number, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes; The method of determining the first consensus node to send the second consensus transaction of the second parallel chain block with the first height plus one according to the second block data of the second main chain block corresponding to the first parallel chain block, the first random number, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes, and determining the first consensus node according to the second block data, the first random number, and the node IDs includes: Get the node ID of each consensus node of the current parallel chain from the main chain; The first consensus node is determined according to the second block data, the first random number, and each of the node IDs.

5. The method according to claim 1, characterized in that Before generating the first consensus transaction of the first parallel chain block including the first hash value of the first random number, the process further includes: Receive third random numbers generated by a first number of third consensus nodes and broadcast to the main chain; wherein the first number of third consensus nodes are determined according to a preconfigured random node determination rule and the first height; The first consensus transaction for generating the first parallel chain block including the first hash value of the first random number includes: Generate a first consensus transaction for the first parallel chain block including the first hash value and a third hash value of each of the third random numbers; The method of re-determining the second consensus node to send the first consensus transaction according to the first block data of the first main chain block corresponding to the third parallel chain block of the first height minus one, the second random number broadcasted by the consensus node that sends the correct third consensus transaction of the third parallel chain block, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes, and the method of re-determining the second consensus node according to the first block data, the second random number, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes includes: The second consensus node is re-determined according to the first block data, the second number of fourth random numbers, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes; wherein the second number of fourth random numbers are generated by the second number of fourth consensus nodes respectively, the second number of fourth consensus nodes are determined according to the random node determination rule and the first height minus one, the second random number is included in the first number of fourth random numbers, and the second number is equal to the first number plus one; The determining of the first consensus node to send the second consensus transaction of the second parallel chain block with the first height plus one according to the second block data of the second main chain block corresponding to the first parallel chain block, the first random number, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes, and the determining of the first consensus node according to the second block data, the first random number, and the node IDs includes: Determine the first consensus node that will send the second consensus transaction of the second parallel chain block with the first height plus one based on the second block data, the first random number, each of the third random numbers, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes.

6. The method according to claim 5, characterized in that The re-determining the second consensus node according to the first block data, the second number of fourth random numbers, and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes includes: generating third data according to the first block data and the second number of fourth random numbers; calculating a third XOR value according to the third data and the node IDs of the consensus nodes of the current parallel chain excluding the illegal nodes; Re-determine the consensus node with the smallest third XOR value as the second consensus node; Selecting a second number of consensus nodes as consensus nodes for generating and broadcasting the fourth random number according to the third XOR value in ascending order; The method of determining the first consensus node to send the second consensus transaction of the second parallel chain block with the first height plus one according to the second block data, the first random number, each of the third random numbers, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes includes: Generate fourth data according to the second block data, the first random number, and each of the third random numbers; Calculate a fourth XOR value according to the fourth data and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes; Re-determining the consensus node with the smallest fourth XOR value as the first consensus node; Starting from the second smallest fourth XOR value, a first number of consensus nodes are selected according to the order of the fourth XOR values ​​from small to large as consensus nodes for generating and broadcasting the third random number.

7. The method according to claim 5 or 6, characterized in that: The node ID of each parallel chain node is recorded on the main chain, and the re-determining of the second consensus node according to the first block data, the second number of fourth random numbers, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes includes: Get the node ID of each consensus node of the current parallel chain from the main chain; Re-determine the second consensus node according to the first block data, the second number of fourth random numbers, and the node IDs of the consensus nodes of the current parallel chain excluding illegal nodes; The method of determining the first consensus node to send the second consensus transaction of the second parallel chain block with the first height plus one according to the second block data, the first random number, each of the third random numbers, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes includes: Get the node ID of each consensus node of the current parallel chain from the main chain; Determine the first consensus node that will send the second consensus transaction of the second parallel chain block with the first height plus one based on the second block data, the first random number, each of the third random numbers, and the node IDs of each consensus node of the current parallel chain excluding illegal nodes.

8. A computer device, characterized in that: The device comprises: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors are caused to perform the method according to any one of claims 1 to 7.

9. A storage medium storing a computer program, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.