CN109859038B - Method and device for taking block chain intelligent contract into effect - Google Patents

Method and device for taking block chain intelligent contract into effect Download PDF

Info

Publication number
CN109859038B
CN109859038B CN201811602952.5A CN201811602952A CN109859038B CN 109859038 B CN109859038 B CN 109859038B CN 201811602952 A CN201811602952 A CN 201811602952A CN 109859038 B CN109859038 B CN 109859038B
Authority
CN
China
Prior art keywords
intelligent contract
latest version
contract
effective
intelligent
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
CN201811602952.5A
Other languages
Chinese (zh)
Other versions
CN109859038A (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.)
Union Mobile Pay Co Ltd
Original Assignee
Union Mobile Pay 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 Union Mobile Pay Co Ltd filed Critical Union Mobile Pay Co Ltd
Priority to CN201811602952.5A priority Critical patent/CN109859038B/en
Publication of CN109859038A publication Critical patent/CN109859038A/en
Application granted granted Critical
Publication of CN109859038B publication Critical patent/CN109859038B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The embodiment of the invention discloses a method and a device for taking a block chain intelligent contract into effect. Wherein the method comprises the following steps: receiving an intelligent contract calling request; acquiring a contract address of the intelligent contract of the latest version according to the intelligent contract calling request, and acquiring the effective state of the corresponding intelligent contract of the latest version according to the contract address of the intelligent contract of the latest version; the effective state of the intelligent contract of the latest version is obtained in advance and corresponds to the contract address of the intelligent contract of the latest version; if the effective state is judged to be effective, the intelligent contract of the latest version is determined to be effective; and acquiring and executing the intelligent contract of the latest version. The device is used for executing the method. The method and the device for taking the intelligent contract of the block chain into effect provided by the embodiment of the invention ensure the accuracy of respectively executing the intelligent contract of the latest version at different block chain nodes.

Description

