Contract process processing method and device, equipment, medium and product

By estimating the number of contract processes based on the transaction distribution ratio and contract process capacity in the blockchain and preheating the processes, the problem of frequent switching of contract processes is solved and transaction execution efficiency is improved.

CN120634719APending Publication Date: 2025-09-12TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410284882.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-12
Publication Date
2025-09-12

AI Technical Summary

Technical Problem

Traditional contract processes in the blockchain are dynamically started and closed through streaming transactions, resulting in frequent switching, wasting time on starting processes, waiting for processes, and other tasks, and inefficiency.

Method used

The number of contract processes is estimated based on the distribution ratio of transactions and the transaction processing capacity of the contract process. By preheating the process, the switching of contract processes is reduced, thereby improving transaction execution efficiency.

Benefits of technology

By rationally allocating contract processes, process switching is reduced and transaction execution efficiency is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120634719A_ABST
    Figure CN120634719A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a contract process processing method and device, equipment, a medium and a product, and is applied to the field of block chains, and the method comprises the steps: obtaining a contract transaction distribution table corresponding to a to-be-processed block; constructing a reference contract transaction processing table according to the reference transaction processing amount corresponding to each smart contract; based on the contract transaction distribution table and the reference contract transaction processing table, generating a first contract process distribution table according to a contract process distribution rule; on the basis of the number of contract processes indicated by the first contract process distribution table, executing process pre-starting processing for the N intelligent contracts; and executing the M contract transactions in the to-be-processed block in each contract process after the process pre-start processing. According to the method, the quantity of the contract processes can be pre-estimated based on the distribution proportion of the transaction and the transaction processing capability of the contract processes so as to execute contract process preheating, so that the switching of the contract processes can be reduced, and the transaction execution efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and in particular to a method for processing a contract process, a device for processing a contract process, a computer device, a computer-readable storage medium, and a computer program product. Background Art

[0002] In blockchains, the smart contract engine of blockchain nodes uses contract processes to execute smart contracts. Traditionally, this approach primarily starts contract processes based on streaming transactions. This means that when a transaction arrives, the corresponding contract process is started based on the smart contract to which the transaction belongs. If the number of current contract processes reaches a threshold and there are no contract processes for that smart contract, the transaction must wait until other contract processes become idle before executing the current transaction. This approach dynamically starts and stops contract processes in a streaming manner, resulting in frequent switching of contract processes, wasting significant time on starting and waiting for processes, and inefficient execution. Summary of the Invention

[0003] The embodiments of the present application propose a method, device, equipment, medium and product for processing contract processes, which can estimate the number of contract processes based on the distribution ratio of transactions and the transaction processing capacity of the contract process to perform contract process preheating, reduce the switching of contract processes, and improve transaction execution efficiency.

[0004] On the one hand, an embodiment of the present application provides a method for processing a contract process, which is applied to a blockchain node, and the method includes:

[0005] Get the contract transaction distribution table corresponding to the pending block. The contract transaction distribution table is used to indicate the N smart contracts that need to be called to process the M contract transactions in the pending block, as well as the number of transactions that each smart contract needs to process. Both M and N are positive integers.

[0006] Based on the reference transaction processing volume corresponding to each smart contract, a reference contract transaction processing table is constructed; the reference transaction processing volume corresponding to each smart contract is used to indicate the maximum number of transactions that the contract process of the corresponding smart contract is allowed to process per unit time; one contract process is used to run one smart contract;

[0007] Based on the contract transaction distribution table and the reference contract transaction processing table, a first contract process allocation table is generated according to the contract process allocation rule; the first contract process allocation table is used to indicate: the number of contract processes to be started for each smart contract in the N smart contracts;

[0008] Based on the number of contract processes indicated by the first contract process allocation table, process pre-start processing is performed for N smart contracts; and M contract transactions in the pending block are executed in each contract process after the process pre-start processing.

[0009] In one aspect, an embodiment of the present application provides a contract process processing device, which is applied to a blockchain node, and includes:

[0010] An acquisition unit is used to obtain the contract transaction distribution table corresponding to the block to be processed. The contract transaction distribution table is used to indicate the N smart contracts that need to be called to process the M contract transactions in the block to be processed, as well as the number of transactions that each smart contract needs to process. Both M and N are positive integers.

[0011] A processing unit is used to construct a reference contract transaction processing table based on the reference transaction processing volume corresponding to each smart contract; the reference transaction processing volume corresponding to each smart contract is used to indicate the maximum number of transactions that the contract process of the corresponding smart contract is allowed to process per unit time; one contract process is used to run one smart contract;

[0012] The processing unit is further configured to generate a first contract process allocation table according to the contract process allocation rule based on the contract transaction distribution table and the reference contract transaction processing table; the first contract process allocation table is configured to indicate the number of contract processes to be started for each of the N smart contracts;

[0013] The processing unit is further used to perform process pre-start processing for N smart contracts based on the number of contract processes indicated by the first contract process allocation table; and execute M contract transactions in the pending block in each contract process after the process pre-start processing.

[0014] In one possible implementation, any one of N smart contracts is represented as smart contract i, and the contract process corresponding to smart contract i is represented as contract process i; the processing unit is configured to perform the following operations:

[0015] Use the time series intelligent model to predict the transaction processing capacity of contract process i and obtain the reference transaction processing volume corresponding to smart contract i; or

[0016] Obtain historical transaction processing data corresponding to contract process i within a historical time period, and determine the reference transaction processing volume corresponding to smart contract i based on the historical transaction processing data.

[0017] In one possible implementation, the processing unit generates a first contract process allocation table based on the contract transaction distribution table and the reference contract transaction processing table according to the contract process allocation rule, and is configured to perform the following operations:

[0018] Get the total number K of contract processes included in the blockchain node, where K is a positive integer;

[0019] Based on the contract transaction distribution table and the reference contract transaction processing table, calculate the proportion of contract transactions that smart contract i needs to process according to the contract process allocation rules;

[0020] Based on the total number of processes and the proportion of contract transactions that smart contract i needs to process, the number of contract processes that smart contract i needs to start is calculated.

[0021] In one possible implementation, if the blockchain node is a master node, the acquisition unit obtains the contract transaction distribution table corresponding to the block to be processed, and performs the following operations:

[0022] In response to the block signal, M contract transactions are obtained from the transaction pool and packaged into a block to be processed;

[0023] Analyze the transaction data of each contract transaction to obtain the smart contract that needs to be called for each contract transaction, so as to determine the N smart contracts that need to be called to process M contract transactions;

[0024] Based on M contract transactions and N smart contracts, a contract transaction distribution table of the block to be processed is constructed; wherein, a smart contract is used to process one or more contract transactions.

[0025] In a possible implementation, the processing unit is further configured to perform the following operations:

[0026] Parse the block signal and obtain the target transaction volume corresponding to the block to be packaged;

[0027] Get the total number of pending contract transactions in the transaction pool;

[0028] If the target transaction volume is less than or equal to the total quantity, contract transactions are obtained from the trading pool according to the target transaction volume;

[0029] If the target transaction volume is greater than the total quantity, contract transactions will be obtained from the trading pool according to the total quantity.

[0030] In one possible implementation, after generating the first contract process allocation table according to the contract process allocation rule based on the contract transaction distribution table and the reference contract transaction processing table, the processing unit is further configured to perform the following operations:

[0031] Based on the first contract process allocation table, call N smart contracts in the K contract processes included in the master node to execute M contract transactions, and obtain N contract execution results; one smart contract corresponds to one contract execution result, and K is a positive integer;

[0032] Parse N contract execution results to obtain the transaction execution time corresponding to each smart contract;

[0033] According to the transaction execution time of N smart contracts, the first contract process allocation table is updated to obtain the second contract process allocation table.

[0034] In one possible implementation, the processing unit updates the first contract process allocation table according to the transaction execution time of N smart contracts to obtain a second contract process allocation table for performing the following operations:

[0035] Based on the transaction execution time of N smart contracts, the contract transaction distribution table, and the reference contract transaction processing table, calculate the target contract transaction processing table for N smart contracts; the target contract transaction processing table includes the target transaction processing volume corresponding to each smart contract;

[0036] Based on the contract transaction distribution table and the target contract transaction processing table, a second contract process allocation table is determined.

[0037] In one possible implementation, any one of N smart contracts is represented as smart contract i, and the contract process corresponding to smart contract i is represented as contract process i. The processing unit calculates a target contract transaction processing table for the N smart contracts based on the transaction execution time of the N smart contracts, the contract transaction distribution table, and the reference contract transaction processing table, and performs the following operations:

[0038] Determine the transaction execution time of smart contract i from the transaction execution time of N smart contracts;

[0039] Determine the number of transactions that smart contract i needs to process from the contract transaction distribution table, and determine the reference transaction processing volume corresponding to smart contract i from the reference contract transaction processing table;

[0040] Based on the number of transactions of smart contract i, the reference transaction processing volume, and the transaction running time, the target transaction processing volume corresponding to smart contract i is obtained.

[0041] In one possible implementation, the processing unit updates the first contract process allocation table according to the transaction execution time of the N smart contracts, and after obtaining the second contract process allocation table, is further configured to perform the following operations:

[0042] Based on the first contract process allocation table and the second contract process allocation table, a contract process adjustment table is calculated; the contract process adjustment table is used to indicate the number of processes that need to be adjusted for each smart contract in the N smart contracts;

[0043] The contract process adjustment table is sent to at least one slave node in the blockchain to trigger any slave node to adjust the number of processes of the N smart contracts after the execution process pre-start processing based on the contract process adjustment table.

[0044] In a possible implementation, the processing unit is further configured to perform the following operations:

[0045] In the process of executing M contract transactions based on the first contract process allocation table, obtaining the target transaction processing volume of contract process i corresponding to any smart contract i;

[0046] Obtain the reference transaction volume of smart contract i predicted by the time series intelligent model;

[0047] Based on the reference transaction processing volume and target transaction processing volume of smart contract i, a time series intelligent model is trained; wherein, the trained time series intelligent model is used to predict the transaction processing capacity of each contract process in the blockchain.

[0048] In one possible implementation, the processing unit trains a time series intelligent model based on the reference transaction processing volume and the target transaction processing volume of smart contract i to perform the following operations:

[0049] Performing data preprocessing on the acquired target transaction processing volume; wherein data preprocessing includes: any one or more of data cleaning, data format conversion, and data deduplication;

[0050] Calculate the difference between the reference transaction volume of smart contract i and the target transaction volume after data preprocessing;

[0051] Adjust the model parameters of the time series intelligent model based on the difference data.

[0052] In one possible implementation, if the blockchain node is a master node, the processing unit is further configured to perform the following operations:

[0053] Sending the first contract process allocation table to at least one slave node in the blockchain, so that any slave node performs process pre-start processing based on the first contract process allocation table, and executes M contract transactions in the pending block in each contract process after the process pre-start processing, to obtain a first transaction execution result;

[0054] receiving the first transaction execution result returned by each slave node;

[0055] Based on the first transaction execution result of each slave node and the second transaction execution result of the master node, block consensus processing is performed on the block to be processed; wherein, the block to be processed after the block consensus processing is added to the blockchain.

[0056] On the one hand, an embodiment of the present application provides a computer device, which includes a processor, an input device, an output device and a memory; a computer program is stored in the memory; when the computer program is executed by the processor, the processing method of the above-mentioned contract process is executed.

[0057] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it executes the processing method of the above-mentioned contract process.

[0058] On the one hand, an embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it executes the processing method of the above-mentioned contract process.

