CN113760353B - Block chain intelligent contract version control method and block chain system - Google Patents
Block chain intelligent contract version control method and block chain system Download PDFInfo
- Publication number
- CN113760353B CN113760353B CN202110993450.5A CN202110993450A CN113760353B CN 113760353 B CN113760353 B CN 113760353B CN 202110993450 A CN202110993450 A CN 202110993450A CN 113760353 B CN113760353 B CN 113760353B
- Authority
- CN
- China
- Prior art keywords
- version
- contract
- intelligent contract
- transaction
- pointer
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 71
- 238000012795 verification Methods 0.000 claims abstract description 60
- 230000008014 freezing Effects 0.000 claims abstract description 14
- 238000007710 freezing Methods 0.000 claims abstract description 14
- 238000010257 thawing Methods 0.000 claims abstract description 9
- 238000011217 control strategy Methods 0.000 claims description 15
- 230000008859 change Effects 0.000 claims description 3
- 238000010200 validation analysis Methods 0.000 claims description 3
- 230000003247 decreasing effect Effects 0.000 claims description 2
- 238000005538 encapsulation Methods 0.000 claims 1
- 238000005516 engineering process Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000000977 initiatory effect Effects 0.000 description 2
- 230000005012 migration Effects 0.000 description 2
- 238000013508 migration Methods 0.000 description 2
- 235000017166 Bambusa arundinacea Nutrition 0.000 description 1
- 235000017491 Bambusa tulda Nutrition 0.000 description 1
- 241001330002 Bambuseae Species 0.000 description 1
- 235000015334 Phyllostachys viridis Nutrition 0.000 description 1
- 239000011425 bamboo Substances 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008878 coupling Effects 0.000 description 1
- 238000010168 coupling process Methods 0.000 description 1
- 238000005859 coupling reaction Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000008439 repair process Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION 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/00—Payment architectures, schemes or protocols
- G06Q20/38—Payment protocols; Details thereof
- G06Q20/382—Payment protocols; Details thereof insuring higher security of transaction
- G06Q20/3825—Use of electronic signatures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION 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/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45595—Network integration; Enabling network access in virtual machine instances
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Accounting & Taxation (AREA)
- Computer Security & Cryptography (AREA)
- Finance (AREA)
- Databases & Information Systems (AREA)
- Strategic Management (AREA)
- General Business, Economics & Management (AREA)
- Data Mining & Analysis (AREA)
- Computing Systems (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Marketing (AREA)
- Technology Law (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
The invention discloses a block chain intelligent contract version control method and a block chain system. Constructing an intelligent contract version control transaction by using a node, wherein transaction types comprise upgrading contracts, switching contract versions, gray level control, contract freezing, contract thawing and quick rollback, transmitting the intelligent contract version control transaction to a verification node by using the node, and broadcasting the transaction to other verification nodes in a blockchain network after verification by the verification node; the verification nodes receiving the intelligent contract version control transaction write the transaction into the block, mutually identify the block, execute the intelligent contract version control transaction in the block after the identification is passed, and correspondingly operate the contract content corresponding to the target contract address in the transaction according to the transaction type. The method of the invention decouples the intelligent contract address from the intelligent contract code, and the intelligent contract address remains unchanged. The intelligent contract version control method is used for realizing intelligent contract version control on the virtual machine layer, is excellent in performance, perfect in function and has technical innovation.
Description
Technical Field
The invention belongs to the field of computer systems, and particularly relates to a blockchain intelligent contract version control method and a blockchain system.
Background
In recent years, various blockchain-based applications have emerged as spring bamboo shoots after rain due to the characteristics of blockchain that are difficult to tamper with, transparent to transactions, etc. Among them, the related technology of blockchain application to smart contracts is one of the concerns.
When the blockchain is applied to the intelligent contract, the program code of the intelligent contract is actually used as transaction content and sent to the blockchain network, the program code containing the intelligent contract is made into a block through a node in the blockchain network and broadcast to the block, and after the verification of other nodes is passed, the program code is equivalent to the deployment of the intelligent contract on the blockchain.
For example, in the protocol version issued by the ethernet, as long as the transaction does not set the receiver address, the blockchain network regards the transaction as issuing an intelligent contract transaction, and generates a corresponding contract address after verification, wherein the contract address is the reference address of the intelligent contract, and the application program of the node can obtain the intelligent contract entity through the contract address and execute the intelligent contract.
However, because of the non-tamperable nature of blockchain data, the smart contracts that have been issued to the blockchain cannot be altered, which makes it difficult to upgrade and maintain blockchain-based smart contracts if there are problems with the contract logic. Since the contract address is updated once the repair or newly added function smart contract is reissued, the contract data is reset and the application program using the node is updated accordingly to the latest smart contract address.
Publication date 2019.07.05, chinese patent application publication number CN 109978477A, discloses a block chain-based intelligent contract version control system and a method thereof, wherein intelligent contracts of different versions are registered with corresponding contract addresses and version numbers through a control module of a version control node, namely intelligent contract version control is indirectly realized through control contracts. Compared with the invention, the invention has the following differences and advantages: the invention adopts the version control node without dependence, carries out version control through the block chain verification node, has no external dependence and belongs to internal functions. Version control is performed through the intelligent contract virtual machine, the intelligent contract virtual machine belongs to the block chain native capability, has good compatibility and excellent performance, returns version information and method signature by combining a version control strategy contract, allows a predefined variable value to be returned, is flexible to control and convenient to manage, and has low maintenance cost on the version control contract which is required to be input for contract upgrading.
Publication date 2020.11.13, chinese patent application publication number CN 111932260A, discloses a method, a device and a readable storage medium for managing intelligent contract versions, and realizes management of multiple contract code versions and gray test support of contract codes by one contract address by storing contract state data, a contract code table and a condition rule table in a storage space corresponding to one contract address. Compared with the invention, the invention has the following differences and advantages: the invention uses the version control strategy contract to support the gray control support of the contract code, compared with a condition rule table, the version control strategy contract deployment and upgrading are more flexible, the control strategy is matched with the logic depth of the corresponding intelligent contract, and the coupling degree with the verification node is low; the method for binding the contract code by combining the current effective version pointer supports contract version control by using contract version switching transaction, and compared with a contract code table, the method has the advantages that the contract version parameter is not required to be transmitted when the contract is called, and the method is simpler and more convenient to use.
Further, through version management and contract control designed by the method, key advantages of no need of data migration can be achieved, historical data always exists in a specific contract address state, and no need of data migration is needed.
Disclosure of Invention
The invention aims to provide a block chain intelligent contract version control method and a block chain system aiming at the defect of intelligent contract version control capability in the prior block chain technology.
The invention aims at realizing the following technical scheme: a blockchain smart contract version control method, the method comprising:
constructing an intelligent contract version control transaction using nodes, the types of the transaction including: upgrade contracts, switch contract versions, gray scale control, contract freeze, contract defrost, and quick rollback; when the transaction type is an upgrade contract, the transaction comprises a new version intelligent contract; when the transaction type is a switching contract version, the transaction comprises an intelligent contract version label to be switched; when the transaction type is gray level control, a corresponding version control strategy contract needs to be deployed in advance for a target intelligent contract in the transaction, wherein the version control strategy contract is used for controlling a specific strategy of gray level upgrading;
the verification node maintains a currently validated version pointer, a historical version pointer list, a contract status identifier, a version control policy contract pointer and a version counter for each smart contract; the current effective version pointer points to the address of the intelligent contract of the latest effective version; pointers in the history version pointer list point to addresses of old version intelligent contracts respectively; the contract state identification includes normal and frozen states; the version control policy contract pointer points to the version control policy contract of the intelligent contract; the version counter is used for recording the version change times of the intelligent contract;
the method comprises the steps that an intelligent contract version control transaction is sent to a master verification node in a blockchain network by using a node, the master verification node verifies the validity of the transaction, and after verification, the transaction is sequenced, packaged and broadcast to other verification nodes in the blockchain network;
other verification nodes receiving the intelligent contract version control transaction will verify the validity of the transaction again, write the transaction into the block after the verification is passed, mutually identify the block, execute the intelligent contract version control transaction in the block after the identification is passed, and perform corresponding operation on the contract content corresponding to the target contract address in the transaction according to the type of the transaction, specifically:
(1) The contract upgrading operation, the verification node verifies and stores the new version intelligent contract, the current effective version pointer is added to the history version pointer list, the current effective version pointer points to the stored new version intelligent contract, and then the current version counter is increased by one;
(2) Version switching operation, namely searching a historical version pointer list through version tag information in a transaction, adding a current effective version pointer to the historical version pointer list after an intelligent contract to be switched is searched, replacing the current effective version pointer with the searched historical version pointer, deleting the historical version pointer from the historical version pointer list, and not adjusting a version counter;
(3) Contract freezing operation, adding a current effective version pointer to a history version pointer list, pointing the current effective version pointer to a null value, setting a contract state identifier to be a freezing state, and enabling a user to be unable to call after freezing the intelligent contract;
(4) Contract thawing operation, in which the current effective version pointer is replaced by the latest added historical version pointer in the historical version pointer list, the historical version pointer is deleted from the historical version pointer list, and after the intelligent contract is thawed, the user can normally call;
(5) A quick rollback operation, namely acquiring a latest added historical version pointer from a historical version pointer list, deleting the historical version pointer from the historical version pointer list, replacing a current effective version pointer with the acquired latest historical version pointer, and subtracting one version counter;
(6) And gray control operation, wherein policy selection is performed according to the version control policy contract pointed by the version control policy contract pointer, and the specific version intelligent contract pointed by the contract return result in the current effective version pointer or the history version pointer list is executed according to the return result.
Further, after the intelligent contract is successfully deployed by the using node, the intelligent contract address is not changed any more, and the intelligent contract is subjected to version control based on the single intelligent contract address.
Further, the version control transaction is identical to the common transaction, needs to be authenticated and then agreed through consensus, executes out the block through the virtual machine, and spends corresponding deployment resources.
Further, the verification node executes intelligent contract version control operation at the intelligent contract virtual machine layer, finds the currently effective version pointer of the contract according to the intelligent contract address, finds the intelligent contract code according to the pointer, and performs calling or version control operation.
Further, the history version pointer contains intelligent contract version label information, a corresponding history version pointer can be found according to the intelligent contract version label information, the version label is generated by a version counter when intelligent contract upgrading operation is executed, the version counter is only increased by one when contract upgrading operation is executed, is decreased by one when quick rollback operation is executed, and other operation version counters are not changed.
Further, in the gray control operation, a corresponding version control policy contract must be deployed for the target intelligent contract first, and after the deployment of the verification node, the version control policy contract pointer of the target intelligent contract is pointed to the version control policy contract.
Further, the gray control operation selects the latest version or the appointed version of the intelligent contract to execute according to the intelligent contract address in the transaction, and the selection result is determined by the version control strategy contract corresponding to the intelligent contract.
Further, the contract method signature and the contract method parameters of the version control strategy contract are consistent with the associated intelligent contract, and if the contract method parameters of the two versions are inconsistent, the contract method needs to be further encapsulated and routed.
Further, the control policy of the version control policy contract requires returning true or false and version number, returning true to indicate that the policy passes, and executing the intelligent contract of the latest version; returning false indicates that the strategy is not passed, if the return version number is null or zero, executing the intelligent contract of the next new version, otherwise executing the version number appointed version contract; the control strategy content depth is related to a specific intelligent contract, can be customized by using contract method parameter depth according to the service type represented by the intelligent contract, and can also be judged directly according to the parity of calling time or according to the last parity of an address field when a node is used for calling.
The invention also provides a blockchain system, which comprises a using node and a verification node, wherein the using node and the verification node are used for executing the steps in the blockchain intelligent contract version control method.
The beneficial effects of the invention are as follows: the block chain intelligent contract version control method provided by the invention has the advantages that the special transaction type is constructed, the contract is upgraded like the common transaction, the verification node is used for identifying the block, a new contract address is not generated, and the original state data is reserved. The method of the invention can enable the intelligent contract to be upgraded more conveniently, can not be forced to update the contract address of the using node because of the intelligent contract upgrade, and can conveniently control and switch the contract version.
Drawings
FIG. 1 is a flow chart of an intelligent contract version upgrade method provided by an embodiment of the invention;
FIG. 2 is a flowchart of a method for switching intelligent contract versions according to an embodiment of the present invention;
FIG. 3 is a flow chart of an intelligent contract freezing method provided by an embodiment of the invention;
FIG. 4 is a flow chart of a method for thawing a smart contract provided by an embodiment of the invention;
FIG. 5 is a flow chart of a smart contract version quick rollback method provided by an embodiment of the present invention;
fig. 6 is a flowchart of an intelligent contract gray scale control method according to an embodiment of the present invention.
Detailed Description
The present invention will now be described in further detail with reference to the drawings and the detailed description, wherein it is to be understood that the detailed description is for the purpose of illustration only and is not intended to limit the invention to the particular embodiments disclosed, but on the contrary, the intention is to cover all embodiments described. Embodiments of the present invention are intended to be within the scope of the present invention as defined by the appended claims.
The invention provides a block chain intelligent contract version control method, which comprises the following steps:
the node is used for constructing and initiating an intelligent contract version control transaction different from a common transaction, and version control is carried out on the intelligent contract on the premise of not modifying the contract address.
The intelligent contract version control transaction can perform operations such as upgrading, version switching, gray level control, contract freezing, thawing, quick rollback and the like on the intelligent contract with the designated intelligent contract address. The version control transaction modifies the contract content to which the contract address points, i.e., points the currently validated version pointer to the smart contract code of the specified version. The transaction itself needs to be authenticated and then agreed through consensus as the common transaction, the block is executed through the virtual machine, and the corresponding deployment resource is spent.
Specifically, when the transaction type is an upgrade contract, the transaction comprises a new version intelligent contract; when the transaction type is a switching contract version, the transaction comprises an intelligent contract version label to be switched; when the transaction type is gray level control, a corresponding version control strategy contract needs to be deployed in advance for a target intelligent contract in the transaction, wherein the version control strategy contract is used for controlling a specific strategy of gray level upgrading.
The verification node maintains a currently validated version pointer, a historical version pointer list, a contract status identifier, a version control policy contract pointer and a version counter for each smart contract; the current effective version pointer points to the address of the intelligent contract of the latest effective version; pointers in the history version pointer list point to addresses of old version intelligent contracts respectively; the contract state identification includes normal and frozen states; the version control policy contract pointer points to the version control policy contract of the intelligent contract; the version counter is used for recording the version change times of the intelligent contract.
The node is used for sending the intelligent contract version control transaction to a master verification node in the blockchain network, the master verification node receives the intelligent contract version control transaction, the validity of the transaction is checked, and after the verification is passed, the transaction is sequenced, packaged and broadcast to other verification nodes in the blockchain network.
And after the verification is passed, all verification nodes execute the intelligent contract version control transaction in the block, and corresponding operation is carried out on contract contents corresponding to the target contract address in the transaction according to the type of the transaction.
And the verification node executes intelligent contract version control operation at the intelligent contract virtual machine layer, finds the currently effective version pointer of the contract according to the intelligent contract address, finds the intelligent contract code according to the pointer, and performs calling or version control operation.
Referring to fig. 1, fig. 1 is a flowchart of a smart contract version upgrade method according to an embodiment of the present invention.
In this embodiment, the steps of the intelligent contract version upgrading method include:
step 111, constructing intelligent contract version upgrading transaction by using a node, wherein the transaction comprises a target intelligent contract address and a new version intelligent contract code, the transaction type is intelligent contract upgrading, and the transaction is signed by using the node and then sent to a verification node;
step 112, the verification node receives the intelligent contract version upgrade transaction, performs validity verification on the transaction, including verification of integrity, verification of signature and the like, packages the transaction into blocks after verification, and broadcasts the blocks to other verification nodes of the blockchain network for consensus;
step 113, after verifying node consensus, executing transaction in the intelligent contract virtual machine;
step 114, verifying and storing the new version intelligent contract, finding out the corresponding current effective version pointer according to the target intelligent contract address in the transaction, adding the current effective version pointer to the history version pointer list, directing the current effective version pointer to the stored new version intelligent contract, and then adding one to the current version counter.
Referring to fig. 2, fig. 2 is a flowchart of a method for switching intelligent contract versions according to an embodiment of the present invention.
In this embodiment, the steps of the intelligent contract version switching method include:
step 121, constructing an intelligent contract version control transaction by using a node, wherein the transaction comprises a target intelligent contract address and intelligent contract switching version label information, the transaction type is contract version switching, and the transaction is signed by using the node and then sent to a verification node;
step 122, the verification node executes the transaction in the intelligent contract virtual machine, searches the current effective version pointer of the contract through the target intelligent contract address and the intelligent contract switching version label information in the transaction, and checks whether the history version pointer conforming to the intelligent contract switching version label information exists or not;
step 123, if present, adding the current effective version pointer to the history version pointer list, replacing the current effective version pointer with the retrieved history version pointer, and deleting the history version pointer from the history version pointer list, without adjusting the version counter.
Referring to fig. 3, fig. 3 is a flowchart of an intelligent contract freezing method according to an embodiment of the present invention.
In this embodiment, the smart contract freezing method includes the steps of:
step 131, constructing an intelligent contract freezing transaction by using a node, transmitting the transaction to a verification node in a blockchain network, wherein the transaction comprises a target intelligent contract address, the transaction type is the intelligent contract freezing transaction, signing the transaction by using the node, and transmitting the transaction to the verification node;
step 132, when the verification node executes the transaction, adding the current effective version pointer to the history version pointer list, pointing the current effective version pointer to a null value, setting the contract state identifier to be a frozen state, and after freezing the intelligent contract, the user cannot call.
Referring to fig. 4, fig. 4 is a flowchart of a smart contract thawing method according to an embodiment of the present invention.
In this embodiment, the steps of the smart contract thawing method include:
step 141, constructing an intelligent contract thawing transaction by using a node, wherein the transaction comprises a target intelligent contract address, the transaction type is the intelligent contract thawing transaction, and the transaction is signed by using the node and then sent to a verification node;
in step 142, when the verification node executes the transaction, the current effective version pointer is replaced by the latest added historical version pointer in the historical version pointer list, the historical version pointer is deleted from the historical version pointer list, and the user can normally call after the intelligent contract is unfrozen.
Referring to fig. 5, fig. 5 is a flowchart of a smart contract version quick rollback method according to an embodiment of the present invention.
In this embodiment, the steps of the intelligent contract version quick rollback method include:
step 151, constructing intelligent contract quick rollback transaction by using a node, wherein the transaction comprises a target intelligent contract address, the transaction type is intelligent contract quick rollback transaction, and the transaction is signed by using the node and then sent to a verification node;
step 152, when the verification node executes the transaction, the latest added historical version pointer is obtained from the historical version pointer list, the historical version pointer is deleted from the historical version pointer list, then the current effective version pointer is replaced by the obtained latest historical version pointer, and the version counter is decremented by one.
Referring to fig. 6, fig. 6 is a flowchart of a smart contract gray scale control method according to an embodiment of the present invention.
In this embodiment, the steps of the smart contract gray scale control method include:
step 161, initiating a deployment version control policy contract using the node, the contract parameters including a target smart contract address for the control policy contract. After the verification node is deployed, the version control policy contract pointer of the target intelligent contract is pointed to the version control policy contract. The contract method signature and the contract method parameters of the version control strategy contract are consistent with the associated intelligent contract, and if the contract method parameters of the two versions are inconsistent, the contract method needs to be further packaged and routed.
And 162, constructing an intelligent contract gray scale control transaction by using the node, wherein the transaction comprises a target intelligent contract address, signing the transaction by using the node, and then sending the transaction to a verification node.
Step 163, the verification node executes the transaction, searches the target smart contract according to the target smart contract address included in the transaction, finds the version control policy contract pointed by the associated version control policy contract pointer, and executes the version control policy contract.
In step 164, the control policy requirements of the control policy contract require a return true or false and version number, the return true indicating that the policy passes, otherwise indicating that the policy does not pass. The specific policy content is deeply related to specific intelligent contracts, can be deeply customized by using contract method parameters according to the service type represented by the intelligent contracts, and can also be judged directly according to the parity of the calling time or according to the last parity of the address field when the node is used for calling.
And step 165, if the policy judgment is satisfied, executing the intelligent contract pointed by the pointer of the current effective version.
And step 166, if the policy judgment is not satisfied, further judging according to the returned version number, if the returned version number is null or zero, executing the intelligent contract pointed by the latest added history version pointer in the history version pointer list, namely the intelligent contract of the next new version, otherwise executing the intelligent contract pointed by the version pointer corresponding to the returned version number.
According to the intelligent contract version control method, the node is used for constructing special intelligent contract version control transaction, the intelligent contract version control is conducted to commonly identify blocks according to normal transaction requests, the intelligent contract virtual machine executes the transaction, contract contents are updated on the premise that contract addresses are not changed, all upgrading records are reserved, the characteristic that block chains cannot be tampered is met, and a new idea is provided for intelligent contract version control.
In one embodiment, a blockchain system is provided that includes a usage node and a validation node for performing the steps of the intelligent contract version control method of the embodiments described above.
In one embodiment, a computer device is provided that includes a memory and a processor, where the memory stores computer readable instructions that, when executed by the processor, cause the processor to perform the steps of the method for controlling a version of a smart contract in each of the embodiments described above.
In one embodiment, a storage medium storing computer readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of the intelligent contract version control method of the embodiments described above is presented. Wherein the storage medium may be a non-volatile storage medium.
Those of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be implemented by a program to instruct related hardware, the program may be stored in a computer readable storage medium, and the storage medium may include: read Only Memory (ROM), random access Memory (RAM, random Access Memory), magnetic or optical disk, and the like.
The foregoing description of the preferred embodiment(s) is (are) merely intended to illustrate the embodiment(s) of the present invention, and it is not intended to limit the embodiment(s) of the present invention to the particular embodiment(s) described.
Claims (10)
1. A blockchain intelligent contract version control method, characterized in that the method comprises the following steps:
constructing an intelligent contract version control transaction using nodes, the types of the transaction including: upgrade contracts, switch contract versions, gray scale control, contract freeze, contract defrost, and quick rollback; when the transaction type is an upgrade contract, the transaction comprises a new version intelligent contract; when the transaction type is a switching contract version, the transaction comprises an intelligent contract version label to be switched; when the transaction type is gray level control, a corresponding version control strategy contract needs to be deployed in advance for a target intelligent contract in the transaction, wherein the version control strategy contract is used for controlling a specific strategy of gray level upgrading;
the verification node maintains a currently validated version pointer, a historical version pointer list, a contract status identifier, a version control policy contract pointer and a version counter for each smart contract; the current effective version pointer points to the address of the intelligent contract of the latest effective version; pointers in the history version pointer list point to addresses of old version intelligent contracts respectively; the contract state identification includes normal and frozen states; the version control policy contract pointer points to the version control policy contract of the intelligent contract; the version counter is used for recording the version change times of the intelligent contract;
the method comprises the steps that an intelligent contract version control transaction is sent to a master verification node in a blockchain network by using a node, the master verification node verifies the validity of the transaction, and after verification, the transaction is sequenced, packaged and broadcast to other verification nodes in the blockchain network;
other verification nodes receiving the intelligent contract version control transaction will verify the validity of the transaction again, write the transaction into the block after the verification is passed, mutually identify the block, execute the intelligent contract version control transaction in the block after the identification is passed, and perform corresponding operation on the contract content corresponding to the target contract address in the transaction according to the type of the transaction, specifically:
(1) The contract upgrading operation, the verification node verifies and stores the new version intelligent contract, the current effective version pointer is added to the history version pointer list, the current effective version pointer points to the stored new version intelligent contract, and then the current version counter is increased by one;
(2) Version switching operation, namely searching a historical version pointer list through version tag information in a transaction, adding a current effective version pointer to the historical version pointer list after an intelligent contract to be switched is searched, replacing the current effective version pointer with the searched historical version pointer, deleting the historical version pointer from the historical version pointer list, and not adjusting a version counter;
(3) Contract freezing operation, adding a current effective version pointer to a history version pointer list, pointing the current effective version pointer to a null value, setting a contract state identifier to be a freezing state, and enabling a user to be unable to call after freezing the intelligent contract;
(4) Contract thawing operation, in which the current effective version pointer is replaced by the latest added historical version pointer in the historical version pointer list, the historical version pointer is deleted from the historical version pointer list, and after the intelligent contract is thawed, the user can normally call;
(5) A quick rollback operation, namely acquiring a latest added historical version pointer from a historical version pointer list, deleting the historical version pointer from the historical version pointer list, replacing a current effective version pointer with the acquired latest historical version pointer, and subtracting one version counter;
(6) And gray control operation, wherein policy selection is performed according to the version control policy contract pointed by the version control policy contract pointer, and the specific version intelligent contract pointed by the contract return result in the current effective version pointer or the history version pointer list is executed according to the return result.
2. The blockchain smart contract version control method of claim 1, wherein the smart contract address is not changed after the using node successfully deploys the smart contract, and the smart contract is version controlled based on a single smart contract address.
3. The blockchain intelligent contract version control method of claim 1, wherein the version control transaction is agreed upon through consensus as the common transaction after verification, and the blockout is executed through a virtual machine and corresponding deployment resources are spent.
4. The blockchain intelligent contract version control method of claim 1, wherein the verification node performs intelligent contract version control operation at an intelligent contract virtual machine layer, finds a currently effective version pointer of the contract according to an intelligent contract address, finds an intelligent contract code according to the pointer, and performs calling or version control operation.
5. The blockchain intelligent contract version control method of claim 1, wherein the history version pointer contains intelligent contract version label information, the corresponding history version pointer can be found according to the intelligent contract version label information, the version label is generated by a version counter when intelligent contract upgrading operation is executed, the version counter is only increased by one when contract upgrading operation is executed, and is decreased by one when quick rollback operation is executed, and other operation version counters are unchanged.
6. The blockchain intelligent contract version control method of claim 1, wherein the gray control operation must deploy a corresponding version control policy contract for the target intelligent contract first, and after the verification node deploys, the version control policy contract pointer of the target intelligent contract is pointed to the version control policy contract.
7. The blockchain intelligent contract version control method according to claim 1, wherein the gray control operation selects the latest version or the designated version of the intelligent contract to execute according to the intelligent contract address in the transaction, and the selection result is determined by the version control policy contract corresponding to the intelligent contract.
8. The blockchain intelligent contract version control method of claim 1, wherein the contract method signature and contract method parameters of the version control policy contract are consistent with the associated intelligent contract, and if the contract method parameters of the two versions are inconsistent, further encapsulation routing of the contract method is required.
9. The blockchain intelligent contract version control method of claim 1, wherein the control policy of the version control policy contract requires a return true or false and a version number, the return true indicates that the policy passes, and the latest version intelligent contract is executed; returning false indicates that the strategy is not passed, if the return version number is null or zero, executing the intelligent contract of the next new version, otherwise executing the intelligent contract of the version number appointed version; the control strategy content depth is related to a specific intelligent contract, can be customized by using contract method parameter depth according to the service type represented by the intelligent contract, and can also be judged directly according to the parity of calling time or according to the last parity of an address field when a node is used for calling.
10. A blockchain system comprising a usage node and a validation node, wherein the usage node and validation node are configured to perform the steps in the method of any of claims 1-9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110993450.5A CN113760353B (en) | 2021-08-27 | 2021-08-27 | Block chain intelligent contract version control method and block chain system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110993450.5A CN113760353B (en) | 2021-08-27 | 2021-08-27 | Block chain intelligent contract version control method and block chain system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113760353A CN113760353A (en) | 2021-12-07 |
CN113760353B true CN113760353B (en) | 2024-01-02 |
Family
ID=78791573
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110993450.5A Active CN113760353B (en) | 2021-08-27 | 2021-08-27 | Block chain intelligent contract version control method and block chain system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113760353B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109978477B (en) * | 2017-12-27 | 2022-12-23 | 现代财富控股有限公司 | Intelligent contract version control and management system and method based on block chain |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108881312A (en) * | 2018-08-24 | 2018-11-23 | 北京京东尚科信息技术有限公司 | Intelligent contract upgrade method, system and relevant device and storage medium |
CN109978477A (en) * | 2017-12-27 | 2019-07-05 | 现代财富控股有限公司 | Intelligent contract version keyholed back plate system and method based on block chain |
CN110544097A (en) * | 2019-09-06 | 2019-12-06 | 杭州复杂美科技有限公司 | Intelligent contract version control, calling and upgrading method, equipment and storage medium |
CN112148794A (en) * | 2020-09-23 | 2020-12-29 | 京东数字科技控股股份有限公司 | Version management method and device of intelligent contract and storage medium |
CN112527781A (en) * | 2020-12-23 | 2021-03-19 | 上海万向区块链股份公司 | Intelligent contract data migration method and system |
CN112835605A (en) * | 2021-03-30 | 2021-05-25 | 中国工商银行股份有限公司 | Block chain version gray scale upgrading verification method, device and system |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20210224253A1 (en) * | 2020-01-20 | 2021-07-22 | International Business Machines Corporation | Conflict-free version control |
-
2021
- 2021-08-27 CN CN202110993450.5A patent/CN113760353B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109978477A (en) * | 2017-12-27 | 2019-07-05 | 现代财富控股有限公司 | Intelligent contract version keyholed back plate system and method based on block chain |
CN108881312A (en) * | 2018-08-24 | 2018-11-23 | 北京京东尚科信息技术有限公司 | Intelligent contract upgrade method, system and relevant device and storage medium |
CN110544097A (en) * | 2019-09-06 | 2019-12-06 | 杭州复杂美科技有限公司 | Intelligent contract version control, calling and upgrading method, equipment and storage medium |
CN112148794A (en) * | 2020-09-23 | 2020-12-29 | 京东数字科技控股股份有限公司 | Version management method and device of intelligent contract and storage medium |
CN112527781A (en) * | 2020-12-23 | 2021-03-19 | 上海万向区块链股份公司 | Intelligent contract data migration method and system |
CN112835605A (en) * | 2021-03-30 | 2021-05-25 | 中国工商银行股份有限公司 | Block chain version gray scale upgrading verification method, device and system |
Also Published As
Publication number | Publication date |
---|---|
CN113760353A (en) | 2021-12-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11438139B2 (en) | Blockchain based secure naming and update verification | |
US11875171B2 (en) | Blockchain network transaction processing method, apparatus, device, and storage medium | |
CN107562513B (en) | Intelligent contract life cycle management method based on JAVA | |
CN103150394B (en) | Distributed file system metadata management method facing to high-performance calculation | |
US20090019139A1 (en) | Repository-Independent System and Method for Asset Management and Reconciliation | |
CN110471750B (en) | Timing task control method, device, medium and computer equipment | |
WO2001082058A2 (en) | Dynamic file system configurations | |
EP1589691A2 (en) | Method, system and apparatus for managing computer identity | |
CN110661658A (en) | Node management method and device of block chain network and computer storage medium | |
CN102141925A (en) | Suitability detection using third party target state | |
CN109522729B (en) | Intelligent contract state changing method and device | |
CN113760353B (en) | Block chain intelligent contract version control method and block chain system | |
CN109508912B (en) | Service scheduling method, device, equipment and storage medium | |
CN114721684B (en) | Firmware version upgrading method, version upgrading server and management platform | |
CN104429048A (en) | Object version management | |
CN113835729B (en) | Upgrading method, upgrading device, terminal equipment and computer readable storage medium | |
CN112632083B (en) | Method, device and equipment for realizing index data updating | |
CN103595573B (en) | Method and device for issuing strategy rules | |
CN107621945A (en) | A kind of method and device for the mark for determining ios device | |
CN110008183B (en) | File searching method of intelligent card file system | |
US11431795B2 (en) | Method, apparatus and storage medium for resource configuration | |
KR100456512B1 (en) | System for detecting a kernel backdoor, method for detecting a kernel backdoor and method for recovering a kernel data using the same | |
CN110991573A (en) | Product management method, system, client node and storage medium | |
WO2004114129A2 (en) | Embedded device with software registry | |
CN110727498B (en) | Virtual network function management method, NFVO, block chain node and MANO network element |
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 |