CN109064327B - Intelligent contract processing method, device and equipment - Google Patents

Intelligent contract processing method, device and equipment Download PDF

Info

Publication number
CN109064327B
CN109064327B CN201810714391.1A CN201810714391A CN109064327B CN 109064327 B CN109064327 B CN 109064327B CN 201810714391 A CN201810714391 A CN 201810714391A CN 109064327 B CN109064327 B CN 109064327B
Authority
CN
China
Prior art keywords
contract
execution
contract transaction
transaction
executing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810714391.1A
Other languages
Chinese (zh)
Other versions
CN109064327A (en
Inventor
沈宇峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Lianhua Future Technology Co.,Ltd.
Original Assignee
Zhejiang Ultrain Space Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Ultrain Space Technology Co ltd filed Critical Zhejiang Ultrain Space Technology Co ltd
Priority to CN201810714391.1A priority Critical patent/CN109064327B/en
Publication of CN109064327A publication Critical patent/CN109064327A/en
Application granted granted Critical
Publication of CN109064327B publication Critical patent/CN109064327B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3829Payment protocols; Details thereof insuring higher security of transaction involving key management

Abstract

The application discloses an intelligent contract processing method, device and equipment. The method comprises the following steps: executing contract transaction based on a first time slice allocated by the node in the process of executing the contract transaction corresponding to the intelligent contract; if the first time slice is detected to be finished and contract transaction is not finished, recording the execution progress of the contract transaction; executing contract transaction based on the second time slice and the execution progress allocated by the node; and repeating the steps until the execution result meets the preset execution stopping condition, and stopping executing the contract transaction. According to the contract execution method and device, the execution progress is recorded from the dimensionality of the time slice distributed by the nodes when the contract transaction cannot be completed in one time slice, so that the contract transaction is continuously executed in the subsequent time slice, and the like until the condition for stopping executing the contract transaction is triggered.

Description

Intelligent contract processing method, device and equipment
Technical Field
The application relates to the technical field of computers, in particular to an intelligent contract processing method, device and equipment.
Background
Smart contracts (Smart contracts) are a computer protocol that propagates, verifies, or enforces contracts in an informative manner that may allow for trusted transactions without third parties. In recent years, with the rapid development of the blockchain technology, the blockchain may allow the intelligent contract to operate in a trusted environment, so that the application of the intelligent contract is more and more extensive.
In the ether house, the intelligent contract execution mechanism generally adopts a Gas mechanism, that is, a program executing contract transaction executes commands step by step according to the specification of the intelligent contract, a certain amount of Gas is consumed when executing each command, and when the Gas is consumed and the contract transaction is not executed, the node forcibly terminates the contract execution, resulting in failure of transaction confirmation. I.e. a problem of shutdown occurs. Based on this, the EOS blockchain operating System (EOS) adopts setting intelligent contract runtime online to solve the shutdown problem, including: the intelligent contract is divided into sub-contracts which can be completed in a single consensus period, and then when one sub-contract is completed in one consensus period, the subsequent sub-contract triggered by the sub-contract can be scheduled in the subsequent consensus period. On one hand, however, splitting the intelligent contract will greatly increase the design difficulty and development cost of the developer; on the other hand, there is no guarantee that subsequent subcontracts can be executed.
Therefore, there is a need to provide a more reliable intelligent contract processing scheme.
Disclosure of Invention
The embodiment of the specification provides an intelligent contract processing method, an intelligent contract processing device and intelligent contract processing equipment, and aims to solve the problems of high design difficulty and design cost and unstable execution of the existing intelligent contract processing scheme.
An embodiment of the present specification further provides an intelligent contract processing method, including:
executing the contract transaction based on the first time slice allocated by the node in the process of executing the contract transaction corresponding to the intelligent contract;
if the first time slice is detected to be finished and the contract transaction is not finished, recording the execution progress of the contract transaction;
executing the contract transaction based on the second time slice allocated by the node and the execution progress;
and repeating the steps until the execution result meets the preset execution stopping condition, and stopping executing the contract transaction.
An embodiment of the present specification further provides an intelligent contract processing apparatus, including:
the execution module is used for executing the contract transaction based on the first time slice distributed by the nodes in the process of executing the contract transaction corresponding to the intelligent contract;
the detection module is used for recording the execution progress of the contract transaction if the first time slice is detected to be finished and the contract transaction is not finished;
the execution module is further used for executing the contract transaction based on the second time slice distributed by the node and the execution progress;
the execution module is further used for repeating the steps until the execution stopping condition is met, and stopping executing the contract transaction.
An embodiment of the present specification further provides an electronic device, including:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
executing the contract transaction based on the first time slice allocated by the node in the process of executing the contract transaction corresponding to the intelligent contract;
if the first time slice is detected to be finished and the contract transaction is not finished, recording the execution progress of the contract transaction;
executing the contract transaction based on the second time slice allocated by the node and the execution progress;
and repeating the steps until the execution result meets the preset execution stopping condition, and stopping executing the contract transaction.
The present specification embodiments also provide a computer-readable storage medium storing one or more programs that, when executed by an electronic device including a plurality of application programs, cause the electronic device to perform operations comprising:
executing the contract transaction based on the first time slice allocated by the node in the process of executing the contract transaction corresponding to the intelligent contract;
if the first time slice is detected to be finished and the contract transaction is not finished, recording the execution progress of the contract transaction;
executing the contract transaction based on the second time slice allocated by the node and the execution progress;
and repeating the steps until the execution result meets the preset execution stopping condition, and stopping executing the contract transaction.
The embodiment of the specification adopts at least one technical scheme which can achieve the following beneficial effects:
setting execution duration for contract transaction through the dimension of the time slice distributed by the slave node, and recording the execution progress and pausing if detecting that the contract transaction is not executed and completed in one time slice; restarting the contract transaction at a time slice subsequently allocated by the node and continuing to execute, and so on until a condition for stopping executing the contract transaction is triggered. Compared with the scheme of splitting the intelligent contract and executing one sub-contract in a single consensus period in the prior art, the method can effectively reduce the development difficulty and the development cost and improve the contract execution stability on the basis of solving the shutdown problem.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1a is a schematic structural diagram of a blockchain provided in the present specification;
FIG. 1b is a schematic diagram of a lifecycle management mechanism provided herein;
fig. 2 is a schematic flow chart of an intelligent contract processing method provided in embodiment 1 of the present specification;
fig. 3 is a schematic flowchart of a smart contract restart step provided in embodiment 1 of the present specification;
fig. 4 is a schematic flow chart of an intelligent contract processing method provided in embodiment 2 of the present specification;
fig. 5 is a schematic structural diagram of an intelligent contract processing apparatus provided in embodiment 3 of this specification;
fig. 6 is a schematic structural diagram of an electronic device provided in embodiment 4 of this specification.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
As stated in the background section, the prior art uses a mode of setting the contract running time upper limit to ensure that the contract transaction can be completed in the consensus period when running the intelligent contract to execute the contract transaction, thereby solving the problem of shutdown. In addition, the EOS introduces a delayed transaction function, which allows the subsequent sub-transactions/contracts triggered by the current sub-transactions/contracts to be scheduled in a future consensus period, thereby meeting the requirement of long-term contract execution to some extent. On one hand, the intelligent contract running for a long time is divided into a plurality of sub-contracts which can be completed in a single consensus period, so that the burden of a developer on contract design is greatly increased, and the development cost is further increased; on the other hand, there is no guarantee that subsequent subcontracts must be scheduled and executed.
Based on the above, the invention provides an intelligent contract processing method, which allows contracts to run on a block chain for a long time through the dimension of a time slice distributed from a node, and particularly records the execution progress and pauses when one time slice is not executed to complete contract transaction; restarting the contract transaction and continuing to execute in a subsequent time slice, and so on until a condition for stopping executing the contract transaction is triggered. Therefore, compared with the scheme provided by EOS, the method and the system can effectively reduce the development difficulty and the development cost and improve the contract execution stability on the basis of solving the shutdown problem.
The following exemplifies an application scenario of the present invention.
Referring to fig. 1a, the blockchain includes node 1, node 2 …, node 6, and so on. Each node is provided with a life cycle management module, and the life cycle management module is used for managing the life cycle of the intelligent contract so as to execute different operations on the contract transaction based on the life cycle of the intelligent contract;
taking the node 4 as an example, and referring to fig. 1b, the lifecycle management mechanism may specifically include four lifecycles, which are: a first life cycle OnStart, a second life cycle OnRunning, a third life cycle OnSunpend and a fourth life cycle OnStop; the cycle process can be as follows:
in the contract transaction process executed by the node, loading and starting an intelligent contract, and enabling the intelligent contract to enter a first life cycle OnStart;
performing related preparation work in the first life cycle OnStart, and entering a second life cycle OnRunning if the related preparation work is determined to be completed;
executing business logic related to contract transaction in the second life cycle OnRunning, and directly entering a fourth life cycle OnStop if the execution is completed in a time slice because the execution duration is indefinite;
if the execution is not completed in a time slice, entering a third life cycle OnSunpend; when entering the next time slice, recovering contract transaction to re-enter the second life cycle OnRunning and executing the rest business logic in the second life cycle OnRunning;
and the like until contract transaction is stopped, and entering a fourth life cycle OnStop.
Wherein, the time slice is the time allocated to each program by the node CPU, and each thread is allocated a time period, which is called its time slice, i.e. the time allowed for the process to run, so that each program is seemingly performed simultaneously. If a process is still running at the end of a time slice, the CPU will be deprived and allocated to another process. If the process is blocked or ended before the time slice is ended, the CPU immediately switches. Without causing CPU resource waste. In this specification, a process may be considered as an operational activity of business logic related to a contract transaction, and a program may be considered as a program that performs a contract transaction.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Example 1
Fig. 2 is a schematic flow diagram of an intelligent contract processing method provided in embodiment 1 of this specification, and referring to fig. 2, the method may be completed by a node in fig. 1a, and specifically may include the following steps:
step 22, in the process of executing the contract transaction corresponding to the intelligent contract, executing the contract transaction based on the first time slice allocated by the node;
that is, the associated programs in the node execute contract transactions, or in other words, execute contract transaction-related business logic, using the CPU based on the time allocated by the node CPU.
In addition, as can be seen from the above description of the life cycle management mechanism, the intelligent contract in step 22 is in the second life cycle Running, and before step 22, the method may further include: the step of entering the second lifecycle Running may specifically be as follows:
firstly, supposing an intelligent contract, when determining that a transaction triggering condition of the intelligent contract is triggered, loading the intelligent contract for executing the contract transaction of the intelligent contract, recording the contract transaction as transaction transactionA, configuring a waiting state Pending for the node when the node accepts the transactionA, and adding the waiting state Pending into a long-term transaction set to be processed. Secondly, the long-term transaction in the LRT set is executed in a time-sharing mode when a short time before each round of consensus period starts, so that the contract transactions in the long-term transaction set have the opportunity to be executed. The execution process comprises the following steps: the smart contract is loaded and the contract is started to enter the first life cycle OnStart. The main work of OnStart in the first life cycle includes: the world state of the participant of TransactionA (i.e., the account participating in the transaction) is locked and TransactionA is set to execute the aggregate state. After the main work is completed, the intelligent contract enters the second life cycle OnRunning.
The world state of the participant may be account information such as a balance of the participant, and the world state is referred to as the account information in the ledger maintained around the global node of the blockchain. Based on this, the participant account information may be made to serve only contract transactions in the course of executing the contract transactions.
Step 24, recording the execution progress of the contract transaction if the first time slice is detected to be finished and the contract transaction is not finished;
wherein the execution progress is used for representing the proportion of the currently completed part of the contract transaction in the whole.
It is understood that if the contract transaction is detected to end within the first time slice, the process ends; and if the contract transaction is finished, recording the execution progress of the contract transaction by setting a breakpoint of the program for executing the contract transaction and recording the breakpoint.
Where a breakpoint is a signal that temporarily suspends a program that executes a contract transaction at a certain point. When a program is suspended at a breakpoint, the program may be said to be in an interruption mode, although entering interruption mode will not terminate or end the program, and when a subsequent time slice is available, the program may continue to perform contract transactions.
Step 26, executing the contract transaction based on the second time slice distributed by the node and the execution progress;
the second time slice is a time slice allocated by the node after the first time slice, and may be a time slice next to the first time slice or an nth time slice separated from the first time slice by a plurality of time slices. It can be seen that the terms "first" and "second" are used herein merely to facilitate distinguishing between different time slices, and have no other meaning.
With reference to fig. 1b, after the intelligent contract enters the third life cycle onsubend, it is actually in a state of suspended processing (or a sleep state, corresponding to the above-mentioned program in the interrupt mode), therefore, in order to reduce the amount of data that needs to be maintained, this embodiment may put the intelligent contract into the transaction scheduling list first, and when there is an available second time slice, extract the intelligent contract and continue to execute; moreover, to avoid the critical contract transaction latency time being too long, the present embodiment also configures an execution priority for the intelligent contracts in the transaction scheduling list to be sequentially extracted and executed based on the execution priority. With reference to fig. 3, the following may be specifically mentioned:
step 32, putting the contract transaction into a transaction scheduling list;
step 34, determining the execution priority of the contract transaction based on the characteristic information of the contract transaction;
wherein the characteristic information comprises at least one of waiting execution duration, intelligent contract type and transaction acceleration packet number. Wherein:
waiting for execution duration, which is duration from a time point of last execution ending to current time, wherein the larger the value of the duration is, the higher the execution priority is;
an intelligent contract type comprising: business contracts, personal contracts, general contracts, etc., and contracts required by different types of intelligent contracts vary in timeliness, such as: the timeliness required by the commercial contracts is greater than that required by the common contracts; thus, execution priorities can be configured for different intelligent contract types respectively;
the transaction acceleration package is used for improving the execution priority of contract transactions, and specifically may be: the amount paid by the transaction participants, etc.; accordingly, the larger the number of acceleration packets, the higher the execution priority.
Step 36, acquiring the execution priority of the contract transaction in the second time slice;
it is understood that the execution priority of the contract transaction changes with the increase of the waiting execution time or the change of the number of the transaction acceleration packages, so that the execution priority of the contract transaction needs to be updated in real time or periodically. Further, the latest execution priority for the contract transaction may be determined when the second time slice is available.
And step 38, when the execution priority meets the preset restarting execution condition, extracting the contract transaction from the transaction scheduling list, and executing the contract transaction based on the execution progress in the second time slice.
Wherein, satisfying the predetermined restart execution condition at least comprises: the execution priority of the contract transaction is the highest one or more in the transaction scheduling list; alternatively, the execution priority of the contract transaction is greater than or equal to a preset priority threshold.
And 28, repeating the steps until the execution result meets the preset execution stopping condition, and stopping executing the contract transaction.
It should be noted that the execution result satisfying the preset execution stop condition includes two cases, the first case is: completing the contract transaction; the second case is: the contract transaction is not completed and the execution resources of the intelligent contract are consumed, the execution resources are the resources required to execute the contract transaction, such as: the amount of gas.
Wherein, if the first condition is normal contract transaction completion, the intelligent contract completion status can be set and the uplink procedure is ready to be executed. Specifically, the method comprises the following steps:
when the next consensus period starts, performing consensus verification on the execution result; and if the result of the consensus verification is passed, writing the execution result of the contract transaction into a block.
The second case pertains to abnormally completing a contract transaction, i.e., ending the run due to the completion of the execution resources, rather than completing a contract transaction. For example: the user pays a certain amount of gas for the intelligent contract, the node has a specific gas consumption for each executed command in the intelligent contract, and if the gas amount is not enough to support the gas consumption of all commands corresponding to the intelligent contract, the execution resource is considered to be consumed, and the contract transaction is not executed and completed.
Wherein each command that can be utilized by the smart contract has a corresponding gas value.
Optionally, after stopping executing the contract transaction, the method further comprises: unlocking account information of a participant to the contract transaction so that the participant's account information may service other transactions.
Optionally, before unlocking the account information, the process of executing the contract transaction further includes: modifying account information for a party to a contract transaction; in particular, the amount of the solvent to be used,
for the first case, modifying account information of a participant of the contract transaction according to an execution result of the contract transaction; for example: after the intelligent contract is triggered, the account A is regulated to transfer 100 yuan to the account B, 100 yuan is deducted from the account A, and 100 yuan is transferred to the account B; another example is: after the intelligent contract is triggered, 100 yuan is transferred from the account A to the account B by stipulating that the account A is transferred to the account B, and the 100 yuan in the account of the intelligent contract is 100 yuan transferred from the account A when the intelligent contract is established.
For the second case, restoring the account information of the participant of the contract transaction to the account information in the locking state; for example: when the intelligent contract is triggered, the balance of the account A is regulated to be 100 yuan to the account B based on the contract, and at the moment, the balances of the account A and the account B are changed; however, after the transfer, if the intelligent contract is abnormally completed because the amount of gas is consumed and the subsequent command cannot be executed, all executed states are rolled back, and the balance of the account a and the account B is restored to the balance during locking. Of course, if the amount of gas is consumed before the transfer, there is no need to restore the balance between the two.
Optionally, for the second case, the embodiment further discloses:
and sending a notification message to a sender of the intelligent contract to notify the sender that the contract transaction is failed to execute so that the sender can pay gas in time and execute the intelligent contract again, thereby avoiding the loss caused by the fact that the intelligent contract is not executed in time.
As can be seen, in the embodiment, the execution duration is set for the contract transaction through the dimension of the time slice allocated from the node, and if it is detected that the contract transaction is not executed in one time slice, the execution progress is recorded and suspended; restarting the contract transaction at a time slice subsequently allocated by the node and continuing to execute, and so on until a condition for stopping executing the contract transaction is triggered. Compared with the scheme of splitting the intelligent contract and executing one sub-contract in a single consensus period in the prior art, the method can effectively reduce the development difficulty and the development cost and improve the contract execution stability on the basis of solving the shutdown problem.
In addition, for simplicity of explanation, the above-described method embodiments are described as a series of acts or combinations, but it should be understood by those skilled in the art that the present invention is not limited by the order of acts or steps described, as some steps may be performed in other orders or simultaneously according to the present invention. Furthermore, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Example 2
Fig. 4 is a schematic flow chart of an intelligent contract processing method provided in embodiment 2 of this specification, and referring to fig. 4, for convenience of understanding, the following detailed description of the method from an overall perspective may specifically include the following steps:
step 42, contract transactions for the intelligent contract to be executed are obtained.
The contract transaction is executed when the first time slice begins, step 44.
Synchronously, account information of parties to a contract transaction is locked while the contract transaction is set to an activated state.
And step 46, judging whether the execution result meets the preset execution stopping condition or not when the time slice is finished.
If yes, go to step 412 and step 420; if not, go to step 48;
and step 48, setting a breakpoint for the contract transaction.
After a breakpoint is set for a contract transaction, the contract transaction is set to enter a sleep state.
At step 412, the contract transaction is restarted to be executed based on the breakpoint when the second time slice begins.
The second time slice is later than the first time slice, and specifically may be a time slice next to the first time slice, or may be a time slice separated from the first time slice by several time slices.
In addition, it is understood that, when the second time slice is ended, whether the execution result meets the preset execution stop condition is determined again, and if yes, step 412 and step 420 are executed; if not, based on the execution of steps 46-410, and so on, the execution of the contract transaction is resumed at the third time slice and the fourth time slice … until the execution result meets the preset stop execution condition, so as to execute step 412 and step 420.
Step 412, determine whether the contract transaction is completed normally.
If yes, go to step 414; if not, go to step 418;
if the contract transaction is stopped because the related command is executed, determining that the contract transaction is normally completed;
if the contract transaction is stopped due to the gas quantity being consumed, the contract transaction is determined to be abnormally completed.
Step 414, prepare to perform the uplink step.
Step 416, when the next consensus period starts, performing consensus verification on the execution result; and if the result of the consensus verification is passed, writing the execution result of the contract transaction into a block.
Step 418, sending a notification message to the sender of the intelligent contract to notify the sender that the contract transaction failed to execute.
And step 420, unlocking account information of the participant of the intelligent contract.
As can be seen, in the embodiment, the execution duration is set for the contract transaction through the dimension of the time slice allocated from the node, and if it is detected that the contract transaction is not executed in one time slice, the execution progress is recorded and suspended; restarting the contract transaction at a time slice subsequently allocated by the node and continuing to execute, and so on until a condition for stopping executing the contract transaction is triggered. Compared with the scheme of splitting the intelligent contract and executing one sub-contract in a single consensus period in the prior art, the method can effectively reduce the development difficulty and the development cost and improve the contract execution stability on the basis of solving the shutdown problem.
Example 3
Fig. 5 is a schematic structural diagram of an intelligent contract processing apparatus provided in embodiment 3 of this specification, and referring to fig. 5, the apparatus may be an apparatus including a lifecycle management module shown in fig. 1a in a node, and specifically may include: an execution module 51 and a detection module 52, wherein:
the execution module 51 is used for executing the contract transaction based on the first time slice allocated by the node in the process of executing the contract transaction corresponding to the intelligent contract;
the detection module 52 is configured to record an execution progress of the contract transaction if it is detected that the first time slice is ended and the contract transaction is not completed;
the execution module 51 is further configured to execute the contract transaction based on the second time slice allocated by the node and the execution progress;
the execution module 51 is further configured to stop executing the contract transaction until the stop execution condition is determined to be satisfied.
Optionally, the executing module 51 is further configured to:
and when the transaction triggering condition of the intelligent contract is determined to be triggered, loading the intelligent contract for executing the contract transaction of the intelligent contract.
Optionally, the apparatus further comprises:
a locking module to lock account information of a participant of the contract transaction.
Optionally, the executing module 51 is specifically configured to:
and setting and recording a breakpoint of a program for executing the contract transaction.
Optionally, the apparatus further comprises:
the priority configuration module is used for putting the contract transaction into a transaction scheduling list; determining an execution priority of the contract transaction based on the characteristic information of the contract transaction;
wherein the characteristic information comprises at least one of waiting execution duration, intelligent contract type and transaction acceleration packet number.
Accordingly, the executing module 51 is specifically configured to:
acquiring the execution priority of the contract transaction in the second time slice;
and when the execution priority meets the preset restarting execution condition, extracting the contract transaction from the transaction scheduling list, and executing the contract transaction based on the execution progress in the second time slice.
Optionally, if the execution result is that the contract transaction is completed, it is determined that a preset execution stop condition is satisfied.
Optionally, if the execution result is that the contract transaction is not completed and the execution resources of the intelligent contract are consumed, determining that a preset execution stopping condition is met;
wherein the execution resources are resources consumed to execute the contract transaction.
Optionally, the apparatus further comprises:
an unlocking module to unlock account information of a participant of the contract transaction.
Optionally, the apparatus further comprises:
the modification module is used for modifying the account information of the participant of the contract transaction according to the execution result of the contract transaction if the execution stopping condition met by the execution result is that the contract transaction is completed; or if the execution stopping condition met by the execution result is that the execution resources of the intelligent contract are consumed, recovering the account information of the participant of the contract transaction to the account information in the locking process.
Optionally, the apparatus further comprises:
and the sending module is used for sending a notification message to a sender of the intelligent contract so as to notify the sender that the contract transaction fails to be executed.
As can be seen, in the embodiment, the execution duration is set for the contract transaction through the dimension of the time slice allocated from the node, and if it is detected that the contract transaction is not executed in one time slice, the execution progress is recorded and suspended; restarting the contract transaction at a time slice subsequently allocated by the node and continuing to execute, and so on until a condition for stopping executing the contract transaction is triggered. Compared with the scheme of splitting the intelligent contract and executing one sub-contract in a single consensus period in the prior art, the method can effectively reduce the development difficulty and the development cost and improve the contract execution stability on the basis of solving the shutdown problem.
In addition, as for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to part of the description of the method embodiment. Further, it should be noted that, among the respective components of the apparatus of the present invention, the components thereof are logically divided according to the functions to be realized, but the present invention is not limited thereto, and the respective components may be newly divided or combined as necessary.
Example 4
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application. Referring to fig. 6, at a hardware level, the electronic device includes a processor, and optionally further includes an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory, such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, the network interface, and the memory may be connected to each other via an internal bus, which may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 6, but that does not indicate only one bus or one type of bus.
And the memory is used for storing programs. In particular, the program may include program code comprising computer operating instructions. The memory may include both memory and non-volatile storage and provides instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs the computer program to form the intelligent contract processing device on the logic level. The processor is used for executing the program stored in the memory and is specifically used for executing the following operations:
executing the contract transaction based on the first time slice allocated by the node in the process of executing the contract transaction corresponding to the intelligent contract;
if the first time slice is detected to be finished and the contract transaction is not finished, recording the execution progress of the contract transaction;
executing the contract transaction based on the second time slice allocated by the node and the execution progress;
and repeating the steps until the execution result meets the preset execution stopping condition, and stopping executing the contract transaction.
The method executed by the intelligent contract processing device according to the embodiment shown in fig. 5 of the present application can be applied to a processor or implemented by the processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps of the method in combination with hardware of the processor.
The electronic device may further execute the methods of fig. 2 to 4, and implement the functions of the embodiment of the intelligent contract processing apparatus shown in fig. 5, which are not described herein again in this embodiment of the present application.
Of course, besides the software implementation, the electronic device of the present application does not exclude other implementations, such as a logic device or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or a logic device.
Embodiments of the present application also provide a computer-readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a portable electronic device comprising a plurality of application programs, enable the portable electronic device to perform the method of the embodiments shown in fig. 2-4, and in particular to perform the following operations:
executing the contract transaction based on the first time slice allocated by the node in the process of executing the contract transaction corresponding to the intelligent contract;
if the first time slice is detected to be finished and the contract transaction is not finished, recording the execution progress of the contract transaction;
executing the contract transaction based on the second time slice allocated by the node and the execution progress;
and repeating the steps until the execution result meets the preset execution stopping condition, and stopping executing the contract transaction.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (13)

1. An intelligent contract processing method is applied to a block chain node and comprises the following steps:
executing the contract transaction based on the first time slice allocated by the node in the process of executing the contract transaction corresponding to the intelligent contract;
if the first time slice is detected to be finished and the contract transaction is not finished, recording the execution progress of the contract transaction;
executing the contract transaction based on the second time slice allocated by the node and the execution progress;
and repeating the steps until the execution result meets the preset execution stopping condition, and stopping executing the contract transaction.
2. The method of claim 1, further comprising:
locking account information of a participant to the contract transaction.
3. The method of claim 1, wherein recording the progress of the execution of the contract transaction comprises:
and setting and recording a breakpoint of a program for executing the contract transaction.
4. The method of claim 1, further comprising:
placing the contract transaction into a transaction scheduling list;
determining an execution priority of the contract transaction based on the characteristic information of the contract transaction;
wherein the characteristic information comprises at least one of waiting execution duration, intelligent contract type and transaction acceleration packet number.
5. The method of claim 4, wherein executing the contract transaction based on the second time slice assigned by the node and the execution progress comprises:
acquiring the execution priority of the contract transaction in the second time slice;
and when the execution priority meets the preset restarting execution condition, extracting the contract transaction from the transaction scheduling list, and executing the contract transaction based on the execution progress in the second time slice.
6. The method of claim 1, wherein the predetermined stop execution condition is determined to be satisfied if the execution results in completion of the contract transaction.
7. The method according to claim 1, wherein if the execution result is that the contract transaction is not completed and the execution resources of the intelligent contract are consumed, determining that a preset stop execution condition is met;
wherein the execution resources are resources consumed to execute the contract transaction.
8. The method of claim 6 or 7, further comprising:
unlocking account information of a party to the contract transaction.
9. The method of claim 8, further comprising, prior to unlocking account information of a party to the contract transaction:
if the execution result is that the contract transaction is completed, modifying the account information of the participant of the contract transaction according to the execution result of the contract transaction;
alternatively, the first and second electrodes may be,
and if the execution result is that the contract transaction is not completed and the execution resources of the intelligent contract are consumed, recovering the account information of the participant of the contract transaction as the account information in the locking process.
10. The method of claim 7, further comprising:
and sending a notification message to the sender of the intelligent contract to notify the sender of the execution failure of the contract transaction.
11. An intelligent contract processing apparatus, comprising:
the execution module is used for executing the contract transaction based on the first time slice distributed by the nodes in the process of executing the contract transaction corresponding to the intelligent contract;
the detection module is used for recording the execution progress of the contract transaction if the first time slice is detected to be finished and the contract transaction is not finished;
the execution module is further used for executing the contract transaction based on the second time slice distributed by the node and the execution progress;
the execution module is further used for repeating the steps until the execution stopping condition is met, and stopping executing the contract transaction.
12. An electronic device, comprising:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to perform the method of any one of claims 1-10.
13. A computer readable storage medium, characterized in that the computer readable storage medium stores one or more programs that, when executed by an electronic device comprising a plurality of application programs, cause the electronic device to perform the method of any of claims 1-10.
CN201810714391.1A 2018-06-29 2018-06-29 Intelligent contract processing method, device and equipment Active CN109064327B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810714391.1A CN109064327B (en) 2018-06-29 2018-06-29 Intelligent contract processing method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810714391.1A CN109064327B (en) 2018-06-29 2018-06-29 Intelligent contract processing method, device and equipment

Publications (2)

Publication Number Publication Date
CN109064327A CN109064327A (en) 2018-12-21
CN109064327B true CN109064327B (en) 2021-01-08

Family

ID=64818877

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810714391.1A Active CN109064327B (en) 2018-06-29 2018-06-29 Intelligent contract processing method, device and equipment

Country Status (1)

Country Link
CN (1) CN109064327B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109508915A (en) * 2019-01-17 2019-03-22 苏州复谷网络科技有限公司 A kind of intelligent contract of intelligence based on block chain
CN110213282B (en) * 2019-06-11 2020-09-25 北京瑞策科技有限公司 Research method and device by means of intelligent contract
CN110414977A (en) * 2019-06-12 2019-11-05 阿里巴巴集团控股有限公司 A kind of method and apparatus to lock an account in block chain
CN110717744A (en) * 2019-09-23 2020-01-21 海南新软软件有限公司 Coin extraction congestion emergency processing method, device and system based on digital assets
CN110995790B (en) * 2019-11-14 2021-05-18 北京联合天成价值网络科技有限公司 Method for solving block chain network consensus uncertainty
CN110874266A (en) * 2019-11-20 2020-03-10 上海欧冶金融信息服务股份有限公司 Intelligent contract task instruction sequence execution method and system
CN110956452A (en) * 2019-12-02 2020-04-03 支付宝(杭州)信息技术有限公司 Contract processing method and device
CN112200672B (en) * 2020-09-30 2023-03-17 上海翌派科技有限公司 Intelligent contract processing method

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106559211A (en) * 2016-11-22 2017-04-05 中国电子科技集团公司第三十研究所 Secret protection intelligence contract method in a kind of block chain
CN106899680A (en) * 2017-03-09 2017-06-27 上海亿账通区块链科技有限公司 The burst treating method and apparatus of multi-tiling chain
CN107016611A (en) * 2017-03-29 2017-08-04 杭州秘猿科技有限公司 A kind of transaction manufacture timeout control method based on block chain
CN107239953A (en) * 2017-06-20 2017-10-10 无锡井通网络科技有限公司 Fast data store method and system based on block chain
CN107481011A (en) * 2017-08-11 2017-12-15 杭州秘猿科技有限公司 A kind of transaction rapid acknowledgment method based on license chain
CN107508863A (en) * 2017-07-27 2017-12-22 北京瑞卓喜投科技发展有限公司 Information processing method and device applied to block chain
CN107577694A (en) * 2017-07-14 2018-01-12 阿里巴巴集团控股有限公司 A kind of data processing method and equipment based on block chain
CN107833060A (en) * 2017-11-13 2018-03-23 中国银行股份有限公司 The verification method and system of intelligent contract transaction in a kind of block chain

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106559211A (en) * 2016-11-22 2017-04-05 中国电子科技集团公司第三十研究所 Secret protection intelligence contract method in a kind of block chain
CN106899680A (en) * 2017-03-09 2017-06-27 上海亿账通区块链科技有限公司 The burst treating method and apparatus of multi-tiling chain
CN107016611A (en) * 2017-03-29 2017-08-04 杭州秘猿科技有限公司 A kind of transaction manufacture timeout control method based on block chain
CN107239953A (en) * 2017-06-20 2017-10-10 无锡井通网络科技有限公司 Fast data store method and system based on block chain
CN107577694A (en) * 2017-07-14 2018-01-12 阿里巴巴集团控股有限公司 A kind of data processing method and equipment based on block chain
CN107508863A (en) * 2017-07-27 2017-12-22 北京瑞卓喜投科技发展有限公司 Information processing method and device applied to block chain
CN107481011A (en) * 2017-08-11 2017-12-15 杭州秘猿科技有限公司 A kind of transaction rapid acknowledgment method based on license chain
CN107833060A (en) * 2017-11-13 2018-03-23 中国银行股份有限公司 The verification method and system of intelligent contract transaction in a kind of block chain

Also Published As

Publication number Publication date
CN109064327A (en) 2018-12-21

Similar Documents

Publication Publication Date Title
CN109064327B (en) Intelligent contract processing method, device and equipment
CN107392611B (en) Method and device for sending transaction information and consensus verification
CN110659988B (en) Parallel processing method and device for block chain consensus and execution and electronic equipment
WO2018161901A1 (en) Consensus method and device
CN110622478B (en) Method and device for data synchronous processing
US9304807B2 (en) Fault tolerant batch processing
US9535768B2 (en) Managing multi-threaded operations in a multimedia authoring environment
CN108319495B (en) Task processing method and device
RU2437144C2 (en) Method to eliminate exception condition in one of nuclei of multinuclear system
CN111383031B (en) Intelligent contract execution method and system in block chain and electronic equipment
CN110019502B (en) Synchronization method between primary database and backup database, database system and device
CN104156263A (en) Interruption of chip component managing tasks, chip, and assembly comprising chip
CN104461876A (en) Concurrent program reappearance debugging method based on snapshot sequence running
RU2603497C2 (en) Method of controlling execution of tasks in computer system
CN108829498B (en) Service data access method and device
US9229716B2 (en) Time-based task priority boost management using boost register values
CN117032903B (en) Simulation debugging method and device, storage medium and electronic equipment
CN116089040A (en) Service flow scheduling method and device, electronic equipment and storage medium
CN111258240A (en) Method and device for controlling holder
CN111143127B (en) Method, device, storage medium and equipment for supervising network equipment
CN110599139B (en) Block output method and device in block chain consensus algorithm
KR102544755B1 (en) Distributed storage method and device, electronic apparatus, computer-readable medium and computer program product
CN111597016B (en) System task time protection method, system, storage medium and terminal
CN116431063A (en) Streaming data processing method and device, electronic equipment and storage medium
CN114385392A (en) Method and device for rebuilding Linux kernel scheduler

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20210121

Address after: 100080 1120-64, 11 / F, 18 Zhongguancun Street, Haidian District, Beijing

Patentee after: Beijing Lianhua Future Technology Co.,Ltd.

Address before: 310026 room 401-1, unit 3, building 9, No. 1218, Wenyi West Road, Cangqian street, Yuhang District, Hangzhou City, Zhejiang Province

Patentee before: ZHEJIANG ULTRAIN SPACE TECHNOLOGY Co.,Ltd.