A method, device and system for deleting duplicate data between transactions in blockchain

By replacing redundant parts of transaction data with short byte aliases in the blockchain, the problem of blockchain scalability is solved and more efficient storage optimization and transaction processing capabilities are achieved.

CN113779006BActive Publication Date: 2024-09-06HUAZHONG UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110960012.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-20
Publication Date
2024-09-06
Estimated Expiration
2041-08-20

AI Technical Summary

Technical Problem

The scalability problem of blockchain is mainly caused by the redundancy of transaction data. Existing technologies only focus on reducing the storage scale of security data, and the effect is not ideal.

Method used

By filtering out the most frequently accessed addresses, smart contracts and currency amounts in transactions, using short byte aliases to replace long byte fields, designing a deduplication method between transactions, and designing mapping tables for addresses, smart contracts and currency amounts respectively, only Alias ​​replacement occurs when a duplicate threshold occurs, and aliases are reassigned after a certain interval.

Benefits of technology

It effectively reduces the storage space requirements of the blockchain, improves transaction processing capabilities and throughput, reduces the size of each block, avoids high synchronization costs, and does not affect P2P network performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113779006B
    Figure CN113779006B
Patent Text Reader

Abstract

The present invention discloses a method, device and system for deleting duplicate data between transactions in a blockchain, and belongs to the field of computer storage technology. The method includes: screening out the top M addresses with the highest access frequency in a transaction, and replacing the M addresses with M first short byte aliases respectively; screening out the top N smart contracts with the highest access frequency in a transaction, and replacing the repeated fragments in the function input of the same smart contract in multiple calls to N smart contracts with P second short byte aliases respectively; for the amount of currency transferred in the transaction, replacing the basis of the amount of currency transferred with a third short byte alias; and maintaining the corresponding mapping table. In this way, the present invention innovatively utilizes the locality of transaction-related data in the blockchain, and uses short byte aliases to replace long byte fields, which can reduce the size of each transaction in the block, thereby reducing the storage space required for the entire blockchain.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer storage technology, and more specifically, relates to a method, device, and system for deleting duplicate data between transactions in a blockchain. Background Art

[0002] Blockchain has been deployed as the core infrastructure of cryptocurrency in the past decade, showing great ability to maintain data consistency and integrity. However, due to its poor scalability (such as low transaction processing capacity and high persistent storage requirements), blockchain has rarely been used outside the scope of cryptocurrency so far. The transaction processing capacity of blockchain is closely related to the block size and the block generation time interval, but rashly increasing the block size or reducing the block generation time interval will bring synchronization risks.

[0003] Transactions in blockchain can be divided into two types: transfer transactions and smart contract call transactions (here transactions refer not only to currency transactions such as transfers, but also to all business logic that can be implemented through smart contracts, similar to the concept of "transactions" in database technology). Although transactions in different blockchains may use different data structures, they mainly include two types of data: security data (such as signatures) to ensure transaction security and transaction-related data (such as account addresses, smart contract function inputs, etc.), of which the latter is dominant. According to existing research statistics, two-thirds of the data in Ethereum is transaction-related data.

[0004] Reducing the size of transactions so that more transactions can be carried out within a fixed-size block is an effective way to alleviate the scalability problem of blockchain. However, existing solutions only focus on reducing the storage size of security data used to verify transactions, and the optimization results are not ideal. Summary of the invention

[0005] In view of the above defects of the prior art, the present invention provides a method, device and system for deleting duplicate data between transactions in a blockchain, the purpose of which is to improve the transaction processing capability of the blockchain and reduce the persistent storage overhead by deleting duplicate data of similar parts of related data that need to be stored for multiple transactions, thereby alleviating the scalability problem of the blockchain.

[0006] To achieve the above objectives, in a first aspect, the present invention provides a method for deleting duplicate data between transactions in a blockchain, comprising:

[0007] Filter out the top M addresses with the highest access frequency in the transaction; replace the M addresses with M first short byte aliases respectively, and store the mapping relationship between the M addresses and the M first short byte aliases;

[0008] Filter out the top N smart contracts with the highest access frequency in the transaction; use P second short byte aliases to replace repeated fragments in the function input of the same smart contract in the N smart contracts that are called multiple times; store a mapping table separately for each smart contract in the N smart contracts, and record the mapping relationship between the replaced fragment and the corresponding second short byte alias and the length of the unreplaced fragment in each mapping table;

