CN109064325A - A kind of intelligent contract implementation method and device based on block chain - Google Patents

A kind of intelligent contract implementation method and device based on block chain Download PDF

Info

Publication number
CN109064325A
CN109064325A CN201810664409.1A CN201810664409A CN109064325A CN 109064325 A CN109064325 A CN 109064325A CN 201810664409 A CN201810664409 A CN 201810664409A CN 109064325 A CN109064325 A CN 109064325A
Authority
CN
China
Prior art keywords
transaction
state
duration
intelligent contract
execution
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.)
Granted
Application number
CN201810664409.1A
Other languages
Chinese (zh)
Other versions
CN109064325B (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.)
Guangzhou smart chain Future Technology Co.,Ltd.
Original Assignee
Zhejiang Hyper Brain Space-Time 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 Hyper Brain Space-Time Technology Co Ltd filed Critical Zhejiang Hyper Brain Space-Time Technology Co Ltd
Priority to CN201810664409.1A priority Critical patent/CN109064325B/en
Publication of CN109064325A publication Critical patent/CN109064325A/en
Application granted granted Critical
Publication of CN109064325B publication Critical patent/CN109064325B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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

Landscapes

  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Engineering & Computer Science (AREA)
  • Finance (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Development Economics (AREA)
  • Technology Law (AREA)
  • Marketing (AREA)
  • Economics (AREA)
  • Computer Security & Cryptography (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

This application discloses a kind of intelligent contract implementation method and device based on block chain, are related to computer field, trade confirmation can be carried out during the realization of intelligent contract, to reach state consistency.The intelligence contract implementation method includes: the mark based on the transaction for driving intelligent contract, determines that the type of the transaction, the type of the transaction include the transaction of first kind duration, the first kind duration trades to execute the transaction that duration is greater than preset value;When the transaction is first kind duration transaction, stateful transaction management is carried out, to realize the decoupling of intelligent the contract cycle of operation and common recognition period.The application is realized for the intelligent contract based on block chain.

Description

A kind of intelligent contract implementation method and device based on block chain
Technical field
This application involves field of computer technology more particularly to a kind of intelligent contract implementation methods and dress based on block chain It sets.
Background technique
Block chain is a kind of a kind of chain type number for being sequentially in time combined into data block in such a way that sequence is connected According to structure, and the distributed account book that can not be distorted He can not forge guaranteed in a manner of cryptography.
Intelligent contract concept was put forward for the first time in 1994 by Nick Szabo, but before the appearance of block chain technology, due to Lack believable performing environment, intelligent contract is not widely used.With popularizing for block chain, intelligent contract technology is obtained Rapid development.Since block chain has the characteristics that decentralization, can not distort and high availability, by intelligent contract with digitized Form is written in block chain, can ensure the storage to intelligent contract, reading, execute whole process it is transparent it is traceable, can not distort.
The intelligent contract based on block chain in the related technology, drive intelligent contract to execute and to come across a common recognition all Transaction in phase must know together herein the period time in be finished, in order to which each node in block chain network is to transaction Implementing result confirmed that and not being performed the transaction finished in the time in period of knowing together herein can then be forced to exit.So And it is inevitably resulted in a large amount of transaction (for example, thousands of or even tens of thousands of transactions) of short time (such as 15 seconds) interior execution numerous Transaction can not be finished by compulsory withdrawal, and so as to cause trade confirmation failure, the realization in turn resulting in intelligent contract is obstructed.
Summary of the invention
The embodiment of the present application provides a kind of intelligent contract implementation method and device based on block chain, can be in intelligent contract Realization during carry out trade confirmation, to reach state consistency.
On the one hand, the embodiment of the present application also provides a kind of intelligent contract implementation method based on block chain, comprising:
Based on the mark for the transaction for driving intelligent contract, the type of the transaction is determined, the type of the transaction includes the A kind of duration transaction, the first kind duration transaction are greater than the transaction of preset value for execution duration;
When the transaction is first kind duration transaction, stateful transaction management is carried out, to realize intelligent contract operation The decoupling in period and common recognition period.
Optionally, in one embodiment, described when the transaction is first kind duration transaction, carry out transaction shape State management, to realize that the decoupling of the intelligent contract cycle of operation and common recognition period include: in the transaction for the first kind duration When transaction, every the common recognition period, the state of the transaction is obtained;If the state of the transaction is ready state, to institute It states transaction and is packaged out block operation;If the state of the transaction is not-ready state, forbid playing the transaction Wrap out block operation.
Optionally, in one embodiment, when the state in the transaction is not-ready state, the non-ready shape State includes that execution state and suspended state forbid playing the transaction if the state of the transaction is not-ready state If wrapping out the state that block operation includes: the transaction is suspended state, the state of the transaction is turned from the suspended state It is changed to execution state;When the state of the transaction is the execution state, the transaction is skipped over.
Optionally, in one embodiment, if the state of the transaction be not-ready state, forbid to it is described trade into Row is packaged out block operation further include:, will be described if the transaction in the execution state is finished in timeslice The state of transaction is converted to the ready state from the execution state;If the transaction in the execution state is in institute It states in timeslice and has not been executed, the state of the transaction is converted into the suspended state from the execution state;If place Occurs abnormal or time-out in the process of implementation in the transaction of the execution state, by the state of the transaction from the execution State is converted to rollback state.
Optionally, in one embodiment, when the intelligent contract is by the first kind duration transaction driven, consumption Growth of the amount of fuel with the intelligent contract operation duration, linear or exponential growth.
Optionally, in one embodiment, the type of the transaction further includes the transaction of the second class duration, when second class Long transaction is not more than the transaction of the preset value for execution duration.The method also includes: it is second class in the transaction When duration is traded, the second class duration transaction is executed.
Optionally, in one embodiment, the preset value can be the common recognition period, and the preset value can be Configurable.
On the other hand, a kind of intelligent contract realization device based on block chain is provided, comprising:
Determining module determines the type of the transaction, the transaction for the mark based on the transaction for driving intelligent contract Type include the transaction of first kind duration, first kind duration transaction is executes the transaction that duration is greater than preset value;
Management module, for carrying out stateful transaction management when the transaction is first kind duration transaction, to realize The decoupling of the intelligent contract cycle of operation and common recognition period.
Optionally, in one embodiment, the management module is specifically used for: being the first kind duration in the transaction When transaction, every the common recognition period, the state of the transaction is obtained;If the state of the transaction is the ready state, Block operation is packaged out to the transaction;If the state of the transaction is not-ready state, forbid carrying out the transaction It is packaged out block operation.
Optionally, in one embodiment, the not-ready state includes execution state and suspended state, the management mould Block is specifically used for: when the state of the transaction is suspended state, the state of the transaction being converted to from the suspended state Execution state;When the state of the transaction is the execution state, the transaction is skipped over.
Optionally, in one embodiment, the management module is also used to: if being in the friendship of the execution state It is easily finished in timeslice, the state of the transaction is converted into the ready state from the execution state;If place It is had not been executed in the timeslice in the transaction of the execution state, by the state of the transaction from the execution shape State is converted to the suspended state;If the transaction in the execution state occurs abnormal or super in the process of implementation When, the state of the transaction is converted into rollback state from the execution state.
Optionally, in one embodiment, when the intelligent contract is by the first kind duration transaction driven, consumption Growth of the amount of fuel with the intelligent contract operation duration, linear or exponential growth.
Optionally, in one embodiment, the type of the transaction further includes the transaction of the second class duration, when second class To execute the transaction that duration is not more than the preset value, the management module is also used to for long transaction: being described the in the transaction When two class durations are traded, the second class duration transaction is executed.
Optionally, in one embodiment, the preset value can be the common recognition period, and the preset value is can to match It sets.
On the other hand, a kind of computer readable storage medium is provided, meter is stored on the computer readable storage medium The instruction of calculation machine executes any of the above kind of intelligent contract implementation method when described instruction is run.
The embodiment of the present application use at least one above-mentioned technical solution can reach it is following the utility model has the advantages that
By classifying to the transaction for driving intelligent contract by mark, it is greater than preset value in the execution duration of the transaction When, by being managed to the state of the transaction, the decoupling of intelligent the contract cycle of operation and common recognition period are realized, so that occurring The transaction in the period of knowing together in one no longer needs to be finished within the common recognition period, but can be across multiple common recognition weeks Phase and execute, so as to trade confirmation be caused to lose due to transaction is by compulsory withdrawal during the realization of intelligent contract It loses, to reach state consistency.
Detailed description of the invention
The drawings described herein are used to provide a further understanding of the present application, constitutes part of this application, this Shen Illustrative embodiments and their description please are not constituted an undue limitation on the present application for explaining the application.In the accompanying drawings:
Fig. 1 is a kind of flow chart of intelligent contract implementation method based on block chain provided by the embodiments of the present application;
Fig. 2 is a kind of flow chart of intelligent contract implementation method based on block chain provided by the embodiments of the present application;
Fig. 3 is a kind of schematic diagram of stateful transaction variation provided by the embodiments of the present application;
Fig. 4 is a kind of structural block diagram of intelligent contract realization device based on block chain provided by the embodiments of the present application.
Specific embodiment
To keep the purposes, technical schemes and advantages of the application clearer, below in conjunction with the application specific embodiment and Technical scheme is clearly and completely described in corresponding attached drawing.Obviously, described embodiment is only the application one Section Example, instead of all the embodiments.Based on the embodiment in the application, those of ordinary skill in the art are not doing Every other embodiment obtained under the premise of creative work out, shall fall in the protection scope of this application.
Before describing the embodiment of the present invention, first some terms in the application are illustrated.
Block chain: it is a kind of without intermediary's participation, can also be maintained between the participant of mutual mistrust or weak trust a set of The technology for the account book record that can not be distorted.The distributed system that block chain is made of the node being much in communication with each other.Block chain System is generally divided into publicly-owned chain, alliance's chain and privately owned chain according to the difference of application scenarios and design system.Each section of publicly-owned chain Point is the read-write that freely can be added and exit network, and participate in data on chain, mutual with flat topological structure interconnection when operation It is logical, the service end node of any centralization is not present in network.Intelligence contract implementation method provided by the embodiments of the present application can base In publicly-owned chain.
The basic conception of block chain may include transaction (Transaction), block (Block) and chain (Chain).Wherein: Transaction can refer to once-through operation, lead to the primary change of account book state, such as one record of addition;Block is hair in record a period of time Raw transaction and state outcome is the primary common recognition to current account book state;Chain is by block one by one according to order of occurrence string Join, is the log recording of entire state change.As soon as if then transaction is attempt to every time using block chain as a state machine Change a next state, and the block for generation of knowing together every time, it is exactly that participant causes state to change All Activity content in block The result of change is confirmed.
Node: the terminal (for example, a computer) being connected in block chain network can be considered as one in block chain A node.
Block chain common recognition mechanism: may include POS (proof of stake, equity prove mechanism), POW (proof of Work, proof of work), DPOS (Delegate Proof of Stake, share authorisation verification) and PBFT (Practical Byzantine Fault Tolerance, practical Byzantine failure tolerance).From probability angle, PBFT serial algorithm be it is determining, one Denier is reached common understanding just irreversible;And POW serial algorithm be then it is uncertain, as time goes by, reversed probability is more next It is smaller.POW guesses a numerical value (nonce) by calculating repeatedly, so that based on the last one block of block chain, in addition new Transaction data Hash (hash) after result meet preset condition.Guarantee whithin a period of time, to lack in system The legal motion of number.These a small amount of legal motions can be broadcasted in a network, and the user received can be based on it after verifying Continue the block new with this method construct on the most long-chain thought.
Intelligent contract: being that is defined in digital form be capable of the contract of automatic implementation of the provisions, i.e., the content packet of intelligent contract Program code is included, the automatic execution of agreement terms can be realized by executing the program code.
In this application, the intelligent contract building based on block chain and execution can be divided into following several steps: (1) multi-party users are total It is same to participate and draw a intelligent contract;(2) intelligent contract passes through reciprocity (peerto peer, P2P) network and spreads and be stored in block Chain;(3) the intelligent contract of block chain building executes automatically.
Below in conjunction with attached drawing, the technical scheme provided by various embodiments of the present application will be described in detail.
Fig. 1 is a kind of flow chart of intelligent contract implementation method based on block chain provided by the embodiments of the present application.Reference Fig. 1, the intelligent contract implementation method provided by the embodiments of the present application based on block chain can include:
Step 12, the mark based on the transaction for driving intelligent contract, determine the type of the transaction, the type of the transaction It trades including first kind duration, the first kind duration transaction is greater than the transaction of preset value for execution duration.
Mark in the embodiment of the present application be used to indicate transaction why seed type.In the embodiment of the present application, transaction can be with It is divided into the transaction of first kind duration and the transaction of the second class duration.Wherein, the first kind duration transaction is greater than default for execution duration The transaction of value, the second class duration transaction are not more than the transaction of preset value for execution duration.In other words, first kind duration is traded It can be, for example, long duration transaction (Long-Range Transaction), the transaction of the second class duration can be, for example, long in short-term hands over Easily (Short-Range Transaction).The preset value can configure according to actual needs in the embodiment of the present application. For example, the preset value is 1 millisecond, 5 milliseconds, 10 milliseconds or 100 milliseconds etc..In one embodiment, the preset value can be with Such as it is set as the duration in a common recognition period.
In the embodiment of the present application, first kind duration transaction can be the transaction for needing to occupy more resource, the second class Duration transaction can be the less transaction of the resource of occupancy.Resource mentioned herein for example can for cpu resource, memory source and Internet resources etc..
In the embodiment of the present application, a mark can all be stamped to each transaction for driving intelligent contract, this mark can Think any form for playing mark action, such as the form for letter of abridging, such as A and B, wherein abbreviation letter A can be indicated The transaction of first kind duration, abbreviation letter b can indicate that the second class duration is traded;Such as the form of one or more numbers, such as 11 With 22, wherein number 11 can indicate that first kind duration is traded, number 22 can indicate that the second class duration is traded;For another example one is small The form of section character, such as abc and qwe, wherein abc can indicate that first kind duration is traded, and qwe can indicate the second class duration Transaction.Mark in the embodiment of the present application can also use other forms, for example, in number, letter and spcial character at least Two kinds of forms etc. mixed.
It certainly, in the embodiment of the present application, can also be to the type of transaction one default of setting.Due to the initiator couple that trades The contract of second class duration exchange triggering is estimated can to execute completion than faster, it is possible to hand over the second class duration Easily it is set as default type.The transaction of default type can be not provided with identifying, so, can be by judging whether transaction is taken Tape identification come determine transaction be the first kind duration transaction or the second class duration transaction.That is, the transaction for carrying mark is the first kind Duration transaction, without carrying the transaction of mark as the transaction of the second class duration.Certainly, in the embodiment of the present application, default type Mark can also be arranged in transaction when needed.
In the embodiment of the present application, the mark of transaction can be preset by the programmer of intelligent contract, in this way, handing over It can easily determine that the transaction belongs to what type of transaction according to the mark carried in the transaction when executed, in turn Facilitate carry out subsequent processing.
In the embodiment of the present application, the second class duration transaction can execute within a common recognition period, and can adopt Accelerated with the method for single machine parallel processing or network fragment.It trades for the second class duration, if being less than the common recognition period Specified runing time in be not carried out, then this transaction can be marked as Fail Transaction, and can carry out rollback to its state. In the embodiment of the present application, first kind duration transaction may execute more complicated application logic, to not can guarantee in pole It is completed in short time (for example, a common recognition period).
Step 14, it is described transaction be the first kind duration transaction when, carry out stateful transaction management, with realize intelligence close The about decoupling of the cycle of operation and common recognition period.
Stateful transaction in the embodiment of the present application can include: at least one in ready state, suspended state and execution state Kind.The decoupling of the intelligent contract cycle of operation and common recognition period can indicate that the intelligent contract cycle of operation is no longer dependent on the common recognition period, That is, intelligent contract can be executed across multiple common recognition periods.
In one embodiment of the application, when the transaction is the second class duration transaction, described the can be performed The transaction of two class durations.So, by distinguishing to two kinds of transaction, and different disposal is carried out, it is ensured that no The transaction of same type can be dealt carefully with, to avoid during the realization of intelligent contract trade confirmation fail, to reach To state consistency.
It is to be understood that each step of the intelligent contract implementation method provided by the embodiments of the present application based on block chain is held Row main body may each be same equipment (for example, can be any node in block chain network), alternatively, this method can also be by difference Equipment is as executing subject.For example, the executing subject of step 12 can be equipment 1 (for example, can be one in block chain network Node), the executing subject of step 14 can be equipment 2 (for example, can be another node in block chain network).
Simultaneously it is to be understood that the intelligent contract implementation method based on block chain in the embodiment of the present application, when implementing, Determine that the process of operation factor (for example, time, random number and data source) can be consistent with the prior art, while running environment It can also keep almost the same with the relevant technologies.It is determined as example with the time, entire block chain can be regarded as to a timestamp clothes Business device, and timestamp when any one block is constructed is obtained, each distributed node can be completely secured in this way and call return Result all can be consistent.
The embodiment of the present application is by classifying to the transaction for driving intelligent contract by mark, in the execution of the transaction When length is greater than preset value, by being managed, realizing the intelligent contract cycle of operation and knowing together the period to the state of the transaction Decoupling, so that the transaction come across in a common recognition period no longer needs to be finished within the common recognition period, but can be with It is executed across multiple common recognition periods, so as to carry out trade confirmation during the realization of intelligent contract, to reach shape State consistency.
Optionally, it in one embodiment of the application, trades in step 14 in the transaction for the first kind duration When, stateful transaction management is carried out, to realize the decoupling of intelligent the contract cycle of operation and common recognition period can include: be in the transaction When the first kind duration is traded, every the common recognition period, the state of the transaction is obtained;If the state of the transaction is The ready state is packaged out block operation to transaction execution;If the state of the transaction is not-ready state, forbid Block operation is packaged out to the transaction.
" being packaged out block operation " mentioned herein can indicate, transaction is packaged into a block and is issued in block chain network Other nodes execute, to carry out calculated result verifying.In the case where meeting some requirements, if such as more than 2/3rds in the whole network Node calculated result it is identical, then may determine therefrom that out block node, and the block that block node out goes out is put into block chain.
For the embodiment of the present application when handling the transaction of first kind duration, meeting first obtains the shape of transaction in each common recognition period State, to determine whether the state of transaction is ready state, only the transaction in ready state, which just will do it, is packaged out block operation, And the transaction in other states not will do it in the currently common recognition period and be packaged out block operation, and so, block chain network In each node after having executed the transaction in ready state, trade confirmation is able to carry out, to guarantee state consistency.
In one embodiment of the application, the not-ready state includes execution state and suspended state, if described The state of transaction is not-ready state, forbids being packaged out the transaction block operation can include: if the shape of the transaction State is suspended state, and the state of the transaction is converted to execution state from the suspended state;If the state of the transaction For the execution state, the transaction is skipped over.The embodiment of the present application is when handling the transaction of first kind duration, however, it is determined that trades out State is suspended state, by the way that suspended state is converted to execution state, can be executed in order to subsequent to the transaction.
Optionally, in one embodiment of the application, for being in the transaction of execution state, it is being in the execution shape When the transaction of state is finished in timeslice, can by the state of the transaction from the execution state be converted to it is described just Not-ready status;It, can be by the transaction when the transaction in the execution state has not been executed in the timeslice State is converted to the suspended state from the execution state;It is being in the transaction of the execution state in the process of implementation When there is abnormal or time-out, the state of the transaction can be converted to rollback state from the execution state.The embodiment of the present application Concrete condition is based on to the transaction of processing execution state and carries out state switching, can be better achieved to the transaction of first kind duration Condition managing.
It, can also be into the embodiment of the present application except through being classified to transaction and being carried out except life cycle management The management of row fuel (gas).It is thus possible to can be better achieved by the integrated management of this three above in intelligent contract Realization during carry out trade confirmation, specifically, can in one embodiment of the application to reach state consistency Paid management is done to the intelligent contract of first kind duration transaction driven, establishes the runing time and rate of fuel consumption of intelligent contract Corresponding relationship.For example, the amount of the fuel of consumption is with institute when the intelligent contract is by the first kind duration transaction driven The growth of intelligent contract operation duration is stated, linear growth or exponential growth.It so, can be in economic cost to The intelligent contract of a kind of duration transaction driven is managed, it is ensured that and no one trades to do evil by first kind duration, such as The long-term occupancy system resources in computation of malice.
Fig. 2 is a kind of flow chart of intelligent contract implementation method based on block chain provided by the embodiments of the present application.Reference Fig. 2, the intelligent contract implementation method provided by the embodiments of the present application based on block chain can include:
Step 22, the mark based on the transaction for driving intelligent contract, determine the type of the transaction, the type of the transaction Including the transaction of first kind duration and the transaction of the second class duration.
Wherein, to execute the transaction that duration is greater than preset value, the second class duration is traded for the first kind duration transaction To execute the transaction that duration is not more than preset value.
Step 24, it is described transaction be the first kind duration transaction when, every the common recognition period, obtain the transaction State, whether be ready state with the state of the determination transaction.
Step 26, the transaction state be the ready state when, to the transaction be packaged out block operation.
Step 28, the transaction state be suspended state when, by the state of the transaction from the suspended state turn It is changed to the execution state.
Step 30, the transaction state be execution state when, based on concrete condition carry out state transition operation.Step 30 can cover following situation:
Step 301, when being finished in timeslice in the transaction of the execution state, by the transaction State is converted to the ready state from the execution state;
Step 302, when being had not been executed in the timeslice in the transaction of the execution state, will be described The state of transaction is converted to the suspended state from the execution state;
Step 303, when the transaction in the execution state occurs abnormal or overtime in the process of implementation, by institute The state for stating transaction is converted to rollback state from the execution state.
Step 32, when the transaction is the second class duration transaction, directly execute the second class duration transaction.
It is to be understood that the related content of each step shown in Fig. 3 can refer to and be described above, details are not described herein.
Stateful switchover process referred to herein can also refer to shown in Fig. 3, as shown in Figure 3, it is assumed that when transaction A is the first kind Long transaction, transaction A may be at suspended state after accepting.In common recognition cycle T 1, the transaction A in suspended state can be scheduled It executes, to be converted into execution state from suspended state.If transaction A has not yet been executed back in timeslice in common recognition cycle T 1 To suspended state, and standby executed again in next common recognition cycle T 2.In common recognition cycle T 2, if transaction A is executed in timeslice It is complete, then it is converted into ready state from execution state, if occur abnormal or time-out in the process of implementation, from the conversion of the state of execution For rollback state.In n-th common recognition period Tn, wherein N is greater than 2, if transaction A has been in ready state, beats transaction A Wrap out block operation.It is to be understood that schematic diagram shown in Fig. 3 is a kind of the schematically illustrate of condition managing, and it is not meant to be limitation.
Intelligent contract implementation method provided by the embodiments of the present application based on block chain classifies to transaction by mark Processing, and the life cycle management to the transaction of first kind duration is realized by condition managing, it is ensured that different types of friendship Can easily be dealt carefully with, to avoid during the realization of intelligent contract trade confirmation fail, while can guarantee first The transaction of class duration can be executed across multiple common recognition periods, so as to carry out trading during the realization of intelligent contract really Recognize, to reach state consistency.
Simultaneously need to understand, in the embodiment of the present application except through classified to transaction and carried out life cycle management it Outside, the management of fuel (gas) can also be carried out.It is thus possible to can be better achieved by the integrated management of this three above Trade confirmation is carried out during the realization of intelligent contract, to reach state consistency, specifically, in the reality of the application It applies in example, paid management can be done to the intelligent contract of first kind duration transaction driven, establish the runing time and combustion of intelligent contract Expect the corresponding relationship of quantity consumed.For example, when the intelligent contract is by the first kind duration transaction driven, the fuel of consumption Amount with the intelligent contract operation duration growth, it is linear to increase or exponential growth.It so, can be in economy The intelligent contract of first kind duration transaction driven is managed in cost, it is ensured that no one by first kind duration trade come It does evil, such as the long-term occupancy system resources in computation of malice.
Fig. 4 is a kind of structural block diagram of intelligent contract realization device based on block chain provided by the embodiments of the present application.Ginseng According to Fig. 4, the intelligent contract realization device 40 provided by the embodiments of the present application based on block chain can include: determining module 41 and management Module 42.Wherein:
Determining module 41 determines the type of the transaction, the friendship for the mark based on the transaction for driving intelligent contract Easy type includes the transaction of first kind duration, and the first kind duration transaction is greater than the transaction of preset value for execution duration;
Management module 42, for stateful transaction management being carried out, with reality when the transaction is first kind duration transaction The now decoupling of intelligent the contract cycle of operation and common recognition period.
Optionally, in one embodiment, the management module 42 is specifically used for: when the transaction is the first kind When long transaction, every the common recognition period, the state of the transaction is obtained;If the state of the transaction is ready state, right The transaction is packaged out block operation;If the state of the transaction is not-ready state, forbid carrying out the transaction It is packaged out block operation.
Optionally, in one embodiment, the not-ready state includes execution state and suspended state, the management mould Block 42 is specifically used for: if the state of the transaction is suspended state, the state of the transaction being converted from the suspended state To execute state;If the state of the transaction is the execution state, the transaction is skipped over;.
Optionally, in one embodiment, the management module 42 is also used to: if described in the execution state Transaction is finished in timeslice, and the state of the transaction is converted to the ready state from the execution state;If The transaction in the execution state has not been executed in the timeslice, by the state of the transaction from the execution State is converted to the suspended state;If the transaction in the execution state occurs abnormal or super in the process of implementation When, the state of the transaction is converted into rollback state from the execution state.
Optionally, in one embodiment, when the intelligent contract is by the first kind duration transaction driven, consumption Growth of the amount of fuel with the intelligent contract operation duration, linear or exponential growth.
Optionally, in one embodiment, the type of the transaction further includes the transaction of the second class duration, when second class To execute the transaction that duration is not more than the preset value, the management module 42 is also used to for long transaction: being described in the transaction When second class duration is traded, the second class duration transaction is executed.
Optionally, in one embodiment, the preset value can be the common recognition period, and the preset value is can to match It sets.
Intelligent contract realization device provided by the embodiments of the present application based on block chain passes through the friendship to intelligent contract is driven Easily classify by mark, when the execution duration of the transaction is greater than preset value, by carrying out pipe to the state of the transaction Reason realizes the decoupling of intelligent the contract cycle of operation and common recognition period, so that the transaction come across in a common recognition period no longer needs It to be finished, but can be executed across multiple common recognition periods within the common recognition period, so as in intelligent contract Realization during carry out trade confirmation, to reach state consistency.
In addition, the embodiment of the present application can provide a kind of computer readable storage medium, the computer readable storage medium On be stored with computer instruction, when described instruction is run, execute any of the above kind of intelligent contract implementation method.
Computer readable storage medium provided by the embodiments of the present application, by drive the transaction of intelligent contract by identify into Row classification, by being managed to the state of the transaction, realizes intelligence when the execution duration of the transaction is greater than preset value The decoupling of the contract cycle of operation and common recognition period, so that the transaction come across in a common recognition period is no longer needed in the common recognition It is finished, but can be executed across multiple common recognition periods in period, so as to during the realization of intelligent contract Trade confirmation is carried out, to reach state consistency.
In addition, a kind of block chain node can also be provided in the embodiment of the present application, the block chain node for example can be computer Or server, and may include storage medium and processor.Wherein, the storage medium is suitable for storing a plurality of instruction;The processing Device is adapted for carrying out the various instructions stored on storage medium.When the instruction stored on the storage medium is run by processor Any intelligent contract implementation method based on block chain as described above can be achieved.
It should be understood by those skilled in the art that, the embodiment of the present invention can provide as method, apparatus or computer program Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the present invention Apply the form of example.Moreover, it wherein includes the computer of computer usable program code that the present invention, which can be used in one or more, The computer program implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) produces The form of product.
The present invention be referring to according to the method for the embodiment of the present invention, the process of equipment (system) and computer program product Figure and/or block diagram describe.It should be understood that every one stream in flowchart and/or the block diagram can be realized by computer program instructions The combination of process and/or box in journey and/or box and flowchart and/or the block diagram.It can provide these computer programs Instruct the processor of general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce A raw machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for real The device for the function of being specified in present one or more flows of the flowchart and/or one or more blocks of the block diagram.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates, Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one The step of function of being specified in a box or multiple boxes.
In a typical configuration, calculating equipment includes one or more processors (CPU), input/output interface, net Network interface and memory.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/or The forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable medium Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data. The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM), Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices Or any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculates Machine readable medium does not include temporary computer readable media (transitorymedia), such as the data-signal and carrier wave of modulation.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability It include so that the process, method, commodity or the equipment that include a series of elements not only include those elements, but also to wrap Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including described want There is also other identical elements in the process, method of element, commodity or equipment.
It will be understood by those skilled in the art that embodiments herein can provide as method, system or computer program product. Therefore, complete hardware embodiment, complete software embodiment or embodiment combining software and hardware aspects can be used in the application Form.It is deposited moreover, the application can be used to can be used in the computer that one or more wherein includes computer usable program code The shape for the computer program product implemented on storage media (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) Formula.
The above description is only an example of the present application, is not intended to limit this application.For those skilled in the art For, various changes and changes are possible in this application.All any modifications made within the spirit and principles of the present application are equal Replacement, improvement etc., should be included within the scope of the claims of this application.

