Transaction processing method and device based on block chain, and computer equipment
By determining the close relationship between the hash value of the target computing resource and the contract hash value in the blockchain system, the transaction processing efficiency problem caused by overloading of computing resources is solved, and load balancing and efficient transaction processing are achieved.
Patent Information
- Application Number
- CN202311444296.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-31
- Publication Date
- 2025-05-02
AI Technical Summary
When blockchain nodes process transactions, they often overload certain computing resources while other computing resources are in idle state, resulting in limited overall processing efficiency.
By receiving a transaction request, the target contract method identification is obtained, the set to which the target contract method identification belongs, and the target computing resource is determined from the set based on the set. The hash value of the computing resource and the contract hash value meet the distance proximity condition, and the transaction request is allocated to the computing resource for processing.
It realizes load balancing allocation of transaction requests, improves transaction processing efficiency of blockchain system, and maximizes multiplexed caches, further improving processing efficiency.
Smart Images

Figure CN119917251A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cross-blockchain technology, and in particular to a transaction processing method, apparatus, computer equipment, storage medium and computer program product based on blockchain. Background Art
[0002] With the development of computer technology, blockchain technology has emerged. Blockchain technology is a distributed ledger technology in the field of information technology. It is generally composed of consensus, transaction blocks and state data storage, cryptographic identity security, etc. Since the ledger is distributed and the blocks are agreed upon, it has the characteristics of being tamper-proof, traceable, and jointly maintained. Blockchain nodes are the basic components of the entire blockchain system, responsible for processing transactions, storing blockchain data, participating in consensus, etc.
[0003] In the related technology, after receiving a transaction request, a blockchain node can allocate the transaction to computing resources. However, when allocating transactions, some computing resources are often overloaded while other computing resources are idle, resulting in the overall transaction processing efficiency being limited by the processing capacity of the overloaded resources. Summary of the invention
[0004] Based on this, it is necessary to provide a blockchain-based transaction processing method, device, computer equipment, computer-readable storage medium and computer program product to address the above-mentioned technical problems, so as to improve the transaction processing efficiency of the blockchain system.
[0005] In a first aspect, the present application provides a transaction processing method based on blockchain. The method comprises:
[0006] Receive a transaction request, and obtain a target contract method identifier indicated by the transaction request, wherein the target contract method identifier indicates a target contract method of a target contract;
[0007] Determine the target contract method identifier set to which the target contract method identifier belongs;
[0008] Determine a target computing resource from a computing resource set according to the target contract method identification set, wherein, in a hash value sequence formed by a hash value domain, a target computing resource hash value determined according to the attribute information of the target computing resource and a target contract hash value corresponding to the target contract method identification set satisfy a distance proximity condition;
[0009] Allocate the transaction request to the target computing resource to instruct the target computing resource to call the target contract method of the target contract to process the transaction request and obtain a transaction processing result;
[0010] Obtain the transaction processing result, and upload the transaction to the blockchain based on the transaction processing result.
[0011] In a second aspect, the present application also provides a transaction processing device based on blockchain. The device includes:
[0012] A transaction request receiving module, configured to receive a transaction request and obtain a target contract method identifier indicated by the transaction request, wherein the target contract method identifier indicates a target contract method of a target contract;
[0013] A contract method identifier set determination module, used to determine a target contract method identifier set to which the target contract method identifier belongs;
[0014] a target computing resource determination module, configured to determine a target computing resource from a computing resource set according to the target contract method identification set, wherein, in a hash value sequence formed by a hash value value domain, a target computing resource hash value determined according to the attribute information of the target computing resource and a target contract hash value corresponding to the target contract method identification set satisfy a distance proximity condition;
[0015] A transaction request allocation module, used to allocate the transaction request to the target computing resource, so as to instruct the target computing resource to call the target contract method of the target contract to process the transaction request and obtain a transaction processing result;
[0016] The transaction processing result chain module is used to obtain the transaction processing result and chain the transaction processing result to the blockchain.
[0017] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0018] Receive a transaction request, and obtain a target contract method identifier indicated by the transaction request, wherein the target contract method identifier indicates a target contract method of a target contract;
[0019] Determine the target contract method identifier set to which the target contract method identifier belongs;
[0020] Determine a target computing resource from a computing resource set according to the target contract method identification set, wherein, in a hash value sequence formed by a hash value domain, a target computing resource hash value determined according to the attribute information of the target computing resource and a target contract hash value corresponding to the target contract method identification set satisfy a distance proximity condition;
[0021] Allocate the transaction request to the target computing resource to instruct the target computing resource to call the target contract method of the target contract to process the transaction request and obtain a transaction processing result;
[0022] Obtain the transaction processing result, and upload the transaction to the blockchain based on the transaction processing result.
[0023] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0024] Receive a transaction request, and obtain a target contract method identifier indicated by the transaction request, wherein the target contract method identifier indicates a target contract method of a target contract;
[0025] Determine the target contract method identifier set to which the target contract method identifier belongs;
[0026] Determine a target computing resource from a computing resource set according to the target contract method identification set, wherein, in a hash value sequence formed by a hash value domain, a target computing resource hash value determined according to the attribute information of the target computing resource and a target contract hash value corresponding to the target contract method identification set satisfy a distance proximity condition;
[0027] Allocate the transaction request to the target computing resource to instruct the target computing resource to call the target contract method of the target contract to process the transaction request and obtain a transaction processing result;
[0028] Obtain the transaction processing result, and upload the transaction to the blockchain based on the transaction processing result.
[0029] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0030] Receive a transaction request, and obtain a target contract method identifier indicated by the transaction request, wherein the target contract method identifier indicates a target contract method of a target contract;
[0031] Determine the target contract method identifier set to which the target contract method identifier belongs;
[0032] Determine a target computing resource from a computing resource set according to the target contract method identification set, wherein, in a hash value sequence formed by a hash value domain, a target computing resource hash value determined according to the attribute information of the target computing resource and a target contract hash value corresponding to the target contract method identification set satisfy a distance proximity condition;
[0033] Allocate the transaction request to the target computing resource to instruct the target computing resource to call the target contract method of the target contract to process the transaction request and obtain a transaction processing result;
[0034] Obtain the transaction processing result, and upload the transaction to the blockchain based on the transaction processing result.
[0035] The above-mentioned blockchain-based transaction processing method, device, computer equipment, storage medium and computer program product can obtain the target contract method identifier indicated by the transaction request after receiving the transaction request, the target contract method identifier indicates the target contract method of the target contract, further determine the target contract method identifier set to which the target contract method identifier belongs, determine the target computing resource from the computing resource set according to the target contract method identifier set, allocate the transaction request to the target computing resource, so as to instruct the target computing resource to call the target contract method of the target contract to process the transaction request, obtain the transaction processing result, finally obtain the transaction processing result, and upload the transaction to the blockchain based on the transaction processing result. In the process of determining the target computing resource, since in the hash value sequence composed of the hash value value domain, the target computing resource hash value determined according to the attribute information of the target computing resource and the target contract hash value corresponding to the target contract method identifier set meet the distance proximity condition, the transaction request can be dispersed to different computing resources in the computing resource set to achieve load balancing, thereby improving the overall processing efficiency of the transaction, and since the method set in the contract is also considered in the allocation process, the contract can be executed on different computing resources, thereby maximizing the reuse of the cache, further improving the transaction processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A schematic diagram of the architecture based on the blockchain system in some embodiments;
[0037] Figure 2 A schematic diagram of a blockchain-based structure in some embodiments;
[0038] Figure 3 A schematic diagram of the process of generating and uploading blocks to the blockchain in some embodiments;
[0039] Figure 4 It is an application environment diagram of a transaction processing method based on blockchain in some embodiments;
[0040] Figure 5 A flowchart of a transaction processing method based on blockchain in some embodiments;
[0041] Figure 6 A schematic diagram of an allocation architecture of computing resources in some embodiments;
[0042] Figure 7is a schematic diagram of a hash ring in some embodiments;
[0043] Figure 8 A flowchart of smart contract deployment steps in some embodiments;
[0044] Fig. 9 A schematic diagram of allocating computing resources through a hash ring in some embodiments;
[0045] Fig.10 A schematic diagram of the structure of a fission tree of a contract method set in some embodiments;
[0046] Fig.11 A diagram of the system architecture involved in transaction processing in some embodiments;
[0047] Fig.12 A schematic diagram of a consistent hashing smart contract creation process in some embodiments;
[0048] Fig.13 A schematic diagram of a consistent hash transaction call flow in some embodiments;
[0049] Fig.14 A schematic diagram of the process of fission and merging consistent hash contract transactions in some embodiments;
[0050] Fig.15 It is a structural block diagram of a transaction processing device based on blockchain in some embodiments;
[0051] Fig.16 is an internal structure diagram of a computer device in some embodiments;
[0052] Fig.17 1 is a diagram of the internal structure of a computer device in some other embodiments. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0054] The blockchain-based transaction processing method provided in the embodiment of the present application can be executed by a node in the blockchain system. Figure 1The blockchain system 100 includes a plurality of blockchain nodes 101. Each blockchain node 101 can receive input information during normal operation and maintain the shared data in the blockchain system based on the received input information. In order to ensure information intercommunication within the blockchain system, information connections can exist between each node in the blockchain system, and information can be transmitted between nodes through the above information connections. For example, when any node in the blockchain system receives input information, other nodes in the blockchain system obtain the input information according to the consensus algorithm, and store the input information as data in the shared data, so that the data stored on all nodes in the blockchain system are consistent.
[0055] Each node in the blockchain system has a corresponding node identifier, and each node in the blockchain system can store the node identifiers of other nodes in the blockchain system, so that the generated blocks can be broadcast to other nodes in the blockchain system according to the node identifiers of other nodes. Each node can maintain a node identifier list as shown in the following table, and store the node name and node identifier in the node identifier list accordingly. Among them, the node identifier can be an IP (Internet Protocol, a protocol for interconnecting networks) address and any other information that can be used to identify the node. Table 1 only uses the IP address as an example for illustration.
[0056] Table 1
[0057] Node Name Node ID Node 1 XXX.XXX.XXX.XXX Node 2 XXX.XXX.XXX.XXX … … Node N XXX.XXX.XXX.XXX
[0058] Each node in the blockchain system stores the same blockchain. The blockchain consists of multiple blocks, see Figure 2 The blockchain consists of multiple blocks. The genesis block includes a block header and a block body. The block header stores the input information characteristic value, version number, timestamp and difficulty value, and the block body stores the input information; the next block of the genesis block takes the genesis block as the parent block, and the next block also includes a block header and a block body. The block header stores the input information characteristic value of the current block, the block header characteristic value, version number, timestamp and difficulty value of the parent block, and so on, so that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, ensuring the security of the input information in the block.
[0059] When generating each block in the blockchain, see Figure 3When the node where the blockchain is located receives the input information, it verifies the input information. After the verification is completed, the input information is stored in the memory pool and the hash tree used to record the input information is updated. After that, the update timestamp is updated to the time when the input information is received, and different random numbers are tried to calculate the eigenvalue multiple times so that the calculated eigenvalue can satisfy the following formula:
[0060] SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x))<TARGET
[0061] Among them, SHA256 is the eigenvalue algorithm used to calculate the eigenvalue; version (version number) is the version information of the relevant block protocol in the blockchain; prev_hash is the block header eigenvalue of the parent block of the current block; merkle_root is the eigenvalue of the input information; ntime is the update time of the update timestamp; nbits is the current difficulty, which is a fixed value within a period of time and is determined again after exceeding the fixed time period; x is a random number; TARGET is the eigenvalue threshold, which can be determined based on nbits.
[0062] In this way, when the random number that satisfies the above formula is calculated, the information can be stored accordingly, the block header and block body can be generated, and the current block can be obtained. Subsequently, the node where the blockchain is located sends the newly generated block to other nodes in the blockchain system where it is located according to the node identification of other nodes in the blockchain system. Other nodes verify the newly generated block and add the newly generated block to the blockchain stored in it after the verification is completed, so as to realize the blockchain chain.
[0063] The resource processing method provided in the embodiment of the present application can be applied to Figure 4In the application environment shown. Among them, the blockchain node 404 in the blockchain system communicates with the user terminal 402 through the network, and the blockchain node 404 also communicates with the computing resource 406 in the computing resource set through the network. The blockchain node 404 receives the transaction request, obtains the target contract method identifier indicated by the transaction request, the target contract method identifier indicates the target contract method, determines the target contract method identifier set to which the target contract method identifier belongs, and determines the target computing resource from the computing resource set according to the target contract method identifier set, wherein, in the hash value sequence composed of the hash value value domain, the target computing resource hash value determined according to the attribute information of the target computing resource, and the target contract hash value corresponding to the target contract method identifier set meet the distance proximity condition, and the transaction request is allocated to the target computing resource to instruct the target computing resource to call the target contract method of the target contract to process the transaction request, and obtain the transaction processing result. The blockchain node can further be chained on the blockchain based on the transaction processing result.
[0064] Among them, the blockchain node 404 can be a terminal or a server. The terminal or user terminal of the blockchain node can be, but is not limited to, various desktop computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server of the blockchain node can be implemented by an independent server or a server cluster composed of multiple servers. The computing resource 406 can be an independent server, a node in a distributed cluster, or a cloud server.
[0065] Understandably, Figure 4 The application environment shown is not intended to limit the present application. In some other embodiments, there may be one or more shared nodes between the blockchain system and the computing resource set. Multiple refers to at least two.
[0066] The embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, etc.
[0067] In some embodiments, Figure 5 As shown, a transaction processing method based on blockchain is provided, and the method is applied to Figure 5 Taking the blockchain node 404 in the example as an example, the following steps are included:
[0068] Step 502, receiving a transaction request, and obtaining a target contract method identifier indicated by the transaction request, wherein the target contract method identifier indicates a target contract method of a target contract.
[0069] Among them, the transaction request can be a request to call a method in a smart contract, and calling a method in a smart contract can be understood as a transaction that calls a contract. Smart contract is a protocol defined in digital form and needs to run in a trusted environment, such as a blockchain platform. It is transmitted, verified or executed in an information-based manner, read and executed by a computer, and has the characteristics of self-service. The decentralization of blockchain and the tamper-proof nature of data determine that smart contracts are more suitable for implementation on blockchain. Smart contracts include at least one variable and a contract method (function). The contract methods in smart contracts are mainly divided into two types according to their functions, one is read-only and the other is modification. The read-only method will not modify any variables of the contract, but will only query the variables on the contract or do some simple data statistics. This method has no transaction hash after the request, and will directly return the request result, and no miner fee is required. The modification method means that the variable needs to be modified. This type of method needs to generate a transaction hash first and then package it into the transaction queue for execution. This will charge a miner fee. The contract method also has a keyword to configure whether additional payment of the main currency is required to call this method. Contract methods can also specify broadcast events, that is, when someone calls this method and it is successfully executed, it will be broadcast outward with parameters.
[0070] Specifically, after receiving the transaction request sent by the user terminal, the blockchain node can parse the transaction request and obtain the parameters carried in the transaction request. The parameters carried in the transaction request may include a contract method identifier, so that the blockchain node can obtain the target contract method identifier indicated by the transaction request, and the target contract method identifier indicates the target contract method of the target contract, which is the contract method requested to be called by the transaction request, and the target contract is the smart contract to which the contract method requested to be called by the transaction request belongs. The target contract method is used to uniquely identify a contract method. Optionally, the target contract method identifier may be the method name of the target contract method.
[0071] In some specific embodiments, the target contract method may be a contract method with parameters, that is, the contract method needs to pass in parameters for calling, and the transaction request may also carry the contract method parameters of the contract method.
[0072] In some specific embodiments, the target contract method may be a parameterless contract method, that is, the contract method does not require input parameters for calling, and thus the contract method parameters do not need to be carried in the transaction request.
[0073] In some specific embodiments, the transaction request may also carry the contract identifier of the target contract, so that the contract method can be accurately called during the transaction request processing. The contract identifier is used to uniquely identify a smart contract, and optionally, the contract identifier may be the contract name.
[0074] In some specific embodiments, after receiving a transaction request, the blockchain node may also perform integer and signature verification on the transaction request. Only transaction requests that pass the verification will be allocated computing resources.
[0075] In some specific embodiments, after receiving a transaction request, the blockchain node may also perform permission verification on the transaction request. Only transaction requests that pass the permission verification will be allocated computing resources.
[0076] Step 504, determine the target contract method identifier set to which the target contract method identifier belongs.
[0077] It can be understood that a smart contract can usually include multiple contract methods, which can be deployed on the same computing resource or on different computing resources. Contract methods deployed on the same computing resource and belonging to the same smart contract constitute a contract method set. For example, assuming that a smart contract includes 10 contract methods, of which contract methods 1 to 5 are deployed on computing resource 1, and contract methods 6 to 10 are deployed on computing resource 2, then contract methods 1 to 5 constitute contract method set 1 corresponding to the smart contract, and contract methods 6 to 10 constitute contract method set 2 corresponding to the smart contract, that is, the smart contract corresponds to two contract method sets. Each contract method in a contract method set has a contract method identifier, and the contract method identifier set can refer to the set composed of the contract method identifiers of all contract methods in a contract method set corresponding to a smart contract. That is to say, a contract method set can correspond to a contract method identifier set. For example, the contract method identifiers of each contract method in the above-mentioned contract method set 1 can constitute the contract method identifier set corresponding to the contract method set 1, and the contract method identifiers of each contract method in the contract method set 2 can constitute the contract method identifier set 2 corresponding to the contract method set 2.
[0078] Specifically, after obtaining the target contract method identifier indicated by the transaction request, the blockchain node can determine the target contract method identifier set to which the target contract method identifier belongs. Determining the target contract method identifier set to which the target contract method identifier belongs is equivalent to determining the contract method set to which the target contract method belongs.
[0079] In some embodiments, the correspondence between the contract identifier of each deployed smart contract and the contract method identifier corresponding to the smart contract can be stored in a contract method data table, so that the blockchain node can query the contract method data table to determine the target contract method identifier set to which the target contract method identifier belongs.
[0080] refer to Figure 6, contract 1 service-part1 is started on computing resource 1, contract 1 service-part2 is started on computing resource 2, contract 2 service is also started on computing resource 1, contract 3 service is also started on computing resource 2, contract 4 service and contract 5 service are started on computing resource 3. It can be seen that each computing resource can start multiple contract services, each contract can start multiple instances on the same computing resource for concurrent execution, and each contract can be started separately on different computing resources. Since the key-value pairs involved in a method are relatively similar, this application can be divided by method, and the methods involved in a contract are divided into multiple method sets. Different method sets can be deployed on different computing resources, so that the cache in contract calculation can be reused as much as possible.
[0081] Step 506, determine the target computing resource from the computing resource set according to the target contract method identification set, wherein, in the hash value sequence composed of the hash value value domain, the target computing resource hash value determined according to the attribute information of the target computing resource and the target contract hash value corresponding to the target contract method identification set meet the distance proximity condition.
[0082] Among them, the hash value domain can be understood as the range of hash value values. For example, SHA256 represents a 256-bit hash, and the hash value domain is [0, 2^256-1]. The hash value sequence can be formed by arranging the hash values in the hash value domain according to certain rules. In specific applications, the hash value sequence can be formed by arranging the hash values in the hash value domain from small to large or from large to small. The hash value sequence can be specifically represented in the form of a hash ring. The attribute information of the computing resource refers to the information used to describe the attributes of the computing resource, such as ip (Internet Protocol Address) or a unique host name. The computing resource hash value is obtained by mapping the attribute information of the computing resource to the hash value domain. The contract hash value is obtained by mapping the identification information of the smart contract to which the contract method identified by the target contract method identification set belongs to the hash value domain. The target computing resource hash value is the computing resource hash value corresponding to the target computing resource. The target contract hash value is the contract hash value corresponding to the target contract method identification set. The target computing resource hash value and the target contract hash value meet the proximity condition, which can be that the target computing resource hash value and the target contract hash value are close in the hash value sequence composed of the hash value range. Optionally, the target computing resource hash value can be the computing resource hash value that is closest to the target contract hash value in the preset numerical change direction of the hash value sequence.
[0083] Specifically, the blockchain node can determine the computing resource hash value based on the target contract method identification set, and determine the target computing resource from the computing resource set based on the computing resource hash value.
[0084] In some embodiments, each computing resource in the computing resource set is mapped to a hash value domain according to its respective attribute information to obtain its respective computing resource hash value. The blockchain node can determine the corresponding target contract hash value according to the target contract method identification set, and determine the computing resource hash value that meets the distance proximity condition with the target contract hash value from the hash value sequence composed of the hash value domain, use the computing resource hash value as the target computing resource hash value, and determine the computing resource mapped to the target computing resource hash value as the target computing resource.
[0085] In some other embodiments, in the process of deploying each smart contract, the contract hash value corresponding to each smart contract can be calculated according to the contract identification information of each smart contract, and then the computing resource hash value that satisfies the distance proximity condition with each contract hash value is found from the hash value sequence composed of the hash value value domain, and then the contract identification, contract identification set and computing resource hash value are stored in the contract method data table accordingly, and then in the process of processing the transaction request, after determining the target contract method identification set, the contract method data table can be searched to obtain the computing resource hash value corresponding to the target contract method identification set, and then the target computing resource can be determined according to the computing resource hash value. Among them, if all the contract methods of a smart contract are deployed on the same computing resource, the contract hash value corresponding to the smart contract is obtained by mapping the contract identification information of the smart contract to the hash value value domain. If the contract method of a smart contract is deployed on multiple different computing resources, then for the contract method set deployed on each computing resource, the contract hash value of the smart contract corresponding to the contract method set can be determined according to the contract identification information of the smart contract and the set identification of the contract method set. For example, assume that the computing resource set has 3 smart contracts deployed, among which contract 1 contains 10 contract methods, contract methods 1-5 are deployed on computing resource 1, contract methods 6-10 are deployed on computing resource 2, all contract methods included in contract 2 are deployed on computing resource 3, and all contract methods included in contract 3 are deployed on computing resource 4. The computing resource hash values of computing resource 1, computing resource 2, computing resource 3 and computing resource 4 are 0y1, 0y2, 0y3 and 0y4 respectively. The contract method data table can be found in Table 2.
[0086] Table 2
[0087] Contract Name method Calculate resource hash value Contract 1 Set 1 (Methods 1-5) 0y1 Contract 1 Set 2 (Methods 6-10) 0y2 Contract 2 Complete 0y3 Contract 3 Complete 0y4
[0088] It is understandable that when the contract method set deployed by each smart contract on the computing resources changes, the blockchain node can update the contract method data table according to the changed contract method set.
[0089] Step 508, allocate the transaction request to the target computing resource to instruct the target computing resource to call the target contract method of the target contract to process the transaction request and obtain the transaction processing result.
[0090] Specifically, the blockchain node can allocate the transaction request to the target computing resource. After receiving the transaction request, the target computing resource parses the transaction request and obtains the target contract method identifier indicated by the transaction request. According to the target contract method identifier, the target contract method indicated by the transaction request can be determined, thereby calling the target contract method to execute the transaction indicated by the transaction request. When the transaction is successfully executed, the transaction processing result is obtained. The transaction processing result may include: whether the transaction execution is successful, status data, contract log, events and other information. The computing resource can return the transaction execution result to the blockchain node.
[0091] Step 510, obtain the transaction processing result, and upload the transaction to the blockchain based on the transaction processing result.
[0092] Specifically, blockchain nodes can obtain transaction processing results obtained by executing transactions with computing resources, then package the transaction processing results into blocks and send them to other blockchain nodes for consensus. After the consensus is passed, the blocks are uploaded to the blockchain.
[0093] In the above-mentioned blockchain-based transaction processing method, after receiving a transaction request, the target contract method identifier indicated by the transaction request can be obtained, the target contract method identifier indicates the target contract method of the target contract, and the target contract method identifier set to which the target contract method identifier belongs is further determined. According to the target contract method identifier set, the target computing resource is determined from the computing resource set, and the transaction request is allocated to the target computing resource to instruct the target computing resource to call the target contract method of the target contract to process the transaction request and obtain the transaction processing result. Finally, the transaction processing result is obtained, and the blockchain is uploaded based on the transaction processing result. In the process of determining the target computing resource, since in the hash value sequence composed of the hash value value domain, the target computing resource hash value determined according to the attribute information of the target computing resource and the target contract hash value corresponding to the target contract method identifier set meet the distance proximity condition, the transaction request can be dispersed to different computing resources in the computing resource set to achieve load balancing, thereby improving the overall processing efficiency of the transaction, and since the method set in the contract is also considered in the allocation process, the contract can be executed on different computing resources, thereby maximizing the reuse of the cache and further improving the transaction processing efficiency.
[0094] In some embodiments, a target computing resource is determined from a computing resource set based on a target contract method identification set, including: obtaining a target contract hash value corresponding to the target contract method identification set; determining a computing resource hash value that satisfies a distance proximity condition with the target contract hash value from the hash value sequence based on the position of the target contract hash value in the hash value sequence, and using the determined computing resource hash value as the target computing resource hash value; determining the target computing resource from the computing resource set based on the target computing resource hash value.
[0095] Among them, the target contract hash value corresponding to the target contract method identification set is determined according to the contract identification information of the smart contract to which the contract method identified by the target contract method identification set belongs. Optionally, if all the contract methods of a smart contract are deployed on the same computing resource, the contract hash value corresponding to the smart contract is obtained by mapping the contract identification information of the smart contract to the hash value domain. If the contract method of a smart contract is deployed on multiple different computing resources, then for the contract method set deployed on each computing resource, the contract hash value of the smart contract corresponding to the contract method set can be jointly determined based on the contract identification information of the smart contract and the set identification of the contract method set.
[0096] Specifically, the blockchain node can obtain the target contract hash value corresponding to the target contract method identification set, determine the position of the target contract hash value in the hash value sequence, and then determine the computing resource hash value that meets the distance proximity condition with the target contract hash value from the hash value sequence, use the determined computing resource hash value as the target computing resource hash value, and determine the target computing resource from the computing resource set according to the target computing resource hash value.
[0097] Exemplarily, the transaction request also carries a contract identifier, and the blockchain node also stores the correspondence between the contract identifier and each contract method identifier set. The blockchain node can determine the target contract method identifier set to which the target contract method identifier belongs based on the contract identifier and the target contract method identifier carried in the transaction request. If the set is an identifier set that uniquely corresponds to the smart contract identified by the contract identifier, the corresponding contract hash value is calculated based on the contract identifier information of the smart contract. If the set is not an identifier set that uniquely corresponds to the smart contract identified by the contract identifier, the corresponding contract hash value can be calculated based on the contract identifier information of the smart contract and the set identifier of the set.
[0098] In the above embodiment, by obtaining the target contract hash value corresponding to the target contract method identification set, and determining the target computing resource hash value that meets the distance proximity condition from the hash value sequence according to the position of the target contract hash value in the hash value sequence, load balancing and high concurrency processing capabilities can be better achieved.
[0099] In some embodiments, the transaction request carries the contract identifier of the target contract, and the target contract method identifier set to which the target contract method identifier belongs is obtained by querying from a contract method data table that stores the correspondence between the contract identifier and the contract method identifier set based on the contract identifier and the contract method identifier. The contract method data table also stores a contract hash value corresponding to the contract method identifier set; obtaining the target contract hash value corresponding to the target contract method identifier set includes: querying the corresponding contract hash value from the contract method data table based on the target contract method identifier set, and obtaining the target contract hash value corresponding to the target contract method identifier set.
[0100] In this embodiment, the contract data table stores the correspondence between the contract identifier, the contract method identifier set, and the contract hash value. If all the contract methods of a smart contract are deployed on the same computing resource, the contract hash value corresponding to the smart contract is obtained by mapping the contract identifier information of the smart contract to the hash value domain. If the contract method of a smart contract is deployed on multiple different computing resources, then for the contract method set deployed on each computing resource, the contract hash value of the smart contract corresponding to the contract method set can be determined based on the contract identifier information of the smart contract and the set identifier of the contract method set. For example, assume that there are 3 smart contracts deployed in the computing resource set, among which contract 1 contains 10 contract methods, contract methods 1 to 5 are deployed on computing resource 1, contract methods 6 to 10 are deployed on computing resource 2, all contract methods contained in contract 2 are deployed on computing resource 3, and all contract methods contained in contract 3 are deployed on computing resource 4. The contract hash value of contract 1 corresponding to set 1 is calculated according to the contract identification information of contract 1 and the collection identification of set 1, which is 0x1. The contract hash value of contract 1 corresponding to set 2 is calculated according to the contract identification information of contract 1 and the collection identification of set 2, which is 0x2. The contract hash values of contract 2 and contract 3 are calculated according to their respective contract identification information. The contract method data table can be found in Table 3.
[0101] Table 3
[0102] Contract Name method Contract hash value Contract 1 Set 1 (Methods 1-5) 0x1 Contract 1 Set 2 (Methods 6-10) 0x2 Contract 2 Complete 0x3 Contract 3 Complete 0x4
[0103] Specifically, the blockchain node can also obtain the contract identifier of the target contract from the transaction request, query the contract identifier of the target contract from the contract method data table, and then determine at least one contract method identifier set corresponding to the contract identifier, and compare the target contract method identifier with each contract method identifier set to determine the target contract method identifier set to which the target contract method identifier belongs, and then query the contract hash value corresponding to the target contract method identifier set from the contract data table to obtain the target contract hash value corresponding to the target contract method identifier set.
[0104] In this embodiment, by storing the correspondence between the contract identifier, the contract method identifier and the contract hash value in the contract data table, the target contract method identifier set to which the target contract method identifier belongs can be quickly determined by querying the contract data table, and then the contract hash value can be quickly queried from the contract data table according to the target contract method identifier set, thereby improving the processing efficiency of transaction requests.
[0105] In some embodiments, the hash value sequence is represented by a hash ring, and each computing resource in the computing resource set corresponds to multiple computing resource hash values on the hash ring. The multiple computing resource hash values corresponding to each computing resource are obtained by adding different numbers to the attribute information corresponding to each computing resource and then performing hash calculation on the attribute information with the added numbers.
[0106] The hash ring is also called a consistent hash ring, which means that the hash value sequence composed of the hash value range is represented in the form of a ring, and the hash values in the hash value sequence are distributed on the ring as nodes on the ring. Figure 7 , assuming that the hash value range is [0, 2^32-1], the hash ring can be as follows Figure 7 As shown, A-01, B-01, C-01, A-02, B-02, C-02, A-03, B-03, and C-03 are nodes on the hash ring respectively, and each node represents a hash value in the hash value range.
[0107] Specifically, in this embodiment, each computing resource corresponds to multiple computing resource hash values on the hash ring, and each computing resource hash value can be regarded as a virtual node of the computing resource, so that the computing resources can be more evenly distributed on the hash ring, avoiding a large amount of data being concentrated on one node and a small amount of data being concentrated on another node. In specific applications, the number of virtual nodes associated with each physical node can be determined first, and then a number can be added after the IP or host name, and then three virtual nodes can be calculated for each server, and the hash values of "Node A#1", "Node A#2", "Node A#3", "Node B#1", "Node B#2", and "Node B#3" are calculated respectively, thereby forming six virtual nodes.
[0108] The above embodiment introduces the processing process of the blockchain-based transaction processing method provided by the embodiment of the present application after receiving a transaction request. In the above embodiment, the transaction processing is implemented based on the successful deployment of the smart contract on the computing resources. In the following embodiment, the specific implementation steps of the deployment of the smart contract in this application will be introduced.
[0109] In some embodiments, the blockchain-based transaction processing method provided by the present application also includes a smart contract deployment step, referring to Figure 8 , the smart contract deployment steps include:
[0110] Step 802: Receive a smart contract deployment request, where the contract deployment request carries the contract identification information of the smart contract to be deployed.
[0111] The contract identification information is used to identify the smart contract. For example, the contract identification information of a smart contract may be the contract identification of the smart contract plus the version number.
[0112] Specifically, the user can write the smart contract source code through the user terminal, carry the contract source code and contract identification information in the smart contract deployment request, and the user terminal sends the smart contract deployment request to the blockchain node. After receiving the smart contract deployment request, the blockchain node can parse the smart contract deployment request and obtain the contract identification information and contract source code carried therein. The smart contract deployment request can be regarded as a transaction for deploying a contract.
[0113] In some specific embodiments, after receiving a smart contract deployment request, the blockchain node may also perform integer and signature verification on the smart contract deployment request. Only smart contract deployment requests that pass the verification will be allocated computing resources.
[0114] In some specific embodiments, after receiving a smart contract deployment request, the blockchain node may also perform a permission check on the smart contract deployment request. Only smart contract deployment requests that pass the permission check will be allocated computing resources.
[0115] Step 804: Determine the contract hash value corresponding to the smart contract to be deployed based on the contract identification information.
[0116] Specifically, the blockchain node can perform hash calculation on the contract identification information, map the contract identification information to a hash value sequence consisting of a value domain, and obtain the contract hash value corresponding to the smart contract to be deployed.
[0117] Step 806: Determine, from the hash value sequence, a computing resource hash value whose contract hash value corresponding to the smart contract to be deployed satisfies the distance proximity condition.
[0118] Step 808: Send a smart contract deployment request to the computing resource corresponding to the determined computing resource hash value to instruct the computing resource corresponding to the determined computing resource hash value to deploy the smart contract.
[0119] Specifically, the blockchain node can determine from the hash value sequence the computing resource hash value whose contract hash value corresponding to the smart contract to be deployed satisfies the distance proximity condition, and send the smart contract deployment request to the computing resource corresponding to the computing resource hash value. After receiving the smart contract deployment request, the computing resource parses the deployment request, obtains the contract source code carried therein, and then can deploy the smart contract based on the contract source code.
[0120] Furthermore, after the smart contract is successfully deployed, the computing resources can return feedback information of successful deployment to the blockchain node. After receiving the feedback information of successful deployment, the blockchain node can package the data carried in the smart contract deployment request into a block and send it to other nodes for consensus. After the consensus is passed, the block will be uploaded to the blockchain.
[0121] It can be understood that in this embodiment, when the smart contract is deployed, all methods of a smart contract are deployed on the same computing resource. In some other embodiments, when the user sends a smart contract deployment request through the terminal, the contract methods contained in the smart contract to be deployed can be divided into multiple contract method sets, and then the blockchain node can deploy the contract methods of the smart contract to be deployed on multiple computing resources, so that the load in the computing resource set is more balanced, thereby better handling high-concurrency transaction requests.
[0122] In the above embodiment, after receiving the smart contract deployment request, the contract hash value corresponding to the smart contract to be deployed can be determined according to the contract identification information carried therein, and then the computing resource hash value that satisfies the distance proximity condition with the contract hash value corresponding to the smart contract to be deployed is determined from the hash value sequence, and the smart contract is deployed to the computing resource corresponding to the computing resource hash value. This allows the smart contract to be deployed in a dispersed manner on various computing resources to achieve load balancing, and when computing resources increase or decrease, the smart contract can be better migrated to avoid bottlenecks or unstable services during the migration process.
[0123] In some embodiments, a hash value sequence is represented by a hash ring, and a computing resource hash value whose contract hash value corresponding to the smart contract to be deployed satisfies a distance proximity condition is determined from the hash value sequence, including: determining the position of the contract hash value corresponding to the smart contract to be deployed in the hash ring; in the hash ring, searching for the computing resource hash value closest to the position corresponding to the smart contract to be deployed, and obtaining the computing resource hash value whose contract hash value corresponding to the smart contract to be deployed satisfies the distance proximity condition.
[0124] Specifically, the blockchain node can determine the position of the contract hash value corresponding to the smart contract to be deployed in the hash ring, and then search the hash value of the computing resource closest to the position clockwise in the hash ring. The computing resource hash value is the computing resource hash value that meets the distance proximity condition with the contract hash value corresponding to the smart contract to be deployed.
[0125] For example, see Fig. 9 , Fig. 9 The hash ring in the figure represents a 256-bit hash. The hash ring starts at 0 and ends at 2^256-1. Each computing resource has multiple points in the ring. For example, computing resource 1 corresponds to Fig. 9 Node 1 and computing resource 2 in Fig. 9 Node 2 and computing resource 3 in Fig. 9 Node 3 in the diagram. When a blockchain node receives a contract deployment transaction, it determines the hash value of the contract method set it contains, and then finds the location corresponding to the hash value on the hash ring. The computing resource closest to the location is the computing resource to be allocated and calculated for this transaction. Fig. 9 , where the arrow indicates the computing resources deployed by the contract. Fig. 9 It can be seen that the hash value of contract 1-part1 is closest to the hash value of computing resource 1, so contract 1-part1 can be deployed on computing resource 1, and the hash value of contract 1-part2 and the hash value of contract 3 are closest to the hash value of computing resource 2, so contract 1-part2 and contract 3 can be deployed on computing resource 2.
[0126] In the above embodiment, in the hash ring, the computing resource hash value closest to the position corresponding to the smart contract to be deployed is searched, so as to obtain the computing resource hash value whose contract hash value corresponding to the smart contract to be deployed satisfies the distance proximity condition, so that the smart contract can be evenly deployed in each computing resource set to achieve load balancing.
[0127] It is understandable that during the deployment process of the smart contract of the present application, the contract method set can be dynamically split and merged according to the pressure of computing resources. This helps to avoid the waste of computing resources while ensuring that computing resources are fully utilized. Through the dynamic adjustment of the contract method set, the cache can be reused to the maximum extent, further improving the execution efficiency. The fission of the contract method set can refer to Fig.10 In the fission tree structure shown, each branch represents the allocation of a part of the method to another computing resource for execution. The allocation process tries to even out the computing pressure. After the allocation, the current hash value calculation method remains unchanged, and the split is recalculated. The leaf node represents the hash status of the computing resource currently in use. For example, Fig.10After the contract 1-part1 is split into contract 1-part1-1 and contract 1-part1-2, the contract hash value corresponding to contract 1-part1-1 is still the contract hash value corresponding to the original contract 1-part1, and the contract hash value corresponding to contract 1-part1-2 is recalculated based on contract 1-part1-2, which can be specifically calculated based on the contract identification information of the smart contract to which contract 1-part1-2 belongs and the collection identification of contract 1-part1-2. The implementation process of contract method fission and merging will be specifically introduced in the following embodiments.
[0128] In some embodiments, the blockchain-based transaction processing method of the present application also includes the following steps: when there are computing resources that meet the load migration conditions in the computing resource set, determining a first target contract method set that meets the fission conditions from at least one contract method set deployed on the computing resources that meet the load migration conditions, wherein the contract methods in the same contract method set belong to the same smart contract; splitting the first target contract method set to obtain at least two contract method subsets; migrating at least a portion of the at least two contract method subsets to other computing resources.
[0129] Among them, the load migration condition may be that the resource utilization rate of the computing resource is greater than a preset threshold value, and the preset threshold value can be set as needed, for example, it may be at least one of the CPU utilization rate of the computing resource being greater than 80% or the memory occupancy rate being greater than 80%. The fission condition may be that the total call frequency of the contract method set within a preset period is greater than the preset frequency threshold, or the total call frequency of the contract method set within the preset period is ranked before the preset threshold in the total call frequency of all contract method sets of the computing resource that meets the load migration condition. Exemplarily, the fission condition may be that the total call frequency of the contract method set within the preset period is the largest among all contract method sets deployed on the computing resource that meets the load migration condition. The total call frequency value of the contract method set can be obtained by statistically analyzing the call frequency of each contract method in the contract method set.
[0130] Specifically, the blockchain node can periodically traverse each computing resource in the computing resource set, access each computing resource, and determine whether the computing resource meets the load migration condition each time it traverses to a computing resource. When the traversed computing resource meets the load migration condition, the first target contract method set that meets the fission condition can be determined from at least one contract method set deployed on the computing resource, and then the first target contract method set is split, so that the first target contract method set is split into at least two contract method subsets. Exemplarily, the blockchain node can randomly divide the contract methods in the first target contract method set into multiple contract method subsets. In some other embodiments, the blockchain node can also obtain the calling frequency of each contract method in the first target contract method set, and split the first target contract method set according to the calling frequency of each contract method. For example, the contract method with a larger calling frequency can be split into a contract method subset, and the contract method subset is determined as the target contract method subset to be migrated, so as to reduce the computing pressure of the current computing resources as much as possible.
[0131] Furthermore, the blockchain node may migrate at least a portion of the method subsets of at least two contract method subsets to other computing resources, so that these method subsets can be deployed on other computing resources to reduce the computing pressure on the computing resources where the first target contract method set is located.
[0132] In some embodiments, at least a portion of at least two contract method subsets are migrated to other computing resources, including: determining a target contract method subset to be migrated from at least two contract method subsets; determining a contract hash value corresponding to the target contract method subset based on the contract identifier of the smart contract to which the target contract method subset belongs and the set identifier of the target contract method subset; determining a computing resource hash value that meets a distance proximity condition from the hash value sequence based on the position of the contract hash value corresponding to the target contract method subset in the hash value sequence; and migrating the target contract method subset to the computing resource corresponding to the determined computing resource hash value.
[0133] Specifically, the blockchain node can determine the target contract method subset to be migrated from the at least two contract method subsets obtained by splitting. Exemplarily, if the call frequencies corresponding to the contract method subsets obtained by splitting are close, the blockchain node can determine any one of the contract method subsets as the target contract method subset to be migrated.
[0134] The blockchain node can further re-perform the contract hash calculation based on the contract identifier of the smart contract to which the target contract method subset belongs and the collection identifier of the target contract method subset, obtain the contract hash value corresponding to the target contract method subset, and then determine the position of the contract hash value in the hash value sequence composed of the hash value value domain, and determine the computing resource hash value closest to it from the hash value sequence according to the position of the contract hash value in the hash value sequence composed of the hash value value domain, and then send a contract deployment request to the computing resource corresponding to the computing resource hash value, so that the computing resource corresponding to the computing resource hash value deploys the target contract method subset and starts the contract service corresponding to the smart contract to which the target contract method subset belongs.
[0135] In the above embodiment, the contract method set that meets the fission conditions on the computing resources that meet the load migration conditions is split into multiple contract method subsets, and the contract method subset to be migrated is determined, and then the contract hash value corresponding to the contract method subset is recalculated. The contract method subset to be migrated is migrated according to the calculated contract hash value, which can avoid the computing resources from being affected by excessive computing pressure and affect the overall transaction processing performance, thereby improving transaction processing efficiency.
[0136] In some embodiments, the first target contract method set is split to obtain at least two contract method subsets, including: obtaining the call frequency corresponding to each contract method in the first target contract method set; splitting the first target contract method set into two contract method subsets according to the call frequency corresponding to each contract method; wherein the total call frequencies corresponding to the two contract method subsets obtained by the split satisfy a proximity condition, and the total call frequencies corresponding to the contract method subsets are obtained by counting the call frequencies of the included contract methods.
[0137] Among them, the total call frequencies corresponding to the two contract method subsets obtained by splitting meet the proximity condition, that is, the total call frequencies corresponding to the two contract method subsets are close in value. For example, assuming that the first target contract method set includes 3 contract methods, namely contract method 1, contract method 2 and contract method 3, and the call frequencies of these three contract methods in the current time period are 2w, 3w and 5w respectively, then contract method 1 and contract method 2 can be divided into a contract method subset, and contract method 3 can be divided into a separate contract method subset.
[0138] Specifically, when splitting the first target contract method set, the blockchain node can obtain the call frequency corresponding to each contract method in the first target contract method set, and then split the first target contract method set into two contract method subsets according to the call frequency corresponding to each contract method, so that the call frequency corresponding to the two contract method subsets obtained by splitting is
[0139] In the above embodiment, by obtaining the calling frequency corresponding to each contract method in the first target contract method set, the first target contract method set is split into two contract method subsets according to the calling frequency corresponding to each contract method, so that the computing pressure can be more evenly distributed, thereby making more effective use of computing resources.
[0140] The above embodiment introduces the fission of a contract method set. The following will introduce an optional implementation method of the merging process of a contract method set.
[0141] In some embodiments, the blockchain-based transaction processing method provided by the present application also includes: when there are computing resources that meet the load access conditions in the computing resource set, determining a second target contract method set that meets the merging conditions from at least one contract method set deployed on the computing resources that meet the load access conditions, wherein the contract methods in the same contract method set belong to the same smart contract; determining a contract method set to be merged from a contract method set deployed on other computing resources and belonging to the same smart contract as the second target contract method set; and merging the contract method set to be merged into the second target contract method set.
[0142] Among them, the load access condition may be that the resource utilization rate of the computing resource is less than a preset threshold value, and the preset threshold value can be set as needed, for example, it may be at least one of the CPU utilization rate of the computing resource is less than 20% or the memory occupancy rate is less than 20%. The merging condition may be that the total call frequency of the contract method set within the preset time period is less than the preset frequency threshold, or the total call frequency of the contract method set within the preset time period is ranked before the preset threshold in the total call frequency of all contract method sets of the computing resource that meets the load migration condition. Exemplarily, the fission condition may be that the total call frequency of the contract method set within the preset time period is the smallest among all contract method sets deployed on the computing resource that meets the load migration condition.
[0143] Specifically, the blockchain node can periodically traverse each computing resource in the computing resource set, access each computing resource, and determine whether the computing resource meets the load access condition for each traversed computing resource. When the traversed computing resource meets the load access condition, the second target contract method set that meets the merging condition is determined from at least one contract method set deployed on the traversed computing resource, and then the contract method set to be merged can be determined from the contract method set deployed on other computing resources and belonging to the same smart contract as the second target contract method set. Exemplarily, the contract method set to be merged can be a contract method set deployed on a computing resource with greater computing pressure among other computing resources.
[0144] The blockchain node can further send a contract deployment request to the computing resource that meets the load access conditions, so that the computing resource deploys the contract method set to be merged, thereby merging the contract method set to be merged with the second target contract method set that meets the merging conditions. At the same time, the blockchain node can also notify the computing resource that deploys the contract method set to be merged to stop its contract process resources after calculating the unfinished tasks.
[0145] In the above embodiment, by determining the contract method set to be merged and merging the contract method set to be merged into the second target contract method set deployed on the computing resources that meet the load access conditions, the waste of computing resources that meet the load access conditions can be avoided, thereby ensuring that the computing resources are fully utilized.
[0146] In some embodiments, a contract method set to be merged is determined from a contract method set deployed on other computing resources and belonging to the same smart contract as the second target contract method set, including: determining the target smart contract to which the second target contract method set belongs; determining the target computing resources on which multiple contract method sets corresponding to the target smart contract are respectively deployed; determining the computing resource with the greatest computing pressure from each target computing resource; and determining the contract method set corresponding to the target smart contract deployed in the computing resource with the greatest computing pressure as the contract method set to be merged.
[0147] The computing pressure of the computing resources can be determined by the resource utilization rate of the computing resources. The computing resource with the greatest computing pressure can be at least one of the computing resource with the greatest CPU utilization rate or the computing resource with the greatest memory occupancy rate.
[0148] Specifically, after determining the second target contract method set that meets the merging conditions, the blockchain node can determine the target smart contract to which the second target contract method set belongs, and then determine the target computing resources on which multiple contract method sets corresponding to the target smart contract are respectively deployed, and determine the computing resource with the greatest computing pressure from these target computing resources, and determine the contract method set deployed on the computing resource with the greatest computing pressure that belongs to the same smart contract as the second target contract method set as the contract method set to be merged.
[0149] In some embodiments, the correspondence between the contract identifier and the contract method identifier set can be stored in a contract data table. The blockchain node can determine the target smart contract to which the second target contract method set belongs by searching the contract data table, and determine other contract method sets corresponding to the target smart contract. After the merge is completed, the blockchain node can also update the contract method set.
[0150] In the above embodiment, by determining the contract method set deployed by the computing resources with the greatest pressure as the contract method set to be merged, while ensuring full utilization of computing resources, the computing pressure of other computing resources with greater computing pressure can be reduced as much as possible.
[0151] In some embodiments, the transaction request carries the contract identifier of the target contract, and the target contract method identifier set to which the target contract method identifier belongs is obtained by querying from a contract method data table that stores the correspondence between the contract identifier and the contract method identifier set based on the contract identifier and the contract method identifier; the method also includes: when the contract method set deployed on any computing resource in the computing resource set changes, updating the contract method data table according to the changed contract method set.
[0152] In this embodiment, the correspondence between the contract identifier and the contract method identifier set can be stored in the contract method data table. Optionally, the contract method data table can also store the contract hash value corresponding to the contract method identifier set. Optionally, the contract method data table can also store the computing resource hash value of the computing resource deployed by the corresponding contract method set. The change can include at least one of merging, fission or migration.
[0153] Specifically, when the contract method set deployed on any computing resource in the computing resource set changes, the blockchain node can update the correspondence between the contract identifier and the contract method identifier set in the contract method data table according to the changed contract method set. For example, when the contract method set 1 of smart contract A deployed on any computing resource in the computing resource set is merged with another contract method set 2, the correspondence between the contract identifier of smart contract A and the contract method identifier set corresponding to contract method set 1 can be deleted, and the contract method identifier contained in the contract method identifier set corresponding to contract method set 1 is added to the contract method identifier set corresponding to contract method set 2. For example, when the contract method set 1 of smart contract B deployed on any computing resource in the computing resource set is split into two contract method subsets, namely contract method subset 1 and contract method subset 2, a new correspondence between the contract identifier set of smart contract B and the contract method identifier set corresponding to contract method subset 2 can be created, and the contract method identifier corresponding to contract method subset 2 is deleted from the contract method identifier set corresponding to contract method set 1.
[0154] Optionally, if the contract method identification set also stores the correspondence between the contract method identification set and the contract hash value, then when the contract method set deployed on any computing resource in the computing resource set is fissioned, it is also necessary to create a correspondence between the contract method identification set corresponding to the contract method subset that is migrated to other computing resources after the fission and its corresponding contract hash value in the contract method data table. The contract hash value here can be calculated based on the contract identification and the set identification.
[0155] In the above embodiment, updating the contract method data table according to the changed contract method set can enable the contract method data table to save correct data, avoid errors when querying the contract method data table during transaction processing, and improve the accuracy of transaction processing.
[0156] In some specific embodiments, the present application also provides a transaction processing method based on blockchain, which realizes efficient concurrent processing, load balancing and flexible scalability of contract transactions by introducing a consistent hashing algorithm based on contract identifiers and method sets, thereby helping to improve the performance and availability of the blockchain system, reduce the waste of computing resources, and maximize the reuse of cache.
[0157] The following disadvantages exist in the related art: 1) Load imbalance: In the related art, when allocating computing tasks, some computing resources may be overloaded while other computing resources are idle. In this case, the overall computing efficiency is limited by the processing power of the overloaded resources, resulting in a decrease in system performance. 2) High data migration cost: When computing resources increase or decrease, the related art generally calculates the hash and then allocates it modulo the number of computing resources. This will cause all computing resources to reallocate data and tasks, which may result in a large amount of data and task migration. Data migration not only consumes a lot of time and bandwidth, but also invalidates the existing cache, and may also cause performance bottlenecks or unstable services in the system during the migration process. 3) Poor scalability: In the related art, when dealing with dynamic changes in resources, it is often necessary to manually adjust and optimize the entire system, which not only increases the operation and maintenance costs, but also may affect the stability of the system. In addition, due to the problems of load imbalance and high data migration costs, it may be difficult to achieve fast and smooth expansion in the face of large-scale concurrent requests in the related art.
[0158] The embodiment of the present application adopts a consistent hashing algorithm to allocate contract transactions to computing resources, realize load balancing and high concurrent processing capabilities, overcome the problem of load imbalance in traditional solutions, and improve overall computing efficiency. And in the embodiment of the present application, the consistent hashing algorithm is not only allocated according to the contract identifier (such as contract name, version, etc.), but also takes into account the method set in the contract (the same method usually reads and writes similar sets), so that the contract can be executed on different computing resources, thereby maximizing the reuse of cache and further improving execution efficiency. In the embodiment of the present application, due to the use of a consistent hashing algorithm, smooth resource reallocation can be achieved when computing resources increase or decrease, reducing data migration costs and improving system scalability. In addition, the embodiment of the present application can also dynamically fission and merge the contract method set according to the pressure size of the computing resources. This helps to avoid the waste of computing resources while ensuring that computing resources are fully utilized. Through the dynamic adjustment of the contract method set, the cache can be reused to the maximum extent, further improving execution efficiency.
[0159] It can be seen that the embodiments of the present application can solve the following problems: 1) Load balancing: The embodiments of the present application adopt a consistent hashing algorithm based on contract identification and method sets to allocate contract transactions to computing resources to achieve load balancing, thereby overcoming the problem of load imbalance in traditional solutions and improving overall computing efficiency. 2) High concurrent processing capabilities: This solution realizes concurrent processing of contract transactions, fully utilizes limited computing resources, and improves the throughput of the blockchain system. At the same time, by allocating contracts to different computing resources for execution, the cache can be reused to the maximum extent, further improving execution efficiency. 3) Dynamic resource adjustment: The embodiments of the present application can dynamically fission and merge contract method sets according to the pressure of computing resources, thereby avoiding waste of computing resources and ensuring that computing resources are fully utilized.
[0160] refer to Fig.11 , is a system architecture diagram of the present application example, which includes the network module, verification module, transaction pool module, scheduling execution module, consensus module and storage module of the blockchain node. The details are as follows:
[0161] Blockchain node: Blockchain node is the basic component of the entire blockchain system, responsible for processing transactions, storing blockchain data, participating in consensus, etc. Blockchain node consists of the following submodules:
[0162] 1. Network module: responsible for the communication between nodes, including the sending and receiving of data. The network module can realize the connection management between nodes, data transmission encryption, data broadcasting and other functions.
[0163] 2. Verification module: responsible for verifying transactions and blocks to ensure their legitimacy and correctness. The verification module includes the following sub-modules:
[0164] 1) Certificate Verification: Responsible for verifying the signatures of transactions and blocks to ensure that they are initiated by legitimate participants.
[0165] 2) Authority verification: responsible for checking whether the initiators of transactions and blocks have the corresponding authority to perform operations.
[0166] 3. Transaction pool module: responsible for managing pending transactions, including transaction reception, storage, sorting and other functions.
[0167] 4. Scheduling Execution Module: The scheduling execution module is responsible for allocating transactions to computing resources for concurrent processing. This module includes the following sub-modules:
[0168] 1) Block generator: Generates new blocks based on transactions in the transaction pool. This usually involves selecting appropriate transactions, calculating block hash values, generating block headers, etc.
[0169] 2) Contract method data table: stores the hash value of the contract method set for quick search and execution. This helps improve the efficiency of contract execution.
[0170] 3) Consistent hash calculator: Calculates the computing resources to which the transaction should be allocated based on the consistent hash algorithm. This helps to achieve load balancing in limited computing resources and improve computing efficiency.
[0171] 4) Consistent hash ring: stores computing resource nodes and is used to implement the consistent hash algorithm. The consistent hash ring can achieve smooth resource reallocation when computing resources increase or decrease, avoiding large amounts of data migration.
[0172] 5) Computing resource connection pool: manages available computing resource client connections.
[0173] 5. Consensus module: responsible for implementing the consensus algorithm of the blockchain system, including the following sub-modules:
[0174] 1) Block broadcast: responsible for broadcasting newly generated blocks to other nodes.
[0175] 2) Block verification: responsible for verifying the correctness of the received blocks and adding them to the blockchain.
[0176] 6. Storage module: responsible for storing blockchain data, including the following sub-modules:
[0177] 1) Blockchain ledger: responsible for storing block data in the blockchain.
[0178] 2) Status data: responsible for storing status information in the blockchain system, such as account balances, smart contract status, etc.
[0179] In addition, the allocation architecture of computing resources in this embodiment can refer to Figure 6 The contract method data table structure provided in this embodiment can refer to Table 3, and the computing resources allocated through the hash ring can refer to Fig. 9 , the fission tree structure of the contract method set can be referenced Fig.10 ,The above system architecture is the operating basis of the entire environment, which can ensure the efficient and stable operation of the system.
[0180] The embodiment of the present application also provides a full life cycle process of a blockchain computing resource load balancing solution based on consistent hashing, including a consistent hashing smart contract creation process, a consistent hashing transaction call process (a process in which the blockchain allocates transactions to computing resources and calls them based on consistent hashing calculations), and a consistent hashing contract transaction fission and merger process (a process in which a consistent hashing contract method set performs fission or merger to balance the computing pressure of each node when the computing pressure of the node is too large or too small). The details are as follows:
[0181] refer to Fig.12 , the consistent hashing smart contract creation process provided in this embodiment includes the following steps:
[0182] 1. Start.
[0183] 2. The user writes the smart contract source code locally.
[0184] 3. The user packages the above source code and contract initialization method parameters.
[0185] 4. The user signs the above packaged content.
[0186] 5. The user sends the above packaged content and signature to the blockchain node.
[0187] 6. The blockchain node network module receives the above request.
[0188] 7. The blockchain node authentication module verifies the certificate and signature of the above request. Is the verification successful? If yes, proceed to step 9, otherwise proceed to step 8.
[0189] 8. Return the result of signature verification failure and go to step 24.
[0190] 9. The authentication module verifies the permission of the request. If the verification is successful, go to step 11. Otherwise, go to step 10.
[0191] 10. Return the result of permission verification failure and go to step 24.
[0192] 11. The scheduling execution module packages the transaction of the new deployment contract in the new block.
[0193] 12. The scheduling execution module consistent hash calculator calculates the hash value of the contract identification information, such as the hash value of the contract name-contract version number.
[0194] 13. The scheduling execution module uses a consistent hash ring to query the computing resource node that is closest to the above hash value.
[0195] 14. The scheduling execution module starts the computing resource connection of the computing resource node in the computing resource connection pool and sends a request to install the contract.
[0196] 15. The computing resource checks the request signature and other specifications, and then begins executing the initialization transaction, which can be achieved by starting a process, container, or other means.
[0197] 16. Was the initialization transaction executed successfully? If yes, proceed to step 17; otherwise, proceed to step 18.
[0198] 17. Return the information that the blockchain node contract is successfully initialized, store the contract file, and go to step 19.
[0199] 18. Returns the error that the blockchain node contract initialization failed and stops the contract process or container.
[0200] 19. The result of blockchain node packaging contract initialization.
[0201] 20. The blockchain node stores the transaction in a block and sends it to all nodes for consensus through the consensus module.
[0202] 21. Is the consensus passed? If yes, proceed to step 22; otherwise, proceed to step 24.
[0203] 22. All nodes append the block to the blockchain ledger.
[0204] 23. All nodes update the data in the block to the status data, such as the latest results obtained by contract execution.
[0205] 24. The end.
[0206] refer to Fig.13 The consistent hashing transaction calling process provided for this implementation includes the following steps:
[0207] 1. Start.
[0208] 2. The user packages the contract name, contract method, and parameters that need to be called.
[0209] 3. The user signs the above packaged content.
[0210] 4. The user sends the above packaged content and signature to the blockchain node.
[0211] 5. The blockchain node network module receives the above request
[0212] 6. The blockchain node authentication module verifies the certificate and signature of the request. Is the verification successful? If yes, proceed to step 8, otherwise proceed to step 7.
[0213] 7. Return the result of signature verification failure and go to step 23.
[0214] 8. The authentication module verifies the permission of the request. If the verification is successful, go to step 10. Otherwise, go to step 9.
[0215] 9. Return the result of permission verification failure and go to step 23.
[0216] 10. The scheduling execution module packages the transaction of calling the contract in the new block.
[0217] 11. The scheduling execution module retrieves the contract method data table according to the contract name and contract method in the transaction, and obtains the contract hash value corresponding to the called contract and method.
[0218] 12. The scheduling execution module uses a consistent hash ring to query the computing resource node that is closest to the hash value of the above contract.
[0219] 13. The scheduling execution module starts the computing resource connection of the computing resource node in the computing resource connection pool and sends a request to call the contract.
[0220] 14. The computing resource checks the request signature and other specifications, and then starts executing the transaction, which can be achieved by starting a new process, container or reusing existing resources.
[0221] 15. Was the transaction successfully executed? If yes, proceed to step 16; otherwise, proceed to step 17.
[0222] 16. Return the information that the blockchain node call is successful and go to step 18.
[0223] 17. Returns the error of blockchain node call failure.
[0224] 18. Blockchain nodes package and execute the results of transactions.
[0225] 19. The blockchain node stores the transaction in a block and sends it to all nodes for consensus through the consensus module.
[0226] 20. Is the consensus passed? If yes, proceed to step 21; otherwise, proceed to step 23.
[0227] 21. All nodes append the block to the blockchain ledger.
[0228] 22. All nodes update the data in the block to the status data, such as the latest results obtained by contract execution.
[0229] 23. The end.
[0230] refer to Fig.14 , the consistent hash contract transaction fission and merging process provided for this implementation, when the computing pressure is too large or too small, the consistent hash contract method set is fissioned or merged to balance the computing pressure of each node, specifically including the following steps:
[0231] 1. Start.
[0232] 2. The scheduling execution module computing resource connection pool regularly accesses all computing resources.
[0233] 3. Is the computing pressure of the currently accessed computing resource too high? If yes, proceed to step 4; otherwise, proceed to step 8.
[0234] 4. Determine the set of contract methods with the highest computing pressure among the currently accessed computing resources.
[0235] 5. According to the calling frequency of all methods, evenly split the above methods into two sets.
[0236] 6. Keep the contract hash value of the contract method set in the original computing resources unchanged, and recalculate the contract hash value of the newly split contract method set.
[0237] 7. Update the contract method data table according to the changes of the above contract method set and contract hash value, and go to step 3.
[0238] 8. Is the computing pressure of the currently accessed computing resource too low? If yes, proceed to step 9; otherwise, proceed to step 14.
[0239] 9. Determine the set of contract methods with the lowest current computing pressure among the currently accessed computing resources.
[0240] 10. According to the contract method data table, determine all contract method sets that belong to the same smart contract as the contract method set with the lowest current computational pressure.
[0241] 11. Determine the computing resources with the greatest computing pressure from the computing resources deployed separately for all contract method sets.
[0242] 12. Merge the contract method set belonging to the above-mentioned smart contract in the above-mentioned computing resources into the above-mentioned contract method set with the least computing pressure.
[0243] 13. The blockchain node notifies the computing resource with the greatest computing pressure, calculates the unfinished tasks, stops its contract process resources, and proceeds to step 8.
[0244] 14. End.
[0245] In summary, the embodiments of the present application have significant advantages in terms of load balancing, concurrent processing capabilities, and dynamic resource adjustment, which helps to improve the performance and availability of the blockchain system, and can be widely reused in the industry.
[0246] The embodiments of the present application can be applied to distributed financial platforms. In distributed financial platforms, the blockchain-based transaction processing method provided by the embodiments of the present application can be used to achieve efficient concurrent processing of contract transactions and improve system throughput. For example, through load balancing and dynamic resource adjustment, it can ensure that financial contracts such as lending, trading, and cross-chain transfers can still be executed quickly and stably in high-concurrency scenarios.
[0247] The blockchain-based transaction processing method provided in the embodiment of the present application can also be applied to decentralized applications (DApp). In decentralized applications, smart contracts undertake the core business logic. Through the blockchain-based transaction processing method provided in the embodiment of the present application, a high-performance smart contract execution environment can be provided for DApp, supporting large-scale concurrent access by users and improving user experience.
[0248] The blockchain-based transaction processing method provided in the embodiment of the present application can also be applied to supply chain management. In the supply chain management scenario, the blockchain-based transaction processing method provided in the embodiment of the present application can be used to build an efficient smart contract to achieve real-time data sharing, transaction processing and asset monitoring among various participants. Through load balancing and dynamic resource adjustment, it is ensured that the contract can still be executed efficiently and stably in a complex supply chain network.
[0249] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0250] Based on the same inventive concept, the embodiment of the present application also provides a blockchain-based transaction processing device for implementing the blockchain-based transaction processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more blockchain-based transaction processing device embodiments provided below can refer to the limitations of the blockchain-based transaction processing method above, and will not be repeated here.
[0251] In some embodiments, Fig.15 As shown, a transaction processing device 1500 based on blockchain is provided, comprising:
[0252] The transaction request receiving module 1502 is used to receive the transaction request and obtain the target contract method identifier indicated by the transaction request, where the target contract method identifier indicates the target contract method of the target contract;
[0253] A contract method identifier set determination module 1504, used to determine a target contract method identifier set to which a target contract method identifier belongs;
[0254] The target computing resource determination module 1506 is used to determine the target computing resource from the computing resource set according to the target contract method identification set, wherein, in the hash value sequence formed by the hash value value domain, the target computing resource hash value determined according to the attribute information of the target computing resource and the target contract hash value corresponding to the target contract method identification set meet the distance proximity condition;
[0255] The transaction request allocation module 1508 is used to allocate the transaction request to the target computing resource to instruct the target computing resource to call the target contract method of the target contract to process the transaction request and obtain the transaction processing result;
[0256] The transaction processing result chain module 1510 is used to obtain the transaction processing result and chain the transaction processing result to the blockchain.
[0257] The above-mentioned blockchain-based transaction processing device, after receiving a transaction request, can obtain the target contract method identifier indicated by the transaction request, further determine the target contract method identifier set to which the target contract method identifier belongs, determine the target computing resource from the computing resource set according to the target contract method identifier set, and allocate the transaction request to the target computing resource to instruct the target computing resource to call the target contract method of the target contract to process the transaction request, obtain the transaction processing result, and finally upload the transaction to the blockchain based on the transaction processing result. Since in the hash value sequence composed of the hash value value domain, the target computing resource hash value determined according to the attribute information of the target computing resource and the target contract hash value corresponding to the target contract method identifier set meet the distance proximity condition, the transaction request can be dispersed to different computing resources in the computing resource set to achieve load balancing, thereby improving the overall processing efficiency of the transaction. Moreover, since the method set in the contract is also considered in the allocation process, the contract can be executed on different computing resources, thereby maximizing the reuse of the cache and further improving the transaction processing efficiency.
[0258] In some embodiments, a target computing resource determination module is used to obtain a target contract hash value corresponding to a target contract method identification set; based on the position of the target contract hash value in the hash value sequence, determine from the hash value sequence a computing resource hash value that satisfies a distance proximity condition with the target contract hash value, and use the determined computing resource hash value as the target computing resource hash value; based on the target computing resource hash value, determine the target computing resource from the computing resource set.
[0259] In some embodiments, the transaction request carries the contract identifier of the target contract, and the target contract method identifier set to which the target contract method identifier belongs is obtained by querying from a contract method data table that stores the correspondence between the contract identifier and the contract method identifier set based on the contract identifier and the contract method identifier. The contract method data table also stores the contract hash value corresponding to the contract method identifier set; the target computing resource determination module is used to query the corresponding contract hash value from the contract method data table based on the target contract method identifier set to obtain the target contract hash value corresponding to the target contract method identifier set.
[0260] In some embodiments, the hash value sequence is represented by a hash ring, and each computing resource in the computing resource set corresponds to multiple computing resource hash values on the hash ring. The multiple computing resource hash values corresponding to each computing resource are obtained by adding different numbers to the attribute information corresponding to each computing resource and then performing hash calculation on the attribute information with the added numbers.
[0261] In some embodiments, the above-mentioned device also includes: a contract deployment module, which is used to receive a smart contract deployment request, and the contract deployment request carries the contract identification information of the smart contract to be deployed; determine the contract hash value corresponding to the smart contract to be deployed according to the contract identification information; determine from the hash value sequence, the computing resource hash value that satisfies the distance proximity condition with the contract hash value corresponding to the smart contract to be deployed; send the smart contract deployment request to the computing resource corresponding to the determined computing resource hash value to instruct the computing resource corresponding to the determined computing resource hash value to deploy the smart contract.
[0262] In some embodiments, the hash value sequence is represented by a hash ring, and the contract deployment module is used to determine the position of the contract hash value corresponding to the smart contract to be deployed in the hash ring; in the hash ring, find the computing resource hash value closest to the position corresponding to the smart contract to be deployed, and obtain the computing resource hash value that satisfies the distance proximity condition with the contract hash value corresponding to the smart contract to be deployed.
[0263] In some embodiments, the above-mentioned device also includes: a contract method set splitting module, which is used to determine a first target contract method set that meets the fission condition from at least one contract method set deployed on the computing resources that meet the load migration condition when there are computing resources that meet the load migration condition in the computing resource set, wherein the contract methods in the same contract method set belong to the same smart contract; split the first target contract method set to obtain at least two contract method subsets; and migrate at least a part of the at least two contract method subsets to other computing resources.
[0264] In some embodiments, the contract method set splitting module is also used to determine a target contract method subset to be migrated from at least two contract method subsets; determine the contract hash value corresponding to the target contract method subset based on the contract identifier of the smart contract to which the target contract method subset belongs and the set identifier of the target contract method subset; determine the computing resource hash value that meets the distance proximity condition from the hash value sequence based on the position of the contract hash value corresponding to the target contract method subset in the hash value sequence; and migrate the target contract method subset to the computing resource corresponding to the determined computing resource hash value.
[0265] In some embodiments, the contract method set splitting module is also used to obtain the calling frequency corresponding to each contract method in the first target contract method set; according to the calling frequency corresponding to each contract method, the first target contract method set is split into two contract method subsets; wherein the total calling frequencies corresponding to the two contract method subsets obtained by splitting meet the proximity condition, and the total calling frequencies corresponding to the contract method subsets are obtained by counting the calling frequencies of the included contract methods.
[0266] In some embodiments, the above-mentioned device also includes: a contract method set merging module, which is used to determine a second target contract method set that meets the merging condition from at least one contract method set deployed on the computing resource that meets the load access condition when there is a computing resource that meets the load access condition in the computing resource set, wherein the contract methods in the same contract method set belong to the same smart contract; determine the contract method set to be merged from the contract method set deployed on other computing resources and belonging to the same smart contract as the second target contract method set; and merge the contract method set to be merged into the second target contract method set.
[0267] In some embodiments, the contract method set merging module is also used to determine the target smart contract to which the second target contract method set belongs; determine the target computing resources on which multiple contract method sets corresponding to the target smart contract are respectively deployed; determine the computing resource with the greatest computing pressure from each target computing resource; and determine the contract method set corresponding to the target smart contract deployed in the computing resource with the greatest computing pressure as the contract method set to be merged.
[0268] In some embodiments, the transaction request carries the contract identifier of the target contract, and the target contract method identifier set to which the target contract method identifier belongs is obtained by querying from a contract method data table that stores the correspondence between the contract identifier and the contract method identifier set based on the contract identifier and the contract method identifier; the above-mentioned device also includes an update module, which is used to update the contract method data table according to the changed contract method set when the contract method set deployed on any computing resource in the computing resource set changes.
[0269] Each module in the above-mentioned blockchain-based transaction processing device can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0270] In some embodiments, a computer device is provided, which may be a server. The server may serve as a blockchain node, and its internal structure diagram may be as follows: Fig.16As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store blockchain data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a transaction processing method based on blockchain is implemented.
[0271] In some embodiments, a computer device is provided, which may be a terminal. The terminal may be used as a blockchain node, and its internal structure diagram may be as follows: Fig.17 Its internal structure can be shown as Fig.17 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless method can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a transaction processing method based on blockchain is implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.
[0272] Those skilled in the art will understand that Fig.16 , Fig.17The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0273] In some embodiments, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of the above-mentioned blockchain-based transaction processing method are implemented.
[0274] In some embodiments, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned blockchain-based transaction processing method are implemented.
[0275] In some embodiments, a computer program product is provided, including a computer program, which, when executed by a processor, implements the steps of the above-mentioned blockchain-based transaction processing method.
[0276] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0277] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0278] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0279] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the present application. It should be noted that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A transaction processing method based on blockchain, characterized in that: The method comprises: Receive a transaction request, and obtain a target contract method identifier indicated by the transaction request, wherein the target contract method identifier indicates a target contract method of a target contract; Determine the target contract method identifier set to which the target contract method identifier belongs; Determine a target computing resource from a computing resource set according to the target contract method identification set, wherein, in a hash value sequence formed by a hash value domain, a target computing resource hash value determined according to the attribute information of the target computing resource and a target contract hash value corresponding to the target contract method identification set satisfy a distance proximity condition; Allocate the transaction request to the target computing resource to instruct the target computing resource to call the target contract method of the target contract to process the transaction request and obtain a transaction processing result; Obtain the transaction processing result, and upload the transaction to the blockchain based on the transaction processing result.
2. The method according to claim 1, characterized in that The step of determining the target computing resource from the computing resource set according to the target contract method identifier set includes: Obtain the target contract hash value corresponding to the target contract method identifier set; According to the position of the target contract hash value in the hash value sequence, determine from the hash value sequence a computing resource hash value that satisfies a distance proximity condition with the target contract hash value, and use the determined computing resource hash value as the target computing resource hash value; According to the target computing resource hash value, a target computing resource is determined from the computing resource set.
3. The method according to claim 2, characterized in that The transaction request carries the contract identifier of the target contract, and the target contract method identifier set to which the target contract method identifier belongs is obtained by querying from a contract method data table storing the correspondence between the contract identifier and the contract method identifier set according to the contract identifier and the contract method identifier, and the contract method data table also stores the contract hash value corresponding to the contract method identifier set; The obtaining the target contract hash value corresponding to the target contract method identifier set includes: According to the target contract method identification set, the corresponding contract hash value is queried from the contract method data table to obtain the target contract hash value corresponding to the target contract method identification set.
4. The method according to claim 2, characterized in that: The hash value sequence is represented by a hash ring, and each computing resource in the computing resource set corresponds to multiple computing resource hash values on the hash ring. The multiple computing resource hash values corresponding to each computing resource are obtained by adding different numbers to the attribute information corresponding to each of the computing resources and then performing hash calculation on the attribute information with the added numbers.
5. The method according to claim 1, characterized in that The method further comprises: Receive a smart contract deployment request, where the contract deployment request carries contract identification information of the smart contract to be deployed; Determine the contract hash value corresponding to the smart contract to be deployed according to the contract identification information; Determine, from the hash value sequence, a computing resource hash value whose contract hash value corresponding to the smart contract to be deployed satisfies the proximity condition; The smart contract deployment request is sent to the computing resource corresponding to the determined computing resource hash value to instruct the computing resource corresponding to the determined computing resource hash value to deploy the smart contract.
6. The method according to claim 5, characterized in that The hash value sequence is represented by a hash ring, and determining, from the hash value sequence, a computing resource hash value whose contract hash value corresponding to the smart contract to be deployed satisfies the proximity condition, includes: Determine the position of the contract hash value corresponding to the smart contract to be deployed in the hash ring; In the hash ring, find the computing resource hash value that is closest to the location corresponding to the smart contract to be deployed, and obtain the computing resource hash value whose contract hash value corresponding to the smart contract to be deployed satisfies the distance proximity condition.
7. The method according to claim 1, characterized in that The method further comprises: When there is a computing resource that meets the load migration condition in the computing resource set, determine a first target contract method set that meets the fission condition from at least one contract method set deployed on the computing resource that meets the load migration condition, wherein the contract methods in the same contract method set belong to the same smart contract; Splitting the first target contract method set to obtain at least two contract method subsets; Migrate at least a portion of the at least two contract method subsets to other computing resources.
8. The method according to claim 7, characterized in that The migrating at least a portion of the at least two contract method subsets to other computing resources includes: Determining a target contract method subset to be migrated from the at least two contract method subsets; Determine the contract hash value corresponding to the target contract method subset according to the contract identifier of the smart contract to which the target contract method subset belongs and the set identifier of the target contract method subset; According to the position of the contract hash value corresponding to the target contract method subset in the hash value sequence, determining the computing resource hash value that meets the distance proximity condition from the hash value sequence; Migrate the target contract method subset to the computing resource corresponding to the determined computing resource hash value.
9. The method according to claim 7, characterized in that: The step of splitting the first target contract method set to obtain at least two contract method subsets includes: Obtaining the calling frequency corresponding to each contract method in the first target contract method set; According to the calling frequencies corresponding to the respective contract methods, the first target contract method set is split into two contract method subsets; Among them, the total call frequencies corresponding to the two contract method subsets obtained by splitting meet the proximity condition, and the total call frequencies corresponding to the contract method subsets are obtained by counting the call frequencies of the included contract methods.
10. The method according to claim 1, characterized in that The method further comprises: When there is a computing resource that meets the load access condition in the computing resource set, determine a second target contract method set that meets the merging condition from at least one contract method set deployed on the computing resource that meets the load access condition, wherein the contract methods in the same contract method set belong to the same smart contract; Determine a contract method set to be merged from contract method sets that are deployed on other computing resources and belong to the same smart contract as the second target contract method set; Merge the contract method set to be merged into the second target contract method set.
11. The method according to claim 10, characterized in that The step of determining the contract method set to be merged from the contract method sets that are deployed on other computing resources and belong to the same smart contract as the second target contract method set includes: Determine the target smart contract to which the second target contract method set belongs; Determine the target computing resources for respectively deploying the multiple contract method sets corresponding to the target smart contract; From among the various target computing resources, determine the computing resource with the greatest computing pressure; The contract method set corresponding to the target smart contract deployed in the computing resource with the greatest computing pressure is determined as the contract method set to be merged.
12. The method according to any one of claims 1 to 11, characterized in that: The transaction request carries the contract identifier of the target contract, and the target contract method identifier set to which the target contract method identifier belongs is obtained by querying from a contract method data table storing the correspondence between the contract identifier and the contract method identifier set according to the contract identifier and the contract method identifier; The method further comprises: When the contract method set deployed on any computing resource in the computing resource set changes, the contract method data table is updated according to the changed contract method set.
13. A transaction processing device based on blockchain, characterized in that: The device comprises: A transaction request receiving module, configured to receive a transaction request and obtain a target contract method identifier indicated by the transaction request, wherein the target contract method identifier indicates a target contract method of a target contract; A contract method identifier set determination module, used to determine a target contract method identifier set to which the target contract method identifier belongs; a target computing resource determination module, configured to determine a target computing resource from a computing resource set according to the target contract method identification set, wherein, in a hash value sequence formed by a hash value value domain, a target computing resource hash value determined according to the attribute information of the target computing resource and a target contract hash value corresponding to the target contract method identification set satisfy a distance proximity condition; A transaction request allocation module, used to allocate the transaction request to the target computing resource, so as to instruct the target computing resource to call the target contract method of the target contract to process the transaction request and obtain a transaction processing result; The transaction processing result chain module is used to obtain the transaction processing result and chain the transaction processing result to the blockchain.
14. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 12 are implemented.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.
16. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.