Method and device for taking block chain intelligent contract into effect
Technical Field
The embodiment of the invention relates to the technical field of block chains, in particular to a method and a device for taking a block chain intelligent contract into effect.
Background
The blockchain technique is a distributed infrastructure and computing paradigm that utilizes blockchain data structures to verify and store data, utilizes distributed node consensus algorithms to generate and update data and maintain consistency among nodes, cryptographically secures data transmission and access, and utilizes intelligent contracts composed of automated script code to program and manipulate data. The intelligent contract is made by a plurality of users in the block chain, and can be used for any transaction behavior among the users. The intelligent contract based on the block chain technology not only can exert the advantages of the intelligent contract in the aspect of cost efficiency, but also can avoid the interference of malicious behaviors on the normal execution of the contract.
The smart contract is written into the block chain in a digital form, and the characteristics of the block chain technology ensure that the whole processes of storage, reading and execution are transparent, traceable and not easy to modify. Meanwhile, a set of state machine system is constructed by the block chain self-contained consensus algorithm, so that the intelligent contract can run efficiently. Once the intelligent contract is deployed, the intelligent contract cannot be modified, and in some cases, the deployed intelligent contract needs to be modified, for example, when a bug of the intelligent contract or a business logic change is found, a new version of the intelligent contract needs to be deployed to upgrade the original intelligent contract. In the prior art, a new version of intelligent contracts can be deployed at all required nodes, the new version of intelligent contracts take effect immediately after deployment is completed, synchronization of the new version of intelligent contracts taking effect at each node after deployment is completed cannot be guaranteed, some nodes execute the updated intelligent contracts, and some nodes execute the intelligent contracts before updating, so that data confusion is caused.
Therefore, how to provide an effective method for a block chain intelligent contract to ensure the accuracy of executing the intelligent contract becomes an important issue to be solved urgently in the industry.
Disclosure of Invention
Aiming at the defects in the prior art, the embodiment of the invention provides a method and a device for taking a block chain intelligent contract into effect.
In one aspect, an embodiment of the present invention provides a method for validating a block chain intelligent contract, including:
receiving an intelligent contract calling request;
acquiring a contract address of the intelligent contract of the latest version according to the intelligent contract calling request, and acquiring the effective state of the corresponding intelligent contract of the latest version according to the contract address of the intelligent contract of the latest version; the effective state of the intelligent contract of the latest version is obtained in advance and corresponds to the contract address of the intelligent contract of the latest version;
if the effective state is judged to be effective, the intelligent contract of the latest version is determined to be effective;
and acquiring and executing the intelligent contract of the latest version.
On the other hand, an embodiment of the present invention provides an apparatus for validating a block chain intelligent contract, including:
the receiving module is used for receiving an intelligent contract calling request;
the first obtaining module is used for obtaining the contract address of the intelligent contract of the latest version according to the intelligent contract calling request and obtaining the effective state of the corresponding intelligent contract of the latest version according to the contract address of the intelligent contract of the latest version; the effective state of the intelligent contract of the latest version is obtained in advance and corresponds to the contract address of the intelligent contract of the latest version;
the first judgment module is used for determining and calling the intelligent contract with the latest version after judging that the effective state is that the contract is effective;
and the first execution module is used for acquiring and executing the intelligent contract with the latest version.
In another aspect, an embodiment of the present invention provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the method for validating a blockchain intelligent contract according to any one of the above embodiments when executing the computer program.
In another aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the method for validating a blockchain intelligent contract according to any one of the above embodiments.
According to the method and the device for taking the intelligent contract into effect, provided by the embodiment of the invention, as the intelligent contract calling request can be received, the contract address of the intelligent contract of the latest version is obtained according to the intelligent contract calling request, and the effective state of the corresponding intelligent contract of the latest version is obtained according to the contract address of the intelligent contract of the latest version, the effective state of the intelligent contract of the latest version is obtained in advance, after the effective state is judged and known to be the contract effective state, the intelligent contract of the latest version is determined to be effective, the intelligent contract of the latest version is obtained and executed, so that the intelligent contract of the latest version in the effective state is executed, and the accuracy of respectively executing the intelligent contract of the latest version at different block chain nodes is ensured.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
Fig. 1 is a schematic flowchart of a method for validating a blockchain intelligent contract according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a method for validating a blockchain intelligent contract according to another embodiment of the present invention;
fig. 3 is a flowchart illustrating a method for validating a blockchain intelligent contract according to yet another embodiment of the present invention;
fig. 4 is a flowchart illustrating a method for validating a blockchain intelligent contract according to another embodiment of the present invention;
fig. 5 is a schematic structural diagram of an apparatus for validating a blockchain intelligent contract according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an apparatus for validating a blockchain intelligent contract according to another embodiment of the present invention;
fig. 7 is a schematic structural diagram of an apparatus for validating a blockchain intelligent contract according to yet another embodiment of the present invention;
fig. 8 is a schematic structural diagram of an apparatus for validating a blockchain intelligent contract according to yet another embodiment of the present invention;
fig. 9 is a schematic physical structure diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. 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 invention.
Fig. 1 is a schematic flow chart of a method for validating a blockchain intelligent contract according to an embodiment of the present invention, and as shown in fig. 1, the method for validating a blockchain intelligent contract according to an embodiment of the present invention includes:
s101, receiving an intelligent contract calling request;
specifically, after the intelligent contracts deployed at each node of the block chain are upgraded to obtain the latest version of the intelligent contract, an effect device (hereinafter referred to as an effect device) of the block chain intelligent contract of each node stores the latest version of the intelligent contract. The client of the node may send an intelligent contract invocation request to the validating device, and the validating device may receive the intelligent contract invocation request. The node is a network node for performing transaction and data exchange in a block chain, and may be implemented by a server.
S102, acquiring a contract address of the intelligent contract of the latest version according to the intelligent contract calling request, and acquiring an effective state of the corresponding intelligent contract of the latest version according to the intelligent contract address of the latest version; the effective state of the intelligent contract of the latest version is obtained in advance and corresponds to the contract address of the intelligent contract of the latest version;
specifically, after receiving the intelligent contract invoking request, the validating device may obtain a contract address of the latest version of the intelligent contract according to the intelligent contract invoking request, and then obtain a validation state of the corresponding latest version of the intelligent contract according to the contract address of the latest version of the intelligent contract. The effective state comprises two states of contract effective and contract non-effective, the contract effective represents that the current node meets the intelligent contract effective condition of the latest version, the latest version of intelligent contract corresponding to the intelligent contract effective condition of the latest version can be executed, and the contract non-effective represents that the current node does not meet the intelligent contract effective condition of the latest version and can not execute the intelligent contract of the latest version corresponding to the intelligent contract effective condition of the latest version. The current node is the node where the server receiving the intelligent contract calling request is located; the effective state of the latest intelligent contract is obtained in advance, and the effective state of the latest intelligent contract corresponds to the contract address of the latest intelligent contract.
For example, the intelligent contract invoking request includes the contract address of the latest version of the intelligent contract, and the validating device receives the intelligent contract invoking request, i.e., the contract address of the latest version of the intelligent contract is obtained from the received intelligent contract invoking request. Or the intelligent contract invoking request comprises a routing contract address and an address identifier of an intelligent contract, the routing contract address corresponds to an address mapping table of the intelligent contract, and the address mapping table of the intelligent contract comprises the address identifier of at least one intelligent contract and the contract address of the intelligent contract of the latest version corresponding to the address identifier of the intelligent contract in a one-to-one manner. The validating means may obtain the address mapping table of the intelligent contract corresponding to the routing contract address according to the routing contract address query, and then obtain the contract address of the latest version of the intelligent contract corresponding to the address identifier of the intelligent contract according to the address identifier query of the intelligent contract. Wherein the address mapping table of the intelligent contract is preset.
S103, if the effective state is judged to be effective, determining that the intelligent contract of the latest version is effective;
specifically, the validation means determines whether the validation state is that the contract is validated or that the contract is not validated after obtaining the validation state of the latest version of the smart contract, and if the validation state is that the contract is validated, determines that the latest version of the smart contract is validated, and may execute the latest version of the smart contract.
For example, the contract effectiveness 1 represents that the contract does not have effectiveness 0 represents that the effectiveness state obtained by the effectiveness device is 1, which indicates that the contract is effective, and the latest version of the intelligent contract can be executed. The effective state obtained by the effective device is 0, which indicates that the contract is not effective, and the intelligent contract before the upgrade of the intelligent contract of the latest version can be executed.
And S104, acquiring and executing the intelligent contract with the latest version.
Specifically, after determining that the latest version of the intelligent contract takes effect, the effect taking-in device obtains the latest version of the intelligent contract according to the contract address of the latest version of the intelligent contract and executes the latest version of the intelligent contract.
For example, the blockchain a includes N nodes where intelligent contracts a1 are deployed, and since the business logic of the intelligent contracts a1 needs to be changed, the intelligent contracts a1 are upgraded, the latest version of the intelligent contracts a2 is deployed at the N nodes, and meanwhile, the latest version of the intelligent contracts validation condition b corresponding to the latest version of the intelligent contracts a2 is deployed: when the block height of the current node is greater than 50, the latest version of intelligent contract a2 is in effect. And the latest version of intelligent contract validation condition b is corresponded to the contract address of the latest version of intelligent contract a 2. The validation device of each node in the N nodes detects the block height of the node regularly, and determines whether the node meets the smart contract validation condition b of the latest version according to the block height of the node and the smart contract validation condition b of the latest version, if the block height of the node is greater than 50, the node meets the smart contract validation condition b, the validation state of the smart contract a2 of the latest version is the contract validation, if the block height of the node is less than or equal to 50, the node does not meet the condition validation condition b, and the validation state of the smart contract a2 of the latest version is the contract non-validation. The validating means may store the validation state of the latest version of intelligent contract a2 in correspondence with the contract address of the latest version of intelligent contract a 2. The period is set according to actual conditions, and the embodiment of the present invention is not limited.
The client of the node N3 in the N nodes sends an intelligent contract calling request to the validation device of the node N3, wherein the intelligent contract calling request comprises the contract address of the intelligent contract a2 of the latest version; after receiving the latest version of intelligent contract invoking request, the validation device of the node n3 obtains the contract address of the latest version of intelligent contract a2 from the intelligent contract invoking request, and then obtains the validation state of the latest version of intelligent contract a2 according to the contract address query of the latest version of intelligent contract a 2. If the validation means of the node n3 determines that the validation state of the latest version of the intelligent contract a2 is that the contract is validated, then the intelligent contract a2 is determined to be validated; the validating means can obtain the latest intelligent contract a2 according to the contract address query of the latest intelligent contract a2 and execute the latest intelligent contract a 2. If the validation means of the node n3 determines that the validation state of the latest version of the intelligent contract a2 is that the contract is not validated, it is determined that the latest version of the intelligent contract a2 is not validated, and the intelligent contract a1 can be acquired and executed.
According to the method for taking the intelligent contract in the block chain provided by the embodiment of the invention, the intelligent contract calling request can be received, the contract address of the intelligent contract of the latest version is obtained according to the intelligent contract calling request, and the effective state of the corresponding intelligent contract of the latest version is obtained according to the contract address of the intelligent contract of the latest version, the effective state of the intelligent contract of the latest version is obtained in advance, after the effective state is judged and known to be effective, the intelligent contract of the latest version is determined to be effective, the intelligent contract of the latest version is obtained and executed, so that the intelligent contract of the latest version in the effective state is executed, and the accuracy of the intelligent contract of the latest version executed at different block chain nodes is ensured. In addition, the effective state of the intelligent contract of the latest version is obtained in advance, so that the processing efficiency of the intelligent contract calling request can be improved.
Fig. 2 is a flowchart of a method for validating a blockchain intelligent contract according to another embodiment of the present invention, as shown in fig. 2, based on the foregoing embodiments, further, the method for validating a blockchain intelligent contract according to an embodiment of the present invention further includes:
s105, if the effective state is judged to be that the contract is not effective, obtaining the effective condition of the intelligent contract of the latest version according to the contract address of the intelligent contract of the latest version; the latest version of intelligent contract validation condition is preset and corresponds to the contract address of the latest version of intelligent contract;
specifically, the validation means determines whether the validation state is that the contract is validated or that the contract is not validated after obtaining the validation state of the latest version of the intelligent contract, and if the validation state is that the contract is not validated, obtains the latest version of the intelligent contract validation condition according to the contract address of the latest version of the intelligent contract. The latest version of intelligent contract validation condition is preset and corresponds to the contract address of the latest version of intelligent contract; the effective condition of the intelligent contract of the latest version is set according to the actual condition, and the embodiment of the invention is not limited.
For example, the latest version of the intelligent contract is effective under the following conditions: when the block height of a node is greater than 50, the latest version of the smart contract is in effect. Or, the time for deploying the latest version of the intelligent contract is 11/26 th 2018, and the effective conditions of the latest version of the intelligent contract are as follows: the latest version of the intelligent contract became effective around 2018, 12 and 1 month. Or, the latest version of the intelligent contract takes effect under the conditions that: when the number of transactions of the node exceeds 500, the latest version of the intelligent contract takes effect. The validating device may obtain the block height, the time and the transaction number of the current node through a corresponding Application Programming Interface (API).
S106, if judging that the current node meets the intelligent contract effective condition of the latest version, determining that the intelligent contract of the latest version is effective;
specifically, the validating means determines whether the current node meets the smart contract validation condition of the latest version after obtaining the smart contract validation condition of the latest version, and if the current node meets the smart contract validation condition of the latest version, the validating means determines that the smart contract of the latest version is validated and invokes the smart contract of the latest version. And the current node is the node where the server receiving the intelligent contract invoking request is located. It is to be understood that the latest version of the intelligent contract validation condition corresponding to the latest version of the intelligent contract may be deployed at the same time when the latest version of the intelligent contract is deployed.
For example, the latest version of the intelligent contract is effective under the following conditions: when the block height of the current node is greater than 50, the latest version of the intelligent contract takes effect. The validation device obtains that the block height of the current node is 70, compares the block height 70 of the current node with the block height 50 in the smart contract validation condition of the latest version, and can confirm that the smart contract of the latest version corresponding to the smart contract validation condition of the latest version is validated because 70 is greater than 50.
And S107, acquiring and executing the intelligent contract with the latest version.
Specifically, the validating means may acquire the latest version of the smart contract according to the contract address of the latest version of the smart contract and execute the latest version of the smart contract after confirming that the latest version of the smart contract is validated.
Fig. 3 is a flowchart of a method for validating a blockchain intelligent contract according to yet another embodiment of the present invention, as shown in fig. 3, based on the foregoing embodiments, further, the method for validating a blockchain intelligent contract according to an embodiment of the present invention further includes:
s108, if the current node is judged to be not satisfied with the intelligent contract effective condition of the latest version, confirming the intelligent contract before the intelligent contract of the latest version is called;
specifically, the validating means determines whether the current node meets the intelligent contract validation condition of the latest version after obtaining the intelligent contract validation condition of the latest version, and if the current node does not meet the intelligent contract validation condition of the latest version, the validating means confirms the intelligent contract before the intelligent contract of the latest version is called for upgrading.
For example, the latest version of the intelligent contract is effective under the following conditions: when the block height of the current node is larger than 50, the intelligent contract is effective. The validating device obtains that the block height of the current node is 45, compares the block height 45 of the current node with the block height 50 in the validation condition of the intelligent contract of the latest version, and confirms that the intelligent contract before the upgrade of the intelligent contract of the latest version is called because the block height 45 of the current node is less than 50 and the current node does not meet the validation condition of the intelligent contract of the latest version.
And S109, acquiring and executing the intelligent contract before upgrading.
Specifically, after confirming that the intelligent contract before the latest version of the intelligent contract is called, the validating device may obtain the intelligent contract before upgrading according to the contract address of the intelligent contract before upgrading, and execute the intelligent contract before upgrading. The contract address of the intelligent contract before upgrading can be obtained through the contract address of the intelligent contract of the latest version when the current node does not meet the effectiveness condition of the intelligent contract of the latest version.
Fig. 4 is a flowchart of a method for validating a blockchain intelligent contract according to yet another embodiment of the present invention, as shown in fig. 4, on the basis of the foregoing embodiments, further, the step of obtaining the validation state of the latest version of the intelligent contract is as follows:
s401, periodically detecting and obtaining state parameters of nodes, wherein the state parameters are preset;
in particular, the validating means may detect the status parameters of the acquiring node periodically, for example once every second, the status parameters being preset, for example, the block height, time and transaction number of the current node. The validating device may obtain the state parameter of the current node through a corresponding API. The period is set according to actual needs, and the embodiment of the invention is not limited. It is understood that the validating means detects the status parameters of the node to which the validating means belongs, and in the embodiment of the present invention, the node includes the validating means.
S402, judging whether the node meets the intelligent contract effective condition of the latest version corresponding to the state parameter according to the state parameter of the node and the intelligent contract effective condition of the latest version corresponding to the state parameter; the latest version of the intelligent contract takes effect conditions are preset and correspond to the latest version of the intelligent contract;
specifically, after obtaining the state parameter of the node, the validating device may determine whether the node satisfies the smart contract validation condition of the latest version corresponding to the state parameter according to the state parameter of the node and the smart contract validation condition of the latest version corresponding to the state parameter. The latest version of intelligent contract validation condition is preset and corresponds to the latest version of intelligent contract, that is, each of the latest version of intelligent contract corresponds to one of the latest version of intelligent contract validation condition. It is understood that there may be a plurality of the latest version of the intelligent contract validation conditions corresponding to the state parameters.
For example, the state parameters include the block height, time, and transaction count of the node. The intelligent contract effective condition of the latest version corresponding to the block height of the node is as follows: the latest version of the smart contract is in effect when the block height of the node is greater than the first threshold. If the block height of the node is greater than the first threshold, the node meets the latest version of the intelligent contract validation condition corresponding to the block height of the node; otherwise, the node does not satisfy the intelligent contract validation condition of the latest version corresponding to the block height of the node. The intelligent contract effective condition of the latest version corresponding to the time of the node is as follows: the latest version of the intelligent contract takes effect at some date in a month of a year. If the time of the node is after (including) a certain day of a certain month of a certain year, satisfying the latest version of the intelligent contract validation condition corresponding to the time of the node for the node; otherwise, the node does not meet the intelligent contract validation condition of the latest version corresponding to the time of the node. The intelligent contract effective condition of the latest version corresponding to the transaction stroke number of the node is as follows: and when the transaction number of the node exceeds a second threshold value, the intelligent contract of the latest version takes effect. If the number of transaction strokes of the node is larger than a second threshold value, the node meets the intelligent contract validation condition of the latest version corresponding to the number of transaction strokes of the node; otherwise, the node does not meet the intelligent contract validation condition of the latest version corresponding to the transaction stroke number of the node. The first threshold and the second threshold are set according to actual conditions, and the embodiment of the present invention is not limited.
And S403, obtaining the effective state of the intelligent contract of the latest version corresponding to the contract address of the intelligent contract of the latest version according to the judgment result of whether the node meets the effective condition of the intelligent contract of the latest version corresponding to the state parameter.
Specifically, for each of the latest version of smart contract validation conditions corresponding to the state parameter, the validation means may obtain a determination result that the node satisfies the latest version of smart contract validation conditions corresponding to the state parameter or that the node does not satisfy the latest version of smart contract validation conditions corresponding to the state parameter. If the judgment result is that the node meets the intelligent contract effective condition of the latest version corresponding to the state parameter, the effective state of the intelligent contract of the latest version corresponding to the intelligent contract effective condition of the latest version is that the contract is effective; and if the judgment result is that the node does not meet the intelligent contract validation condition of the latest version corresponding to the state parameter, the validation state of the intelligent contract of the latest version corresponding to the intelligent contract validation condition of the latest version is that the contract is not validated. Because the latest version of the intelligent contract corresponds to the contract address of the latest version of the intelligent contract in a one-to-one manner, in order to facilitate searching for the effective state of the latest version of the intelligent contract, the contract address of the latest version of the intelligent contract may correspond to the effective state of the latest version of the intelligent contract, so that the effective state of the latest version of the intelligent contract corresponding to the contract address of the latest version of the intelligent contract is obtained.
According to the method for taking the intelligent contract in the block chain provided by the embodiment of the invention, the intelligent contract calling request can be received, the contract address of the intelligent contract of the latest version is obtained according to the intelligent contract calling request, and the effective state of the corresponding intelligent contract of the latest version is obtained according to the contract address of the intelligent contract of the latest version, the effective state of the intelligent contract of the latest version is obtained in advance, after the effective state is judged and known to be effective, the intelligent contract of the latest version is determined to be effective, the intelligent contract of the latest version is obtained and executed, so that the intelligent contract of the latest version in the effective state is executed, and the accuracy of the intelligent contract of the latest version executed at different block chain nodes is ensured. Further, the effective state of the intelligent contract of the latest version of the node is obtained through the effective condition of the intelligent contract of the latest version, and the synchronism of the intelligent contract execution of the latest version of each node is ensured.
Fig. 5 is a schematic structural diagram of a device for validating a blockchain intelligent contract according to an embodiment of the present invention, as shown in fig. 5, the device for validating a blockchain intelligent contract according to an embodiment of the present invention includes a receiving module 501, a first obtaining module 502, a first determining module 503, and a first executing module 504, where:
the receiving module 501 is configured to receive an intelligent contract invoking request; the first obtaining module 502 is configured to obtain a contract address of the latest version of the intelligent contract according to the intelligent contract invoking request, and obtain an effective state of the corresponding latest version of the intelligent contract according to the contract address of the latest version of the intelligent contract; the effective state of the intelligent contract of the latest version is obtained in advance and corresponds to the contract address of the intelligent contract of the latest version; the first judging module 503 is configured to determine to invoke the latest version of the intelligent contract after judging that the effective state is the contract effective state; the first execution module 504 is configured to obtain the latest version of the smart contract and execute the smart contract.
Specifically, after the intelligent contracts deployed at each node of the block chain are upgraded to obtain the intelligent contract of the latest version, the client of the node may send an intelligent contract invoking request to the receiving module 501, and the receiving module 501 receives the intelligent contract invoking request. The node is a network node for performing transaction and data exchange in a block chain, and may be implemented by a server.
After receiving the intelligent contract invoking request, the first obtaining module 502 may obtain the contract address of the latest version of the intelligent contract according to the intelligent contract invoking request, and then obtain the effective state of the corresponding latest version of the intelligent contract according to the contract address of the latest version of the intelligent contract. The effective state comprises two states of contract effective and contract non-effective, the contract effective represents that the current node meets the intelligent contract effective condition of the latest version, the latest version of intelligent contract corresponding to the intelligent contract effective condition of the latest version can be executed, and the contract non-effective represents that the current node does not meet the intelligent contract effective condition of the latest version and can not execute the intelligent contract of the latest version corresponding to the intelligent contract effective condition of the latest version. The current node is the node where the server receiving the intelligent contract calling request is located; the effective state of the latest intelligent contract is obtained in advance, and the effective state of the latest intelligent contract corresponds to the contract address of the latest intelligent contract.
After obtaining the effective state of the latest version of the smart contract, the first determination module 503 determines whether the effective state is that the contract is effective or that the contract is not effective, and if the effective state is that the contract is effective, then determines that the latest version of the smart contract is effective, and the latest version of the smart contract may be executed.
After determining that the latest intelligent contract is effective, the first execution module 504 obtains the latest intelligent contract according to the contract address of the latest intelligent contract and executes the latest intelligent contract.
According to the device for taking effect of the intelligent contract with the block chain, which is provided by the embodiment of the invention, because the intelligent contract calling request can be received, the contract address of the intelligent contract with the latest version is obtained according to the intelligent contract calling request, and the effective state of the corresponding intelligent contract with the latest version is obtained according to the contract address of the intelligent contract with the latest version, the effective state of the intelligent contract with the latest version is obtained in advance, after the effective state is judged and known to be effective, the intelligent contract with the latest version is determined to be effective, the intelligent contract with the latest version is obtained and executed, so that the intelligent contract with the latest version in the effective state is executed, and the accuracy of respectively executing the intelligent contract with the latest version at different block chain nodes is ensured. In addition, the effective state of the intelligent contract of the latest version is obtained in advance, so that the processing efficiency of the intelligent contract calling request can be improved.
Fig. 6 is a schematic structural diagram of a validation apparatus for a blockchain intelligent contract according to another embodiment of the present invention, as shown in fig. 6, on the basis of the foregoing embodiments, further, the validation apparatus for a blockchain intelligent contract according to an embodiment of the present invention further includes a second determining module 505, a third determining module 506, and a second executing module 507, where:
the second judging module 505 is configured to, after judging that the effective state is that the contract is not effective, obtain an effective condition of the latest version of the intelligent contract according to the contract address of the latest version of the intelligent contract; the third judging module 506 is configured to determine to invoke the intelligent contract of the latest version after judging that the current node meets the effective condition of the intelligent contract of the latest version; the second executing module 507 is configured to obtain the latest version of the smart contract and execute the smart contract.
Specifically, after obtaining the effective state of the latest version of the intelligent contract, the second determination module 505 determines whether the effective state is that the contract is effective or that the contract is not effective, and if the effective state is that the contract is not effective, obtains the latest version of the intelligent contract effective condition according to the contract address of the latest version of the intelligent contract. The latest version of intelligent contract validation condition is preset and corresponds to the contract address of the latest version of intelligent contract; the effective condition of the intelligent contract of the latest version is set according to the actual condition, and the embodiment of the invention is not limited.
After obtaining the intelligent contract validation condition of the latest version, the third determining module 506 determines whether the current node meets the intelligent contract validation condition of the latest version, and if the current node meets the intelligent contract validation condition of the latest version, the validation means determines that the intelligent contract of the latest version is validated and invokes the intelligent contract of the latest version. And the current node is the node where the server receiving the intelligent contract invoking request is located. It is to be understood that the latest version of the intelligent contract validation condition corresponding to the latest version of the intelligent contract may be deployed at the same time when the latest version of the intelligent contract is deployed.
After confirming that the latest version of the intelligent contract takes effect, the second execution module 507 may obtain the latest version of the intelligent contract according to the contract address of the latest version of the intelligent contract and execute the latest version of the intelligent contract.
Fig. 7 is a schematic structural diagram of a validation apparatus for a blockchain intelligent contract according to yet another embodiment of the present invention, as shown in fig. 7, on the basis of the foregoing embodiments, further, the validation apparatus for a blockchain intelligent contract according to an embodiment of the present invention further includes a fourth determining module 508 and a third executing module 509, where:
the fourth determining module 508 is configured to determine, after it is determined that the current node does not meet the effective condition of the intelligent contract of the latest version, to invoke the intelligent contract of the latest version before upgrading; the third executing module 509 is configured to obtain the smart contract before the upgrade and execute the smart contract.
Specifically, after obtaining the intelligent contract validation condition of the latest version, the fourth determining module 508 determines whether the current node satisfies the intelligent contract validation condition of the latest version, and if the current node does not satisfy the intelligent contract validation condition of the latest version, the fourth determining module 508 determines to invoke the intelligent contract before the intelligent contract of the latest version is upgraded.
After confirming that the intelligent contract before the latest version of the intelligent contract is called, the third executing module 509 may obtain the intelligent contract before the upgrade according to the contract address of the intelligent contract before the upgrade, and execute the intelligent contract before the upgrade. The contract address of the intelligent contract before upgrading can be obtained through the contract address of the intelligent contract of the latest version when the current node does not meet the effectiveness condition of the intelligent contract of the latest version.
Fig. 8 is a schematic structural diagram of an apparatus for validating a blockchain intelligent contract according to yet another embodiment of the present invention, as shown in fig. 8, on the basis of the foregoing embodiments, further, the apparatus for validating a blockchain intelligent contract according to an embodiment of the present invention further includes a detection module 510, a fifth determination module 511, and a second obtaining module 512, where:
the detecting module 510 is configured to periodically detect a state parameter of a current node, where the state parameter is preset; the fifth judging module 511 is configured to judge whether the node meets the intelligent contract validation condition of the latest version corresponding to the state parameter according to the state parameter of the node and the intelligent contract validation condition of the latest version corresponding to the state parameter; the latest version of the intelligent contract takes effect conditions are preset and correspond to the latest version of the intelligent contract; the second obtaining module 512 is configured to obtain an effective state of the latest version of the intelligent contract corresponding to the contract address of the latest version of the intelligent contract according to a determination result of whether the node meets the effective condition of the latest version of the intelligent contract corresponding to the state parameter.
Specifically, the detecting module 510 may detect the state parameters of the obtained node periodically, for example, once per second, where the state parameters are preset, for example, the block height, the time and the number of transaction strokes of the current node. The detection module 510 may obtain the state parameter of the current node through a corresponding API. The period is set according to actual needs, and the embodiment of the invention is not limited. It is understood that the detection module 510 detects the state parameter of the node to which the detection module 510 belongs, and the node includes the detection module 510 in the embodiment of the present invention.
After obtaining the state parameter of the node, the fifth determining module 511 may determine whether the node satisfies the smart contract validation condition of the latest version corresponding to the state parameter according to the state parameter of the node and the smart contract validation condition of the latest version corresponding to the state parameter. The latest version of intelligent contract validation condition is preset and corresponds to the latest version of intelligent contract, that is, each of the latest version of intelligent contract corresponds to one of the latest version of intelligent contract validation condition. It is understood that there may be a plurality of the latest version of the intelligent contract validation conditions corresponding to the state parameters.
For each intelligent contract validation condition of the latest version corresponding to the state parameter, the second obtaining module 512 may obtain a determination result that the node satisfies the intelligent contract validation condition of the latest version corresponding to the state parameter or the node does not satisfy the intelligent contract validation condition of the latest version corresponding to the state parameter. If the judgment result is obtained, the node meets the intelligent contract effective condition of the latest version corresponding to the state parameter, the effective state of the intelligent contract of the latest version corresponding to the intelligent contract effective condition of the latest version is that the contract is effective; and if the judgment result is that the node does not meet the intelligent contract validation condition of the latest version corresponding to the state parameter, the validation state of the intelligent contract of the latest version corresponding to the intelligent contract validation condition of the latest version is that the contract is not validated. Because the latest version of the intelligent contract corresponds to the contract address of the latest version of the intelligent contract in a one-to-one manner, in order to facilitate searching for the effective state of the latest version of the intelligent contract, the contract address of the latest version of the intelligent contract may correspond to the effective state of the latest version of the intelligent contract, so that the effective state of the latest version of the intelligent contract corresponding to the contract address of the latest version of the intelligent contract is obtained.
The embodiment of the apparatus provided in the embodiment of the present invention may be specifically configured to execute the processing flow of the corresponding method embodiment, and the functions of the apparatus are not described herein again, and refer to the detailed description of the corresponding method embodiment.
Fig. 9 is a schematic physical structure diagram of an electronic device according to an embodiment of the present invention, and as shown in fig. 9, the electronic device may include: a processor (processor)910, a communication Interface (Communications Interface)920, a memory (memory)930, and a communication bus 940, wherein the processor 910, the communication Interface 920, and the memory 930 communicate with each other via the communication bus 940. Processor 910 may invoke logic instructions in memory 930 to perform the following method: receiving an intelligent contract calling request; acquiring a contract address of the intelligent contract of the latest version according to the intelligent contract calling request, and acquiring the effective state of the corresponding intelligent contract of the latest version according to the contract address of the intelligent contract of the latest version; the effective state of the intelligent contract of the latest version is obtained in advance and corresponds to the contract address of the intelligent contract of the latest version; if the effective state is judged to be effective, the intelligent contract of the latest version is determined to be effective; and acquiring and executing the intelligent contract of the latest version.
The present embodiments provide a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, enable the computer to perform the methods provided by the above-described method embodiments, for example, comprising: receiving an intelligent contract calling request; acquiring a contract address of the intelligent contract of the latest version according to the intelligent contract calling request, and acquiring the effective state of the corresponding intelligent contract of the latest version according to the contract address of the intelligent contract of the latest version; the effective state of the intelligent contract of the latest version is obtained in advance and corresponds to the contract address of the intelligent contract of the latest version; if the effective state is judged to be effective, the intelligent contract of the latest version is determined to be effective; and acquiring and executing the intelligent contract of the latest version.
The present embodiments provide a non-transitory computer-readable storage medium storing a computer program that causes a computer to perform the methods provided by the above-described method embodiments, for example, including: receiving an intelligent contract calling request; acquiring a contract address of the intelligent contract of the latest version according to the intelligent contract calling request, and acquiring the effective state of the corresponding intelligent contract of the latest version according to the contract address of the intelligent contract of the latest version; the effective state of the intelligent contract of the latest version is obtained in advance and corresponds to the contract address of the intelligent contract of the latest version; if the effective state is judged to be effective, the intelligent contract of the latest version is determined to be effective; and acquiring and executing the intelligent contract of the latest version.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (8)