[0059] In an embodiment of the present application, a contract transaction distribution table corresponding to the block to be processed can be obtained, and the contract transaction distribution table is used to indicate the N smart contracts that need to be called to process the M contract transactions in the block to be processed, and the number of transactions that each smart contract needs to process, where M and N are both positive integers; a reference contract transaction processing table is constructed based on the reference transaction processing volume corresponding to each smart contract; the reference transaction processing volume corresponding to each smart contract is used to indicate the maximum number of transactions allowed to be processed by the contract process of the corresponding smart contract per unit time, and one contract process is used to run one smart contract; based on the contract transaction distribution table and the reference contract transaction processing table, a first contract process allocation table is generated according to the contract process allocation rules; the first contract process allocation table is used to indicate the number of contract processes that need to be started for each smart contract in the N smart contracts; based on the number of contract processes indicated by the first contract process allocation table, process pre-start processing is performed for the N smart contracts; and the M contract transactions in the block to be processed are executed in each contract process after the process pre-start processing. It can be seen that before the transaction is executed, this application can estimate the number of contract processes that need to be started for each smart contract according to the distribution ratio of contract transactions and the transaction processing capacity of the contract process, and then preheat the contract process of the corresponding smart contract according to the estimated number of contract processes. Since the contract processes are reasonably allocated after the process preheating, when the transaction needs to be executed, the transaction can be executed based on the reasonably allocated contract processes, reducing process switching and the like, thereby improving the efficiency of transaction execution. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present application. For ordinary technical objects in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0061] Figure 1 This is a lane comparison diagram of a contract process preheating provided by an embodiment of the present application;

[0062] Figure 2a This is a schematic diagram of the structure of a blockchain system provided by an embodiment of the present application;

[0063] Figure 2b This is a schematic diagram of the structure of a blockchain provided by an embodiment of the present application;

[0064] Figure 3a This is a schematic diagram of the architecture of a contract process processing system provided in an embodiment of the present application;

[0065] Figure 3b This is a module structure diagram of a blockchain node provided in an embodiment of the present application;

[0066] Figure 4 This is a flowchart of a method for processing a contract process provided by an embodiment of the present application;

[0067] Figure 5 It is a shared topology diagram of a contract transaction distribution table provided in an embodiment of the present application;

[0068] Figure 6 This is a schematic diagram of a calculation flow of a first contract process allocation table provided in an embodiment of the present application;

[0069] Figure 7 This is a flowchart of another method for processing a contract process provided by an embodiment of the present application;

[0070] Figure 8a This is a schematic diagram of a calculation flow of a second contract process allocation table provided in an embodiment of the present application;

[0071] Figure 8b This is a schematic diagram of a calculation flow of a contract process adjustment table provided in an embodiment of the present application;

[0072] Figure 9 This is a flow chart of a training method for a time series intelligent model provided in an embodiment of the present application;

[0073] Figure 10a This is a flow chart of a model prediction process provided by an embodiment of the present application;

[0074] Figure 10b This is a flow chart of a model training process provided by an embodiment of the present application;

[0075] Figure 11 This is a flowchart of a contract process scheduling method provided by an embodiment of the present application;

[0076] Figure 12 This is a schematic diagram of a process scheduling process based on contract time consumption drive provided by an embodiment of the present application;

[0077] Figure 13 This is a schematic diagram of a contract process scheduling process driven by a time series intelligent model provided by an embodiment of the present application;

[0078] Figure 14 This is a schematic diagram of the structure of a contract process processing device provided in an embodiment of the present application;

[0079] Figure 15 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0080] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.

[0081] This application provides a contract process processing solution that can estimate the number of contract processes based on the distribution ratio of contract transactions in the block and the transaction processing capacity of the contract process before executing block transactions, thereby preheating (pre-starting) the contract process based on the number of contract processes, so that transactions can be executed in the contract process after the process is preheated. This solution can reduce the frequent switching of contract processes and improve the efficiency of transaction execution. Specifically, the process of the contract process processing solution proposed in this application is roughly as follows:

[0082] 1) When a blockchain node receives a block signal, it can obtain the contract transaction distribution table corresponding to the pending block. The contract transaction distribution table is used to indicate the N smart contracts that need to be called to process the M contract transactions in the pending block, as well as the number of transactions that each smart contract needs to process. Both M and N are positive integers.

[0083] 2) Blockchain nodes can obtain the reference transaction processing volume of each smart contract and construct a reference contract transaction processing table; the reference transaction processing volume corresponding to each smart contract is used to indicate the maximum number of transactions that the contract process of the corresponding smart contract is allowed to process per unit time; one contract process is used to run one smart contract; the reference transaction processing volume can be obtained by using a time series AI model or based on historical reference transaction processing data.

[0084] 3) Based on the contract transaction distribution table and the reference contract transaction processing table, a first contract process allocation table is generated according to the contract process allocation rule; the first contract process allocation table is used to indicate: the number of contract processes to be started for each smart contract in the N smart contracts;

[0085] 4) Preheating N smart contract execution processes based on the number of contract processes indicated by the first contract process allocation table (i.e., process pre-start processing); subsequently, executing the M contract transactions in the pending block directly in each contract process after the process pre-start processing, so as to facilitate block consensus on the pending block in the blockchain.

[0086] It can be seen from this that before the transaction is executed, this application can estimate the number of contract processes that need to be started for each smart contract according to the distribution ratio of contract transactions and the transaction processing capacity of the contract process, and then preheat the contract process of the corresponding smart contract according to the estimated number of contract processes. Since the contract processes are reasonably allocated after the process preheating, when the transaction needs to be executed, the transaction can be executed based on the reasonably allocated contract processes, reducing process switching and the like, thereby improving the efficiency of transaction execution.

[0087] The following is a detailed introduction to the relevant technical terms involved in this application solution.

[0088] 1. Smart contracts and contract processes

[0089] A smart contract is a computer protocol designed to communicate, verify, or execute contracts in an information-based manner. It allows for trusted transactions without a third party, making these transactions traceable and irreversible. In blockchain systems, smart contracts can include any type of contract, including resource contracts, game contracts, system contracts, node management contracts, and network configuration contracts.

[0090] A contract process is a program instance that executes a smart contract. Each contract process executes a smart contract in an independent runtime environment and handles transactions associated with that smart contract. Specifically, a contract process runs a smart contract, and a smart contract executes one or more contract transactions. Different types of smart contracts handle different types of transactions. For example, asset contracts handle transactions related to digital assets, while game contracts handle transactions related to gaming assets. It should be understood that the number and performance of contract processes directly impacts the blockchain system's ability to process transactions.

[0091] 2. Process pre-start.

[0092] Process pre-launch, also known as process warm-up, is an optimization technique primarily used to improve system responsiveness. Its key concept is to create and initialize contract processes in advance to reduce their startup time. In this application, process warm-up refers to adjusting the number of contract processes in advance based on predicted transaction processing demand. This ensures that contract processes are immediately available when new transactions arrive, improving system responsiveness and, consequently, transaction processing efficiency.

[0093] See Figure 1 , Figure 1 This is a lane comparison diagram of a contract process preheating provided by the embodiment of the present application. Figure 1 As shown, the upper part is the block scheduling swimlane diagram of the existing solution. The master node executes the block and then sends it to other slave nodes for block verification. Since real-time process switching is required, it takes a long time and is inefficient. The lower part is the swimlane diagram optimized by this application. Before block execution and block verification, each blockchain node (master node or slave node) performs process preheating (pre-start). After that, all transactions are executed in the pre-started contract process, without the need to repeatedly start and switch processes. Therefore, the process preheating technology used in this application can improve the system response speed and thus improve the efficiency of transaction processing.

[0094] 3. Blockchain.

[0095] A blockchain is essentially a decentralized database, a series of data blocks linked together using cryptographic methods. Each block contains relevant information used to verify its validity (forgery prevention) and generate the next block. Specifically, this application will provide a detailed introduction to blockchain systems and related terms, such as blockchain structure.

[0096] (1) Blockchain system:

[0097] See Figure 2a , Figure 2a This is a schematic diagram of the structure of a blockchain system provided by an embodiment of this application. Figure 2a As shown, the blockchain system can be a data sharing system. The so-called data sharing system refers to a system for sharing data between node devices. The data sharing system 100 may include multiple node devices 201. The multiple node devices 201 can refer to various computer devices in the data sharing system. The computer devices can be, for example, terminal devices or servers. The device types of different node devices 201 can be the same or different. For example, one node device 201 can be a terminal device and another node device 201 can be a server.

[0098] Specifically, each node device 201 can receive input information when performing normal operations and maintain the shared data within the data sharing system based on the received input information. For example, when any node device 201 in the blockchain system receives input information (e.g., a contract transaction), the node device 201 can obtain the target smart contract from the blockchain based on the contract identifier of the target smart contract carried in the transaction data of the contract transaction, call the target smart contract to execute the target transaction, and write the transaction execution result of the target transaction to the blockchain, so that each blockchain node on the blockchain can jointly maintain the transaction data of the target transaction.

[0099] (2) Blockchain nodes:

[0100] ①Node function:

[0101] a. Application functions are deployed in the blockchain to implement specific businesses based on actual business needs. They record data related to business functions (such as resource transfer functions, game business functions, etc.) to form record data. The record data carries a digital signature to indicate the source of the task data. The record data is sent to other nodes in the blockchain system for other nodes to add to the temporary block when they successfully verify the source and integrity of the record data.

[0102] b. Contract function: Any blockchain node in a blockchain system has the ability to call and execute a corresponding smart contract. A smart contract (or simply a contract) consists of three key elements: a commitment, an agreement, and a digital form. Therefore, it can expand the application scope of blockchain to all aspects of financial transactions, payments, settlements, and clearing. A smart contract is one that immediately executes the corresponding contract terms when a pre-compiled condition is triggered. Its operating principle is similar to that of an if-then statement in a computer program. Blockchain nodes run contract processes, each of which is used to run a smart contract. Upon reaching block consensus, the same smart contract must initiate one or more contract processes to execute the contract transactions it needs to process. Therefore, before reaching block consensus, this application can pre-heat the smart contract execution processes according to the first contract process allocation table calculated by the application scheme, so that when transactions are executed, the corresponding contract transactions can be executed according to the reasonably allocated contract processes.

[0103] ②Node type:

[0104] In blockchain networks, nodes can be primarily categorized by their function: master nodes and slave nodes. Master nodes are typically responsible for coordinating key network operations, such as generating new blocks, processing transactions, and initiating consensus. Slave nodes, on the other hand, execute tasks assigned by the master node, such as verifying transactions, storing data, and participating in consensus. In some blockchain designs, master nodes may rotate to ensure network decentralization and security.

[0105] ③Node identification:

[0106] Each node in a blockchain system has a corresponding node identifier. Furthermore, each node in a blockchain system can store the node identifiers of other nodes in the system, allowing it to subsequently broadcast generated blocks to other nodes in the blockchain system based on those identifiers. Each node maintains a node identifier list, as shown in the table below, storing the node name and node identifier in this node identifier list.

[0107] The node identifier may be an IP (Internet Protocol, a protocol for interconnecting networks) address or any other information that can be used to identify the node. Table 1 only uses the IP address as an example for description.

[0108] Table 1. Node ID list

[0109] Node Name Node ID Node 1 000.000.000.000 Node 2 111.111.111.111 … … Node N xxx.xxx.xxx.xxx

[0110] In the processing scheme of the contract process of the present application, it involves the interaction between different types of nodes, that is, the interaction between the master node and the slave node. For example, the master node can send the contract transaction distribution table to each slave node, so that each slave node can calculate the first contract process allocation table according to the contract transaction distribution table and the constructed reference contract transaction processing table; subsequently, the slave node can perform process preheating based on the first contract process allocation table; for example, the slave node can return the transaction execution result to the master node after the transaction is executed, and the master node can perform block consensus based on the execution results of each transaction, so that after the block consensus is passed, the current block can be added to the blockchain. In the above-mentioned interaction process between the master node and the slave node, any node can carry its own node identification, so that other nodes can perform node verification processing based on the corresponding node identification before performing consensus processing, thereby improving the data security of the node interaction process.

