A blockchain sharding method based on transaction frequency analysis

By analyzing transaction frequency, high-frequency accounts and their associated accounts are put into the same shard, which solves the low throughput and cross-chain transaction complexity problems of the blockchain system and achieves high throughput and low cross-chain transaction ratio. Effect.

CN115034898BInactive Publication Date: 2024-09-06XI'AN PETROLEUM UNIVERSITY
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210589229.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-26
Publication Date
2024-09-06
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The low business throughput and high transaction delay of the blockchain system make it unable to adapt to Internet-level applications. Although sharding technology can improve throughput, it raises issues of cross-chain transaction complexity and delay, especially how to use Choosing an appropriate data sharding strategy for the transaction frequency of a specific application scenario is key.

Method used

By counting the transaction frequency of trading accounts, sorting them from large to small, prioritize high-frequency accounts and their associated accounts into the same shard, recursively assign all accounts to the corresponding shards, and calculate shard granularity and cross-chain transaction ratio to reduce the cross-chain transaction ratio.

Benefits of technology

It effectively improves the business throughput of the blockchain, reduces the proportion of cross-chain transactions, reduces the complexity of data interaction between shards, and improves the performance of the blockchain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115034898B
    Figure CN115034898B
Patent Text Reader

Abstract

The present invention discloses a blockchain sharding method based on transaction frequency analysis, which includes the following steps: for a digital cryptocurrency system, collect transaction information of the blockchain; then count the blockchain transaction frequency according to the account information of the transaction initiator, and construct a transaction frequency set; then divide the account initiator and receiver with high transaction frequency into the same shard, and recursively put the account information associated with the account into the same shard; then traverse the transaction frequency set, according to the above method until all account information and transaction information are in different shards. Finally, calculate the sharding granularity of the blockchain, the account ratio of the shard, the transaction data volume ratio, the transaction throughput and the cross-chain transaction ratio, and evaluate the blockchain sharding method through various indicators. This method can not only improve the parallel transaction throughput of the blockchain through sharding technology, but also effectively reduce the cross-chain transaction ratio brought by shards, and is suitable for high-throughput blockchain application scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular to a blockchain sharding method based on transaction frequency analysis. Background Art

[0002] The scalability of blockchain is one of the hot topics in the field of blockchain research. Due to the low business throughput and long transmission delay of blockchain systems, which cannot adapt to Internet-level applications, the scalability of blockchain is an important reason that restricts the implementation of blockchain. Sharding technology is one of the mainstream technologies used by blockchain to solve efficiency and scalability problems. Sharding technology uses the idea of ​​divide and conquer to divide blockchain nodes and transaction information into multiple shards in a logical sense without weakening the degree of decentralization of blockchain and sacrificing the immutability and security of all blockchain shards. Multiple independent shards run in parallel and can execute multiple transactions, thereby improving the throughput of blockchain. Generally speaking, the granularity of sharding is proportional to the transaction throughput of blockchain. However, the biggest problem caused by sharding is the cross-chain transaction problem. The cross-chain transaction problem makes the implementation of blockchain transactions more complex and increases transaction delays. How to select a suitable data sharding strategy based on the transaction frequency analysis of specific application scenarios is one of the key issues of blockchain sharding technology.

[0003] In blockchain transactions, transaction data has characteristics for different application scenarios. Transactions between some accounts are more frequent, and they can be assigned to one shard to reduce the cross-chain ratio of the blockchain, thereby shortening transaction delays. Summary of the invention

[0004] In response to the above problems, the present invention aims to propose a blockchain sharding method based on transaction frequency analysis, which is used to improve the blockchain business throughput and reduce the cross-chain ratio.

[0005] The core idea of ​​the present invention is: first, for transactions in specific application scenarios, shard mapping is performed according to transaction account information. For each transaction, the transaction frequency of the transaction initiator account is counted, and the account information is sorted from large to small according to the transaction frequency to form a transaction frequency set; then, the accounts of both parties with high transaction frequency are preferentially selected and put into the same shard, and all accounts associated with the accounts of both parties are recursively put into the same shard, and then the transaction account with the second highest transaction frequency is put into the next shard, and so on, until all transactions and accounts are allocated and mapped to the corresponding shards; finally, the shard granularity, cross-chain transaction ratio and blockchain business throughput are calculated.

[0006] In order to achieve the above object, the technical solution adopted by the present invention is as follows:

[0007] A blockchain sharding method based on transaction frequency analysis, characterized in that it includes the following steps:

[0008] S1: Obtain transaction data within a period of time in the blockchain network to form a data transaction set Tx = {tx1, ..., tx k ,…,tx n};

