A blockchain transaction processing method and system
By introducing main chains and shards into the blockchain system, and realizing regular convergence and dynamic load adjustment of main chains and shards, the problem of low blockchain performance is solved, the transaction processing speed and system stability are improved, and the system stability is supported. Diverse commercial applications.
Patent Information
- Application Number
- CN202010202525.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-20
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2040-03-20
AI Technical Summary
The performance of blockchain systems is slow to process transactions, blocking the network without completing transactions, making it difficult to support applications such as real-time payments, and cannot compete with centralized payment systems.
By introducing the main chain and shards into the blockchain system, and regularly obtaining the latest block hash value generated by shards in the main chain, the regular convergence between the main chain and shards is achieved, consistency is ensured, and dynamics are based on transaction volume Adjust the load of shards to improve resource utilization and system stability.
It significantly improves the performance of the blockchain platform, supports commercial application needs, ensures data consistency, realizes cross-shash transactions and contracts, enhances the scalability of the blockchain, and adapts to a variety of business scenarios.
Smart Images

Figure HDA0002419877600000011 
Figure HDA0002419877600000021
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of blockchain technology, and in particular to a blockchain transaction processing method and system. Background Art
[0002] Blockchain is a decentralized and trustless collectively maintained reliable database. One of the biggest problems it faces is scalability. All mainstream platform systems are working hard to increase the number of transactions per second. In fact, today's Bitcoin network can process an average of 7-10 transactions per second and the Ethereum network can process 20-30 transactions per second, which is much lower than centralized payment systems such as Visa, which can process an average of about 8,000 transactions per second. The slow transaction processing speed has caused a major problem for the blockchain system: a large number of unfinished transactions have blocked the network, making it difficult for applications such as real-time payments to work on the blockchain. The time it takes to confirm payment is extended, which will cause a lot of inconvenience to users. This is one of the main reasons why credit card payment methods such as Visa are still more attractive. Summary of the invention
[0003] In view of this, the purpose of the embodiments of the present invention is to provide a blockchain transaction processing method and system, which effectively solves the problem of poor performance of the blockchain.
[0004] In order to solve the above technical problems, the technical solutions adopted in the embodiments of the present invention are as follows:
[0005] An embodiment of the present invention provides a blockchain transaction processing method, which is applied to a blockchain system, wherein the blockchain system includes a main chain and at least one shard parallel to the main chain; the method includes:
[0006] When the main chain periodically obtains the hash value of the latest block generated by the shard, it records the hash value in the latest block generated by the main chain;
[0007] The main chain checks the total transaction volume of the shard to determine whether the total transaction volume is less than or equal to the preset amount. If so, the main chain obtains each pending transaction of the shard and processes each pending transaction; otherwise, the shard obtains the unprocessed cross-shard transaction voucher of the shard based on each cross-shard transaction voucher recorded on the main chain, generates pending transactions based on the cross-shard transaction voucher, and completes the pending transactions.
[0008] Compared with the prior art, the implementation method of the present invention is that the main chain in the blockchain system will regularly record the hash value of the latest block generated by the shard in the latest block generated by the main chain to achieve regular "convergence" between the main chain and the shard, thereby achieving consistency between the main chain and the shard and ensuring the reliability of the blockchain system.
[0009] A further technical solution is that the main chain periodically obtains the hash value of the latest block generated by the shard, specifically including: when the height of the newly generated block reaches a first preset height, the shard stops generating new blocks; or, when the number of cross-shard transactions processed by the shard reaches a preset threshold, the shard stops generating new blocks; when the main chain detects that the shard stops generating new blocks, it obtains the hash value of the latest block generated by the shard. In this way, a specific implementation form of the main chain periodically obtaining the hash value of the latest block generated by the shard is realized, which increases the flexibility of the implementation method of the present invention. In addition, when the main chain detects that the shard stops generating new blocks, it obtains the hash value of the latest block generated by the shard for recording, which can avoid deviations in the latest generated blocks located by the main chain, and further ensure the consistency of the main chain and the shard.
[0010] A further technical solution is that the blockchain transaction processing method further includes: if the height of the newly generated block of the main chain reaches a second preset height, and the main chain has not obtained the hash value of the latest block generated by the shard, the main chain stops generating new blocks. In this way, after the main chain and the shard fail to "merge" normally, the main chain will stop generating new blocks to wait for the shard to be merged, effectively ensuring the stability of the entire blockchain system.
[0011] A further technical solution is that after recording the hash value in the latest block generated by the main chain, the main chain detects the total transaction volume of the shard; if the total transaction volume is less than or equal to the preset number, the main chain obtains each pending transaction of the shard and processes each pending transaction. In this way, dynamic load balancing of shards on the blockchain system is achieved, and the effective utilization rate of resources of the blockchain system is improved.
[0012] If the total transaction volume is greater than the preset amount, the shard obtains the unprocessed cross-shard transaction credentials based on the cross-shard transaction credentials recorded on the main chain; the shard generates pending transactions based on the cross-shard transaction credentials and completes the pending transactions; when the shard completes the pending transactions, the shard generates the cross-shard transaction credentials, broadcasts the cross-shard transaction credentials, and records the cross-shard transaction credentials on the main chain. In this way, the consistency between each shard and the main chain in the subsequent entire blockchain system is achieved, effectively ensuring the stability of the entire blockchain system.
[0013] An embodiment of the present invention provides a blockchain transaction processing system, comprising a main chain and at least one shard parallel to the main chain;
[0014] When the main chain periodically obtains the hash value of the latest block generated by the shard, the hash value is recorded in the latest block generated by the main chain;
[0015] The main chain checks the total transaction volume of the shard to determine whether the total transaction volume is less than or equal to the preset amount. If so, the main chain obtains each pending transaction of the shard and processes each pending transaction; otherwise, the shard obtains the unprocessed cross-shard transaction voucher of the shard based on each cross-shard transaction voucher recorded on the main chain, generates pending transactions based on the cross-shard transaction voucher, and completes the pending transactions.
[0016] A further technical solution is that the main chain and at least one shard parallel to the main chain are in the following specific forms: obtaining the initiator account of the pending transaction; obtaining the shard information corresponding to the initiator account, and using the original chain of the blockchain system as the main chain; and, introducing a shard parallel to the main chain based on the shard information; handing over part or all of the pending transactions of the initiator account to the shard corresponding to the initiator account for processing; wherein, if the pending transaction is a smart contract transaction, the initiator account is the smart contract creator account of the pending transaction. In this way, smart contract transactions are divided into shards according to the smart contract creator account, which can avoid the situation of cross-shard processing of transactions as much as possible, not only ensuring high efficiency of transaction processing, but also ensuring high utilization of resources in the blockchain system.
[0017] A further technical solution is that the main chain and at least one shard parallel to the main chain are specifically in the following form: obtaining the calling relationship of the smart contract in the pending transaction; obtaining the shard information corresponding to the calling relationship, and using the original chain of the blockchain system as the main chain; and, introducing a shard parallel to the main chain according to the shard information, and handing over the pending transaction to the shard for processing. In this way, transactions involving smart contract calls are processed in one shard as much as possible, which not only ensures high transaction processing efficiency, but also ensures high utilization of resources in the blockchain system.
[0018] A further technical solution is that the main chain and at least one shard parallel to the main chain are in the following specific forms: obtaining the group of decentralized applications DAPP (Decentralized Application, referred to as "DAPP") in the pending transaction; obtaining the shard information corresponding to the group, and using the original chain of the blockchain system as the main chain; and, introducing a shard parallel to the main chain according to the shard information, and handing over the pending transaction to the shard for processing. In this way, the DAPP is divided into groups, and a DAPP and its related transactions are processed in one shard as much as possible, which not only ensures a high efficiency in transaction processing, but also ensures a high utilization rate of resources in the blockchain system.
[0019] A further technical solution is that the main chain and at least one shard parallel to the main chain are in the following specific forms: obtaining the initiator account of the pending transaction; obtaining the shard information corresponding to the group to which the initiator account belongs, and using the original chain of the blockchain system as the main chain; and introducing a shard parallel to the main chain based on the shard information; handing over part or all of the pending transactions of the initiator account to the shard corresponding to the initiator account for processing; wherein the group to which the initiator account belongs is generated based on the coupling degree between the initiator account and other accounts. In this way, it is possible for the blockchain system to analyze historically processed transactions to realize the intelligent division of subsequent shards, thereby minimizing the situation of transactions crossing shards and ensuring high utilization of resources within the blockchain system.
[0020] The technical solution provided by the above embodiment of the present invention has the following beneficial effects:
[0021] 1. Expanding the number of shards based on the main chain can greatly improve the performance of the blockchain platform and significantly enhance support for commercial application needs.
[0022] 2. The synchronization mechanism between shards and the main chain effectively guarantees data consistency and the reliability of on-chain business processing;
[0023] 3. Elastically support shard expansion and contraction based on transaction volume, effectively balancing performance expansion and resource optimization.
[0024] 4. Support cross-shard transactions and cross-shard contracts, enhance the scalability of the blockchain, and realize DAPP for a variety of business scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings described herein are used to provide a further understanding of the embodiments of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0026] Figure 1 is a flowchart of a blockchain transaction processing method in Embodiment 1 of the present invention;
[0027] Figure 2 It is a flowchart of the blockchain transaction processing method in Embodiment 2 of the present invention. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical scheme and advantages of the embodiments of the present invention clearer, the embodiments of the present invention will be described in detail below with reference to the accompanying drawings. However, it will be appreciated by those skilled in the art that in the embodiments of the present invention, many technical details are provided to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present application can be implemented.
[0029] Embodiment 1:
[0030] Embodiment 1 of the present invention relates to a blockchain transaction processing method, the specific process is as follows: Figure 1 The transaction processing method in this embodiment is applied to a blockchain system including a main chain and at least one shard. The consensus algorithms of the main chain and the shard are the same, except that the seed of each shard is different from the main chain seed.
[0031] Specifically, the blockchain system including the main chain and at least one shard may be formed in the following manner:
[0032] (i) The blockchain system obtains the shard information corresponding to the initiator account according to the initiator account of the pending transaction, and uses the original chain of the blockchain system as the main chain; and introduces a shard parallel to the main chain according to the shard information. In addition, the blockchain system transfers part or all of the pending transactions of the initiator account to the shard corresponding to the initiator account for processing. Among them, if the pending transaction is a smart contract transaction, the initiator account is the smart contract creator account of the pending transaction.
[0033] Specifically, the consensus algorithm of the blockchain system can pre-store the correspondence between the initiator account and the shard, so that the blockchain system can introduce the corresponding shard according to the initiator account of the transaction, assign the transaction to the corresponding shard for processing, and realize the parallel processing capability of the blockchain system.
[0034] More specifically, when the main chain hands over some or all pending transactions of the initiator's account to the corresponding shard for processing, the main chain will detect the transaction type of the pending transaction. If the transaction type of the pending transaction is a transfer transaction or a smart contract transaction, the main chain will hand over the pending transaction to the corresponding shard for processing. If the transaction type of the pending transaction is a governance transaction (such as bookkeeping application, representative voting, etc.), the transaction will also be processed by the main chain to ensure the security of the entire blockchain system.
[0035] (2) The blockchain system obtains the calling relationship of the smart contract in the pending transaction, obtains the sharding information corresponding to the calling relationship, and uses the original chain of the blockchain system as the main chain; and, based on the sharding information, introduces a shard parallel to the main chain, and hands the pending transaction to the sharding for processing.
[0036] Specifically, the consensus algorithm of the blockchain system can pre-store the correspondence between the calling relationship of the smart contract and the shards, so that the blockchain system can introduce the corresponding shards according to the calling relationship of the smart contract, and allocate transactions to the corresponding shards for processing, thereby realizing the parallel processing capability of the blockchain system.
[0037] More specifically, when there is a calling relationship of a smart contract in a pending transaction, it is very likely that the transaction will be processed across shards. Therefore, in this implementation, based on the calling relationship of the smart contract, each smart contract with a calling relationship corresponds to the same shard, so that the call of the smart contract is performed in one shard as much as possible to avoid the situation where the transaction is processed across shards. This not only ensures high transaction processing efficiency, but also ensures high utilization of resources within the blockchain system.
[0038] (3) The blockchain system obtains the group of DAPPs in the pending transaction; obtains the shard information corresponding to the group, and uses the original chain of the blockchain system as the main chain; and, based on the shard information, introduces a shard parallel to the main chain, and hands the pending transaction to the shard for processing.
[0039] Specifically, the DAPP group can be specified by the technical staff when initiating the pending transaction. That is to say, the pending transaction directly carries the relevant information of the DAPP group. In this way, the consensus algorithm of the blockchain system can pre-store the correspondence between the DAPP group and the shard, so that the blockchain system can introduce the corresponding shard according to the DAPP group in the pending transaction, and assign the transaction to the corresponding shard for processing, so as to realize the parallel processing capability of the blockchain system.
[0040] More specifically, the consensus algorithm of the blockchain system can also pre-store the correspondence between DAPP groups and shards, as well as the correspondence between DAPP and groups. In this way, technicians can directly initiate transactions to be processed without specifying DAPP groups. The blockchain system can automatically identify DAPP groups, introduce corresponding shards based on the automatically identified DAPP groups, and allocate transactions to corresponding shards for processing, thus realizing the parallel processing capability of the blockchain system.
[0041] It should be noted that when the pending transaction is related to DAPP, it is very likely that the transaction will be processed across shards. Therefore, in this implementation, DAPP is divided into groups, and each related DAPP (there is information interaction between each DAPP) is placed in one shard, so that the pending transactions involving DAPP can be processed in one shard as much as possible to avoid the situation of cross-shard processing of transactions, which not only ensures high transaction processing efficiency, but also ensures high utilization of resources in the blockchain system.
[0042] (IV) The blockchain system obtains the initiator account of the pending transaction, obtains the shard information corresponding to the group to which the initiator account belongs, and uses the original chain of the blockchain system as the main chain; and introduces a shard parallel to the main chain based on the shard information. In addition, the blockchain system transfers part or all of the pending transactions of the initiator account to the shard corresponding to the initiator account for processing. The group to which the initiator account belongs is generated based on the coupling degree between the initiator account and other accounts.
[0043] Specifically, the coupling degree between the initiator account and other accounts refers to the degree of transaction dependence between the initiator account and other accounts, which can be obtained by the blockchain system based on the cross-shard transaction statistics of historical processing. In this way, the blockchain system divides several accounts with high coupling degrees into one group, and realizes that several accounts with high coupling degrees correspond to the same shard, which can reduce the possibility of cross-shard processing of transactions when subsequent shards are processed by shards, and realizes the dynamic generation and adjustment of sharding rules on the blockchain system, which can gradually improve the intelligence of sharding division of the blockchain system, and provide a basis for ensuring the high utilization rate of resources in the blockchain system. For example, taking the four accounts A, B, C, and D as an example, if the coupling degree between A and B is high, greater than the preset coupling degree, and the coupling degree between B and C is high, greater than the preset coupling degree, then A, B, and C can be divided into the same group. However, the above examples are only for illustrative purposes, and any implementation form of dividing groups according to coupling degrees is within the protection scope of this embodiment.
[0044] It is worth mentioning that in the formation methods of the blockchain system exemplified in (i), (ii), (iii) and (iv) above, sharding conditions can also be set. For example, sharding is performed only when the system pressure of the blockchain system is relatively high, and the way for the blockchain system to detect whether the system pressure is relatively high can be: the blockchain system detects whether a specified number of full blocks are continuously generated. Among them, the specified number can be pre-existing in the consensus algorithm of the blockchain system. In other words, if the blockchain system continuously generates a specified number of full blocks, it means that the blockchain system has a large number of transactions and the blockchain system is at full load. At this time, it can be determined that the system pressure of the blockchain system is relatively high. However, the above-mentioned method of judging the system pressure by checking the number of full blocks generated continuously is only an exemplary description, and this exemplary description does not constitute a limitation on this embodiment.
[0045] The formation methods of the blockchain system exemplified in (i), (ii), (iii), and (iv) above are only used as examples. In actual use, any formation method that can realize a blockchain system including a main chain and at least one shard can be applied in this embodiment. In addition, the above (i), (ii), (iii), and (iv) can be implemented separately in the blockchain system or coexist. When the above (i), (ii), (iii), and (iv) sharding rules coexist in the blockchain system, sharding conflicts can be avoided by setting priorities, such as the priority of (iv) is greater than the priority of (iii), the priority of (iii) is greater than the priority of (ii), and the priority of (i) is the lowest. Alternatively, the priority of (iii) can be set to be the highest and the priority of (i) to be the lowest. After several rounds of sharding merge with the main chain, the priority of (iv) can be set to be greater than the priority of (iii).
[0046] The specific implementation of the blockchain transaction processing method in this embodiment is described below, including the following steps:
[0047] Step 101, when the main chain periodically obtains the hash value of the latest block generated by the shard, the hash value is recorded in the latest block generated by the main chain.
[0048] Specifically, after introducing shards in parallel with the main chain, both the shards and the main chain will generate blocks regularly. Therefore, it can be set that when the height of the newly generated block of the shard reaches the first preset height, the generation of new blocks will stop. When the main chain detects that the shard stops generating new blocks, it obtains the hash value of the latest block generated by the shard. The first preset height can be pre-stored in the consensus algorithm, for example, the first preset height can be 100. That is to say, when the newly generated block of the shard reaches 100 blocks, the shard stops generating new blocks. The way for the shard to stop generating blocks can be to set the shard seed to empty.
[0049] More specifically, it can also be set that when the number of cross-shard transactions processed by a shard reaches a preset threshold, the generation of new blocks will be stopped, which can avoid the situation where too many cross-shard transactions are processed by the shard, resulting in a decrease in the shard processing efficiency, and effectively ensure the high processing efficiency of the entire blockchain system. Among them, the first threshold preset threshold can also be pre-stored in the consensus algorithm.
[0050] In this implementation, the main chain obtains the hash value of the latest block generated by the shard for recording only when it detects that the shard stops generating new blocks, which can avoid deviations in the latest generated blocks located by the main chain and effectively ensure the consistency between the main chain and the shard. For example, if the shard generates 100 new blocks, the main chain obtains the hash value of the 100th block for recording.
[0051] Step 102, the main chain checks the total transaction volume of the shard.
[0052] Specifically, each time a shard generates a block, the main chain will calculate the total transaction volume, add the transaction volume recorded in the newly generated block to the current total transaction volume, and continuously update the total transaction volume. In other words, the total transaction volume is equal to Among them, i is a positive integer, n represents the nth block, and X represents the transaction volume recorded in the nth block.
[0053] Step 103: The main chain determines whether the total transaction amount is less than or equal to the preset amount. If yes, proceed to step 104; otherwise, proceed to step 105.
[0054] Specifically, the preset number can be pre-stored in the consensus algorithm. In this embodiment, the main chain determines whether the total transaction amount is less than or equal to the preset number to measure whether the shard needs to be introduced to assist in processing pending transactions. If the total transaction amount is less than or equal to the preset number, it is considered that there are no transactions on the shard or the transaction volume is relatively small, and step 104 is executed. The main chain obtains each pending transaction of the shard and processes each pending transaction, that is, the shard is cancelled. If the total transaction amount is greater than the preset number, it is considered that the transaction volume on the shard is large, and steps 105 and 106 are executed. That is, the shard is introduced again for auxiliary processing, and the consistency between the shard and the main chain is achieved, which effectively ensures the stable and healthy operation of the entire blockchain system.
[0055] Step 105, the shard obtains the unprocessed cross-shard transaction credentials of the shard based on the cross-shard transaction credentials recorded on the main chain.
[0056] Step 106, the shard generates pending transactions based on the cross-shard transaction credentials and completes the pending transactions.
[0057] More specifically, each time a cross-shard transaction is processed, a shard will generate a transaction voucher, and the shard will broadcast the transaction voucher so that the relevant shards and the main chain can make corresponding changes to achieve consistency between the cross-shard transaction on the shard and the main chain. At the same time, the shard will make a record on the main chain, that is, the cross-shard transaction voucher is recorded on the main chain. It should be noted that in actual operation, the cross-shard transaction voucher recorded on the main chain can also exist in the form of a URL link, so that other shards can obtain the cross-shard transaction voucher according to the URL link, and make corresponding information changes based on the cross-shard transaction voucher. For example, assuming that the cross-shard transaction is a cross-shard transfer, the general operation process is: the transaction is processed in the shard corresponding to the initiator's account, the shard changes the initiator's balance, generates an account change voucher, the shard broadcasts the account change voucher, and records the account change voucher on the main chain. Other shards change the account balance of the initiator's account after receiving the account change voucher broadcast by the shard, or after "merging" with the main chain.
[0058] In this implementation, if the cross-shard transaction is a DAPP cross-shard call, the shard uses a distributed asynchronous call to process it. That is, after the shard completes its own corresponding processing operation on the cross-shard transaction, it temporarily puts the cross-shard transaction on hold and waits for feedback, and the shard processes the next pending transaction, which effectively ensures the high processing efficiency of the shard.
[0059] It is not difficult to see that the core of this implementation lies in step 101. When the hash value of the latest block generated by the shard is regularly obtained through the main chain, the hash value is recorded in the latest block generated by the main chain, so as to achieve the regular "convergence" of the main chain and the shard, thereby achieving the consistency of the main chain and the shard and ensuring the reliability of the blockchain system. In addition, in steps 102 to 106 of this implementation, the main chain is introduced to judge whether the shard needs to be introduced again, so as to achieve the dynamic load balancing of the shard on the blockchain system, and provide a basis for improving the effective utilization of resources of the blockchain system. In other words, after the judgment result of step 103 is no, it is equivalent to the shard being reintroduced. At this time, the shard needs to execute steps 105 and 106 first to ensure the consistency of the shard with the main chain. In addition, after the shard is reintroduced, steps 101 to 103 will still be continued, which is equivalent to a new cycle, and this is repeated until the system pressure of the blockchain system is low.
[0060] Embodiment 2
[0061] Embodiment 2 of the present invention relates to a blockchain transaction processing method, the specific process is as follows: Figure 2 The second embodiment is improved on the basis of the first embodiment, and the main improvement is that: in the second embodiment of the present invention, after the main chain and the shards fail to "converge" normally, the main chain will stop generating new blocks to wait for the shards to merge, which effectively ensures the stability of the entire blockchain system. The following is a specific description:
[0062] Steps 201 to 206 in this embodiment are substantially the same as steps 101 to 106 in the first embodiment. To reduce repetition, they are not described here again. Only the different parts are described below.
[0063] Step 207: The height of the newly generated block of the main chain reaches the second preset height, and the main chain has not obtained the hash value of the latest block generated by the shard, and the main chain stops generating new blocks.
[0064] Specifically, the second preset height can be pre-stored in the consensus algorithm. The main chain seed is set to zero, so that the main chain stops generating blocks. In this way, the main chain stops generating new blocks to wait for the "inflow" of shards, thereby avoiding the problem of blockchain system bifurcation caused by shards and ensuring the stability of the blockchain system.
[0065] More specifically, if the blockchain system adopts a method in which a shard stops generating new blocks when the height of the newly generated block reaches a first preset height, and the main chain obtains the hash value of the latest block generated by the shard when it detects that the shard has stopped generating new blocks, then the second preset height can be set to be greater than the first preset height. For example, the second preset height can be two or three times the first preset height, thereby achieving forced "convergence" of the main chain and the shard after a certain period of time.
[0066] Compared with the first embodiment, the blockchain system in this embodiment has better stability.
[0067] The step division of the above methods is only for the purpose of clear description. When implemented, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent; adding insignificant modifications to the algorithm or process or introducing insignificant designs without changing the core design of the algorithm and process are all within the scope of protection of this patent.
[0068] Embodiment 3
[0069] The system provided in this embodiment can execute any blockchain transaction processing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the method. The system includes a main chain and at least one shard parallel to the main chain;
[0070] When the main chain periodically obtains the hash value of the latest block generated by the shard, the hash value is recorded in the latest block generated by the main chain;
[0071] The main chain checks the total transaction volume of the shard to determine whether the total transaction volume is less than or equal to the preset amount. If so, the main chain obtains each pending transaction of the shard and processes each pending transaction; otherwise, the shard obtains the unprocessed cross-shard transaction voucher of the shard based on each cross-shard transaction voucher recorded on the main chain, generates pending transactions based on the cross-shard transaction voucher, and completes the pending transactions.
[0072] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0073] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0074] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0075] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0076] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0077] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0078] Those skilled in the art will appreciate that the above-mentioned embodiments are specific embodiments for implementing the present invention, and in actual applications, various changes may be made thereto in form and detail without departing from the spirit and scope of the present invention.
Claims
1. A blockchain transaction processing method, characterized in that: The method is applied to a blockchain system, wherein the blockchain system includes a main chain and at least one shard parallel to the main chain; the method includes: When the main chain periodically obtains the hash value of the latest block generated by the shard, it records the hash value in the latest block generated by the main chain; The main chain checks the total transaction volume of the shard and determines whether the total transaction volume is less than or equal to the preset amount. If so, the main chain obtains each pending transaction of the shard and processes each pending transaction; otherwise, the shard obtains the unprocessed cross-shard transaction voucher of the shard based on each cross-shard transaction voucher recorded on the main chain, generates pending transactions based on the cross-shard transaction voucher, and completes the pending transactions; Among them, the main chain and at least one shard parallel to the main chain are specifically in the following form: obtaining the initiator account of the transaction to be processed; obtaining the shard information corresponding to the initiator account, and taking the original chain of the blockchain system as the main chain; and, introducing a shard parallel to the main chain based on the shard information; handing over part or all of the pending transactions of the initiator account to the shard corresponding to the initiator account for processing; among them, if the transaction to be processed is a smart contract transaction, the initiator account is the smart contract creator account of the transaction to be processed.
2. The blockchain transaction processing method according to claim 1, characterized in that: The main chain periodically obtains the hash value of the latest block generated by the shard, specifically including: When the height of the newly generated block reaches a first preset height, the shard stops generating new blocks; or, when the number of cross-shard transactions processed by the shard reaches a preset threshold, the shard stops generating new blocks; When the main chain detects that the shard stops generating new blocks, it obtains the hash value of the latest block generated by the shard.
3. The blockchain transaction processing method according to claim 1 or 2, characterized in that: Also includes: If the height of the block newly generated by the main chain reaches a second preset height, and the main chain has not obtained the hash value of the block newly generated by the shard, the main chain stops generating new blocks.
4. The blockchain transaction processing method according to claim 3 is characterized in that: When the shard completes the pending transaction, the shard generates a cross-shard transaction credential, broadcasts the cross-shard transaction credential, and records the cross-shard transaction credential on the main chain.
5. The blockchain transaction processing method according to claim 1, characterized in that: The part or all of the pending transactions of the initiator account are handed over to the sharding system corresponding to the initiator account for processing, specifically including: The pending transactions of the transaction type of transfer or smart contract are handed over to the shard corresponding to the initiator account for processing.
6. The blockchain transaction processing method according to claim 1, characterized in that: The main chain and at least one shard parallel to the main chain are specifically in the following form: Get the calling relationship of the smart contract in the pending transaction; Obtain shard information corresponding to the call relationship, and use the original chain as the main chain; and, introduce a shard parallel to the main chain according to the shard information, and hand over the pending transaction to the shard for processing.
7. The blockchain transaction processing method according to claim 1, characterized in that: The main chain and at least one shard parallel to the main chain are specifically in the following form: Get the population of decentralized applications (DAPPs) in pending transactions; Obtain the shard information corresponding to the group, and use the original chain as the main chain; and, introduce a shard parallel to the main chain according to the shard information, and hand over the pending transaction to the shard for processing.
8. The blockchain transaction processing method according to claim 1, characterized in that: The main chain and at least one shard parallel to the main chain are specifically in the following form: Get the initiator account of the pending transaction; Obtaining shard information corresponding to the group to which the initiator account belongs, and using the original chain as the main chain; and introducing a shard parallel to the main chain based on the shard information; Submit part or all of the pending transactions of the initiator account to the shard corresponding to the initiator account for processing; The group to which the initiator account belongs is generated according to the coupling degree between the initiator account and other accounts.
9. A blockchain transaction processing system, characterized in that: It includes a main chain and at least one shard parallel to the main chain; When the main chain periodically obtains the hash value of the latest block generated by the shard, the hash value is recorded in the latest block generated by the main chain; The main chain checks the total transaction volume of the shard and determines whether the total transaction volume is less than or equal to the preset amount. If so, the main chain obtains each pending transaction of the shard and processes each pending transaction; otherwise, the shard obtains the unprocessed cross-shard transaction voucher of the shard based on each cross-shard transaction voucher recorded on the main chain, generates pending transactions based on the cross-shard transaction voucher, and completes the pending transactions; Among them, the main chain and at least one shard parallel to the main chain are specifically in the following form: obtaining the initiator account of the transaction to be processed; obtaining the shard information corresponding to the initiator account, and taking the original chain of the blockchain system as the main chain; and, introducing a shard parallel to the main chain based on the shard information; handing over part or all of the pending transactions of the initiator account to the shard corresponding to the initiator account for processing; among them, if the transaction to be processed is a smart contract transaction, the initiator account is the smart contract creator account of the transaction to be processed.
Citation Information
Patent Citations
Block chain cross-chain communication method and system, electronic device and storage medium
CN109934592A
Parallel chain main chain transaction state synchronization method and device, and storage medium
CN110084601A