[0111] (2) Block structure:

[0112] See also Figure 2b , Figure 2b This is a schematic diagram of the structure of a blockchain provided by an embodiment of this application. Figure 2b As shown, a blockchain consists of multiple blocks, and each blockchain includes a genesis block. As the name suggests, the genesis block is the first or initial block. The genesis block includes a block header and a block body. The block header stores the input information feature value, version number, timestamp, and difficulty value, while the block body stores the input information. The next block of the genesis block uses the genesis block as its parent block. The next block also includes a block header and a block body. The block header stores the input information feature value of the current block, the block header feature value, version number, timestamp, and difficulty value of the parent block, and so on. This ensures that the transaction data stored in each block in the blockchain is linked to the transaction data stored in the parent block, ensuring the security of the transaction data in the block.

[0113] In this application, according to Figure 2b The blockchain network composed of the block structure shown can ensure the security of relevant transaction data involved in the execution of contract transactions, thereby improving the reliability and security of executing various contract transactions on the blockchain.

[0114] 4. Artificial intelligence.

[0115] Artificial intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive field of computer science that seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also studies the design principles and implementation methods of various intelligent machines, enabling them to perceive, reason, and make decisions. AI technology is an interdisciplinary discipline encompassing a wide range of fields, encompassing both hardware and software technologies. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, pre-trained models, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, speech processing, natural language processing, and machine learning / deep learning.

[0116] In this application, a time series AI model can be trained using machine learning technology in the field of artificial intelligence. The trained time series AI model can be used to predict the transaction processing volume (Transactions Per Second, TPS) of the contract process. The predicted contract process TPS can be used to calculate the contract process allocation table, so that each blockchain node can perform process preheating processing based on the contract process allocation table.

[0117] 5. Cloud technology.

[0118] The contract process processing scheme proposed in this application involves a large number of data computing and storage services within the blockchain, resulting in significant computer operating costs. Therefore, this application can utilize cloud storage technology within cloud technology to perform corresponding processing operations. Specifically, this includes: storing the contract transaction distribution table, the reference contract transaction processing table, and the first contract process allocation table using the data storage service; and generating the first contract process allocation table based on the contract process allocation rules using the data computing service. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, and application technology used in the cloud computing business model. It can form a resource pool that provides on-demand, flexible, and convenient resource utilization. Cloud technology can include cloud storage technology. Cloud storage is a new concept developed and extended from the concept of cloud computing. A distributed cloud storage system (hereinafter referred to as a storage system) is a storage system that uses cluster applications, grid technology, and distributed storage file systems to bring together a large number of different types of storage devices (also known as storage nodes) on a network through application software or application interfaces to work collaboratively and provide external data storage and service access capabilities.

[0119] It should be noted that the relevant data involved in the contract process processing involved in this application (for example: contract transaction distribution table, reference contract transaction processing table, and first contract process allocation table, etc.). When the above embodiments of this application are applied to specific products or technologies, the permission or consent of the object must be obtained, and the relevant data collection, use and processing processes must comply with the relevant laws, regulations and standards of the region, and comply with the principles of legality, legitimacy and necessity, and do not involve obtaining data types prohibited or restricted by laws and regulations. In some optional embodiments, the relevant data involved in the embodiments of this application are obtained after the object has been separately authorized. In addition, when obtaining the object's separate authorization, the purpose of the relevant data involved is indicated to the object.

[0120] The following is a detailed introduction to the architecture of the contract process processing system provided by this application with reference to the accompanying drawings.

[0121] 1. Introduction to the overall architecture of the contract processing system.

[0122] See Figure 3a , Figure 3a This is a schematic diagram of the architecture of a contract process processing system provided by an embodiment of the present application. Figure 3aAs shown in the diagram, the architecture of the contract processing system may include at least: a master node 301, at least one slave node 302, and a client 303. The master node 301 and each slave node 302 constitute a blockchain network. It should be noted that the number of nodes in the blockchain network is for illustration only and does not specifically limit the number of nodes in this application. Any blockchain node (master node 301 or slave node 302) in the blockchain network may be directly or indirectly connected to the client 303 via wired or wireless communication.

[0123] In one possible implementation, any computer device (master node 301, slave node 302, or client 303) in the contract processing system can be a mobile phone, tablet computer, laptop computer, PDA, mobile internet device (MID), vehicle, vehicle-mounted device, roadside device, aircraft, wearable device, smart device such as a smart watch, smart bracelet, pedometer, etc., virtual reality device, etc. In another possible implementation, any computer device (master node 301, slave node 302, or client 303) can also be a server. Specifically, the server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.

[0124] The following is a detailed introduction to the data interaction process between nodes in the contract processing system:

[0125] ① The object initiates a transaction request in the client 303. The transaction request is used to request the execution of a target transaction on the blockchain. The transaction request carries the contract identifier of the target smart contract to be called to execute the target transaction, such as the contract name, contract version and other information.

[0126] ② The client 303 sends the transaction request to any blockchain node (master node 301 or slave node 302), and then the master node 301 puts the target transaction into the transaction pool for execution.

[0127] ③ Upon receiving a block signal, master node 301 retrieves M contract transactions from the transaction pool and constructs a contract transaction distribution table. This contract transaction distribution table indicates the N smart contracts that need to be invoked to process the M contract transactions, as well as the number of transactions each smart contract needs to process. Optionally, master node 301 can also send the contract transaction distribution table to each slave node 302 in the blockchain.

[0128] ④ Any blockchain node (master node 301 or slave node 302) constructs a reference contract transaction processing table based on the reference transaction processing volume corresponding to each smart contract; the reference transaction processing volume corresponding to each smart contract is used to indicate the maximum number of transactions that the contract process of the corresponding smart contract is allowed to process per unit time.

[0129] ⑤ Any blockchain node (master node 301 or slave node 302) generates a first contract process allocation table based on the contract transaction distribution table and the reference contract transaction processing table in accordance with the contract process allocation rules; the first contract process allocation table is used to indicate: the number of contract processes that need to be started for each smart contract in N smart contracts.

[0130] ⑥ Any blockchain node (master node 301 or slave node 302) performs process pre-start processing for N smart contracts based on the number of contract processes indicated by the first contract process allocation table; and executes M contract transactions in each contract process after the process pre-start processing.

[0131] 2. Introduction to the module structure of blockchain nodes.

[0132] See Figure 3b , Figure 3b This is a module structure diagram of a blockchain node provided by an embodiment of the present application. The blockchain node can be the master node or slave node mentioned above. Figure 3b As shown, the following details the internal implementation of the blockchain node and the interaction between the various modules, which mainly include the following modules:

[0133] (1) Network Module: The network module is responsible for handling network communications between blockchain nodes, including sending and receiving data. It ensures information exchange and data synchronization between blockchain nodes.

[0134] (2) Verification module: The verification module is responsible for verifying transactions and blocks to ensure their legitimacy and correctness. It includes two sub-modules: certificate verification and permission verification.

[0135] a. Certificate verification module: responsible for verifying the blockchain node's certificate to ensure the node's identity is legitimate.

[0136] b. Authority Verification Module: Responsible for verifying the authority of the transaction and ensuring that the initiator of the transaction has the right to conduct the transaction.

[0137] (3) Transaction Pool Module: The transaction pool module is responsible for managing pending transactions, including the receipt, storage, and distribution of transactions. It includes three submodules: the transaction pool, the contract transaction statistics module, and the contract transaction distribution module.

[0138] a. Transaction pool: stores pending transactions.

[0139] b. Contract transaction statistics module: responsible for counting the number of transactions for each contract.

[0140] c. Contract transaction distribution module: responsible for distributing transactions to corresponding contract processes.

[0141] (4) Time Series AI Module: The Time Series AI module is responsible for predicting and adjusting the number of contract processes to optimize the execution of smart contracts. It includes five submodules: data acquisition module, data cleaning module, model storage module, model prediction module, and model correction module.

[0142] a. Data collection module: responsible for collecting relevant data for contract execution.

[0143] b. Data cleaning module: responsible for cleaning and formatting the collected data.

[0144] c. Model storage module: responsible for storing time series AI models.

[0145] d. Model prediction module: responsible for predicting the TPS of the contract process.

[0146] e. Model correction module: responsible for correcting the timing AI model based on actual execution results.

[0147] (5) Scheduling module: The scheduling module is responsible for scheduling various tasks of blockchain nodes, including transaction processing, block generation, etc. It includes four sub-modules: block transaction packager, block generator, virtual machine engine, and contract process pool.

[0148] a. Block transaction packager: responsible for packaging transactions into blocks.

[0149] b. Block generator: responsible for generating new blocks.

[0150] c. Virtual Machine Engine: Responsible for executing smart contracts. It includes four submodules: the contract process controller, the contract process allocation calculation module, the contract process preheating module, and the contract process fine-tuning module.

[0151] d. Contract process pool: stores contract processes.

[0152] (6) Consensus Module: The consensus module is responsible for processing the consensus among blockchain nodes to reach a consensus on the blockchain state. It is the core component of the blockchain system and determines the security and performance of the blockchain system.

[0153] (7) Storage module: The storage module is responsible for storing blockchain data, including blocks, transactions, status, etc. It includes two sub-modules: the block ledger and the status database.