1. A method for validating a blockchain intelligent contract, comprising:
receiving an intelligent contract calling request;
acquiring a contract address of the intelligent contract of the latest version according to the intelligent contract calling request, and acquiring the effective state of the corresponding intelligent contract of the latest version according to the contract address of the intelligent contract of the latest version; the effective state of the intelligent contract of the latest version is obtained in advance and corresponds to the contract address of the intelligent contract of the latest version;
if the effective state is judged to be effective, the intelligent contract of the latest version is determined to be effective;
acquiring and executing the intelligent contract of the latest version;
the method for acquiring the effective state of the intelligent contract of the latest version comprises the following steps:
periodically detecting and obtaining state parameters of the nodes, wherein the state parameters are preset;
judging whether the node meets the intelligent contract effective condition of the latest version corresponding to the state parameter or not according to the state parameter of the node and the intelligent contract effective condition of the latest version corresponding to the state parameter; the latest version of the intelligent contract takes effect conditions are preset and correspond to the latest version of the intelligent contract;
and obtaining the effective state of the intelligent contract of the latest version corresponding to the contract address of the intelligent contract of the latest version according to the judgment result of whether the node meets the effective condition of the intelligent contract of the latest version corresponding to the state parameter.
2. The method of claim 1, further comprising:
if the effective state is judged to be that the contract is not effective, acquiring the effective condition of the intelligent contract of the latest version according to the contract address of the intelligent contract of the latest version; the latest version of intelligent contract validation condition is preset and corresponds to the contract address of the latest version of intelligent contract;
if the current node is judged to meet the intelligent contract effective condition of the latest version, the intelligent contract of the latest version is determined to be effective;
and acquiring and executing the intelligent contract of the latest version.
3. The method of claim 2, further comprising:
if the current node is judged to be not satisfied with the intelligent contract effective condition of the latest version, confirming the intelligent contract before the intelligent contract of the latest version is called;
and acquiring and executing the intelligent contract before upgrading.
4. An apparatus for validating a blockchain intelligent contract, comprising:
the receiving module is used for receiving an intelligent contract calling request;
the first obtaining module is used for obtaining the contract address of the intelligent contract of the latest version according to the intelligent contract calling request and obtaining the effective state of the corresponding intelligent contract of the latest version according to the contract address of the intelligent contract of the latest version; the effective state of the intelligent contract of the latest version is obtained in advance and corresponds to the contract address of the intelligent contract of the latest version;
the first judgment module is used for determining and calling the intelligent contract with the latest version after judging that the effective state is that the contract is effective;
the first execution module is used for acquiring and executing the intelligent contract with the latest version;
the detection module is used for periodically detecting the state parameters of the current node, and the state parameters are preset;
a fifth judging module, configured to judge, according to the state parameter of the node and an intelligent contract validation condition of the latest version corresponding to the state parameter, whether the node meets the intelligent contract validation condition of the latest version corresponding to the state parameter; the latest version of the intelligent contract takes effect conditions are preset and correspond to the latest version of the intelligent contract;
and the second obtaining module is used for obtaining the effective state of the intelligent contract of the latest version corresponding to the contract address of the intelligent contract of the latest version according to the judgment result of whether the node meets the effective condition of the intelligent contract of the latest version corresponding to the state parameter.
5. The apparatus of claim 4, further comprising a second determining module, a third determining module, and a second executing module, wherein:
the second judgment module is used for obtaining the intelligent contract effective condition of the latest version according to the contract address of the intelligent contract of the latest version after judging that the effective state is that the contract is not effective;
the third judging module is used for determining and calling the intelligent contract of the latest version after judging and knowing that the current node meets the effective condition of the intelligent contract of the latest version;
and the second execution module is used for acquiring and executing the intelligent contract with the latest version.
6. The apparatus of claim 5, further comprising a fourth determining module and a third executing module, wherein:
the fourth judging module is used for confirming and calling the intelligent contract before the intelligent contract of the latest version is upgraded after judging and knowing that the current node does not meet the effective condition of the intelligent contract of the latest version;
and the third execution module is used for acquiring and executing the intelligent contract before upgrading.
7. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the method for validating a blockchain smart contract of any one of claims 1 to 3 when executing the program.
8. A non-transitory computer readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method for validating a blockchain smart contract according to any one of claims 1 to 3.
CN201811602952.5A 2018-12-26 2018-12-26 Method and device for taking block chain intelligent contract into effect Active CN109859038B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811602952.5A CN109859038B (en) 2018-12-26 2018-12-26 Method and device for taking block chain intelligent contract into effect

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811602952.5A CN109859038B (en) 2018-12-26 2018-12-26 Method and device for taking block chain intelligent contract into effect

