Transaction sending method, computer device and storage medium

By aggregating consensus transactions between parachain nodes and sending them to the main chain, the problems of unfair handling fees and insufficient consensus stability in the main chain-parallel chain mechanism are solved, and a relatively fair fee allocation and concise and stability of parachain consensus are achieved. .

CN114140102BActive Publication Date: 2025-01-07ORDOS ZONGBAO TECHNOLOGY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111457984.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-02
Publication Date
2025-01-07
Estimated Expiration
2041-12-02

AI Technical Summary

Technical Problem

In the main chain-parallel chain mechanism, having only one parachain node sends aggregate consensus transactions lead to unfair handling fees and insufficient stability of parachain consensus.

Method used

When the current node is the leader node of the first block height, it obtains the consensus content of the first block height generated by other parachain nodes, aggregates and generates the first aggregate consensus transaction, and sends it to the main chain to ensure the handling fee Payment is fair and the parachain consensus is concise and stable.

Benefits of technology

It realizes fair distribution of handling fees, and maintains the simplicity and stability of parachain consensus, avoiding the problem of overload of a single node.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114140102B_ABST
    Figure CN114140102B_ABST
Patent Text Reader

Abstract

The present invention provides a transaction sending method, a computer device and a storage medium, the method comprising: when the current node is the leader node of the first block height, obtaining the first consensus content of the first block height generated by other parallel chain nodes of the current parallel chain respectively; generating a first aggregate consensus transaction of the first block height according to the second consensus content of the first block height generated by the current node and the first consensus content; sending the first aggregate consensus transaction to the main chain. The application makes the handling fee payment more fair and keeps the parallel chain consensus simple and stable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of parallel chain technology, and specifically to a transaction sending method, computer device and storage medium. Background Art

[0002] In the existing main chain-parallel chain mechanism, if only one parallel chain node is allowed to send an aggregate consensus transaction, only the transaction fee of that node will be consumed, which is very unfair. Summary of the invention

[0003] In view of the above-mentioned defects or deficiencies in the prior art, it is desired to provide a transaction sending method, computer device and storage medium that is fairer and maintains a simple and stable parallel chain consensus.

[0004] In a first aspect, the present invention provides a transaction sending method, a computer device and a storage medium applicable to a parachain node, wherein the parachain nodes on the same parachain can communicate with each other, and the order of each parachain node is fixed and serves as a leader node in turn, and the above method includes:

[0005] When the current node is the leader node of the first block height, obtain the first consensus content of the first block height generated by other parallel chain nodes of the current parallel chain;

[0006] The first aggregate consensus transaction of the first block height is generated based on the second consensus content of the first block height generated by the current node and the first consensus contents;

[0007] Send the first aggregate consensus transaction to the main chain.

[0008] In a second aspect, the present invention further 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 transaction sending method provided according to various embodiments of the present invention.

[0009] In a third aspect, the present invention further provides a storage medium storing a computer program, wherein the computer program enables a computer to execute the transaction sending method provided according to each embodiment of the present invention.

[0010] The transaction sending method, computer device and storage medium provided by many embodiments of the present invention obtain the first consensus content of the first block height generated by other parallel chain nodes of the current parallel chain respectively when the current node is the leading node of the first block height; generate the first aggregate consensus transaction of the first block height according to the second consensus content of the first block height generated by the current node and the aggregation of each first consensus content; send the first aggregate consensus transaction to the main chain, so that the payment of handling fees is relatively fair and the parallel chain consensus is kept simple and stable. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] 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:

[0012] Figure 1 A flowchart of a transaction sending method provided by an embodiment of the present invention.

[0013] Figure 2 for Figure 1 A flowchart of step S12 in a preferred implementation of the method shown.

[0014] Figure 3 for Figure 2 A flow chart of a preferred embodiment of the method is shown.

[0015] Figure 4 for Figure 3 A flow chart of a preferred embodiment of the method is shown.

[0016] Figure 5 A schematic diagram of the structure of a device provided in one embodiment of the present invention. DETAILED DESCRIPTION

[0017] 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.

[0018] 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.

[0019] Figure 1 A flow chart of a transaction sending method provided by an embodiment of the present invention. Figure 1 As shown, in this embodiment, the present invention provides a transaction sending method, a computer device and a storage medium applicable to a parachain node. Parachain nodes on the same parachain can communicate with each other, and the order of each parachain node is fixed and serves as a leader node in turn. The above method includes:

