A consensus method, device and storage medium for pre-specified transaction height

Through binary conversion of transaction hashing and block height, the pre-specified height and packaging of transactions are achieved, which solves the problem of low serial processing efficiency caused by unknown transaction order in the blockchain consensus, and improves the efficiency and consistency of transaction processing. Process transaction data in parallel.

CN114817280BActive Publication Date: 2025-01-07HUNAN SHENGCHEN ENTERPRISE CONSULTING MANAGEMENT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210370537.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-10
Publication Date
2025-01-07
Estimated Expiration
2042-04-10

AI Technical Summary

Technical Problem

During the consensus process on the blockchain, the latter block cannot predict the transaction and packaging order of the previous block, resulting in low data transmission and storage efficiency and serial processing must be used.

Method used

Through binary conversion of transaction hash and block height, transactions are pre-sorted, and parallel processing is carried out, and transaction consistency is confirmed by using comparison groups, the storage pressure of consensus nodes is reduced, and the pre-specified height and packaging of transactions are achieved.

Benefits of technology

It improves the efficiency of transaction processing, ensures the consistency of pre-specified results of transactions by different nodes, and processes transaction data in parallel, reducing the storage and network resource requirements of consensus nodes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114817280B_ABST
    Figure CN114817280B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of computer technology, and more particularly to a consensus method, device and storage medium for pre-specifying transaction heights. The present invention utilizes binary conversion of transaction hashes and binary conversion of pre-specified block heights to pre-specify packaged block heights for transactions, and presets the specifiable block heights to ensure that most different nodes will classify the same transaction at the same height, and then confirm the transaction list of a certain height of the current data storage node through a comparison group to ensure the consistency of pre-specified results of transactions at different nodes, and then verify and reach consensus through consensus nodes, so as to arrange transactions before packaging and reach consensus in an orderly manner, so as to achieve a certain degree of parallelism and effectively improve efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology, and in particular, relates to a consensus method, device and storage medium for pre-specifying a transaction height. Background Art

[0002] The consensus on the blockchain is that generally at a new block height, a node will submit a new block, and the node will determine a batch of transactions and the order of these transactions. After other nodes approve the new block, they will submit the next new block. The problem here is that the latter block does not know the transactions of the previous block and the order of packaged transactions, so serial data storage and data storage must be used, and efficiency is difficult to improve. Summary of the invention

[0003] In order to solve the above problems, the present invention provides a consensus method, device and storage medium for pre-specified transaction heights, which pre-sort transactions, process transactions in parallel, and improve efficiency.

[0004] The present invention adopts the following technical solutions:

[0005] In a first aspect, the present invention provides a block consensus method for specifying a high transaction height, the method being applicable to a blockchain system, the blockchain system comprising a plurality of data storage nodes and a consensus node, and characterized in that the method comprises:

[0006] The first data storage node receives the first transaction sent by the user, obtains the transaction hash of the first transaction and converts it into binary, and obtains the highly identifiable field data therein according to the preset value for marking;

[0007] According to the preset determined pre-specified height interval, all block heights within the pre-specified height interval are converted into binary and preset height matching field data is extracted to mark the height, and the length of the height matching field data is consistent with the length of the height identification field data; wherein the range of the pre-specified height interval is set according to the length of the height matching field data;

[0008] Matching the height identification field data of the first transaction with all block heights within a pre-specified height range to determine a pre-specified height of the first transaction, recorded as a first height;

[0009] When the difference between the first height and the current height is a preset first value, the blockchain system randomly selects a group of data storage nodes as a comparison group for the first data storage node, obtains all transactions with a pre-specified height of the first height in the first data storage node and its comparison group, removes duplicates to obtain a first transaction list, traverses the transactions in the first transaction list and compares them with the transactions in the comparison group one by one, and when more than 2 / 3 of the data storage nodes in the comparison group have the transaction, it is added to the second transaction list, and the traversal is completed to obtain the second transaction list;

[0010] When the first data storage node receives the request for obtaining transaction data with a pre-specified height being the first height sent by the first consensus node, the first data storage node sends the second transaction list and its Merkle root to the first consensus node;

[0011] The first consensus node obtains the transaction lists and corresponding Merkle roots sent by multiple data storage nodes, selects data consistent with at least 2 / 3 of the data storage nodes as consensus data, and performs consensus.

[0012] Preferably, after receiving the first transaction sent by the user, the first data storage node further includes verifying the transaction signature of the first transaction, and directly refusing to receive the signature if it is invalid.

[0013] Preferably, before reaching consensus, the consensus nodes verify the validity of all transactions in the consensus data, eliminate invalid transactions, and then reach consensus.

[0014] In a second aspect, a computer device is provided, comprising one or more processors;

[0015] a memory for storing one or more programs,

[0016] When the one or more programs are executed by the one or more processors, the one or more processors execute the method as described in the first aspect above.

[0017] According to a third aspect, a storage medium storing a computer program is provided, and when the program is executed by a processor, the method described in the first aspect is implemented.