Publications (2)

Publication Number Publication Date
CN109859038A CN109859038A (en) 2019-06-07
CN109859038B true CN109859038B (en) 2021-06-25

Family

ID=66892534

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811602952.5A Active CN109859038B (en) 2018-12-26 2018-12-26 Method and device for taking block chain intelligent contract into effect

Country Status (1)

Country Link
CN (1) CN109859038B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111932260B (en) * 2020-09-18 2021-01-26 杭州趣链科技有限公司 Intelligent contract version management method, equipment and readable storage medium
WO2022263690A1 (en) * 2021-06-16 2022-12-22 E Process Med, S.L. Smart contract generation method

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017180846A1 (en) * 2016-04-14 2017-10-19 Pricewaterhousecoopers Llp Cryptoconomy solution for administration and governance in a distributed system

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101444272B1 (en) * 2013-02-27 2014-10-22 (주) 아트리아트레이딩 Method, system and non-transitory computer-readable recording medium for supporting securities lending and borrowing transaction by using address book
US20180220278A1 (en) * 2017-02-01 2018-08-02 BriefTrace Ltd. System and method for securing and verifying information from transportation monitors
CN107943580A (en) * 2017-11-13 2018-04-20 上海点融信息科技有限责任公司 For managing the method and equipment of user's intelligence contract at block chain link point
CN108170740B (en) * 2017-12-18 2022-04-26 深圳前海微众银行股份有限公司 Data migration method, system and computer readable storage medium
CN108510389B (en) * 2018-03-30 2020-12-18 深圳前海微众银行股份有限公司 Intelligent contract calling method and device based on block chain and readable storage medium
CN108833398B (en) * 2018-06-08 2020-12-15 深圳智链未来科技有限公司 Block chain intelligent contract updating method, device and equipment

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017180846A1 (en) * 2016-04-14 2017-10-19 Pricewaterhousecoopers Llp Cryptoconomy solution for administration and governance in a distributed system