[0009] S2: For any transaction data in the transaction set tx = {ac i , ac j}, count the account ac of the initiator of this transaction i and the recipient account ac j The transaction frequencies between them form a transaction frequency set Tn = {tn1, ..., tn k ,…,tn n};

[0010] S3: Construct an account-based blockchain sharding algorithm, and divide all accounts in the transaction frequency set Tn into multiple shards through the account-based blockchain sharding algorithm to obtain multiple shards;

[0011] S4: Calculate the account ratio and transaction data volume ratio of each shard;

[0012] S5: Calculate the cross-chain transaction ratio of this blockchain based on the number of blockchain shards obtained.

[0013] Furthermore, the step of forming the transaction frequency set in S2 is:

[0014] S21: All transactions in the transaction frequency set are k ={ac i , ac j ,Num(ac i , ac j )} transaction frequency Num(ac i , ac j ) is initialized to 0;

[0015] S22: For any record tx in the data transaction set Tx i , tx i The initiator account is ac i , the recipient account is ac j , then record:

[0016] tn k .sender=ac i ,tn k .reciever=ac j ,

[0017] Num(aci , ac j )=Num(ac i , ac j )+1,

[0018] Count all transaction records in Tx until all transactions in Tx are counted;

[0019] S23: Set the transaction frequency Num(ac i , ac j ) are sorted in descending order to obtain the final transaction frequency set Tn = {tn1, ..., tn k ,…,tn n}.

[0020] Furthermore, the steps of the account-based blockchain sharding algorithm in S3 include:

[0021] S31: Initialize the current number of shards, the sender account set of the transaction, and the blockchain shard set to m=0 respectively.

[0022] S32: Select transactions tn in the transaction frequency set Tn in sequence k ={ac i , ac j ,Num(ac i , ac j )},if Then ac i Add Shard m and Ac sender In, juxtaposition

[0023] S33: For the set Ac sender Any account ac k , traverse tn in Tn in turn i , if tn i .sender is equal to ac k ,and Then tn i .reciever join Ac reciever And Ac reciever Add Shard m ;

[0024] S34: Judgment Is it true, if it is a blockchain shard m Formed, if otherwise set Ac sender =Ac reciever and transfer to S33;

[0025] S35: If all accounts Ac are in the shard Shard, the sharding is completed; otherwise, m=m+1 is set and the process proceeds to S32.

[0026] Furthermore, the specific operation steps of S4 include:

[0027] S41: Calculate shard m Account ratio:

[0028] S411: Shard statistics m The number of all accounts in the shard is denoted as Num(shard m );

[0029] S412: Calculate shard m Account ratio Ar:

[0030]

[0031] Where Num(Ac) is the number of accounts in the account set Ac;

[0032] S42: Calculate shard m Transaction data volume ratio Tr:

[0033] S421: Shard statistics m The sum of the cumulative transaction frequencies of all accounts in;

[0034] S422: Calculate shard m Volume of transaction data:

[0035]

[0036] Among them, Num(Tx) is the number of transactions in the transaction set Tx.

[0037] Furthermore, the specific operation steps of S5 include:

[0038] S51: Record the cross-chain transaction set as Tx cross , set

[0039] S52: Traverse all transactions Tx, for tx k ∈Tx,tx k ={ac i , ac j}, if ac i ∈shard k , ac j ∈shard n and shard k ≠shardn ,but:

[0040] Tx cross =Tx cross ∪tx k ;

[0041] S53: Calculate the cross-chain transaction ratio Cr:

[0042]

[0043] Among them, Num(Tx cross ) is the sum of the number of cross-chain transactions.

[0044] The beneficial effects of the present invention are:

[0045] The blockchain sharding method based on transaction frequency analysis proposed in the present invention can be used in high-throughput blockchain DAPP application scenarios. It aims at the cross-chain transaction problem caused by sharding technology in blockchain applications. By statistically analyzing the blockchain transaction frequency, the association relationship between transaction accounts is discovered. By dividing the frequently traded associated accounts into the same shard, frequent transactions can complete transaction verification and block creation in the same shard as much as possible, and the proportion of cross-chain transactions is minimized, thereby reducing the complexity of inter-shard data interaction caused by sharding technology. Ultimately, it can effectively reduce the proportion of cross-chain transactions on the basis of improving the throughput of blockchain parallel services. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 This is a flow chart of the blockchain sharding method based on transaction frequency analysis of the present invention;

[0047] Figure 2 This is a flow chart of the account-based blockchain sharding method of the present invention;

[0048] Figure 3 Comparison of cross-chain transaction ratios at different sharding granularities. DETAILED DESCRIPTION

[0049] In order to enable those skilled in the art to better understand the technical solution of the present invention, the technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0050] Reference Figure 1 As shown, a blockchain sharding method based on transaction frequency analysis includes the following steps:

[0051] Step 1: In the blockchain network, for the application field of digital cryptocurrency, collect transaction data for at least half a year to form a transaction set, denoted as Tx = {tx1, ..., tx k ,…,tx n}, where txk ∈Tx,tx k ={ac i , ac j}, account ac i As the transaction initiator account, recorded as tx k .sender=ac i ;Account ac j The transaction recipient account, denoted as tx k .reciever=ac j ; The transaction account set is recorded as Ac = {ac1, ..., ac i ,…,ac n}; The blockchain shard set is recorded as Shard = {shard1, ..., shard m , …, shard n};

[0052] Step 2: For any transaction in the transaction set Tx, tx = {ac i , ac j}, with the transaction initiator account ac i and the transaction recipient account ac j The statistical object is the transaction frequency set Tn = {tn1, ..., tn k ,…,tn n}, tn k ∈Tn,tn k ={ac i , ac j ,Num(ac i , ac j )}, where Num(ac i , ac j ) represents ac i As the transaction initiator account and the transaction recipient account ac j The number of transactions generated;

[0053] The specific steps of statistical transaction frequency set include:

[0054] Step 2.1: For tn k ∈Tn,tn k ={ac i , ac j ,Num(ac i , ac j )}, set Num(ac i , ac j )=0.

[0055] Step 2.2: Target txi ∈Tx, if tx i The transaction initiator account is ac i , the transaction recipient account is ac j , set tn k .sender=ac i ,tn k .reciever=ac j ,Num(ac i , ac j )=Num(ac i , ac j )+1 until all transactions in Tx are counted;

[0056] Step 2.3: The elements tn in the transaction frequency set Tn are sorted according to the transaction frequency Num(ac i , ac j ) are arranged in descending order to obtain a new transaction frequency set Tn = {tn1, ..., tn k ,…,tn n};

[0057] Step 3: For the transaction frequency set Tn, select the transaction account with high transaction frequency, and put all the accounts associated with the account with high transaction frequency into the same shard through recursive calling to form a shard;

[0058] As attached Figure 2 As shown, the specific steps of the account-based blockchain sharding include:

[0059] Step 3.1: Initialize the current number of shards m = 0, set Among them, Ac sender and Ac reciever Both are temporary variables, used to store the initiator account and the receiver account in the recursive call;

[0060] Step 3.2: Select transactions tn in the transaction frequency set Tn in turn k , where tn k ={ac i , ac j ,Num(ac i , ac j )},if Shard m =shard m ∪ac i ,Ac sender =Ac sender ∪ac i , set

[0061] Step 3.3: For the set Ac sender Any account ac k , traverse tn in Tn in turn i , if tn i .sender is equal to ac k ,and Then Ac reciever =Ac reciever ∪tn i .reciever, shard m =shard m ∪Ac reciever ;

[0062] Step 3.4: If Set Ac sender =Ac reciever , go to step 3.3, otherwise, blockchain shard m form.

[0063] Step 3.5: If all accounts Ac are in the shard, continue to step 4; otherwise, m=m+1, go to step 3.2;