Claims (15)

1. a kind of intelligent contract implementation method based on block chain characterized by comprising
Based on the mark for the transaction for driving intelligent contract, determine that the type of the transaction, the type of the transaction include the first kind Duration transaction, the first kind duration transaction are greater than the transaction of preset value for execution duration;
If the transaction is that the first kind duration is traded, stateful transaction management is carried out, to realize the intelligent contract cycle of operation With the decoupling in common recognition period.
2. intelligence contract implementation method according to claim 1, which is characterized in that described in the transaction is described first When class duration is traded, stateful transaction management is carried out, the decoupling with the realization intelligent contract cycle of operation and common recognition period includes:
When the transaction is first kind duration transaction, every the common recognition period, the state of the transaction is obtained;
If the state of the transaction is ready state, block operation is packaged out to the transaction;
If the state of the transaction is not-ready state, forbid being packaged out the transaction block operation.
3. intelligence contract implementation method according to claim 2, which is characterized in that the not-ready state includes executing shape State and suspended state forbid being packaged out the transaction block operation packet if the state of the transaction is not-ready state It includes:
If the state of the transaction is suspended state, the state of the transaction is converted into execution shape from the suspended state State;
If the state of the transaction is the execution state, the transaction is skipped over.
4. intelligence contract implementation method according to claim 3, which is characterized in that if the state of the transaction is non- Not-ready status forbids being packaged out the transaction block operation further include:
If the transaction in the execution state is finished in timeslice, the state of the transaction is held from described Row state is converted to the ready state;
If had not been executed in the timeslice in the transaction of the execution state, by the state of the transaction from The execution state is converted to the suspended state;
If there is abnormal or time-out in the process of implementation in the transaction in the execution state, by the state of the transaction Rollback state is converted to from the execution state.
5. intelligence contract implementation method according to claim 1 to 4, which is characterized in that
When the intelligent contract is by the first kind duration transaction driven, the amount of the fuel of consumption is with the intelligent contract fortune The growth of row duration, linear or exponential growth.
6. intelligence contract implementation method according to claim 1, which is characterized in that the type of the transaction further includes second The transaction of class duration, the second class duration transaction are not more than the transaction of the preset value for execution duration,
The method also includes:
If the transaction is that the second class duration is traded, the second class duration transaction is executed.
7. intelligence contract implementation method according to claim 1, which is characterized in that the preset value is the common recognition week Phase, and the preset value is configurable.
8. a kind of intelligent contract realization device based on block chain characterized by comprising
Determining module determines the type of the transaction, the class of the transaction for the mark based on the transaction for driving intelligent contract Type includes the transaction of first kind duration, and the first kind duration transaction is greater than the transaction of preset value for execution duration;
Management module carries out stateful transaction management, if being that the first kind duration is traded for the transaction to realize intelligence The decoupling of the contract cycle of operation and common recognition period.
9. intelligence contract realization device according to claim 8, which is characterized in that the management module is specifically used for:
When the transaction is first kind duration transaction, every the common recognition period, the state of the transaction is obtained;
If the state of the transaction is the ready state, block operation is packaged out to the transaction;
If the state of the transaction is not-ready state, forbid being packaged out the transaction block operation.
10. intelligence contract realization device according to claim 9, which is characterized in that the not-ready state includes executing State and suspended state, the management module are specifically used for:
When the state of the transaction is suspended state, the state of the transaction is converted into execution shape from the suspended state State;
If the state of the transaction is the execution state, the transaction is skipped over.
11. intelligence contract realization device according to claim 10, which is characterized in that the management module is also used to:
If the transaction in the execution state is finished in timeslice, the state of the transaction is held from described Row state is converted to the ready state;
If had not been executed in the timeslice in the transaction of the execution state, by the state of the transaction from The execution state is converted to the suspended state;
If there is abnormal or time-out in the process of implementation in the transaction in the execution state, by the state of the transaction Rollback state is converted to from the execution state.
12. according to any intelligent contract realization device of claim 8-11, which is characterized in that
When the intelligent contract is by the first kind duration transaction driven, the amount of the fuel of consumption is with the intelligent contract fortune The growth of row duration, linear or exponential growth.
13. intelligence contract realization device according to claim 8, which is characterized in that the type of the transaction further includes the The transaction of two class durations, the second class duration transaction are not more than the transaction of the preset value for execution duration,
The management module is also used to:
If the transaction is that the second class duration is traded, the second class duration transaction is executed.
14. intelligence contract realization device according to claim 8, which is characterized in that the preset value is the common recognition week Phase, and the preset value is configurable.
15. a kind of computer readable storage medium, it is stored with computer instruction on the computer readable storage medium, when described When instruction is run, -7 any intelligent contract implementation method according to claim 1 is executed.
CN201810664409.1A 2018-06-25 2018-06-25 Intelligent contract implementation method and device based on block chain Active CN109064325B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810664409.1A CN109064325B (en) 2018-06-25 2018-06-25 Intelligent contract implementation method and device based on block chain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810664409.1A CN109064325B (en) 2018-06-25 2018-06-25 Intelligent contract implementation method and device based on block chain

