Resource processing method and device, computer equipment and storage medium
By entrusting the resource processing tasks of blockchain nodes to cloud functions for legality verification, the problem of high computing resources consumption of blockchain nodes during resource processing is solved, and the effect of reducing operating costs is achieved.
Patent Information
- Application Number
- CN202311302682.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-09
- Publication Date
- 2025-04-11
AI Technical Summary
When blockchain nodes perform resource processing, they need to conduct complete verification of resource transfer indication data, resulting in high computing resources consumption and high operating costs.
By obtaining the pending resource transfer indication data in the blockchain system, reading the transferred resources, building a read data set, and sending it to the cloud function server for legality verification. The verified data is used to generate a set of write data, feed it back to the blockchain node, and update the resources in the resource pool.
The decoupling of the computing of blockchain nodes into cloud functions with lower costs is achieved, reducing the operating cost of blockchain nodes and avoiding relying on high fixed computing resources.
Smart Images

Figure CN119808168A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a resource processing method, apparatus, computer equipment, storage medium and computer program product. Background Art
[0002] With the development of computer technology, blockchain technology has emerged. Blockchain is a data structure composed of several blocks connected by hash values. Resource processing can be achieved through blockchain nodes. For example, resources from one address can be transferred to another resource through nodes in the blockchain to achieve resource transfer.
[0003] In the related technology, when a blockchain node performs resource processing, it is usually necessary to fully verify the resource transfer indication data, which requires a large amount of computing resources and results in a high cost for running a blockchain node. Summary of the invention
[0004] Based on this, it is necessary to provide a resource processing method, device, computer equipment, computer-readable storage medium and computer program product that can save the operating costs of blockchain nodes in response to the above-mentioned technical problems.
[0005] In a first aspect, the present application provides a resource processing method. The method comprises:
[0006] Obtain at least one pending resource transfer indication data in the blockchain system;
[0007] Reading at least one transfer-out resource indicated by the at least one resource transfer indication data from a resource pool of the blockchain system, determining at least one corresponding resource transfer read data according to the read transfer-out resource, and obtaining a read data set including the at least one resource transfer read data;
[0008] Sending the read data set to a cloud function server;
[0009] Receive a write data set fed back by the cloud function server; the write data set includes resource transfer write data, and the resource transfer write data is determined based on the resource transfer read data that has passed the verification after the cloud function verifies the legitimacy of each resource transfer read data in the read data set;
[0010] According to the resource transfer write data in the write data set, the resources to be updated and the update operation for the resource pool are determined, and the resources to be updated are updated in the resource pool according to the update operation.
[0011] In a second aspect, the present application also provides a resource processing device. The device comprises:
[0012] A data acquisition module, used to acquire at least one resource transfer indication data to be processed in the blockchain system;
[0013] A transfer-out resource reading module, configured to read at least one transfer-out resource indicated by the at least one resource transfer indication data from a resource pool of the blockchain system, determine at least one corresponding resource transfer read data according to the read transfer-out resource, and obtain a read data set including the at least one resource transfer read data;
[0014] A read data set sending module, used to send the read data set to a cloud function server;
[0015] A write data set receiving module, used to receive the write data set fed back by the cloud function server; the write data set includes resource transfer write data, and the resource transfer write data is determined by the cloud function after verifying the legitimacy of each resource transfer read data in the read data set, and then based on the verified resource transfer read data;
[0016] The resource update module is used to determine the resources to be updated and the update operation for the resource pool according to the resource transfer write data in the write data set, and update the resources to be updated in the resource pool according to the update operation.
[0017] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the resource processing method when executing the computer program.
[0018] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the resource processing method described above are implemented.
[0019] In a fifth aspect, the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the resource processing method are implemented.
[0020] The resource processing method, apparatus, computer device, storage medium and computer program product obtain at least one resource transfer indication data to be processed in the blockchain system, read at least one transfer-out resource indicated by at least one resource transfer indication data of the resource processing from the resource pool of the blockchain system, determine at least one corresponding resource transfer read data according to the read transfer-out resource, obtain a read data set including at least one resource transfer read data of the resource processing, send the resource processing read data set to the cloud function server, receive a write data set fed back by the resource processing cloud function server, the resource processing write data set including resource transfer write data, resource processing resource transfer write data It is determined according to the verified resource transfer read data after the cloud function verifies the legitimacy of each resource transfer read data in the resource processing read data set, and finally determines the resources to be updated and the update operation for the resource processing resource pool according to the resource transfer write data in the resource processing write data set, and updates the resource processing resources to be updated in the resource processing resource pool according to the resource processing update operation, realizing the separation of storage and computing of blockchain nodes through read-write sets and cloud functions, decoupling computing to cloud functions with lower costs and pay-per-call, so that blockchain nodes do not need to rely on high fixed computing costs for resource processing, reducing the operating costs of blockchain nodes.
[0021] In a sixth aspect, the present application provides a resource processing method. The method comprises:
[0022] Receive a read data set sent by a blockchain node; the read data set includes at least one resource transfer read data, the resource transfer read data is determined according to the resource read by the blockchain node from the resource pool, and the read resource is a transfer-out resource indicated by at least one resource transfer indication data to be processed;
[0023] Through the cloud function, the legitimacy of each resource transfer read data in the read data set is verified, and the resource transfer write data is determined according to the verified resource transfer read data, so as to obtain a write data set including the resource transfer write data;
[0024] Feeding back the write data set to the blockchain node;
[0025] The write data set is used to instruct the blockchain node to determine the resources to be updated and the update operation for the resource pool according to the resource transfer write data in the write data set, and update the resources to be updated in the resource pool according to the update operation.
[0026] In a seventh aspect, the present application also provides a resource processing device. The device comprises:
[0027] A read data set receiving module, used to receive a read data set sent by a blockchain node; the read data set includes at least one resource transfer read data, the resource transfer read data is determined according to the resource read by the blockchain node from the resource pool, and the read resource is a transfer-out resource indicated by at least one resource transfer indication data to be processed;
[0028] A legality verification module, used to verify the legality of each resource transfer read data in the read data set through a cloud function, determine the resource transfer write data according to the verified resource transfer read data, and obtain a write data set including the resource transfer write data;
[0029] A write data set feedback module is used to feed back the write data set to the blockchain node; the write data set is used to instruct the blockchain node to determine the resources to be updated and the update operation for the resource pool according to the resource transfer write data in the write data set, and update the resources to be updated in the resource pool according to the update operation.
[0030] In an eighth aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the resource processing method are implemented.
[0031] In a ninth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and the computer program implements the steps of the resource processing method described above when executed by a processor.
[0032] In a tenth aspect, the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the resource processing method are implemented.
[0033] The resource processing method, apparatus, computer equipment, storage medium and computer program product receive a read data set sent by a blockchain node; the read data set includes at least one resource transfer read data, the resource transfer read data is determined according to the resource read by the blockchain node from the resource pool, the read resource is a transfer-out resource indicated by at least one resource transfer indication data to be processed, and the cloud function is used to verify the legitimacy of each resource transfer read data in the read data set, and the resource transfer write data is determined according to the verified resource transfer read data, and a write data set including the resource transfer write data is obtained, and the write data set is sent to the blockchain node, and the write data set is used to instruct the blockchain node to determine the resources to be updated and the update operation for the resource pool according to the resource transfer write data in the write data set, and update the resources to be updated in the resource pool according to the update operation. Since the read data set sent by the blockchain node can be verified for legitimacy through the cloud function, the blockchain node can decouple the calculation into a cloud function with lower cost and pay-per-call, so that there is no need to rely on high fixed computing costs for resource processing, thereby reducing the operating cost of the blockchain node. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1A A schematic diagram of a blockchain system in one embodiment;
[0035] Figure 1B A schematic diagram of the structure of a blockchain in one embodiment;
[0036] Figure 1C A schematic diagram of a process of generating a block in one embodiment;
[0037] Figure 2 An application environment diagram of a resource processing method in an embodiment;
[0038] Figure 3 A schematic diagram of a resource processing method in one embodiment;
[0039] Figure 4 It is an architecture diagram of a resource processing method in a specific application in some embodiments;
[0040] Figure 5 Schematic diagram of a flow chart of a resource processing method in some other embodiments;
[0041] Figure 6 A schematic diagram of a cloud function server scheduling a cloud function instance in some embodiments;
[0042] Figure 7 A schematic diagram of a process flow of steps for a cloud function server to schedule a cloud function instance in some embodiments;
[0043] Figure 8Schematic diagram of a flow chart of a resource processing method in some other embodiments;
[0044] Fig. 9 A schematic diagram of a UTXO storage-computing separation architecture based on cloud functions and read-write sets in some embodiments;
[0045] Fig.10 A schematic diagram of elastic blockchain transaction processing based on cloud function runtime scheduling in some embodiments;
[0046] Fig.11 is a structural block diagram of a resource processing device in some embodiments;
[0047] Fig.12 is a structural block diagram of a resource processing device in some other embodiments;
[0048] Fig.13 is an internal structure diagram of a computer device in some embodiments;
[0049] Fig.14 1 is a diagram of the internal structure of a computer device in some other embodiments. DETAILED DESCRIPTION
[0050] 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.
[0051] The resource processing method provided in the embodiment of the present application involves blockchain technology. Blockchain refers to blocks connected in chronological order through hash values to form a chain structure. Such a structure is blockchain. Blockchain not only refers to the data structure of blockchain, but also refers to the entire blockchain system. Figure 1A In the blockchain system shown, the blockchain system 100 may include multiple blockchain nodes 101. Each blockchain node 101 may receive input information during normal operation, and may upload the input information to the blockchain. The input information here may be, for example, resource transfer indication data. In order to ensure information intercommunication within the blockchain system, there may be an information connection between each blockchain node in the blockchain system, and information may be transmitted between blockchain nodes through the above information connection. For example, when any blockchain node in the blockchain system receives input information, other blockchain 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 blockchain nodes in the blockchain system are consistent.
[0052] Each blockchain node in the blockchain system has a corresponding node identifier, and each blockchain 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 blockchain 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 explanation.
[0053] Table 1
[0054] Node Name Node ID Node 1 XXX.XXX.XXX.XXX Node 2 XXX.XXX.XXX.XXX … … Node N XXX.XXX.XXX.XXX
[0055] Each blockchain node in the blockchain system stores the same blockchain. The blockchain consists of multiple blocks, see Figure 1B 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.
[0056] When generating each block in the blockchain, see Figure 1C When a blockchain node receives input information, it verifies the input information. After verification, it stores the input information in the memory pool and updates the feature tree used to record the input information. After that, it updates the update timestamp to the time when the input information is received, tries different random numbers, and calculates the feature value multiple times so that the calculated feature value can satisfy the following formula:
[0057] SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x))<TARGET
[0058] 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 value, 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.
[0059] 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 blockchain node sends the newly generated block to other nodes in the blockchain system 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 after completing the legitimacy verification, thereby completing the chain process of input information.
[0060] It can be understood that in the present application, the above-mentioned input information is resource transfer indication data, and the resource processing method of the present application is applied to process the resource processing indication data that needs to be packaged when packaging and generating blocks, or is applied to the resource processing indication data in the received block when receiving the block.
[0061] The resource processing method provided in the embodiment of the present application can be applied to Figure 2 In the application environment shown. Among them, the blockchain node 202 in the blockchain system and the cloud function server 204 can communicate through a network, such as a wired or wireless network. The blockchain node 202 can obtain at least one resource transfer indication data to be processed in the blockchain system, read at least one transfer-out resource indicated by at least one resource transfer indication data from the resource pool of the blockchain system, determine at least one corresponding resource transfer read data according to the read transfer-out resource, obtain a read data set including at least one resource transfer read data, and send the read data set to the cloud function server 204. The cloud function server 204 verifies the legitimacy of each resource transfer read data in the read data set through the cloud function, determines the resource transfer write data according to the verified resource transfer read data, and obtains a write data set including the resource transfer write data. The cloud function server 204 further feeds back the write data set to the blockchain node 202. The blockchain node 202 determines the resources to be updated and the update operation for the resource pool according to the resource transfer write data in the write data set, and updates the resources to be updated in the resource pool according to the update operation.
[0062] Among them, the blockchain node 204 can be a terminal or a server. The terminal can be, but is not limited to, various desktop computers, laptops, smart phones, tablet computers, IoT devices and portable wearable devices. IoT 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 can be implemented as an independent server or a server cluster composed of multiple servers. The cloud function server is a server that can perform cloud functions, which can be implemented as an independent server or a server cluster composed of multiple servers.
[0063] 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.
[0064] In some embodiments, Figure 3 As shown, a resource processing method is provided, which is described by taking the method applied to the blockchain node in FIG1 as an example, and includes the following steps:
[0065] Step 302: Obtain at least one resource transfer indication data to be processed in the blockchain system.
[0066] Among them, resource transfer indication data refers to data used to describe a resource transfer, and resource transfer means that resource transfer can be the transfer of resources from one address to another address. Resources refer to items that can be circulated through the network, including at least one of virtual items and physical items. Among them, virtual items can specifically include but are not limited to at least one of various virtual resources that can be represented by numerical values, funds, stocks, bonds, virtual image products, virtual recharge cards, game equipment, etc. Physical items can be any items with actual forms that can be owned by users, and can specifically include but are not limited to electronic products, toys, handicrafts or signed photos, etc. Resource transfer indication data can specifically be transaction data.
[0067] Specifically, the blockchain node can obtain at least one resource transfer indication data to be processed in the blockchain system, and the resource transfer indication data to be processed is the resource transfer indication data that needs to be processed and linked to the blockchain.
[0068] As a possible implementation, the blockchain node can obtain resource transfer indication data from the resource transfer indication data pool of the blockchain system, process it according to the resource processing method of the present application, and package the obtained resource transfer indication data to generate a block. As another possible implementation, after receiving a block sent by other nodes in the blockchain system, the blockchain node can obtain at least one resource transfer indication data to be processed from the received block.
[0069] Step 304: read at least one transfer-out resource indicated by at least one resource transfer indication data from the resource pool of the blockchain system, determine at least one corresponding resource transfer read data according to the read transfer-out resource, and obtain a read data set including at least one resource transfer read data.
[0070] Among them, the resource pool is used to store resources. The blockchain model is generally divided into UTXO (Unspent Transaction Output) type and account type. For UTXO type blockchain, the resource pool can be the UTXO storage stored in the blockchain node, and the UTXO storage can be any relational / non-relational database storage, object storage, etc.; for account type blockchain, the resource pool can be the user's account address. Each resource transfer indication data indicates that there is at least one transferred-out resource, and the transferred-out resource refers to the resource transferred from a certain address for transfer. Resource transfer read data refers to data determined according to the resources read in the resource pool during the resource transfer process. Each transferred-out resource can correspond to a resource transfer read data, and the resource transfer read data at least includes the corresponding transferred-out resource.
[0071] Specifically, the blockchain node can read the transferred-out resources indicated by each resource transfer indication data from the resource pool of the blockchain system respectively, and for each transferred-out resource, determine the corresponding resource transfer read data according to the transferred-out resource, and the resource transfer read data corresponding to all the read transferred-out resources are jointly constructed to obtain the obtained read data set.
[0072] It is understandable that when a blockchain node reads a transferred resource, it can also simultaneously obtain the attribute information of the transferred resource, for example, it can obtain one or more of the resource identifier of the transferred resource, the address to which the transferred resource belongs, etc. In a specific application, for a UTXO type blockchain, one UTXO in the UTXO storage is a resource, and when a blockchain node reads the UTXO indicated by the resource transfer indication data, it can also read the resource identifier of the UTXO and the address to which it belongs. As a possible implementation method, for each transferred resource read, the blockchain node can determine the corresponding resource transfer read data based on the transferred resource and the corresponding attribute information.
[0073] As a possible implementation method, the resource transfer indication data includes the resource identifier of the indicated transferred-out resource, and the blockchain node can read the corresponding transferred-out resource from the resource pool of the blockchain system according to the resource identifier.
[0074] As a possible implementation, for each resource transfer indication data, after the blockchain node reads the transfer-out resource corresponding to the resource transfer indication data, it can further determine whether the value of the transfer-out resource is greater than the transfer-out resource indicated by the resource transfer indication data, and only determine the resource transfer read data for the resource transfer indication data whose value of the transfer-out resource is greater than the transfer-out resource. As a possible implementation, after the blockchain node reads the transfer-out resource, for each transfer-out resource, the blockchain node can obtain the unlocking script of the transfer-out resource, and then determine the resource transfer read data corresponding to the transfer-out resource based on the unlocking script and the transfer-out resource.
[0075] Step 306, sending the read data set to the cloud function server.
[0076] Among them, cloud function server refers to the server outside the blockchain system that can run cloud functions. Serverless Cloud Function (SCF) is a serverless execution environment that can run code without purchasing and managing servers. You only need to write core code in a language supported by the platform and set the conditions for code running, and you can run the code flexibly and securely on the cloud infrastructure.
[0077] Specifically, the blockchain node can send the read data set to the cloud function server.
[0078] Step 308, receiving the write data set fed back by the cloud function server; the write data set includes resource transfer write data, and the resource transfer write data is determined by the cloud function after verifying the legitimacy of each resource transfer read data in the read data set, and based on the verified resource transfer read data.
[0079] Specifically, after receiving the resource transfer read data, the cloud function server verifies the legitimacy of each resource transfer read data in the resource transfer read data set through a cloud function, and determines the resource transfer write data based on the verified resource transfer read data.
[0080] The resource transfer write data refers to data used to perform write operations on the resource pool during the resource transfer process. Optionally, the resource transfer write data may be verified resource transfer read data. Also optionally, since the resource transfer write data is used to perform write operations on the resource pool, the resource transfer write data only needs to be able to correctly identify the resource targeted by the write operation. Therefore, the resource transfer write data may also be the resource identifier of the resource targeted by the write operation.
[0081] In one possible implementation, the cloud function server may verify the legitimacy of the resource transfer read data by: the cloud function server unlocks the resource transfer read data according to the unlocking script in the resource transfer read data; if the unlocking is successful, it indicates that the verification is passed.
[0082] In another possible implementation, when a blockchain node sends a read data set to a cloud function server, it may also send resource transfer indication data corresponding to each resource transfer read data in the read data set. When the cloud function verifies the legitimacy of the resource transfer read data, it may further verify whether the value of the transferred-out resource indicated by the resource transfer indication data corresponding to the resource transfer read data is greater than the value of the transferred-in resource. If the unlocking is successful and the value of the transferred-out resource is greater than the value of the transferred-in resource, the resource transfer read data verification is determined to have passed.
[0083] Step 310 : Determine the resources to be updated and the update operation for the resource pool according to the resource transfer write data in the write data set, and update the resources to be updated in the resource pool according to the update operation.
[0084] The resource to be updated refers to a resource that needs to be updated in the resource pool, and the resource to be updated may be a resource to be deleted, a resource to be modified, or a resource to be inserted. Correspondingly, the update operation may be a delete operation, a modify operation, or an insert operation.
[0085] Specifically, after receiving the write data set fed back by the cloud function server, the blockchain node transfers the write data according to the resources in the write data set, determines the resources to be updated and the update operation for the resource pool, and updates the resources to be updated in the resource pool according to the update operation.
[0086] As a possible implementation method, for a UTXO type blockchain, the resources to be updated include UTXO to be deleted and UTXO to be inserted. For the UTXO to be deleted, the blockchain node can delete the UTXO from the UTXO storage, and for the UTXO to be inserted, the blockchain node can insert it into the blockchain storage.
[0087] In some other possible implementations, each UTXO in the UTXO storage may also store a status identifier, which is used to identify whether the UTXO is valid. For example, "1" may be used to identify validity, and "0" may be used to identify invalidity. The resources to be updated may include the UTXO to be modified and the UTXO to be inserted. For the UTXO to be modified, the blockchain node may change the status identifier of the UTXO in the UTXO storage to a status identifier used to identify invalidity. For the UTXO to be inserted, the blockchain node may insert it into the blockchain storage and set its status identifier to a status identifier that identifies validity. It is understandable that in this implementation, when the blockchain node reads the UTXO from the UTXO storage, it needs to determine whether the UTXO is valid. If the identifier of the UTXO indicated by the resource transfer indication data is an identifier indicating invalidity, the blockchain node will not generate resource transfer read data for the resource transfer indication data.
[0088] As a possible implementation method, for an account-type blockchain, after receiving the resource transfer write data, the blockchain node can delete resources from the account according to the resource transfer write data, that is, reduce the value of the account.
[0089] In some specific embodiments, reference Figure 4 , which is the architecture diagram of the resource processing method of this application in a specific application, refer to Figure 4 In this embodiment, the blockchain node includes a block validator and packager, a data validator and a resource pool, wherein the block validator and packager is used to obtain resource transfer indication data, and the transaction validator reads the transfer-out resources indicated by the resource transfer indication data from the resource pool of the blockchain system, determines the corresponding resource transfer read data according to the read transfer-out resources, obtains a read data set including the resource transfer read data, sends the read data set to the cloud function server, receives a write data set fed back by the cloud function server, and finally determines the resources to be updated and the update operation for the resource pool according to the resource transfer write data in the write data set, and updates the resources to be updated in the resource pool according to the update operation.
[0090] In the above resource processing method, at least one resource transfer indication data to be processed in the blockchain system is obtained, at least one transfer-out resource indicated by at least one resource transfer indication data of the resource processing is read from the resource pool of the blockchain system, at least one corresponding resource transfer read data is determined according to the read transfer-out resource, a read data set including at least one resource transfer read data of the resource processing is obtained, the resource processing read data set is sent to the cloud function server, and a write data set fed back by the resource processing cloud function server is received, the resource processing write data set includes resource transfer write data, the resource processing resource transfer write data is determined according to the resource transfer read data that has passed the verification after the cloud function verifies the legitimacy of each resource transfer read data in the resource processing read data set, and finally, according to the resource transfer write data in the resource processing write data set, the resources to be updated and the update operation for the resource processing resource pool are determined, and the resource processing resources to be updated are updated in the resource processing resource pool according to the resource processing update operation, so that the storage and computing separation of the blockchain node is realized through the read-write set and the cloud function, and the computing is decoupled into the cloud function with lower cost and pay-per-call, so that the blockchain node does not need to rely on high fixed computing costs for resource processing, thereby reducing the operating cost of the blockchain node.
[0091] In some embodiments, at least one transferred-out resource indicated by at least one resource transfer indication data is read from a resource pool of a blockchain system, including: for each of at least one resource transfer indication data, obtaining a resource transfer identifier and a resource transfer index from resource transfer input data of the resource transfer indication data; and reading the transferred-out resource indicated by the resource transfer indication data from the resource pool of the blockchain system according to the resource transfer identifier and the resource transfer index.
[0092] The resource transfer identifier is used to identify the historical resource transfer indication data, and the resource transfer index points to one of the at least one transfer-in resources obtained by performing resource transfer based on the historical resource transfer indication data. The resource transfer identifier can be a hash value of the historical resource transfer indication data. For example, taking the historical resource transfer indication data as historical transaction data, the resource transfer identifier is the transaction hash value of the historical transaction data. Each historical resource transfer indication data can correspond to an index list, and each resource transfer index in the index list can be a letter or a number. For example, assuming that there are 3 transfer-in resources obtained by performing resource transfer based on a certain historical resource transfer indication data, 0, 1, and 2 can be used as the resource transfer index of each transfer-in resource, respectively.
[0093] Specifically, in this embodiment, the blockchain is a UTXO type blockchain, and each resource transfer indication data obtained by the blockchain node from the blockchain system includes resource transfer input data and resource transfer output data. Each resource transfer input data includes a resource transfer identifier and a resource transfer index. According to the resource transfer identifier and the resource transfer index, the resource transfer output data in a historical resource transfer indication data can be uniquely determined. Therefore, according to the resource transfer identifier and the resource transfer index, the transferred resources can be traced to further ensure the security of resource transfer. In UTXO storage, the resource transfer identifier and the resource transfer index can be used as the resource identifier of UTXO and stored in association with UTXO, so that for each resource transfer indication data, the blockchain node can extract the resource transfer input data from the resource transfer indication data, and then obtain the resource transfer identifier and the resource transfer index from the resource transfer input data. Finally, from the resource pool of the blockchain system, read the resources associated with the resource transfer identifier and the resource transfer index to obtain the transferred resources indicated by the resource transfer indication data.
[0094] In the above embodiment, since the resource transfer identifier and the resource transfer index can be obtained from the resource transfer input data of the resource transfer indication data, the transferred-out resources can be quickly and accurately read from the resource pool, thereby improving the efficiency and accuracy of resource reading.
[0095] In some embodiments, based on the resource transfer identifier and the resource transfer index, the transfer-out resource indicated by the resource transfer indication data is read from the resource pool of the blockchain system, including: determining at least one candidate resource associated with the resource transfer identifier from the resource pool of the blockchain system; determining a target resource associated with the resource transfer index from at least one candidate resource associated with the resource transfer identifier; and reading the target resource to obtain the transfer-out resource indicated by the resource transfer indication data.
[0096] Specifically, each resource in the resource pool is associated with a corresponding resource transfer identifier and a resource index. If the resource transfer identifier and the resource index are matched at the same time to determine the transferred resources, the two fields need to be compared at the same time each time, which is time-consuming. In this embodiment, for each resource transfer indication data, the blockchain node can first query the resource pool through the resource transfer identifier corresponding to the resource transfer indication data, obtain the resources associated with the resource transfer identifier, and use these resources as candidate resources. Then, the resource transfer index corresponding to the resource transfer indication data can be matched with the resource transfer index associated with these candidate resources. The successfully matched resource is the transferred resource indicated by the resource transfer indication data.
[0097] In the above embodiment, the candidate resources are first determined by the resource transfer identifier, and then the transferred resources that need to be read are determined from the candidate resources by the resource transfer index. Since there is no need to compare the resource transfer identifier and the resource transfer index for each traversed resource at the same time, the resource reading efficiency is improved, thereby improving the resource transfer efficiency.
[0098] In some embodiments, Figure 5 As shown, a resource processing method is provided, which is described by taking the method applied to the blockchain node in FIG1 as an example, and includes the following steps:
[0099] Step 502: Obtain at least one resource transfer indication data to be processed in the blockchain system, each resource transfer indication data including resource transfer input data.
[0100] Step 504: read at least one transfer-out resource indicated by at least one resource transfer indication data from the resource pool of the blockchain system.
[0101] Step 506: For each of the at least one resource transfer indication data, obtain an unlocking script for the resource transfer indication data from the included resource transfer input data.
[0102] Step 508: Determine the resource transfer read data corresponding to the resource transfer indication data according to the transfer-out resource indicated by the resource transfer indication data and the unlocking script corresponding to the resource transfer indication data, and obtain a read data set including the resource transfer read data.
[0103] For UTXO-type blockchains, there is a script on both the input and output of the resource transfer indication data. The script on the output is called the locking script (Locking Script, also often represented by scriptPubKey), which is a cryptographic puzzle that specifies the conditions that must be met to spend this UTXO in the future, equivalent to a lock. The script on the input is called the unlocking script (Unlocking Script, also often represented by scriptSig), which solves or satisfies the cryptographic puzzle or condition previously placed on this UTXO, unlocks the UTXO for payment, and is equivalent to a key. Optionally, the unlocking script can be a signature script. In the specific implementation, the signature script can contain two elements: signature and public key, and their function is to verify the signature.
[0104] Specifically, for each resource transfer indication data, the blockchain node can extract the resource transfer input data from the resource transfer indication data, and then obtain the unlocking script of the resource transfer indication data from the resource transfer input data, determine the resource transfer read data corresponding to the resource transfer indication data according to the transfer-out resources of the resource transfer indication data, the attribute information of the transfer-out resources and the unlocking script, and finally obtain a read data set including the resource transfer read data.
[0105] Step 510, sending the read data set to the cloud function server.
[0106] Step 512, receiving the write data set fed back by the cloud function server.
[0107] The write data set includes resource transfer write data. The resource transfer write data is determined by verifying the legitimacy of each resource transfer read data in the read data set through a cloud function and then based on the verified resource transfer read data.
[0108] Step 514: Determine the resources to be updated and the update operation for the resource pool according to the resource transfer write data in the write data set, and update the resources to be updated in the resource pool according to the update operation.
[0109] The above-mentioned resource processing method determines the resource transfer read data by locking the script and transferring out the resources, so that the cloud function server can better verify the legitimacy of the resource transfer read data, thereby further improving the security of resource transfer.
[0110] In some embodiments, based on the resource transfer write data in the write data set, the resources to be updated and the update operation for the resource pool are determined, and the resources to be updated are updated in the resource pool according to the update operation, including: in the resource pool, the transferred-out resources corresponding to the resource transfer write data in the write data set are determined as resources to be deleted, and the update operation for the resources to be deleted is determined as a deletion operation; the transferred-in resources obtained by performing resource transfer on the resources to be deleted are determined as resources to be inserted, and the update operation for the resources to be inserted is determined as an insertion operation; in the resource pool, the resources to be deleted are deleted according to the deletion operation, and the resources to be inserted are inserted according to the insertion operation.
[0111] The resource transfer write data is determined based on the verified resource transfer read data, and the resource transfer read data is determined based on the transfer-out resources indicated by the resource indication data, that is, each resource transfer write data corresponds to a resource transfer indication data, and the transfer-out resources corresponding to the resource transfer write data are the transfer-out resources indicated by the resource transfer indication data corresponding to the resource transfer write data. As a possible implementation method, the resource transfer indication data includes the resource identifier of the transfer-out resource, and the resource transfer read data of the resource transfer indication data includes the transfer-out resource and the resource identifier indicated by the resource transfer indication data, and the resource transfer write data includes the resource identifier. After receiving the resource transfer write data, the blockchain node can determine the resource transfer indication data containing the same resource identifier based on the resource identifier in the resource transfer write data, and then use the transfer-out resource indicated by the determined resource transfer indication data as the transfer-out resource corresponding to the resource transfer write data.
[0112] In this embodiment, each time a resource is transferred, at least one transferred-out resource in the resource pool is consumed, and at least one new transferred-in resource is generated and inserted into the resource pool. The values of the consumed transferred-out resources and the inserted transferred-in resources are equal to ensure that the values of the resources in the resource pool are constant. Specifically, after receiving the write data set, the blockchain node determines the transferred-out resource corresponding to each resource transfer write data in the write data set as a resource to be deleted, and determines the update operation for the resource to be deleted as a deletion operation. The blockchain node further determines the transferred-in resource obtained by performing a resource transfer on the resource to be deleted, determines the transferred-in resource as a resource to be inserted, and determines the update operation for the resource to be inserted as an insertion operation. Then, the blockchain node can delete the operation to be deleted in the resource pool and insert the resource to be inserted.
[0113] In the above embodiment, the transfer-out resources corresponding to the resource transfer write data in the write data set are determined as resources to be deleted, and the transfer-in resources obtained by resource transfer of the resources to be deleted are determined as resources to be inserted, and the resources to be deleted are deleted from the resource pool and the resources to be inserted are inserted, so that only the transfer-in resources obtained by each resource transfer and not used are retained in the resource pool. On the one hand, the storage space of the resource pool can be saved, and on the other hand, the efficiency can be higher when reading the transfer-out resources of the resource transfer indication data each time.
[0114] In some embodiments, the incoming resources obtained by performing resource transfer on the resources to be deleted are determined as the resources to be inserted, including: determining resource transfer indication data corresponding to the resources to be deleted; extracting resource transfer output data from the resource transfer indication data corresponding to the resources to be deleted; determining the incoming resources indicated by the resource transfer output data as the incoming resources obtained by performing resource transfer on the resources to be deleted, and obtaining the resources to be inserted.
[0115] Among them, the resource to be inserted is the newly generated resource for this resource transfer. When the resource transfer read data corresponding to the resource transfer indication data is successfully verified on the cloud function server and returns the corresponding resource transfer write data, the resource transfer indicated by the resource transfer indication data can take effect. The blockchain node implements the resource transfer indicated by the resource transfer indication data by deleting the transferred-out resources indicated by the resource transfer indication data in the resource pool and inserting the transferred-in data indicated by the resource transfer indication data.
[0116] Based on this, after receiving the write data set, for each resource transfer write data, the blockchain node determines the transfer-out resource corresponding to the resource transfer write data as the resource to be deleted, and further determines the resource transfer indication data corresponding to the resource to be deleted based on the resource transfer indication data to which the resource to be deleted belongs. Then, the resource transfer output data can be extracted from the resource transfer indication data corresponding to the resource to be deleted, and the transfer-in resource indicated by the resource transfer output data is determined as the transfer-in resource obtained by transferring the resource to the resource to be deleted, thereby obtaining the resource to be inserted.
[0117] For example, assuming that the resource transfer indication data obtained by the blockchain node includes Tx1, Tx2, Tx3 and Tx4, assuming that the transfer-out resources indicated by Tx1 are UTXO11 and UTXO12, the transfer-out resources indicated by Tx2 are UTXO21 and UTXO22, the transfer-out resources indicated by Tx3 are UTXO31 and UTXO32, and the transfer-out resources indicated by Tx4 are UTX41 and UTXO42. If the resource transfer write data obtained through verification includes UTXO11, UTXO21 and UTXO31, then the blockchain node can delete UTXO11, UTXO21 and UTXO31 from the resource pool, and insert UTXO12, UTXO22 and UTXO32.
[0118] In the above embodiment, resource transfer indication data corresponding to the resource to be deleted is determined, resource transfer output data is extracted from the resource transfer indication data corresponding to the resource to be deleted, and the input resource indicated by the resource transfer output data is determined as the input resource obtained by performing resource transfer on the resource to be deleted, so as to obtain the resource to be inserted, which can ensure that the obtained inserted resource is more accurate.
[0119] In some embodiments, the cloud function is determined by the cloud function server scheduling the cloud function instance in the cloud function service pool. The cloud function service pool includes multiple cloud function instances, and the operating resource indication parameters corresponding to each cloud function instance are different. The operating resource indication parameter is used to characterize the operating resources required for the cloud function to run, and the operating resource indication parameter may include at least one of the number of cores and memory capacity required for the cloud function to run.
[0120] In specific applications, refer to Figure 6 , schematic diagram of cloud function server scheduling cloud function instances. The cloud function server obtains the historical service parameter values of each cloud function instance in the cloud function service pool from the service parameter storage through the SCF selector, and schedules the cloud function instances in the cloud function service pool according to the historical service parameter values of each cloud function instance. After the scheduled cloud function instance performs legitimacy verification, it returns the write data set and service parameter value. The returned service parameter value is the current service parameter value of the scheduled cloud function instance. The SCF selector can write the current service parameter value of the scheduled cloud function instance into the service parameter storage, thereby updating the service parameter storage.
[0121] The following embodiments will specifically introduce possible implementation methods of scheduling cloud functions by a cloud function server.
[0122] In some embodiments, scheduling cloud function instances in a cloud function service pool includes: determining service level constraints; obtaining historical service parameter values corresponding to each cloud function in the cloud function service pool, the historical service parameter values being used to describe the service level of the corresponding cloud function for validating the legitimacy of a historical read data set; screening cloud function instances whose corresponding historical service parameter values satisfy the service level constraints from the cloud function service pool; and when at least one candidate cloud function instance is obtained through screening, selecting a cloud function instance for validating the legitimacy of the read data set from the at least one candidate cloud function instance.
[0123] The service level constraint is a condition used to constrain the service level of the cloud function server. The service level constraint can be determined based on the SLA (Service-Level Agreement) parameters. The SLA parameters can be sent to the cloud function server together with the read data by the blockchain, or they can be set by the user in advance in the cloud function server. The SLA parameters can be set according to user needs. For example, the SLA parameter can be a specified time T, and the corresponding server level constraint is to return the write data set within the specified time T. For another example, the SLA parameter can be a specified time T0 and a specified number N0, and the corresponding service level constraint is to return the write data set corresponding to the resource transfer read data matching the specified number N0 within the specified time T0.
[0124] The historical service parameter value is used to describe the service level of the corresponding cloud function for validating the historical read data set. The historical service parameter value may include at least one of the time T or the number N of times the cloud function instance validates the historical read data set. The historical read data set refers to the read data set received by the cloud function server before this valid verification.
[0125] The historical service parameter values of the candidate cloud function instances satisfy the service level constraints. Optionally, the historical service parameter values include the time T that the cloud function instance verifies the legitimacy of the historical read data set. The historical service parameter values satisfy the service level constraints when: the time T that the cloud function instance verifies the legitimacy of the historical read data set is less than the specified time T corresponding to the service level constraints. In a specific application, if a cloud function instance verifies the legitimacy of multiple historical read data sets in a historical stage, there may be multiple Ts. In this case, it is possible to determine whether the cloud function instance satisfies the service level constraints based on the most recent T. Optionally, the historical service parameter values include the time T and the number N that the cloud function instance verifies the legitimacy of the historical read data set. The historical service parameter values satisfy the service level constraints when: the time T that the cloud function instance verifies the legitimacy of the historical read data set that matches the specified number N is less than the specified time T corresponding to the service level constraints.
[0126] Specifically, the cloud function server can obtain SLA parameters, determine service level constraints based on the SLA parameters, obtain historical service parameter values corresponding to each cloud function instance in the cloud function service pool, and judge whether each cloud function instance meets the service level constraints based on the historical service parameter values corresponding to each cloud function instance, and determine the cloud function instances that meet the service level constraints as candidate cloud function instances, so that a cloud function instance can be selected from the candidate cloud function instances for verifying the legitimacy of the current read data set.
[0127] It can be understood that when no candidate cloud function instances are screened out, that is, the historical service parameter values corresponding to all cloud function instances in the cloud function service pool do not meet the service level constraints, the server can select the cloud function instance with the largest number of cores as the cloud function instance for verifying the legitimacy of the current read data set.
[0128] In the above embodiment, by determining the service level constraints and obtaining the historical service parameter values corresponding to each cloud function instance, the cloud function used for legitimacy verification can be scheduled from the cloud function instance that meets the service level constraints, so that the legitimacy verification of the cloud function server can better meet the needs.
[0129] In some embodiments, a cloud function instance for performing legitimacy verification on a read data set is selected from at least one candidate cloud function instance, including: obtaining an operating resource indication parameter value corresponding to each of the at least one candidate cloud function instances; and selecting a cloud function instance whose operating resource indication parameter value satisfies a preset resource constraint condition from at least one candidate cloud function instance, to obtain a cloud function instance for performing legitimacy verification on the read data set.
[0130] The preset resource constraint condition is a condition used to constrain the resources of the scheduled cloud function. Since cloud functions are charged based on calls, generally speaking, the more resources a cloud function instance requires to run, the higher the fee to be paid. Based on this, the present application can set resource constraints so that when scheduling cloud functions, the cloud function server can select cloud function instances that meet the preset resource constraints to save the computing costs of cloud function nodes.
[0131] Specifically, the cloud function server can obtain the running resource indication parameter value corresponding to at least one candidate cloud function instance; from at least one candidate cloud function instance, select a cloud function instance whose running resource indication parameter value meets the preset resource constraint condition, and obtain a cloud function instance for verifying the legitimacy of the read data set.
[0132] As a possible implementation, the preset resource constraint condition may be: the scheduled cloud function instance is a cloud function instance that is ranked before a preset ranking threshold when all candidate cloud function instances are ranked from small to large by the number of cores, for example, a cloud function instance ranked in the top 2 when ranked from small to large. In particular, the preset resource constraint condition may be: the scheduled cloud function instance is a cloud function instance with the smallest number of cores among all candidate cloud function instances.
[0133] In the above embodiment, the server schedules cloud function instances that meet both service level constraints and preset resource constraints. This can satisfy user needs while selecting cloud function instances that can save node computing costs, thereby further reducing the computing cost of blockchain nodes.
[0134] In some embodiments, the service level constraint is: the time required for legitimacy verification of a specified number of resource transfer read data is less than or equal to the specified time; the historical service parameter value includes: the historical running time and historical verification quantity corresponding to the legitimacy verification of the historical read data set by the cloud function instance; from the cloud function service pool, cloud function instances whose corresponding historical service parameter values meet the service level constraint, including: from the cloud function service pool, a part of cloud function instances are filtered out; the historical verification data of the filtered cloud function instances match the specified number; from a part of the cloud function instances, cloud function instances whose corresponding historical running time is less than or equal to the specified time are filtered out to obtain candidate cloud function instances.
[0135] Specifically, in this embodiment, the historical service parameter value corresponding to the cloud function instance includes the historical running time T and the historical verification number N, that is, the historical service parameter value is used to characterize that the time required for the cloud function instance to perform the legitimacy verification on the read data set containing N resource transfer read data is T. When screening candidate cloud function instances, the cloud function server first screens out a part of cloud function instances from the cloud function service pool, and the number of resource transfer read data in the read data set for which the legitimacy is verified in the historical stage matches the specified number T0. The match here can be any one of a small amount greater than the specified number T0, a small amount less than the specified number T0, or equal to the specified number T0. After determining the cloud function instance that matches the specified number, the cloud function server can further obtain the historical running time of each of these cloud function instances. It can be understood that the historical running time here refers to the time when the cloud function instance verifies the legitimacy of the historical read data set that matches the specified number, and the historical running time here does not take into account the historical running time when the cloud function set verifies other historical read data sets that do not match the specified number. After obtaining the historical running time corresponding to each of the specified number of cloud function instances, the cloud function server can select the cloud function instances whose corresponding historical running time is less than or equal to the specified time from these cloud function instances to obtain candidate cloud function instances.
[0136] It is understandable that in some other embodiments, the cloud function server may first filter out cloud function instances whose historical running time is less than or equal to the specified time, and then further filter out cloud function instances whose corresponding historical verification quantity matches the specified number from the filtered cloud function instances to obtain candidate cloud function instances.
[0137] In the above embodiment, since the service level constraint is that the time required for legitimacy verification of a specified number of resource transfer read data is less than or equal to the specified time, the cloud function server can obtain the historical running time and historical verification quantity corresponding to the cloud function instance's legitimacy verification of the historical read data set, and then filter out candidate cloud function instances that meet the service level constraint based on the historical running time and historical verification quantity.
[0138] In some embodiments, Figure 7 As shown, the cloud function server schedules the cloud function instance in the cloud function service pool including the following steps:
[0139] Step 702: Determine service level constraints.
[0140] Step 704, obtain the historical service parameter values corresponding to each cloud function instance in the cloud function service pool, the historical service parameter values include: the historical running time and historical verification quantity corresponding to the cloud function instance performing legitimacy verification on the historical read data set.
[0141] Step 706, filter out a portion of cloud function instances from the cloud function service pool; the historical verification data of the filtered cloud function instances matches the specified number.
[0142] Step 708, from a portion of the filtered cloud function instances, filter the cloud function instances whose corresponding historical running time is less than or equal to the specified time to obtain candidate cloud function instances.
[0143] Step 710, when the number of the filtered cloud function instances is greater than the number of candidate cloud function instances, determine the minimum number of cores of the filtered cloud function instances.
[0144] Step 712, select the cloud function instance corresponding to the minimum number of cores to obtain the cloud function instance used to verify the legitimacy of the read data set.
[0145] For the same cloud function instance, the fewer the specified number, the less running time is required. On the contrary, the more the specified number, the more running time is required. Therefore, the blockchain node can dynamically adjust the specified number according to business needs. For example, during business peak periods, a larger specified number can be set, and during business troughs, a smaller specified number can be set. In this way, the cloud function server can flexibly schedule cloud function instances according to business needs. During business troughs, cloud function instances with a smaller number of cores can be selected, thereby further reducing costs. For example, assuming that the historical running time and historical verification number of each cloud function are shown in Table 2 below, during business troughs, if the specified time is 5 seconds and the specified number is 20, the final number of cores selected is 1. During business peaks, if the specified time is 5 seconds and the specified number is 20, the final number of cores selected is 2. It can be seen that through the embodiments of the present application, cloud function instances can be dynamically scheduled according to business needs, and cloud function instances with as few cores as possible can be selected during business troughs, thereby further reducing costs.
[0146] Table 2
[0147] Number of cores Historical verification quantity Historical running time (seconds) 1 20 5 2 20 2.5 4 20 1 1 40 10 2 40 5 4 40 2.5
[0148] In some embodiments, the cloud function server schedules cloud function instances in a cloud function service pool, further comprising the following steps: when the number of a portion of cloud function instances is consistent with the number of candidate cloud function instances, when there are cloud function instances in the cloud function service pool whose corresponding number of cores is less than the minimum number of cores, the cloud function instance with the largest number of cores is selected from the cloud function instances with less than the minimum number of cores to obtain a cloud function instance for verifying the legitimacy of the read data set.
[0149] In this embodiment, when the number of a part of the cloud function instances screened out is consistent with the number of candidate cloud function instances, it means that among the part of the cloud function instances screened out, the historical running time of all cloud function instances is less than or equal to the specified time. At this time, you can try to further reduce the number of cores to further reduce the cost. Therefore, the cloud function server can further determine whether there is a cloud function instance in the cloud function service pool whose corresponding core number is less than the minimum core number. If so, select the cloud function instance with the largest core number from the cloud function instances with less than the minimum core number to obtain the cloud function instance used to verify the legitimacy of the read data set.
[0150] In the above embodiment, by selecting the cloud function instance with the largest number of cores from the cloud function instances with less than the minimum number of cores, a cloud function instance for verifying the legitimacy of the read data set is obtained, which can further reduce costs while ensuring that the service level constraints are met.
[0151] In some embodiments, Figure 8 As shown, a resource processing method is provided, which is applied to Figure 2 The following steps are used to illustrate the cloud function server in the example:
[0152] Step 802, receiving a read data set sent by a blockchain node; the read data set includes at least one resource transfer read data, the resource transfer read data is determined based on the resources read by the blockchain node from the resource pool, and the read resources are transfer-out resources indicated by at least one resource transfer indication data to be processed.
[0153] Step 804, through the cloud function, verify the legitimacy of each resource transfer read data in the read data set, determine the resource transfer write data based on the verified resource transfer read data, and obtain the write data set including the resource transfer write data.
[0154] Step 806, feed back the write data set to the blockchain node; the write data set is used to instruct the blockchain node to transfer the write data according to the resources in the write data set, determine the resources to be updated and the update operation for the resource pool, and update the resources to be updated in the resource pool according to the update operation.
[0155] In the above embodiment, a read data set sent by a blockchain node is received; the read data set includes at least one resource transfer read data, the resource transfer read data is determined according to the resource read by the blockchain node from the resource pool, the read resource is a transfer-out resource indicated by at least one resource transfer indication data to be processed, and the legality of each resource transfer read data in the read data set is verified through a cloud function, and the resource transfer write data is determined according to the verified resource transfer read data, and a write data set including the resource transfer write data is obtained, and the write data set is sent to the blockchain node. The write data set is used to instruct the blockchain node to determine the resources to be updated and the update operation for the resource pool according to the resource transfer write data in the write data set, and the resources to be updated are updated in the resource pool according to the update operation. Since the legitimacy of the read data set sent by the blockchain node can be verified through the cloud function, the blockchain node can decouple the calculation into a cloud function with lower cost and pay-per-call, so that there is no need to rely on high fixed computing costs for resource processing, thereby reducing the operating cost of the blockchain node.
[0156] In some embodiments, a cloud function is a cloud function instance scheduled from a cloud function service pool, and the running resource indication parameters corresponding to each cloud function instance in the cloud function service pool are different; the above-mentioned resource processing method also includes: determining service level constraints; obtaining historical service parameter values corresponding to each cloud function instance in the cloud function service pool, the historical service parameter values are used to represent the service level of the corresponding cloud function instance for legitimacy verification of historical read data sets; from the cloud function service pool, screening cloud function instances whose corresponding historical service parameter values meet the service level constraints; when at least one candidate cloud function instance is screened, selecting a cloud function instance for legitimacy verification of the read data set from the at least one candidate cloud function instance.
[0157] In some embodiments, a cloud function instance for performing legitimacy verification on a read data set is selected from at least one candidate cloud function instance, including: obtaining an operating resource indication parameter value corresponding to each of the at least one candidate cloud function instance; and selecting a cloud function instance whose corresponding operating resource indication parameter value satisfies a preset resource constraint condition from at least one candidate cloud function instance, to obtain a cloud function instance for performing legitimacy verification on the read data set.
[0158] In some embodiments, the service level constraint is: the time required for legitimacy verification of a specified number of resource transfer read data is less than or equal to the specified time; the historical service parameter value includes: the historical running time and historical verification quantity corresponding to the legitimacy verification of the historical read data set by the cloud function instance; from the cloud function service pool, cloud function instances whose corresponding historical service parameter values meet the service level constraint, including: from the cloud function service pool, a part of cloud function instances are filtered out; the historical verification data of the filtered cloud function instances match the specified number; from a part of the cloud function instances, cloud function instances whose corresponding historical running time is less than or equal to the specified time are filtered out to obtain candidate cloud function instances.
[0159] In some embodiments, the running resource indication parameter value includes the number of cores; from at least one candidate cloud function instance, a cloud function instance is selected for performing legitimacy verification on a read data set, including: when the number of a portion of cloud function instances is greater than the number of candidate cloud function instances, determining a minimum number of cores for a portion of cloud function instances; selecting a cloud function instance corresponding to the minimum number of cores, and obtaining a cloud function instance for performing legitimacy verification on a read data set.
[0160] In some embodiments, the above-mentioned resource processing method also includes: when the number of a part of cloud function instances and the number of candidate cloud function instances are the same, when there are cloud function instances in the cloud function service pool whose corresponding number of cores is less than the minimum number of cores, the cloud function instance with the largest number of cores is selected from the cloud function instances with less than the minimum number of cores to obtain the cloud function instance used to verify the legitimacy of the read data set.
[0161] The present application also provides an application scenario, in which the resource transfer indication data of the present application is transaction data, and the blockchain in the blockchain system of the present application is a UTXO type blockchain.
[0162] The operation of blockchain requires complete verification of transaction data, which requires a large amount of computing resources. The cost of running a blockchain node server often requires the simultaneous bearing of fixed storage and computing costs. At the same time, blockchain transaction pressure is cyclical and instantaneous, requiring blockchain node transaction processing to have a certain degree of flexibility and to change computing resources as transaction pressure changes in order to achieve cost reduction and efficiency improvement.
[0163] In response to the problems of high node costs and inability to elastically scale computing requirements in existing blockchain full nodes, this application proposes a resource transfer method to process transaction data based on cloud functions and read-write sets to reduce user costs and adjust the computing resources used as needed.
[0164] The work of the transaction processing engine in the full node of the blockchain can be explained at the macro and micro levels. Taking the UTXO type blockchain as an example, at the macro level, the blockchain transaction processing engine is native as the core part of transaction packaging\verification, which reads and writes the storage of UTXO and returns the packaging or verification results of the blockchain. At the micro level, the blockchain transaction processing engine needs to process the transaction internally, process the transaction and its input as transaction output, and meet certain execution time limits to reduce the delay impact of the upper-level business. Therefore, for the purpose of this application, there are two main difficulties in the elastic scaling of blockchain transactions through cloud functions. One is how to separate the storage and calculation of blockchain transactions at the macro level to achieve normal packaging and verification, and the other is how to process the demand for elastic cloud function calculation of blockchain transactions at the micro level and meet a certain service level (Service-Level Agreement, SLA). Therefore, for ease of understanding, the technical description of this application is divided into two parts, one is the UTXO storage and calculation separation architecture based on cloud functions and read-write sets, and the other is the elastic blockchain transaction processing technology based on cloud function runtime scheduling. This application jointly realizes the processing of blockchain transactions based on cloud functions and read-write sets through these two parts.
[0165] like Fig. 9 The main modules and macro processing process of UTXO storage and computing separation based on cloud functions and read-write sets are shown, and each module is explained as follows:
[0166] Blockchain node: A blockchain node is mainly composed of a fixed-cost cloud server, which is used to handle external communications with other nodes and complete the verification and packaging of block transactions.
[0167] Block Verifier and Packager: This is the module in the UTXO blockchain used to obtain transaction packaged blocks from the transaction pool and verify the legitimacy of the blocks.
[0168] Transaction validator: a module used to verify the legitimacy of transactions in a block. In traditional UTXO blockchains, this part is the module that fully executes the verification process of UTXO transactions. In this application, the main computing load of this module is decoupled to the cloud function service pool on the right, and it is only responsible for the reading and writing of basic read-write sets.
[0169] UTXO storage: the unspent output of blockchain transactions stored in blockchain nodes. The result of transaction processing is essentially reflected in the consumption and generation of UTXO, and is ultimately stored in UTXO storage.
[0170] Cloud function service pool: the main module for blockchain transaction calculation in this application, which is embodied as a cloud function selector and several cloud function (SCF) runtimes.
[0171] It should be noted that blockchain models are generally divided into UTXO type and account type. For UTXO type blockchains, their read-write sets are directly reflected in transactions, while for account type blockchains, it is necessary to determine whether to have a read-write set based on the function of the blockchain system itself. If the account type blockchain system has a read-write set, it can also apply this application for flexible transaction processing.
[0172] Based on the above modules, such as Fig. 9 The various steps of the UTXO storage-computing separation architecture based on cloud functions and read-write sets are described in detail as follows:
[0173] 1. Packaging and receiving blocks: During the execution process, the UTXO blockchain full node reads the required packaged transactions from the memory pool to obtain the block to be executed, or obtains a block that needs to be verified from other blockchains. After the block is verified for legitimacy, the block body needs to be verified, that is, the transaction of the block:
[0174] TXs=TXs1∪TXs2U…UTXs N
[0175] As shown above, TXs is a collection of all transactions included or received in a new block.
[0176] 2. Analyze and submit the UTXO read set:
[0177] After receiving the block in the block packaging and validator, the transaction validator analyzes the TXs transaction in it and obtains the input and output of each transaction, as follows:
[0178] TXs i ={Inputs i , Outputs i}
[0179] Among them, Inputs i All inputs of transaction i, which are reflected in the reading of several UTXOs and the additional unlocking scripts, Outputs i is the output script of transaction i.
[0180] During the transaction verification phase, we only need to analyze the transaction input and obtain its read set, as follows
[0181] TXs_read=(N,InputUTXOof(TXs))
[0182] Among them, N is the number of transactions, which is displayed at the beginning of the read set of TXs_read to facilitate the decoding of the set in the subsequent cloud function calculation. The InputsUTXOof() function is a function that extracts the input in the transaction and constructs it into a set, as follows:
[0183] InputUTXO of (Txs)=Inputs1∪Inputs2∪…∪Inputs N
[0184] The transaction validator then submits TXs_read to the cloud function service for transaction verification and ensures a certain quality of service (i.e. processing delay) during the interaction.
[0185] 3. Return and update the UTXO write set: The write set of UTXO is mainly divided into two parts, one is to delete the spent transaction output, and the other is to add new unspent transaction output. The cloud function server mainly returns the write set of the spent transaction output, and the transaction validator updates the corresponding new UTXO write set:
[0186] TXs_result = {Result i}
[0187] Result i ={TXhash j ,Output j}
[0188] The TXs_result returned by the cloud function server is an array of several transaction results. Each transaction result represents the UTXO input spent after a transaction is correctly executed, that is, the hash TXhash of the transaction. j and the output subscript Output j .
[0189] Based on the output of the verified transaction, the transaction validator can obtain the new UTXO part of the transaction as follows: New = OutputUTXOof(Txs_success) = Outputs1∪Outputs2∪…∪Outputs N , where OutputUTXOof() is a function for extracting a transaction output set. Each Outputs in the obtained set is an array. OutputUTXOof(Txs) and TXs_result represent the two parts of addition and deletion in the write set respectively.
[0190] Therefore, the final transaction validator’s write set is updated to:
[0191] Query=DELETE(TXs_result)+INSERT(New)
[0192] That is, corresponding delete and insert statements are constructed through TXs_result and New, and submitted to UTXO storage for update, where UTXO storage can be any relational / non-relational database storage, object storage, etc.
[0193] One of the main features of cloud functions is that they are charged based on the call, so they have a natural elastic cost advantage for businesses with high elastic computing requirements. This application decouples blockchain transaction processing into a process of separating storage and computing. In the computing part, multiple cloud function runtimes (i.e., the cloud function instances mentioned above) will be used for on-demand scheduling to achieve elastic blockchain transaction processing based on cloud function runtime scheduling.
[0194] refer to Fig.10 , which is a schematic diagram of elastic blockchain transaction processing based on cloud function runtime scheduling, where the cloud function service pool includes multiple cloud function runtimes, such as SCF-1, SCF-2, and SCF-4. Different cloud function runtimes represent cloud function runtime environments with different runtime core numbers and memory capacities. For example, SCF-1 represents an SCF runtime with 1 core and 4G memory, SCF-2 represents an SCF runtime with 2 cores and 8G memory, and SCF-4 represents an SCF runtime with 4 cores and 16G memory. By analogy, the ratio of cores to memory is generally 1:4.
[0195] Continue to refer Fig.10 , where the SCF selector is a module that schedules the UTXO read set of a transaction to a specific SCF runtime when processing blockchain transaction scheduling. The historical SCF execution result is a module that stores the number, time, and other information of blockchain transactions executed by SCF over a period of time. The SCF selector and the historical SCF execution result itself can also be a cloud function.
[0196] Continue to refer Fig.10 The steps of elastic blockchain transaction processing based on cloud function runtime scheduling are described in detail as follows:
[0197] 1. Read set and SLA parameters: During the execution of blockchain transactions, the transaction validator reads the transaction read set and constructs TXs\TXs read and sends it to the SCF service pool. The first to enter is the SCF selector. In the SCF selector, in addition to the input of the transaction TX, there are also SLA parameter settings, which can be set by the user in advance in the SCF selector, or sent by the transaction validator to the SCF selector in real time according to business needs. The simplest SLA parameter is reflected in a floating point number T and an integer N, indicating that the corresponding transaction write set of N transactions needs to be returned within T milliseconds.
[0198] 2. Get historical results: The SCF selector gets the historical SCF execution results. Given an integer k (e.g. 10), get the historical processing time of transactions from (Nk) to (N+k) and the number of SCF runtime cores used, that is:
[0199] History=<Core i ,Time i >=QUERY(N,k)
[0200] Among them, QUERY is a function that queries the historical SCF processing transaction results based on the input N and k. The obtained results are reflected in an array, in which the elements are tuples consisting of the SCF core number Core and the execution time Time.
[0201] 3. Scheduling SCF runtime: Based on the obtained <Core, Time> array, the SCF selector combines the SLA parameter T to calculate the minimum Core value in Time that is not greater than T (or only slightly greater than T), as follows:
[0202] X=MIN(Core i ), Time i ≤T
[0203] Among them, MIN is the function for calculating the minimum Core value in the array, and makes Time less than or equal to T. The obtained Core value is recorded in X, that is, the transaction read set is forwarded to SCF-X for execution. If there is no Time value greater than T in history, the next level of X with fewer cores is taken as X.
[0204] 4. Execute and return: After SCF-X obtains TXs and TXs_read, it executes and verifies the transaction according to the preset UTXO transaction verification rules, builds a write set based on the verified transactions and returns it to the selector.
[0205] 5. Write new execution results: After the SCF selector receives the execution result of the SCF-X runtime (i.e., the historical service parameter value mentioned above), it first records the round-trip time Rtt of the runtime and writes it to the historical SCF execution result for persistence, i.e., constructs a tuple of <N, X, Rtt>, where N corresponds to the number of transactions mentioned above, X corresponds to the number of cores in the SCF runtime, and Rtt corresponds to the execution time, i.e., the Time field in the historical data. The SCF selector then returns the execution result to the transaction validator, and the execution engine is completed. Therefore, if the execution time of this block is too long, more cores will be executed in the next SCF selector's work; conversely, the SCF selector will select fewer cores in the next execution. The number of cores is directly related to the user's SCF fee. Therefore, this application will achieve the purpose of flexibly selecting SCF services and further reducing costs.
[0206] In this application, the UTXO storage and computing separation architecture based on cloud functions and read-write sets decouples computing into cloud functions with lower costs and pay-per-call, so that the processing of blockchain transactions does not need to rely on high fixed computing costs, reducing the daily costs of node operations. By using the SCF selector to selectively schedule SCF runtimes with different core numbers, the needs of using high-performance computing environments during peak periods and low-performance computing environments during trough periods are met. Without significantly increasing latency, computing requirements and costs can be increased or decreased according to transaction pressure, further reducing node computing costs.
[0207] 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.
[0208] Based on the same inventive concept, the embodiment of the present application also provides a resource processing device for implementing the resource 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 resource processing method device embodiments provided below can refer to the above limitations on the resource processing method, and will not be repeated here.
[0209] In some embodiments, Fig.11As shown, a resource processing method device 1100 is provided, including:
[0210] A data acquisition module 1102 is used to acquire at least one resource transfer indication data to be processed in the blockchain system;
[0211] The transfer-out resource reading module 1104 is used to read at least one transfer-out resource indicated by at least one resource transfer indication data from the resource pool of the blockchain system, determine at least one corresponding resource transfer read data according to the read transfer-out resource, and obtain a read data set including at least one resource transfer read data;
[0212] A read data set sending module 1106 is used to send the read data set to the cloud function server;
[0213] The write data set receiving module 1108 is used to receive the write data set fed back by the cloud function server; the write data set includes resource transfer write data, and the resource transfer write data is determined by the cloud function after verifying the legitimacy of each resource transfer read data in the read data set, and then based on the verified resource transfer read data;
[0214] The resource update module 1110 is used to determine the resources to be updated and the update operation for the resource pool according to the resource transfer write data in the write data set, and update the resources to be updated in the resource pool according to the update operation.
[0215] The resource processing method and device obtains at least one resource transfer indication data to be processed in the blockchain system, reads at least one transfer-out resource indicated by at least one resource transfer indication data of the resource processing from the resource pool of the blockchain system, determines at least one corresponding resource transfer read data according to the read transfer-out resource, obtains a read data set including at least one resource transfer read data of the resource processing, sends the resource processing read data set to the cloud function server, receives a write data set fed back by the resource processing cloud function server, the resource processing write data set includes resource transfer write data, the resource processing resource transfer write data is determined according to the resource transfer read data that passes the verification after the cloud function verifies the legitimacy of each resource transfer read data in the resource processing read data set, and finally determines the resources to be updated and the update operation for the resource processing resource pool according to the resource transfer write data in the resource processing write data set, updates the resource processing resources to be updated in the resource processing resource pool according to the resource processing update operation, realizes the separation of storage and calculation of blockchain nodes through read-write sets and cloud functions, decouples the calculation into cloud functions with lower cost and pay-per-call, so that the blockchain nodes do not need to rely on high fixed computing costs for resource processing, and reduce the operating costs of blockchain nodes.
[0216] In some embodiments, each resource transfer indication data includes resource transfer input data; a transfer-out resource reading module is used to obtain a resource transfer identifier and a resource transfer index from the resource transfer input data of the targeted resource transfer indication data for each of at least one resource transfer indication data; the resource transfer identifier is used to identify historical resource transfer indication data, and the resource transfer index points to one of at least one transfer-in resource obtained by performing resource transfer based on the historical resource transfer indication data; according to the resource transfer identifier and the resource transfer index, the transfer-out resource indicated by the targeted resource transfer indication data is read from the resource pool of the blockchain system.
[0217] In some embodiments, the transfer-out resource reading module is also used to determine at least one candidate resource associated with the resource transfer identifier from the resource pool of the blockchain system; determine the target resource associated with the resource transfer index from the at least one candidate resource associated with the resource transfer identifier; read the target resource to obtain the transfer-out resource indicated by the resource transfer indication data.
[0218] In some embodiments, each resource transfer indication data includes resource transfer input data; the above-mentioned resource processing device also includes: an unlocking script acquisition module, which is used to obtain the unlocking script of the resource transfer indication data for each of at least one resource transfer indication data from the included resource transfer input data; the transfer-out resource reading module is also used to determine the resource transfer reading data for the resource transfer indication data based on the transfer-out resources indicated by the resource transfer indication data and the unlocking script for the resource transfer indication data.
[0219] In some embodiments, a resource update module is used to, in a resource pool, determine the transferred-out resources corresponding to the resource transfer write data in a write data set as resources to be deleted, and determine the update operation on the resources to be deleted as a deletion operation; determine the transferred-in resources obtained by performing resource transfer on the resources to be deleted as resources to be inserted, and determine the update operation on the resources to be inserted as an insertion operation; in the resource pool, delete the resources to be deleted according to the deletion operation, and insert the resources to be inserted according to the insertion operation.
[0220] In some embodiments, the resource update module is also used to determine resource transfer indication data corresponding to the resource to be deleted; extract resource transfer output data from the resource transfer indication data corresponding to the resource to be deleted; determine the input resource indicated by the resource transfer output data as the input resource obtained by transferring the resource to the resource to be deleted, and obtain the resource to be inserted.
[0221] In some embodiments, a cloud function is determined by a cloud function server scheduling a cloud function instance in a cloud function service pool, and the running resource indication parameters corresponding to each cloud function instance in the cloud function service pool are different; the above-mentioned resource transfer device also includes a scheduling module for determining a service level constraint; obtaining a historical service parameter value corresponding to each cloud function instance in the cloud function service pool, the historical service parameter value being used to characterize the service level of the corresponding cloud function instance for verifying the legitimacy of a historical read data set; from the cloud function service pool, screening cloud function instances whose corresponding historical service parameter values meet the service level constraint conditions; when screening to obtain at least one candidate cloud function instance, selecting a cloud function instance for verifying the legitimacy of the read data set from the at least one candidate cloud function instance.
[0222] In some embodiments, the scheduling module is also used to obtain the operating resource indication parameter value corresponding to at least one candidate cloud function instance; from at least one candidate cloud function instance, select a cloud function instance whose operating resource indication parameter value meets the preset resource constraint condition, and obtain a cloud function instance for verifying the legitimacy of the read data set.
[0223] In some embodiments, Fig.12 As shown, a resource processing method device 1200 is provided, including:
[0224] The read data set receiving module 1202 is used to receive a read data set sent by a blockchain node; the read data set includes at least one resource transfer read data, the resource transfer read data is determined according to the resource read by the blockchain node from the resource pool, and the read resource is a transfer-out resource indicated by at least one resource transfer indication data to be processed;
[0225] The legality verification module 1204 is used to verify the legality of each resource transfer read data in the read data set through a cloud function, determine the resource transfer write data according to the verified resource transfer read data, and obtain a write data set including the resource transfer write data;
[0226] The write data set feedback module 1206 is used to feed back the write data set to the blockchain node; the write data set is used to instruct the blockchain node to transfer the write data according to the resources in the write data set, determine the resources to be updated and the update operation for the resource pool, and update the resources to be updated in the resource pool according to the update operation.
[0227] The resource processing device receives a read data set sent by a blockchain node; the read data set includes at least one resource transfer read data, the resource transfer read data is determined according to the resource read by the blockchain node from the resource pool, the read resource is a transfer-out resource indicated by at least one resource transfer indication data to be processed, and the legitimacy of each resource transfer read data in the read data set is verified through a cloud function, and the resource transfer write data is determined according to the verified resource transfer read data, and a write data set including the resource transfer write data is obtained, and the write data set is sent to the blockchain node. The write data set is used to instruct the blockchain node to determine the resources to be updated and the update operation for the resource pool according to the resource transfer write data in the write data set, and update the resources to be updated in the resource pool according to the update operation. Since the legitimacy of the read data set sent by the blockchain node can be verified through the cloud function, the blockchain node can decouple the calculation into a cloud function with lower cost and pay-per-call, so that there is no need to rely on high fixed computing costs for resource processing, thereby reducing the operating cost of the blockchain node.
[0228] In some embodiments, a cloud function is a cloud function instance scheduled from a cloud function service pool, and the running resource indication parameters corresponding to each cloud function instance in the cloud function service pool are different; the above-mentioned resource processing device also includes a scheduling module, which is used to determine the service level constraint conditions; obtain the historical service parameter values corresponding to each cloud function instance in the cloud function service pool, and the historical service parameter values are used to represent the service level of the corresponding cloud function instance for legitimacy verification of the historical read data set; from the cloud function service pool, filter the cloud function instances whose corresponding historical service parameter values meet the service level constraint conditions; when at least one candidate cloud function instance is obtained through screening, select a cloud function instance from the at least one candidate cloud function instance for legitimacy verification of the read data set.
[0229] In some embodiments, the scheduling module is also used to obtain the operating resource indication parameter value corresponding to at least one candidate cloud function instance; from at least one candidate cloud function instance, select a cloud function instance whose corresponding operating resource indication parameter value meets the preset resource constraint condition, and obtain a cloud function instance for verifying the legitimacy of the read data set.
[0230] In some embodiments, the service level constraint is: the time required for legitimacy verification of a specified number of resource transfer read data is less than or equal to a specified time; the historical service parameter value includes: the historical running time and historical verification quantity corresponding to the legitimacy verification of the historical read data set by the cloud function instance; the scheduling module is also used to filter out a portion of cloud function instances from the cloud function service pool; the historical verification data of the filtered cloud function instances matches a specified number; from a portion of the cloud function instances, filter out cloud function instances whose corresponding historical running time is less than or equal to the specified time to obtain candidate cloud function instances.
[0231] In some embodiments, the running resource indication parameter value includes the number of cores; the scheduling module is also used to: determine the minimum number of cores of a part of the cloud function instances when the number of the part of the cloud function instances is greater than the number of candidate cloud function instances; select the cloud function instance corresponding to the minimum number of cores to obtain the cloud function instance used to verify the legitimacy of the read data set.
[0232] In some embodiments, the scheduling module is also used for: when the number of a part of the cloud function instances is the same as the number of candidate cloud function instances, when there are cloud function instances in the cloud function service pool whose corresponding number of cores is less than the minimum number of cores, the cloud function instance with the largest number of cores is selected from the cloud function instances with less than the minimum number of cores to obtain the cloud function instance used to verify the legitimacy of the read data set.
[0233] Each module in the above resource processing method device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module 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 operations corresponding to each module.
[0234] In some embodiments, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Fig.13As 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 resource processing method is implemented.
[0235] In some embodiments, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig.14 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. 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 an 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 manner 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 resource processing method 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.
[0236] Those skilled in the art will understand that Fig.13 , Fig.14The 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.
[0237] 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 resource processing method in any of the above embodiments are implemented.
[0238] In some embodiments, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the resource processing method in any of the above embodiments are implemented.
[0239] In some embodiments, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of the resource processing method in any of the above embodiments are performed.
[0240] 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.
[0241] 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.
[0242] The technical features of the above embodiments may be combined arbitrarily. 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.
[0243] 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 understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations 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 resource processing method, characterized in that: The method comprises: Obtain at least one pending resource transfer indication data in the blockchain system; Reading at least one transfer-out resource indicated by the at least one resource transfer indication data from a resource pool of the blockchain system, determining at least one corresponding resource transfer read data according to the read transfer-out resource, and obtaining a read data set including the at least one resource transfer read data; Sending the read data set to a cloud function server; Receive a write data set fed back by the cloud function server; the write data set includes resource transfer write data, and the resource transfer write data is determined based on the resource transfer read data that has passed the verification after the cloud function verifies the legitimacy of each resource transfer read data in the read data set; According to the resource transfer write data in the write data set, the resources to be updated and the update operation for the resource pool are determined, and the resources to be updated are updated in the resource pool according to the update operation.
2. The method according to claim 1, characterized in that Each of the resource transfer indication data includes resource transfer input data; and reading at least one transfer-out resource indicated by at least one resource transfer indication data from the resource pool of the blockchain system includes: For each of the at least one resource transfer indication data, obtaining a resource transfer identifier and a resource transfer index from the resource transfer input data of the resource transfer indication data; the resource transfer identifier is used to identify the historical resource transfer indication data, and the resource transfer index points to one of the at least one transfer-in resource obtained by performing resource transfer based on the historical resource transfer indication data; According to the resource transfer identifier and the resource transfer index, the transfer-out resources indicated by the resource transfer indication data are read from the resource pool of the blockchain system.
3. The method according to claim 2, characterized in that The step of reading the transfer-out resource indicated by the resource transfer indication data from the resource pool of the blockchain system according to the resource transfer identifier and the resource transfer index includes: Determine at least one candidate resource associated with the resource transfer identifier from a resource pool of the blockchain system; Determining a target resource associated with the resource transfer index from at least one candidate resource associated with the resource transfer identifier; The target resource is read to obtain the transfer-out resource indicated by the resource transfer indication data.
4. The method according to claim 2, characterized in that: Each of the resource transfer indication data includes resource transfer input data; the method further includes: For each of the at least one resource transfer indication data, obtaining an unlocking script for the resource transfer indication data from the included resource transfer input data; The step of determining at least one corresponding resource transfer read data according to the read transfer-out resource comprises: The resource transfer read data corresponding to the resource transfer indication data is determined according to the transfer-out resources indicated by the resource transfer indication data and the unlocking script corresponding to the resource transfer indication data.
5. The method according to claim 1, characterized in that The step of transferring write data from resources in the write data set, determining resources to be updated and an update operation for the resource pool, and updating the resources to be updated in the resource pool according to the update operation includes: In the resource pool, determining the transferred-out resources corresponding to the resource transfer write data in the write data set as resources to be deleted, and determining the update operation for the resources to be deleted as a deletion operation; Determine the transferred-in resource obtained by transferring the resource to be deleted as the resource to be inserted, and determine the update operation on the resource to be inserted as the insertion operation; In the resource pool, the resource to be deleted is deleted according to the deletion operation, and the resource to be inserted is inserted according to the insertion operation.
6. The method according to claim 5, characterized in that The step of determining the transferred-in resources obtained by transferring the resources to be deleted as the resources to be inserted includes: Determining resource transfer indication data corresponding to the resource to be deleted; Extracting resource transfer output data from the resource transfer indication data corresponding to the resource to be deleted; The input resource indicated by the resource transfer output data is determined as the input resource obtained by performing resource transfer on the resource to be deleted, so as to obtain the resource to be inserted.
7. The method according to any one of claims 1 to 6, characterized in that: The cloud function is determined by the cloud function server scheduling the cloud function instance in the cloud function service pool, and the running resource indication parameters corresponding to each cloud function instance in the cloud function service pool are different; The scheduling of cloud function instances in the cloud function service pool includes: Determine service level constraints; Obtaining a historical service parameter value corresponding to each cloud function instance in the cloud function service pool, wherein the historical service parameter value is used to represent a service level of the corresponding cloud function instance for validating the legitimacy of the historical read data set; Filtering, from the cloud function service pool, cloud function instances whose corresponding historical service parameter values satisfy the service level constraint; When at least one candidate cloud function instance is obtained through screening, a cloud function instance for performing validity verification on the read data set is selected from the at least one candidate cloud function instance.
8. The method according to claim 7, characterized in that The step of selecting a cloud function instance for performing legality verification on the read data set from the at least one candidate cloud function instance includes: Obtaining a running resource indication parameter value corresponding to each of the at least one candidate cloud function instances; From the at least one candidate cloud function instance, select a cloud function instance whose running resource indication parameter value satisfies a preset resource constraint condition, and obtain a cloud function instance for performing legitimacy verification on the read data set.
9. A resource processing method, characterized in that: The method comprises: Receive a read data set sent by a blockchain node; the read data set includes at least one resource transfer read data, the resource transfer read data is determined according to the resource read by the blockchain node from the resource pool, and the read resource is a transfer-out resource indicated by at least one resource transfer indication data to be processed; Through the cloud function, the legitimacy of each resource transfer read data in the read data set is verified, and the resource transfer write data is determined according to the verified resource transfer read data, so as to obtain a write data set including the resource transfer write data; Feeding back the write data set to the blockchain node; The write data set is used to instruct the blockchain node to determine the resources to be updated and the update operation for the resource pool according to the resource transfer write data in the write data set, and update the resources to be updated in the resource pool according to the update operation.
10. The method according to claim 9, characterized in that The cloud function is a cloud function instance scheduled from a cloud function service pool, and the running resource indication parameters corresponding to each cloud function instance in the cloud function service pool are different; the method further includes: Determine service level constraints; Obtaining a historical service parameter value corresponding to each cloud function instance in the cloud function service pool, wherein the historical service parameter value is used to represent a service level of the corresponding cloud function instance for validating the legitimacy of the historical read data set; Filtering, from the cloud function service pool, cloud function instances whose corresponding historical service parameter values satisfy the service level constraint; When at least one candidate cloud function instance is obtained through screening, a cloud function instance for performing validity verification on the read data set is selected from the at least one candidate cloud function instance.
11. The method according to claim 10, characterized in that The step of selecting a cloud function instance for performing legality verification on the read data set from the at least one candidate cloud function instance includes: Obtaining a running resource indication parameter value corresponding to each of the at least one candidate cloud function instances; From the at least one candidate cloud function instance, select a cloud function instance whose corresponding running resource indication parameter value satisfies a preset resource constraint condition, and obtain a cloud function instance for performing legitimacy verification on the read data set.
12. The method according to claim 10, characterized in that The service level constraint condition is: the time required for the legality verification of a specified number of resource transfer read data is less than or equal to the specified time; the historical service parameter value includes: the historical running time and the historical verification quantity corresponding to the legality verification of the historical read data set by the cloud function instance; The step of screening, from the cloud function service pool, cloud function instances whose corresponding historical service parameter values satisfy the service level constraint condition comprises: Filtering out a portion of cloud function instances from the cloud function service pool; the historical verification data of the filtered cloud function instances matches the specified number; From the portion of cloud function instances, filter the cloud function instances whose corresponding historical running time is less than or equal to the specified time to obtain candidate cloud function instances.
13. The method according to claim 12, characterized in that The running resource indication parameter value includes the number of cores; the selecting, from the at least one candidate cloud function instance, a cloud function instance for performing legality verification on the read data set includes: When the number of the cloud function instances of the portion is greater than the number of candidate cloud function instances, determining a minimum number of cores of the cloud function instances of the portion; Select the cloud function instance corresponding to the minimum number of cores to obtain the cloud function instance used to verify the legitimacy of the read data set.
14. The method according to claim 13, characterized in that The method further comprises: When the number of cloud function instances in the part is consistent with the number of candidate cloud function instances, when there is a cloud function instance in the cloud function service pool whose corresponding number of cores is less than the minimum number of cores, the cloud function instance with the largest number of cores is selected from the cloud function instances with less than the minimum number of cores to obtain the cloud function instance used to verify the legitimacy of the read data set.
15. A resource processing device, characterized in that: The device comprises: A data acquisition module, used to acquire at least one resource transfer indication data to be processed in the blockchain system; A transfer-out resource reading module, configured to read at least one transfer-out resource indicated by the at least one resource transfer indication data from a resource pool of the blockchain system, determine at least one corresponding resource transfer read data according to the read transfer-out resource, and obtain a read data set including the at least one resource transfer read data; A read data set sending module, used to send the read data set to a cloud function server; A write data set receiving module, used to receive the write data set fed back by the cloud function server; the write data set includes resource transfer write data, and the resource transfer write data is determined by the cloud function after verifying the legitimacy of each resource transfer read data in the read data set, and then based on the verified resource transfer read data; The resource update module is used to determine the resources to be updated and the update operation for the resource pool according to the resource transfer write data in the write data set, and update the resources to be updated in the resource pool according to the update operation.
16. A resource processing device, characterized in that: The device comprises: A read data set receiving module, used to receive a read data set sent by a blockchain node; the read data set includes at least one resource transfer read data, the resource transfer read data is determined according to the resource read by the blockchain node from the resource pool, and the read resource is a transfer-out resource indicated by at least one resource transfer indication data to be processed; A legality verification module, used to verify the legality of each resource transfer read data in the read data set through a cloud function, determine the resource transfer write data according to the verified resource transfer read data, and obtain a write data set including the resource transfer write data; A write data set feedback module is used to feed back the write data set to the blockchain node; the write data set is used to instruct the blockchain node to determine the resources to be updated and the update operation for the resource pool according to the resource transfer write data in the write data set, and update the resources to be updated in the resource pool according to the update operation.
17. 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 14 are implemented.
18. 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 14 are implemented.
19. 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 14 are implemented.