[0064] Step 4: For the blockchain shard set Shard = {shard1, ..., shard m , …, shard n Each shard in m , calculate the shard m The account ratio and transaction data volume ratio of the shards are calculated in the following steps:

[0065] Step 4.1: Calculate shards m The account ratio is first counted by shard m The number of all accounts in the shard is denoted as Num(shard m ), and then calculate the shard m The account ratio is recorded as Where Num(Ac) is the number of accounts in the account set Ac;

[0066] Step 4.2: Calculate shards m The transaction data volume ratio for shard m The ratio of the cumulative transaction frequency of all accounts in the blockchain as the initiator account to the total transaction volume of the blockchain is called a shard. m The transaction data volume ratio is denoted as Where Num(Tx) is the number of transactions in the transaction set Tx;

[0067] By calculating the account ratio and transaction data volume ratio of each shard, we can effectively observe the aggregation of accounts and transactions in the shards;

[0068] Step 5: The number of blockchain shards m is the shard granularity, and the cross-chain transaction ratio of the blockchain is calculated. For any transaction tx={ac i , ac j}, if the transaction initiator ac i and the transaction receiver ac j If they do not belong to the same shard, then tx is called a cross-chain transaction. The cross-chain transaction ratio is the ratio of the number of cross-chain transactions to the total number of blockchain transactions. The cross-chain transaction ratio is one of the important indicators for evaluating blockchain sharding methods. A low cross-chain transaction ratio can effectively reduce the complexity of blockchain transactions and queries.

[0069] Step 5.1: The cross-chain transaction set is recorded as Tx cross , set

[0070] Step 5.2: Traverse all transactions Tx, for tx k ∈Tx,tx k ={ac i , ac j}, if ac i ∈shard k , ac j ∈shard n , and shard k ≠shard n , then Tx cross =Tx cross ∪tx k .

[0071] Step 5.3: Calculate the cross-chain transaction ratio Where Num(Tx cross ) is the sum of the number of cross-chain transactions.

[0072] Example

[0073] In order to verify the effectiveness of the method proposed in the present invention, the present invention calculates the cross-chain transaction ratio by using the method provided by the present invention for 420,000 transaction data and 21,304 transaction accounts in PlugChain. Figure 3 This is a comparison chart of cross-chain transaction ratios under different sharding granularities. Figure 3 It can be seen that the cross-chain transaction ratio of this method is lower than that of the account random sharding method. Experiments show that this method can effectively reduce the cross-chain transaction ratio and reduce the cross-chain communication cost, thereby improving the performance of the blockchain.

[0074] The above shows and describes the basic principles, main features and advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited to the above embodiments, and the above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the attached claims and their equivalents.

Claims

1. A blockchain sharding method based on transaction frequency analysis, characterized in that: The following steps are involved: S1: Obtain transaction data within a period of time in the blockchain network to form a data transaction set Tx = {tx1, ..., tx k ,…,tx n }; S2: For any transaction data in the transaction set tx = {ac i , ac j }, count the account ac of the initiator of this transaction i and the recipient account ac j The transaction frequencies between them form a transaction frequency set Tn = {tn1, ..., tn k ,…,tn n }; S3: Construct an account-based blockchain sharding algorithm, and divide all accounts in the transaction frequency set Tn into multiple shards through the account-based blockchain sharding algorithm to obtain multiple shards; S4: Calculate the account ratio and transaction data volume ratio of each shard; S5: Calculate the cross-chain transaction ratio of this blockchain based on the number of blockchain shards obtained; in: The steps of forming a transaction frequency set in S2 are: S21: All transactions in the transaction frequency set are k ={ac i , ac j ,Num(ac i , ac j )}'s transaction frequency Num(ac i , ac j ) is initialized to 0; S22: For any record tx in the data transaction set Tx i , tx i The initiator account is ac i , the recipient account is ac j , then record: tn k .sender=ac i ,tn k .reciever=ac j , Num(ac i ,with j )=Num(ac i ,with j )+1, Count all transaction records in Tx until all transactions in Tx are counted; S23: Set the transaction frequency Num(ac i , ac j ) are sorted in descending order to obtain the final transaction frequency set Tn = {tn1, ..., tn k ,…,tn n }; The steps of the account-based blockchain sharding algorithm described in S3 include: S31: Initialize the current number of shards, the sender account set of the transaction, and the blockchain shard set to m=0 respectively. S32: Select transactions tn in the transaction frequency set Tn in sequence k ={ac i , ac j ,Num(ac i , ac j )},if Then ac i Add Shard m and Ac sender In, juxtaposition S33: For the set Ac sender Any account ac k , traverse tn in Tn in turn i , if tn i .sender is equal to ac k ,and Then tn i .reciever join Ac reciever And Ac reciever Add Shard m ; S34: Judgment Is it true, if it is a blockchain shard m Formed, if otherwise set Ac sender =Ac reciever and transfer to S33; S35: If all accounts Ac are in the shard, the sharding is completed; otherwise, m=m+1 and the process goes to S32; The specific operation steps of S4 include: S41: Calculate shard m Account ratio: S411: Shard statistics m The number of all accounts in the shard is denoted as Num(shard m ); S412: Calculate Shard m Account ratio Ar: Where Num(Ac) is the number of accounts in the account set Ac; S42: Calculate shard m Transaction data volume ratio Tr: S421: Shard statistics m The sum of the cumulative transaction frequencies of all accounts in; S422: Calculate shard m Volume of transaction data: Among them, Num(Tx) is the number of transactions in the transaction set Tx; The specific operation steps of S5 include: S51: Record the cross-chain transaction set as Tx cross , set S52: Traverse all transactions Tx, for tx k ∈Tx,tx k ={ac i , ac j }, if ac i ∈shard k , ac j ∈shard n Shard k ≠shard n ,but: Tx cross =Tx cross ∪tx k ; S53: Calculate the cross-chain transaction ratio Cr: Among them, Num(Tx cross ) is the sum of the number of cross-chain transactions.

Citation Information

Patent Citations

  • Method and system for quitting cross-slice transactions in block chain system containing slices

    CN112261160A

  • Trusted block chain fragment performance optimization method

    CN113807847A

  • Method and system for securing peer nodes in a blockchain network

    US20210385065A1