Publications (2)

Publication Number Publication Date
CN109064325A true CN109064325A (en) 2018-12-21
CN109064325B CN109064325B (en) 2020-07-24

Family

ID=64821489

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810664409.1A Active CN109064325B (en) 2018-06-25 2018-06-25 Intelligent contract implementation method and device based on block chain

Country Status (1)

Country Link
CN (1) CN109064325B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109710385A (en) * 2018-12-29 2019-05-03 杭州趣链科技有限公司 A kind of intelligent contract complexity method for limiting based on Java Virtual Machine
CN111274576A (en) * 2020-01-17 2020-06-12 济南浪潮高新科技投资发展有限公司 Control method, system, equipment and medium for intelligent contract operating environment
CN112200575A (en) * 2020-05-28 2021-01-08 支付宝(杭州)信息技术有限公司 Node group creating method and node group-based transaction method in alliance chain network
CN112380149A (en) * 2021-01-18 2021-02-19 腾讯科技(深圳)有限公司 Data processing method, device, equipment and medium based on node memory
CN112529582A (en) * 2019-08-20 2021-03-19 厦门本能管家科技有限公司 Multistage transaction acceleration method and system for block chain
WO2021135467A1 (en) * 2020-07-31 2021-07-08 平安科技(深圳)有限公司 Automated machine learning-based ethereum fuel restriction prediction method, apparatus, computer device, and storage medium
WO2021197227A1 (en) * 2020-04-01 2021-10-07 International Business Machines Corporation Noisy transaction for protection of data

