Data processing method based on block chain and related equipment
By sharding the transaction pool and adopting multiple storage and selection strategies, and storing and selecting transaction data according to different attributes of the transaction data, the problem of inefficient transaction data processing in existing blockchain technology is solved, and more efficient transaction pool processing and block construction are achieved.
Patent Information
- Application Number
- CN202410097734.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-23
- Publication Date
- 2025-07-25
AI Technical Summary
In the existing blockchain technology, the storage and extraction methods of transaction data are single, and the lack of diversity leads to inefficient processing of transaction pools.
By dividing the transaction pool into multiple transaction pool fragments, and using multiple storage strategies and selection strategies, transaction data is stored and selected according to different attributes of the transaction data for block construction processing, including reference resource consumption, transaction creation time, and transaction reception order.
It enriches the storage and extraction methods of transaction data, improves the processing efficiency of transaction data related to transaction pools, realizes concurrent operations, and improves the efficiency of block construction processing.
Smart Images

Figure CN120371912A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of blockchain technology, and in particular, to a data processing method and related devices based on blockchain. Background Art
[0002] In the current blockchain scenario, blockchain nodes in a blockchain network can store received transaction data in their transaction pools. In the case of constructing a block, transaction data can be extracted from the transaction pool and used for block construction processing (i.e., block packaging). In existing implementation methods, usually the received transaction data is directly stored in the transaction pool, and usually the strategy of first come, first packaged is adopted to extract transaction data for packaging, and the storage method and extraction method of transaction data are single. Summary of the Invention
[0003] Embodiments of this application provide a data processing method and related devices based on blockchain, which can enrich the storage method and extraction method of transaction data.
[0004] On the one hand, embodiments of this application provide a data processing method based on blockchain, and the method includes:
[0005] Obtain a set of transaction data; the set of transaction data includes at least one transaction data;
[0006] Determine the transaction pool shard corresponding to each transaction data from N transaction pool shards; where the N transaction pool shards are obtained by partitioning the transaction pool, and N is a positive integer;
[0007] According to a target storage strategy, store the transaction data corresponding to each transaction pool shard in the corresponding transaction pool shard to obtain a to-be-packaged sequence corresponding to each transaction pool shard; where the target storage strategy is determined from multiple storage strategies, each transaction data has multiple transaction attributes, and different storage strategies refer to different transaction attributes when storing transaction data;
[0008] In the case of constructing a block, select transaction data from N to-be-packaged sequences according to the target selection strategy corresponding to the target storage strategy, and use the selected transaction data for block construction processing.
[0009] On the one hand, embodiments of this application provide a data processing device based on blockchain, and the device includes:
[0010] A communication unit for performing communication interaction;
[0011] A processing unit for obtaining a set of transaction data; the set of transaction data includes at least one transaction data; determining, from N transaction pool shards, the transaction pool shard corresponding to each transaction data; wherein the N transaction pool shards are obtained by partitioning a transaction pool, and N is a positive integer; storing the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard according to a target storage policy, to obtain a to-be-packed sequence corresponding to each transaction pool shard; wherein the target storage policy is determined from multiple storage policies, each transaction data has multiple transaction attributes, and different storage policies refer to different transaction attributes when storing transaction data; in the case of needing to construct a block, selecting transaction data from the N to-be-packed sequences according to the target selection policy corresponding to the target storage policy, and performing block construction processing using the selected transaction data.
[0012] In one implementation, the multiple storage policies include at least two of: a first storage policy, a second storage policy, and a third storage policy;
[0013] The transaction attribute referred to by the first storage policy is: the amount of consumption resources required for on-chain transaction data. In the case where the target storage policy is the first storage policy, the order of transaction data in any to-be-packed sequence is in ascending order of the consumption resources amount, and the corresponding target selection policy is used to indicate selecting transaction data from the tail of any to-be-packed sequence in descending order of the consumption resources amount;
[0014] The transaction attribute referred to by the second storage policy is: the transaction creation time of the transaction data. In the case where the target storage policy is the second storage policy, the order of transaction data in any to-be-packed sequence is in ascending order of the transaction creation time, and the corresponding target selection policy is used to indicate selecting transaction data from the head of any to-be-packed sequence in ascending order of the transaction creation time;
[0015] The transaction attribute referred to by the third storage policy is: the transaction reception order of the transaction data. In the case where the target storage policy is the third storage policy, the order of transaction data in any to-be-packed sequence is in ascending order of the transaction reception order, and the corresponding target selection policy is used to indicate selecting transaction data from the head of any to-be-packed sequence in ascending order of the transaction reception order.
[0016] In one implementation, when the processing unit is used to select transaction data from the N to-be-packed sequences according to the target selection policy corresponding to the target storage policy, it may specifically be used to:
[0017] Obtain the target quantity of the transaction data to be selected;
[0018] When the total number of transaction data included in the N sequences to be packaged is less than or equal to the target number, all the transaction data is selected from each sequence to be packaged;
[0019] When the total number of transaction data included in the N sequences to be packaged is greater than the target number, the selection quantity corresponding to each sequence to be packaged is determined; the sum of the selection quantities corresponding to each sequence to be packaged is less than or equal to the target number;
[0020] According to the selection order indicated by the target selection strategy, the corresponding selection quantity of transaction data is selected from each sequence to be packaged.
[0021] In an implementation manner, the target storage strategy is the first storage strategy, and the data structure of any sequence to be packaged is a binary tree. When the processing unit is used to store the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard according to the target storage strategy to obtain the sequence to be packaged corresponding to each transaction pool shard, it can be specifically used for:
[0022] Construct a tree to be sorted according to the transaction data corresponding to the nth transaction pool shard among the N transaction pool shards and the un-packaged transaction data in the nth transaction pool shard; the tree to be sorted is a binary tree, and the nodes in the tree to be sorted are transaction data, where n ∈ [1, N];
[0023] According to the resource consumption amount of each node in the tree to be sorted, adjust and process each node in the tree to be sorted to obtain a first intermediate tree; the first intermediate tree is a max heap, and the resource consumption amount of any node in the max heap is greater than or equal to the resource consumption amount of its corresponding child node;
[0024] Exchange the last node in the first intermediate tree with the root node to obtain a second intermediate tree;
[0025] Adjust the second intermediate tree to obtain a target sorted tree, and obtain the sequence to be packaged corresponding to the nth transaction pool shard according to the transaction data recorded in the target sorted tree.
[0026] In an implementation manner, when the processing unit is used to adjust and process each node in the tree to be sorted according to the resource consumption amount of each node in the tree to be sorted to obtain a first intermediate tree, it can be specifically used for:
[0027] Start from the last non-leaf node in the tree to be sorted, and traverse each non-leaf node in the tree to be sorted layer by layer in the direction towards the root node;
[0028] For the currently traversed node, if the resource consumption of the currently traversed node is less than the resource consumption of the left child node of the currently traversed node, then swap the currently traversed node with the corresponding left child node, and when the resource consumption of the swapped left child node is less than that of the child node of the corresponding left child node, adjust the nodes of the subtree corresponding to the corresponding left child node;
[0029] If the resource consumption of the currently traversed node is less than the resource consumption of the right child node of the currently traversed node, then swap the currently traversed node with the corresponding right child node, and when the resource consumption of the swapped right child node is less than that of the child node of the corresponding right child node, adjust the nodes of the subtree corresponding to the corresponding right child node;
[0030] Until the traversal ends and the first intermediate tree is obtained through adjustment.
[0031] In one implementation, when the processing unit is used to construct the tree to be sorted according to the transaction data corresponding to the nth transaction pool slice among the N transaction pool slices and the un-packaged transaction data in the nth transaction pool slice, it may specifically be used for:
[0032] Construct the tree to be sorted from the transaction data corresponding to the nth transaction pool slice and the un-packaged transaction data in the nth transaction pool slice in a random order;
[0033] Or, construct the tree to be sorted from the transaction data corresponding to the nth transaction pool slice and the un-packaged transaction data in the nth transaction pool slice in ascending order of the transaction reception order;
[0034] Or, take the transaction data corresponding to the nth transaction pool slice as a node and add it after the last node of the binary tree formed by the un-packaged transaction data in the nth transaction pool slice in a random order or in ascending order of the transaction reception order to obtain the tree to be sorted.
[0035] In one implementation, the target storage policy is the second storage policy, the data structure of any sequence to be packed is a linked list. When the processing unit is used to store the transaction data corresponding to each transaction pool slice into the corresponding transaction pool slice according to the target storage policy to obtain the sequence to be packed corresponding to each transaction pool slice, it may specifically be used for:
[0036] Determine the transaction linked list formed by the un-packaged transaction data in the nth transaction pool slice, where n ∈ [1, N];
[0037] Traverse the transaction data corresponding to the nth transaction pool slice;
[0038] For the target transaction data being currently traversed, starting from the last transaction data in the transaction linked list and moving towards the first transaction data in the transaction linked list, compare the transaction creation times between the target transaction data and the transaction data in the transaction linked list in sequence until a reference transaction data with a transaction creation time earlier than the target transaction data is determined from the transaction linked list, and add the target transaction data to the transaction linked list as the transaction data after the reference transaction data in the transaction linked list;
[0039] If the determination of the reference transaction data fails, add the target transaction data to the transaction linked list as the transaction data before the first transaction data in the transaction linked list;
[0040] According to the various transaction data recorded in the transaction linked list obtained after the traversal, obtain the to-be-packaged sequence corresponding to the nth transaction pool shard.
[0041] In one implementation, the target storage policy is the third storage policy, and the data structure of any to-be-packaged sequence is a queue. When the processing unit is used to store the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard according to the target storage policy to obtain the to-be-packaged sequence corresponding to each transaction pool shard, it can be specifically used for:
[0042] Determine a transaction queue composed of the un-packaged transaction data in the nth transaction pool shard, where n ∈ [1, N];
[0043] Based on the ascending order of the transaction reception order, add the various transaction data corresponding to the nth transaction pool shard to the transaction queue in sequence;
[0044] According to the various transaction data recorded in the transaction queue after the addition is completed, obtain the to-be-packaged sequence corresponding to the nth transaction pool shard.
[0045] In one implementation, the blockchain is maintained by a blockchain network, and the blockchain network includes multiple consensus nodes. After a consensus node that performs block construction processing constructs a target block using the selected transaction data, it broadcasts the target block to other consensus nodes; after each consensus node in the blockchain network obtains the target block, it performs consensus processing on the target block based on the transaction data in the transaction pool of the corresponding consensus node, and after reaching a consensus on the target block, uploads the target block to the blockchain and removes the transaction data in the target block from the transaction pool.
[0046] In one implementation, the way for a target consensus node in the blockchain network to perform consensus processing on the target block based on the transaction data in the transaction pool of the target consensus node includes:
[0047] Verify the validity of the target block based on the transaction data in the transaction pool of the target consensus node;
[0048] When it is verified that the target block is valid, execute the transactions indicated by the respective transaction data in the target block;
[0049] When the transaction execution result determined by the target consensus node is consistent with the transaction execution result carried by the target block, determine that the target consensus node reaches a consensus on the target block;
[0050] Otherwise, determine that the target consensus node does not reach a consensus on the target block.
[0051] On the one hand, an embodiment of the present application provides a computer device. The computer device includes an input interface and an output interface. The computer device further includes:
[0052] A processor and a computer-readable storage medium;
[0053] The computer-readable storage medium is used to store a computer program;
[0054] The processor is used to run the computer program to implement the above-mentioned blockchain-based data processing method.
[0055] On the one hand, an embodiment of the present application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and the computer program is adapted to be loaded and executed by the processor to implement the above-mentioned blockchain-based data processing method.
[0056] On the one hand, an embodiment of the present application provides a computer program product. The computer program product includes a computer program, and the computer program is adapted to be loaded and executed by the processor to implement the above-mentioned blockchain-based data processing method.
[0057] In the embodiments of the present application, a variety of storage strategies for transaction data and a selection strategy corresponding to each storage strategy are provided. When different storage strategies are adopted, the transaction data can be stored in the transaction pool based on different transaction attributes. When constructing a block, the selection strategy corresponding to the storage strategy used can be adopted to select transaction data from the transaction pool for block construction processing, enriching the storage method of transaction data in the transaction pool and the method of extracting (selecting) transaction data from the transaction pool when constructing a block; moreover, the embodiments of the present application propose that the transaction pool can be divided into at least one transaction pool shard. When the transaction pool is divided into multiple transaction pool shards, concurrent operations on the transaction data can be implemented based on the multiple transaction pool shards (for example, concurrent storage or concurrent selection of transaction data based on the multiple transaction pool shards), which can improve the processing efficiency of the transaction data related to the transaction pool. Description of the Drawings
[0058] To more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0059] Figure 1 is a schematic structural diagram of a blockchain system provided by an embodiment of the present application;
[0060] Figure 2 is a schematic flowchart of a data processing method based on blockchain provided by an embodiment of the present application;
[0061] Figure 3 is a schematic flowchart of another data processing method based on blockchain provided by an embodiment of the present application;
[0062] Figure 4a is a schematic diagram of a tree to be sorted provided by an embodiment of the present application;
[0063] Figure 4b is a schematic diagram of constructing a first intermediate tree provided by an embodiment of the present application;
[0064] Figure 4c is a schematic diagram of constructing a second intermediate tree provided by an embodiment of the present application;
[0065] Figure 4d is a schematic diagram of constructing a target sorted tree provided by an embodiment of the present application;
[0066] Figure 4e is a schematic diagram of another tree to be sorted provided by an embodiment of the present application;
[0067] Figure 4f is a schematic diagram of sharding a transaction pool provided by an embodiment of the present application;
[0068] Figure 5a is a schematic diagram of constructing a sequence to be packaged provided by an embodiment of the present application;
[0069] Figure 5b is a schematic diagram of another sharding of the transaction pool provided by an embodiment of the present application;
[0070] Figure 6a is a schematic diagram of another construction of a sequence to be packaged provided by an embodiment of the present application;
[0071] Figure 6b is a schematic diagram of yet another sharding of the transaction pool provided by an embodiment of the present application;
[0072] Figure 7a It is a schematic diagram of another sharding of the transaction pool provided by an embodiment of the present application;
[0073] Figure 7b It is a schematic diagram of the interaction between consensus nodes provided by an embodiment of the present application;
[0074] Figure 8 It is a schematic diagram of the structure of a data processing device based on a blockchain provided by an embodiment of the present application;
[0075] Figure 9 It is a schematic diagram of the structure of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0076] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application.
[0077] Blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission (i.e., Peer to Peer transmission, that is, a transmission method based on the peer-to-peer transmission protocol), consensus mechanism, and encryption algorithm; in essence, it is a decentralized database, which is a string of data blocks (i.e., blocks) generated by using cryptographic methods; each data block (block) contains information (i.e., data) of a batch of network transactions, which is used to verify the validity of its information (i.e., anti-counterfeiting) and generate the next block. The blockchain includes a series of blocks (Blocks) that are sequentially connected in the order of generation, and the blocks record the block data packaged and submitted by the blockchain nodes in the blockchain network; the blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.
[0078] The underlying blockchain platform may include processing modules such as object management, basic services, smart contracts, and operation supervision. Among them, the object management module is responsible for the identity information management of all blockchain participants, including maintaining the generation of public and private keys (account management), key management, and the maintenance of the correspondence between the real identity of the object and the blockchain address (permission management). And under authorization, it supervises and audits the transaction situations of certain real identities, and provides the rule configuration for risk control (risk control audit); the basic service module is deployed on all blockchain node devices (also known as blockchain nodes) used to maintain the blockchain, used to verify the validity of business requests, and record them on the storage after consensus on valid requests. For a new business request, the basic service module first performs interface adaptation parsing and authentication processing (interface adaptation), then encrypts the business information through a consensus algorithm (consensus management), transmits it to the shared ledger completely and consistently after encryption (network communication), and performs record storage; the smart contract module is responsible for the registration and issuance of contracts, contract triggering and contract execution. Developers can define contract logic through a certain programming language, publish it to the blockchain (contract registration), trigger the execution by calling keys or other events according to the logic of the contract terms, complete the contract logic, and at the same time provide the functions of contract upgrade and cancellation; the operation supervision module is mainly responsible for the deployment, configuration modification, contract setting, cloud adaptation during the product release process, and the visual output of the real-time state during the product operation, such as: alarm, monitoring network conditions, monitoring the health status of blockchain nodes, etc. The platform product service layer provides the basic capabilities and implementation frameworks of typical applications. Developers can build on these basic capabilities and overlay the characteristics of the business to complete the blockchain implementation of the business logic. The application service layer provides application services based on the blockchain solution for business participants to use. It should be noted that the transactions involved in the embodiments of this application can be understood as the computer term Transaction. A transaction includes one or more of the data that needs to be submitted to the blockchain network and the operations that need to be executed. In view of the established use of the term "transaction" in blockchain technology, the embodiments of this application follow this convention. Similarly, the shared ledger and the like involved in the embodiments of this application are also computer terms in the blockchain technology field.
[0079] Based on the above description of the blockchain, the embodiments of this application provide a blockchain system. Refer to Figure 1 , which is a schematic structural diagram of a blockchain system provided by the embodiments of this application. The blockchain system may include a terminal device cluster and a blockchain network. The blockchain network can be used to maintain the blockchain; the terminal device cluster in the blockchain system can be marked as 10, and the blockchain network in the blockchain system can be marked as 11.
[0080] Among them, Figure 1The terminal device cluster 10 shown may include one or more terminal devices. The terminal devices in the terminal device cluster 10 may be marked as 101. The embodiments of the present application do not limit the number of terminal devices in the terminal device cluster 10. Among them, Figure 1 The blockchain network 11 shown is a network composed of a blockchain and a peer-to-peer network. The blockchain network 11 may include multiple blockchain nodes (also called consensus nodes). The blockchain nodes in the blockchain network 11 may be marked as 111. The embodiments of the present application do not limit the number of blockchain nodes in the blockchain network 11; the blockchain nodes in the blockchain network 11 can be used to jointly maintain the blockchain. The blockchain nodes in the blockchain network 11 are connected based on a peer-to-peer manner. The blockchain nodes in the blockchain network 11 support consensus communication based on peer-to-peer transmission and a consensus mechanism. The so-called consensus mechanism refers to a mechanism that completes the verification and confirmation of data in a short time through the voting of blockchain nodes. It should be understood that any blockchain node in the blockchain network 11 can be a terminal device or a server; the terminal devices mentioned in the embodiments of the present application may be smartphones, tablets, laptops, desktop computers, intelligent vehicles, and smart wearable devices, etc. The embodiments of the present application do not limit this; the servers mentioned in the embodiments of the present application may be independent physical servers, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms, etc. The embodiments of the present application do not limit this.
[0081] As Figure 1 shown, the terminal device 101 in the terminal device cluster 10 supports communication connection with the blockchain node 111 in the blockchain network 11 to achieve data interaction with the blockchain node 111 in the blockchain network 11. For example, the terminal device 101 can be used as a service terminal. The service object can send a data query request to the blockchain network 11 through this service terminal. The blockchain nodes in the blockchain network 11 can determine the request result based on this data query request, and then return the request result to the corresponding service terminal; the service object can send transaction data to the blockchain network 11 through this service terminal. The blockchain nodes in the blockchain network 11 can execute the transactions indicated by the corresponding transaction data. It should be noted that Figure 1 In the blockchain system shown, devices with communication requirements can communicate in a wired or wireless manner. The embodiments of the present application do not limit this.
[0082] Based on the above description, an embodiment of the present application provides a data processing solution based on a blockchain. This data processing solution based on a blockchain can be executed by a blockchain node in a blockchain network. For example, it can be executed by Figure 1 the blockchain node 111 in the blockchain network 11 shown. This data processing solution based on a blockchain proposes that after a blockchain node obtains a transaction data set containing transaction data, it can determine the transaction pool shard corresponding to each transaction data from N transaction pool shards, and according to the target storage strategy, store the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard to obtain a to-be-packed sequence corresponding to each transaction pool shard. In the case of needing to construct a block, it can select transaction data from N to-be-packed sequences according to the target selection strategy corresponding to the target storage strategy, and use the selected transaction data to perform block construction processing; where, the N transaction pool shards are obtained by dividing a transaction pool, N is a positive integer, the target storage strategy is determined from multiple storage strategies, each transaction data has multiple transaction attributes, and different storage strategies refer to different transaction attributes when storing transaction data.
[0083] It should be particularly noted that in the practical application of the collection and processing of relevant data (such as transaction data) in the present application, the informed consent or separate consent of the personal information subject should be obtained strictly in accordance with the requirements of laws and regulations, and subsequent data use and processing behaviors should be carried out within the scope authorized by laws and regulations and the personal information subject.
[0084] Based on the above description, an embodiment of the present application provides a data processing method based on a blockchain. Refer to Figure 2 , which is a schematic flowchart of a data processing method based on a blockchain provided by an embodiment of the present application; this data processing method based on a blockchain can be executed by a blockchain node in a blockchain network. For example, it can be executed by Figure 1 the blockchain node 111 in the blockchain network 11 of the blockchain system shown. This data processing method based on a blockchain may include the following steps S201 - S204:
[0085] S201, obtain a transaction data set; the transaction data set includes at least one transaction data.
[0086] Among them, the transaction data in the transaction data set includes the transaction data received by the blockchain node.
[0087] S202, determine the transaction pool shard corresponding to each transaction data from N transaction pool shards.
[0088] Among them, the N trading pool shards are obtained by partitioning the trading pool, where N is a positive integer; the number of trading pool shards can be set according to specific requirements. For example, the trading pool can be set to be partitioned into 5 trading pool shards, 10 trading pool shards, etc., and the embodiments of the present application do not limit this. In a feasible implementation manner, when determining the trading pool shard corresponding to each transaction data from the N trading pool shards, it can be determined randomly. That is to say, for any transaction data, one trading pool shard can be randomly selected from the N trading pool shards as the trading pool shard corresponding to the transaction data.
[0089] S203. According to the target storage policy, store the transaction data corresponding to each trading pool shard into the corresponding trading pool shard to obtain the to-be-packaged sequence corresponding to each trading pool shard.
[0090] Among them, the target storage policy is determined from multiple storage policies. Each transaction data has multiple transaction attributes, and different storage policies refer to different transaction attributes when storing transaction data.
[0091] In a feasible implementation manner, the multiple storage policies may include at least two of the first storage policy, the second storage policy, and the third storage policy; among them, the transaction attribute referred to by the first storage policy is the amount of consumption resources required for the on-chain transaction data. When the target storage policy is the first storage policy, the order of the transaction data in any to-be-packaged sequence is in ascending order of the consumption resources; the transaction attribute referred to by the second storage policy is the transaction creation time of the transaction data. When the target storage policy is the second storage policy, the order of the transaction data in any to-be-packaged sequence is in ascending order of the transaction creation time; the transaction attribute referred to by the third storage policy is the transaction reception order of the transaction data. When the target storage policy is the third storage policy, the order of the transaction data in any to-be-packaged sequence is in ascending order of the transaction reception order.
[0092] In a feasible implementation manner, the target storage policy can be configurable. That is to say, the developers (or organizations or institutions) of the blockchain network can select a storage policy from multiple storage policies and configure it as the target storage policy according to specific requirements. When determining the target storage policy from multiple storage policies, the blockchain node can determine it according to the configured storage policy. In an alternative implementation manner, if the blockchain node fails to obtain the configured storage policy, it can determine the target storage policy from multiple storage policies according to the policy selection mechanism. Among them, the policy selection mechanism can be configured according to specific requirements. For example, a policy selection mechanism can indicate to randomly select a storage policy from multiple storage policies as the target storage policy. Another example is that a policy selection mechanism can indicate to select the storage policy with the highest priority from multiple storage policies according to the priority of the storage policy, where the priority of the storage policy can be configured according to specific requirements.
[0093] S204. In the case of constructing a block, select transaction data from N to-be-packed sequences according to the target selection policy corresponding to the target storage policy, and use the selected transaction data for block construction processing.
[0094] Among them, the target selection policy can be used to indicate the selection order adopted when selecting transaction data from any to-be-packed sequence. When the target storage policy is the first storage policy, the corresponding target selection policy is used to indicate to select transaction data from the tail of any to-be-packed sequence in descending order of resource consumption. When the target storage policy is the second storage policy, the corresponding target selection policy is used to indicate to select transaction data from the head of any to-be-packed sequence in ascending order of transaction creation time. When the target storage policy is the third storage policy, the corresponding target selection policy is used to indicate to select transaction data from the head of any to-be-packed sequence in ascending order of transaction reception order.
[0095] In the embodiments of the present application, multiple storage strategies for transaction data and selection strategies corresponding to each storage strategy are provided. When different storage strategies are adopted, transaction data can be stored in a transaction pool based on different transaction attributes. In the case of constructing a block, the selection strategy corresponding to the storage strategy used can be adopted to select transaction data from the transaction pool for block construction processing, enriching the storage method of transaction data in the transaction pool and the method of extracting (selecting) transaction data from the transaction pool in the case of constructing a block. Moreover, the embodiments of the present application propose that the transaction pool can be divided into at least one transaction pool shard. In the case where the transaction pool is divided into multiple transaction pool shards, concurrent operations on transaction data can be implemented based on multiple transaction pool shards (for example, concurrent storage or concurrent selection of transaction data based on multiple transaction pool shards), which can improve the processing efficiency of transaction data related to the transaction pool.
[0096] Based on the above description, the embodiments of the present application provide another blockchain-based data processing method. Refer to Figure 3 , which is a flowchart of another blockchain-based data processing method provided by the embodiments of the present application. This blockchain-based data processing method can be executed by a blockchain node in a blockchain network. For example, it can be executed by the blockchain node 111 in the blockchain network 11 of the blockchain system shown in Figure 1 . This blockchain-based data processing method may include the following steps S301-S307:
[0097] S301, obtain a transaction data set; the transaction data set includes at least one transaction data.
[0098] Among them, the transaction data in the transaction data set includes the transaction data received by the blockchain node. After receiving the transaction data, the blockchain node can add the transaction data to the transaction data set. Optionally, after receiving the transaction data, the blockchain node can also perform a validity check on the transaction data. In the case where it is determined that the transaction data passes the validity check (that is, it is determined that the transaction data is valid), the transaction data is added to the transaction data set. Optionally, when performing the validity check on the transaction data, it can be implemented based on data such as the account address of the transaction data and the signature information of the transaction data.
[0099] In a feasible implementation, the blockchain node can trigger the operation of obtaining a set of transaction data when detecting a target trigger condition; among them, the set of transaction data obtained by the blockchain node this time can include the transaction data received during the historical time period from the last time the operation of obtaining the set of transaction data was triggered to this time the operation of obtaining the set of transaction data was triggered. That is to say, the blockchain node can continuously receive transaction data, and when detecting the target trigger condition, store the received transaction data into the transaction pool shards to obtain a to-be-packaged sequence, so that subsequent transaction data can be selected from the to-be-packaged sequence and packaged into a block when a block needs to be constructed.
[0100] In a feasible implementation, the target trigger condition can indicate that the current time point reaches a specified time point; that is, the blockchain node triggers the operation of obtaining a set of transaction data when detecting that the current time point reaches the specified time point. Optionally, the specified time point can be configured according to specific requirements, and the embodiments of the present application do not limit this; for example, the specified time point can be configured as zero o'clock (i.e., 00:00), 8 o'clock in the morning (i.e., 8:00), 2 o'clock in the afternoon (i.e., 14:00), etc. of a day; another example is that the specified time point can be configured as a periodic node of a time period, and the time period can be configured according to specific requirements, for example, the time period can be configured as 5 minutes, 10 minutes, 30 minutes, etc.
[0101] In a feasible implementation, the target trigger condition can indicate that all the transaction data in the N transaction pool shards have been packaged, that is, there is no un-packaged transaction data in the N transaction pool shards, that is, all the transaction data in the N to-be-packaged sequences constructed after the last time the operation of obtaining the set of transaction data was triggered have been packaged. In another feasible implementation, the target trigger condition can indicate that in the N transaction pool shards, all the transaction data in H transaction pool shards have been packaged, where H is a positive integer and H can be set according to specific requirements, for example, it can be set as 1, N - 1, N - 2, etc., and the embodiments of the present application do not limit this.
[0102] S302. Determine the transaction pool shard corresponding to each transaction data from the N transaction pool shards.
[0103] Among them, the N transaction pool shards are obtained by partitioning the transaction pool, and N is a positive integer.
[0104] In a feasible implementation manner, when the blockchain node determines the transaction pool shard corresponding to each transaction data from the N transaction pool shards, it can be determined randomly. In another feasible implementation manner, when the blockchain node determines the transaction pool shard corresponding to each transaction data from the N transaction pool shards, it can be determined according to the account address corresponding to each transaction data; taking the determination of the transaction pool shard corresponding to a transaction data as an example, the blockchain node can obtain the account address corresponding to the transaction data, and determine the remainder of the account address relative to the number N of the transaction pool shards, and determine the transaction pool shard indicated by the determined remainder as the transaction pool shard corresponding to the transaction data; for example, if the determined remainder is 0, the transaction pool shard indicated by 0 is determined as the transaction pool shard corresponding to the transaction data, and if the determined remainder is N - 1, the transaction pool shard indicated by N - 1 is determined as the transaction pool shard corresponding to the transaction data; wherein, the process of determining the remainder of the account address relative to the number N of the transaction pool shards is the process of taking the account address modulo N.
[0105] S303. According to the target storage strategy, store the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard to obtain a to-be-packaged sequence corresponding to each transaction pool shard.
[0106] Wherein, the target storage strategy is determined from multiple storage strategies, each transaction data has multiple transaction attributes, and different storage strategies refer to different transaction attributes when storing transaction data.
[0107] In a feasible implementation, when the target storage policy is the first storage policy, the data structure of any sequence to be packaged is a binary tree; when the blockchain node stores the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard according to the target storage policy to obtain the sequence to be packaged corresponding to each transaction pool shard, the following steps can be executed: construct a tree to be sorted according to the transaction data corresponding to the nth transaction pool shard among the N transaction pool shards and the un-packaged transaction data in the nth transaction pool shard; the tree to be sorted is a binary tree, and the nodes in the tree to be sorted are transaction data, where n ∈ [1, N]; adjust each node in the tree to be sorted according to the resource consumption of each node in the tree to be sorted to obtain a first intermediate tree; the first intermediate tree is a max heap, and the resource consumption of any node in the max heap is greater than or equal to the resource consumption of the corresponding node's child node; swap the last node in the first intermediate tree with the root node to obtain a second intermediate tree; adjust the second intermediate tree to obtain a target sorted tree, and obtain the sequence to be packaged corresponding to the nth transaction pool shard according to the transaction data recorded in the target sorted tree. Among them, the un-packaged transaction data in the nth transaction pool shard, that is, after the operation of triggering the execution of obtaining the transaction data set last time, the un-packaged transaction data in the nth sequence to be packaged constructed, that is, the un-packaged transaction data in the remaining historical sequence to be packaged of the nth transaction pool shard; the process of adjusting to obtain the target sorted tree according to the resource consumption of each node in the tree to be sorted can be a heap sorting process.
[0108] In a feasible implementation manner, when constructing a tree to be sorted based on the transaction data corresponding to the nth transaction pool shard among N transaction pool shards and the un-packaged transaction data in the nth transaction pool shard, the blockchain node may: construct the tree to be sorted from the transaction data corresponding to the nth transaction pool shard and the un-packaged transaction data in the nth transaction pool shard in a random order; or construct the tree to be sorted from the transaction data corresponding to the nth transaction pool shard and the un-packaged transaction data in the nth transaction pool shard in ascending order of the transaction reception order. Taking the construction of the tree to be sorted in ascending order of the transaction reception order as an example, if there are 3 un-packaged transaction data in the nth transaction pool shard, and when these 3 un-packaged transaction data are arranged in ascending order of the transaction reception order, they are respectively: transaction data a (abbreviation: a), transaction data b (abbreviation: b), transaction data c (abbreviation: c), and when the transaction data corresponding to the nth transaction pool shard are arranged in ascending order of the reception order, they are respectively: transaction data d (abbreviation: d), transaction data e (abbreviation: e), transaction data f (abbreviation: f), then the transaction data used to construct the tree to be sorted are arranged in ascending order of the transaction reception order as: a, b, c, d, e, f. Assuming that the resource consumption amounts of each of these 6 transaction data are respectively: 3, 7, 16, 10, 21, 23, the tree to be sorted constructed in ascending order of the transaction reception order may be as shown in Figure 4a ; among which, the 0th node (i.e., the root node) is a, the 1st node is b, the 2nd node is c, the 3rd node is d, the 4th node is e, and the 5th node is f.
[0109] In a feasible implementation, when the blockchain node adjusts each node in the tree to be sorted according to the resource consumption of each node in the tree to be sorted and obtains the first intermediate tree, it can be adjusted according to the large top heap adjustment rule. Based on this, when the blockchain node adjusts each node in the tree to be sorted according to the resource consumption of each node in the tree to be sorted and obtains the first intermediate tree, the following steps can be executed: starting from the last non-leaf node in the tree to be sorted, traverse each non-leaf node in the tree to be sorted layer by layer towards the root node; for the currently traversed node, if the resource consumption of the currently traversed node is less than the resource consumption of the left child node of the currently traversed node, then swap the currently traversed node with the corresponding left child node, and when the resource consumption of the swapped left child node is less than the child node of the corresponding left child node, adjust the nodes of the subtree corresponding to the left child node; if the resource consumption of the currently traversed node is less than the resource consumption of the right child node of the currently traversed node, then swap the currently traversed node with the corresponding right child node, and when the resource consumption of the swapped right child node is less than the child node of the corresponding right child node, adjust the nodes of the subtree corresponding to the right child node; until the traversal ends and the first intermediate tree is adjusted. Among them, when adjusting the nodes of the subtree corresponding to the left child node when the resource consumption of the swapped left child node is less than the child node of the corresponding left child node, the resource consumption of any node in the adjusted subtree should be greater than or equal to the resource consumption of the corresponding node's child node, that is to say, the adjusted subtree should also satisfy the characteristics of the large top heap; when adjusting the nodes of the subtree corresponding to the right child node when the resource consumption of the swapped right child node is less than the child node of the corresponding right child node, the resource consumption of any node in the adjusted subtree should be greater than or equal to the resource consumption of the corresponding node's child node, that is to say, the adjusted subtree should also satisfy the characteristics of the large top heap.
[0110] Taking Figure 4a the tree to be sorted shown as an example, the 0th node (i.e., the root node) is a, the 1st node is b, the 2nd node is c, the 3rd node is d, the 4th node is e, and the 5th node is f; please refer to Figure 4b , which is a schematic diagram of constructing the first intermediate tree provided by the embodiment of the present application, that is, the process of constructing a large top heap based on the tree to be sorted.
[0111] If the current traversal is the first traversal, the node of the first traversal (i.e., the current traversal node) is the last non-leaf node in the tree to be sorted, which is the 2nd node (c). The left child node of the 2nd node is the 5th node (f), and the 2nd node has no right child node. At this time, the resource consumption of the 2nd node (16) is less than that of the 5th node (23), so the 2nd node and the 5th node are exchanged. The tree to be sorted after the exchange can be as shown by the 401 mark. At this time, the 2nd node is f and the 5th node is c.
[0112] If the current traversal is the second traversal, the node of the second traversal (i.e., the current traversal node) is the 1st node (b). The left child node of the 1st node is the 3rd node (d), and the right child node of the 1st node is the 4th node (e). At this time, the resource consumption of the 1st node (7) is less than that of the 3rd node (10), so the 1st node and the 3rd node are exchanged. The tree to be sorted after the exchange can be as shown by the 402 mark. At this time, the current traversal node is the 1st node, specifically d. The left child node after the exchange is the 3rd node, specifically b. At this time, the resource consumption of the 1st node (10) is less than that of the 4th node (21), so the 1st node and the 4th node are exchanged. The tree to be sorted after the exchange can be as shown by the 403 mark. At this time, the current traversal node is the 1st node, specifically e, and the right child node after the exchange is the 4th node, specifically d.
[0113] If the current traversal is the third traversal, the node of the third traversal (i.e., the current traversal node) is the 0th node (a). The left child node of the 0th node is the 1st node (e), and the right child node of the 0th node is the 2nd node (f). At this time, the resource consumption of the 0th node (3) is less than that of the 1st node (21), so the 0th node and the 1st node are exchanged. The tree to be sorted after the exchange can be as shown by the 404 mark. At this time, the current traversal node is the 0th node, specifically e, and the left child node after the exchange is the 1st node, specifically a. At this time, the resource consumption of the left child node after the exchange (i.e., the 1st node) (3) is less than that of the child node of the corresponding left child node (the 3rd node) (7), so it is necessary to adjust the nodes of the subtree corresponding to the left child node, that is, it is necessary to exchange the 1st node and the 3rd node. The tree to be sorted after the exchange can be as shown by the 405 mark. At this time, the 1st node is b and the 3rd node is a. Since the resource consumption of the 1st node (7) is less than that of the 4th node (10) at this time, it is necessary to exchange the 1st node and the 4th node. The tree to be sorted after the exchange can be as shown by the 406 mark. At this time, the 1st node is d and the 4th node is b.
[0114] Since the resource consumption amount (21) of the currently traversed node (the 0th node) is less than the resource consumption amount (23) of the right child node (the 2nd node) of the currently traversed node, the 0th node and the 2nd node are exchanged. The sorted tree to be sorted after the exchange can be as shown by the 407 mark. At this time, the currently traversed node is the 0th node, specifically f, and the right child node after the exchange is the 2nd node, specifically e. Since the resource consumption amount (21) of the right child node after the exchange (i.e., the 2nd node) is not less than the resource consumption amount (16) of the child node (the 5th node) of the corresponding right child node, there is no need to adjust the nodes of the subtree corresponding to the right child node. Thus, the traversal ends and the first intermediate tree is obtained through adjustment. The first intermediate tree can be as shown by the 407 mark.
[0115] After the blockchain node adjusts each node in the sorted tree to be sorted and obtains the first intermediate tree, the last node in the first intermediate tree can be exchanged with the root node to obtain the second intermediate tree. The second intermediate tree is adjusted to obtain the target sorted tree, and the to-be-packaged sequence corresponding to the nth transaction pool shard is obtained according to each transaction data recorded in the target sorted tree. Taking Figure 4b the first intermediate tree shown by the 407 mark as an example, please refer to Figure 4c , which is a schematic diagram of constructing the second intermediate tree provided by the embodiment of the present application; the last node (the 5th node c) in the first intermediate tree is exchanged with the root node (the 0th node f) to obtain the second intermediate tree. The second intermediate tree can be as shown by 411. At this time, the 5th node is f and the 0th node is c.
[0116] In the process of a blockchain node adjusting the second intermediate tree to obtain a target sorted tree, the subtree of the second intermediate tree except the last node can be used as the to-be-sorted tree after update; according to the resource consumption of each node in the to-be-sorted tree after update, each node in the to-be-sorted tree after update is adjusted to obtain the first intermediate tree after update; the last node in the first intermediate tree after update is exchanged with the root node to obtain the second intermediate tree after update; the blockchain node can use the subtree of the second intermediate tree after update except the last node as the to-be-sorted tree after update, and iteratively execute the above process until the termination condition is reached, and the binary tree composed of each node when the termination condition is reached is used as the target sorted tree; where the termination condition is that the second intermediate tree after update only contains two nodes. Among them, the related process of constructing the second intermediate tree after update based on the to-be-sorted tree after update is similar to the related process of constructing the second intermediate tree based on the to-be-sorted tree above, and will not be elaborated here. Based on the above description, among the nodes in the target sorted tree, from the root node to the tail node (the last node), it satisfies the characteristic of ascending resource consumption. When obtaining the to-be-packed sequence corresponding to the nth transaction pool shard according to the transaction data recorded in the target sorted tree, the target sorted tree can be used as the to-be-packed sequence corresponding to the nth transaction pool shard; the corresponding target selection strategy can be used to indicate that according to the descending order of resource consumption, transaction data is selected from the tail of any to-be-packed sequence. When selecting transaction data from the nth to-be-packed sequence, transaction data can be selected from the tail node of the target sorted tree (corresponding to the nth to-be-packed sequence).
[0117] Taking Figure 4c the second intermediate tree marked as 411 in the figure as an example, please refer to Figure 4d , which is a schematic diagram of constructing a target sorted tree provided by an embodiment of the present application; among them, the to-be-sorted tree after the first update can be as marked by 421; the first intermediate tree after the first update can be as marked by 422, the second intermediate tree after the first update can be as marked by 423, the first intermediate tree after the second update can be as marked by 424, the second intermediate tree after the second update can be as marked by 425, the first intermediate tree after the third update can be as marked by 426, the second intermediate tree after the third update can be as marked by 427, the first intermediate tree after the fourth update can be as marked by 428, the second intermediate tree after the fourth update can be as marked by 429, and the second intermediate tree marked by 429 is the constructed target sorted tree.
[0118] In another feasible implementation manner, when the blockchain node constructs the to-be-sorted tree according to the transaction data corresponding to the nth transaction pool shard among the N transaction pool shards and the un-packaged transaction data in the nth transaction pool shard, it can also be implemented through the following process: taking the transaction data corresponding to the nth transaction pool shard as nodes in ascending order of random order or transaction reception order, and adding them after the last node of the binary tree formed by the un-packaged transaction data in the nth transaction pool shard to obtain the to-be-sorted tree. Among them, the un-packaged transaction data in the nth transaction pool shard is the un-packaged transaction data in the remaining to-be-packed sequence of the history of the nth transaction pool shard. Based on this, among the nodes of the binary tree formed by the un-packaged transaction data in the nth transaction pool shard, the characteristic that the resource consumption amount increases in ascending order is satisfied from the root node to the tail node. Taking Figure 4a the transaction data in the to-be-sorted tree shown as an example, please refer to Figure 4e , which is another schematic diagram of constructing a to-be-sorted tree provided by an embodiment of the present application. Among them, the binary tree formed by the un-packaged transaction data in the nth transaction pool shard can be as shown by the label 431, the transaction data corresponding to the nth transaction pool shard can be as shown by the label 432, the to-be-sorted tree can be as shown by the label 433, and the transaction data corresponding to the nth transaction pool shard is added to the binary tree shown by the label 431 in ascending order of transaction reception order.
[0119] In the case where the target storage policy is the first storage policy, the data structure of any to-be-packed sequence is a binary tree. Please refer to Figure 4f , which is a schematic diagram of a transaction pool shard provided by an embodiment of the present application. Among them, the data structure of the to-be-packed sequence stored in any transaction pool shard is a binary tree.
[0120] In a feasible implementation, when the target storage policy is the second storage policy, the data structure of any sequence to be packaged is a linked list; when the blockchain node stores the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard according to the target storage policy to obtain the sequence to be packaged corresponding to each transaction pool shard, the following steps may be executed: determining a transaction linked list composed of the un-packaged transaction data in the nth transaction pool shard, where n ∈ [1, N]; traversing the transaction data corresponding to the nth transaction pool shard; for the target transaction data currently traversed, starting from the last transaction data in the transaction linked list and moving towards the first transaction data in the transaction linked list, sequentially comparing the transaction creation time between the target transaction data and the transaction data in the transaction linked list until a reference transaction data whose transaction creation time is earlier than that of the target transaction data is determined from the transaction linked list, and adding the target transaction data as the transaction data after the reference transaction data in the transaction linked list; if it fails to determine the reference transaction data, adding the target transaction data as the transaction data before the first transaction data in the transaction linked list; according to the transaction data recorded in the transaction linked list obtained after the traversal is completed, obtaining the sequence to be packaged corresponding to the nth transaction pool shard. Among them, when the target storage policy is the second storage policy, the order of the transaction data in any sequence to be packaged is in ascending order of the transaction creation time, and the corresponding target selection policy is used to indicate that according to the ascending order of the transaction creation time, transaction data is selected starting from the head of any sequence to be packaged; based on this, it can be known that the un-packaged transaction data in the nth transaction pool shard is the un-packaged transaction data in the remaining sequence to be packaged in the history of the nth transaction pool shard, and the transaction data in the transaction linked list composed of the un-packaged transaction data in the nth transaction pool shard satisfies the characteristic of ascending order of the transaction creation time from the first transaction data to the last transaction data.
[0121] For example, if there are 3 un-packaged transaction data in the nth transaction pool shard, and when the 3 un-packaged transaction data are arranged in ascending order of the transaction reception order, they are: transaction data a (abbreviated as a), transaction data b (abbreviated as b), transaction data c (abbreviated as c), and when the transaction data corresponding to the nth transaction pool shard are arranged in ascending order of the reception order, they are: transaction data d (abbreviated as d), transaction data e (abbreviated as e), transaction data f (abbreviated as f). Assume that the transaction creation times of each of the 6 transaction data are: 3, 7, 16, 10, 21, 23. Refer to Figure 5a , which is a schematic diagram for constructing a sequence to be packaged provided by an embodiment of the present application; among them, the transaction linked list composed of the un-packaged transaction data in the nth transaction pool shard may be as marked by 501. At this time, the transaction linked list includes 3 transaction data, and the first transaction data to the last transaction data (i.e., the third transaction data) are respectively: a, b, c.
[0122] The blockchain node can traverse the transaction data corresponding to the nth transaction pool shard, that is, traverse d, e, and f. If the current traversal is the first traversal, the target transaction data for the first traversal is d, and the transaction creation time of d is 10; the blockchain node can start from the last transaction data in the transaction linked list and compare the transaction creation time between the target transaction data and the transaction data in the transaction linked list in turn in the direction of the first transaction data in the transaction linked list until a reference transaction data with an earlier transaction creation time than the target transaction data is determined from the transaction linked list; based on this, it can be known that the transaction creation time (16) of the last transaction data (c) in the transaction linked list is not earlier than the transaction creation time (10) of the target transaction data (d), so continue to compare the transaction creation time of d and b forward; the transaction creation time (7) of b is earlier than the transaction creation time (10) of d, so b is determined as the reference transaction data, and the target transaction data (d) is added to the transaction linked list as the transaction data after the reference transaction data (b) in the transaction linked list. At this time, the obtained transaction linked list can be as shown by the 502 label. Referring to the above process, the transaction linked list obtained after adding the transaction data e to the transaction linked list shown by the 502 label can be as shown by the 503 label, and the transaction linked list obtained after adding the transaction data f to the transaction linked list shown by the 503 label can be as shown by the 504 label. The transaction linked list shown by the 504 label is the transaction linked list obtained after the traversal ends.
[0123] Based on the above description, it can be known that in the transaction linked list obtained after traversal, from the first transaction data to the last transaction data, it satisfies the characteristic of ascending order of transaction creation time. When obtaining the to-be-packed sequence corresponding to the nth transaction pool shard according to each transaction data recorded in the transaction linked list obtained after traversal, the transaction linked list obtained after traversal can be used as the to-be-packed sequence corresponding to the nth transaction pool shard; the corresponding target selection strategy can be used to indicate that according to the ascending order of transaction creation time, transaction data is selected starting from the head of any to-be-packed sequence. When selecting transaction data from the nth to-be-packed sequence, transaction data can be selected starting from the first transaction data of the transaction linked list obtained after traversal (corresponding to the nth to-be-packed sequence). In another feasible implementation manner, when the target storage strategy is the second storage strategy, the order of transaction data in any to-be-packed sequence can also be in descending order of transaction creation time. At this time, in the transaction linked list obtained after traversal corresponding to any to-be-packed sequence, from the first transaction data to the last transaction data, it satisfies the characteristic of descending order of transaction creation time; the corresponding target selection strategy can be used to indicate that according to the ascending order of transaction creation time, transaction data is selected starting from the tail of any to-be-packed sequence, that is, starting from the last transaction data of the transaction linked list obtained after traversal; the relevant implementation process in this case can refer to the above, when the target storage strategy is the second storage strategy, the order of transaction data in any to-be-packed sequence is in ascending order of transaction creation time, and the corresponding target selection strategy is used to indicate that according to the ascending order of transaction creation time, transaction data is selected starting from the head of any to-be-packed sequence. The embodiments of the present application will not be elaborated herein.
[0124] When the target storage strategy is the second storage strategy, the data structure of any to-be-packed sequence is a linked list. Please refer to Figure 5b , which is another schematic diagram of a transaction pool shard provided by the embodiments of the present application. Among them, the data structure of the to-be-packed sequence stored in any transaction pool shard is a linked list.
[0125] In a feasible implementation manner, when the target storage strategy is the third storage strategy, the data structure of any to-be-packed sequence is a queue; when the blockchain node stores the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard according to the target storage strategy to obtain the to-be-packed sequence corresponding to each transaction pool shard, the following steps can be executed: determining a transaction queue composed of the un-packed transaction data in the nth transaction pool shard, where n ∈ [1, N]; based on the ascending order of transaction reception order, adding each transaction data corresponding to the nth transaction pool shard to the transaction queue in sequence; obtaining the to-be-packed sequence corresponding to the nth transaction pool shard according to each transaction data recorded in the transaction queue after the addition is completed.
[0126] Among them, when the target storage policy is the third storage policy, the order of transaction data in any to-be-packed sequence is in ascending order of the transaction reception order. The corresponding target selection policy is used to indicate that, according to the ascending order of the transaction reception order, transaction data is selected starting from the head of any to-be-packed sequence. Based on this, it can be known that the un-packed transaction data in the nth transaction pool shard is the un-packed transaction data in the remaining to-be-packed sequence in the history of the nth transaction pool shard. Each transaction data in the transaction queue composed of the un-packed transaction data in the nth transaction pool shard satisfies the characteristic of ascending order of the transaction reception order from the first transaction data (i.e., the transaction data at the head of the queue) to the last transaction data (i.e., the transaction data at the tail of the queue).
[0127] For example, if there are 3 un-packed transaction data in the nth transaction pool shard, when the 3 un-packed transaction data are arranged in ascending order of the transaction reception order, they are respectively: transaction data a (abbreviated as a), transaction data b (abbreviated as b), and transaction data c (abbreviated as c). When the transaction data corresponding to the nth transaction pool shard are arranged in ascending order of the reception order, they are respectively: transaction data d (abbreviated as d), transaction data e (abbreviated as e), and transaction data f (abbreviated as f). Refer to Figure 6a , which is another schematic diagram for constructing a to-be-packed sequence provided by an embodiment of the present application; among them, the transaction queue composed of the un-packed transaction data in the nth transaction pool shard can be indicated as shown by the label 601; the blockchain node can, according to the ascending order of the transaction reception order, sequentially add each transaction data corresponding to the nth transaction pool shard to the transaction queue. Among them, the transaction queue obtained after adding the transaction data d to the transaction queue shown by the label 601 can be indicated as shown by the label 602, the transaction queue obtained after adding the transaction data e to the transaction queue shown by the label 602 can be indicated as shown by the label 603, the transaction queue obtained after adding the transaction data f to the transaction queue shown by the label 603 can be indicated as shown by the label 604, and the transaction queue shown by the label 604 is the transaction queue after the addition is completed.
[0128] Based on the above description, it can be known that in the transaction queue after the addition is completed, the transaction data from the head of the queue to the tail of the queue satisfies the characteristic of ascending order of the transaction reception order. When obtaining the to-be-packed sequence corresponding to the nth transaction pool shard according to each transaction data recorded in the transaction queue after the addition is completed, the transaction queue after the addition is completed can be used as the to-be-packed sequence corresponding to the nth transaction pool shard; the corresponding target selection policy is used to indicate that, according to the ascending order of the transaction reception order, transaction data is selected starting from the head of any to-be-packed sequence. When selecting transaction data from the nth to-be-packed sequence, transaction data can be selected starting from the transaction data at the head of the transaction queue after the addition is completed (corresponding to the nth to-be-packed sequence).
[0129] When the target storage policy is the third storage policy, the data structure of any sequence to be packaged is a queue. Please refer to Figure 6b , which is another schematic diagram of the sharding of the transaction pool provided by the embodiments of the present application. Among them, the data structure of the sequence to be packaged stored in any shard of the transaction pool is a queue.
[0130] S304. When a block needs to be constructed, obtain the target quantity of the transaction data to be selected.
[0131] Among them, the target quantity can be configured according to specific requirements. For example, the target quantity can be configured as 10, 50, 100, etc., and the embodiments of the present application do not make limitations.
[0132] S305. When the total quantity of the transaction data included in the N sequences to be packaged is less than or equal to the target quantity, select all the transaction data from each sequence to be packaged.
[0133] S306. When the total quantity of the transaction data included in the N sequences to be packaged is greater than the target quantity, determine the selection quantity corresponding to each sequence to be packaged; according to the selection order indicated by the target selection policy, select the corresponding selection quantity of transaction data from each sequence to be packaged.
[0134] Among them, the sum of the selection quantities corresponding to each sequence to be packaged is less than or equal to the target quantity, and the selection quantity corresponding to any sequence to be packaged should be less than or equal to the quantity of the transaction data included in the corresponding sequence to be packaged.
[0135] In a feasible implementation, the blockchain node can randomly determine the selection quantity corresponding to each sequence to be packaged. In another feasible implementation, the blockchain node can first determine the average quantity of the target quantity relative to the quantity N of the sequences to be packaged. For any sequence to be packaged, when the quantity of the transaction data included in the sequence to be packaged is greater than or equal to the average quantity, the average quantity is used as the selection quantity corresponding to the sequence to be packaged; otherwise, the quantity of the transaction data included in the sequence to be packaged is used as the selection quantity corresponding to the sequence to be packaged. In another feasible implementation, the blockchain node can first determine the average quantity of the target quantity relative to the quantity N of the sequences to be packaged, determine M sequences to be packaged (M is a non-negative integer) with the quantity of the transaction data included less than the average quantity from the N sequences to be packaged, use the quantity of the transaction data included in each of the M sequences to be packaged as the selection quantity corresponding to the corresponding sequence to be packaged, and determine the first difference quantity between the quantity of the transaction data included in each of the M sequences to be packaged and the average quantity, and count each first difference quantity to obtain the total first difference quantity; determine the second difference quantity between the target quantity and the sum of the N average quantities, and determine the sum of the total first difference quantity and the second difference quantity to obtain the total difference quantity; sequentially allocate the total difference quantity to the N - M sequences to be packaged until the total difference quantity is allocated completely, and based on the quantity allocated to each of the N - M sequences to be packaged and the average quantity corresponding to each of the N - M sequences to be packaged, determine the selection quantity corresponding to each of the N - M sequences to be packaged, where one selection quantity is the sum of the average quantity and the corresponding allocated quantity.
[0136] S307. Use the selected transaction data to perform block construction processing.
[0137] In a feasible implementation, when the blockchain node uses the selected transaction data to perform block construction processing, it can execute the transactions indicated by each of the selected transaction data to obtain the transaction execution results, and construct a block (referred to as the target block for ease of description) based on each of the selected transaction data and the transaction execution results. In a feasible implementation, the N transaction pool shards of the blockchain node further include N packaged sequences, and the N transaction pool shards correspond to the N packaged sequences one by one. After the blockchain node selects transaction data from the nth sequence to be packaged according to the target selection strategy corresponding to the target storage strategy, it can move the selected transaction data from the nth sequence to be packaged to the nth packaged sequence, which can effectively prevent the situation of duplicate packaging of transaction data; the transaction pool shard including the packaged sequence can be as Figure 7a shown.
[0138] In a feasible implementation, the blockchain is maintained by a blockchain network. The blockchain network includes multiple consensus nodes (i.e., blockchain nodes). After a consensus node that performs block construction processing constructs a target block using the selected transaction data, it can broadcast the target block to all other consensus nodes. After each consensus node in the blockchain network obtains the target block, it can perform consensus processing on the target block based on the transaction data in the transaction pool of the corresponding consensus node. After reaching a consensus on the target block, it uploads the target block to the blockchain and removes the transaction data in the target block from the transaction pool.
[0139] In a feasible implementation, the manner in which a target consensus node in the blockchain network performs consensus processing on a target block based on the transaction data in the transaction pool of the target consensus node may include the following process. Herein, the target consensus node in the blockchain network may be any consensus node in the blockchain network. Specifically, the target consensus node may perform validity verification on the target block based on the transaction data in the transaction pool of the target consensus node. In the case where the target block is verified to be valid, it executes the transactions indicated by each piece of transaction data in the target block. In the case where the transaction execution result determined by the target consensus node is consistent with the transaction execution result carried by the target block, it is determined that the target consensus node reaches a consensus on the target block. Otherwise, it is determined that the target consensus node does not reach a consensus on the target block. Among them, after the target consensus node determines that the target consensus node reaches a consensus on the target block, it can vote on the target block. After the target consensus node determines that the target consensus node does not reach a consensus on the target block, it can vote against the target block or not vote on the target block. Each consensus node in the blockchain network can make a decision on the consensus situation of the blockchain network on the target block based on the voting situation of each consensus node on the target block. After reaching a consensus on the target block (in the blockchain network), it uploads the target block to the blockchain and removes the transaction data in the target block from the transaction pool.
[0140] In a feasible implementation, when validating the effectiveness of a target block based on the transaction data in the transaction pool of the target consensus node, the target consensus node can determine the transaction data in the target block that exists in the transaction pool and the transaction data in the target block that does not exist in the transaction pool based on the transaction data in the transaction pool of the target consensus node, and perform effectiveness verification processing on the transaction data in the target block that exists in the transaction pool and the transaction data in the target block that does not exist in the transaction pool respectively. When it is verified that each transaction data in the target block is effective, it is determined that the target block is effective; otherwise, it is determined that the target block is not effective. Among them, when performing effectiveness verification processing on the transaction data in the target block that exists in the transaction pool, the transaction data identical to the transaction data in the target block can be obtained from the transaction pool of the target consensus node. If the hash of the obtained transaction data is consistent with the hash of the transaction data in the target block that exists in the transaction pool, it is determined that the transaction data in the target block that exists in the transaction pool is effective. When performing effectiveness verification processing on the transaction data in the target block that does not exist in the transaction pool, effectiveness inspection can be performed on the corresponding transaction data. When it is determined that the corresponding transaction data passes the effectiveness inspection, it is determined that the corresponding transaction data is effective. Optionally, when performing effectiveness inspection on the transaction data, it can be implemented based on data such as the account address of the transaction data and the signature information of the transaction data.
[0141] Among them, when the target consensus node is the consensus node for block construction processing, since the target block is constructed by the target consensus node, the target consensus node can directly vote on the target block. When the target consensus node is other consensus nodes in the blockchain network, after verifying the effectiveness of the target block, the target consensus node can move the transaction data in the target block that exists in the transaction pool from the to-be-packaged sequence corresponding to the transaction data to the corresponding packaged sequence, which can effectively prevent the situation of duplicate packaging of transaction data.
[0142] In a feasible implementation, the consensus node that performs block construction processing in the blockchain network can be called the primary node. After constructing the target block using the selected transaction data, the primary node can broadcast the target block to other consensus nodes. At this time, the other consensus nodes that receive the target block broadcast by the primary node can be called secondary nodes. Among them, the primary node can package transactions to construct a block in one round of consensus and broadcast the block to other secondary nodes. Therefore, the primary node plays a key role in one round of consensus. If the primary node behaves maliciously, packages invalid transactions, or there are errors in the block structure, no consensus will be reached on any block in this round of consensus. After receiving the block proposed by the primary node, the secondary node can verify the validity of the target block and execute the transactions indicated by each piece of transaction data in the target block. When verifying that the target block is valid and the transaction execution result determined by the secondary node is consistent with the transaction execution result carried by the target block, the secondary node votes for the target block. When verifying that the target block is not valid or the transaction execution result determined by the secondary node is inconsistent with the transaction execution result carried by the target block, the secondary node votes against the target block or does not vote on the target block. Each consensus node in the blockchain network can make decisions on the consensus situation of the blockchain network for the target block based on the voting situation of each consensus node for the target block, and after reaching a consensus on the target block (in the blockchain network), upload the target block to the blockchain. Each consensus node in the blockchain network can deploy a consensus algorithm to implement the consensus-related process. Exemplary consensus algorithms can include, but are not limited to, the following: the Raft consensus algorithm of the fault tolerance type, the PBFT consensus algorithm of the Byzantine fault tolerance type, the Tendermint consensus algorithm, the HotStuff consensus algorithm, etc. Different consensus algorithms have different applicable scenarios.
[0143] In a feasible implementation, a transaction pool, a consensus engine module, and a core engine module can be deployed in blockchain nodes (consensus nodes) in a blockchain network. Among them, the transaction pool can be used to receive transaction data, perform validity checks on the received transaction data, put the transaction data into a transaction data set when it is determined that the transaction data is valid (i.e., it passes the validity check), store the transaction data in the transaction data set into a to-be-packed sequence, select transaction data from the to-be-packed sequence when a block needs to be constructed so that the selected transaction data can be packed into a block. Among them, the transaction pool of a consensus node can be used to receive transaction data sent by other consensus nodes, and can also be used to receive transaction data sent by a terminal device, and broadcast the transaction data sent by the terminal device to other consensus nodes when it is determined that the transaction data sent by the terminal device is valid, which can ensure the consistency of transaction data among all consensus nodes in the blockchain network and facilitate quick verification based on the transaction data in the transaction pool when the validity of a block needs to be verified. Among them, the consensus engine module can include a consensus algorithm module and a peer-to-peer network module. The consensus algorithm module can include one or more consensus algorithms. The peer-to-peer network module can be used to implement point-to-point transmission between consensus nodes. The core engine module is the core scheduling module in the consensus node and can play a central scheduling role. The core engine module of the master node will, when a block needs to be constructed, request the transaction pool to return the transaction data to be packed, construct a block using the transaction data returned by the transaction pool, and send the constructed block to the consensus engine module. The consensus engine module constructs a proposal based on the block and broadcasts the proposal to other slave nodes. After receiving the proposal, the slave node can, through its core engine module, verify the validity of the block corresponding to the proposal and execute the transactions indicated by each transaction data in the block. When the block is verified to be valid and the transaction execution result determined by the slave node is consistent with the transaction execution result carried by the block, the slave node can vote for the block; otherwise, vote against the target block or not vote for the target block.
[0144] Please refer to Figure 7b, which is an interaction schematic diagram between consensus nodes provided by an embodiment of the present application; for any consensus node, the transaction pool of the consensus node can be used to receive transaction data sent by other consensus nodes or to receive transaction data sent by a terminal device. Optionally, the transaction data can be received based on the Remote Procedure Call Protocol (RPC); for the received transaction data, if it is determined that the received transaction data is valid, the transaction data can be placed in the transaction data set. For the transaction data from the terminal device, if it is determined that the corresponding transaction data is valid, the corresponding transaction data can also be broadcast to other consensus nodes. When the core engine module of the master node needs to construct a block, it requests the transaction pool to return the transaction data to be packaged; the transaction pool can select transaction data from the to-be-packaged sequence and return it; after receiving the transaction data returned by the transaction pool, the core engine module can construct a block using the transaction data returned by the transaction pool and notify the transaction pool to move the returned transaction data from the to-be-packaged sequence to the already-packaged sequence; then the core engine module sends the constructed block to the slave node via the consensus engine module. The core engine module of the slave node can load (obtain) the transaction data identical to the transaction data in the block from the transaction pool of the slave node and perform a validity verification on the target block based on the loaded transaction data. After verifying that the block is valid, it can notify the transaction pool to move the transaction data in the block that exists in the transaction pool from the to-be-packaged sequence corresponding to the transaction data to the corresponding already-packaged sequence. After the master node and the slave node complete consensus and upload the block to the blockchain (i.e., submit the block), they can remove the transaction data in the submitted block from the transaction pool. Optionally, if the master node and the slave node receive multiple verified valid blocks at the same height, when a certain block is chained, the node will prune other blocks at the same height, and the transaction data in the pruned block will be re-added to the transaction pool. At this time, the transaction pool will perform a validity check on these transaction data. If it is determined that the transaction data is valid, the transaction data will be added to the transaction data set so that it can be added to the to-be-packaged sequence subsequently.
[0145] In the embodiments of the present application, a variety of storage strategies for transaction data and selection strategies corresponding to each storage strategy are provided. When different storage strategies are adopted, transaction data can be stored in a transaction pool based on different transaction attributes, and the transaction data stored in the transaction pool can be sorted according to the transaction attributes. In the case of constructing a block, the selection strategy corresponding to the storage strategy used can be adopted, and transaction data can be selected from the transaction pool for block construction processing according to the selection order indicated by the corresponding selection strategy, enriching the storage method of transaction data in the transaction pool and the method of extracting (selecting) transaction data from the transaction pool in the case of constructing a block. Moreover, the embodiments of the present application propose that the transaction pool can be divided into at least one transaction pool shard. In the case where the transaction pool is divided into multiple transaction pool shards, concurrent operations on transaction data can be implemented based on multiple transaction pool shards (for example, concurrent storage or concurrent selection of transaction data based on multiple transaction pool shards), which can improve the processing efficiency of transaction data related to the transaction pool. And, in the case where the transaction pool is divided into multiple transaction pool shards, compared with sorting the transaction data in the transaction data set in the transaction pool to obtain a sequence to be packaged, when the transaction data in the transaction data set is stored in multiple transaction pool shards and sorted to obtain multiple sequences to be packaged, the size of the sequence to be packaged can be reduced, and the processing efficiency during sorting can be improved. In summary, by dividing the transaction pool into multiple transaction pool shards, the processing efficiency and performance of operations related to the transaction pool can be improved.
[0146] Based on the description of the above method embodiments, the embodiments of the present application also disclose a blockchain-based data processing device; the blockchain-based data processing device can be a computer program running on a computer device, and the computer device can be the above-mentioned blockchain node (i.e., the consensus node), and the blockchain-based data processing device can execute Figure 2 or Figure 3 each step in the method flow shown. Please refer to Figure 8 , which is a schematic structural diagram of a blockchain-based data processing device provided by the embodiments of the present application. The blockchain-based data processing device can include a communication unit 801 and a processing unit 802, where:
[0147] The communication unit 801 is used for communication interaction;
[0148] A processing unit 802 is configured to obtain a set of transaction data; the set of transaction data includes at least one transaction data; determine a transaction pool shard corresponding to each transaction data from N transaction pool shards; wherein, the N transaction pool shards are obtained by partitioning a transaction pool, and N is a positive integer; store the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard according to a target storage policy, to obtain a to-be-packaged sequence corresponding to each transaction pool shard; wherein, the target storage policy is determined from multiple storage policies, each transaction data has multiple transaction attributes, and different storage policies refer to different transaction attributes when storing transaction data; in the case of needing to construct a block, select transaction data from the N to-be-packaged sequences according to a target selection policy corresponding to the target storage policy, and perform block construction processing using the selected transaction data.
[0149] In one implementation, the multiple storage policies include at least two of: a first storage policy, a second storage policy, and a third storage policy;
[0150] The transaction attribute referred to by the first storage policy is: the amount of consumption resources required for on-chain transaction data. In the case where the target storage policy is the first storage policy, the order of transaction data in any to-be-packaged sequence is in ascending order of the consumption resources amount, and the corresponding target selection policy is used to indicate that according to the descending order of the consumption resources amount, select transaction data starting from the tail of any to-be-packaged sequence;
[0151] The transaction attribute referred to by the second storage policy is: the transaction creation time of the transaction data. In the case where the target storage policy is the second storage policy, the order of transaction data in any to-be-packaged sequence is in ascending order of the transaction creation time, and the corresponding target selection policy is used to indicate that according to the ascending order of the transaction creation time, select transaction data starting from the head of any to-be-packaged sequence;
[0152] The transaction attribute referred to by the third storage policy is: the transaction reception order of the transaction data. In the case where the target storage policy is the third storage policy, the order of transaction data in any to-be-packaged sequence is in ascending order of the transaction reception order, and the corresponding target selection policy is used to indicate that according to the ascending order of the transaction reception order, select transaction data starting from the head of any to-be-packaged sequence.
[0153] In one implementation, when the processing unit 802 is used to select transaction data from the N to-be-packaged sequences according to the target selection policy corresponding to the target storage policy, it may specifically be used to:
[0154] Obtain the target quantity of the transaction data to be selected;
[0155] When the total number of transaction data included in the N sequences to be packed is less than or equal to the target number, all the transaction data is selected from each sequence to be packed;
[0156] When the total number of transaction data included in the N sequences to be packed is greater than the target number, the selection quantity corresponding to each sequence to be packed is determined; the sum of the selection quantities corresponding to each sequence to be packed is less than or equal to the target number;
[0157] According to the selection order indicated by the target selection strategy, the corresponding selection quantity of transaction data is selected from each sequence to be packed.
[0158] In one implementation, the target storage strategy is the first storage strategy, and the data structure of any sequence to be packed is a binary tree. When the processing unit 802 is used to store the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard according to the target storage strategy to obtain the sequence to be packed corresponding to each transaction pool shard, it can be specifically used for:
[0159] Construct a to-be-sorted tree according to the transaction data corresponding to the nth transaction pool shard among the N transaction pool shards and the transaction data not packed in the nth transaction pool shard; the to-be-sorted tree is a binary tree, and the nodes in the to-be-sorted tree are transaction data, where n ∈ [1, N];
[0160] According to the resource consumption amount of each node in the to-be-sorted tree, adjust and process each node in the to-be-sorted tree to obtain a first intermediate tree; the first intermediate tree is a max heap, and the resource consumption amount of any node in the max heap is greater than or equal to the resource consumption amount of the corresponding node's child node;
[0161] Exchange the last node in the first intermediate tree with the root node to obtain a second intermediate tree;
[0162] Adjust the second intermediate tree to obtain a target sorted tree, and obtain the sequence to be packed corresponding to the nth transaction pool shard according to the transaction data recorded in the target sorted tree.
[0163] In one implementation, when the processing unit 802 is used to adjust and process each node in the to-be-sorted tree according to the resource consumption amount of each node in the to-be-sorted tree to obtain a first intermediate tree, it can be specifically used for:
[0164] Start from the last non-leaf node in the to-be-sorted tree and traverse each non-leaf node in the to-be-sorted tree layer by layer in the direction towards the root node;
[0165] For the currently traversed node, if the resource consumption of the currently traversed node is less than the resource consumption of the left child node of the currently traversed node, then swap the currently traversed node with the corresponding left child node, and when the resource consumption of the swapped left child node is less than that of the child node of the corresponding left child node, adjust the nodes of the subtree corresponding to the corresponding left child node;
[0166] If the resource consumption of the currently traversed node is less than the resource consumption of the right child node of the currently traversed node, then swap the currently traversed node with the corresponding right child node, and when the resource consumption of the swapped right child node is less than that of the child node of the corresponding right child node, adjust the nodes of the subtree corresponding to the corresponding right child node;
[0167] Until the traversal ends and the first intermediate tree is obtained through adjustment.
[0168] In one implementation, when the processing unit 802 is used to construct the tree to be sorted according to the transaction data corresponding to the nth transaction pool slice among the N transaction pool slices and the un-packaged transaction data in the nth transaction pool slice, it may specifically be used for:
[0169] Construct the tree to be sorted from the transaction data corresponding to the nth transaction pool slice and the un-packaged transaction data in the nth transaction pool slice in a random order;
[0170] Or, construct the tree to be sorted from the transaction data corresponding to the nth transaction pool slice and the un-packaged transaction data in the nth transaction pool slice in ascending order of the transaction reception order;
[0171] Or, take the transaction data corresponding to the nth transaction pool slice as a node and add it after the last node of the binary tree formed by the un-packaged transaction data in the nth transaction pool slice in a random order or in ascending order of the transaction reception order to obtain the tree to be sorted.
[0172] In one implementation, the target storage policy is the second storage policy, the data structure of any sequence to be packaged is a linked list, and when the processing unit 802 is used to store the transaction data corresponding to each transaction pool slice into the corresponding transaction pool slice according to the target storage policy to obtain the sequence to be packaged corresponding to each transaction pool slice, it may specifically be used for:
[0173] Determine the transaction linked list formed by the un-packaged transaction data in the nth transaction pool slice, where n ∈ [1, N];
[0174] Traverse the transaction data corresponding to the nth transaction pool slice;
[0175] For the target transaction data being currently traversed, starting from the last transaction data in the transaction linked list and moving towards the first transaction data in the transaction linked list, compare the transaction creation times between the target transaction data and the transaction data in the transaction linked list in sequence until a reference transaction data with a transaction creation time earlier than the target transaction data is determined from the transaction linked list, and add the target transaction data to the transaction linked list as the transaction data after the reference transaction data in the transaction linked list;
[0176] If the determination of the reference transaction data fails, add the target transaction data to the transaction linked list as the transaction data before the first transaction data in the transaction linked list;
[0177] According to the various transaction data recorded in the transaction linked list obtained after the traversal, obtain the to-be-packaged sequence corresponding to the nth transaction pool shard.
[0178] In one implementation manner, the target storage policy is the third storage policy, and the data structure of any to-be-packaged sequence is a queue. When the processing unit 802 is used to store the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard according to the target storage policy to obtain the to-be-packaged sequence corresponding to each transaction pool shard, it can specifically be used for:
[0179] Determine a transaction queue composed of the un-packaged transaction data in the nth transaction pool shard, where n ∈ [1, N];
[0180] Based on the ascending order of the transaction reception order, add the various transaction data corresponding to the nth transaction pool shard to the transaction queue in sequence;
[0181] According to the various transaction data recorded in the transaction queue after the addition is completed, obtain the to-be-packaged sequence corresponding to the nth transaction pool shard.
[0182] In one implementation manner, the blockchain is maintained by a blockchain network, and the blockchain network includes multiple consensus nodes. After a consensus node performing block construction processing constructs a target block using the selected transaction data, it broadcasts the target block to other consensus nodes; after each consensus node in the blockchain network obtains the target block, it performs consensus processing on the target block based on the transaction data in the transaction pool of the corresponding consensus node, and after reaching a consensus on the target block, uploads the target block to the blockchain and removes the transaction data in the target block from the transaction pool.
[0183] In one implementation manner, the manner in which a target consensus node in the blockchain network performs consensus processing on the target block based on the transaction data in the transaction pool of the target consensus node includes:
[0184] Verify the validity of the target block based on the transaction data in the transaction pool of the target consensus node;
[0185] When it is verified that the target block is valid, execute the transactions indicated by each piece of transaction data in the target block;
[0186] When the transaction execution result determined by the target consensus node is consistent with the transaction execution result carried by the target block, determine that the target consensus node reaches a consensus on the target block;
[0187] Otherwise, determine that the target consensus node does not reach a consensus on the target block.
[0188] According to another embodiment of the present application, Figure 8 Each unit in the blockchain-based data processing device shown can be separately or all combined into one or several other units to form, or a certain (some) unit can be further split into multiple smaller units in terms of function to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above units are divided based on logical functions. In practical applications, the function of one unit can also be realized by multiple units, or the functions of multiple units are realized by one unit. In other embodiments of the present application, the blockchain-based data processing device can also include other units. In practical applications, these functions can also be assisted by other units and can be realized by the cooperation of multiple units.
[0189] According to another embodiment of the present application, it can be achieved by running a computer program capable of executing the steps involved in the corresponding method shown in Figure 2 or Figure 3 on a general computing device such as a computer including processing elements and storage elements such as a central processing unit (CPU), a random access storage medium (RAM), and a read-only storage medium (ROM), to construct the blockchain-based data processing device shown in Figure 8 and to implement the blockchain-based data processing method of the embodiments of the present application. The computer program can be recorded on, for example, a computer-readable storage medium, loaded into the above computing device through the computer-readable storage medium, and run therein.
[0190] In the embodiments of the present application, the term "module" or "unit" refers to a computer program with a predetermined function or a part of a computer program, which works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of an overall module or unit that includes the function of the module or unit.
[0191] In the embodiments of the present application, multiple storage strategies for transaction data and corresponding selection strategies for each storage strategy are provided. When different storage strategies are adopted, transaction data can be stored in a transaction pool based on different transaction attributes. In the case of constructing a block, the corresponding selection strategy of the storage strategy used can be adopted to select transaction data from the transaction pool for block construction processing, enriching the storage method of transaction data in the transaction pool and the method of extracting (selecting) transaction data from the transaction pool in the case of constructing a block; moreover, in the embodiments of the present application, it is proposed that the transaction pool can be divided into at least one transaction pool shard. In the case where the transaction pool is divided into multiple transaction pool shards, concurrent operations on transaction data can be implemented based on multiple transaction pool shards (for example, concurrent storage or concurrent selection of transaction data based on multiple transaction pool shards), which can improve the processing efficiency of transaction data related to the transaction pool.
[0192] Based on the descriptions of the above method embodiments and apparatus embodiments, the embodiments of the present application further provide a computer device, which can be the above-mentioned blockchain node (i.e., a consensus node). Please refer to Figure 9 , this computer device at least includes a processor 901, an input interface 902, an output interface 903, and a computer-readable storage medium 904. Among them, the processor 901, the input interface 902, the output interface 903, and the computer-readable storage medium 904 in the computer device can be connected through a bus or other means. The computer-readable storage medium 904 can be stored in the memory of the computer device. The computer-readable storage medium 904 is used to store a computer program, and the processor 901 is used to execute the computer program stored in the computer-readable storage medium 904. The processor 901 (or CPU (Central Processing Unit, central processor)) is the computing core and control core of the computer device, and is suitable for running the computer program to implement the corresponding method flow or corresponding function.
[0193] In one embodiment, the processor 901 proposed in the embodiments of the present application can be used to execute relevant processes for transaction data access and block construction, specifically including: obtaining a set of transaction data; the set of transaction data includes at least one transaction data; determining, from N transaction pool shards, the transaction pool shard corresponding to each transaction data; wherein, the N transaction pool shards are obtained by partitioning a transaction pool, and N is a positive integer; storing the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard according to a target storage policy, to obtain a to-be-packaged sequence corresponding to each transaction pool shard; wherein, the target storage policy is determined from multiple storage policies, each transaction data has multiple transaction attributes, and different storage policies refer to different transaction attributes when storing transaction data; in the case of needing to construct a block, selecting transaction data from the N to-be-packaged sequences according to a target selection policy corresponding to the target storage policy, and performing block construction processing using the selected transaction data, and so on.
[0194] The embodiments of the present application also provide a computer-readable storage medium (Memory). A computer-readable storage medium is a memory device in a computer device, used to store computer programs and data. It can be understood that the computer-readable storage medium here can include both the built-in storage medium in the computer device, and of course can also include the extended storage medium supported by the computer device. The computer-readable storage medium provides a storage space, and this storage space stores the operating system of the computer device. And, a computer program is also stored in this storage space, and this computer program is suitable for being loaded and executed by the processor 901 to implement the corresponding method flow provided by the embodiments of the present application. It should be noted that the computer-readable storage medium here can be a high-speed RAM memory, or a non-volatile memory, such as at least one disk memory; optionally, it can also be at least one computer-readable storage medium located far from the aforementioned processor.
[0195] In one embodiment, the computer program stored in the computer-readable storage medium can be loaded and executed by the processor to implement the corresponding steps in the method embodiments related to Figure 2 or Figure 3 shown above; in specific implementation, the computer program in the computer-readable storage medium can be loaded and executed by the processor to perform the following steps:
[0196] Obtain a set of transaction data; the set of transaction data includes at least one transaction data;
[0197] Determine, from N transaction pool shards, the transaction pool shard corresponding to each transaction data; wherein, the N transaction pool shards are obtained by partitioning a transaction pool, and N is a positive integer;
[0198] According to the target storage policy, store the transaction data corresponding to each shard of the transaction pool into the corresponding shard of the transaction pool to obtain the to-be-packaged sequence corresponding to each shard of the transaction pool; wherein, the target storage policy is determined from multiple storage policies, each transaction data has multiple transaction attributes, and different storage policies refer to different transaction attributes when storing transaction data;
[0199] When a block needs to be constructed, according to the target selection policy corresponding to the target storage policy, select transaction data from N to-be-packaged sequences, and use the selected transaction data to perform block construction processing.
[0200] In one implementation, the multiple storage policies include at least two of: a first storage policy, a second storage policy, and a third storage policy;
[0201] The transaction attribute referred to by the first storage policy is: the consumption resource amount required for the on-chain transaction data. When the target storage policy is the first storage policy, the order of the transaction data in any to-be-packaged sequence is the ascending order of the consumption resource amount, and the corresponding target selection policy is used to indicate to select transaction data from the tail of any to-be-packaged sequence according to the descending order of the consumption resource amount;
[0202] The transaction attribute referred to by the second storage policy is: the transaction creation time of the transaction data. When the target storage policy is the second storage policy, the order of the transaction data in any to-be-packaged sequence is the ascending order of the transaction creation time, and the corresponding target selection policy is used to indicate to select transaction data from the head of any to-be-packaged sequence according to the ascending order of the transaction creation time;
[0203] The transaction attribute referred to by the third storage policy is: the transaction reception order of the transaction data. When the target storage policy is the third storage policy, the order of the transaction data in any to-be-packaged sequence is the ascending order of the transaction reception order, and the corresponding target selection policy is used to indicate to select transaction data from the head of any to-be-packaged sequence according to the ascending order of the transaction reception order.
[0204] In one implementation, when the processor 901 is used to select transaction data from N to-be-packaged sequences according to the target selection policy corresponding to the target storage policy, it may specifically be used to:
[0205] Obtain the target quantity of the transaction data to be selected;
[0206] When the total quantity of the transaction data included in the N to-be-packaged sequences is less than or equal to the target quantity, select all the transaction data from each to-be-packaged sequence;
[0207] When the total number of transaction data included in N sequences to be packed is greater than the target number, determine the selection quantity corresponding to each sequence to be packed; the sum of the selection quantities corresponding to each sequence to be packed is less than or equal to the target number;
[0208] Select the corresponding quantity of transaction data from each sequence to be packed according to the selection order indicated by the target selection strategy.
[0209] In one implementation, the target storage strategy is the first storage strategy, and the data structure of any sequence to be packed is a binary tree. When the processor 901 is used to store the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard according to the target storage strategy to obtain the sequence to be packed corresponding to each transaction pool shard, it can be specifically used for:
[0210] Construct a tree to be sorted according to the transaction data corresponding to the nth transaction pool shard among the N transaction pool shards and the transaction data not packed in the nth transaction pool shard; the tree to be sorted is a binary tree, and the nodes in the tree to be sorted are transaction data, n ∈ [1, N];
[0211] Adjust each node in the tree to be sorted according to the resource consumption amount of each node in the tree to be sorted to obtain a first intermediate tree; the first intermediate tree is a max heap, and the resource consumption amount of any node in the max heap is greater than or equal to the resource consumption amount of the corresponding node's child node;
[0212] Exchange the last node in the first intermediate tree with the root node to obtain a second intermediate tree;
[0213] Adjust the second intermediate tree to obtain a target sorted tree, and obtain the sequence to be packed corresponding to the nth transaction pool shard according to the transaction data recorded in the target sorted tree.
[0214] In one implementation, when the processor 901 is used to adjust each node in the tree to be sorted according to the resource consumption amount of each node in the tree to be sorted to obtain a first intermediate tree, it can be specifically used for:
[0215] Start from the last non-leaf node in the tree to be sorted, and traverse each non-leaf node in the tree to be sorted layer by layer in the direction of the root node;
[0216] For the currently traversed node, if the resource consumption amount of the currently traversed node is less than the resource consumption amount of the left child node of the currently traversed node, then exchange the currently traversed node with the corresponding left child node, and adjust the nodes of the subtree corresponding to the left child node after the exchange in the case that the resource consumption amount of the left child node after the exchange is less than the child node of the corresponding left child node;
[0217] If the resource consumption of the currently traversed node is less than the resource consumption of the right child node of the currently traversed node, then swap the currently traversed node with the corresponding right child node, and when the resource consumption of the right child node after the swap is less than that of the child node of the corresponding right child node, adjust the nodes of the subtree corresponding to the corresponding right child node;
[0218] Until the traversal ends and the first intermediate tree is obtained through adjustment.
[0219] In one implementation, when the processor 901 is used to construct a tree to be sorted according to the transaction data corresponding to the nth transaction pool shard among the N transaction pool shards, and the un-packaged transaction data in the nth transaction pool shard, it can be specifically used for:
[0220] Construct the tree to be sorted with the transaction data corresponding to the nth transaction pool shard and the un-packaged transaction data in the nth transaction pool shard in a random order;
[0221] Or, construct the tree to be sorted with the transaction data corresponding to the nth transaction pool shard and the un-packaged transaction data in the nth transaction pool shard in ascending order of the transaction reception order;
[0222] Or, take the transaction data corresponding to the nth transaction pool shard as a node in a random order or in ascending order of the transaction reception order, and add it after the last node of the binary tree formed by the un-packaged transaction data in the nth transaction pool shard to obtain the tree to be sorted.
[0223] In one implementation, the target storage policy is the second storage policy, the data structure of any sequence to be packaged is a linked list, and when the processor 901 is used to store the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard according to the target storage policy to obtain the sequence to be packaged corresponding to each transaction pool shard, it can be specifically used for:
[0224] Determine a transaction linked list formed by the un-packaged transaction data in the nth transaction pool shard, where n ∈ [1, N];
[0225] Traverse the transaction data corresponding to the nth transaction pool shard;
[0226] For the target transaction data being currently traversed, starting from the last transaction data in the transaction linked list and moving towards the first transaction data in the transaction linked list, compare the transaction creation times between the target transaction data and the transaction data in the transaction linked list in sequence until a reference transaction data whose transaction creation time is earlier than that of the target transaction data is determined from the transaction linked list, and add the target transaction data to the transaction linked list as the transaction data after the reference transaction data;
[0227] If the determination of the reference transaction data fails, the target transaction data is added to the transaction linked list as the previous transaction data of the first transaction data in the transaction linked list;
[0228] According to each transaction data recorded in the transaction linked list obtained after traversal, the to-be-packaged sequence corresponding to the nth transaction pool shard is obtained.
[0229] In one implementation, the target storage policy is the third storage policy, and the data structure of any to-be-packaged sequence is a queue. When the processor 901 is used to store the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard according to the target storage policy to obtain the to-be-packaged sequence corresponding to each transaction pool shard, it can be specifically used for:
[0230] Determine a transaction queue composed of the un-packaged transaction data in the nth transaction pool shard, where n ∈ [1, N];
[0231] Based on the ascending order of the transaction reception order, add each transaction data corresponding to the nth transaction pool shard to the transaction queue in sequence;
[0232] According to each transaction data recorded in the transaction queue after the addition is completed, obtain the to-be-packaged sequence corresponding to the nth transaction pool shard.
[0233] In one implementation, the blockchain is maintained by a blockchain network. The blockchain network includes multiple consensus nodes. After the consensus node performing block construction processing constructs a target block using the selected transaction data, the target block is broadcast to other consensus nodes; after each consensus node in the blockchain network obtains the target block, based on the transaction data in the transaction pool of the corresponding consensus node, perform consensus processing on the target block, and after reaching a consensus on the target block, upload the target block to the blockchain and remove the transaction data in the target block from the transaction pool.
[0234] In one implementation, the method for a target consensus node in the blockchain network to perform consensus processing on the target block based on the transaction data in the transaction pool of the target consensus node includes:
[0235] Perform validity verification on the target block based on the transaction data in the transaction pool of the target consensus node;
[0236] In the case of verifying the validity of the target block, execute the transactions indicated by each transaction data in the target block;
[0237] In the case where the transaction execution result determined by the target consensus node is consistent with the transaction execution result carried by the target block, it is determined that the target consensus node reaches a consensus on the target block;
[0238] Otherwise, it is determined that the target consensus node does not reach a consensus on the target block.
[0239] In the embodiments of the present application, a variety of storage strategies for transaction data and selection strategies corresponding to each storage strategy are provided. When different storage strategies are adopted, transaction data can be stored in a transaction pool based on different transaction attributes. In the case of constructing a block, the selection strategy corresponding to the storage strategy used can be adopted to select transaction data from the transaction pool for block construction processing, enriching the storage method of transaction data in the transaction pool and the method of extracting (selecting) transaction data from the transaction pool in the case of constructing a block; moreover, the embodiments of the present application propose that the transaction pool can be divided into at least one transaction pool shard. In the case where the transaction pool is divided into multiple transaction pool shards, concurrent operations on transaction data can be implemented based on multiple transaction pool shards (for example, concurrent storage or concurrent selection of transaction data based on multiple transaction pool shards), which can improve the processing efficiency of transaction data related to the transaction pool.
[0240] The embodiments of the present application provide a computer program product. The computer program product includes a computer program, and the computer program is stored in a computer-readable storage medium; a processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above Figure 2 or Figure 3 shown method embodiments. It should be understood that the above-disclosed are only the preferred embodiments of the present application, and of course, the scope of rights of the present application cannot be limited thereby. Therefore, equivalent changes made according to the claims of the present application still fall within the scope covered by the present application.
Claims
1. A data processing method based on blockchain, characterized in that, Including: Obtaining a set of transaction data; the set of transaction data includes at least one transaction data; Determining the transaction pool shard corresponding to each transaction data from N transaction pool shards; wherein, the N transaction pool shards are obtained by partitioning a transaction pool, and N is a positive integer; According to a target storage strategy, storing the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard to obtain a to-be-packaged sequence corresponding to each transaction pool shard; wherein, the target storage strategy is determined from multiple storage strategies, each transaction data has multiple transaction attributes, and different storage strategies refer to different transaction attributes when storing transaction data; In the case where a block needs to be constructed, according to the target selection strategy corresponding to the target storage strategy, selecting transaction data from N to-be-packaged sequences, and using the selected transaction data to perform block construction processing.
2. The method according to claim 1, wherein The multiple storage strategies include at least two of: a first storage strategy, a second storage strategy, and a third storage strategy; The transaction attribute referred to by the first storage strategy is: the amount of consumption resources required for on-chain transaction data. In the case where the target storage strategy is the first storage strategy, the order of transaction data in any to-be-packaged sequence is in ascending order of the amount of consumption resources, and the corresponding target selection strategy is used to indicate that according to the descending order of the amount of consumption resources, transaction data is selected starting from the tail of any to-be-packaged sequence; The transaction attribute referred to by the second storage strategy is: the transaction creation time of the transaction data. In the case where the target storage strategy is the second storage strategy, the order of transaction data in any to-be-packaged sequence is in ascending order of the transaction creation time, and the corresponding target selection strategy is used to indicate that according to the ascending order of the transaction creation time, transaction data is selected starting from the head of any to-be-packaged sequence; The transaction attribute referred to by the third storage strategy is: the transaction reception order of the transaction data. In the case where the target storage strategy is the third storage strategy, the order of transaction data in any to-be-packaged sequence is in ascending order of the transaction reception order, and the corresponding target selection strategy is used to indicate that according to the ascending order of the transaction reception order, transaction data is selected starting from the head of any to-be-packaged sequence.
3. The method according to claim 2, wherein The selecting transaction data from N to-be-packaged sequences according to the target selection strategy corresponding to the target storage strategy includes: Obtaining the target number of transaction data to be selected; In the case where the total number of transaction data included in the N to-be-packaged sequences is less than or equal to the target number, selecting all transaction data from each to-be-packaged sequence; In the case where the total number of transaction data included in the N to-be-packaged sequences is greater than the target number, determining the selection number corresponding to each to-be-packaged sequence; the sum of the selection numbers corresponding to each to-be-packaged sequence is less than or equal to the target number; According to the selection order indicated by the target selection strategy, selecting the corresponding selection number of transaction data from each to-be-packaged sequence.
4. The method according to claim 2, wherein The target storage policy is the first storage policy, and the data structure of any sequence to be packaged is a binary tree. According to the target storage policy, storing the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard to obtain the sequence to be packaged corresponding to each transaction pool shard includes: Constructing a tree to be sorted based on the transaction data corresponding to the nth transaction pool shard among the N transaction pool shards and the un-packaged transaction data in the nth transaction pool shard; the tree to be sorted is a binary tree, and the nodes in the tree to be sorted are transaction data, where n ∈ [1, N]; Adjusting each node in the tree to be sorted according to the resource consumption amount of each node in the tree to be sorted to obtain a first intermediate tree; the first intermediate tree is a max heap, and the resource consumption amount of any node in the max heap is greater than or equal to the resource consumption amount of the corresponding node's child node; Exchanging the last node in the first intermediate tree with the root node to obtain a second intermediate tree; Adjusting the second intermediate tree to obtain a target sorted tree, and obtaining the sequence to be packaged corresponding to the nth transaction pool shard according to the transaction data recorded in the target sorted tree.
5. The method according to claim 4, wherein The adjusting each node in the tree to be sorted according to the resource consumption amount of each node in the tree to be sorted to obtain a first intermediate tree includes: Starting from the last non-leaf node in the tree to be sorted, traversing each non-leaf node in the tree to be sorted layer by layer in the direction towards the root node; For the currently traversed node, if the resource consumption amount of the currently traversed node is less than the resource consumption amount of the left child node of the currently traversed node, then exchange the currently traversed node with the corresponding left child node, and adjust the nodes of the subtree corresponding to the left child node after the exchange if the resource consumption amount of the left child node after the exchange is less than the resource consumption amount of the child node of the corresponding left child node; If the resource consumption amount of the currently traversed node is less than the resource consumption amount of the right child node of the currently traversed node, then exchange the currently traversed node with the corresponding right child node, and adjust the nodes of the subtree corresponding to the right child node after the exchange if the resource consumption amount of the right child node after the exchange is less than the resource consumption amount of the child node of the corresponding right child node; Until the traversal ends and the first intermediate tree is adjusted.
6. The method according to claim 4, wherein The constructing a tree to be sorted based on the transaction data corresponding to the nth transaction pool shard among the N transaction pool shards and the un-packaged transaction data in the nth transaction pool shard includes: Constructing the tree to be sorted by the transaction data corresponding to the nth transaction pool shard and the un-packaged transaction data in the nth transaction pool shard in a random order; Or, constructing the tree to be sorted by the transaction data corresponding to the nth transaction pool shard and the un-packaged transaction data in the nth transaction pool shard in ascending order of the transaction receiving order; Or, taking the transaction data corresponding to the nth transaction pool shard as a node and adding it after the last node of the binary tree formed by the un-packaged transaction data in the nth transaction pool shard in a random order or in ascending order of the transaction receiving order to obtain the tree to be sorted.
7. The method according to claim 2, wherein The target storage policy is the second storage policy. The data structure of any sequence to be packaged is a linked list. According to the target storage policy, storing the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard to obtain the sequence to be packaged corresponding to each transaction pool shard includes: Determining a transaction linked list composed of un-packaged transaction data in the nth transaction pool shard, where n ∈ [1, N]; Traversing the transaction data corresponding to the nth transaction pool shard; For the target transaction data being currently traversed, starting from the last transaction data in the transaction linked list and moving towards the first transaction data in the transaction linked list, sequentially comparing the transaction creation time between the target transaction data and the transaction data in the transaction linked list until a reference transaction data whose transaction creation time is earlier than that of the target transaction data is determined from the transaction linked list, and adding the target transaction data as the transaction data after the reference transaction data in the transaction linked list; If it is determined that the reference transaction data fails, adding the target transaction data as the transaction data before the first transaction data in the transaction linked list; According to the various transaction data recorded in the transaction linked list obtained after the traversal ends, obtaining the sequence to be packaged corresponding to the nth transaction pool shard.
8. The method according to claim 2, wherein The target storage policy is the third storage policy. The data structure of any sequence to be packaged is a queue. According to the target storage policy, storing the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard to obtain the sequence to be packaged corresponding to each transaction pool shard includes: Determining a transaction queue composed of un-packaged transaction data in the nth transaction pool shard, where n ∈ [1, N]; Based on the ascending order of the transaction reception order, sequentially adding the various transaction data corresponding to the nth transaction pool shard to the transaction queue; According to the various transaction data recorded in the transaction queue after the addition is completed, obtaining the sequence to be packaged corresponding to the nth transaction pool shard.
9. The method according to claim 1, wherein The blockchain is maintained by a blockchain network. The blockchain network includes multiple consensus nodes. After a consensus node that performs block construction processing constructs a target block using the selected transaction data, it broadcasts the target block to other consensus nodes; after each consensus node in the blockchain network obtains the target block, it performs consensus processing on the target block based on the transaction data in the transaction pool of the corresponding consensus node, and after reaching a consensus on the target block, uploads the target block to the blockchain and removes the transaction data in the target block from the transaction pool.
10. The method according to claim 9, wherein The manner in which a target consensus node in the blockchain network performs consensus processing on the target block based on the transaction data in the transaction pool of the target consensus node includes: Performing validity verification on the target block based on the transaction data in the transaction pool of the target consensus node; When verifying that the target block is valid, executing the transactions indicated by the various transaction data in the target block; When the transaction execution result determined by the target consensus node is consistent with the transaction execution result carried by the target block, it is determined that the target consensus node reaches a consensus on the target block; Otherwise, it is determined that the target consensus node does not reach a consensus on the target block.
11. A data processing device based on blockchain, characterized in that, Including: A communication unit for performing communication interactions; A processing unit for obtaining a transaction data set; the transaction data set includes at least one transaction data; determining the transaction pool shard corresponding to each transaction data from N transaction pool shards; wherein the N transaction pool shards are obtained by partitioning a transaction pool, and N is a positive integer; storing the transaction data corresponding to each transaction pool shard into the corresponding transaction pool shard according to a target storage policy to obtain a to-be-packed sequence corresponding to each transaction pool shard; wherein the target storage policy is determined from multiple storage policies, each transaction data has multiple transaction attributes, and different storage policies refer to different transaction attributes when storing transaction data; when a block needs to be constructed, select transaction data from the N to-be-packed sequences according to the target selection policy corresponding to the target storage policy, and perform block construction processing using the selected transaction data.
12. A computer device, comprising an input interface and an output interface, characterized in that, Further including: A processor and a computer-readable storage medium; The computer-readable storage medium is used for storing a computer program; The processor is used for running the computer program to implement the blockchain-based data processing method according to any one of claims 1-10.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded and executed by the processor to implement the blockchain-based data processing method according to any one of claims 1-10.
14. A computer program product, characterized in that, The computer program product includes a computer program, and the computer program is suitable for being loaded and executed by the processor to implement the blockchain-based data processing method according to any one of claims 1-10.