[0020] S12: When the current node is the leader node of the first block height, obtain the first consensus content of the first block height generated by other parallel chain nodes of the current parallel chain;

[0021] S13: Generate a first aggregate consensus transaction of the first block height based on the second consensus content of the first block height generated by the current node and the first consensus contents;

[0022] S14: Send the first aggregate consensus transaction to the main chain.

[0023] Specifically, each parallel chain node of the current parallel chain is sequentially configured with a node index, and is configured with a base index with an initial value of 0; S12 includes "calculating base = (height / M)% nodes; wherein height is the first block height, M is a pre-configured first value, and nodes is the number of parallel chain nodes of the current parallel chain; when the calculated base value is consistent with the node index of the current node, obtaining the first consensus content of the first block height generated by other parallel chain nodes of the current parallel chain respectively" as an example;

[0024] Assume that the current blockchain is parachain1 (hereinafter referred to as pc1), and there are parachain nodes N1 to N4 on pc1; the node indexes of N1 to N4 are 0 to 3 respectively; M is 100; the first block height is 10; the current node is N1;

[0025] Assume that there is a parachain transaction tx1 of pc1 in the main chain block block(100_main); N1~N4 generate parachain blocks and consensus content according to tx1 respectively; the parachain blocks generated by N1~N4 are block(10_pc1)_N1~block(10_pc1)_N4 respectively, and the consensus content generated by N1~N4 is msg(10)_N1~msg(10)_N4 respectively;

[0026] N1 executes step S12, calculates base = (height / M)% nodes = (10 / 100)% 4 = 0; since 0 is consistent with the node index of N1, N1 is determined to be the leader node of 10; N1 obtains the consensus content msg(10)_N2~msg(10)_N4 of block height 10 from N2~N4;

[0027] N1 executes step S13, and generates an aggregate consensus transaction tx2 with a block height of 10 based on msg(10)_N1, msg(10)_N2 to msg(10)_N4;

[0028] N1 executes step S14 and sends tx2 to the main chain.

[0029] It can be seen that N1~N4 are uniformly rotated every 100 block heights;

[0030] In more embodiments, assuming that consensus nodes and non-consensus nodes are configured on the parallel chain, the above method can be completed only by the consensus nodes.

[0031] In more embodiments, step S12 can be configured according to actual needs, for example, configured as: calculate base = height% nodes; when the calculated base value is consistent with the node index of the current node, obtain the first consensus content of the first block height generated by other parallel chain nodes of the current parallel chain; the same technical effect can be achieved.

[0032] How N1 generates tx2 based on msg(10)_N1, msg(10)_N2~msg(10)_N4, and how the main chain node executes tx2 after tx2 is sent to the main chain can refer to the prior art, such as the patent application previously filed by the applicant (application number: 202010631494.9), which is not specifically limited here.

[0033] The above embodiments make the handling fee expenditure more fair and keep the parallel chain consensus simple and stable.

[0034] Figure 2 for Figure 1 The flowchart of step S12 in a preferred embodiment of the method shown in FIG. Figure 2 As shown, in a preferred embodiment, each parallel chain node of the current parallel chain is sequentially configured with a node index and a base index with an initial value of 0; step S12 includes:

[0035] S121: Calculate base = (height / M)% nodes; where height is the first block height, M is the preconfigured first value, and nodes is the number of parallel chain nodes of the current parallel chain;

[0036] S122: When the calculated base value is consistent with the node index of the current node, obtain the first consensus content of the first block height generated by other parallel chain nodes of the current parallel chain.

[0037] The transaction sending principle of the above embodiment can be referred to Figure 1 The method shown will not be repeated here.

[0038] Figure 3 for Figure 2 A flow chart of a preferred embodiment of the method shown. Figure 3 As shown, in a preferred embodiment, each parallel chain node of the current parallel chain is configured with an offset parameter, and the above method also includes:

[0039] S15: Broadcast the first heartbeat to other parallel chain nodes of the current parallel chain at first intervals, so that other parallel chain nodes:

[0040] When the first heartbeat is not received within the second time period, offset=(offset+1)%nodes is calculated; wherein the second time period is longer than the first time period;