[0018] The beneficial effect of the present invention lies in utilizing the binary conversion of transaction hashes and the binary conversion of pre-specified block heights to pre-specify packaged block heights for transactions, and preset the specifiable block heights at the same time, ensuring that most different nodes will classify the same transaction at the same height, and then confirming the transaction list of a certain height of the current data storage node through a comparison group, ensuring the consistency of the pre-specified results of transactions at different nodes, and then verifying and reaching consensus through the consensus node, thereby arranging transactions before packaging and reaching consensus in an orderly manner, achieving a certain degree of parallelism, and effectively improving efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 A flowchart of a consensus method for pre-specifying transaction heights provided by an embodiment of the present invention;

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

[0021] The present invention is further described in detail below in conjunction with specific embodiments and the accompanying drawings of the specification. Those of ordinary skill in the art will be able to implement the present invention based on these descriptions. In addition, the embodiments of the present invention involved in the following description are usually only embodiments of a part of the present invention, rather than all of the embodiments. Therefore, based on the embodiments in the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative work should fall within the scope of protection of the present invention. It should be noted that, in the absence of conflict, the embodiments in this application and the features in the embodiments can be combined with each other. Unless otherwise specified, the methods briefly described in the embodiments of the present invention are methods mastered by those skilled in the art.

[0022] Figure 1 A flowchart of a consensus method for pre-specifying transaction height provided by an embodiment of the present invention.

[0023] like Figure 1 As shown, this embodiment provides a consensus method for pre-specifying transaction heights, which is applicable to a blockchain system, wherein the blockchain system includes a plurality of data storage nodes and consensus nodes, and is characterized in that the method includes:

[0024] The first data storage node receives the first transaction sent by the user, obtains the transaction hash of the first transaction and converts it into binary, and obtains the highly identifiable field data therein according to the preset value for marking;

[0025] According to the preset determined pre-specified height interval, all block heights within the pre-specified height interval are converted into binary and preset height matching field data is extracted to mark the height, and the length of the height matching field data is consistent with the length of the height identification field data; wherein the range of the pre-specified height interval is set according to the length of the height matching field data;

[0026] Matching the height identification field data of the first transaction with all block heights within a pre-specified height range to determine a pre-specified height of the first transaction, recorded as a first height;

[0027] When the difference between the first height and the current height is a preset first value, the blockchain system randomly selects a group of data storage nodes as a comparison group for the first data storage node, obtains all transactions with a pre-specified height of the first height in the first data storage node and its comparison group, removes duplicates to obtain a first transaction list, traverses the transactions in the first transaction list and compares them with the transactions in the comparison group one by one, and when more than 2 / 3 of the data storage nodes in the comparison group have the transaction, it is added to the second transaction list, and the traversal is completed to obtain the second transaction list; specifically, considering the delay of network transmission, the time when different nodes receive the same transaction will be different, so the comparison group needs to verify the inclusion of 2 / 3 nodes to confirm the second transaction list;

[0028] When the first data storage node receives the request for obtaining transaction data with a pre-specified height being the first height sent by the first consensus node, the first data storage node sends the second transaction list and its Merkle root to the first consensus node;

[0029] The first consensus node obtains the transaction list and corresponding Merkle root sent by multiple data storage nodes, selects the data consistent with at least 2 / 3 of the data storage nodes as the consensus data, and reaches a consensus. In the above scheme, the data storage and block consensus of the same block are undertaken by the data storage node and the consensus node respectively. The data storage nodes can compare the transaction data of the same block scheduled in the future in parallel. In this way, the transaction data of each future block height stored by the data node is kept consistent before the consensus node generates a new block. It is not necessary to store transaction data in the hard disk of the consensus node, which can reduce the requirements for the storage capacity of the consensus node. Different nodes will receive consistent transactions in advance, and there is a certain amount of time to ensure that the transactions received by each node are consistent, and the Merkle tree is calculated after sorting to obtain the same result. Transaction data transmission and storage can be achieved in parallel to a certain extent, and network transmission resources and node storage resources can be used in parallel. The consensus node of the new block does not need to send the transaction of the new block to other nodes. It only compares whether the Merkle tree is consistent and deletes invalid transactions to reach a consensus.

[0030] Furthermore, after receiving the first transaction sent by the user, the first data storage node also includes verifying the transaction signature of the first transaction, and directly refusing to receive it if it is invalid.

[0031] Furthermore, before reaching consensus, the consensus nodes verify the validity of all transactions in the consensus data, eliminate invalid transactions, and then reach consensus.