Also Published As

Publication number Publication date
CN109859038A (en) 2019-06-07

Similar Documents

Publication Publication Date Title
CN109885612B (en) Synchronous validation method and device for intelligent contracts of block chains
CN110677462B (en) Access processing method, system, device and storage medium for multi-block chain network
CN110046029A (en) Data processing method and device applied to multi-level buffer in cluster
CN108416449B (en) Operation and maintenance method and device
CN109753300B (en) Algorithm upgrading method, calculation task sending method and related device
CN110347545A (en) A kind of test method and device of business platform cache policy
CN109859038B (en) Method and device for taking block chain intelligent contract into effect
US11301237B2 (en) Upgrading method and apparatus
CN111694638A (en) Rule package loading method, rule package executing method and terminal equipment
CN103176892A (en) Page monitoring method and system
US20150006736A1 (en) Method and System for Deploying and Modifying a Service-Oriented Architecture Deployment Environment
CN112083971A (en) Component processing method, device and storage medium
CN107463390B (en) Software upgrading method and upgrading server
CN115829297A (en) Method and device for generating work package of assembly type building, terminal and storage medium
CN106603125B (en) Method and device for data interaction with Bluetooth equipment
CN113703946B (en) Application recovery method and device, electronic equipment and computer readable storage medium
CN110737548A (en) Data request method and server
CN108733536B (en) Monitoring management system and method
CN110119429B (en) Data processing method, data processing device, computer equipment and storage medium
CN109933407B (en) Block chain DAPP virtual machine, data processing method and computing equipment
CN109194703B (en) Processing method of communication load between cloud platform hosts, electronic device and medium
CN111105277A (en) Block chain state change transaction tracing method and device
CN115421891A (en) Task distribution method, device, equipment and medium
CN113867778A (en) Method and device for generating mirror image file, electronic equipment and storage medium
CN112860379A (en) Method for installing and deploying high availability of redis on cloud platform

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