Data processing method and device of block chain network, equipment, medium and product
By introducing the architecture of management nodes and sub-nodes into the blockchain network, and using contract routing strategies to allocate business transactions to multiple sub-nodes for processing, the problem of low performance when blockchain nodes process a large number of transactions is solved, and transaction load balancing and Data is stored evenly, improving transaction processing efficiency.
Patent Information
- Application Number
- CN202310394561.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-07
- Publication Date
- 2024-10-15
AI Technical Summary
In a blockchain network, blockchain nodes are prone to transaction congestion and low performance when processing a large number of business transactions, resulting in low transaction processing efficiency.
By introducing the blockchain network architecture of management nodes and sub-nodes, and using the contract routing strategy of management contracts and sub-contracts, business transactions are allocated to multiple sub-nodes for processing, data sharding is achieved, and the transaction load and data storage amount of a single node are reduced. And achieve transaction load balancing through contract routing strategy.
It improves the performance of blockchain nodes in processing business transactions, reduces transaction congestion, achieves uniform storage of data and improves transaction processing efficiency.
Smart Images

Figure CN118779091A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and in particular to a data processing method, device, equipment, medium and product for a blockchain network. Background Art
[0002] Blockchain refers to a data structure composed of several blocks, each of which consists of transactions generated within a period of time. Blockchain nodes that have obtained the right to record accounts package the blocks and verify them independently. At present, in the blockchain network, each blockchain node can deploy the same smart contract. When a pending business transaction is obtained, each blockchain node can call the deployed smart contract to execute the business transaction. However, when a large number of business transactions need to be executed, each blockchain node needs to process the large number of business transactions, which will cause the blockchain node to handle transactions too much, and it is easy to cause transaction congestion and low transaction processing efficiency, resulting in low performance of blockchain nodes in processing business transactions. Summary of the invention
[0003] The embodiments of the present application provide a data processing method, device, equipment, medium and product for a blockchain network, which can improve the performance of blockchain nodes in the blockchain network in processing business transactions.
[0004] On the one hand, an embodiment of the present application provides a data processing method for a blockchain network, wherein the blockchain network includes a management node and multiple sub-nodes managed by the management node, the management node is configured with a management contract, and each sub-node managed by the management node is respectively configured with a sub-contract of the management contract, and the method is applied to the management node; the method includes:
[0005] Receive pending business transactions from management contracts;
[0006] Call the management contract based on the configured contract routing strategy to obtain the routing information of the business transaction; the routing information is used to indicate the sub-node that processes the business transaction;
[0007] The business transaction is sent to the sub-node indicated by the routing information among the multiple sub-nodes, so that the indicated sub-node calls the configured sub-contract to execute the business transaction.
[0008] On the one hand, an embodiment of the present application provides a data processing device of a blockchain network, wherein the blockchain network includes a management node and multiple subnodes managed by the management node, the management node is configured with a management contract, and each subnode managed by the management node is respectively configured with a sub-contract of the management contract, and the device runs on the management node; the device includes:
[0009] A receiving module, used to receive pending business transactions of the management contract;
[0010] The calling module is used to call the management contract based on the configured contract routing strategy to obtain the routing information of the business transaction; the routing information is used to indicate the sub-node that processes the business transaction;
[0011] The processing module is used to send the business transaction to the sub-node indicated by the routing information among the multiple sub-nodes, so that the indicated sub-node calls the configured sub-contract to execute the business transaction.
[0012] On the one hand, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute some or all of the steps in the above method.
[0013] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program includes program instructions, which, when executed by a processor, are used to execute some or all of the steps in the above method.
[0014] Accordingly, according to one aspect of the present application, a computer program product or a computer program is provided, wherein the computer program product or the computer program comprises computer instructions, and when the computer instructions are executed by a processor, some or all of the steps in the above method can be implemented.
[0015] In the embodiment of the present application, the business transaction to be processed by the management contract can be received, the management contract can be called based on the configured contract routing strategy, the routing information of the business transaction can be obtained, and the business transaction can be sent to the subnode indicated by the routing information in multiple subnodes, so that the indicated subnode calls the configured subcontract to execute the business transaction. Through the above method, multiple business transactions can be assigned to different subnodes for processing, thereby realizing data sharding in the blockchain network, and the number of transactions processed by a single subnode (i.e., blockchain node) can be reduced, and the amount of data stored can be reduced. There is no need for each blockchain node to execute the same large-scale business transactions, so that the blockchain network can reduce the transaction load occupied by the blockchain network due to processing a large number of business transactions when carrying massive business data (i.e., data related to business transactions), and reduce the transaction congestion on the blockchain node, improve the transaction processing efficiency, and then improve the performance of the blockchain node in processing business transactions; in addition, through the contract routing strategy, a large number of business transactions can be distributed as evenly as possible to each subnode, so as to achieve the purpose of uniform storage of business data, that is, the transaction load balancing of the blockchain nodes in the blockchain network can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0017] Figure 1 A schematic diagram of a network architecture of a blockchain network provided in an embodiment of the present application;
[0018] Figure 2 A schematic diagram of a transaction processing process provided by an embodiment of the present application;
[0019] Figure 3 A flowchart of a data processing method for a blockchain network provided in an embodiment of the present application;
[0020] Figure 4 A flowchart of a data processing method for a blockchain network provided in an embodiment of the present application;
[0021] Figure 5 A schematic diagram of a data processing process of a blockchain network provided in an embodiment of the present application Figure 1 ;
[0022] Figure 6 A schematic diagram of a data processing process of a blockchain network provided in an embodiment of the present application Figure 2 ;
[0023] Figure 7 A schematic diagram of a business transaction processing process provided in an embodiment of the present application Figure 1 ;
[0024] Figure 8 A schematic diagram of a business transaction processing process provided in an embodiment of the present application Figure 2 ;
[0025] Fig. 9 A schematic diagram of a business transaction processing process provided in an embodiment of the present application Figure 3 ;
[0026] Fig.10 A schematic diagram of a business transaction processing process provided in an embodiment of the present application Figure 4 ;
[0027] Fig.11 A schematic diagram of the structure of a data processing device provided in an embodiment of the present application;
[0028] Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0030] See also Figure 1 , Figure 1 This is a schematic diagram of the network architecture of a blockchain network provided by an embodiment of the present application. Figure 1 As shown, blockchain nodes are deployed in the blockchain network, such as blockchain node 100a, blockchain node 100b, ..., blockchain node 100h. The number of blockchain nodes is not limited here. The blockchain node includes a management node and multiple sub-nodes managed by the management node, such as blockchain node 100a is a management node, and blockchain nodes 100b-100d are sub-nodes associated with blockchain node 100a. Blockchain node 100a is a management node, and blockchain nodes 100b-100d are sub-nodes 1 associated with blockchain node 100a; blockchain node 100e is a management node, and blockchain nodes 100f-100h are sub-nodes associated with blockchain node 100e. It can be understood that the number of management nodes and the number of sub-nodes will not be limited here. In addition, each management node in the blockchain network and the sub-nodes managed by each of them constitute a blockchain sub-network, such as blockchain nodes 100a-100d are a blockchain sub-network, and blockchain nodes 100e-100h are a blockchain sub-network.
[0031] In addition, the network architecture also includes a service terminal cluster, wherein the service terminal cluster may include one or more service terminals, and the number of service terminals in the service terminal cluster is not limited here. Figure 1As shown, the multiple business terminals in the business terminal cluster may specifically include: business terminal 200a, business terminal 200b, ..., business terminal 200n, wherein there may be a communication connection between the business terminal clusters, for example, there is a communication connection between business terminal 200a and business terminal 200b, and there is a communication connection between business terminal 200a and business terminal 200n. At the same time, any business terminal in the business terminal cluster may have a communication connection with a management node (such as blockchain node 100a) in the blockchain network, so that each business terminal in the business terminal cluster can exchange data with the management node in the blockchain network through the communication connection, for example, there is a communication connection between business terminal 200a and blockchain node 100a, such as business terminal 200a initiates a business transaction, and blockchain node 100a receives the pending business transaction. In addition, there may be a communication connection between any two blockchain nodes in the blockchain network.
[0032] It can be understood that in actual scenarios, there may be a communication connection between a blockchain node as a management node and a blockchain node as a child node, there may be a communication connection between any two blockchain nodes as management nodes, etc. The above communication connection does not limit the connection method, and may be directly or indirectly connected through a wired communication method, directly or indirectly connected through a wireless communication method, or through other methods, which are not limited in this application.
[0033] It should be understood that Figure 1 Each business terminal in the business terminal cluster shown in FIG. 1 may be installed with a client, which is used to implement blockchain services. When the client runs in each business terminal, it can be respectively connected to the above Figure 1 Data is exchanged between any management node (such as blockchain node 100a) shown. The client can be any client for initiating business transactions. The client can be an independent client or an embedded sub-client integrated in a client, which is not limited here.
[0034] For example, the business terminal 200a can send a business transaction to the blockchain node 100a through the client. When the blockchain node 100a receives the business transaction, it can determine the sub-node that processes the business transaction (such as blockchain node 100b) from the managed sub-nodes, and send the business transaction to the blockchain node 100b, which will execute the business transaction.
[0035] It can be understood that the embodiments of the present application can be executed by an electronic device, and the electronic device involved can refer to a management node in a blockchain network. Figure 1The blockchain node shown is, for example, blockchain node 100a. The electronic device can be a server or a terminal. Among them, the server can be an independent physical server, 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 communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The terminal can be a smart phone, a tablet computer, a laptop, a desktop computer, a smart speaker, a smart watch, a car terminal, etc., but is not limited to this.
[0036] For further information, see Figure 2 , Figure 2 A schematic diagram of a transaction processing process provided by an embodiment of the present application. The transaction processing process is used to characterize the data processing method of the blockchain network proposed in the present application. Figure 1 The blockchain node 100a in the example is configured with a management contract to manage multiple child nodes associated with the node (e.g. Figure 1 The blockchain nodes 100b-100d in the example are configured with a sub-contract of the management contract. The management contract and the sub-contract of the management contract correspond to a smart contract. The management node receives the business transaction to be processed by the management contract, and calls the management contract based on the configured contract routing strategy to obtain the routing information of the business transaction, so that the business transaction can be sent to the sub-node indicated by the routing information among the multiple sub-nodes (for example, Figure 1 The blockchain node 100c in the block chain, the indicated sub-node calls the configured sub-contract to execute the business transaction. It can be understood that the above description reflects the data sharding process based on the blockchain network.
[0037] Understandably, Figure 1 The possible network architecture of the technical solution of the present application is merely exemplified and does not limit the specific architecture of the technical solution of the present application. That is, the technical solution of the present application can also provide other forms of network architecture.
[0038] Optionally, in some embodiments, the electronic device may execute the data processing method of the blockchain network to improve the transaction processing performance of the blockchain network according to actual business needs. The technical solution of the present application can be applied to transaction processing in any blockchain scenario. For example, a business transaction may be a transaction related to bills, such as an electronic invoice issuance transaction, an electronic invoice red-offset transaction, and so on. For another example, a business transaction may be a transaction related to object information, such as an object information addition transaction, an object information deletion transaction, and so on. The type of business transaction is not limited here.
[0039] For ease of understanding, the following is an introduction to the technical terms involved in the technical fields to which the solutions of the embodiments of the present application may be applied:
[0040] 1. Blockchain:
[0041] The embodiments of the present application may relate to the field of blockchain technology. Blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.
[0042] The underlying blockchain platform can include processing modules such as user management, basic services, smart contracts, and operational detection. Among them, the user management module is responsible for the identity information management of all blockchain participants, including maintaining public and private key generation (account management), key management, and the maintenance of the correspondence between the user's real identity and the blockchain address (authority management), etc., and, under authorization, supervises and audits the transactions of certain real identities and provides risk control rule configuration (risk control audit); the basic service module is deployed on all blockchain node devices to verify the validity of business requests, and records valid requests to storage after consensus is reached. For a new business request, the basic service first performs interface adaptation analysis and authentication processing (interface adaptation), and then encrypts the business information through the consensus algorithm (consensus management). The smart contract module is responsible for the registration and issuance of contracts, as well as contract triggering and contract execution. Developers can define the contract logic in a programming language and publish it to the blockchain (contract registration). According to the logic of the contract terms, the key or other events are called to trigger the execution and complete the contract logic. It also provides the function of contract upgrade and cancellation. The operation detection module is mainly responsible for the deployment, configuration modification, contract setting, cloud adaptation and real-time status visualization output of the product during the product release process, such as alarm, network status detection, node equipment health status detection, etc.
[0043] The platform product service layer provides the basic capabilities and implementation framework of typical applications. Developers can build on these basic capabilities and superimpose business features to complete the blockchain implementation of business logic. The application service layer provides application services based on blockchain solutions for business participants to use.
[0044] The embodiment of the present application can propose a blockchain network architecture in combination with the blockchain technology concept, and the blockchain network may include two types of blockchain nodes, specifically: management nodes and subnodes managed by management nodes. The transaction processing performance of the blockchain network can be improved through these two types of blockchain nodes. Blockchain nodes of the same type in the blockchain network have the same business capabilities and jointly maintain the blockchain network. If a blockchain node is abnormal, it will not affect the execution of blockchain services by the entire blockchain network, thereby improving the execution stability of blockchain services and reducing the maintenance and deployment costs of blockchain services. Any blockchain node can leave the blockchain network, or join the blockchain network and deploy related functions.
[0045] 2. Data sharding (also known as data slicing):
[0046] Data sharding (partition, sharding). In a narrow sense, it refers to the data storage system, the process of dividing a large table into smaller slices, and the divided data blocks will be distributed among multiple servers. Data sharding in a broad sense also includes data computing sharding, that is, routing requests to different servers for data computing and processing. Data sharding in the blockchain field often refers to the decentralized storage of stored state data (such as smart contracts) in various blockchain nodes, and then allocating business transactions related to certain state data to designated blockchain nodes for processing (without the need for all blockchain nodes to process them), so as to improve the performance of the blockchain system in processing transactions and improve the scalability of the blockchain. This application can achieve data sharding by managing contracts and sub-contracts to distribute a large number of business transactions as equally as possible to sub-nodes for processing, thereby alleviating the performance pressure of blockchain nodes in processing business transactions.
[0047] It should be noted that when the electronic device in the embodiment of the present application obtains relevant data, such as business transactions and user-related information uploaded by the user through the client, a prompt interface or pop-up window may be displayed. The prompt interface or pop-up window is used to prompt the user that business transactions and other data are currently being obtained. Only after the user confirms the prompt interface or pop-up window, the relevant steps for data acquisition are started, otherwise the process ends. It is understandable that in the specific implementation of the present application, user data (for example, business transactions uploaded by users, etc.) may be involved. When the above embodiments of the present application are applied to specific products or technologies, the user's permission or consent needs to be obtained, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0048] It is understood that the above scenarios are only examples and do not constitute a limitation on the application scenarios of the technical solutions provided in the embodiments of the present application. The technical solutions of the present application can also be applied to other scenarios. For example, it is known to those skilled in the art that with the evolution of the system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0049] For further information, see Figure 3 , Figure 3 A data processing method of a blockchain network provided in an embodiment of the present application is as follows: Figure 3 As shown, the method can be performed by the electronic device mentioned above (such as a management node), and the electronic device can be a blockchain node 100a in a blockchain network. Figure 1 The device node 100a shown in FIG. 1 may specifically include the following steps S101 to S103:
[0050] S101, receiving pending business transactions of the management contract.
[0051] Among them, a management contract (also known as a factory contract) and a sub-contract of the management node correspond to a smart contract. For example, a smart contract A is used to execute an electronic invoice issuance transaction. The smart contract A corresponds to a management contract A and a sub-contract A of the management contract A. The management contract A is used to manage sub-contract A, such as the creation and deletion of sub-contract A. Sub-contract A is used to execute an electronic invoice issuance transaction, and the electronic invoice issuance transaction is the business transaction to be processed by the management contract A. For another example, a smart contract B is used to execute an asset transfer transaction. The smart contract B corresponds to a management contract B and a sub-contract B of the management contract B. The management contract B is used to manage sub-contract B, such as the creation and deletion of sub-contract B. Sub-contract B is used to execute an asset transfer transaction, and the asset transfer transaction is the business transaction to be processed by the management contract B.
[0052] Among them, the management node can be used as a unified entrance for receiving business transactions, and the management node is configured with a management contract. Multiple subnodes managed by the management node can be used to execute business transactions, and the subnodes are configured with subcontracts of the management contract. It can be understood that a subnode can be used to configure a subcontract of the management contract. A management node can be configured with one or more management contracts (such as management contract A and management contract B), and a subnode of a management node can be used to configure a subcontract of the management contract configured on the management node (for example, the management node is configured with management contract A and management contract B, and the subnodes managed by the management node can configure a subcontract A of management contract A and a subcontract B of management contract B). In addition, the business functions of multiple subcontracts created by a management contract are the same, that is, they can be used to execute the same type of business transactions. It can be understood that there can be multiple management nodes in the blockchain network, and the process and principle of each management node processing business transactions through several subnodes managed by each management node are the same. Therefore, the embodiment of the present application takes any management node as an example to illustrate the process of processing business transactions through several subnodes managed.
[0053] Among them, the number of sub-nodes managed by different management nodes may be the same or different. In addition, for the same management contract, when configured on different management nodes, some parameters in its management contract may be different. For example, the management contract contains a sub-contract creation parameter for indicating the number of sub-contracts to be created (i.e., the number of sub-contracts created by the management contract). The values indicated by the sub-contract creation parameters in the management contracts on different management nodes may be different. The values indicated by the sub-contract creation parameters in the management contracts corresponding to different smart contracts may be different. For example, for management node 1, management contract A is configured, and the value indicated by the sub-contract creation parameter in the management contract A on the management node 1 is 5, indicating that management node 1 can create 5 sub-contracts of management contract A and configure them on 5 different sub-nodes managed by management node 1; for management node 2, management contract A is configured, and the value indicated by the sub-contract creation parameter in the management contract A on the management node 2 is 4, indicating that management node 2 can create 4 sub-contracts of management contract A and configure them on 4 different sub-nodes managed by management node 1.
[0054] It can be understood that the business transaction received by the management node refers to the transaction for which the management contract configured on the management node performs relevant business processing. The relevant business processing of the business transaction through the management contract is to determine the sub-contract for processing the business transaction through the management contract, and send the business transaction to the sub-node corresponding to the determined sub-contract, and the sub-node corresponding to the determined sub-contract executes the business transaction through the configured sub-contract.
[0055] It can be understood that the above business transactions can be generated and submitted by the business terminal through the client. The management node can obtain the business transaction from the transaction pool in the blockchain network. Among them, the business transaction can be any type of transaction, for example, it can be a business transaction related to electronic invoices, such as electronic invoice issuance transactions. Another example is that it can be a business transaction related to object information (such as user information), such as a transaction for adding a new object. The management node is configured with a management contract related to the business transaction, that is, a management contract for processing business transactions.
[0056] S102. Call the management contract based on the configured contract routing strategy to obtain routing information of the business transaction.
[0057] Among them, the determined routing information can be used to indicate the subnode that processes the business transaction among the multiple subnodes managed by the management node. It can be understood that the routing information can directly indicate the subnode that processes the business transaction, such as the routing information is the node identifier of the subnode. Alternatively, the routing information can indirectly indicate the subnode that processes the business transaction, such as the routing information is the contract identifier of the subcontract for processing the business transaction, and the subnode deployed with the subcontract corresponding to the contract identifier can be used as the subnode that indicates the processing of the business transaction. The routing information is not limited here.
[0058] The contract routing strategy may be a strategy for routing based on the number of sub-contracts created by the management contract and the identification information of the initiating object of the business transaction. The routing information of the business transaction may be obtained by calling the management contract to parse the identification information of the object from the business transaction, and calling the management contract to obtain the number of sub-contracts created; performing a modulo calculation on the value of the identification information of the initiating object and the number of creations to obtain the routing information; wherein the routing information is used to indicate the identification information of the corresponding child node.
[0059] In some embodiments, the number of sub-contracts created by the management contract may refer to the number of sub-contracts actually created by the management contract (i.e., the number of sub-contracts currently created and deployed), or may refer to the number of sub-contracts that the management contract can create. For example, the management contract may include a sub-contract creation parameter (contractNumer), and the value indicated by the sub-contract creation parameter is the number of sub-contracts that the management contract can create. For example, the management contract can create 10 sub-contracts, but only 8 sub-contracts are actually created at this time. Among them, the object address of the initiating object of the business transaction can be converted into a numerical value, and the number of sub-contracts created can be calculated modulo based on the numerical value of the object address, and the result of the modulo calculation can be used as the index information (cindex) of the child node, that is, the index information of the sub-contract.
[0060] It can be understood that each modulo calculation result will be associated with a child node (or it can be understood as being associated with a sub-contract). The association relationship can be determined based on the number of creations and the situation of all modulo calculation results. The determination rules of the association relationship can be determined by relevant business personnel based on the actual scenario. Therefore, when the modulo calculation result is used as routing information, a sub-node for processing the business transaction can be indicated through the routing information. In other words, the modulo calculation result is equivalent to the index information of the sub-contract, and each modulo calculation result is associated with a sub-contract. Therefore, when the modulo calculation result is used as routing information, a sub-contract for processing the business transaction can be indicated through the routing information, and the sub-node deploying the sub-contract can be used as the sub-node for processing the business transaction.
[0061] Therefore, the sub-contract routing strategy configured in the above management contract is set by converting the object address into a numerical value, and then using the converted numerical value to modulo the number of sub-contracts created. Since the object address is a uniform and random value, when a large number of objects submit business transactions, the business transactions can be evenly distributed to each sub-node as much as possible, so as to achieve the purpose of evenly storing the transaction data related to the business transaction in each sub-node.
[0062] Optionally, when taking the modulo of the number of creations indicated by the sub-contract creation parameter, there may be a situation where the determined sub-contract has not been created. For example, if the number of creations indicated by the sub-contract creation parameter is 10, and the number of sub-contracts actually created is 9, then when the sub-contract associated with the modulo calculation result is sub-contract 10, it indicates that the determined sub-contract does not exist, so it is necessary to call the management contract to create and deploy the sub-contract 10, and use the sub-node that deploys the sub-contract 10 as the sub-node indicated by the routing information.
[0063] For example, you can execute the following code to determine whether a sub-contract exists. If it does not exist, create a sub-contract. The code is as follows:
[0064] if(allContracts[cIndex]==address(0)){
[0065] ChildContract cc=new ChildContract();
[0066] allContracts[cIndex]=address(cc)
[0067] }
[0068] Among them, the allContracts variable stores the address information of the child contract. Each actually created child contract will have corresponding address information and be stored. cIndex is the index information of the child contract (i.e. the corresponding modulo calculation result). It can be determined in the address information of the child contract whether the index information of the child contract has corresponding address information. If it exists, it means that the child contract indicated by the index information has been created. If it does not exist, a child contract (newChildContract) corresponding to the index information is created, and the address information of the newly created child contract is associated with the index information cIndex and stored in the allContracts variable.
[0069] In some embodiments, different contract routing strategies can also be set in different management contracts according to different business transactions in actual scenarios. For example, the contract routing strategy can be a strategy for routing based on the number of sub-contracts created by the management contract and the total number of transactions processed by the management contract. Therefore, the routing information of the business transaction can be obtained by calling the management contract to obtain the total number of transactions processed by the management contract and the number of sub-contracts created; the total number is modulo calculated by the number of sub-contracts created to obtain the routing information; wherein the routing information is used to indicate the identification information of the corresponding child node.
[0070] Among them, the total number of transactions processed by the management contract may refer to the number of calls to the management contract. A counter may be set in the management contract, and the counter is incremented by one each time the management contract is called. Therefore, when selecting a sub-contract (i.e., a sub-node) for processing business transactions, the counter may be used to modulo the number of sub-contracts created. It can be understood that this strategy of routing based on the number of calls may also enable the sub-nodes to achieve a certain transaction load balancing effect. Therefore, the relevant contract routing strategies may be customized according to different business scenarios, and the contract routing strategies are not limited here.
[0071] Among them, the management contract can handle multiple business transactions, that is, one sub-contract can be used to handle multiple business transactions. It can be that a contract routing strategy is configured in the management contract, and each business transaction determines the corresponding routing information through the contract routing strategy. It can also be that multiple contract routing strategies are configured in the management contract, and one business transaction handled by the management contract corresponds to one contract routing strategy. Each business transaction determines the corresponding routing information through its corresponding contract routing strategy.
[0072] It can be understood that the identification information (such as the object address) of the initiating object of the business transaction is unchanged. Therefore, in the case of the first contract routing strategy mentioned above (i.e., the strategy for routing based on the number of sub-contracts created by the management contract and the identification information of the initiating object of the business transaction), for the same initiating object, the submitted business transactions are all processed by the same sub-node, that is, the determined routing information remains unchanged. For the second contract routing strategy (i.e., the strategy for routing based on the number of sub-contracts created by the management contract and the total number of transactions processed by the management contract), since the total number of transactions processed by the management contract is constantly changing, for the same initiating object, each submitted business transaction may be processed by a different sub-node, that is, the determined routing information will change. Therefore, for the contract routing strategies in different management contracts, it can be that when the same type of business transaction needs to be processed by the same sub-node, the contract routing strategy corresponding to the business transaction of this type can be the first contract routing strategy. When the same type of business transaction does not need to be processed by the same sub-node, the contract routing strategy corresponding to the business transaction of this type can be the second contract routing strategy. The setting method of the contract routing strategy corresponding to different business transactions is not limited here, and can be set by relevant business personnel according to the actual scenario.
[0073] For example, the object address is parsed from the business transaction and converted into a number (for example, 51). The number of sub-contracts created is 4. The modulo calculation result obtained by performing a modulo calculation on the number of creation using the numerical value of the object address is 3. The modulo calculation result can be used as routing information. It can be understood that the identification information of multiple sub-nodes is 0-3 in sequence (such as the identification information of sub-node A is 0, the identification information of sub-node B is 1, the identification information of sub-node C is 2, and the identification information of sub-node D is 3). Therefore, the sub-node indicated by the routing information is sub-node D. Alternatively, it can be understood that each modulo calculation result will be associated with a sub-contract (such as the modulo calculation result associated with sub-contract A is 0, the modulo calculation result associated with sub-contract B is 1, the modulo calculation result associated with sub-contract C is 2, and the modulo calculation result associated with sub-contract D is 3). Therefore, the sub-contract indicated by the routing information is sub-contract D, that is, the sub-node indicated by the routing information is the sub-node configured with sub-contract D, that is, the modulo calculation result associated with the sub-contract is the identification information of the sub-node configured with the sub-contract.
[0074] For another example, the total number of transactions processed by the management contract is obtained (for example, 51), the number of sub-contracts created is 4, and the total number of transactions processed is used to perform a modulo calculation on the number of creations, and the modulo calculation result is 3, and the modulo calculation result can be used as routing information; it can be understood that the identification information of multiple sub-nodes is 0-3 in sequence (for example, the identification information of sub-node A is 0, the identification information of sub-node B is 1, the identification information of sub-node C is 2, and the identification information of sub-node D is 3), so the sub-node indicated by the routing information is sub-node D. Alternatively, it can be understood that each modulo calculation result is associated with a sub-contract (for example, the modulo calculation result associated with sub-contract A is 0, the modulo calculation result associated with sub-contract B is 1, the modulo calculation result associated with sub-contract C is 2, and the modulo calculation result associated with sub-contract D is 3), so the sub-contract indicated by the routing information is sub-contract D, that is, the sub-node indicated by the routing information is the sub-node configured with sub-contract D, that is, the modulo calculation result associated with the sub-contract is the identification information of the sub-node configured with the sub-contract.
[0075] It can be understood that the contract routing strategy is used to determine the sub-node used to execute the current business transaction from the multiple sub-nodes managed by the management node, so as to distribute multiple business transactions to each sub-node as evenly as possible for processing. This can not only achieve transaction load balancing of each sub-node, but also reduce the transaction processing pressure of a single sub-node, so that transaction data related to the business transaction can be evenly stored in each sub-node, thereby improving transaction processing performance at the smart contract level.
[0076] That is to say, the management contract can be used to manage and plan sub-contracts, and each sub-contract can be responsible for the execution of part of the business transaction and the storage of the execution result information. The management contract can extract relevant information (such as the identification information of the initiator of the business transaction) from the business transaction through the technical means of data sharding to determine which sub-node (i.e., sharding in the blockchain field) the business transaction should be sent to, or from which sub-node to obtain relevant transaction data for subsequent business calculations and aggregation, so as to achieve the purpose of transaction load balancing and data storage balancing, and improve the execution performance and scalability of business transactions from the smart contract level.
[0077] S103. Send the business transaction to the sub-node indicated by the routing information among the multiple sub-nodes, so that the indicated sub-node calls the configured sub-contract to execute the business transaction.
[0078] The business transaction can be sent to the subnode indicated by the routing information, and the indicated subnode calls the configured subcontract to execute the business transaction, and stores the execution result information of the business transaction in the subnode. In different subnodes, the execution result information stored is different due to the different business transactions executed.
[0079] Therefore, it can be a distributed and uniform storage of massive business data of the blockchain network, which can ensure transaction processing performance when enabling the blockchain network to carry a large number of business transactions. At the same time, for a smart contract, there are multiple sub-contracts to jointly undertake the business transactions that were originally to be processed by a smart contract (that is, the sub-nodes where multiple sub-contracts are located evenly store the relevant business data that were originally to be stored by the node where a smart contract is located), which can reduce the transaction processing pressure of each blockchain node in the blockchain network and improve transaction processing efficiency. In other words, applying data sharding and management contract technology to the management of smart contracts, the execution of business transactions, and the storage of execution result information can realize data sharding in the blockchain network from the smart contract level, solve the performance degradation problem caused by a single smart contract processing a large number of business transactions, and improve the scalability of the blockchain.
[0080] In the embodiment of the present application, the business transaction to be processed by the management contract can be received, the management contract can be called based on the configured contract routing strategy, the routing information of the business transaction can be obtained, and the business transaction can be sent to the subnode indicated by the routing information in multiple subnodes, so that the indicated subnode calls the configured subcontract to execute the business transaction. Through the above method, multiple business transactions can be assigned to different subnodes for processing, thereby realizing data sharding in the blockchain network, and the number of transactions processed by a single subnode (i.e., blockchain node) can be reduced, and the amount of data stored can be reduced. There is no need for each blockchain node to execute the same large-scale business transactions, so that the blockchain network can reduce the transaction load occupied by the blockchain network due to processing a large number of business transactions when carrying massive business data (i.e., data related to business transactions), and reduce the transaction congestion on the blockchain node, improve the transaction processing efficiency, and then improve the performance of the blockchain node in processing business transactions; in addition, through the contract routing strategy, a large number of business transactions can be distributed as evenly as possible to each subnode, so as to achieve the purpose of uniform storage of business data, that is, the transaction load balancing of the blockchain nodes in the blockchain network can be achieved.
[0081] For further information, see Figure 4 , Figure 4 A data processing method of a blockchain network provided in an embodiment of the present application is as follows: Figure 4 As shown, the method can be performed by the electronic device mentioned above (such as a management node), and the electronic device can be a blockchain node 100a in a blockchain network. Figure 1 The device node 100a shown in FIG. 1 may specifically include the following steps S201 to S204:
[0082] S201. Receive pending business transactions of the management contract.
[0083] S202: Call the management contract based on the configured contract routing strategy to obtain the routing information of the business transaction. The specific implementation of steps S201-S202 can refer to the relevant description of the above embodiment, which will not be repeated here.
[0084] S203: parse the transaction execution parameters from the business transaction, and generate an execution request for the business transaction based on the transaction execution parameters.
[0085] Among them, the transaction execution parameters are the specific parameters involved in executing business transactions.
[0086] For example, a business transaction may be a transaction for adding a first object, and the transaction execution parameter may include the object information of the first object. It can be understood that after the business transaction is executed by the sub-contract configured by the sub-node indicated by the routing information, the object information of the first object is stored in the object information library of the indicated sub-node. The object information of the first object may be stored in the first object information list in the object information library. For example, the object information of the first object is added to the last row of the first object information list according to the time of addition.
[0087] For another example, a business transaction may be a transaction for adding a second object, then the transaction execution parameters may include the object information of the second object, and the object information of the second object may include the object index information of the second object (such as the object age information). It can be understood that after the business transaction is executed by the sub-contract configured by the sub-node indicated by the routing information, the object information of the second object is stored in the object information library and inserted at the position indicated by the object index information of the second object. For example, the information addition position of the object information of the second object is determined in the second object information list of the object information library according to the object index information of the second object, and the object information of the second object is added to the information addition position in the second object information list. It can be understood that a transaction for adding a first object means that the object information of the first object is inserted into the object information library according to the time of addition, and a transaction for adding a second object means that the object information of the second object is inserted into the object information library in an orderly manner according to the order corresponding to the object index information of the second object.
[0088] For another example, a business transaction may be a transaction for deleting an object, then the transaction execution parameter may include the object index information (such as object identification information or object address information, etc.) of the object to be deleted. It can be understood that after the business transaction is executed by the child contract configured by the child node indicated by the routing information, the object information at the location indicated by the object index information of the object to be deleted in the object information library is deleted. The data in the above object information library may refer to the contract status data associated with the child contract called by the indicated child node.
[0089] S204. Send the execution request to the sub-node indicated by the routing information, so that the indicated sub-node calls the configured sub-contract and executes the business transaction based on the execution request.
[0090] It can be understood that the execution request can be sent to the indicated child node, and the indicated child node calls the configured sub-contract to parse the transaction execution parameters from the execution request, and execute the business transaction based on the parsed transaction execution parameters.
[0091] It can be understood that after the business transaction is executed by calling the configured sub-contract by the indicated sub-node, the execution result information of the business transaction is stored in the indicated sub-node, that is, the execution result information is distributed and stored in each sub-node. When the execution result information needs to be queried, the full amount of execution result information can be obtained from each sub-node through the management node. Specifically, if a full transaction query request from the client is received, a transaction information pull request is sent to each of the multiple sub-nodes, and the execution result information for the executed full transaction is received from each sub-node based on the full transaction pull request, and the execution result information sent by the received multiple sub-nodes is returned to the client. Among them, the client can refer to a client on any business terminal. It can be understood that the execution result information of the full transaction refers to all execution result information obtained by a sub-node when executing the same type of business transaction.
[0092] For example, if the client wants to obtain the full amount of first object information in the first object information list, the management node can generate a transaction information pull request and send it to each child node respectively. Each child node obtains the first object information in the stored first object information list based on the transaction information pull request, and returns the obtained first object information to the management node. The management node merges the first object information obtained from each child node, such as merging them in a specified order (such as merging them in order of the new addition time of the first object information from small to large), and returns the merged first object information as the full amount of first object information to the client.
[0093] For another example, when it is necessary to query the execution result information that meets the query conditions, the management node can obtain the execution result information that meets the query conditions from each child node. Specifically, if a transaction query request carrying the query conditions is received from the client, a transaction information pull request carrying the query conditions is sent to each of the multiple child nodes, and the execution result information that meets the query conditions is returned by each child node based on the transaction information pull request carrying the query conditions, and the received execution result information is returned to the client.
[0094] For example, if the client wants to obtain the first object information in the first object information list that meets the query conditions (such as the object information of an object whose gender is female), the management node can generate a transaction information pull request carrying the query conditions and send it to each child node respectively. Each child node obtains the first object information that meets the query conditions from the stored first object information list, and returns the obtained first object information to the management node. The management node merges the first object information obtained from each child node, such as merging them in a specified arrangement order (such as merging them in ascending order of the time when the first object information was added), and returns the merged first object information as the first object information that meets the query conditions to the client.
[0095] In addition, for full transaction query requests (it can be understood that the same is true for transaction query requests that carry query requests), the client can also submit them to the management node in the form of transactions (such as object query transactions). For example, when the management node receives the full transaction query request and parses the corresponding query transaction from the full transaction query request, it can send the query transaction to each managed sub-node, and each sub-node executes the query transaction to obtain the execution result information (it can be understood that the management node generates a corresponding transaction information pull request based on the query transaction, and sends the transaction information pull request to each sub-node). Alternatively, when receiving a query transaction, the routing information of the query transaction can be obtained based on the configured contract routing strategy, and the query transaction can be sent to the sub-node indicated by the routing information, and the indicated sub-nodes can pull the execution result information from each sub-node respectively, and the indicated sub-nodes can return the execution result information pulled from each sub-node to the management node.
[0096] Among them, it can be understood that there are N management nodes in the blockchain network, and the N management nodes belong to N consensus nodes, N is a positive integer. The embodiment of the present application takes any one of the N consensus nodes as an example, and each consensus node manages multiple child nodes of its own, and each consensus node is used to receive the transaction results returned by the respective child nodes indicated by the routing information after executing the business transaction, and the N consensus nodes are used to perform consensus processing on the business transaction based on the transaction results of the respective child nodes for the business transaction. Therefore, if the business transaction is passed by consensus of the N consensus nodes, the business transaction is chained to the blockchain network.
[0097] For example, when management node A packages the business transactions obtained from the transaction pool into a consensus block, it executes the business transaction through the child node indicated by the determined routing information, obtains the first transaction result returned by the indicated child node, and sends the business transaction and the first transaction result to management node B. Management node B executes the business transaction through the child node indicated by the corresponding routing information, obtains the second transaction result returned by the indicated child node, and performs consensus processing on the business transaction based on the first transaction result and the second transaction result (i.e., performs consensus on the consensus block). In other words, each management node will receive the transaction result returned by the child node indicated by the routing information after executing the business transaction, and send the returned transaction result to other management nodes. At the same time, consensus processing is performed on the business transaction based on the transaction result returned by the indicated child node and the transaction results sent by other management nodes, and after the business transaction consensus is passed, the business transaction is put on the chain, that is, after the consensus block where the business transaction is located is passed by consensus, the consensus block is put on the chain to the blockchain network. For example, the N management nodes in the blockchain network are used to jointly maintain the target blockchain. Therefore, after the consensus block is passed by consensus, the N management nodes will link the consensus block to the target blockchain.
[0098] Accordingly, when the management node receives a full transaction query request from the client (it can be understood that the same is true for a transaction query request carrying a query request), the full transaction query request can be sent to other management nodes when sending a transaction information pull request to each of the multiple child nodes. When the management node receives the execution result information returned by the child node, the management nodes mutually verify the execution result information received by each other, and when the verification is successful, the management node returns the received execution result information to the client. In other words, each management node can verify the execution result information obtained through the transaction information pull request, and after the verification is successful, the verified execution result information is returned to the client.
[0099] For example, when management node A obtains a full transaction query request, it sends a transaction information pull request to multiple child nodes managed by management node A, and receives the first execution result information returned by the multiple child nodes managed by management node A (i.e., the first execution result information for the executed full transaction), and at the same time sends the transaction information pull request and the first execution result information to management node B. Management node B sends a transaction information pull request to multiple child nodes managed by management node B, and receives the second execution result information returned by the multiple child nodes managed by management node B. Management node A receives the second execution result information sent by management node B. Management node A verifies the first execution result information based on the second execution result information, and management node B also verifies the second execution result information based on the first execution result information. When management node A determines that the first execution result information is successfully verified based on the verification result of the management node in the blockchain network, it returns the first execution result information to the client.
[0100] For example, Figure 5 As shown, Figure 5 A schematic diagram of a data processing process of a blockchain network provided in an embodiment of the present application; wherein, a client 50 submits a business transaction to a management node 51, and a management contract configured on the management node 51 is used to create a sub-contract and deploy the sub-contract to multiple sub-nodes (52a, 52b, ..., 52n) managed by the management node 51, and each sub-node has a sub-contract of the management contract; the management node 51 calls the management contract to route the sub-contract based on the contract routing strategy (i.e., routing of the sub-node); the management node 51 sends the business transaction to the sub-node indicated by the routing information, so that the indicated sub-node (such as sub-node 52a, or sub-node 52b, ..., or child node 52n) executes a business transaction to store the execution result information of the business transaction in the indicated child node (for example, writing it into the contract status data associated with the child contract configured by the indicated child node); subsequently, when the management node 51 needs to obtain the execution result information related to a certain business transaction (for example, the first object information in the first object information list), the execution result information stored in each of the child nodes (52a, 52b, ..., 52n) can be pulled from the managed child nodes (52a, 52b, ..., 52n), and the pulled execution result information can be returned to the client 50 after merging and summarizing.
[0101] For example, Figure 6 As shown, Figure 6A schematic diagram of a data processing process of a blockchain network provided in an embodiment of the present application; wherein, the management node 60 deploys the sub-contract on the sub-nodes (61a, 61b, 61c) through the management contract, and the management node 62 deploys the sub-contract on the sub-nodes (63a, 63b, 63c) through the management contract; S1, the management node 60 receives the full transaction query request sent by the client; S2, the management node 60 sends a transaction information pull request to the sub-nodes (61a, 61b, 61c); S3, the sub-nodes (61a, 61b, 61c) return the first execution result information of the full transaction (such as all the first object information in the first object information list respectively stored by the sub-nodes (61a, 61b, 61c)) to the management node 60; S4, the management node 60 sends the full transaction query request and the summarized first execution result information to the management node 6 2; S5, management node 62 sends a transaction information pull request to child nodes (63a, 63b, 63c); S6, child nodes (63a, 63b, 63c) return the second execution result information (such as the first object information in the first object information list stored by child nodes (63a, 63b, 63c) respectively) to management node 62; S7, management node 62 sends the second execution result information to management node 60; S8, management node 60 verifies the first execution result information based on the second execution result information; S9, management node 62 verifies the second execution result information based on the first execution result information; S10, after the first execution result information and the second execution result information are verified successfully through management node 60 and management node 62, management node 60 returns the first execution result information to the client after the first execution result information is verified successfully. Among them, the verification principle of the execution result information can be the same as the consensus principle of the block in the blockchain network.
[0102] Therefore, the technical solution of the present application can be used to configure a management contract for each smart contract, and multiple sub-contracts can be created and deployed through the management contract. The business function of the sub-contract is the same as the business function of the smart contract, and the business transaction related to the smart contract can be executed. When executing the business transaction, the management contract can determine the sub-contract used to process the business transaction from multiple sub-contracts through the contract routing strategy, and the sub-node that deploys the determined sub-contract executes the business transaction. It can be understood that the business transaction can be any type of business transaction. A sub-contract can be one or more business transactions. The following describes this solution by taking the business transaction related to object information as an example. It can be understood that the execution principle of business transactions in any business scenario is the same. Among them, business transactions related to object information may include: transactions for adding a first object, transactions for adding a second object, transactions for deleting an object, and transactions for obtaining an object.
[0103] Among them, some code examples of management contracts are as follows:
[0104]
[0105]
[0106] Among them, part 1 is used to define the subcontract creation parameter (contractNumber); part 2 is the execution logic involved in the transaction of adding the first object in the management contract, that is, the AddUser function in the management contract is used to define the execution logic of the management node for the transaction of adding the first object; part 3 is the execution logic involved in the transaction of adding the second object in the management contract, that is, the AddUserByIndex function in the management contract is used to define the execution logic of the management node for the transaction of adding the second object; part 4 is the execution logic involved in the transaction of deleting the object in the management contract, that is, the DeleteUser function in the management contract is used to define the execution logic of the management node for the transaction of deleting the object; part 5 is the execution logic involved in the transaction of obtaining the object in the management contract, that is, the GetAllUser function in the management contract is used to define the execution logic of the management node for the transaction of obtaining the object. The relevant specific descriptions are as follows.
[0107] In addition, some code examples of sub-contracts are as follows:
[0108]
[0109]
[0110] Among them, part 6 is used to define the storage structure (UserData) of object information and related parameters, such as userAddress is the object address parameter (i.e., the identification information corresponding to the initiating object of the business transaction), userId is the object identification of the newly added object (such as the ID number), and userName is the object information of the newly added object (such as the object name). The specific types of the relevant parameters are not limited here and are determined according to the actual scenario; part 7 is the execution logic involved in the transaction of the newly added first object in the subcontract, that is, the addUser function in the subcontract is used to define the execution logic of the subnode for the transaction of the newly added first object; part 8 is the execution logic involved in the transaction of the newly added second object in the subcontract, that is, the addUserByIndex function in the subcontract is used to define the execution logic of the subnode for the transaction of the newly added second object; part 9 is the execution logic involved in the transaction of deleting objects in the subcontract, that is, the deleteUser function in the subcontract is used to define the execution logic of the subnode for the transaction of deleting objects; part 10 is the execution logic involved in the transaction of obtaining objects in the subcontract, that is, the getAllUser function in the subcontract is used to define the execution logic of the subnode for the transaction of obtaining objects. The relevant specific descriptions are as follows.
[0111] Among them, the management contract can be deployed in the management node, that is, the bytecode file is compiled by the code file of the management contract, and the bytecode file is deployed on the management node. It can be understood that when deploying the management contract, it is necessary to determine the number of sub-contracts that the management contract subsequently manages, that is, the sub-contract creation parameters need to be specified in the management contract.
[0112] Among them, for the transaction of the newly added first object (i.e., the code examples in Part 2 and Part 7 above), the specific process may be that the client initiates the transaction of the newly added first object to store the object information of the first object. When the management node receives the transaction of the newly added first object, it calls the addUser function in the management contract (i.e., the code example corresponding to Part 2 above) to execute the following logic: parse the transaction execution parameters (i.e., the object information of the first object, such as the userId parameter, userName parameter, msg.sender parameter, etc.) from the transaction of the newly added first object, and at the same time, the addUser function of the management contract is configured with a contract routing strategy, and the routing information is determined by the contract routing strategy, such as parsing the identification information of the initiating object from the transaction of the newly added first object (i.e., the msg.sender parameter above), and taking the value of the identification information of the initiating object and the sub-contract creation parameter modulo to obtain the routing information (i.e., the cIndex parameter above), such as by performing the modulo calculation through the following code statement:
[0113] uint256 uIndex=uint256(unit160(msg.sender));
[0114] uint256 cIndex=uIndex%_contractNumber;
[0115] Among them, after determining the routing information, it can be determined whether the sub-contract indicated by the routing information exists. It can be understood that if the sub-contract does not exist, the management contract is called to create and deploy the corresponding sub-contract. If it exists, an execution request is generated according to the transaction execution parameters, and the execution request is sent to the child node indicated by the routing information. The indicated child node will call the AddUser function in the sub-contract (i.e., the code example corresponding to the above part 7) to execute the following logic: parse the transaction execution parameters from the execution request, and generate the newly added first object information corresponding to the transaction execution parameters through the information storage structure indicated by the structure UserData (that is, insert the object information of the first object parsed in the newly added first object transaction into the object information library according to the specified information insertion format), and insert the newly added first object information into the last row of the first object information list (UserData[]users) in the object information library. The execution of the transaction of the newly added first object is thereby achieved.
[0116] It can be understood that the above process completes the process of storing the object information of the first object in the sub-contract indicated by the routing information. Since the sub-contract configured on each sub-node can store the object information of the first object, the full amount of the object information of the first object is dispersed in each sub-contract, which can improve the efficiency of inserting and storing the object information of the first object, and the efficiency of retrieving the object information of a certain first object from the sub-contract.
[0117] For example, Figure 7 As shown, Figure 7A processing process for a business transaction provided in an embodiment of the present application; wherein, the client submits a transaction for adding a first object, the management node calls the addUser function in the management contract to parse the transaction execution parameters from the transaction for the newly added first object, and generates a corresponding execution request, and at the same time determines the routing information based on the contract routing strategy in the addUser function, and sends the execution request to the child node indicated by the routing information, and the indicated child node calls the AddUser function in the child contract to execute the transaction for the newly added first object, which can be specifically: parsing the transaction execution parameters from the execution request, and generating the newly added first object information according to the information storage structure, and writing the newly added first object information to the last line of the first object information list in the object information library, which can be understood as being written to the contract status data associated with the child contract configured on the indicated child node, that is, the object information of the first object is stored in the object information library of the indicated child node.
[0118] Among them, for the transaction of adding a second object (i.e., the code examples in Part 3 and Part 8 above), the transaction of adding a second object means that in some business scenarios, there is a need to sort some information lists, so there is also a need to insert them into a specified position in the list. The specific process may be that the client initiates a transaction of adding a second object to store the object information of the second object in a certain order. When the management node receives the transaction of adding a second object, it calls the AddUserByIndex function in the management contract (i.e., the code example corresponding to the above part 3) to execute the following logic: parse the transaction execution parameters (i.e., the object information of the second object, such as the above userId parameter, userName parameter, msg.sender parameter, userIndex parameter, etc.) from the transaction of adding the second object, and the userIndex parameter is the object index information of the second object, such as the age of the object. At the same time, the AddUserByIndex function of the management contract is configured with a contract routing strategy, and the routing information is determined by the contract routing strategy. For example, the identification information of the initiating object (i.e., the above msg.sender parameter) is parsed from the transaction of adding the second object, and the numerical value of the identification information of the initiating object is modulo the sub-contract creation parameter to obtain the routing information (i.e., the above cIndex parameter).
[0119] Among them, after determining the routing information, it can be determined whether the sub-contract indicated by the routing information exists. It can be understood that if the sub-contract does not exist, the management contract is called to create and deploy the corresponding sub-contract. If it exists, an execution request is generated according to the transaction execution parameters, and the execution request is sent to the sub-node indicated by the routing information. The child node indicated by the routing information will call the AddUserByIndex function in the child contract (i.e., the code example corresponding to the above part 8) to execute the following logic: parse the transaction execution parameters from the execution request, and generate the newly added second object information corresponding to the transaction execution parameters through the information storage structure indicated by the structure UserData (that is, insert the object information of the second object parsed in the newly added second object transaction into the object information library according to the specified information insertion format), and determine the insertion position in the second object information list according to the object index information of the second object, for example, traverse the second object information list, find the insertion position of the object information of the second object according to the userIndex parameter (for example, the object information in the second object information list is sorted in a specified order, such as in order from small to large according to the age of the object), and then copy the object information of the last row in the second object information list, and insert the newly added second object information into the last row of the second object information list (UserData[]users) in the object information library, and then move all the object information in the second object information list after the insertion position back one grid, thereby adding the newly added second object information to the insertion position in the second object information list, and realizing the execution of the transaction of the newly added second object.
[0120] It can be understood that this completes the process of storing the object information of the second object in the sub-contract indicated by the routing information. Due to the adoption of the data sharding idea, each sub-contract configured on each sub-node can store the object information of the second object, so that the full amount of the object information of the second object is dispersed to each sub-contract, which greatly reduces the number of moves of the object information originally stored in the second object information list, and can improve the insertion and storage efficiency of the object information of the second object. In theory, the business execution efficiency can be improved by multiples of the contractNumber parameter value.
[0121] For example, Figure 8 As shown, Figure 8A processing process for a business transaction provided in an embodiment of the present application; wherein, the client submits a transaction for adding a second object, the management node calls the addUser function in the management contract to parse out the transaction execution parameters, and generates a corresponding execution request, and at the same time determines the routing information based on the contract routing strategy in the addUser function, sends the execution request to the child node indicated by the routing information, and the indicated child node calls the AddUser function in the child contract to execute the transaction for adding the second object, specifically, the transaction execution parameters are parsed from the execution request, and the corresponding new second object information is generated according to the information storage structure, and the new second object information is written into the object information The last row in the second object information list in the library, and the object index information of the second object is parsed from the transaction execution parameters, the insertion position is determined from the second object information list according to the object index information of the second object, and the object information after the insertion position in the second object information list is moved back by one row, thereby adding the newly added second object information to the insertion position in the second object information list. This can be understood as writing the object information of the second object into the contract status data associated with the sub-contract configured on the sub-node indicated by the routing information in a certain order, that is, the object information of the second object is inserted and stored in the object information library at the position indicated by the object index information of the second object.
[0122] Among them, for the transaction of deleting an object (i.e., the above-mentioned parts 4 and 9), the transaction of deleting an object may refer to deleting the object information in the first object information list or deleting the object information in the second object information list. The specific process may be that the client initiates a transaction to delete an object to delete the object information of the specified object. When the management node receives the transaction to delete an object, it calls the DeleteUser function in the management contract (i.e., the code example corresponding to the above-mentioned part 4) to execute the following logic: parse the transaction execution parameters (i.e., the object index information of the object to be deleted, such as the msg.sender parameter, etc.) from the transaction to delete the object, and at the same time, the DeleteUser function of the management contract is configured with a contract routing strategy, and the routing information is determined by the contract routing strategy, such as parsing the identification information of the initiating object from the transaction to delete the object (i.e., the above-mentioned msg.sender parameter), and taking the value of the identification information of the initiating object and the sub-contract creation parameter modulo to obtain the routing information (i.e., the above-mentioned cIndex parameter).
[0123] Among them, after determining the routing information, an execution request is generated according to the transaction execution parameters, and the execution request is sent to the child node indicated by the routing information. The indicated child node will call the deleteUser function in the child contract (i.e., the code example corresponding to the above part 9) to execute the following logic: parse the transaction execution parameters from the execution request, determine the information deletion position according to the transaction execution parameters (for example, the position indicated by the object index information of the object to be deleted in the first object information list), such as traversing the first object information list, comparing the msg.sender parameter and the userAddress parameter in the first object information list, and taking the position of the userAddress parameter that is the same as the msg.sender parameter as the information deletion position (i.e., the above findIndex parameter), and then, move the object information after the information deletion position in the first object information list forward by one row. At this time, the object information in the first object information list that was originally in the information deletion position is now in the last row of the first object information list, and delete the object information corresponding to the last row in the first object information list to realize the execution of the transaction of deleting the object.
[0124] It can be understood that the above process completes the process of deleting the object information from the indicated sub-contract (i.e., the process of deleting it from the contract status data associated with the indicated sub-contract). Due to the adoption of the data sharding idea, each sub-contract configured on a sub-node can store the object information of the object, so that the object information of the entire object is dispersed to each sub-contract, which greatly reduces the number of moves of the object information originally stored in the object information list, and can improve the efficiency of deleting the object information of the object. In theory, the business execution efficiency can be increased by multiples of the contractNumber parameter value.
[0125] For example, Fig. 9 As shown, Fig. 9A processing process of a business transaction provided by an embodiment of the present application; wherein, a client submits a transaction to delete an object (such as a transaction to delete a first object), and the management node calls the DeleteUser function in the management contract to execute the transaction to delete the object. Specifically, the transaction execution parameters are parsed and a corresponding execution request is generated. At the same time, the routing information is determined based on the contract routing policy in the DeleteUser function, and the execution request is sent to the child node indicated by the routing information. The indicated child node calls the deleteUser function in the child contract to parse the transaction execution parameters (the object index information of the object to be deleted) from the execution request, and determines the information deletion position from the first object information list according to the transaction execution parameters, that is, the object information corresponding to the information deletion position needs to be deleted, that is, the object information after the information deletion position in the first object information list is moved forward by one row, and the object information of the last row in the first object information list at this time (such as the first object information 2) is deleted, that is, it can be understood that the object information corresponding to the information deletion position is deleted in the contract status data associated with the child contract configured on the indicated child node, that is, the object information at the position indicated by the object index information of the object to be deleted in the object information library is deleted.
[0126] Among them, for the transaction of obtaining an object (i.e., Part 5 and Part 10 above), the transaction of obtaining an object may refer to obtaining the full amount of object information in the second object information list. The specific process may be that the client initiates a transaction to obtain an object. When the management node receives the transaction to obtain an object, it calls the GetAllUser function in the management contract (i.e., the code example corresponding to Part 5 above) to execute the following logic: traverse all sub-contracts to obtain the address information of the sub-contract (i.e., the address information of the sub-node that configures the sub-contract), and construct a sub-contract structure for obtaining object information, generate a transaction information pull request corresponding to the sub-contract structure, and send the transaction information pull request to each managed sub-node. Each sub-node will call the getAllUser function in the sub-contract (i.e., the code example corresponding to Part 10 above) to execute the following logic: query the full amount of object information from the second object information list according to the sub-contract structure in the transaction information pull request. Subsequently, the management node can receive the full object information returned by each child node. The full object information returned by each child node is an object information list, that is, the second object information stored is obtained from the contract status data associated with each child contract. The management node can use a multi-way merge sorting method to sort the object information list returned by each child node, obtain a complete full object information, and implement the execution of the transaction to obtain the object. The idea of data sharding and merge sorting can improve the efficiency of object information acquisition and sorting.
[0127] For example, Fig.10As shown, Fig.10 A processing process for a business transaction provided in an embodiment of the present application; wherein, ① the client submits a full transaction query request, which includes a transaction for obtaining an object (such as a transaction for obtaining a second object); ② the management node calls the GetAllUser function in the management contract to execute the transaction for obtaining the object, which may specifically be to generate a transaction information pull request and send the transaction information pull request to each child node; ③ each child node calls the getAllUser function in the child contract, obtains all second object information (i.e., execution result information) from the second object information list based on the transaction information pull request, and returns it to the management node; ④ the management node may merge and sort all second object information obtained from each child node to obtain the full object information, and return the full object information to the client.
[0128] Therefore, the present application provides a sub-contract management method that supports a custom contract routing strategy, specifically, through the mode of management contract and sub-contract matching, a corresponding contract routing strategy is formulated, so that business transactions can be dispersed to each sub-contract for processing, and the data related to the business transaction can be routed to the appropriate sub-contract for storage, so as to achieve the goal of uniform data storage, and improve the transaction processing performance from the level of business contracts. In addition, the management contract is used as a unified entry for object calls, which can shield the object's perception of changes in the blockchain business system and keep the object's usage habits unchanged. At the same time, a contract status data storage method based on data sharding is provided, specifically, through multiple sub-contracts to uniformly store the contract status data originally stored by a smart contract, and implement the corresponding addition, deletion, modification, and query operations on the contract status data in the sub-contract; since the sub-contract stores less contract status data, the efficiency of operations such as insertion and deletion is greatly improved; at the same time, it is easy to maintain the orderly arrangement of the contract status data in the sub-contract, and perform operations such as aggregation and merging sorting in the management contract to improve the efficiency of data acquisition and sorting.
[0129] In the embodiment of the present application, the business transaction to be processed by the management contract can be received, the management contract can be called based on the configured contract routing strategy, the routing information of the business transaction can be obtained, the transaction execution parameters can be parsed from the business transaction, and the execution request of the business transaction can be generated based on the transaction execution parameters, and the execution request can be sent to the subnode indicated by the routing information, so that the indicated subnode can call the configured subcontract and execute the business transaction based on the execution request. Through the above method, multiple business transactions can be assigned to different subnodes for processing, thereby realizing data sharding in the blockchain network, and the number of transactions processed by a single subnode (i.e., blockchain node) can be reduced, and the amount of data stored can be reduced. There is no need for each blockchain node to execute the same large-scale business transactions, so that the blockchain network can reduce the transaction load occupied by the blockchain network due to processing a large number of business transactions when carrying massive business data (i.e., data related to business transactions), and reduce the transaction congestion on the blockchain node, improve the transaction processing efficiency, and then improve the performance of the blockchain node in processing business transactions; in addition, through the contract routing strategy, a large number of business transactions can be distributed to each subnode as evenly as possible, so as to achieve the purpose of uniform storage of business data, that is, the transaction load balancing of the blockchain nodes in the blockchain network can be achieved.
[0130] For further information, see Fig.11 , Fig.11 Schematic diagram of a data processing device for a blockchain network provided in an embodiment of the present application. Fig.11 As shown, the data processing device 1 of the blockchain network can be applied to a cloud function computing node. For example, the cloud function computing node can be the above-mentioned Figure 1 The device node 100a in the corresponding embodiment. It should be understood that the data processing device 1 of the blockchain network can be a computer program (including program code) running in the cloud function computing node. For example, the data processing device 1 of the blockchain network can be an application software; it can be understood that the data processing device 1 of the blockchain network can be used to execute the corresponding steps of the method provided in the embodiment of the present application. Fig.11 As shown, the data processing device 1 of the blockchain network may include: a receiving module 11, a calling module 12 and a processing module 13; wherein:
[0131] A receiving module 11, used for receiving business transactions to be processed by the management contract;
[0132] The calling module 12 is used to call the management contract based on the configured contract routing strategy to obtain the routing information of the business transaction; the routing information is used to indicate the sub-node that processes the business transaction;
[0133] The processing module 13 is used to send the business transaction to the sub-node indicated by the routing information among the multiple sub-nodes, so that the indicated sub-node calls the configured sub-contract to execute the business transaction.
[0134] In some embodiments, the contract routing strategy includes a strategy for routing based on the number of subcontracts created by the management contract and identification information of an initiating object of the business transaction;
[0135] The calling module 12 is used to call the management contract based on the configured contract routing strategy to obtain the routing information of the business transaction, specifically for:
[0136] Call the management contract to parse the object's identification information from the business transaction, and call the management contract to obtain the number of sub-contracts created;
[0137] Perform a modulo calculation on the value of the identification information of the initiating object and the number of sub-contracts created to obtain the routing information;
[0138] The routing information is used to indicate the identification information of the corresponding sub-node.
[0139] In some embodiments, the contract routing policy includes a policy for routing based on the number of subcontracts created by the management contract and the total number of transactions processed by the management contract;
[0140] The calling module 12 is used to call the management contract based on the configured contract routing strategy to obtain the routing information of the business transaction, specifically for:
[0141] Call the management contract to obtain the total number of transactions processed by the management contract and the number of sub-contracts created;
[0142] Perform a modulo calculation on the total quantity and the number of sub-contracts created to obtain the routing information;
[0143] The routing information is used to indicate the identification information of the corresponding sub-node.
[0144] In some embodiments, when the processing module 13 is used to send the business transaction to the sub-node indicated by the routing information among the multiple sub-nodes, it is specifically used to:
[0145] Parsing transaction execution parameters from the business transaction, and generating an execution request for the business transaction based on the transaction execution parameters;
[0146] The execution request is sent to the subnode indicated by the routing information, so that the indicated subnode calls the configured subcontract to parse the transaction execution parameters from the execution request, and executes the business transaction based on the parsed transaction execution parameters.
[0147] In some embodiments, if the business transaction is a transaction for adding a first object, the transaction execution parameter includes object information of the first object, and after the business transaction is executed by the indicated child node calling the configured child contract, the object information of the first object is stored in the object information library of the indicated child node;
[0148] If the business transaction is a transaction for adding a second object, the transaction execution parameter includes the object information of the second object, the object information of the second object includes the object index information of the second object, and after the business transaction is executed by calling the configured sub-contract by the indicated sub-node, the object information of the second object is inserted and stored in the object information library at the position indicated by the object index information of the second object;
[0149] If the business transaction is a transaction to delete an object, the transaction execution parameters include the object index information of the object to be deleted. After the business transaction is executed by the indicated sub-node calling the configured sub-contract, the object information at the position indicated by the object index information of the object to be deleted in the object information library is deleted.
[0150] In some embodiments, after the business transaction is executed by the indicated sub-node calling the configured sub-contract, the execution result information of the business transaction is stored in the indicated sub-node;
[0151] The processing module 13 is also used for:
[0152] If a full transaction query request is received from the client, a transaction information pull request is sent to each of the multiple child nodes;
[0153] Receive the execution result information of the executed full transaction sent by each child node based on the transaction information pull request;
[0154] The execution result information received from multiple child nodes is returned to the client.
[0155] In some embodiments, there are N management nodes, the N management nodes belong to N consensus nodes, the method is applied to any one of the N consensus nodes, N is a positive integer, each consensus node manages multiple child nodes, each consensus node is used to receive the transaction result returned by the respective child node indicated by the routing information after executing the business transaction, and the N consensus nodes are used to perform consensus processing on the business transaction based on the transaction results of the respective child nodes for the business transaction;
[0156] Among them, if the business transaction is approved by consensus of N consensus nodes, the business transaction will be uploaded to the blockchain network.
[0157] According to one embodiment of the present application, Fig.10The various modules in the data processing device of the blockchain network shown can be separately or completely combined into one or several other modules to constitute, or one (some) of the modules can be further divided into multiple smaller modules in function to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above modules are divided based on logical functions. In practical applications, the functions of one module can also be implemented by multiple modules, or the functions of multiple modules can be implemented by one module. In other embodiments of the present application, the data processing device of the blockchain network may also include other modules. In practical applications, these functions can also be implemented with the assistance of other modules, and can be implemented by the collaboration of multiple modules.
[0158] According to another embodiment of the present application, the program can be executed by running on a general computing device such as a computer including a central processing unit (CPU), a random access memory medium (RAM), a read-only memory medium (ROM) and other processing elements and storage elements. Figure 3 and Figure 4 A computer program (including program code) for each step involved in the corresponding method shown in FIG. Fig.10 The data processing device of the blockchain network shown in the figure, and the data processing method of the blockchain network to implement the embodiment of the present application. The computer program can be recorded on, for example, a computer-readable recording medium, and loaded into the above-mentioned computing device through the computer-readable recording medium, and run therein.
[0159] In the embodiment of the present application, the receiving module receives the business transaction to be processed by the management contract; the calling module calls the management contract based on the configured contract routing strategy to obtain the routing information of the business transaction; the processing module sends the business transaction to the subnode indicated by the routing information in the multiple subnodes, so that the indicated subnode calls the configured subcontract to execute the business transaction. Through the above device, multiple business transactions can be assigned to different subnodes for processing, thereby realizing data sharding in the blockchain network, which can reduce the number of transactions processed by a single subnode (i.e., blockchain node) and the amount of data stored, without each blockchain node executing the same large batch of business transactions, so that the blockchain network can reduce the transaction load occupied by the blockchain network due to processing a large number of business transactions when carrying massive business data (i.e., data related to business transactions), and reduce the transaction congestion on the blockchain node, improve the transaction processing efficiency, and then improve the performance of the blockchain node in processing business transactions; in addition, through the contract routing strategy, a large number of business transactions can be distributed to each subnode as evenly as possible, so as to achieve the purpose of uniform storage of business data, that is, the transaction load balancing of the blockchain nodes in the blockchain network can be achieved.
[0160] Each functional module in each embodiment of the present application can be integrated into one module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules, which is not limited in the present application.
[0161] For further information, see Fig.12 , Fig.12 Schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.12 As shown, the electronic device 1200 can be a user terminal or a server, which will not be limited here. It is understandable that the electronic device can be the above-mentioned management node. For ease of understanding, this application takes the electronic device as a server as an example, and the electronic device 1200 may include: a processor 1201, a network interface 1204 and a memory 1205. In addition, the electronic device 1200 may also include: a user interface 1203, and at least one communication bus 1202. Among them, the communication bus 1202 is used to realize the connection communication between these components.
[0162] Among them, the user interface 1203 may also include a standard wired interface and a wireless interface. The network interface 1204 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1205 may include a volatile memory, such as a random-access memory (RAM); the memory 1205 may also include a non-volatile memory, such as a flash memory, a solid-state drive (SSD), etc.; the memory 1205 may also include a combination of two or more of the above-mentioned types of memory. The memory 1205 may optionally be at least one storage device located away from the aforementioned processor 1201. The memory 1205 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a device control application. The processor 1201 may be a central processing unit (CPU). In one embodiment, the processor 1201 may also be a graphics processing unit (GPU). The processor 1201 may also be a combination of a CPU and a GPU.
[0163] The network interface 1204 in the electronic device 1200 can also provide a network communication function. Fig.12In the electronic device 1200 shown, the network interface 1204 can provide a network communication function; the user interface 1203 is mainly used to provide an input interface for the user; and the processor 1201 can be used to call the device control application stored in the memory 1205 to execute the above Figure 3 and Figure 4 The description of the data processing method of the blockchain network in the corresponding embodiment can also be performed as described above. Fig.11 The description of the data processing device of the blockchain network (i.e., the data processing device 1 of the blockchain network) in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of using the same method will not be repeated.
[0164] In some embodiments, the memory 1205 is used to store program instructions, and the processor 1201 can call the program instructions to perform the following steps:
[0165] Receive pending business transactions from management contracts;
[0166] Call the management contract based on the configured contract routing strategy to obtain the routing information of the business transaction; the routing information is used to indicate the sub-node that processes the business transaction;
[0167] The business transaction is sent to the sub-node indicated by the routing information among multiple sub-nodes, so that the indicated sub-node calls the configured sub-contract to execute the business transaction.
[0168] In some embodiments, the contract routing strategy includes a strategy for routing based on the number of subcontracts created by the management contract and identification information of an initiating object of the business transaction;
[0169] When the processor 1201 is used to call the management contract based on the configured contract routing strategy to obtain the routing information of the business transaction, it is specifically used to:
[0170] Call the management contract to parse the object's identification information from the business transaction, and call the management contract to obtain the number of sub-contracts created;
[0171] Perform a modulo calculation on the value of the identification information of the initiating object and the number of sub-contracts created to obtain the routing information;
[0172] The routing information is used to indicate the identification information of the corresponding sub-node.
[0173] In some embodiments, the contract routing policy includes a policy for routing based on the number of subcontracts created by the management contract and the total number of transactions processed by the management contract;
[0174] When the processor 1201 is used to call the management contract based on the configured contract routing strategy to obtain the routing information of the business transaction, it is specifically used to:
[0175] Call the management contract to obtain the total number of transactions processed by the management contract and the number of sub-contracts created;
[0176] Perform a modulo calculation on the total quantity and the number of sub-contracts created to obtain the routing information;
[0177] The routing information is used to indicate the identification information of the corresponding sub-node.
[0178] In some embodiments, when the processor 1201 is used to send the business transaction to the sub-node indicated by the routing information among the multiple sub-nodes, it is specifically used to:
[0179] Parsing transaction execution parameters from the business transaction, and generating an execution request for the business transaction based on the transaction execution parameters;
[0180] The execution request is sent to the subnode indicated by the routing information, so that the indicated subnode calls the configured subcontract to parse the transaction execution parameters from the execution request, and executes the business transaction based on the parsed transaction execution parameters.
[0181] In some embodiments, if the business transaction is a transaction for adding a first object, the transaction execution parameter includes object information of the first object, and after the business transaction is executed by the indicated child node calling the configured child contract, the object information of the first object is stored in the object information library of the indicated child node;
[0182] If the business transaction is a transaction for adding a second object, the transaction execution parameter includes the object information of the second object, the object information of the second object includes the object index information of the second object, and after the business transaction is executed by calling the configured sub-contract by the indicated sub-node, the object information of the second object is inserted and stored in the object information library at the position indicated by the object index information of the second object;
[0183] If the business transaction is a transaction to delete an object, the transaction execution parameters include the object index information of the object to be deleted. After the business transaction is executed by the indicated sub-node calling the configured sub-contract, the object information at the position indicated by the object index information of the object to be deleted in the object information library is deleted.
[0184] In some embodiments, after the business transaction is executed by the indicated sub-node calling the configured sub-contract, the execution result information of the business transaction is stored in the indicated sub-node;
[0185] The processor 1201 is further configured to:
[0186] If a full transaction query request is received from the client, a transaction information pull request is sent to each of the multiple child nodes;
[0187] Receive the execution result information of the executed full transaction sent by each child node based on the transaction information pull request;
[0188] The execution result information received from multiple child nodes is returned to the client.
[0189] In some embodiments, there are N management nodes, the N management nodes belong to N consensus nodes, the method is applied to any one of the N consensus nodes, N is a positive integer, each consensus node manages multiple child nodes, each consensus node is used to receive the transaction result returned by the respective child node indicated by the routing information after executing the business transaction, and the N consensus nodes are used to perform consensus processing on the business transaction based on the transaction results of the respective child nodes for the business transaction;
[0190] Among them, if the business transaction is approved by consensus of N consensus nodes, the business transaction will be uploaded to the blockchain network.
[0191] In addition, it should be pointed out here that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program executed by the data processing device 1 of the blockchain network mentioned above, and the computer program includes computer instructions. When the processor executes the computer instructions, it can execute the above-mentioned Figure 3 and Figure 4 The description of the data processing method of the blockchain network in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application. As an example, computer instructions can be deployed on a computing device for execution, or on multiple computing devices located at one location, or on multiple computing devices distributed at multiple locations and interconnected by a communication network. Multiple computing devices distributed at multiple locations and interconnected by a communication network can constitute a blockchain system.
[0192] In addition, it should be noted that: the embodiment of the present application also provides a computer program product or a computer program, which may include computer instructions, and the computer instructions may be stored in a computer-readable storage medium. The processor of the electronic device reads the computer instructions from the computer-readable storage medium, and the processor may execute the computer instructions so that the electronic device performs the above Figure 3 or Figure 4The description of the data processing method of the blockchain network in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. For technical details not disclosed in the computer program product or computer program embodiment involved in this application, please refer to the description of the method embodiment of this application.
[0193] It should be noted that, for the above-mentioned various method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0194] The term "multiple" as used herein refers to two or more than two. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.
[0195] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0196] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in accordance with the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted via a computer-readable storage medium.
[0197] Computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. Computer-readable storage media can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. Available media can be magnetic media (e.g., floppy disks, hard disks, tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
[0198] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A data processing method for a blockchain network, characterized in that: The blockchain network includes a management node and a plurality of subnodes managed by the management node, the management node is configured with a management contract, each subnode managed by the management node is respectively configured with a subcontract of the management contract, and the method is applied to the management node; the method includes: Receiving pending business transactions of the management contract; Calling the management contract based on the configured contract routing strategy to obtain routing information of the business transaction; the routing information is used to indicate the sub-node that processes the business transaction; The business transaction is sent to the subnode indicated by the routing information among the multiple subnodes, so that the indicated subnode calls the configured subcontract to execute the business transaction.
2. The method according to claim 1, characterized in that The contract routing strategy includes a strategy for routing based on the number of sub-contracts created by the management contract and the identification information of the initiating object of the business transaction; The calling of the management contract based on the configured contract routing strategy to obtain the routing information of the business transaction includes: Calling the management contract to parse the identification information of the object from the business transaction, and calling the management contract to obtain the number of created sub-contracts; Performing a modulo calculation on the value of the identification information of the initiating object and the number of sub-contracts created to obtain the routing information; The routing information is used to indicate the identification information of the corresponding sub-node.
3. The method according to claim 1, characterized in that: The contract routing strategy includes a strategy for routing based on the number of subcontracts created by the management contract and the total number of transactions processed by the management contract; The calling of the management contract based on the configured contract routing strategy to obtain the routing information of the business transaction includes: Calling the management contract to obtain the total number of transactions processed by the management contract and the number of sub-contracts created; Performing a modulo calculation on the total quantity and the quantity of created sub-contracts to obtain the routing information; The routing information is used to indicate the identification information of the corresponding sub-node.
4. The method according to claim 1, characterized in that: The sending the business transaction to the sub-node indicated by the routing information among the multiple sub-nodes includes: Parsing transaction execution parameters from the business transaction, and generating an execution request for the business transaction based on the transaction execution parameters; The execution request is sent to the subnode indicated by the routing information, so that the indicated subnode calls the configured subcontract to parse the transaction execution parameters from the execution request, and executes the business transaction based on the parsed transaction execution parameters.
5. The method according to claim 4, characterized in that If the business transaction is a transaction for adding a first object, the transaction execution parameter includes the object information of the first object, and after the business transaction is executed by calling the configured sub-contract by the indicated sub-node, the object information of the first object is stored in the object information library of the indicated sub-node; If the business transaction is a transaction for adding a second object, the transaction execution parameter includes the object information of the second object, the object information of the second object includes the object index information of the second object, and after the business transaction is executed by the sub-contract configured by the indicated sub-node calling, the object information of the second object is inserted and stored in the position indicated by the object index information of the second object in the object information library; If the business transaction is a transaction for deleting an object, the transaction execution parameters include object index information of the object to be deleted. After the business transaction is executed by the sub-contract configured by the indicated sub-node calling, the object information at the position indicated by the object index information of the object to be deleted in the object information library is deleted.
6. The method according to claim 1, characterized in that After the business transaction is executed by calling the configured sub-contract by the indicated sub-node, the execution result information of the business transaction is stored in the indicated sub-node; The method further comprises: If a full transaction query request is received from the client, a transaction information pull request is sent to each of the multiple subnodes; Receiving execution result information of the executed full transaction sent by each of the child nodes based on the transaction information pull request; The received execution result information sent by the multiple child nodes is returned to the client.
7. The method according to claim 1, characterized in that There are N management nodes, and the N management nodes belong to N consensus nodes. The method is applied to any one of the N consensus nodes, where N is a positive integer. Each consensus node manages the plurality of child nodes, and each consensus node is used to receive a transaction result returned by a child node indicated by the routing information after executing the business transaction. The N consensus nodes are used to perform consensus processing on the business transaction based on the transaction result of the child node for the business transaction; Among them, if the business transaction is approved by consensus by the N consensus nodes, the business transaction is uploaded to the blockchain network.
8. A data processing device for a blockchain network, characterized in that: The blockchain network includes a management node and a plurality of subnodes managed by the management node, the management node is configured with a management contract, each subnode managed by the management node is respectively configured with a subcontract of the management contract, and the device runs on the management node; the device includes: A receiving module, used to receive the business transaction to be processed by the management contract; A calling module, used to call the management contract based on the configured contract routing strategy to obtain routing information of the business transaction; the routing information is used to indicate the sub-node that processes the business transaction; A processing module is used to send the business transaction to the sub-node indicated by the routing information among the multiple sub-nodes, so that the indicated sub-node calls the configured sub-contract to execute the business transaction.
9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 7.
11. A computer program product, characterized in that The computer program product comprises computer instructions, and when the computer instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.