[0041] Calculate base = (base + offset) % nodes;

[0042] The parallel chain node with the same node index as the calculated base value is determined as the new leader node.

[0043] Specifically, take the first duration as 2s and the second duration as 10s as an example;

[0044] N1 executes step S15 and broadcasts heartbeats to N2 to N4 every 2 seconds;

[0045] For N2~N4: If the heartbeat broadcast by N1 is not received within 10s, calculate offset=(offset+1)%nodes; then according to base=(base+offset)%nodes, uniquely determine a parallel chain node with the same node index as the calculated base value as the new leader node.

[0046] Specifically, N2 to N4 can be divided into two cases:

[0047] a) If N1 does not broadcast the heartbeat, N2~N4 reselect a new leader node; taking N2 as an example, if it finds that the selected new leader node is itself, N2 broadcasts the heartbeat;

[0048] b) Taking N2 as an example, if only N2 loses connection and does not receive the heartbeat broadcast by N1, N2 will shift to the leader node by itself. N2 will wait until it becomes the leader node (with Figure 1 For the embodiment shown, N2 has to wait until block height 100) to broadcast the heartbeat.

[0049] The above-mentioned embodiments ensure that the leadership node is switched in a timely manner, further maintaining the stability of the parallel chain consensus.

[0050] Figure 4 for Figure 3 A flow chart of a preferred embodiment of the method shown. Figure 4 As shown, in a preferred embodiment, the first heartbeat includes a calculated base value and a calculated offset value; the above method also includes:

[0051] S16: receiving the second heartbeat;

[0052] S171: Determine whether the base value in the second heartbeat is the same as the base value in the first heartbeat:

[0053] If they are not the same, execute step S172: end;

[0054] If they are the same, execute step S1731: determine whether the offset value in the second heartbeat is greater than the offset value in the first heartbeat:

[0055] When it is greater than, execute step S1732: determine the parallel chain node that sends the second heartbeat as the leader node of the first block height, and update the offset value of the current node to the offset value in the second heartbeat;

[0056] When it is not greater than, execute step S1733: end.

[0057] It can be seen that if the bases of the two heartbeats are different, the process ends, indicating that the two heartbeats are not from the same block height; if the bases are the same but the offsets are different, the heartbeat node with the larger offset is used as the leader node, and the offset of the current node is updated.

[0058] The above embodiments further ensure that the leadership node is switched in a timely manner, further maintaining the stability of the parallel chain consensus.

[0059] Preferably, before step S12, the method further includes:

[0060] Obtain a first main chain block from the main chain, and generate a first parachain block of a first block height according to each parachain transaction of the current parachain in the first main chain block;

[0061] Among them, the first main chain block is generated by the main chain node according to the first transactions in the first to-be-packaged queue of the first main chain block height of the first main chain block; when the main chain node receives the first transaction, it calculates according to the preconfigured transaction storage rule that the first transaction should be stored in the first to-be-packaged queue when the first main chain block height is packaged; the difference between the first main chain block height and the second main chain block height of the second main chain block generated most recently when the first transaction is received is greater than the second value; the first transaction includes the main chain transaction and the parallel chain transaction; the generation of the second main chain block and the storage of the first transaction are executed in parallel.

[0062] Specifically, taking the calculation that the first transaction should be stored in the first queue to be packaged when the first main chain block height is packaged according to the preconfigured transaction storage rule as "obtaining the first N-ary number of the first M bits of the first full hash of the first transaction; calculating the third main chain block height; wherein the calculation method of the third main chain block height is: min(h1) mod N^M===>>>(x1)2, min(h1)>current main chain block height+second value+1, min(h1) is the third main chain block height, (x1)2 is the first N-ary number; and, determining the third main chain block height as the first main chain block height; storing the first transaction in the first queue to be packaged" as an example;

[0063] Assume that the main chain node receives tx1 when the main chain block height is 93; the first 3 binary digits of tx1's full hash are 100, and the second digit is 5;

[0064] The main chain node obtains the first 3 binary digits of the full hash of tx1, which is 100;

[0065] The main chain node calculates the main chain block height, and the calculated main chain block height is 100;