[0009] For the amount of money transferred in the transaction, a third short byte alias is used to replace the basis of the transferred amount of money; a mapping relationship between the third short byte alias and the basis and a corresponding offset are stored; wherein the offset is the difference between the amount of money transferred and the basis.

[0010] Furthermore, the M first short byte aliases have different lengths.

[0011] Furthermore, the aliases with shorter lengths among the M first short byte aliases are assigned to addresses with higher access frequencies in transactions.

[0012] Furthermore, the storing of the mapping relationship between the M addresses and the M first short byte aliases includes: storing two mapping tables with addresses and aliases as keys respectively, so that after the addresses are replaced with aliases, the aliases can be easily restored to addresses.

[0013] Furthermore, alias replacement is performed only when the number of occurrences of the repeated segment exceeds a preset threshold.

[0014] Furthermore, the alias is reallocated every time interval T.

[0015] In a second aspect, the present invention provides a device for deleting duplicate data between transactions in a blockchain, comprising: a first conversion module, used to screen out the top M addresses with the highest access frequency in a transaction; replace the M addresses with M first short byte aliases respectively, and store the mapping relationship between the M addresses and the M first short byte aliases; a second conversion module, used to screen out the top N smart contracts with the highest access frequency in a transaction; replace repeated fragments in the function input of multiple calls to the same smart contract in the N smart contracts with P second short byte aliases respectively; store a mapping table separately for each of the N smart contracts, and record the mapping relationship between the replaced fragment and the corresponding second short byte alias and the length of the unreplaced fragment in each of the mapping tables; a third conversion module, used to replace the basis of the transferred currency amount in the transaction with a third short byte alias; store the mapping relationship between the third short byte alias and the basis and the corresponding offset; wherein the offset is the difference between the transferred currency amount and the basis.

[0016] In a third aspect, the present invention provides a blockchain system, comprising the device for deleting duplicate data between transactions in the blockchain provided in the second aspect.

[0017] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects:

[0018] (1) The present invention is different from the existing related technologies that only focus on reducing the storage scale of security data used to verify transactions in transactions to alleviate the scalability problem of blockchain. It innovatively utilizes the locality of transaction-related data in blockchain, uses short-byte aliases to replace long-byte fields, and designs inter-transaction duplicate data deletion methods for addresses, smart contracts, and currency amounts. At the same time, the additional storage overhead brought by the alias mapping table does not need to be propagated in the P2P network, does not affect the performance of the chain, and occupies very little local storage space and can be ignored. In this way, the present invention can reduce the size of each transaction in the block, thereby reducing the storage space required for the entire blockchain.

[0019] (2) The present invention assigns shorter aliases to addresses with higher access frequencies in transactions, thereby making greater use of shorter aliases and achieving greater storage optimization effects.

[0020] (3) The present invention reallocates aliases at regular time intervals rather than updating in real time, thus avoiding high synchronization costs and being easier to implement.

[0021] (4) When the size of each block is constant, the method for deleting duplicate data between transactions in the blockchain provided by the present invention can make a block of the same size contain more transactions, thereby improving the throughput of the blockchain system. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 One of the flow charts of the method for deleting duplicate data between transactions in a blockchain provided by an embodiment of the present invention;

[0023] Figure 2 Flow chart 2 of the method for deleting duplicate data between transactions in a blockchain provided by an embodiment of the present invention;

[0024] Figure 3 A block diagram of a device for deleting duplicate data between transactions in a blockchain provided by an embodiment of the present invention;

[0025] Figure 4 A block diagram of a blockchain system provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0027] In the present invention, the terms "first", "second", etc. (if any) in the present invention and the accompanying drawings are used to distinguish similar objects but not necessarily to describe a specific order or sequence.

[0028] First of all, it should be noted that the present invention has discovered two types of content locality that are ubiquitous but highly neglected through a comprehensive analysis of the workload of Ethereum, the world's largest and most representative blockchain system: ① economic locality (most transactions occur between a few account addresses); ② parameter locality (most of the parameters of transactions that call the same smart contract have the same parts or are even exactly the same). More importantly, the scale of these fields with strong locality is usually relatively large. For example, in order to avoid conflicts, the length of an account address in Ethereum is 20 bytes, and the parameters of smart contracts can even be thousands of bytes. Based on this, a method for deduplicating data between transactions in blockchain is proposed.