[0154] a. Blockchain ledger: Stores all blocks. The blockchain ledger is the core data structure in the blockchain system, used to store and manage all confirmed blocks. Organized in a chain-like structure, each block contains a set of transactions, a block header (including metadata such as the previous block's hash value and timestamp), and other information. The blockchain ledger provides a public, immutable record of transaction history, ensuring transparency and consistency.

[0155] b. State Database: Stores the current state of the blockchain. State data refers to the data structure used within a blockchain system to represent the current state of the system. This data includes the balances of all accounts, the status of smart contracts, and other relevant information. State data is continuously updated as transactions are executed, reflecting the global state of the blockchain system at a given point in time. In blockchain systems, state data is typically stored in the form of a Merkle tree or other encrypted data structures to ensure its integrity and security.

[0156] Based on this, the above-mentioned blockchain node architecture includes: network module, verification module, transaction pool module, timing AI module, scheduling module, consensus module, and storage module. These modules are the operating basis of the contract process processing solution of this application. The above-mentioned architecture can ensure the efficient and stable operation of the system.

[0157] The contract process processing system provided by the present application is a system in which a blockchain node can obtain a contract transaction distribution table corresponding to a block to be processed, where the contract transaction distribution table is used to indicate the N smart contracts that need to be called to process the M contract transactions in the block to be processed, and the number of transactions that each smart contract needs to process, where M and N are both positive integers; a reference contract transaction processing table is constructed based on the reference transaction processing volume corresponding to each smart contract; the reference transaction processing volume corresponding to each smart contract is used to indicate the maximum number of transactions allowed to be processed by the contract process of the corresponding smart contract per unit time, and one contract process is used to run one smart contract; based on the contract transaction distribution table and the reference contract transaction processing table, a first contract process allocation table is generated according to the contract process allocation rules; the first contract process allocation table is used to indicate the number of contract processes that need to be started for each smart contract in N smart contracts; based on the number of contract processes indicated by the first contract process allocation table, process pre-start processing is performed for the N smart contracts; and the M contract transactions in the block to be processed are executed in each contract process after the process pre-start processing. It can be seen that before the transaction is executed, this application can estimate the number of contract processes that need to be started for each smart contract according to the distribution ratio of contract transactions and the transaction processing capacity of the contract process, and then preheat the contract process of the corresponding smart contract according to the estimated number of contract processes. Since the contract processes are reasonably allocated after the process preheating, when the transaction needs to be executed, the transaction can be executed based on the reasonably allocated contract processes, reducing process switching and the like, thereby improving the efficiency of transaction execution.

[0158] It can be understood that the contract process processing system described in the embodiment of the present application is for the purpose of more clearly illustrating the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided by the embodiment of the present application. It is known to those skilled in the art that with the evolution of the system architecture and the emergence of new business scenarios, the technical solution provided by the embodiment of the present application is also applicable to similar technical problems.

[0159] The following describes specific embodiments of the contract process processing solution with reference to the accompanying drawings.

[0160] See Figure 4 , Figure 4 This is a flow chart of a method for processing a contract process provided by an embodiment of the present application. Figure 3a The blockchain node (e.g., master node or slave node) in the processing system of the contract process shown is executed. The processing method of the contract process mainly includes but is not limited to the following steps S401 to S404:

[0161] S401: Obtain the contract transaction distribution table corresponding to the pending block. The contract transaction distribution table is used to indicate the N smart contracts that need to be called to process the M contract transactions in the pending block, as well as the number of transactions that each smart contract needs to process. Both M and N are positive integers.

[0162] In one possible implementation, if the blockchain node is a master node, the contract transaction distribution table can be generated by the master node and sent to each slave node by the master node; if the blockchain node is a slave node, the slave node can directly receive the contract transaction distribution table sent by the master node. Figure 5 , Figure 5 This is a shared topology diagram of a contract transaction distribution table provided in an embodiment of the present application. Figure 5 As shown in the figure, the transaction pool module of the master node generates a contract transaction distribution table, which defines the contract names and transaction quantities of all transactions in the current block. The master node can then distribute the contract transaction distribution table to the virtual machine engines of each slave node in the blockchain to facilitate the subsequent execution of the contract process.

[0163] Specifically, the process of constructing the contract transaction distribution table includes: ① In response to the block signal, M contract transactions are obtained from the transaction pool and packaged into a block to be processed. Specifically, the master node can parse the block signal to obtain the target transaction volume corresponding to the block to be packaged; then obtain the total number of contract transactions to be processed in the transaction pool; if the target transaction volume (100) is less than or equal to the total number (200), 100 contract transactions are obtained from the transaction pool according to the target transaction volume; if the target transaction volume (100) is greater than the total number (80), the contract transaction is obtained from the transaction pool according to the total number (80). ② Analyze the transaction data of each contract transaction to obtain the smart contract to be called for each contract transaction, so as to determine the N smart contracts to be called to process the M contract transactions. ③ Based on the M contract transactions and the N smart contracts, a contract transaction distribution table for the block to be processed is constructed; wherein, one smart contract is used to process one or more contract transactions. For example, the constructed contract transaction distribution table is shown in Table 2 below:

[0164] Table 2. Contract transaction distribution

[0165] Contract Name Transaction quantity contract1 4000 contract2 3000 contract3 2000 contract4 1000

[0166] As shown in the contract transaction distribution table in Table 2 above, the pending block includes 10,000 contract transactions. These 10,000 contract transactions need to be processed by calling four smart contracts, namely: smart contract 1 (contract1), smart contract 2 (contract2), smart contract 3 (contract3), and smart contract 4 (contract4). Among them, the number of transactions that contract1 needs to process is 4,000; the number of transactions that contract2 needs to process is 3,000; the number of transactions that contract3 needs to process is 2,000; and the number of transactions that contract4 needs to process is 1,000.

[0167] S402: Construct a reference contract transaction processing table based on the reference transaction processing volume corresponding to each smart contract.

[0168] The reference transaction processing volume corresponding to each smart contract indicates the maximum number of transactions that the corresponding smart contract process is allowed to process per unit time. One contract process is used to run one smart contract. Transactions Per Second (TPS) refers to the number of transactions processed per second by a contract process. It is an important indicator of system processing capacity, particularly in systems that handle large volumes of transactions, such as databases, trading systems, and blockchain systems. In the blockchain field, TPS is commonly used to measure the performance of a blockchain system, namely the number of transactions it can confirm and process per second.

[0169] In one possible implementation, any one of N smart contracts is denoted as smart contract i, and the contract process corresponding to smart contract i is denoted as contract process i. The reference transaction processing volume (TPS) corresponding to any smart contract i is obtained in the following two ways:

[0170] Method 1: Time Series AI Model Prediction of TPS. Specifically, a time series AI model can be used to predict the transaction processing capacity of contract process i and obtain the reference transaction processing volume corresponding to smart contract i.

[0171] Method 2: Obtain historical TPS. Specifically, obtain the historical transaction processing data corresponding to contract process i within the historical time period, and determine the reference transaction processing volume corresponding to smart contract i based on the historical transaction processing data. Specifically, the historical transaction processing data includes multiple historical TPS data included in the historical time period of contract process i: such as TPS_1, TPS_2, and TPS_3. Then, after performing calculations (such as arithmetic averaging or weighted calculations) on the multiple historical TPS data, the reference transaction processing volume corresponding to the current smart contract i can be obtained, or any historical TPS (such as TPS_1) can be randomly selected as the reference transaction processing volume.

[0172] Furthermore, based on the reference transaction processing volume of each smart contract, a reference contract transaction processing table can be constructed. For example, the reference contract transaction processing table can be shown in Table 3 below:

[0173] Table 3. Reference contract transaction processing table

[0174] Contract Name Unit process TPS contract1 100 contract2 300 contract3 200 contract4 200

[0175] S403: Based on the contract transaction distribution table and the reference contract transaction processing table, generate a first contract process allocation table according to the contract process allocation rule; the first contract process allocation table is used to indicate: the number of contract processes that need to be started for each smart contract in N smart contracts.

[0176] In one possible implementation, a blockchain node generates a first contract process allocation table based on a contract transaction distribution table and a reference contract transaction processing table, according to a contract process allocation rule. The table primarily includes the following steps: ① Obtain the total number K of contract processes included in the blockchain node, where K is a positive integer (e.g., 100). ② Based on the contract transaction distribution table and the reference contract transaction processing table, calculate the contract transaction ratio that smart contract i needs to process according to the contract process allocation rule. For example, based on Tables 2 and 3 above, for contract 1, the contract transaction ratio that smart contract 1 needs to process is: (4000 / 100) / (4000 / 100+3000 / 300+2000 / 200+1000 / 200)=0.62. ③ Based on the total number of processes and the contract transaction ratio that smart contract i needs to process, calculate the number of contract processes that smart contract i needs to initiate. That is, the number of contract processes that contract 1 needs to initiate is: 100*0.62=62.

[0177] See Figure 6 , Figure 6 This is a schematic diagram of the calculation process of a first contract process allocation table provided in an embodiment of the present application. Figure 6As shown in the figure, based on the contract transaction ratio that each smart contract needs to process and the transaction processing capacity of each smart contract, the number of contract processes that each smart contract needs to start can be generated according to the contract process allocation rule. For example, the number of contract processes that contract1 needs to start is 62; for another example, the number of contract processes that contract2 needs to start is 15. Because the number of contract processes is determined based on the actual number of transactions that each smart contract needs to process and the contract TPS, it can reasonably reflect the transaction processing capacity of each contract process.

[0178] In one possible implementation, if a blockchain node is a master node, the master node can directly calculate the first contract allocation table and distribute the first contract allocation table to each slave node in the blockchain. The specific process is as follows: ① First, the total number of contract processes deployed by each consensus node in each blockchain (i.e., the master node and slave nodes participating in the consensus) can be counted. If the total number of contract processes deployed by the master node and the slave node is the same (e.g., both are 100), the master node can send the first contract process allocation table to at least one slave node in the blockchain; ② Each slave node performs a process pre-startup based on the first contract process allocation table and executes M contract transactions in the pending block in each contract process after the process pre-startup, obtaining a first transaction execution result; ③ The master node receives the first transaction execution results returned by each slave node and, based on the first transaction execution results of each slave node and the second transaction execution result of the master node, performs block consensus processing on the pending block. For example, the master node can compare the first transaction execution result and the second transaction execution result to see if they are identical. If they are identical, the pending block can be determined to have passed consensus; ④ Subsequently, the pending block that has passed the block consensus processing is added to the blockchain. Under this implementation method, when the total number of contract processes of each consensus node is the same, the master node can directly calculate the first contract process allocation table and distribute it to each slave node. Each slave node does not need to calculate the first contract process allocation table separately, which can reduce the calculation complexity of the slave node.

[0179] S404: Based on the number of contract processes indicated by the first contract process allocation table, perform process pre-start processing for the N smart contracts; and execute the M contract transactions in the pending block in each contract process after the process pre-start processing.

[0180] In specific implementation, the above Figure 6The first contract process allocation table shown has calculated the number of contract processes required for each smart contract. For example, if the total number of processes included in the blockchain node is 100, the number of contract processes required for each smart contract to perform process preheating is 62, 15, 15, and 8, respectively. Then, the corresponding contract processes can be initialized and pre-started (preheated) according to the above number of contract processes. That is, for 100 contract processes, 62 contract processes are pre-started for smart contract 1, 15 contract processes are pre-started for smart contract 2 and smart contract 3, and 8 contract processes are pre-started for smart contract 4.

[0181] Furthermore, when a blockchain node needs to execute a contract transaction, it can directly execute the M contract transactions in the pending block in each contract process after the process pre-start processing. Since the contract processes required for each smart contract to process the corresponding transaction have been reasonably allocated and preheated in advance, when the transaction is officially executed, the contract process can be immediately available, thereby improving the system's response speed and further improving the efficiency of transaction execution.

[0182] In an embodiment of the present application, a contract transaction distribution table corresponding to the block to be processed can be obtained, and the contract transaction distribution table is used to indicate the N smart contracts that need to be called to process the M contract transactions in the block to be processed, and the number of transactions that each smart contract needs to process, where M and N are both positive integers; a reference contract transaction processing table is constructed based on the reference transaction processing volume corresponding to each smart contract; the reference transaction processing volume corresponding to each smart contract is used to indicate the maximum number of transactions allowed to be processed by the contract process of the corresponding smart contract per unit time, and one contract process is used to run one smart contract; based on the contract transaction distribution table and the reference contract transaction processing table, a first contract process allocation table is generated according to the contract process allocation rules; the first contract process allocation table is used to indicate the number of contract processes that need to be started for each smart contract in the N smart contracts; based on the number of contract processes indicated by the first contract process allocation table, process pre-start processing is performed for the N smart contracts; and the M contract transactions in the block to be processed are executed in each contract process after the process pre-start processing. It can be seen that before the transaction is executed, this application can estimate the number of contract processes that need to be started for each smart contract according to the distribution ratio of contract transactions and the transaction processing capacity of the contract process, and then preheat the contract process of the corresponding smart contract according to the estimated number of contract processes. Since the contract processes are reasonably allocated after the process preheating, when the transaction needs to be executed, the transaction can be executed based on the reasonably allocated contract processes, reducing process switching and the like, thereby improving the efficiency of transaction execution.

[0183] See Figure 7 , Figure 7 This is another contract process processing method provided by the embodiment of the present application. This method can be Figure 3aThe master node in the processing system of the contract process shown is executed. The processing method of the contract process mainly includes but is not limited to the following steps S701 to S708:

[0184] S701: Obtain the contract transaction distribution table corresponding to the block to be processed.

[0185] The contract transaction distribution table is used to indicate the N smart contracts that need to be called to process the M contract transactions in the pending block, as well as the number of transactions that each smart contract needs to process.

[0186] S702: Construct a reference contract transaction processing table based on the reference transaction processing volume corresponding to each smart contract.

[0187] Among them, the reference transaction processing volume corresponding to each smart contract is used to indicate the maximum number of transactions that the contract process of the corresponding smart contract is allowed to process per unit time.

[0188] S703: Based on the contract transaction distribution table and the reference contract transaction processing table, generate a first contract process allocation table according to the contract process allocation rule.

[0189] It should be noted that the specific process performed by steps S701-S703 can be detailed with reference to the specific process in steps S401-S403 of the above embodiment, and will not be repeated here in the embodiment of this application.

[0190] S704: Based on the first contract process allocation table, call N smart contracts in the K contract processes included in the master node to execute M contract transactions, and obtain N contract execution results.

[0191] For example, the master node includes K (K=100) contract processes, then according to Figure 6 The number of contract processes indicated by the first contract process allocation table shown is that N smart contracts are called in 100 contract processes to execute M contract transactions, and N contract execution results can be obtained, where one smart contract corresponds to one contract execution result. The contract execution result here can include the transaction running time corresponding to each smart contract, that is, the actual running time of executing the smart contract.

[0192] S705: Analyze N contract execution results to obtain the transaction execution time corresponding to each smart contract.

[0193] Specifically, a contract time statistics table can be constructed based on the transaction execution time of each smart contract. For example, the contract time statistics table is shown in Table 4 below:

[0194] Table 4. Contract time statistics

[0195] Contract Name Transaction execution time contract1 0.60s contract2 0.70s contract3 0.55s contract4 0.60s

[0196] S706: Update the first contract process allocation table according to the transaction execution time of the N smart contracts to obtain a second contract process allocation table.

[0197] See Figure 8a , Figure 8a This is a schematic diagram of the calculation flow of a second contract process allocation table provided in an embodiment of the present application. Figure 8a As shown in FIG, the master node updates the first contract process allocation table according to the transaction execution time of N smart contracts to obtain the second contract process allocation table, including the following steps:

[0198] ① Based on the transaction operation time of N smart contracts, the contract transaction distribution table and the reference contract transaction processing table, calculate the target contract transaction processing table for N smart contracts. Among them, the target contract transaction processing table includes the target transaction processing volume corresponding to each smart contract; specifically, the target transaction processing volume corresponding to any smart contract i is calculated as follows: determine the transaction operation time of smart contract i from the transaction operation time of N smart contracts; determine the number of transactions to be processed by smart contract i from the contract transaction distribution table, and determine the reference transaction processing volume corresponding to smart contract i from the reference contract transaction processing table; based on the number of transactions, reference transaction processing volume, and transaction operation time of smart contract i, obtain the target transaction processing volume corresponding to smart contract i, for example, target transaction processing volume = number of transactions / reference transaction processing volume / transaction operation time. Figure 8a As shown, for smart contract 1, the target transaction processing volume (i.e., actual TPS) of smart contract 1 is calculated as follows: 4000 / 0.62 / 0.6=108. Based on the above method, the target contract transaction processing table of N smart contracts can be calculated.

[0199] ② Based on the contract transaction distribution table and the target contract transaction processing table, determine the second contract process allocation table.

[0200] Specifically, based on the contract transaction distribution table and the target contract transaction processing table, the second contract process allocation table (such as Figure 8a As shown); wherein, the calculation method of the second contract process allocation table can refer to the calculation method of the first contract process allocation table in the above embodiment, and the embodiment of this application will not be repeated here.

[0201] Based on the process shown in steps ①-② above, this application can calculate the real TPS of each contract process according to the actual time taken by the master node to execute the contract (i.e., the transaction running time) on the basis of the first contract process allocation table, so that the master node can recalculate a more accurate contract process allocation table (i.e., the second contract process allocation table) based on the real TPS and transaction distribution ratio.

[0202] S707: Calculate a contract process adjustment table based on the first contract process allocation table and the second contract process allocation table.

[0203] The contract process adjustment table is used to indicate the number of processes that need to be adjusted for each smart contract among N smart contracts. Figure 8b , Figure 8b This is a schematic diagram of the calculation process of a contract process adjustment table provided in the embodiment of this application. Figure 8b As shown, the first contract process allocation table and the second contract process allocation table can be subtracted to obtain a contract process adjustment table. Specifically, for any smart contract (such as smart contract 1), the number of contract processes (61) corresponding to the smart contract 1 in the second contract process allocation table can be subtracted from the number of contract processes (62) corresponding to the smart contract 1 in the first contract process allocation table to obtain the number of processes that need to be adjusted for the smart contract: 61-62=-1. Among them, "+" represents that the current smart contract needs to increase the contract process, and "-" represents that the current smart contract needs to reduce the contract process; for example, the number of processes that need to be adjusted for smart contract 1 is -1, specifically reducing 1 contract process; for example, the number of processes that need to be adjusted for smart contract 2 is +2, specifically adding 2 contract processes.

[0204] S708: Send the contract process adjustment table to at least one slave node in the blockchain to trigger any slave node to adjust the number of processes of the N smart contracts after the execution process pre-start processing based on the contract process adjustment table.

[0205] Specifically, the master node sends the contract process adjustment table to each slave node, so that each slave node adjusts the process quantity of each smart contract after the process is preheated according to the adjustment quantity indicated in the process adjustment table. Figure 8b As shown, the slave node needs to reduce the number of processes corresponding to smart contract 1 by one; increase the number of processes corresponding to smart contract 2 by two; and reduce the number of processes corresponding to smart contract 3 by one.

[0206] In an embodiment of the present application, the master node first preliminarily calculates a relatively accurate first contract process allocation table according to the transaction distribution ratio and the predicted TPS of the contract process, and then the master node executes the transaction according to the first contract process allocation table, and calculates the real TPS of each smart contract according to the transaction running time of each smart contract. Finally, based on the real TPS and transaction distribution ratio, the contract process can be allocated more accurately, thereby notifying the slave node to adjust the number of contract processes according to the more accurate second contract process allocation table. This method can improve the accuracy of process pre-startup.

[0207] See Figure 9 , Figure 9 This is a flow chart of a training method for a time series intelligent model provided by an embodiment of the present application. The training method can be Figure 3a The blockchain node (master node or slave node) in the processing system of the contract process shown is executed. Among them, the training method of the time series intelligent model mainly includes but is not limited to the following steps S901 to S903:

[0208] S901: In the process of executing M contract transactions based on the first contract process allocation table, obtain the target transaction processing volume of the contract process i corresponding to any smart contract i.

[0209] S902: Obtain the reference transaction processing volume of smart contract i predicted by the time series intelligent model.

[0210] See Figure 10a , Figure 10a This is a flow chart of a model prediction process provided by the embodiment of this application. Figure 10a As shown, the time series AI model can predict the reference TPS (reference transaction processing volume) of any smart contract i at the current moment according to the historical transaction processing data of the smart contract i (such as the solid line S001 in the figure). The predicted reference TPS is shown as the dotted line S002 in the figure.

[0211] S903: Based on the reference transaction processing volume and target transaction processing volume of smart contract i, train a time series intelligent model.

[0212] In one possible implementation, the blockchain node trains a time series intelligent model based on the reference transaction processing volume and target transaction processing volume of smart contract i, which mainly includes the following processes: performing data preprocessing on the obtained target transaction processing volume; wherein the data preprocessing includes: any one or more of data cleaning, data format conversion, and data deduplication; calculating the difference data between the reference transaction processing volume of smart contract i and the target transaction processing volume after data preprocessing; and adjusting the model parameters of the time series intelligent model based on the difference data.

[0213] See Figure 10b , Figure 10b This is a flow chart of a model training process provided by the embodiment of this application. Figure 10bAs shown, the training process of the time series AI model is roughly as follows: ① In the process of executing M contract transactions based on the first contract process allocation table, the data collection module can be called to collect the target transaction processing volume of contract process i corresponding to any smart contract i; ② The data cleaning module is called to clean and format the collected data (target transaction processing volume); ③ The target transaction processing volume after data preprocessing is stored in the data storage module; ④ Based on the target transaction processing volume of smart contract i (i.e., actual TPS) and the reference transaction processing volume of the smart contract (i.e., model-predicted TPS), the difference between the two is calculated; ⑤ The parameters of the time series AI model are adjusted according to the difference data. Among them, the trained time series intelligent model is used to predict the transaction processing capacity of each contract process in the blockchain.

[0214] In this application, a contract process scheduling prediction and correction mechanism based on a time-series AI model can improve the stability of blockchain services. By using a time-series AI model to predict changes in transaction processing requirements and modifying the model based on actual execution results, blockchain service providers can better adapt to changes in transaction processing requirements and provide more stable blockchain services.

[0215] The following is a detailed introduction to the full life cycle process provided by this application solution with reference to the accompanying drawings.

[0216] Based on the processes shown in the above embodiments, this application designs a full life cycle process of a contract process scheduling system driven by real-time contract time consumption and timing AI. It mainly includes: ① Blockchain contract process scheduling process based on real-time transaction ratio (the master node transaction pool estimates the process allocation based on the transaction ratio and historical TPS of the current block, and notifies all blockchain nodes to execute the process); ② The slave node process scheduling correction process driven by contract time consumption (the master node calculates the result of process scheduling fine-tuning based on its actual execution situation and sends it to the slave node for fine-tuning and correction); ③ The contract process scheduling process driven by the timing AI model (the process of predicting the contract process TPS based on the timing AI model and correcting the model according to the actual execution results). The above processes are elaborated in detail below:

[0217] (1) Blockchain contract process scheduling process based on real-time transaction ratio.

[0218] See Figure 11 , Figure 11 This is a flow chart of a contract process scheduling method provided by an embodiment of the present application. Figure 11 As shown, the scheduling method of the contract process mainly includes the following steps S1-S20:

[0219] S1. Start.

[0220] S2. The blockchain master node receives the block generation signal and prepares to generate a new block.

[0221] S3. The block transaction packager of the master node scheduling module notifies the transaction pool to obtain the transaction.

[0222] S4: The masternode transaction pool module determines whether the current block size is greater than the transaction number in the transaction pool. If so, it executes S5; otherwise, it executes S6.

[0223] S5. The master node transaction pool module obtains all transactions from the transaction pool and prepares them for execution as transactions in the new block, and then executes S7.

[0224] S6. The master node transaction pool module obtains the number of transactions of the block size from the transaction pool and prepares to execute them as transactions in the new block.

[0225] S7. The contract transaction statistics module of the master node transaction pool module generates a contract transaction distribution table based on the smart contract called by the exchange.

[0226] S8. The contract transaction distribution module of the master node transaction pool module distributes the contract transaction distribution table to the virtual machine engines of all consensus nodes (slave nodes participating in the consensus) of the blockchain.

[0227] S9. The contract process allocation calculation module of all nodes (master nodes and slave nodes) calculates a first contract process allocation table based on the contract transaction distribution table and the contract transaction TPS table.

[0228] S10. The contract process preheating modules of all nodes perform contract process preheating, that is, adjusting the number of contract processes to the quota in the first contract process allocation table.

[0229] S11. While executing S8-S10, the master node transaction pool module sends the transaction to the block transaction packager for block pre-generation.

[0230] S12. The master node virtual machine engine receives these transactions and distributes them to the corresponding contract process for execution.

[0231] S13. After the transaction is executed, the block generator generates a new block and distributes it to the blockchain slave nodes.

[0232] S14. The virtual machine engine of the blockchain slave node scheduling module has been preheated through the contract process and directly executes these transactions.

[0233] S15. The blockchain slave nodes reach consensus on the calculated block results.

[0234] S16: Is the consensus successful? If so, execute S17; if not, execute S20.

[0235] S17. All nodes append the latest block to the block ledger.

[0236] S18. All nodes store the updated status in the status database.

[0237] S19. All nodes update the contract transaction TPS table based on the calculation results.

[0238] S20, end.

[0239] In the above process, the present application provides a dynamic contract process scheduling mechanism based on the real-time transaction ratio and the contract execution time. The mechanism can estimate the allocation of contract processes according to the real-time transaction ratio and the historical transaction processing speed (TPS) to obtain a first contract process allocation table, so that each blockchain node can preheat the contract process according to the first contract process allocation table. Since the contract processes are reasonably allocated after the process preheating, when the transaction needs to be executed, the transaction can be executed based on the reasonably allocated contract process, reducing process switching and the like, thereby improving the efficiency of transaction execution.

[0240] (2) Correction process of slave node process scheduling driven by time-consuming contracts.

[0241] See Figure 12 , Figure 12 This is a process scheduling flow chart based on contract time-consuming drive provided by the embodiment of the present application. Figure 12 As shown, the process mainly includes the following steps S1-S25:

[0242] S1. Start.

[0243] S2. The blockchain master node receives the block generation signal and prepares to generate a new block.

[0244] S3. The block transaction packager of the master node scheduling module notifies the transaction pool to obtain the transaction.

[0245] S4: The masternode transaction pool module determines whether the current block size is greater than the transaction number in the transaction pool. If so, it executes S5; otherwise, it executes S6.

[0246] S5. The master node transaction pool module obtains all transactions from the transaction pool and prepares them for execution as transactions in the new block, and then executes S7.

[0247] S6. The master node transaction pool module obtains the number of transactions of the block size from the transaction pool and prepares to execute them as transactions in the new block.

[0248] S7. The contract transaction statistics module of the master node transaction pool module generates a contract transaction distribution table based on the smart contract called by the exchange.

[0249] S8. The contract transaction distribution module of the master node transaction pool module distributes the contract transaction distribution table to the virtual machine engines of all consensus nodes (slave nodes participating in the consensus) of the blockchain.

[0250] S9. The contract process allocation calculation module of all nodes (master nodes and slave nodes) calculates a first contract process allocation table based on the contract transaction distribution table and the contract transaction TPS table.

[0251] S10. The contract process preheating modules of all nodes perform contract process preheating, that is, adjusting the number of contract processes to the quota in the first contract process allocation table.

[0252] S11. While executing S8-S10, the master node transaction pool module sends the transaction to the block transaction packager for block pre-generation.

[0253] S12. The master node virtual machine engine receives these transactions and distributes them to the corresponding contract process for execution.

[0254] S13. After the transaction is executed, the master node block generator calculates the actual time consumption data of each smart contract, which includes the actual transaction execution time of the smart contract.

[0255] S14. The master node block generator calculates the second contract process allocation table based on the actual transaction execution time.

[0256] S15. The master node block generator calculates the contract process adjustment table of the slave node.

[0257] S16. If there is a contract process that needs to be adjusted in the contract process fine-tuning table, the master node block generator sends it to all slave nodes.

[0258] S17. All slave nodes fine-tune the number of contract processes according to the contract process adjustment table.

[0259] S18. While executing S13-S17, the block generator generates a new block and distributes it to the blockchain slave nodes.

[0260] S19. The virtual machine engine of the blockchain slave node scheduling module has been preheated and fine-tuned by the contract process and directly executes these transactions.

[0261] S20. The blockchain slave nodes reach consensus on the calculated block results.

[0262] S21: Is consensus successful? If yes, execute S22; if not, execute S25.

[0263] S22. All nodes append the latest block to the block ledger.

[0264] S23. All nodes store the updated status in the status database.

[0265] S24. All nodes update the contract transaction TPS table based on the calculation results.

[0266] S25, end.

[0267] In the above process, based on the first contract process allocation table, a more accurate second contract allocation table can be recalculated according to the actual transaction execution time of the smart contract executed by the master node, thereby notifying each slave node to fine-tune the quota ratio of the contract process and achieve the accuracy of the contract process preheating.

[0268] (3) Contract process scheduling process driven by time series AI model.

[0269] See Figure 13 , Figure 13 This is a schematic diagram of a contract process scheduling process driven by a time series intelligent model provided by the embodiment of the present application. Figure 13 As shown, the process mainly includes the following steps S1-S9:

[0270] S1. Start.

[0271] S2. Whenever a new block signal is received, the model prediction module of the time series AI module will predict the TPS of all current contract processes.

[0272] S3. The contract process allocation calculation module of the contract process controller generates a first contract process allocation table based on the TPS.

[0273] S4. The blockchain node executes all contract transactions according to the first contract process allocation table to obtain the actual TPS of the contract process.

[0274] S5. The data acquisition module of the time series AI module collects the above-mentioned real TPS.

[0275] S6. The data cleaning module cleans and formats the real TPS and puts the data into the data storage module. The data storage module here can be provided by the state database.

[0276] S7. The time series AI model obtains real TPS data from storage.

[0277] S8. When the node is not busy, the data AI model provides feedback and updates based on the difference between the actual TPS and the prediction.

[0278] S9, end.

[0279] In the above process, during the contract process scheduling, the contract process TPS can be predicted based on the time series AI model, and the model can be corrected according to the actual TPS obtained according to the actual execution results, so that a more accurate time series AI model can be trained and the accuracy of the time series AI model in predicting the contract process TPS can be improved.

[0280] In summary, this application designs a full lifecycle process for a contract process scheduling system based on real-time contract time consumption and time-series AI. On the one hand, this solution uses a dynamic scheduling mechanism based on real-time transaction ratios and contract execution time consumption to more accurately allocate contract processes and optimize contract process scheduling, avoiding time waste caused by operations such as process switching, process startup and shutdown, thereby improving the overall performance of the blockchain system. On the other hand, this solution uses a contract process scheduling prediction and correction mechanism based on a time-series AI model to better predict and adapt to changes in transaction processing requirements, further improving the performance and stability of the blockchain system. On the other hand, this solution uses a dynamic adjustment of the number of contract processes to better utilize system resources, avoid resource waste, and thus improve the system's resource utilization.

[0281] The following is an explanation of the relevant devices of the contract process processing solution provided in the embodiment of the present application.

[0282] See Figure 14 , Figure 14 This is a schematic diagram of the structure of a contract process processing device provided by an embodiment of the present application. Figure 14 As shown, the contract process processing device 1400 can be applied to the blockchain node (such as a master node or a slave node) mentioned in the aforementioned embodiment. Specifically, the contract process processing device 1400 can be a computer program (including program code) running in the blockchain node. For example, the contract process processing device 1400 is an application software; the contract process processing device 1400 can be used to execute the corresponding steps in the contract process processing method provided in the embodiment of the present application. In specific implementation, the contract process processing device 1400 can specifically include:

[0283] Acquisition unit 1401 is used to obtain a contract transaction distribution table corresponding to the pending block. The contract transaction distribution table is used to indicate the N smart contracts that need to be called to process M contract transactions in the pending block, as well as the number of transactions that each smart contract needs to process. Both M and N are positive integers.

[0284] Processing unit 1402 is configured to construct a reference contract transaction processing table based on the reference transaction processing volume corresponding to each smart contract. The reference transaction processing volume corresponding to each smart contract indicates the maximum number of transactions that the contract process of the corresponding smart contract is allowed to process per unit time. One contract process is used to run one smart contract.

[0285] Processing unit 1402 is further configured to generate a first contract process allocation table according to the contract process allocation rule based on the contract transaction distribution table and the reference contract transaction processing table; the first contract process allocation table is configured to indicate the number of contract processes to be started for each of the N smart contracts;

[0286] The processing unit 1402 is further used to perform process pre-start processing for N smart contracts based on the number of contract processes indicated by the first contract process allocation table; and execute M contract transactions in the pending block in each contract process after the process pre-start processing.

[0287] In one possible implementation, any one of the N smart contracts is represented as smart contract i, and the contract process corresponding to smart contract i is represented as contract process i; the processing unit 1402 is configured to perform the following operations:

[0288] Use the time series intelligent model to predict the transaction processing capacity of contract process i and obtain the reference transaction processing volume corresponding to smart contract i; or

[0289] Obtain historical transaction processing data corresponding to contract process i within a historical time period, and determine the reference transaction processing volume corresponding to smart contract i based on the historical transaction processing data.

[0290] In one possible implementation, the processing unit 1402 generates a first contract process allocation table according to the contract process allocation rule based on the contract transaction distribution table and the reference contract transaction processing table, and is used to perform the following operations:

[0291] Get the total number K of contract processes included in the blockchain node, where K is a positive integer;

[0292] Based on the contract transaction distribution table and the reference contract transaction processing table, calculate the proportion of contract transactions that smart contract i needs to process according to the contract process allocation rules;

[0293] Based on the total number of processes and the proportion of contract transactions that smart contract i needs to process, the number of contract processes that smart contract i needs to start is calculated.

[0294] In one possible implementation, if the blockchain node is a master node, the acquisition unit 1401 acquires the contract transaction distribution table corresponding to the block to be processed, and performs the following operations:

[0295] In response to the block signal, M contract transactions are obtained from the transaction pool and packaged into a block to be processed;

[0296] Analyze the transaction data of each contract transaction to obtain the smart contract that needs to be called for each contract transaction, so as to determine the N smart contracts that need to be called to process M contract transactions;

[0297] Based on M contract transactions and N smart contracts, a contract transaction distribution table of the block to be processed is constructed; wherein, a smart contract is used to process one or more contract transactions.

[0298] In a possible implementation, the processing unit 1402 is further configured to perform the following operations:

[0299] Parse the block signal and obtain the target transaction volume corresponding to the block to be packaged;

[0300] Get the total number of pending contract transactions in the transaction pool;

[0301] If the target transaction volume is less than or equal to the total quantity, contract transactions are obtained from the trading pool according to the target transaction volume;

[0302] If the target transaction volume is greater than the total quantity, contract transactions will be obtained from the trading pool according to the total quantity.

[0303] In one possible implementation, after generating the first contract process allocation table according to the contract process allocation rule based on the contract transaction distribution table and the reference contract transaction processing table, the processing unit 1402 is further configured to perform the following operations:

[0304] Based on the first contract process allocation table, call N smart contracts in the K contract processes included in the master node to execute M contract transactions, and obtain N contract execution results; one smart contract corresponds to one contract execution result, and K is a positive integer;

[0305] Parse N contract execution results to obtain the transaction execution time corresponding to each smart contract;

[0306] According to the transaction execution time of N smart contracts, the first contract process allocation table is updated to obtain the second contract process allocation table.

[0307] In one possible implementation, the processing unit 1402 updates the first contract process allocation table according to the transaction execution time of the N smart contracts to obtain a second contract process allocation table for performing the following operations:

[0308] Based on the transaction execution time of N smart contracts, the contract transaction distribution table, and the reference contract transaction processing table, calculate the target contract transaction processing table for N smart contracts; the target contract transaction processing table includes the target transaction processing volume corresponding to each smart contract;

[0309] Based on the contract transaction distribution table and the target contract transaction processing table, a second contract process allocation table is determined.

[0310] In one possible implementation, any one of N smart contracts is represented as smart contract i, and the contract process corresponding to smart contract i is represented as contract process i. The processing unit 1402 calculates a target contract transaction processing table for the N smart contracts based on the transaction execution time of the N smart contracts, the contract transaction distribution table, and the reference contract transaction processing table, and performs the following operations:

[0311] Determine the transaction execution time of smart contract i from the transaction execution time of N smart contracts;

[0312] Determine the number of transactions that smart contract i needs to process from the contract transaction distribution table, and determine the reference transaction processing volume corresponding to smart contract i from the reference contract transaction processing table;

[0313] Based on the number of transactions of smart contract i, the reference transaction processing volume, and the transaction running time, the target transaction processing volume corresponding to smart contract i is obtained.

[0314] In one possible implementation, the processing unit 1402 updates the first contract process allocation table according to the transaction execution time of the N smart contracts. After obtaining the second contract process allocation table, the processing unit 1402 is further configured to perform the following operations:

[0315] Based on the first contract process allocation table and the second contract process allocation table, a contract process adjustment table is calculated; the contract process adjustment table is used to indicate the number of processes that need to be adjusted for each smart contract in the N smart contracts;

[0316] The contract process adjustment table is sent to at least one slave node in the blockchain to trigger any slave node to adjust the number of processes of the N smart contracts after the execution process pre-start processing based on the contract process adjustment table.

[0317] In a possible implementation, the processing unit 1402 is further configured to perform the following operations:

[0318] In the process of executing M contract transactions based on the first contract process allocation table, obtaining the target transaction processing volume of contract process i corresponding to any smart contract i;

[0319] Obtain the reference transaction volume of smart contract i predicted by the time series intelligent model;

[0320] Based on the reference transaction processing volume and target transaction processing volume of smart contract i, a time series intelligent model is trained; wherein, the trained time series intelligent model is used to predict the transaction processing capacity of each contract process in the blockchain.

[0321] In one possible implementation, the processing unit 1402 trains a time series intelligent model based on the reference transaction processing volume and the target transaction processing volume of the smart contract i to perform the following operations:

[0322] Performing data preprocessing on the acquired target transaction processing volume; wherein data preprocessing includes: any one or more of data cleaning, data format conversion, and data deduplication;

[0323] Calculate the difference between the reference transaction volume of smart contract i and the target transaction volume after data preprocessing;

[0324] Adjust the model parameters of the time series intelligent model based on the difference data.

[0325] In one possible implementation, if the blockchain node is a master node, the processing unit 1402 is further configured to perform the following operations:

[0326] Sending the first contract process allocation table to at least one slave node in the blockchain, so that any slave node performs process pre-start processing based on the first contract process allocation table, and executes M contract transactions in the pending block in each contract process after the process pre-start processing, to obtain a first transaction execution result;

[0327] receiving the first transaction execution result returned by each slave node;

[0328] Based on the first transaction execution result of each slave node and the second transaction execution result of the master node, block consensus processing is performed on the block to be processed; wherein, the block to be processed after the block consensus processing is added to the blockchain.

[0329] In an embodiment of the present application, a contract transaction distribution table corresponding to the block to be processed can be obtained, and the contract transaction distribution table is used to indicate the N smart contracts that need to be called to process the M contract transactions in the block to be processed, and the number of transactions that each smart contract needs to process, where M and N are both positive integers; a reference contract transaction processing table is constructed based on the reference transaction processing volume corresponding to each smart contract; the reference transaction processing volume corresponding to each smart contract is used to indicate the maximum number of transactions allowed to be processed by the contract process of the corresponding smart contract per unit time, and one contract process is used to run one smart contract; based on the contract transaction distribution table and the reference contract transaction processing table, a first contract process allocation table is generated according to the contract process allocation rules; the first contract process allocation table is used to indicate the number of contract processes that need to be started for each smart contract in the N smart contracts; based on the number of contract processes indicated by the first contract process allocation table, process pre-start processing is performed for the N smart contracts; and the M contract transactions in the block to be processed are executed in each contract process after the process pre-start processing. It can be seen that before the transaction is executed, this application can estimate the number of contract processes that need to be started for each smart contract according to the distribution ratio of contract transactions and the transaction processing capacity of the contract process, and then preheat the contract process of the corresponding smart contract according to the estimated number of contract processes. Since the contract processes are reasonably allocated after the process preheating, when the transaction needs to be executed, the transaction can be executed based on the reasonably allocated contract processes, reducing process switching and the like, thereby improving the efficiency of transaction execution.

[0330] See Figure 15 , Figure 15 1500 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. The computer device 1500 is used to execute the steps performed by the blockchain node (master node or slave node) in the aforementioned method embodiment. The computer device 1500 may include an independent device (such as one or more of a server, node, terminal, etc.), or may include components within an independent device (such as a chip, software module, or hardware module, etc.). The computer device may include at least one processor 1501 and a communication interface 1502. Further, optionally, the computer device may also include at least one memory 1503 and a bus 1504. In addition, the processor 1501, the communication interface 1502, and the memory 1503 are connected via a bus 1504.

[0331] in:

[0332] 1) The processor 1501 is a module that performs arithmetic and / or logical operations, and may specifically be one or more combinations of processing modules such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor unit (MPU), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), a complex programmable logic device (CPLD), a coprocessor (which assists the central processing unit in completing corresponding processing and applications), and a microcontroller unit (MCU).