[0066] The main chain node determines 100 as the main chain block height for packaging tx1, and the main chain node stores tx1 in the queue to be packaged at the main chain block height 100;

[0067] The main chain node generates block (93_main) according to each transaction in the queue to be packaged at the main chain block height 93;

[0068] Generate block (93_main) and store tx1 in the queue to be packaged at the main chain block height 100 in parallel.

[0069] In more embodiments, the transaction storage rules may be configured according to actual needs to configure the method for determining the height of the first main chain block, thereby achieving the same technical effect.

[0070] The above embodiments improve the throughput of the main chain.

[0071] Figure 5 A schematic diagram of the structure of a device provided in one embodiment of the present invention.

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

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

[0074] 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 509, and / or installed from a removable medium 511.

[0075] As another aspect, the present application also provides a computer-readable storage medium, which may be a computer-readable storage medium included in the apparatus of the above embodiment; or a computer-readable storage medium that exists independently and is not assembled into the 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.

[0076] 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.

[0077] 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.

[0078] 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 transaction sending method, characterized in that: Parallel chain nodes on the same parachain can communicate with each other, and the order of each of the parachain nodes is fixed and they serve as leader nodes in turn. The method is applicable to parachain nodes, and the method includes: when the current node is the leader node of the first block height, obtaining the first consensus content of the first block height generated by other parachain nodes of the current parachain respectively; Generate a first aggregate consensus transaction of the first block height according to the second consensus content of the first block height generated by the current node and the aggregation of the first consensus contents; Send the first aggregate consensus transaction to the main chain.

2. The method according to claim 1, characterized in that Each parachain node of the current parachain is configured with a node index in turn, and a base index with an initial value of 0; When the current node is the leader node of the first block height, obtaining the first consensus content of the first block height generated by other first parallel chain nodes of the current parallel chain includes: calculating base=(height / M)%nodes; wherein height is the first block height, M is a preconfigured first value, and nodes is the number of parallel chain nodes of the current parallel chain; When the calculated base value is consistent with the node index of the current node, the first consensus content of the first block height generated by other parallel chain nodes of the current parallel chain is obtained.

3. The method according to claim 2, characterized in that Each parallel chain node of the current parallel chain is configured with an offset parameter, and the method further includes: broadcasting a first heartbeat to other parallel chain nodes of the current parallel chain every first time period, so that other parallel chain nodes: when the first heartbeat is not received within a second time period, calculating offset=(offset+1)%nodes; wherein the second time period is longer than the first time period; Calculate base = (base + offset) % nodes; The parallel chain node with the same node index as the calculated base value is determined as the new leader node.

4. The method according to claim 3, characterized in that The first heartbeat includes a calculated base value and a calculated offset value; the method further includes: receiving a second heartbeat; Determine whether the base value in the second heartbeat is the same as the base value in the first heartbeat: if they are not the same, end; If they are the same, determine whether the offset value in the second heartbeat is greater than the offset value in the first heartbeat: if it is greater, determine the parallel chain node that sends the second heartbeat as the leader node of the first block height, and update the offset value of the current node to the offset value in the second heartbeat; When it is not greater than, end.

5. The method according to claim 1, characterized in that When the current node is the leader node of the first block height, before obtaining the first consensus content of the first block height generated by other parallel chain nodes of the current parallel chain, the method further includes: obtaining the first main chain block from the main chain, and generating the first parallel chain block of the first block height according to each parallel chain transaction of the current parallel chain in the first main chain block; Among them, the first main chain block is generated by the main chain node according to the first transactions in the first to-be-packaged queue of the first main chain block height of the first main chain block; the first transaction is calculated by the main chain node when receiving the first transaction according to the preconfigured transaction storage rule that the first transaction should be stored in the first to-be-packaged queue when the first main chain block height is packaged; the difference between the first main chain block height and the second main chain block height of the second main chain block generated most recently when the first transaction is received is greater than a second value; the first transaction includes a main chain transaction and a parallel chain transaction; generating the second main chain block and storing the first transaction are executed in parallel.

Citation Information

Patent Citations

  • Parallel chain consensus methods, devices, and storage media

    CN111798238B

  • Consensus method based on cross-chain transaction, device thereof and storage medium

    CN107909369A

  • Block chain consensus method, device and equipment and computer readable storage medium

    CN109831425A