Block chain data processing method and device, equipment and storage medium
By generating and storing the delayed execution primitives in the system's built-in contract, the problem of low security and reliability of late execution of smart contracts is solved, and a flexible delayed execution mechanism is realized.
Patent Information
- Application Number
- CN202311432601.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-30
- Publication Date
- 2025-05-02
AI Technical Summary
In the prior art, the delayed execution of smart contracts depends on code implementation, resulting in low security and reliability and lack of flexibility.
By obtaining the contract attribute information and business attribute information of the smart contract, the delay execution time is determined, and the delay execution primitive is generated and stored in the system built-in contract. This delayed execution primitive has atomic operation characteristics, is independent of smart contract code, and avoids malicious tampering.
Improve the security and reliability of late execution of smart contracts, dynamically adjust the late execution time, and enhance flexibility.
Smart Images

Figure CN119918095A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to fields such as blockchain technology, and in particular to a blockchain data processing method, device, equipment and storage medium. Background Art
[0002] A smart contract is an automatically executed contract based on blockchain technology. It can define and execute various execution logics and execution rules on the network without going through other intermediaries. Smart contracts can be used to implement various scenarios, such as asset transactions, invoice reimbursement, supply chain management, etc. In practice, smart contracts need to be delayed in some scenarios (such as too many smart contracts to be executed at the same time). At present, R&D personnel need to write a timer based on the code of the smart contract to implement the delayed execution of the smart contract. However, this delayed execution method is overly dependent on the code of the smart contract, resulting in low security and reliability of the delayed execution of the smart contract. Summary of the invention
[0003] The embodiments of the present application provide a blockchain data processing method, apparatus, device and storage medium to improve the security and reliability of delayed execution of smart contracts.
[0004] On the one hand, an embodiment of the present application provides a blockchain data processing method, including:
[0005] Obtain the contract attribute information of the smart contract to be executed in the blockchain, as well as the business attribute information of the business associated with the smart contract;
[0006] When the above-mentioned smart contract meets the delayed execution conditions, the delayed execution duration of the above-mentioned smart contract is determined according to the above-mentioned business attribute information;
[0007] Calling the smart contract engine corresponding to the smart contract, generating a delayed execution primitive for the smart contract according to the contract attribute information and the delayed execution duration, and storing the delayed execution primitive in the system built-in contract corresponding to the smart contract engine;
[0008] When it is determined that the smart contract meets the immediate execution conditions based on the delayed execution duration, the delayed execution primitive is read from the system built-in contract, and the smart contract engine is called to execute the smart contract according to the delayed execution primitive.
[0009] An embodiment of the present application provides a blockchain data processing device, including:
[0010] An acquisition module is used to obtain the contract attribute information of the smart contract to be executed in the blockchain, as well as the business attribute information of the business associated with the smart contract;
[0011] A determination module, configured to determine the delayed execution duration of the smart contract according to the business attribute information when the smart contract meets the delayed execution condition;
[0012] A generation module, used to call the smart contract engine corresponding to the smart contract, generate a delayed execution primitive for the smart contract according to the contract attribute information and the delayed execution duration, and store the delayed execution primitive in the system built-in contract corresponding to the smart contract engine;
[0013] The calling module is used to read the above-mentioned delayed execution primitive from the above-mentioned system built-in contract when it is determined that the above-mentioned smart contract meets the immediate execution condition based on the above-mentioned delayed execution duration, and call the above-mentioned smart contract engine to execute the above-mentioned smart contract according to the above-mentioned delayed execution primitive.
[0014] Optionally, the generation module includes a calling unit and a packaging unit;
[0015] A calling unit, used to call the smart contract engine corresponding to the smart contract, and generate an execution instruction for the smart contract according to the contract attribute information;
[0016] An encapsulation unit is used to encapsulate the above-mentioned execution instruction and the above-mentioned delayed execution time according to the data encapsulation format of the above-mentioned smart contract engine, obtain the delayed execution primitive about the above-mentioned smart contract, and store the above-mentioned delayed execution primitive in the system built-in contract corresponding to the above-mentioned smart contract engine.
[0017] Optionally, the encapsulation unit encapsulates the execution instruction and the delayed execution duration according to the data encapsulation format of the smart contract engine to obtain a delayed execution primitive for the smart contract, and stores the delayed execution primitive in a system built-in contract corresponding to the smart contract engine, including:
[0018] Obtain the message encapsulation format from the data encapsulation format of the above smart contract engine;
[0019] According to the message encapsulation format, the execution instruction and the delayed execution duration are encapsulated to obtain a delayed execution message about the smart contract, and the delayed execution message is determined as a delayed execution primitive about the smart contract;
[0020] The above-mentioned delayed execution primitive is stored in the message queue of the system built-in contract corresponding to the above-mentioned smart contract engine.
[0021] Optionally, the encapsulation unit encapsulates the execution instruction and the delayed execution duration according to the data encapsulation format of the smart contract engine to obtain a delayed execution primitive for the smart contract, and stores the delayed execution primitive in a system built-in contract corresponding to the smart contract engine, including:
[0022] Obtain the transaction encapsulation format from the data encapsulation format of the above smart contract engine;
[0023] According to the transaction encapsulation format, the execution instruction and the delayed execution duration are encapsulated to obtain a delayed execution transaction related to the smart contract, and the delayed execution transaction is determined as a delayed execution primitive related to the smart contract;
[0024] The above-mentioned delayed execution primitive is stored in the transaction database of the system built-in contract corresponding to the above-mentioned smart contract engine.
[0025] Optionally, the calling module includes a first acquisition unit, a prediction unit, a detection unit and a first determination unit;
[0026] A first acquisition unit is used to acquire block information of a target block in the blockchain when the delayed execution primitive is acquired, and a generation time required to generate a single block; the target block is a block with a maximum block height in the blockchain;
[0027] A prediction unit, configured to predict, according to the generation duration, the number of predicted blocks corresponding to the blocks generated under the delayed execution duration;
[0028] A detection unit, configured to detect, according to the block information of the target block, the actual number of blocks corresponding to the blocks generated in the blockchain after the target block is generated;
[0029] The first determination unit is used to determine that the smart contract meets the immediate execution condition when the predicted block number is equal to the actual block number, and read the delayed execution primitive from the system built-in contract.
[0030] Optionally, the delayed execution primitive is stored in a message queue of a system built-in contract corresponding to the smart contract engine according to the delayed execution duration;
[0031] Optionally, when the calling module determines that the smart contract meets the immediate execution condition based on the delayed execution duration, the calling module reads the delayed execution primitive from the system built-in contract, including:
[0032] When all execution primitives arranged before the delayed execution primitive in the message queue are executed, it is determined that the smart contract meets the immediate execution condition;
[0033] The above-mentioned delayed execution primitive is read from the message queue of the system built-in contract corresponding to the above-mentioned smart contract engine.
[0034] Optionally, the calling module reads the above-mentioned delayed execution primitive from the above-mentioned system built-in contract, including:
[0035] When the above-mentioned delayed execution primitive is stored in the message queue of the system built-in contract corresponding to the above-mentioned smart contract engine, the above-mentioned delayed execution primitive is read from the above-mentioned message queue;
[0036] When the above-mentioned delayed execution primitive is stored in the transaction database of the system built-in contract corresponding to the above-mentioned smart contract engine, the above-mentioned delayed execution primitive is read from the above-mentioned transaction database.
[0037] Optionally, the determination module includes a second determination unit, a second acquisition unit, and a third determination unit;
[0038] A second determining unit, configured to determine a data source for triggering the execution of the smart contract according to the business attribute information;
[0039] A second acquisition unit is used to acquire generation log data of the off-chain data when the data source indicates that the data triggering the execution of the smart contract is off-chain data;
[0040] The third determination unit is used to determine the generation time of the above-mentioned off-chain data according to the generation log data of the above-mentioned off-chain data, and determine the delayed execution duration of the above-mentioned smart contract according to the above-mentioned generation time.
[0041] Optionally, the second acquisition unit is further used to acquire, from the business attribute information, the organization information of the business organization to which the business associated with the smart contract belongs;
[0042] The second determining unit is further used to determine the credibility of the business institution according to the institution attribute information of the business institution;
[0043] The third determination unit is also used to determine the delayed execution time of the above-mentioned smart contract based on the credibility of the above-mentioned business organization and the number of smart contracts to be executed in the above-mentioned blockchain.
[0044] Optionally, the second acquisition unit is further used to acquire the business type of the business associated with the smart contract from the business attribute information;
[0045] The second determination unit is further used to determine the real-time characteristics of the business associated with the smart contract according to the business type of the business associated with the smart contract;
[0046] The third determination unit is also used to determine the delayed execution duration of the above-mentioned smart contract based on the real-time characteristics of the business associated with the above-mentioned smart contract.
[0047] Optionally, the third determining unit determines the delayed execution duration of the smart contract according to the real-time characteristics of the business associated with the smart contract, including:
[0048] Obtaining execution log data of the smart contract according to the contract attribute information of the smart contract;
[0049] According to the execution log data of the above smart contract, the execution frequency of the above smart contract is counted;
[0050] Determine the execution priority of the smart contract based on the real-time characteristics of the business associated with the smart contract and the execution frequency of the smart contract;
[0051] According to the execution priority of the above smart contract, the delayed execution time of the above smart contract is determined.
[0052] In one aspect, an embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0053] Obtain the contract attribute information of the smart contract to be executed in the blockchain, as well as the business attribute information of the business associated with the smart contract;
[0054] When the above-mentioned smart contract meets the delayed execution conditions, the delayed execution duration of the above-mentioned smart contract is determined according to the above-mentioned business attribute information;
[0055] Calling the smart contract engine corresponding to the smart contract, generating a delayed execution primitive for the smart contract according to the contract attribute information and the delayed execution duration, and storing the delayed execution primitive in the system built-in contract corresponding to the smart contract engine;
[0056] When it is determined that the smart contract meets the immediate execution conditions based on the delayed execution duration, the delayed execution primitive is read from the system built-in contract, and the smart contract engine is called to execute the smart contract according to the delayed execution primitive.
[0057] On one hand, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the following steps are implemented:
[0058] Obtain the contract attribute information of the smart contract to be executed in the blockchain, as well as the business attribute information of the business associated with the smart contract;
[0059] When the above-mentioned smart contract meets the delayed execution conditions, the delayed execution duration of the above-mentioned smart contract is determined according to the above-mentioned business attribute information;
[0060] Calling the smart contract engine corresponding to the smart contract, generating a delayed execution primitive for the smart contract according to the contract attribute information and the delayed execution duration, and storing the delayed execution primitive in the system built-in contract corresponding to the smart contract engine;
[0061] When it is determined that the smart contract meets the immediate execution conditions based on the delayed execution duration, the delayed execution primitive is read from the system built-in contract, and the smart contract engine is called to execute the smart contract according to the delayed execution primitive.
[0062] On the one hand, an embodiment of the present application provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0063] Obtain the contract attribute information of the smart contract to be executed in the blockchain, as well as the business attribute information of the business associated with the smart contract;
[0064] When the above-mentioned smart contract meets the delayed execution conditions, the delayed execution duration of the above-mentioned smart contract is determined according to the above-mentioned business attribute information;
[0065] Calling the smart contract engine corresponding to the smart contract, generating a delayed execution primitive for the smart contract according to the contract attribute information and the delayed execution duration, and storing the delayed execution primitive in the system built-in contract corresponding to the smart contract engine;
[0066] When it is determined that the smart contract meets the immediate execution conditions based on the delayed execution duration, the delayed execution primitive is read from the system built-in contract, and the smart contract engine is called to execute the smart contract according to the delayed execution primitive.
[0067] In this application, when a smart contract meets the delayed execution condition, the node device in the blockchain network can determine the delayed execution duration of the smart contract based on the business attribute information, and generate a delayed execution primitive for the smart contract based on the delayed execution duration and the contract attribute information of the smart contract through the smart contract engine corresponding to the smart contract, and store the delayed execution primitive in the system built-in contract corresponding to the smart contract engine. The data in the system built-in contract is tamper-proof, so it can avoid the delayed execution primitive in the system built-in contract from being maliciously tampered with, and improve the reliability of the delayed execution of the smart contract. The delayed execution primitive is used to indicate that the smart contract is executed when the waiting time is the delayed execution time. Therefore, when it is determined that the smart contract meets the immediate execution condition based on the delayed execution time, the delayed execution primitive can be read from the system built-in contract, the smart contract engine is called, and the smart contract is executed according to the delayed execution primitive. The delayed execution primitive is related to the operating system where the smart contract engine is located. The delayed execution primitive does not need to rely on the code of the smart contract, and the delayed execution primitive has the characteristics of atomic operation. In the process of executing the smart contract according to the delayed execution primitive, it will not be interrupted by other malicious threads. Therefore, this application can improve the security and reliability of the delayed execution of the smart contract. In addition, the delayed execution duration is dynamically determined according to the contract attribute information of the smart contract, which can improve the flexibility of the delayed execution of the smart contract. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0069] Figure 1 It is a schematic diagram of a blockchain data processing system provided by this application;
[0070] Figure 2 This is a schematic diagram of a scenario for implementing a blockchain data processing method in a blockchain data processing system provided by the present application;
[0071] Figure 3 It is a flowchart of a blockchain data processing method provided by this application;
[0072] Figure 4 It is a flowchart of a blockchain data processing method provided by this application;
[0073] Figure 5 This is a schematic diagram of a scenario for generating a delayed execution primitive for a smart contract provided by this application;
[0074] Figure 6 This is a schematic diagram of a scenario for generating a delayed execution primitive for a smart contract provided by this application;
[0075] Figure 7 It is a structural schematic diagram of a blockchain data processing device provided in an embodiment of the present application;
[0076] Figure 8 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0077] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0078] First, we introduce the blockchain data processing system used in this solution. Figure 1 , Figure 1 A schematic diagram of the structure of a blockchain data processing system provided in an embodiment of the present application. The blockchain data processing system may include a blockchain network.
[0079] The blockchain network is an end-to-end decentralized network composed of multiple node devices (also called blockchain nodes). The number of node devices in the blockchain network can be deployed according to actual needs. This application does not limit the number of node devices. Figure 1 The blockchain network includes four node devices as an example for explanation, and the four node devices are node device 101, node device 102, node device 103 and node device 104.
[0080] It is understandable that the functions involved in each node device in the blockchain network include:
[0081] 1) Routing: The node has the basic functions of the device and is used to support communication between node devices.
[0082] For example, Figure 1As shown, data or blocks can be transferred between node devices through network connection. The network connection between the above-mentioned node devices can be based on node identification for data transmission. Each node device has a node identification corresponding to it, and each of the above-mentioned node devices can store the node identifications of other node devices connected to itself, so that the acquired data or generated blocks can be broadcast to other node devices according to the node identifications of other node devices. For example, node device 101 can maintain a node identification list, which stores the node names and node identifications of other node devices, as shown in Table 1:
[0083] Table 1
[0084]
[0085]
[0086] Among them, the node identifier can be the Internet Protocol (IP) address for interconnecting networks or any other information that can be used to identify the node device in the blockchain network. Table 1 only uses the IP address as an example for explanation.
[0087] Assuming that the node identifier of node device 101 is 117.xxx.xxx.174, node device 101 can send a data synchronization request to node device 102 through 117.xxx.xxx.174, and node device 102 can know that the data synchronization request is sent by node device 101 through node identifier 117.xxx.xxx.174; similarly, node device 102 can send transaction data A to node device 101 through node identifier 117.xxx.xxx.145, and node device 101 can know that transaction data A is sent by node device 101 through node identifier 117.xxx.xxx.145, and the same is true for data transmission between other node devices, so they will not be elaborated one by one.
[0088] 2) Applications are deployed in the blockchain to implement specific businesses based on actual business needs, record data related to the implementation of functions to form record data, carry digital signatures in the record data to indicate the source of the task data, and send the record data to other node devices in the blockchain network for other node devices to add the record data to a temporary block when they successfully verify the source and integrity of the record data.
[0089] For example, the services implemented by the application include:
[0090] 2.1) Resource management service: the node device may include a resource client, which can be used to implement the resource management service function and realize the communication connection with the decentralized application client based on the resource management service function. The resource client is a tool for managing and storing user digital resources. For example, digital resources can be transferred to other accounts based on the resource client, and digital resources transferred from other accounts can be received based on the resource client. The resource client can be a hardware device or a software program.
[0091] It is understandable that with the widespread deployment of various decentralized applications on the blockchain and the increase in user activities on the blockchain, general users can use blockchain key management tools to log in when using decentralized applications. The address in the blockchain key management tool corresponds to a user on the blockchain. The decentralized application can obtain the user address from the key management tool through some interfaces, in order to solve the problem that the Dapp background cannot trust the user address used when logging in to the decentralized application.
[0092] 2.2) Shared ledger, which is used to provide functions such as storage, query and modification of account data (i.e. transaction data), and sends the record data of the operation on the account data to other nodes in the blockchain network. After other nodes verify the validity, as a response to acknowledging the validity of the account data, the record data is stored in a temporary block, and a confirmation can also be sent to the node device that initiated the operation.
[0093] For example, each node device can receive the data to be recorded when performing normal work, and maintain the shared ledger (i.e., blockchain) based on the received data to be recorded. In order to ensure the intercommunication of information within the shared ledger network, a network connection can exist between each node device in the shared ledger network, and data can be transmitted between the node devices through the above network connection. For example, when any node device in the shared ledger network receives the data to be recorded, the other node devices in the shared ledger network will verify the data to be recorded according to the consensus algorithm, and after successful verification (i.e., after consensus is reached), the data to be recorded will be stored as data in the shared ledger, so that the data stored on all node devices in the shared ledger network are consistent.
[0094] 2.3) Smart contracts are computerized protocols that can execute the terms of a contract. They are implemented through code deployed on a shared ledger that is executed when certain conditions are met. The code is used to complete automated transactions based on actual business needs, such as querying the logistics status of the goods purchased by the buyer and transferring the buyer's digital resources to the merchant's address after the buyer signs for the goods. Of course, smart contracts are not limited to executing contracts for transactions, but can also execute contracts for processing received information.
[0095] It should be noted that node device 101, node device 102, node device 103, and node device 104 can be an independent physical server, or a server cluster or distributed system composed of at least two 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, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0096] It should be noted that each node in the blockchain network may also include a smart contract engine and a system built-in contract. The smart contract engine may refer to a software component that runs a smart contract and can realize automated contract execution and asset transfer, etc. The system built-in contract is used to store smart contracts of primitives to be executed. The system built-in contract may be stored on the blockchain, or the system built-in contract may be stored in a secure environment under the blockchain of the node device. The secure environment refers to a storage space that is inaccessible to external devices, and the data in the secure environment is tamper-proof.
[0097] Among them, the delayed execution primitive about smart contracts in this application refers to the primitive used to indicate the delayed execution of smart contracts. The primitive belongs to the operating system. Between the operating system and the hardware, it refers to a series of atomic operations / a series of operations for hardware. The general implementation is achieved through instructions, such as switch interrupts. The main emphasis is on atomicity, that is, atomic operations. Atomic operations refer to operations that will not be interrupted by the thread scheduling mechanism; once this operation starts, it will run until the end, and there will be no thread interruptions in the middle (that is, it will not switch to other threads). In other words, the delayed execution primitive in this application has the characteristics of atomic operations. In the process of executing smart contracts according to the delayed execution primitive, there will be no thread interruptions due to malicious attacks, which can ensure the reliability and security of the delayed execution of smart contracts.
[0098] It should be noted that in some scenarios, smart contracts need to be executed in a delayed manner. For example, there are a large number of smart contracts to be executed at the same time on the node device. In order to avoid execution congestion, jamming and other problems, it is necessary to delay the execution of some smart contracts. For another example, the execution trigger condition of the smart contract is timed execution. At present, R&D personnel need to write a timer based on the code of the smart contract to realize the delayed execution of the smart contract. However, this delayed execution method has the following problems: 1. Security issues: The implementation of the timer needs to rely on the code of the smart contract. If there are vulnerabilities in the smart contract, the timer may be tampered with or bypassed, thereby affecting the execution of the smart contract. 2. Reliability issues: The implementation of the timer needs to rely on the code of the smart contract. If there are errors or abnormalities in the smart contract, the timer may not be executed normally, thereby affecting the execution of the smart contract. 3. Flexibility issues: The implementation of the timer requires setting a fixed time in the smart contract, which cannot be dynamically adjusted according to the actual situation and lacks flexibility.
[0099] Based on this, a blockchain data processing method is proposed in this application. Specifically, taking the node device 101 in the blockchain network as an example, the node device 101 can generate a delayed execution primitive for the smart contract according to the delayed execution time and the contract attribute information of the smart contract through the smart contract engine corresponding to the smart contract, and generate a delayed execution primitive for the smart contract according to the delayed execution time and the contract attribute information of the smart contract, and store the delayed execution primitive in the system built-in contract corresponding to the smart contract engine. The data in the system built-in contract is tamper-proof, so it can avoid the delayed execution primitive in the system built-in contract from being maliciously tampered with, and improve the reliability of the delayed execution of the smart contract. The delayed execution primitive is used to indicate that the smart contract is executed when the waiting time is the delayed execution time. Therefore, when it is determined that the smart contract meets the immediate execution condition based on the delayed execution time, the delayed execution primitive can be read from the system built-in contract, the smart contract engine is called, and the smart contract is executed according to the delayed execution primitive. The delayed execution primitive is related to the operating system where the smart contract engine is located. The delayed execution primitive does not need to rely on the code of the smart contract, and the delayed execution primitive has the characteristics of atomic operation. During the execution of the smart contract according to the delayed execution primitive, it will not be interrupted by other malicious threads. Therefore, this application can improve the security and reliability of the delayed execution of the smart contract. In addition, the delayed execution duration of the smart contract is dynamically determined based on the business attribute information of the business related to the smart contract. Therefore, this application can improve the flexibility of the delayed execution of the smart contract.
[0100] In a specific implementation, the blockchain data processing method in this application can be as follows: Figure 2 As shown, Figure 2The node device 20a in the block chain network may refer to any node device in the block chain network. The node device 20a includes a block chain 21a. The block chain 21a includes multiple smart contracts and a system built-in contract 23a. Different smart contracts have different functions, and the execution conditions of different smart contracts may also be different. For example, the invoice smart contract for invoice reimbursement can realize the invoice reimbursement function. The execution condition of the invoice smart contract may refer to receiving the invoice data of an individual or an organization; the inventory management smart contract for items can realize the update of the inventory of items. The execution condition of the inventory management smart contract may refer to receiving the sale record of the item, or the purchase record of the item. The node device 20a may also include a system built-in contract 23a, and the system built-in contract 23a stored in a secure environment is used as an example for explanation.
[0101] The node device 20a can detect the smart contracts to be executed in the blockchain. When it is detected that there are multiple smart contracts to be executed at the same time, the node device 20a can select the smart contract that meets the delayed execution condition from the smart contracts to be executed. The smart contracts that meet the delayed execution condition may include one or more of the following: 1. Smart contracts whose off-chain data used to trigger their execution has not been received. 2. Smart contracts whose real-time requirement level is less than the level threshold among the smart contracts to be executed, such as the real-time requirement level of smart contracts about asset transfer is usually relatively high, and the real-time requirement level of invoice smart contracts about invoice reimbursement is relatively low. The real-time requirement level of smart contracts can be determined according to the application scenario of smart contracts. 3. Smart contracts whose corresponding business in the smart contracts to be executed has a credibility less than the credibility threshold. The business corresponding to the smart contract belongs to the organization that is associated with the business corresponding to the smart contract. For example, regarding the invoice smart contract for invoice reimbursement, the organization to which the business corresponds to the invoice smart contract may refer to the organization that needs to reimburse the invoice (such as a corporate organization), or the organization that reimburses the invoice (such as a tax agency); regarding the smart contract for asset transfer, the organization to which the business corresponds to the smart contract includes the recipient of the asset or the sender of the asset.
[0102] further, Figure 2If the smart contract 22a in the smart contract 22a satisfies the delayed execution condition, the node device 20a can obtain the contract attribute information of the smart contract 22a and the business attribute information of the business associated with the smart contract 22a; the contract attribute information may include the contract identifier of the smart contract 22a, the storage address of the smart contract 22a on the blockchain, etc., and the business attribute information may include the business type, the organization information of the business organization to which the business belongs (such as the organization name, code), etc. The node device 20a can determine the delayed execution duration of the smart contract 22a based on the business attribute information, and the delayed execution duration refers to the execution of the smart contract 22a after waiting for the delayed execution duration; then, the smart contract 22a engine corresponding to the smart contract 22a is called, and the delayed execution primitive about the smart contract 22a is generated according to the contract attribute information and the delayed execution duration, and the delayed execution primitive is stored in the system built-in contract 23a corresponding to the smart contract 22a engine.
[0103] Then, when it is determined that the smart contract 22a meets the immediate execution condition based on the delayed execution duration, the node device 20a can read the delayed execution primitive from the system built-in contract 23a, and call the smart contract 22a engine to execute the smart contract 22a according to the delayed execution primitive.
[0104] In summary, when it is detected that the smart contract regarding the invoice meets the delayed execution condition, the node device 20 can determine the delayed execution duration of the smart contract based on the business attribute information associated with the smart contract, call the smart contract engine, and generate a delayed execution primitive for the smart contract based on the delayed execution duration and the contract attribute information of the smart contract, and store the delayed execution primitive in the system built-in contract corresponding to the smart contract engine. The data in the system built-in contract is tamper-proof, so it can prevent the delayed execution primitive in the system built-in contract from being maliciously tampered with, thereby improving the reliability of the delayed execution of the smart contract. The delayed execution primitive is used to indicate that the smart contract is executed when the waiting time is the delayed execution time. Therefore, when it is determined that the smart contract meets the immediate execution condition based on the delayed execution time, the delayed execution primitive can be read from the system built-in contract, the smart contract engine is called, and the smart contract is executed according to the delayed execution primitive. The delayed execution primitive is related to the operating system where the smart contract engine is located. The delayed execution primitive does not need to rely on the code of the smart contract, and the delayed execution primitive has the characteristics of atomic operation. In the process of executing the smart contract according to the delayed execution primitive, it will not be interrupted by other malicious threads. Therefore, this application can improve the security and reliability of the delayed execution of the smart contract. In addition, the delayed execution duration is dynamically determined according to the contract attribute information of the smart contract, which can improve the flexibility of the delayed execution of the smart contract.
[0105] It should be noted that the above is an example of implementing this solution using a single-layer blockchain network. This application can also be implemented based on a multi-layer blockchain network, such as a two-layer blockchain network. The two-layer blockchain network includes a first-layer blockchain network and a second-layer blockchain network. The first-layer blockchain network includes multiple first node devices, and the second-layer blockchain network includes multiple second node devices. The multiple first node devices are used to generate a delayed execution primitive for the smart contract, and send the delayed execution primitive to the second node device in the second-layer blockchain network. The second node device is used to execute the smart contract according to the delayed execution primitive, which is conducive to reducing the data processing pressure of each node device and improving the execution efficiency of the smart contract.
[0106] For example, any first node device in the first-layer blockchain network can obtain the contract attribute information of the smart contract to be executed in the blockchain network, as well as the business attribute information of the business associated with the smart contract. The first node device can broadcast the contract attribute information and the business attribute information to other first node devices in the first-layer blockchain network, and other node devices can verify whether the smart contract meets the delayed execution condition based on the contract attribute information. When most of the first node devices (or all the first node devices) in the first-layer blockchain network determine that the smart contract meets the delayed execution condition, any first node device can determine the delayed execution duration of the smart contract based on the business attribute information, and send the delayed execution duration to other first node devices. Other first node devices reach a consensus on the delayed duration. When other first node devices reach a consensus on the delayed duration, any first node device can generate a delayed execution primitive for the smart contract based on the delayed execution duration and the contract attribute information, and store the delayed execution primitive in the system built-in contract on the first blockchain corresponding to the first-layer blockchain network.
[0107] Furthermore, when it is determined that the smart contract meets the immediate execution condition based on the delayed execution duration, the delayed execution primitive is read from the system's built-in contract, and the delayed execution primitive is sent to the second node device in the second-layer blockchain network. The second node device can call the smart contract engine in the second node device to execute the smart contract on the second blockchain according to the delayed execution primitive. The delayed execution of smart contracts is achieved through a multi-layer blockchain network, which is conducive to reducing the data processing pressure of each node device and improving the execution efficiency of smart contracts. In addition, the verification of whether the smart contract meets the delayed execution condition and the delayed execution duration of the smart contract are jointly witnessed (consensus) by all first node devices in the first-layer blockchain network, which is conducive to avoiding malicious delayed execution of smart contracts and causing asset losses to users.
[0108] For further information, see Figure 3This is a flowchart of a blockchain data processing method provided by an embodiment of the present application. Figure 3 As shown, this method can be Figure 1 The method may include the following steps:
[0109] S101. Obtain contract attribute information of a smart contract to be executed in the blockchain, and business attribute information of a business associated with the smart contract.
[0110] In this application, the node device can obtain the contract attribute information of the smart contract to be executed in the blockchain, as well as the business attribute information of the business associated with the smart contract, and verify whether the smart contract meets the delayed execution condition based on the contract attribute information or the business attribute information. The contract attribute information and the business attribute information are broadcast to other node devices in the blockchain network, and other node devices are used to verify whether the smart contract meets the delayed execution condition based on the contract attribute information (or business attribute information). The specific verification process can refer to the description above, and the repeated parts will not be repeated.
[0111] S102. When the smart contract meets the delayed execution condition, the delayed execution duration of the smart contract is determined according to the business attribute information.
[0112] In the present application, when receiving the satisfaction indication information sent by other node devices, the satisfaction indication information is used to indicate that the smart contract meets the delayed execution condition. At this time, the node device can determine that the smart contract meets the delayed execution condition, determine the delayed execution duration of the smart contract according to the business attribute information, and send the delayed execution duration to other node devices. Other node devices can also determine the delayed execution duration of the smart contract according to the business attribute information. Other node devices can reach a consensus on the received delayed execution duration with the delayed execution duration generated by themselves. When the delayed execution duration generated by themselves is the same as the received delayed execution duration, the delayed execution duration generated by the node device is passed by consensus. When the delayed execution duration generated by the node device is not passed by consensus, the node device regenerates the delayed execution duration. When the delayed execution duration generated by the node device is passed by consensus, step S103 is executed. In other words, step S103 is executed only when the delay durations generated by most node devices (or all node devices) in the blockchain network are the same, or when the delayed execution duration of the smart contract is agreed upon by the node devices in the blockchain network. This helps avoid malicious delayed execution (or early execution) of the smart contract, which may cause asset losses to users. Early execution here may refer to shortening the delayed execution duration.
[0113] For example, a smart contract on asset transfer receives a large asset transfer transaction. After the execution of the large asset transfer transaction, the transaction value of the asset will increase. There is a user who maliciously inserts a buy transaction on the asset before the execution of the large asset transfer transaction, that is, by executing the smart contract in advance based on the buy transaction, in order to arbitrage from it. The delayed execution conditions and delay duration of the smart contract in this application are jointly witnessed by all node devices in the blockchain network, that is, all node devices jointly determine, so as to avoid malicious delayed execution (or early execution) of the smart contract, which will cause asset losses to users.
[0114] In one embodiment, the above-mentioned determining the delayed execution duration of the above-mentioned smart contract based on the above-mentioned business attribute information includes: the node device can determine the data source used to trigger the execution of the above-mentioned smart contract based on the above-mentioned business attribute information; when the above-mentioned data source indicates that the data triggering the execution of the above-mentioned smart contract is off-chain data, obtaining the generation log data of the above-mentioned off-chain data; according to the generation log data of the above-mentioned off-chain data, determining the generation time of the above-mentioned off-chain data, and according to the above-mentioned generation time, determining the delayed execution duration of the above-mentioned smart contract.
[0115] Specifically, the node device can determine the data source used to trigger the execution of the smart contract based on the business attribute information. If the data source indicates that the data that triggers the execution of the smart contract is off-chain data, it means that the smart contract needs data under the external chain to trigger execution. At this time, the node device can obtain the generation log data of the off-chain data, and the generation log data reflects the generation time of each off-chain data. The generation time of the off-chain data is predicted based on the generation log data of the off-chain data. The generation time reflects how long the off-chain data is generated. The delayed execution duration of the smart contract can be determined based on the generation time. If the interval duration corresponding to the generation time is less than the delayed execution duration, it is beneficial to wait for the off-chain data to be received before triggering the execution of the smart contract, ensuring that sufficient conditions are prepared for the execution of the smart contract, and ensuring the reliability of the delayed execution of the smart contract.
[0116] In one embodiment, the above-mentioned determining the delayed execution duration of the above-mentioned smart contract based on the above-mentioned business attribute information includes: the node device can obtain the organization information of the business organization to which the business associated with the above-mentioned smart contract belongs from the above-mentioned business attribute information; determine the credibility of the above-mentioned business organization based on the organization attribute information of the above-mentioned business organization; determine the delayed execution duration of the above-mentioned smart contract based on the credibility of the above-mentioned organization and the number of smart contracts to be executed in the above-mentioned blockchain.
[0117] The node device can obtain the organization information of the business organization to which the business associated with the smart contract belongs from the business attribute information. The organization information may include the name, code, and logo of the business organization; according to the organization attribute information of the business organization, the credibility of the business organization is queried from the blockchain. The credibility of the business organization can be determined based on at least one of the registration time of the business organization, the comment data about the business organization, and the transaction volume of the business organization. According to the credibility of the organization and the number of smart contracts to be executed in the blockchain, the delayed execution time of the smart contract is determined. There is a negative correlation between the delayed execution time and the credibility of the business organization, that is, the higher the credibility, the shorter the delayed execution time; conversely, the lower the credibility, the longer the delayed execution time. This is conducive to giving priority to the execution of smart contracts corresponding to business organizations with high credibility, and improving the flexibility of delayed execution of smart contracts.
[0118] In one embodiment, the above-mentioned determination of the delayed execution duration of the above-mentioned smart contract according to the above-mentioned business attribute information includes: the node device can obtain the business type of the business associated with the above-mentioned smart contract from the above-mentioned business attribute information; the business type can include invoice reimbursement, asset transaction, inventory update of goods, etc. The node device can determine the real-time characteristics of the business associated with the above-mentioned smart contract according to the business type of the business associated with the above-mentioned smart contract; the real-time characteristics include the real-time demand level of the business, the higher the real-time demand level of the business, the faster the smart contract associated with the business needs to be executed; the lower the real-time demand level of the business, the faster the smart contract associated with the business does not need to be executed. Therefore, the node device can determine the delayed execution duration of the above-mentioned smart contract according to the real-time characteristics of the business associated with the smart contract, that is, there is a negative correlation between the real-time demand level of the business and the delayed execution duration, that is, the higher the real-time demand level of the business, the shorter the delayed execution duration of the smart contract corresponding to the business; the lower the real-time demand level of the business, the longer the delayed execution duration of the smart contract corresponding to the business.
[0119] In one embodiment, the above-mentioned method of determining the delayed execution duration of the smart contract based on the real-time characteristics of the business associated with the smart contract includes: the node device can obtain the execution log data of the smart contract based on the contract attribute information of the smart contract; count the execution frequency of the smart contract based on the execution log data of the smart contract; determine the execution priority of the smart contract based on the real-time characteristics of the business associated with the smart contract and the execution frequency of the smart contract; and determine the delayed execution duration of the smart contract based on the priority of the smart contract.
[0120] Specifically, the node device can obtain the execution log data of the smart contract from the node device according to the contract attribute information of the smart contract. The execution log data records the execution time and execution duration of each execution of the smart contract. The node device can count the execution frequency of the smart contract according to the execution log data, and determine the execution priority of the smart contract according to the real-time characteristics and execution frequency of the business associated with the smart contract. There is a positive correlation between the execution frequency and the execution priority, that is, the higher the execution frequency, the higher the execution priority of the smart contract; conversely, the lower the execution frequency, the lower the execution priority of the smart contract. The node device can determine the delayed execution duration of the smart contract according to the execution priority of the smart contract, that is, there is a negative correlation between the execution priority and the delayed execution duration, the higher the execution priority, the shorter the delayed execution duration; the lower the execution priority, the longer the delayed execution duration. Determining the delayed execution duration of the smart contract by the execution priority of the smart contract is conducive to giving priority to the execution of the smart contract with a high execution priority, and improving the flexibility of delayed execution of the smart contract.
[0121] In one embodiment, the node device can detect its own execution performance of the smart contract. When the execution performance of the node device is abnormal, it is determined that the smart contract to be executed meets the delayed execution condition. At this time, the recovery time of the execution performance of the node device can be predicted based on the historical execution log of the smart contract of the node device, and the delayed execution duration of the smart contract can be determined based on the recovery time. The abnormal execution performance can refer to at least one of network abnormality, insufficient remaining storage space in the memory, excessive port occupancy, excessive CPU occupancy, excessive hard disk occupancy, etc.
[0122] S103. Call the smart contract engine corresponding to the smart contract, generate a delayed execution primitive for the smart contract according to the contract attribute information and the delayed execution duration, and store the delayed execution primitive in the system built-in contract corresponding to the smart contract engine.
[0123] In this application, the node device can call the smart contract engine corresponding to the smart contract, and generate the delayed execution primitive of the smart contract according to the contract attribute information and the delayed execution duration. The delayed execution primitive is adapted to the operating system where the smart contract engine is located. The delayed execution primitive has an atomic feature, that is, the process of executing the smart contract based on the delayed execution primitive is not subject to external interference, thereby improving the reliability and security of the delayed execution of the smart contract. In addition, by storing the delayed primitive in the system built-in contract corresponding to the smart contract, the delayed execution primitive can be prevented from being maliciously tampered with, thereby improving the reliability of the delayed execution of the smart contract.
[0124] S104. When it is determined that the smart contract meets the immediate execution condition based on the delayed execution duration, the delayed execution primitive is read from the system built-in contract, and the smart contract engine is called to execute the smart contract according to the delayed execution primitive.
[0125] In the present application, when the node device determines that the smart contract meets the immediate execution condition based on the delayed execution duration, it can read the delayed execution primitive from the system's built-in contract, call the smart contract engine to execute the smart contract according to the delayed execution primitive, and realize delayed execution of the smart contract.
[0126] It should be noted that determining that the smart contract meets the immediate execution condition based on the delayed execution duration may refer to any one or more of the following: 1. The interval from the time when the delayed execution duration of the smart contract is obtained to the current time is the same as the delayed execution duration; 2. All other smart contracts have been executed, and other smart contracts refer to smart contracts whose delayed execution duration is less than the delayed execution duration of this smart contract; 3. Off-chain data about the smart contract is received, and the off-chain data refers to the data used to trigger the execution of the smart contract; 4. The execution performance of the node device regarding the smart contract is restored. In other words, although the delayed execution duration is set in the delayed execution primitive, the delayed execution duration of the smart contract can be dynamically adjusted with at least one of the factors such as the execution of other smart contracts, the time to obtain off-chain data, and the execution performance of the node device, thereby improving the flexibility of the delayed execution of the smart contract.
[0127] In this application, when a smart contract meets the delayed execution condition, the node device in the blockchain network can determine the delayed execution duration of the smart contract based on the business attribute information, and generate a delayed execution primitive for the smart contract based on the delayed execution duration and the contract attribute information of the smart contract through the smart contract engine corresponding to the smart contract, and store the delayed execution primitive in the system built-in contract corresponding to the smart contract engine. The data in the system built-in contract is tamper-proof, so it can avoid the delayed execution primitive in the system built-in contract from being maliciously tampered with, and improve the reliability of the delayed execution of the smart contract. The delayed execution primitive is used to indicate that the smart contract is executed when the waiting time is the delayed execution time. Therefore, when it is determined that the smart contract meets the immediate execution condition based on the delayed execution time, the delayed execution primitive can be read from the system built-in contract, the smart contract engine is called, and the smart contract is executed according to the delayed execution primitive. The delayed execution primitive is related to the operating system where the smart contract engine is located. The delayed execution primitive does not need to rely on the code of the smart contract, and the delayed execution primitive has the characteristics of atomic operation. In the process of executing the smart contract according to the delayed execution primitive, it will not be interrupted by other malicious threads. Therefore, this application can improve the security and reliability of the delayed execution of the smart contract. In addition, the delayed execution duration is dynamically determined according to the contract attribute information of the smart contract, which can improve the flexibility of the delayed execution of the smart contract.
[0128] For further information, see Figure 4 This is a flowchart of a blockchain data processing method provided by an embodiment of the present application. Figure 4 As shown, this method can be Figure 1 The method may include the following steps:
[0129] S201. Obtain contract attribute information of a smart contract to be executed in the blockchain, and business attribute information of a business associated with the smart contract.
[0130] S202. When the smart contract meets the delayed execution condition, the delayed execution duration of the smart contract is determined according to the business attribute information.
[0131] S203. Call the smart contract engine corresponding to the smart contract and generate execution instructions for the smart contract according to the contract attribute information.
[0132] In the present application, the node device can call the corresponding smart contract engine of the smart contract, and generate an execution instruction for the smart contract based on the contract attribute information. The execution instruction can be a call instruction for calling the smart contract. The execution instruction can refer to the primitive of the operating system of the smart contract engine, and the execution instruction has an atomic operation feature.
[0133] S204. According to the data encapsulation format of the smart contract engine, the execution instruction and the delayed execution time are encapsulated to obtain a delayed execution primitive for the smart contract, and the delayed execution primitive is stored in a system built-in contract corresponding to the smart contract engine.
[0134] In this application, the node device can encapsulate the execution instruction and the above-mentioned delayed execution time through the interface of the system built-in contract according to the data encapsulation format of the smart contract engine to obtain the delayed execution primitive of the above-mentioned smart contract, which is conducive to preventing the process of executing the smart contract based on the delayed execution primitive from external interference and improving the reliability and security of the delayed execution of the smart contract. In addition, by storing the delay primitive in the system built-in contract corresponding to the smart contract, the delayed execution primitive can be prevented from being maliciously tampered with, thereby improving the reliability of the delayed execution of the smart contract.
[0135] It should be noted that the data encapsulation format may refer to a data encapsulation format adapted to the operating system where the smart contract engine is located. The data encapsulation format may include a message encapsulation format and a transaction encapsulation format. The message encapsulation format may be used to indicate that a message is encapsulated, and the transaction encapsulation format is used to indicate that a transaction is encapsulated. The transaction encapsulation format may refer to a KV (Key-Value) format. K in this application may refer to the delayed execution duration of the smart contract, and V may refer to an execution instruction.
[0136] In one embodiment, the execution instruction and the delayed execution time are encapsulated according to the data encapsulation format of the smart contract engine to obtain a delayed execution primitive for the smart contract, and the delayed execution primitive is stored in a system built-in contract corresponding to the smart contract engine, including: the node device can obtain a message encapsulation format from the data encapsulation format of the smart contract engine; the execution instruction and the delayed execution time are encapsulated according to the message encapsulation format to obtain a delayed execution message for the smart contract, and the delayed execution message is determined as a delayed execution primitive for the smart contract; and the delayed execution primitive is stored in a message queue of the system built-in contract corresponding to the smart contract engine.
[0137] Specifically, the node device can use the message queue technology to generate the delayed execution primitive of the smart contract, that is, the node device can obtain the message encapsulation format from the data encapsulation format of the smart contract engine; the message encapsulation format can be a message encapsulation format adapted to the operating system where the smart contract engine is located, and the message encapsulation format can include TLV (Type-Len-Value), a message encapsulation format based on RTMP (Real-time Information Transfer Protocol), etc. The node device can encapsulate the above-mentioned execution instruction and the above-mentioned delayed execution duration according to the message encapsulation format, obtain the delayed execution message about the above-mentioned smart contract, determine the delayed execution message as the delayed execution primitive about the above-mentioned smart contract; and store the delayed execution primitive in the message queue of the system built-in contract corresponding to the above-mentioned smart contract engine.
[0138] For example, Figure 5 As shown, the system built-in contract may include a message queue, and the message queue may include one or more delayed execution messages, such as the message queue includes delayed execution message 1, delayed execution message 2, delayed execution message 3 and delayed execution message 4, ...; each delayed execution message is arranged in the message queue in order from short to long according to the corresponding delayed execution time. Figure 5 The delayed execution time corresponding to delayed execution message 1 is the shortest, the delayed execution time corresponding to delayed execution message 2 is longer than the delayed execution time corresponding to delayed execution message 1, and shorter than the delayed execution time corresponding to delayed execution message 3, and so on. When obtaining the execution instruction and delayed execution time of the smart contract, the node device can encapsulate the execution instruction and delayed execution time according to the message encapsulation format to obtain a delayed execution message, and the node device can arrange the delayed execution message in the message queue according to the delayed execution time corresponding to the delayed execution message.
[0139] In one embodiment, the execution instruction and the delayed execution time are encapsulated according to the data encapsulation format of the smart contract engine to obtain a delayed execution primitive for the smart contract, and the delayed execution primitive is stored in a system built-in contract corresponding to the smart contract engine, including: the node device can obtain a transaction encapsulation format from the data encapsulation format of the smart contract engine; according to the transaction encapsulation format, the execution instruction and the delayed execution time are encapsulated to obtain a delayed execution transaction for the smart contract, and the delayed execution transaction is determined as a delayed execution primitive for the smart contract; and the delayed execution primitive is stored in a transaction database of the system built-in contract corresponding to the smart contract engine.
[0140] Specifically, the node device can use the KV database storage technology to generate the delayed execution primitive of the smart contract. The node device can obtain the transaction encapsulation format from the data encapsulation format of the smart contract engine. The transaction encapsulation format can refer to the format adapted to the operating system where the smart contract engine is located. The transaction encapsulation format can refer to the KV encapsulation format. The node device can encapsulate the above-mentioned execution instructions and the above-mentioned delayed execution duration according to the above-mentioned transaction encapsulation format to obtain the delayed execution transaction related to the above-mentioned smart contract, and determine the above-mentioned delayed execution transaction as the delayed execution primitive related to the above-mentioned smart contract; the above-mentioned delayed execution primitive is stored in the transaction database of the system built-in contract corresponding to the above-mentioned smart contract engine, that is, the transaction database can refer to the KV database.
[0141] For example, Figure 6 As shown, the system built-in contract may include a transaction database, which is used to store delayed execution transactions to be executed. When receiving the execution instruction and delayed execution time of the smart contract, the node device can encapsulate the delayed execution time and the execution instruction according to the transaction encapsulation format to obtain the delayed execution transaction, and add the delayed execution transaction to the transaction database.
[0142] It should be noted that node devices can
[0143] S205. When it is determined that the smart contract meets the immediate execution condition based on the delayed execution duration, the delayed execution primitive is read from the system built-in contract, and the smart contract engine is called to execute the smart contract according to the delayed execution primitive.
[0144] In one embodiment, when it is determined that the smart contract meets the immediate execution condition based on the delayed execution time, the delayed execution primitive is read from the system built-in contract, including: the node device can obtain the block information of the target block in the blockchain when the delayed execution primitive is obtained, and the generation time required to generate a single block; the target block is a block with a maximum block height in the blockchain, and according to the generation time, the predicted number of blocks corresponding to the blocks generated under the delayed execution time is predicted; after the target block is generated in the blockchain, the actual number of blocks corresponding to the generated blocks is detected according to the block information of the target block; when the predicted number of blocks is equal to the actual number of blocks, it is determined that the smart contract meets the immediate execution condition, and the delayed execution primitive is read from the system built-in contract.
[0145] Specifically, the node device can obtain the block information of the target block in the blockchain when obtaining the delayed execution primitive, as well as the generation time required to generate a single block, that is, the target block is the latest generated block in the blockchain, and the generation time can be the time required to generate a block. The generation time can be a fixed value or the average time to generate a block. According to the generation time, the predicted number of blocks corresponding to the blocks generated under the above delayed execution time is predicted, that is, the ratio between the delayed execution time and the generation time is the predicted number of blocks corresponding to the blocks generated under the above delayed execution time. The node device can detect the actual number of blocks corresponding to the blocks generated in the blockchain after the target block is generated according to the block information of the target block; when the predicted number of blocks is equal to the actual number of blocks, it is determined that the above smart contract meets the immediate execution condition, and the delayed execution primitive is read from the system built-in contract through the system built-in contract. Timing by the number of blocks generated in the blockchain can solve the problem that the smart contract cannot directly perceive time, which is conducive to ensuring the reliability of delayed execution of smart contracts.
[0146] In one embodiment, the above-mentioned delayed execution primitive is stored in the message queue of the system built-in contract corresponding to the above-mentioned smart contract engine according to the above-mentioned delayed execution time, that is, the delayed execution primitive can be arranged in the message queue in the order of delayed execution time from short to long, that is, the delayed execution primitive corresponding to the shortest delayed execution time is arranged at the front of the message queue (i.e., the head of the team), and the delayed execution primitive corresponding to the longest delayed execution time is arranged at the end of the message queue (i.e., the tail of the team). When it is determined that the above-mentioned smart contract meets the immediate execution condition based on the above-mentioned delayed execution time, the above-mentioned delayed execution primitive is read from the above-mentioned system built-in contract, including: when the execution primitives arranged before the above-mentioned delayed execution primitive in the above-mentioned message queue are all executed, it indicates that the execution primitives whose execution order in the message queue is before the execution order of the delayed execution primitive are all executed, at this time, even if the waiting time has not reached the delayed execution time, the node device can determine that the above-mentioned smart contract meets the immediate execution condition; the node device can read the above-mentioned delayed execution primitive from the message queue of the system built-in contract corresponding to the above-mentioned smart contract engine through the system built-in contract. In other words, the delayed execution duration of the smart contract can be dynamically adjusted according to the execution status of the tasks to be executed in the node device, thereby improving the flexibility of the delayed execution of the smart contract.
[0147] In one embodiment, the above-mentioned reading of the delayed execution primitive from the above-mentioned system built-in contract includes: when the above-mentioned delayed execution primitive is stored in the message queue of the system built-in contract corresponding to the above-mentioned smart contract engine, reading the above-mentioned delayed execution primitive from the above-mentioned message queue; when the above-mentioned delayed execution primitive is stored in the transaction database of the system built-in contract corresponding to the above-mentioned smart contract engine, reading the above-mentioned delayed execution primitive from the above-mentioned transaction database.
[0148] Specifically, when the above-mentioned delayed execution primitive is stored in the message queue of the system built-in contract corresponding to the above-mentioned smart contract engine, the node device can read the above-mentioned delayed execution primitive from the above-mentioned message queue; when the above-mentioned delayed execution primitive is stored in the transaction database of the system built-in contract corresponding to the above-mentioned smart contract engine, the reliability and security of the smart contract are improved: the delayed execution technology of the present invention does not need to rely on the code of the smart contract, but is implemented through system primitives, thereby avoiding the security risk of vulnerabilities in the smart contract. At the same time, the delayed execution technology of the present invention can be dynamically adjusted according to actual conditions, has higher flexibility, and improves the reliability and security of the smart contract.
[0149] It should be noted that this application has the following advantages: 1. Improving the performance and scalability of smart contracts: The delayed execution of smart contracts in this application uses message queue technology and KV database storage technology, which has high performance and scalability and can meet the needs of large-scale blockchain applications. 2. Improving the functionality of smart contracts: This application provides the native delayed execution capability of the smart contract engine, which can meet the needs of smart contracts and improve the functionality of smart contracts. 3. Reducing the difficulty of developing smart contracts: The delayed execution of smart contracts in this application can be achieved by calling the interface of the system's built-in contract, without the need for developers to implement it themselves, which reduces the difficulty of developing smart contracts.
[0150] In this application, when a smart contract meets the delayed execution condition, the node device in the blockchain network can determine the delayed execution duration of the smart contract based on the business attribute information, and generate a delayed execution primitive for the smart contract based on the delayed execution duration and the contract attribute information of the smart contract through the smart contract engine corresponding to the smart contract, and store the delayed execution primitive in the system built-in contract corresponding to the smart contract engine. The data in the system built-in contract is tamper-proof, so it can avoid the delayed execution primitive in the system built-in contract from being maliciously tampered with, and improve the reliability of the delayed execution of the smart contract. The delayed execution primitive is used to indicate that the smart contract is executed when the waiting time is the delayed execution time. Therefore, when it is determined that the smart contract meets the immediate execution condition based on the delayed execution time, the delayed execution primitive can be read from the system built-in contract, the smart contract engine is called, and the smart contract is executed according to the delayed execution primitive. The delayed execution primitive is related to the operating system where the smart contract engine is located. The delayed execution primitive does not need to rely on the code of the smart contract, and the delayed execution primitive has the characteristics of atomic operation. In the process of executing the smart contract according to the delayed execution primitive, it will not be interrupted by other malicious threads. Therefore, this application can improve the security and reliability of the delayed execution of the smart contract. In addition, the delayed execution duration is dynamically determined according to the contract attribute information of the smart contract, which can improve the flexibility of the delayed execution of the smart contract.
[0151] See also Figure 7 , is a schematic diagram of the structure of a blockchain data processing device provided in an embodiment of the present application. The above-mentioned blockchain-based data processing device can be a computer program (including program code) running in a network device. For example, the blockchain-based data processing device is an application software; the device can be used to execute the corresponding steps in the method provided in an embodiment of the present application. Figure 7 As shown, the blockchain data processing device may include:
[0152] The acquisition module 711 is used to obtain the contract attribute information of the smart contract to be executed in the blockchain, and the business attribute information of the business associated with the smart contract;
[0153] A determination module 712 is used to determine the delayed execution duration of the smart contract according to the business attribute information when the smart contract meets the delayed execution condition;
[0154] A generation module 713 is used to call the smart contract engine corresponding to the smart contract, generate a delayed execution primitive for the smart contract according to the contract attribute information and the delayed execution duration, and store the delayed execution primitive in the system built-in contract corresponding to the smart contract engine;
[0155] The calling module 714 is used to read the above-mentioned delayed execution primitive from the above-mentioned system built-in contract when it is determined that the above-mentioned smart contract meets the immediate execution condition based on the above-mentioned delayed execution duration, and call the above-mentioned smart contract engine to execute the above-mentioned smart contract according to the above-mentioned delayed execution primitive.
[0156] Optionally, the generating module 713 includes a calling unit 71a and an encapsulating unit 72a;
[0157] A calling unit 71a is used to call the smart contract engine corresponding to the smart contract and generate an execution instruction of the smart contract according to the contract attribute information;
[0158] The encapsulation unit 72a is used to encapsulate the above-mentioned execution instructions and the above-mentioned delayed execution time according to the data encapsulation format of the above-mentioned smart contract engine, obtain the delayed execution primitive about the above-mentioned smart contract, and store the above-mentioned delayed execution primitive in the system built-in contract corresponding to the above-mentioned smart contract engine.
[0159] Optionally, the encapsulation unit 72a encapsulates the execution instruction and the delayed execution duration according to the data encapsulation format of the smart contract engine to obtain a delayed execution primitive for the smart contract, and stores the delayed execution primitive in a system built-in contract corresponding to the smart contract engine, including:
[0160] Obtain the message encapsulation format from the data encapsulation format of the above smart contract engine;
[0161] According to the message encapsulation format, the execution instruction and the delayed execution duration are encapsulated to obtain a delayed execution message about the smart contract, and the delayed execution message is determined as a delayed execution primitive about the smart contract;
[0162] The above-mentioned delayed execution primitive is stored in the message queue of the system built-in contract corresponding to the above-mentioned smart contract engine.
[0163] Optionally, the encapsulation unit 72a encapsulates the execution instruction and the delayed execution duration according to the data encapsulation format of the smart contract engine to obtain a delayed execution primitive for the smart contract, and stores the delayed execution primitive in a system built-in contract corresponding to the smart contract engine, including:
[0164] Obtain the transaction encapsulation format from the data encapsulation format of the above smart contract engine;
[0165] According to the transaction encapsulation format, the execution instruction and the delayed execution duration are encapsulated to obtain a delayed execution transaction related to the smart contract, and the delayed execution transaction is determined as a delayed execution primitive related to the smart contract;
[0166] The above-mentioned delayed execution primitive is stored in the transaction database of the system built-in contract corresponding to the above-mentioned smart contract engine.
[0167] Optionally, the calling module 714 includes a first acquiring unit 73b, a predicting unit 74b, a detecting unit 75b and a first determining unit 76b;
[0168] The first acquisition unit 73b is used to acquire the block information of the target block in the blockchain when the delayed execution primitive is acquired, and the generation time required to generate a single block; the target block is the block with the maximum block height in the blockchain;
[0169] A prediction unit 74b, configured to predict, according to the generation duration, the number of predicted blocks corresponding to the blocks generated under the delayed execution duration;
[0170] A detection unit 75b is used to detect the actual number of blocks corresponding to the generated blocks after the target block is generated in the blockchain according to the block information of the target block;
[0171] The first determination unit 76b is used to determine that the smart contract meets the immediate execution condition when the predicted block number is equal to the actual block number, and read the delayed execution primitive from the system built-in contract.
[0172] Optionally, the delayed execution primitive is stored in a message queue of a system built-in contract corresponding to the smart contract engine according to the delayed execution duration;
[0173] Optionally, when the calling module 714 determines that the smart contract meets the immediate execution condition based on the delayed execution duration, the calling module 714 reads the delayed execution primitive from the system built-in contract, including:
[0174] When all execution primitives arranged before the delayed execution primitive in the message queue are executed, it is determined that the smart contract meets the immediate execution condition;
[0175] The above-mentioned delayed execution primitive is read from the message queue of the system built-in contract corresponding to the above-mentioned smart contract engine.
[0176] Optionally, the calling module 714 reads the above-mentioned delayed execution primitive from the above-mentioned system built-in contract, including:
[0177] When the above-mentioned delayed execution primitive is stored in the message queue of the system built-in contract corresponding to the above-mentioned smart contract engine, the above-mentioned delayed execution primitive is read from the above-mentioned message queue;
[0178] When the above-mentioned delayed execution primitive is stored in the transaction database of the system built-in contract corresponding to the above-mentioned smart contract engine, the above-mentioned delayed execution primitive is read from the above-mentioned transaction database.
[0179] Optionally, the determination module 712 includes a second determination unit 77c, a second acquisition unit 78c and a third determination unit 79c;
[0180] A second determining unit 77c is used to determine a data source for triggering the execution of the smart contract according to the business attribute information;
[0181] The second acquisition unit 78c is used to acquire generation log data of the off-chain data when the data source indicates that the data triggering the execution of the smart contract is off-chain data;
[0182] The third determination unit 79c is used to determine the generation time of the above-mentioned off-chain data according to the generation log data of the above-mentioned off-chain data, and determine the delayed execution duration of the above-mentioned smart contract according to the above-mentioned generation time.
[0183] Optionally, the second acquisition unit 78c is further configured to acquire, from the business attribute information, the organization information of the business organization to which the business associated with the smart contract belongs;
[0184] The second determining unit 77c is further used to determine the credibility of the business institution according to the institution attribute information of the business institution;
[0185] The third determination unit 79c is further used to determine the delayed execution time of the above-mentioned smart contract according to the credibility of the above-mentioned business organization and the number of smart contracts to be executed in the above-mentioned blockchain.
[0186] Optionally, the second acquisition unit 78c is further configured to acquire the business type of the business associated with the smart contract from the business attribute information;
[0187] The second determining unit 77c is further used to determine the real-time characteristics of the business associated with the smart contract according to the business type of the business associated with the smart contract;
[0188] The third determination unit 79c is further used to determine the delayed execution duration of the above-mentioned smart contract according to the real-time characteristics of the business associated with the above-mentioned smart contract.
[0189] Optionally, the third determining unit 79c determines the delayed execution duration of the smart contract according to the real-time characteristics of the business associated with the smart contract, including:
[0190] Obtaining execution log data of the smart contract according to the contract attribute information of the smart contract;
[0191] According to the execution log data of the above smart contract, the execution frequency of the above smart contract is counted;
[0192] Determine the execution priority of the smart contract based on the real-time characteristics of the business associated with the smart contract and the execution frequency of the smart contract;
[0193] According to the execution priority of the above smart contract, the delayed execution time of the above smart contract is determined.
[0194] In this application, when a smart contract meets the delayed execution condition, the node device in the blockchain network can determine the delayed execution duration of the smart contract based on the business attribute information, and generate a delayed execution primitive for the smart contract based on the delayed execution duration and the contract attribute information of the smart contract through the smart contract engine corresponding to the smart contract, and store the delayed execution primitive in the system built-in contract corresponding to the smart contract engine. The data in the system built-in contract is tamper-proof, so it can avoid the delayed execution primitive in the system built-in contract from being maliciously tampered with, and improve the reliability of the delayed execution of the smart contract. The delayed execution primitive is used to indicate that the smart contract is executed when the waiting time is the delayed execution time. Therefore, when it is determined that the smart contract meets the immediate execution condition based on the delayed execution time, the delayed execution primitive can be read from the system built-in contract, the smart contract engine is called, and the smart contract is executed according to the delayed execution primitive. The delayed execution primitive is related to the operating system where the smart contract engine is located. The delayed execution primitive does not need to rely on the code of the smart contract, and the delayed execution primitive has the characteristics of atomic operation. In the process of executing the smart contract according to the delayed execution primitive, it will not be interrupted by other malicious threads. Therefore, this application can improve the security and reliability of the delayed execution of the smart contract. In addition, the delayed execution duration is dynamically determined according to the contract attribute information of the smart contract, which can improve the flexibility of the delayed execution of the smart contract.
[0195] See also Figure 8 , is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 8As shown, the above-mentioned computer device 1000 may refer to a terminal or a server, including: a processor 1001, a network interface 1004 and a memory 1005. In addition, the above-mentioned computer device 1000 may also include: a user interface 1003, and at least one communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. Among them, in some embodiments, the user interface 1003 may include a display screen (DiSPlay), a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or it may be a non-volatile memory (non-volatileMeMory), such as at least one disk storage. The memory 1005 may also be optionally at least one storage device away from the aforementioned processor 1001. As Figure 8 As shown, the memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a computer program.
[0196] exist Figure 8 In the computer device 1000 shown, the network interface 1004 can provide a network communication function; the user interface 1003 is mainly used to provide an input interface; and the processor 1001 can be used to call a computer program stored in the memory 1005 to execute:
[0197] Obtain the contract attribute information of the smart contract to be executed in the blockchain, as well as the business attribute information of the business associated with the smart contract;
[0198] When the above-mentioned smart contract meets the delayed execution conditions, the delayed execution duration of the above-mentioned smart contract is determined according to the above-mentioned business attribute information;
[0199] Calling the smart contract engine corresponding to the smart contract, generating a delayed execution primitive for the smart contract according to the contract attribute information and the delayed execution duration, and storing the delayed execution primitive in the system built-in contract corresponding to the smart contract engine;
[0200] When it is determined that the smart contract meets the immediate execution conditions based on the delayed execution duration, the delayed execution primitive is read from the system built-in contract, and the smart contract engine is called to execute the smart contract according to the delayed execution primitive.
[0201] Optionally, the processor 1001 calls the computer program stored in the memory 1005 to execute the call to the smart contract engine corresponding to the smart contract, generates a delayed execution primitive for the smart contract according to the contract attribute information and the delayed execution duration, and stores the delayed execution primitive in the system built-in contract corresponding to the smart contract engine, including:
[0202] Calling the smart contract engine corresponding to the smart contract, and generating the execution instruction of the smart contract according to the contract attribute information;
[0203] According to the data encapsulation format of the above-mentioned smart contract engine, the above-mentioned execution instruction and the above-mentioned delayed execution time are encapsulated and processed to obtain the delayed execution primitive regarding the above-mentioned smart contract, and the above-mentioned delayed execution primitive is stored in the system built-in contract corresponding to the above-mentioned smart contract engine.
[0204] Optionally, the processor 1001 calls the computer program stored in the memory 1005 to execute according to the data encapsulation format of the smart contract engine, encapsulates the execution instruction and the delayed execution duration, obtains a delayed execution primitive for the smart contract, and stores the delayed execution primitive in a system built-in contract corresponding to the smart contract engine, including:
[0205] Obtain the message encapsulation format from the data encapsulation format of the above smart contract engine;
[0206] According to the message encapsulation format, the execution instruction and the delayed execution duration are encapsulated to obtain a delayed execution message about the smart contract, and the delayed execution message is determined as a delayed execution primitive about the smart contract;
[0207] The above-mentioned delayed execution primitive is stored in the message queue of the system built-in contract corresponding to the above-mentioned smart contract engine.
[0208] Optionally, the processor 1001 calls the computer program stored in the memory 1005 to execute according to the data encapsulation format of the smart contract engine, encapsulates the execution instruction and the delayed execution duration, obtains a delayed execution primitive for the smart contract, and stores the delayed execution primitive in a system built-in contract corresponding to the smart contract engine, including:
[0209] Obtain the transaction encapsulation format from the data encapsulation format of the above smart contract engine;
[0210] According to the transaction encapsulation format, the execution instruction and the delayed execution duration are encapsulated to obtain a delayed execution transaction related to the smart contract, and the delayed execution transaction is determined as a delayed execution primitive related to the smart contract;
[0211] The above-mentioned delayed execution primitive is stored in the transaction database of the system built-in contract corresponding to the above-mentioned smart contract engine.
[0212] Optionally, the processor 1001 calls a computer program stored in the memory 1005 to execute, when it is determined based on the delayed execution duration that the smart contract meets the immediate execution condition, reading the delayed execution primitive from the system built-in contract, including:
[0213] Obtaining the block information of the target block in the blockchain when the delayed execution primitive is obtained, and the generation time required to generate a single block; the target block is the block with the maximum block height in the blockchain;
[0214] According to the above generation duration, predict the number of predicted blocks corresponding to the blocks generated under the above delayed execution duration;
[0215] Detecting the actual number of blocks corresponding to the generated blocks after the target block is generated in the blockchain according to the block information of the target block;
[0216] When the predicted number of blocks is equal to the actual number of blocks, it is determined that the smart contract meets the immediate execution condition, and the delayed execution primitive is read from the system built-in contract.
[0217] Optionally, the delayed execution primitive is stored in a message queue of a system built-in contract corresponding to the smart contract engine according to the delayed execution duration;
[0218] Optionally, the processor 1001 calls a computer program stored in the memory 1005 to execute, when it is determined based on the delayed execution duration that the smart contract meets the immediate execution condition, reading the delayed execution primitive from the system built-in contract, including:
[0219] When all execution primitives arranged before the delayed execution primitive in the message queue are executed, it is determined that the smart contract meets the immediate execution condition;
[0220] The above-mentioned delayed execution primitive is read from the message queue of the system built-in contract corresponding to the above-mentioned smart contract engine.
[0221] Optionally, the processor 1001 calls a computer program stored in the memory 1005 to execute reading the above-mentioned delayed execution primitive from the above-mentioned system built-in contract, including:
[0222] When the above-mentioned delayed execution primitive is stored in the message queue of the system built-in contract corresponding to the above-mentioned smart contract engine, the above-mentioned delayed execution primitive is read from the above-mentioned message queue;
[0223] When the above-mentioned delayed execution primitive is stored in the transaction database of the system built-in contract corresponding to the above-mentioned smart contract engine, the above-mentioned delayed execution primitive is read from the above-mentioned transaction database.
[0224] Optionally, the processor 1001 calls a computer program stored in the memory 1005 to execute, according to the business attribute information, determining the delayed execution duration of the smart contract, including:
[0225] Determine the data source for triggering the execution of the smart contract based on the business attribute information.
[0226] When the data source indicates that the data that triggers the execution of the smart contract is off-chain data, obtaining the generation log data of the off-chain data;
[0227] According to the generation log data of the above-mentioned off-chain data, the generation time of the above-mentioned off-chain data is determined, and according to the above-mentioned generation time, the delayed execution duration of the above-mentioned smart contract is determined.
[0228] Optionally, the processor 1001 calls a computer program stored in the memory 1005 to execute, according to the business attribute information, determining the delayed execution duration of the smart contract, including:
[0229] From the above business attribute information, obtain the organization information of the business organization to which the business associated with the above smart contract belongs;
[0230] Determining the credibility of the above-mentioned business institutions based on the institution attribute information of the above-mentioned business institutions;
[0231] The delayed execution time of the above-mentioned smart contract is determined based on the credibility of the above-mentioned business organization and the number of smart contracts to be executed in the above-mentioned blockchain.
[0232] Optionally, the processor 1001 calls a computer program stored in the memory 1005 to execute, according to the business attribute information, determining the delayed execution duration of the smart contract, including:
[0233] From the business attribute information, obtain the business type of the business associated with the smart contract;
[0234] Determine the real-time characteristics of the business associated with the smart contract according to the business type of the business associated with the smart contract;
[0235] Determine the delayed execution duration of the smart contract based on the real-time characteristics of the business associated with the smart contract.
[0236] Optionally, the processor 1001 calls a computer program stored in the memory 1005 to execute, according to the real-time characteristics of the business associated with the smart contract, determining the delayed execution duration of the smart contract, including:
[0237] Obtaining execution log data of the smart contract according to the contract attribute information of the smart contract;
[0238] According to the execution log data of the above smart contract, the execution frequency of the above smart contract is counted;
[0239] Determine the execution priority of the smart contract based on the real-time characteristics of the business associated with the smart contract and the execution frequency of the smart contract;
[0240] According to the execution priority of the above smart contract, the delayed execution time of the above smart contract is determined.
[0241] In this application, when a smart contract meets the delayed execution condition, the node device in the blockchain network can determine the delayed execution duration of the smart contract based on the business attribute information, and generate a delayed execution primitive for the smart contract based on the delayed execution duration and the contract attribute information of the smart contract through the smart contract engine corresponding to the smart contract, and store the delayed execution primitive in the system built-in contract corresponding to the smart contract engine. The data in the system built-in contract is tamper-proof, so it can avoid the delayed execution primitive in the system built-in contract from being maliciously tampered with, and improve the reliability of the delayed execution of the smart contract. The delayed execution primitive is used to indicate that the smart contract is executed when the waiting time is the delayed execution time. Therefore, when it is determined that the smart contract meets the immediate execution condition based on the delayed execution time, the delayed execution primitive can be read from the system built-in contract, the smart contract engine is called, and the smart contract is executed according to the delayed execution primitive. The delayed execution primitive is related to the operating system where the smart contract engine is located. The delayed execution primitive does not need to rely on the code of the smart contract, and the delayed execution primitive has the characteristics of atomic operation. In the process of executing the smart contract according to the delayed execution primitive, it will not be interrupted by other malicious threads. Therefore, this application can improve the security and reliability of the delayed execution of the smart contract. In addition, the delayed execution duration is dynamically determined according to the contract attribute information of the smart contract, which can improve the flexibility of the delayed execution of the smart contract.
[0242] In addition, it should be pointed out here that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program executed by the blockchain data processing device mentioned above, and the computer program includes program instructions. When the processor executes the program instructions, it can execute the description of the blockchain data processing method in the corresponding embodiment above, so it will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application.
[0243] As an example, the above program instructions may be deployed on a computer device for execution, or deployed on at least two computer devices at one location for execution, or executed on at least two computer devices distributed at at least two locations and interconnected through a communication network. At least two computer devices distributed at at least two locations and interconnected through a communication network may constitute a blockchain network.
[0244] The computer-readable storage medium may be the blockchain data processing device provided in any of the aforementioned embodiments or the central storage unit of the computer device, such as a hard disk or a central storage of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SMART Media card, SMC), a secure digital (Secure digital, SD) card, a flash memory card (flaSh card), etc. equipped on the computer device. Further, the computer-readable storage medium may also include both the central storage unit of the computer device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0245] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish between contents in different media, rather than to describe a specific order. In addition, the terms "including" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, device, product, or equipment that includes a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules that are not listed, or may optionally include other step units inherent to these processes, methods, devices, products, or equipment.
[0246] The collection and processing of relevant data in this application (such as the initial behavioral characteristics corresponding to the user's interaction behavior, and the user's object characteristics, etc.) should be strictly in accordance with the requirements of relevant national laws and regulations when applied in instances, and the informed consent or separate consent of the personal information subject should be obtained. Subsequent data use and processing should be carried out within the scope of authorization of laws and regulations and the personal information subject.
[0247] The embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the description of the blockchain data processing method and decoding method in the corresponding embodiment above, so it will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. For technical details not disclosed in the embodiment of the computer program product involved in this application, please refer to the description of the method embodiment of this application.
[0248] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0249] The method and related apparatus provided by the embodiment of the present application are described with reference to the method flow chart and / or structural diagram provided by the embodiment of the present application. Specifically, each process and / or box in the method flow chart and / or structural diagram, as well as the combination of the processes and / or boxes in the flow chart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable network connection device to generate a machine, so that the instructions executed by the processor of the computer or other programmable network connection device generate instructions for implementing the process in the process. Figure 1 A process or multiple processes and / or structures Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable network-connected device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or structures Figure 1These computer program instructions can also be loaded onto a computer or other programmable network connected device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process. Figure 1 A flow or multiple flows and / or structures illustrate the steps of the functions specified in one block or multiple blocks.
[0250] The above disclosure is only the preferred embodiment of the present application, which 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 blockchain data processing method, characterized in that: include: Obtaining contract attribute information of the smart contract to be executed in the blockchain, as well as business attribute information of the business associated with the smart contract; When the smart contract meets the delayed execution condition, determining the delayed execution duration of the smart contract according to the business attribute information; Calling the smart contract engine corresponding to the smart contract, generating a delayed execution primitive for the smart contract according to the contract attribute information and the delayed execution duration, and storing the delayed execution primitive in the system built-in contract corresponding to the smart contract engine; When it is determined that the smart contract meets the immediate execution condition based on the delayed execution duration, the delayed execution primitive is read from the system built-in contract, and the smart contract engine is called to execute the smart contract according to the delayed execution primitive.
2. The method according to claim 1, characterized in that: The calling of the smart contract engine corresponding to the smart contract, generating a delayed execution primitive for the smart contract according to the contract attribute information and the delayed execution duration, and storing the delayed execution primitive in a system built-in contract corresponding to the smart contract engine, includes: Calling the smart contract engine corresponding to the smart contract, and generating an execution instruction for the smart contract according to the contract attribute information; According to the data encapsulation format of the smart contract engine, the execution instruction and the delayed execution duration are encapsulated to obtain a delayed execution primitive for the smart contract, and the delayed execution primitive is stored in a system built-in contract corresponding to the smart contract engine.
3. The method according to claim 2, characterized in that The step of encapsulating the execution instruction and the delayed execution duration according to the data encapsulation format of the smart contract engine to obtain a delayed execution primitive for the smart contract, and storing the delayed execution primitive in a system built-in contract corresponding to the smart contract engine includes: Obtain a message encapsulation format from the data encapsulation format of the smart contract engine; According to the message encapsulation format, encapsulate the execution instruction and the delayed execution duration to obtain a delayed execution message about the smart contract, and determine the delayed execution message as a delayed execution primitive about the smart contract; The delayed execution primitive is stored in the message queue of the system built-in contract corresponding to the smart contract engine.
4. The method according to claim 2, characterized in that: The step of encapsulating the execution instruction and the delayed execution duration according to the data encapsulation format of the smart contract engine to obtain a delayed execution primitive for the smart contract, and storing the delayed execution primitive in a system built-in contract corresponding to the smart contract engine includes: Obtaining a transaction encapsulation format from the data encapsulation format of the smart contract engine; According to the transaction encapsulation format, encapsulate the execution instruction and the delayed execution duration to obtain a delayed execution transaction related to the smart contract, and determine the delayed execution transaction as a delayed execution primitive related to the smart contract; The delayed execution primitive is stored in the transaction database of the system built-in contract corresponding to the smart contract engine.
5. The method according to claim 1, characterized in that: When determining that the smart contract meets the immediate execution condition based on the delayed execution duration, reading the delayed execution primitive from the system built-in contract includes: Obtaining block information of a target block in the blockchain when the delayed execution primitive is obtained, and a generation time required to generate a single block; the target block is a block with a maximum block height in the blockchain; According to the generation duration, predict the number of predicted blocks corresponding to the blocks generated under the delayed execution duration; After the target block is generated in the blockchain, the actual number of blocks corresponding to the generated blocks is detected according to the block information of the target block; When the predicted number of blocks is equal to the actual number of blocks, it is determined that the smart contract meets the immediate execution condition, and the delayed execution primitive is read from the system built-in contract.
6. The method according to claim 1, characterized in that The delayed execution primitive is stored in the message queue of the system built-in contract corresponding to the smart contract engine according to the delayed execution duration; When determining that the smart contract meets the immediate execution condition based on the delayed execution duration, reading the delayed execution primitive from the system built-in contract includes: When all execution primitives arranged before the delayed execution primitive in the message queue are executed, it is determined that the smart contract meets the immediate execution condition; Read the delayed execution primitive from the message queue of the system built-in contract corresponding to the smart contract engine.
7. The method according to claim 1, characterized in that The reading the delayed execution primitive from the system built-in contract includes: When the delayed execution primitive is stored in the message queue of the system built-in contract corresponding to the smart contract engine, the delayed execution primitive is read from the message queue; When the delayed execution primitive is stored in the transaction database of the system built-in contract corresponding to the smart contract engine, the delayed execution primitive is read from the transaction database.
8. The method according to claim 1, characterized in that: Determining the delayed execution duration of the smart contract according to the business attribute information includes: Determine, according to the business attribute information, a data source for triggering the execution of the smart contract; When the data source indicates that the data triggering the execution of the smart contract is off-chain data, obtaining generation log data of the off-chain data; The generation time of the off-chain data is determined according to the generation log data of the off-chain data, and the delayed execution duration of the smart contract is determined according to the generation time.
9. The method according to claim 1, characterized in that: Determining the delayed execution duration of the smart contract according to the business attribute information includes: Obtaining, from the business attribute information, the organization information of the business organization to which the business associated with the smart contract belongs; Determining the credibility of the business organization according to the organization attribute information of the business organization; The delayed execution time of the smart contract is determined according to the credibility of the business organization and the number of smart contracts to be executed in the blockchain.
10. The method according to claim 1, characterized in that Determining the delayed execution duration of the smart contract according to the business attribute information includes: Acquire the business type of the business associated with the smart contract from the business attribute information; Determine the real-time characteristics of the business associated with the smart contract according to the business type of the business associated with the smart contract; Determine the delayed execution duration of the smart contract based on the real-time characteristics of the business associated with the smart contract.
11. The method according to claim 10, characterized in that Determining the delayed execution duration of the smart contract according to the real-time characteristics of the business associated with the smart contract includes: Obtaining execution log data of the smart contract according to the contract attribute information of the smart contract; Counting the execution frequency of the smart contract according to the execution log data of the smart contract; Determining the execution priority of the smart contract based on the real-time characteristics of the business associated with the smart contract and the execution frequency of the smart contract; Determine the delayed execution duration of the smart contract according to the execution priority of the smart contract.
12. A blockchain data processing device, characterized in that: include: An acquisition module, used to acquire contract attribute information of a smart contract to be executed in the blockchain, and business attribute information of a business associated with the smart contract; A determination module, configured to determine a delayed execution duration of the smart contract according to the business attribute information when the smart contract meets a delayed execution condition; A generation module, used to call the smart contract engine corresponding to the smart contract, generate a delayed execution primitive for the smart contract according to the contract attribute information and the delayed execution duration, and store the delayed execution primitive in a system built-in contract corresponding to the smart contract engine; The calling module is used to read the delayed execution primitive from the system built-in contract when it is determined that the smart contract meets the immediate execution condition based on the delayed execution duration, and call the smart contract engine to execute the smart contract according to the delayed execution primitive.
13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 11 are implemented.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.