[0333] 2) The communication interface 1502 can be used to provide information input or output for the at least one processor 1501. Furthermore, the communication interface 1502 can be used to receive data sent externally and / or send data externally. It can be a wired link interface such as an Ethernet cable, or a wireless link interface (Wi-Fi, Bluetooth, general wireless transmission, in-vehicle short-range communication technology, or other short-range wireless communication technology). The communication interface 1502 can serve as a network interface.

[0334] 3) Memory 1503 is used to provide storage space for storing data such as the operating system and computer programs. Memory 1503 can be one or a combination of random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or compact disc read-only memory (CD-ROM).

[0335] In a specific implementation, the processor 1501 is used to call the program instructions stored in the memory 1503 to perform the following operations:

[0336] Get the contract transaction distribution table corresponding to the pending block. The contract transaction distribution table is used to indicate the N smart contracts that need to be called to process the M contract transactions in the pending block, as well as the number of transactions that each smart contract needs to process. Both M and N are positive integers.

[0337] Based on the reference transaction processing volume corresponding to each smart contract, a reference contract transaction processing table is constructed; the reference transaction processing volume corresponding to each smart contract is used to indicate the maximum number of transactions that the contract process of the corresponding smart contract is allowed to process per unit time; one contract process is used to run one smart contract;

[0338] Based on the contract transaction distribution table and the reference contract transaction processing table, a first contract process allocation table is generated according to the contract process allocation rule; the first contract process allocation table is used to indicate: the number of contract processes to be started for each smart contract in the N smart contracts;