Citations (5)

* 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
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
CN107577694A (en) * 2017-07-14 2018-01-12 阿里巴巴集团控股有限公司 A kind of data processing method and equipment based on block chain

Patent Citations (5)

* 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
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
CN107481011A (en) * 2017-08-11 2017-12-15 杭州秘猿科技有限公司 A kind of transaction rapid acknowledgment method based on license chain

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109710385A (en) * 2018-12-29 2019-05-03 杭州趣链科技有限公司 A kind of intelligent contract complexity method for limiting based on Java Virtual Machine
CN112529582A (en) * 2019-08-20 2021-03-19 厦门本能管家科技有限公司 Multistage transaction acceleration method and system for block chain
CN112529582B (en) * 2019-08-20 2024-08-06 本无链科技(深圳)有限公司 Multistage transaction acceleration method and system for blockchain
CN111274576A (en) * 2020-01-17 2020-06-12 济南浪潮高新科技投资发展有限公司 Control method, system, equipment and medium for intelligent contract operating environment
WO2021197227A1 (en) * 2020-04-01 2021-10-07 International Business Machines Corporation Noisy transaction for protection of data
GB2609156A (en) * 2020-04-01 2023-01-25 Ibm Noisy transaction for protection of data
CN112200575A (en) * 2020-05-28 2021-01-08 支付宝(杭州)信息技术有限公司 Node group creating method and node group-based transaction method in alliance chain network
CN112200575B (en) * 2020-05-28 2022-05-31 支付宝(杭州)信息技术有限公司 Node group creating method and node group-based transaction method in alliance chain network
WO2021135467A1 (en) * 2020-07-31 2021-07-08 平安科技(深圳)有限公司 Automated machine learning-based ethereum fuel restriction prediction method, apparatus, computer device, and storage medium
CN112380149A (en) * 2021-01-18 2021-02-19 腾讯科技(深圳)有限公司 Data processing method, device, equipment and medium based on node memory
CN113094396A (en) * 2021-01-18 2021-07-09 腾讯科技(深圳)有限公司 Data processing method, device, equipment and medium based on node memory
CN113094396B (en) * 2021-01-18 2022-07-26 腾讯科技(深圳)有限公司 Data processing method, device, equipment and medium based on node memory