[0029] See also Figure 1 , combined with Figure 2 The present invention provides a method for deleting duplicate data between transactions in a blockchain, comprising:

[0030] Filter out the top M addresses with the highest access frequency in the transaction; use M first short byte aliases to replace the M addresses respectively, and store the mapping relationship between the M addresses and the M first short byte aliases.

[0031] Specifically, first select the top M addresses with the highest access frequency (the number of times they appear in a transaction, whether they are senders or receivers), such as the top 100 addresses with the highest access frequency. Then use aliases of 1 to 4 bytes (because 4 bytes are sufficient to represent all addresses in Ethereum) to replace the addresses (source address and destination address) in the original transaction; in this embodiment, variable-length aliases are used to replace the addresses in the original transaction, and the aliases have four lengths, and the length of each alias is indicated by its first 2 bits; preferably, shorter aliases are assigned to addresses that appear more frequently, so as to make greater use of shorter aliases and obtain greater storage optimization effects.

[0032] Furthermore, when maintaining the mapping table of aliases and addresses, two mapping tables are maintained with addresses and aliases as keys, namely a forward mapping table and a reverse mapping table, so that the aliases can be easily restored to their original form after the addresses are replaced with aliases. In addition, since the aliases and address mappings are one-to-one corresponding, the use of the data structure BiMap can efficiently achieve the above goals.

[0033] like Figure 2 As shown in the figure, in a specific example, the address 0xc89773ac of the transaction to be converted is mapped to the alias 0x01, and the address part in the original transaction is replaced with the single-byte alias 0x01, thereby reducing the storage size of the address field. The target address is also mapped to the two-byte alias 0x2bf5 using the same method, and can be easily restored by simply querying the mapping table during recovery.

[0034] Filter out the top N smart contracts with the highest access frequency in the transaction; use P second short byte aliases to replace repeated fragments in the function input of multiple calls to the same smart contract in the N smart contracts; store a mapping table separately for each smart contract in the N smart contracts, and record the mapping relationship between the replaced fragment and the corresponding second short byte alias and the length of the unreplaced fragment in each mapping table.

[0035] Specifically, first select the top N smart contracts with the highest access frequency (the number of times they appear in a transaction, whether as a sender or a receiver), such as the top 50 smart contracts with the highest access frequency. Then use the second short byte alias to replace the repeated fragments in the function input of the smart contract. Since the number of functions in a smart contract and the number of parameters of each function are limited, the 2-byte length can already meet the number of function input fragments with strong locality in the smart contract. Preferably, the second short byte alias length is 2 bytes.

[0036] Furthermore, the second short byte alias is used to replace the lengthy byte fragments in the function input of the smart contract to reduce the data storage size of the transaction. Since different smart contracts have completely different logics, parameters, and internal addresses, no strong locality is found between the function inputs of different smart contracts. On the contrary, the function inputs of multiple calls of the same smart contract show strong locality. Therefore, maintaining a mapping table for each smart contract separately instead of maintaining an overall mapping table can effectively reduce the storage overhead of smart contract transactions.

[0037] Furthermore, the present invention assigns an alias to a long byte segment (prefix or infix) in the function input of the smart contract only when the number of occurrences exceeds a certain threshold (e.g., 5 times) in the recent multiple calls, that is, only the localized segments are replaced.

[0038] Furthermore, the key of the mapping table is the identifier of each function in the smart contract, that is, a prefix of a certain length in the function input (the first few bytes of the function input are the function identifier, which uniquely identifies the function to be called by the function input). Function inputs with the same prefix often have one or more infixes with strong locality, that is, in multiple calls to the same function, the parameters of the function input often have the same parts. The mapping table not only records the infix corresponding to the prefix (that is, the high-frequency parameters corresponding to each function), but also records the length of the unreplaced fragments between multiple infixes, that is, the mask, to facilitate the recovery of the original function input.