[0339] Based on the number of contract processes indicated by the first contract process allocation table, process pre-start processing is performed for N smart contracts; and M contract transactions in the pending block are executed in each contract process after the process pre-start processing.

[0340] In one possible implementation, any one of N smart contracts is represented as smart contract i, and the contract process corresponding to smart contract i is represented as contract process i; the processor 1501 is configured to perform the following operations:

[0341] Use the time series intelligent model to predict the transaction processing capacity of contract process i and obtain the reference transaction processing volume corresponding to smart contract i; or

[0342] Obtain historical transaction processing data corresponding to contract process i within a historical time period, and determine the reference transaction processing volume corresponding to smart contract i based on the historical transaction processing data.

[0343] In one possible implementation, the processor 1501 generates a first contract process allocation table based on the contract transaction distribution table and the reference contract transaction processing table according to the contract process allocation rule, and is configured to perform the following operations:

[0344] Get the total number K of contract processes included in the blockchain node, where K is a positive integer;

[0345] Based on the contract transaction distribution table and the reference contract transaction processing table, calculate the proportion of contract transactions that smart contract i needs to process according to the contract process allocation rules;

[0346] Based on the total number of processes and the proportion of contract transactions that smart contract i needs to process, the number of contract processes that smart contract i needs to start is calculated.