Also Published As

Publication number Publication date
CN109064325B (en) 2020-07-24

Similar Documents

Publication Publication Date Title
CN109064325A (en) A kind of intelligent contract implementation method and device based on block chain
CN108062672B (en) Flow scheduling method based on block chain intelligent contract
US11336589B2 (en) Allocating virtual resource based on blockchain
CN110471984B (en) Service processing method and device based on block chain and electronic equipment
CN110163590B (en) Payment withholding method and device based on block chain, electronic equipment and storage medium
CN108200203B (en) Block chain system based on double-layer network
TW202105276A (en) Allocating virtual resource based on block chain
CN101315607B (en) There is how synchronous transaction module control flow
US20190199693A1 (en) Safe-Transfer Exchange Protocol Based on Trigger-Ready Envelopes Among Distributed Nodes.
CN110162470A (en) A kind of test method and device of block chain
Dubslaff et al. Probabilistic model checking for energy analysis in software product lines
CN111784318B (en) Data processing method, device, electronic equipment and storage medium
CN110704438B (en) Method and device for generating bloom filter in blockchain
CN111966503B (en) Method and device for managing storage space of intelligent contract account
CN112015577B (en) Intelligent contract calling method and device
CN110263580A (en) Data processing method, device and block chain node based on block chain
CN112015822B (en) Block chain data deleting method and device
CN109146146A (en) Event prediction method and device, electronic equipment
CN110443612B (en) Block chain-based reimbursement expense segmentation method and device and electronic equipment
CN115456772A (en) Intelligent contract creating method and device
CN111553695A (en) Cross-region payment method and device and electronic equipment
Kang et al. Stochastic modeling approaches for analyzing blockchain: A survey
ter Hofstede et al. Generating a process model from a process audit log
Volpe et al. A Deep Reinforcement Learning Approach for Competitive Task Assignment in Enterprise Blockchain
Xu et al. Pinfer: Learning to infer concurrent request paths from system kernel events

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

Effective date of registration: 20200728

Address after: B1910, building 9, zone 2, Shenzhen Bay science and technology ecological park, 3609 Baishi Road, community, high tech Zone, Yuehai street, Nanshan District, Shenzhen City, Guangdong Province

Patentee after: Shenzhen smart chain Future Technology Co., Ltd

Address before: 310026 401 unit -1, 3 unit of Wen Yi Road 1218, Cang Qian Road, Yuhang District, Hangzhou, Zhejiang, China, 401

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

TR01 Transfer of patent right
CP03 Change of name, title or address

Address after: 518054 unit 201, 202, 203, 2nd floor, unit 301, 302, 303, 3rd floor, building A1, commercial plaza, 191 science Avenue, Huangpu District, Guangzhou City, Guangdong Province

Patentee after: Guangzhou smart chain Future Technology Co.,Ltd.

Address before: B1910, building 9, zone 2, Shenzhen Bay science and technology ecological park, 3609 Baishi Road, high tech Zone community, Yuehai street, Nanshan District, Shenzhen, Guangdong 518054

Patentee before: Shenzhen smart chain Future Technology Co., Ltd

CP03 Change of name, title or address