[0039] like Figure 2 As shown, in a specific example, a mapping table between the alias of the smart contract and the function input fragment is established, and the function input 0x1801fbe5c52ca5df that needs to be converted is mapped. The mapping of the function input consists of a prefix and two infixes, where 0x1801fbe5 is the prefix, which uniquely indicates the function currently called in the smart contract and is the identifier of the smart contract function; the two infixes are 0xc5 and 0xa5, which represent the fragments of the two parameters of the function that are called multiple times and widely used. Use the public input field to record the infix and its position in the function input, and use the character '0' to replace the other parts of the function input to facilitate the subsequent recovery of the function input. The mapped alias 0x0000 and the unreplaced fragment together constitute the function input part of the alias transaction, that is, the actual parameter alias.

[0040] For the amount of money transferred in the transaction, a third short byte alias is used to replace the basis of the transferred amount of money; a mapping relationship between the third short byte alias and the basis and a corresponding offset are stored; wherein the offset is the difference between the amount of money transferred and the basis.

[0041] Specifically, the amount of money transferred in a transaction also has strong locality. As the number of transactions increases, the amount of money transferred in a transaction often has several hot values, which are called bases (similar to the concept of currency denomination). The present invention divides the amount of money transferred in a transaction into bases and offsets. The base represents the currency value frequently used in transaction activities, and the offset is the difference between the actual transaction value and the base. The present invention uses a third short byte alias to replace the long byte base, thereby reducing the storage overhead of data.

[0042] Preferably, the third short byte alias adopts a length of 1 byte, because a length of 1 byte is sufficient to represent the number of bases.

[0043] like Figure 2As shown, in a specific example, the transferred currency amount 0x0de021 is divided into two parts: a base and an offset. In this embodiment, the base is 0x0de000, and the offset is 0x21. In the alias transaction, the single-byte alias 0x05 mapped to the base and the offset are recorded at the same time. Ultimately, the actual transferred currency amount can be restored from the two.

[0044] In addition, if the transaction type is a transfer transaction, the main data in the transaction is the account address, because transfer transactions usually do not contain function inputs or function inputs of very few bytes. If the transaction type is a smart contract call transaction, the main data in the transaction is the function input of the smart contract, which can reach hundreds or thousands of bytes. Compared with the function input, the byte size occupied by the account address is very small.

[0045] Furthermore, before verifying a block, the node in the blockchain can restore the alias in the transaction through the local mapping table, and can still use the original verification information to verify the block. It should be noted that most nodes in the blockchain have the same consensus blockchain view, so the mapping table constructed by the same method is consistent.

[0046] Furthermore, the present invention uses optimized BLS signatures to quickly verify the correctness of blocks, and the verification time does not affect the scalability of the blockchain.

[0047] Figure 3 A block diagram of a device for deleting duplicate data between transactions in a blockchain provided by an embodiment of the present invention. Figure 3 The inter-transaction deduplication device 300 in the blockchain includes a first conversion module 310, a second conversion module 320, and a third conversion module 330.

[0048] The first conversion module 310, for example, performs operation S1 to filter out the top M addresses with the highest access frequency in the transaction; replace the M addresses with M first short byte aliases respectively, and store the mapping relationship between the M addresses and the M first short byte aliases;

[0049] The second conversion module 320, for example, performs operation S2 to filter out the top N smart contracts with the highest access frequency in the transaction; use P second short byte aliases to replace repeated segments in the function input of the same smart contract in the N smart contracts that are called multiple times; store a mapping table separately for each smart contract in the N smart contracts, and record the mapping relationship between the replaced segment and the corresponding second short byte alias and the length of the unreplaced segment in each mapping table;

[0050] The third conversion module 330, for example, performs operation S3, which is used to replace the basis of the amount of money transferred in the transaction with a third short byte alias; stores the mapping relationship between the third short byte alias and the basis and the corresponding offset; wherein the offset is the difference between the amount of money transferred and the basis.

[0051] The device 300 for deduplicating data between transactions in the blockchain is used to perform the above Figure 1 The method for deleting duplicate data between transactions in the blockchain in the embodiment shown. For details not covered in this embodiment, please refer to the aforementioned Figure 1 The method for deleting duplicate data between transactions in the blockchain in the illustrated embodiment will not be described in detail here.