[0347] In one possible implementation, if the blockchain node is a master node, the processor 1501 obtains the contract transaction distribution table corresponding to the block to be processed, and performs the following operations:

[0348] In response to the block signal, M contract transactions are obtained from the transaction pool and packaged into a block to be processed;

[0349] Analyze the transaction data of each contract transaction to obtain the smart contract that needs to be called for each contract transaction, so as to determine the N smart contracts that need to be called to process M contract transactions;

[0350] Based on M contract transactions and N smart contracts, a contract transaction distribution table of the block to be processed is constructed; wherein, a smart contract is used to process one or more contract transactions.

[0351] In a possible implementation, the processor 1501 is further configured to perform the following operations:

[0352] Parse the block signal and obtain the target transaction volume corresponding to the block to be packaged;

[0353] Get the total number of pending contract transactions in the transaction pool;

[0354] If the target transaction volume is less than or equal to the total quantity, contract transactions are obtained from the trading pool according to the target transaction volume;

[0355] If the target transaction volume is greater than the total quantity, contract transactions will be obtained from the trading pool according to the total quantity.

[0356] In one possible implementation, after generating the first contract process allocation table according to the contract process allocation rule based on the contract transaction distribution table and the reference contract transaction processing table, the processor 1501 is further configured to perform the following operations:

[0357] Based on the first contract process allocation table, call N smart contracts in the K contract processes included in the master node to execute M contract transactions, and obtain N contract execution results; one smart contract corresponds to one contract execution result, and K is a positive integer;

[0358] Parse N contract execution results to obtain the transaction execution time corresponding to each smart contract;

[0359] According to the transaction execution time of N smart contracts, the first contract process allocation table is updated to obtain the second contract process allocation table.

[0360] In one possible implementation, the processor 1501 updates the first contract process allocation table according to the transaction execution time of the N smart contracts to obtain a second contract process allocation table for performing the following operations:

[0361] Based on the transaction execution time of N smart contracts, the contract transaction distribution table, and the reference contract transaction processing table, calculate the target contract transaction processing table for N smart contracts; the target contract transaction processing table includes the target transaction processing volume corresponding to each smart contract;

[0362] Based on the contract transaction distribution table and the target contract transaction processing table, a second contract process allocation table is determined.

[0363] In one possible implementation, any one of N smart contracts is represented as smart contract i, and the contract process corresponding to smart contract i is represented as contract process i. The processor 1501 calculates a target contract transaction processing table for the N smart contracts based on the transaction execution time of the N smart contracts, the contract transaction distribution table, and the reference contract transaction processing table, and performs the following operations:

[0364] Determine the transaction execution time of smart contract i from the transaction execution time of N smart contracts;

[0365] Determine the number of transactions that smart contract i needs to process from the contract transaction distribution table, and determine the reference transaction processing volume corresponding to smart contract i from the reference contract transaction processing table;

[0366] Based on the number of transactions of smart contract i, the reference transaction processing volume, and the transaction running time, the target transaction processing volume corresponding to smart contract i is obtained.

[0367] In one possible implementation, the processor 1501 updates the first contract process allocation table according to the transaction execution time of the N smart contracts, and after obtaining the second contract process allocation table, is further configured to perform the following operations:

[0368] Based on the first contract process allocation table and the second contract process allocation table, a contract process adjustment table is calculated; the contract process adjustment table is used to indicate the number of processes that need to be adjusted for each smart contract in the N smart contracts;

[0369] The contract process adjustment table is sent to at least one slave node in the blockchain to trigger any slave node to adjust the number of processes of the N smart contracts after the execution process pre-start processing based on the contract process adjustment table.

[0370] In a possible implementation, the processor 1501 is further configured to perform the following operations:

[0371] In the process of executing M contract transactions based on the first contract process allocation table, obtaining the target transaction processing volume of contract process i corresponding to any smart contract i;

[0372] Obtain the reference transaction volume of smart contract i predicted by the time series intelligent model;

[0373] Based on the reference transaction processing volume and target transaction processing volume of smart contract i, a time series intelligent model is trained; wherein, the trained time series intelligent model is used to predict the transaction processing capacity of each contract process in the blockchain.

[0374] In one possible implementation, the processor 1501 trains a time series intelligent model based on the reference transaction processing volume and the target transaction processing volume of the smart contract i to perform the following operations:

[0375] Performing data preprocessing on the acquired target transaction processing volume; wherein data preprocessing includes: any one or more of data cleaning, data format conversion, and data deduplication;

[0376] Calculate the difference between the reference transaction volume of smart contract i and the target transaction volume after data preprocessing;

[0377] Adjust the model parameters of the time series intelligent model based on the difference data.

[0378] In one possible implementation, if the blockchain node is a master node, the processor 1501 is further configured to perform the following operations:

[0379] Sending the first contract process allocation table to at least one slave node in the blockchain, so that any slave node performs process pre-start processing based on the first contract process allocation table, and executes M contract transactions in the pending block in each contract process after the process pre-start processing, to obtain a first transaction execution result;

[0380] receiving the first transaction execution result returned by each slave node;

[0381] Based on the first transaction execution result of each slave node and the second transaction execution result of the master node, block consensus processing is performed on the block to be processed; wherein, the block to be processed after the block consensus processing is added to the blockchain.

[0382] In an embodiment of the present application, a contract transaction distribution table corresponding to the block to be processed can be obtained, and the contract transaction distribution table is used to indicate the N smart contracts that need to be called to process the M contract transactions in the block to be processed, and the number of transactions that each smart contract needs to process, where M and N are both positive integers; a reference contract transaction processing table is constructed based on the reference transaction processing volume corresponding to each smart contract; the reference transaction processing volume corresponding to each smart contract is used to indicate the maximum number of transactions allowed to be processed by the contract process of the corresponding smart contract per unit time, and one contract process is used to run one smart contract; based on the contract transaction distribution table and the reference contract transaction processing table, a first contract process allocation table is generated according to the contract process allocation rules; the first contract process allocation table is used to indicate the number of contract processes that need to be started for each smart contract in the N smart contracts; based on the number of contract processes indicated by the first contract process allocation table, process pre-start processing is performed for the N smart contracts; and the M contract transactions in the block to be processed are executed in each contract process after the process pre-start processing. It can be seen that before the transaction is executed, this application can estimate the number of contract processes that need to be started for each smart contract according to the distribution ratio of contract transactions and the transaction processing capacity of the contract process, and then preheat the contract process of the corresponding smart contract according to the estimated number of contract processes. Since the contract processes are reasonably allocated after the process preheating, when the transaction needs to be executed, the transaction can be executed based on the reasonably allocated contract processes, reducing process switching and the like, thereby improving the efficiency of transaction execution.

[0383] In the above embodiments, the term "module" or "unit" refers to a computer program or part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the functions of the module or unit.

[0384] In addition, it should be noted here that: the embodiment of the present application also provides a computer storage medium, and a computer program is stored in the computer storage medium, and the computer program includes program instructions. When the processor executes the above program instructions, it can execute the method in the corresponding embodiment above, so it will not be described in detail here. For technical details not disclosed in the computer storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application. As an example, the program instructions can be deployed on a computer device, or executed on multiple computer devices located in one place, or, executed on multiple computer devices distributed in multiple locations and interconnected by a communication network.

[0385] According to one aspect of the present application, embodiments of the present application further provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, so that the computer device can perform the methods described in the corresponding embodiments above. Therefore, these methods will not be described in detail here.

[0386] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted via a computer-readable storage medium. The computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data processing device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD) or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0387] The above disclosure is only a preferred embodiment of the present application, and certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. A method for processing a contract process, characterized in that: Applied to a blockchain node, the method includes: Obtain the contract transaction distribution table corresponding to the pending block. The contract transaction distribution table is used to indicate the N smart contracts that need to be called to process the M contract transactions in the pending block, as well as the number of transactions that each smart contract needs to process. Both M and N are positive integers. Constructing a reference contract transaction processing table based on the reference transaction processing volume corresponding to each smart contract; the reference transaction processing volume corresponding to each smart contract is used to indicate the maximum number of transactions that the contract process of the corresponding smart contract is allowed to process per unit time; one contract process is used to run one smart contract; Based on the contract transaction distribution table and the reference contract transaction processing table, generating a first contract process allocation table according to a contract process allocation rule; the first contract process allocation table is used to indicate: the number of contract processes to be started for each smart contract in the N smart contracts; Based on the number of contract processes indicated by the first contract process allocation table, process pre-start processing is performed for the N smart contracts; and the M contract transactions in the to-be-processed block are executed in each contract process after the process pre-start processing.

2. The method according to claim 1, wherein Any one of the N smart contracts is represented as smart contract i, and the contract process corresponding to the smart contract i is represented as contract process i; the method further includes: Use a time series intelligent model to predict the transaction processing capacity of the contract process i to obtain a reference transaction processing volume corresponding to the smart contract i; or Obtain historical transaction processing data corresponding to the contract process i within a historical time period, and determine a reference transaction processing volume corresponding to the smart contract i based on the historical transaction processing data.

3. The method according to claim 2, wherein The step of generating a first contract process allocation table based on the contract transaction distribution table and the reference contract transaction processing table according to the contract process allocation rule includes: Obtain the total number K of contract processes included in the blockchain node, where K is a positive integer; Based on the contract transaction distribution table and the reference contract transaction processing table, calculate the contract transaction ratio that smart contract i needs to process according to the contract process allocation rule; Based on the total number of processes and the contract transaction ratio that smart contract i needs to process, the number of contract processes that smart contract i needs to start is calculated.

4. The method according to claim 1, wherein If the blockchain node is a master node, obtaining the contract transaction distribution table corresponding to the block to be processed includes: In response to the block signal, M contract transactions are obtained from the transaction pool and packaged into a block to be processed; Analyze the transaction data of each contract transaction to obtain the smart contract to be called for each contract transaction, so as to determine the N smart contracts to be called to process the M contract transactions; Based on the M contract transactions and the N smart contracts, a contract transaction distribution table of the block to be processed is constructed; wherein one smart contract is used to process one or more contract transactions.

5. The method according to claim 4, wherein The method further comprises: Analyze the block generation signal to obtain the target transaction volume corresponding to the block to be packaged; Get the total number of pending contract transactions in the transaction pool; If the target transaction volume is less than or equal to the total quantity, then the contract transaction is obtained from the transaction pool according to the target transaction volume; If the target transaction volume is greater than the total quantity, contract transactions are obtained from the transaction pool according to the total quantity.

6. The method according to claim 4, wherein After generating the first contract process allocation table based on the contract transaction distribution table and the reference contract transaction processing table according to the contract process allocation rule, the method further includes: Based on the first contract process allocation table, calling the N smart contracts in the K contract processes included in the master node to execute the M contract transactions, and obtaining N contract execution results; one smart contract corresponds to one contract execution result, and K is a positive integer; Analyze the N contract execution results to obtain the transaction execution time corresponding to each smart contract; According to the transaction execution time of the N smart contracts, the first contract process allocation table is updated to obtain a second contract process allocation table.

7. The method according to claim 6, wherein The updating of the first contract process allocation table according to the transaction execution time of the N smart contracts to obtain a second contract process allocation table includes: Calculate a target contract transaction processing table for the N smart contracts based on the transaction execution time of the N smart contracts, the contract transaction distribution table, and the reference contract transaction processing table; the target contract transaction processing table includes a target transaction processing volume corresponding to each smart contract; Based on the contract transaction distribution table and the target contract transaction processing table, a second contract process allocation table is determined.

8. The method according to claim 7, wherein Any one of the N smart contracts is represented as smart contract i, and the contract process corresponding to the smart contract i is represented as contract process i; the calculation of the target contract transaction processing table for the N smart contracts based on the transaction execution time of the N smart contracts, the contract transaction distribution table, and the reference contract transaction processing table includes: Determine the transaction execution time of the smart contract i from the transaction execution time of N smart contracts; Determine the number of transactions to be processed by smart contract i from the contract transaction distribution table, and determine the reference transaction processing volume corresponding to smart contract i from the reference contract transaction processing table; Based on the number of transactions of the smart contract i, the reference transaction processing volume, and the transaction execution time, the target transaction processing volume corresponding to the smart contract i is obtained.

9. The method according to any one of claims 5 to 8, wherein: After the first contract process allocation table is updated according to the transaction execution time of the N smart contracts to obtain the second contract process allocation table, the method further includes: Calculating a contract process adjustment table based on the first contract process allocation table and the second contract process allocation table; the contract process adjustment table is used to indicate the number of processes that need to be adjusted for each smart contract in the N smart contracts; The contract process adjustment table is sent to at least one slave node in the blockchain to trigger any of the slave nodes to adjust the number of processes of the N smart contracts after the execution process pre-start processing based on the contract process adjustment table.

10. The method according to claim 1, wherein The method further comprises: In the process of executing the M contract transactions based on the first contract process allocation table, obtaining a target transaction processing volume of a contract process i corresponding to any smart contract i; Obtaining a reference transaction volume of the smart contract i predicted using a time series intelligent model; Based on the reference transaction processing volume and the target transaction processing volume of the smart contract i, the time series intelligent model is trained; wherein the trained time series intelligent model is used to predict the transaction processing capacity of each contract process in the blockchain.

11. The method according to claim 10, wherein The training of the time series intelligent model based on the reference transaction processing volume and the target transaction processing volume of the smart contract i includes: Performing data preprocessing on the acquired target transaction processing volume; wherein the data preprocessing includes: any one or more of data cleaning, data format conversion, and data deduplication; Calculate the difference between the reference transaction processing volume of the smart contract i and the target transaction processing volume after data preprocessing; The model parameters of the time series intelligent model are adjusted based on the difference data.

12. The method according to claim 1, wherein If the blockchain node is a master node, the method further includes: Sending the first contract process allocation table to at least one slave node in the blockchain, so that any of the slave nodes performs process pre-start processing based on the first contract process allocation table, and executes the M contract transactions in the pending block in each contract process after the process pre-start processing, to obtain a first transaction execution result; receiving a first transaction execution result returned by each of the slave nodes; Based on the first transaction execution result of each of the slave nodes and the second transaction execution result of the master node, block consensus processing is performed on the block to be processed; wherein, the block to be processed after the block consensus processing is added to the blockchain.

13. A contract process processing device, characterized in that: Applied to a blockchain node, the device includes: an acquisition unit, configured to acquire a contract transaction distribution table corresponding to the block to be processed, wherein the contract transaction distribution table indicates N smart contracts to be invoked to process M contract transactions in the block to be processed, and the number of transactions to be processed by each smart contract, where M and N are both positive integers; a processing unit, configured to construct a reference contract transaction processing table based on a reference transaction processing volume corresponding to each smart contract; the reference transaction processing volume corresponding to each smart contract is used to indicate a maximum number of transactions that a contract process of the corresponding smart contract is allowed to process per unit time; and one contract process is used to run one smart contract; The processing unit is further configured to generate a first contract process allocation table according to a contract process allocation rule based on the contract transaction distribution table and the reference contract transaction processing table; the first contract process allocation table is configured to indicate the number of contract processes to be started for each of the N smart contracts; The processing unit is further used to perform process pre-start processing for the N smart contracts based on the number of contract processes indicated by the first contract process allocation table; and execute the M contract transactions in the to-be-processed block in each contract process after the process pre-start processing.

14. A computer device, characterized in that: include: storage devices and processors; a memory storing one or more computer programs; A processor, configured to load the one or more computer programs to implement the method for processing a contract process as described in any one of claims 1 to 12.

15. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which is suitable for being loaded by a processor and executing the method for processing a contract process according to any one of claims 1 to 12.

16. A computer program product, characterized in that The computer program product comprises a computer program, which is suitable for being loaded by a processor and executing the method for processing a contract process according to any one of claims 1 to 12.