[0032] Specifically, assuming that the current block height is 96, and the height identification field of the transaction is set to the last two digits after the binary conversion of the transaction hash, then the corresponding pre-specified height interval range is four block heights, because the height identification field of the transaction has four cases (00, 01, 10, 11), of course, it can also be a prefix, taking the first two digits, and the basis for judgment is not limited, as long as it is set in advance; assuming that the pre-specified height interval is preset to four block heights after the current block height, then the current pre-specified height interval is height 101-104, among which 101 (01), 102 (10 ), 103(11), 104(00), the reason for setting the upper limit of the pre-specified height range is that, on the one hand, a wide range will cause duplication of the height matching field of the block height, which needs to be sorted; on the other hand, if the user's pre-set block height is too large, more gas fees will be required, which can effectively avoid occupying too many resources, but if no reservation is made, it may be too late to implement subsequent operations; assuming that the height identification field of the first transaction is 01, then the first transaction is pre-specified to be a block with a height of 101. Assuming that the first value is preset to 3, then when the current block of the blockchain is 98, the first data storage node It is necessary to confirm the transaction list with a pre-specified height of 101. At the same time, the pre-specified height range at this time has become height 103-106, indicating that the received transaction can no longer be pre-specified and packaged into the block with a height of 101. The process of confirming the transaction list is that the system randomly selects a group of data storage nodes as a comparison group, such as the second data storage node, the fifth data storage node, and the eighth data storage node, and then lists all transactions with a pre-specified height of 101 in the four data storage nodes and removes duplicates, and determines one by one whether more than 2 / 3 of the data storage nodes in the comparison group exist. This transaction is added to the second transaction list. After traversal, the obtained second transaction list updates the database of the first data storage node and supplements the missed transactions. When the height of the next packaged block is 101, the first data node sends the second transaction list and its Merkle root to the consensus node. The consensus node receives the transaction list and the corresponding Merkle root hash of the pre-specified height of 101 from multiple data nodes including the first data node, and uses the consistent data of more than 2 / 3 nodes as the consensus data to perform on-chain consensus. When comparing, the Merkle root hash can be used to quickly identify whether the content of the transaction list is consistent.

[0033] The solution provided in this embodiment adopts the form of consensus nodes and data storage nodes, so that it is not necessary to store transaction data in the hard disk of the consensus node, which can reduce the requirements for the storage capacity of the consensus node. On the other hand, when users send transactions in batches, they can reserve different block heights for each transaction, which can balance the pressure of transmission, storage, and consensus. It ensures the consistency of the pre-specified results of transactions at different nodes, and at the same time enables orderly consensus, which can achieve a certain degree of parallelism and effectively improve efficiency.

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

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

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

[0037] In particular, according to the embodiments disclosed in the present application, the method described in the above embodiment 1 can be implemented as a computer software program. For example, the embodiments disclosed in the present application include 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 the method described in any of the above embodiments. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 109, and / or installed from the removable medium 111.

[0038] As another aspect, the present application further 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.

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

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

[0041] 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 consensus method for pre-specifying transaction heights, the method being applicable to a blockchain system comprising a plurality of data storage nodes and consensus nodes, characterized in that: The method comprises: The first data storage node receives the first transaction sent by the user, obtains the transaction hash of the first transaction and converts it into binary, and obtains the highly identifiable field data therein according to the preset value for marking; According to the preset determined pre-specified height interval, all block heights within the pre-specified height interval are converted into binary and preset height matching field data is extracted to mark the height, and the length of the height matching field data is consistent with the length of the height identification field data; wherein the range of the pre-specified height interval is set according to the length of the height matching field data; Matching the height identification field data of the first transaction with all block heights within a pre-specified height range to determine a pre-specified height of the first transaction, recorded as a first height; When the difference between the first height and the current height is a preset first value, the blockchain system randomly selects a group of data storage nodes as a comparison group for the first data storage node, obtains all transactions with a pre-specified height of the first height in the first data storage node and its comparison group, removes duplicates to obtain a first transaction list, traverses the transactions in the first transaction list and compares them with the transactions in the comparison group one by one, and when more than 2 / 3 of the data storage nodes in the comparison group have the transaction, it is added to the second transaction list, and the traversal is completed to obtain the second transaction list; When the first data storage node receives the request for obtaining transaction data with a pre-specified height being the first height sent by the first consensus node, the first data storage node sends the second transaction list and its Merkle root to the first consensus node; The first consensus node obtains the transaction lists and corresponding Merkle roots sent by multiple data storage nodes, selects data consistent with at least 2 / 3 of the data storage nodes as consensus data, and performs consensus.

2. A consensus method for pre-specified transaction height according to claim 1, characterized in that: After the first data storage node receives the first transaction sent by the user, it also includes verifying the transaction signature of the first transaction, and directly refusing to receive it if it is invalid.

3. A consensus method for pre-specified transaction height according to claim 1, characterized in that: Before reaching consensus, the consensus nodes verify the validity of all transactions in the consensus data, eliminate invalid transactions, and then reach consensus.

4. A computer device, characterized in that: 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 as claimed in claim 1 , 2 or 3 .

5. A storage medium storing a computer program, characterized in that: When the program is executed by a processor, the method according to claim 1, 2 or 3 is implemented.

Citation Information

Patent Citations

  • Transaction screening and block generation method and device, and storage medium

    CN114138904A

  • Transaction storage and block execution method and device, and storage medium

    CN114138906A