[0052] Figure 4 This is a block diagram of a blockchain system provided by an embodiment of the present invention. The main structure of the blockchain system is the same as other blockchains, but the innovation is that two data structures and one module are added. The two data structures are used to store the information of alias transactions and alias blocks respectively, and the newly added conversion module is used to realize the conversion between original transactions and alias transactions.

[0053] The alias block consists of three parts: block header, block body and metadata, of which the block body is mainly composed of alias transactions. In fact, the only difference between an alias block and an original block is that the block body is composed of alias transactions.

[0054] The overall execution process of the blockchain system is:

[0055] ① The miner who obtains the block generation right selects transactions from the transaction pool, packages the selected transactions into blocks, and calculates the BLS signature;

[0056] ② After calculating the BLS signature, the block producer replaces the original transaction in the block with the corresponding alias transaction with a smaller storage size through the conversion module;

[0057] ③ The block producer broadcasts the alias block consisting of the alias transaction and the original block header (including verification information) to the blockchain system for consensus;

[0058] ④ The verification node in the blockchain obtains the alias block and restores the alias transactions in it to the original block through the conversion module;

[0059] ⑤The verification node verifies the validity of the recovered block. If the block passes the verification of the majority of nodes, the alias block is recorded in the blockchain.

[0060] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for deleting duplicate data between transactions in a blockchain, characterized in that: include: Filter out the top M addresses with the highest access frequency in transactions; Replacing the M addresses with M first short byte aliases respectively, and storing a mapping relationship between the M addresses and the M first short byte aliases; The storing of the mapping relationship between the M addresses and the M first short byte aliases includes: storing two mapping tables with addresses and aliases as keys, respectively, so that after replacing the addresses with the aliases, it is convenient to restore the aliases to the addresses; Filter out the top N smart contracts with the highest access frequency in the transaction; use P second short byte aliases to replace repeated fragments in the function input of the same smart contract in the N smart contracts that are called multiple times; store a mapping table separately for each smart contract in the N smart contracts, and record the mapping relationship between the replaced fragment and the corresponding second short byte alias and the length of the unreplaced fragment in each mapping table; For the amount of money transferred in the transaction, a third short byte alias is used to replace the basis of the transferred amount of money; a mapping relationship between the third short byte alias and the basis and a corresponding offset are stored; wherein the offset is the difference between the amount of money transferred and the basis.

2. The method for deleting duplicate data between transactions in a blockchain as claimed in claim 1, characterized in that: The M first short byte aliases have different lengths.

3. The method for deleting duplicate data between transactions in a blockchain as claimed in claim 2, characterized in that: The alias with shorter length among the M first short byte aliases is assigned to an address with higher access frequency in transactions.

4. The method for deleting duplicate data between transactions in a blockchain as claimed in claim 1, characterized in that: Alias ​​replacement is performed only when the number of occurrences of the repeated segment exceeds a preset threshold.

5. The method for deleting duplicate data between transactions in a blockchain according to any one of claims 1 to 4, characterized in that: Aliases are reassigned every time interval T.

6. A device for deleting duplicate data between transactions in a blockchain, characterized in that: include: The first conversion module is used to filter out the top M addresses with the highest access frequency in transactions; Replacing the M addresses with M first short byte aliases respectively, and storing a mapping relationship between the M addresses and the M first short byte aliases; The storing of the mapping relationship between the M addresses and the M first short byte aliases includes: storing two mapping tables with addresses and aliases as keys, respectively, so that after replacing the addresses with the aliases, it is convenient to restore the aliases to the addresses; The second conversion module is used to filter out the top N smart contracts with the highest access frequency in the transaction; use P second short byte aliases to replace repeated fragments in the function input of the same smart contract in the N smart contracts that are called multiple times; store a mapping table separately for each smart contract in the N smart contracts, and record the mapping relationship between the replaced fragment and the corresponding second short byte alias and the length of the unreplaced fragment in each mapping table; The third conversion module is used to replace the basis of the amount of currency transferred in the transaction with a third short byte alias; store the mapping relationship between the third short byte alias and the basis and the corresponding offset; wherein the offset is the difference between the amount of currency transferred and the basis.

7. A blockchain system, characterized in that: It includes a device for deleting duplicate data between transactions in a blockchain as described in claim 6.