Smart contract lifecycle management method, apparatus and computer device
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SF TECH CO LTD
- Filing Date
- 2021-05-20
- Publication Date
- 2026-05-29
AI Technical Summary
In existing technologies, the full lifecycle management of contracts in the Hyperledger Fabric consortium blockchain is incomplete, only including installation, instantiation, and upgrade operations, resulting in insufficient smart contract management.
Deploy smart contracts and manage chaincode on the consortium blockchain. When anomalies are detected by managing the chaincode, the smart contracts can be frozen or unfrozen. The corresponding state values can be updated when the contracts are updated or cancelled, thus realizing the freezing, unfreezing and cancellation of smart contracts.
It improves the lifecycle management of smart contracts, enhances the security and data reliability of the consortium blockchain, avoids data upload errors, and improves the utilization rate of blockchain storage resources.
Smart Images

Figure CN115375469B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of blockchains, and in particular to a smart contract lifecycle management method and device, a computer device and a storage medium. BACKGROUND
[0002] A smart contract is an application program running on a blockchain. The smart contract of Fabric is called chaincode, which is divided into system chaincode and user chaincode. The system chaincode is used to implement system-level functions, including system configuration, user chaincode deployment and upgrade, user transaction signature and verification policy, etc. The user chaincode implements the application functions of users.
[0003] However, the contract lifecycle management in the alliance chain Hyperledger Fabric currently only has installation, instantiation and upgrade operations, resulting in imperfect smart contract lifecycle management. SUMMARY
[0004] Therefore, it is necessary to provide a smart contract lifecycle management method and device, a computer device and a storage medium capable of perfecting the lifecycle management of a smart contract.
[0005] A smart contract lifecycle management method, the method comprising:
[0006] deploying a smart contract on a first channel built by an alliance chain and deploying a management chaincode on a second channel built by the alliance chain;
[0007] triggering a management node to call the management chaincode when detecting that the smart contract is running abnormally;
[0008] performing a freezing operation on the smart contract according to the management chaincode, updating a state value of the smart contract to a first state value, and updating the smart contract; the first state value is used to represent that the smart contract can only be called by a node having a permission required for calling the smart contract.
[0009] In one of the embodiments, the method further comprises:
[0010] performing an unfreezing operation on the updated smart contract according to the management chaincode when detecting that the smart contract is updated, and updating a state value of the smart contract from the first state value to a second state value; the second state value is used to represent that the smart contract can be called by all nodes on the alliance chain.
[0011] In one of the embodiments, before the management node is triggered to call the management chaincode from the second channel of the alliance chain, the method further comprises:
[0012] Obtain the first access permission for the management node;
[0013] When the first calling permission meets the permission required to call the management chaincode, the step of triggering the management node to call the management chaincode from the consortium blockchain channel is executed.
[0014] In one embodiment, the method further includes:
[0015] In response to the cancellation command of the smart contract, the management node is triggered to call the deployed cancellation chaincode from the third channel of the consortium blockchain;
[0016] By executing the deregistration chaincode, the chaincode container of the smart contract and the corresponding chaincode source file are deleted.
[0017] In one embodiment, responding to the smart contract's cancellation instruction, triggering the management node to call the deployed cancellation chaincode from the third channel of the consortium blockchain, includes:
[0018] In response to the cancellation command of the smart contract, the cancellation event corresponding to the cancellation command is sent to the endorsing node for voting to obtain the number of votes;
[0019] When the number of votes is greater than or equal to the preset number of votes, the management node is triggered to call the deployed deregistration chaincode from the third channel of the consortium blockchain.
[0020] In one embodiment, before triggering the management node to invoke the deployed deregistration chaincode from the consortium blockchain channel, the method further includes:
[0021] Obtain the second access permission for the management node;
[0022] When the second calling permission meets the permission required to call the deregistration chaincode, the step of triggering the management node to call the deployed deregistration chaincode from the consortium blockchain channel is executed.
[0023] A smart contract lifecycle management device, the device comprising:
[0024] The deployment module is used to deploy smart contracts on the first channel of the consortium blockchain and to deploy management chaincode on the second channel.
[0025] The triggering module is used to trigger the management node to call the management chaincode when an abnormality is detected in the smart contract.
[0026] The freeze module is used to freeze the smart contract according to the management chaincode, update the state value of the smart contract to a first state value, and update the smart contract; the first state value is used to indicate that the smart contract can only be called by nodes with the permissions required to call the smart contract.
[0027] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program performing the following steps:
[0028] Deploy smart contracts on the first channel of the consortium blockchain and deploy management chaincode on the second channel.
[0029] When an abnormality is detected in the smart contract, the management node is triggered to call the management chaincode;
[0030] The smart contract is frozen according to the management chaincode, the state value of the smart contract is updated to a first state value, and the smart contract is updated; the first state value is used to indicate that the smart contract can only be called by nodes with the permissions required to call the smart contract.
[0031] A computer-readable storage medium having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0032] Deploy smart contracts on the first channel of the consortium blockchain and deploy management chaincode on the second channel.
[0033] When an abnormality is detected in the smart contract, the management node is triggered to call the management chaincode;
[0034] The smart contract is frozen according to the management chaincode, the state value of the smart contract is updated to a first state value, and the smart contract is updated; the first state value is used to indicate that the smart contract can only be called by nodes with the permissions required to call the smart contract.
[0035] The aforementioned smart contract lifecycle management method, device, computer equipment, and storage medium deploy smart contracts on the first channel of the consortium blockchain and management chaincode on the second channel. When an abnormal operation of the smart contract is detected, the management node is triggered to call the management chaincode to freeze the smart contract, update the smart contract's state value to the first state value (meaning nodes without the necessary permissions to call the smart contract cannot call it normally), and update the smart contract. Based on the lifecycle of smart contract installation, instantiation, and upgrade operations, the freezing operation of the smart contract is realized, thereby improving the lifecycle management of smart contracts and enhancing the security of the consortium blockchain. Attached Figure Description
[0036] Figure 1 This is a flowchart illustrating a smart contract lifecycle management method in one embodiment;
[0037] Figure 2 This is a flowchart illustrating a smart contract lifecycle management method in another embodiment;
[0038] Figure 3 This is a flowchart illustrating a smart contract lifecycle management method in another embodiment;
[0039] Figure 4 This is a schematic diagram illustrating an application scenario of smart contract lifecycle management in one embodiment;
[0040] Figure 5 This is a structural block diagram of a smart contract lifecycle management device in one embodiment;
[0041] Figure 6 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0042] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0043] In one embodiment, such as Figure 1 As shown, a smart contract lifecycle management method is provided. This embodiment illustrates the application of this method to blockchain. It is understood that this method can also be applied to terminals and systems including terminals and blockchains, and is implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0044] Step 102: Deploy smart contracts on the first channel built by the consortium blockchain and deploy management chaincode on the second channel built.
[0045] The management chaincode, located in the framework contract layer of the consortium blockchain, is used to freeze or unfreeze smart contracts. Its initial state value is a boolean value of true. Changing the management chaincode's state value alters the smart contract's state, thus enabling the freezing and unfreezing of the smart contract.
[0046] "First" and "Second" are used to distinguish different channels on the consortium blockchain. The first channel can also be the second channel, and the second channel can also be the first channel.
[0047] Specifically, a first channel and a second channel are established on the consortium blockchain. A smart contract is deployed on the first channel, including code for state value verification and calling the management chaincode. Management chaincode is deployed on the second channel and initialized. For example, consortium blockchain A establishes a first channel (mychannel) and a second channel (mgchannel). The management contract (mgcc) is deployed on the second channel (mgchannel) to initialize the management chaincode, specifically by default setting the field (state value) ccstatus to true. The smart contract (mycc) is deployed on the first channel (mychannel), including code for verifying the ccstatus status and code for calling mgcc.
[0048] Step 104: When an abnormality is detected in the smart contract, the management node is triggered to call the management chaincode.
[0049] Specifically, when an abnormal operation of a smart contract deployed on the first channel of the consortium blockchain is detected, the management node calls the management chaincode on the second channel.
[0050] Optionally, in one embodiment, before triggering the management node to call the management chaincode from the second channel of the consortium blockchain, the management node obtains first calling permission; when the first calling permission meets the permission required to call the management chaincode, the management node is triggered to call the management chaincode from the consortium blockchain channel. That is, before calling the management chaincode, the management node's permission is verified. When the permission verification is successful, the management node with operation permission performs the freezing and unfreezing operation on the abnormal smart contract, thereby improving the reliability of the smart contract.
[0051] Step 106: Freeze the smart contract according to the management chaincode, update the smart contract's state value to the first state value, and update the smart contract.
[0052] The first state value is used to indicate that the smart contract can only be invoked by nodes with the permissions required to invoke the smart contract.
[0053] Specifically, the management chaincode is invoked to check its initial state value. When the initial state value is a preset state value, the state value of the management chaincode is changed from the initial state value to the first state value. This first state value is then used as the state value of the smart contract. In other words, the management chaincode is invoked to freeze the smart contract, putting it in a frozen state so that it cannot be invoked by other nodes on the consortium chain that do not have the authority to invoke it.
[0054] For example, in consortium blockchain A, a first channel (mychannel) and a second channel (mgchannel) are established. The first channel (mychannel) deploys a smart contract (mycc), which includes code to verify the ccstatus status and code to call mgcc. The second channel (mgchannel) deploys the management chaincode (mgcc) and initializes it. When the smart contract (mycc) encounters a problem, it needs to call the management chaincode (mgcc). First, the management node's first calling permission is verified. If the verification passes, the management node calls the management chaincode (mgcc), sets the ccstatus status to the first status value (false), and uses the first status value (false) as the smart contract's status value. In other words, the smart contract's ccstatus status is updated to the first status value (false). If the smart contract (mycc) is frozen, ordinary user certificate identity verification fails, and it can no longer be called.
[0055] In the aforementioned smart contract lifecycle management method, smart contracts are deployed on the first channel of the consortium blockchain, and management chaincode is deployed on the second channel. When an abnormality is detected in the smart contract, the management node is triggered to call the management chaincode to freeze the smart contract. The smart contract's state value is updated to the first state value, meaning that nodes without the necessary permissions to call the smart contract cannot call it normally, and the smart contract is frozen. This prevents data from being uploaded to the blockchain incorrectly, which could reduce the reliability of data in the blockchain. Based on the lifecycle of smart contract installation, instantiation, and upgrade operations, the freezing operation of smart contracts is implemented, thus improving the lifecycle management of smart contracts and enhancing the security of the consortium blockchain.
[0056] In another embodiment, such as Figure 2 As shown, a smart contract lifecycle management method is provided. This embodiment illustrates the application of this method to blockchain. It is understood that this method can also be applied to terminals and systems including terminals and blockchains, and is implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0057] Step 202: Deploy smart contracts on the first channel built by the consortium blockchain and deploy management chaincode on the second channel built.
[0058] Step 204: When an abnormality is detected in the smart contract, the management node is triggered to call the management chaincode.
[0059] Step 206: Freeze the smart contract according to the management chaincode, update the smart contract's state value to the first state value, and update the smart contract.
[0060] The first state value is used to indicate that the smart contract can only be invoked by nodes with the permissions required to invoke the smart contract.
[0061] Step 208: When the smart contract update is detected to be complete, the updated smart contract is unfrozen according to the management chaincode, and the state value of the smart contract is updated from the first state value to the second state value.
[0062] The second state value indicates that the smart contract can be invoked by all nodes on the consortium blockchain. The smart contract update method, i.e., the contract upgrade method, can be upgraded using existing upgrade methods within the consortium blockchain framework, which will not be elaborated upon here.
[0063] Specifically, the smart contract is upgraded through an upgrade process. After the smart contract is updated, the management node calls the management chaincode to unfreeze the updated smart contract, changing the smart contract's state value from the first state value to the second state value, so that the smart contract can be called by other nodes on the consortium blockchain.
[0064] In the aforementioned smart contract lifecycle management method, smart contracts are deployed on the first channel of the consortium blockchain, and management chaincode is deployed on the second channel. When an anomaly is detected in the smart contract, the management node is triggered to call the management chaincode to freeze the smart contract, update its state value to the first state value (meaning nodes without the necessary permissions cannot call the smart contract), and update the smart contract. Once the update is complete, the smart contract is unfrozen, allowing all nodes to call it. In other words, when an anomaly occurs in the smart contract, the management chaincode deployed on the consortium blockchain channel performs freeze, upgrade, and unfreeze operations on the smart contract. Based on the lifecycle of smart contract installation, instantiation, and upgrade operations, this method implements the freezing and unfreezing of smart contracts, improving the lifecycle management of smart contracts and enhancing the security of the consortium blockchain.
[0065] In another embodiment, such as Figure 3 As shown, a smart contract lifecycle management method is provided. This embodiment illustrates the application of this method to blockchain. It is understood that this method can also be applied to terminals and systems including terminals and blockchains, and is implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0066] Step 302: Deploy smart contracts on the first channel built by the consortium blockchain and deploy management chaincode on the second channel built.
[0067] Step 304: When an abnormality is detected in the smart contract, the management node is triggered to call the management chaincode.
[0068] Step 306: Freeze the smart contract according to the management chaincode, update the smart contract's state value to the first state value, and update the smart contract.
[0069] The first state value is used to indicate that the smart contract can only be invoked by nodes with the permissions required to invoke the smart contract.
[0070] Step 308: When the smart contract update is detected to be complete, the updated smart contract is unfrozen according to the management chaincode, and the state value of the smart contract is updated from the first state value to the second state value.
[0071] Step 310: Respond to the smart contract's cancellation instruction, triggering the management node to call the deployed cancellation chaincode from the third channel of the consortium blockchain.
[0072] The deregistration chaincode is used to deregister smart contracts without affecting the main program when the Hyperledger Fabric system chaincode supports plugin functionality. The deregistration chaincode includes logic for verifying caller permissions and, upon successful verification, deleting the corresponding contract container and source files.
[0073] Specifically, by responding to the cancellation command of the smart contract, the cancellation event corresponding to the cancellation command is sent to the endorsing node for voting to obtain the number of votes; when the number of votes is greater than or equal to the preset number of votes, the management node is triggered to call the deployed cancellation chaincode from the third channel of the consortium blockchain.
[0074] Optionally, in one embodiment, before triggering the management node to call the deployed deregistration chaincode from the consortium blockchain channel, the method further includes: obtaining a second calling permission from the management node; when the second calling permission meets the permissions required to call the deregistration chaincode, triggering the management node to call the deployed deregistration chaincode from the third channel of the consortium blockchain, verifying the caller's permissions before the deregistration smart contract, ensuring the reliability of deregistration and maintaining the security of the blockchain.
[0075] Step 312: By executing the unregistered chaincode, the chaincode container of the smart contract and the corresponding chaincode source file are deleted.
[0076] In one embodiment, such as Figure 4The diagram illustrates an application scenario for smart contract lifecycle management. In consortium blockchain A, a first channel (mychannel) and a second channel (mgchannel) are established. The first channel (mychannel) deploys the smart contract (mycc), which includes code to verify the ccstatus status and code to call mgcc. The second channel (mgchannel) deploys the management chaincode (mgcc) and initializes it. When a problem occurs with the smart contract (mycc), the management node's primary calling permission needs to be verified. If the verification passes, the management node calls the management chaincode (mgcc) and sets ccstatus to false, updating the smart contract's ccstatus status to the first status value, false. If the smart contract (mycc) is frozen, ordinary user certificate verification fails, and it can no longer be called.
[0077] When the update of the smart contract mycc is detected, the updated smart contract is unfrozen according to the management chaincode, and the status value of the smart contract is updated from the first status value to the second status value, that is, the status value ccstatus is updated to the second status value true, so that the smart contract can be called by other nodes on the consortium chain.
[0078] When it is necessary to cancel the smart contract mycc, in response to the cancellation command of the smart contract, the management node is triggered to call the deployed cancellation chaincode cancelcc from the third channel of the consortium blockchain. By executing the cancellation chaincode cancelcc, the chaincode container of the smart contract mycc and the corresponding chaincode source file are deleted.
[0079] In the aforementioned smart contract lifecycle management method, smart contracts are deployed on the first channel of the consortium blockchain, and management chaincode is deployed on the second channel. When an abnormality is detected in the smart contract, the management node is triggered to call the management chaincode to freeze the smart contract, update its state value to the first state value (meaning nodes without the necessary permissions cannot call the smart contract), and update the smart contract. Once the update is complete, the smart contract is unfrozen, allowing all nodes to call it. In other words, when a smart contract malfunctions, the management chaincode deployed on the consortium blockchain channel performs freeze, upgrade, and unfreeze operations to prevent data errors on the blockchain. The unfreeze chaincode is then called to deregister the smart contract. Thus, based on the smart contract installation, instantiation, and upgrade lifecycle, the method implements freeze, unfreeze, and deregistration operations, improving the security of the consortium blockchain and the utilization rate of blockchain storage resources while perfecting the smart contract lifecycle management.
[0080] It should be understood that, althoughFigures 1-3 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figures 1-3 At least some of the steps in the process may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but may be executed at different times. The execution order of these steps or stages is not necessarily sequential, but may be executed in turn or alternately with other steps or at least some of the steps or stages in other steps.
[0081] In one embodiment, such as Figure 5 As shown, a smart contract lifecycle management device is provided, including: a deployment module 502, a triggering module 504, and a freezing module 506, wherein:
[0082] Deployment module 502 is used to deploy smart contracts on the first channel of the consortium blockchain and to deploy management chaincode on the second channel.
[0083] Trigger module 504 is used to trigger the management node to call the management chaincode when an abnormality is detected in the smart contract.
[0084] The freeze module 506 is used to freeze the smart contract according to the management chaincode, update the state value of the smart contract to the first state value, and update the smart contract; the first state value is used to indicate that the smart contract can only be called by nodes with the permissions required to call the smart contract.
[0085] In the aforementioned smart contract lifecycle management device, smart contracts are deployed on the first channel of the consortium blockchain, and management chaincode is deployed on the second channel. When an abnormal operation of the smart contract is detected, the management node is triggered to call the management chaincode to freeze the smart contract, update the smart contract's state value to the first state value, meaning that nodes without the necessary permissions to call the smart contract cannot call it normally, and update the smart contract. In other words, the smart contract is frozen during its lifecycle of installation, instantiation, and upgrade operations, thus improving the lifecycle management of smart contracts and enhancing the security of the consortium blockchain.
[0086] In another embodiment, a smart contract lifecycle management device is provided, which, in addition to including a deployment module 502, a triggering module 504, and a freezing module 506, further includes: , wherein:
[0087] The unfreezing module is used to unfreeze the updated smart contract according to the management chaincode when the smart contract update is detected to be complete, and update the state value of the smart contract from the first state value to the second state value; the second state value is used to indicate that the smart contract can be called by all nodes on the consortium blockchain.
[0088] The permission verification module is used to obtain the first calling permission of the management node; when the first calling permission meets the permission required to call the management chaincode, the management node is triggered to call the management chaincode from the consortium blockchain channel.
[0089] The deregistration module is used to respond to the deregistration command of the smart contract, triggering the management node to call the deployed deregistration chaincode from the third channel of the consortium blockchain; by executing the deregistration chaincode, the chaincode container of the smart contract and the corresponding chaincode source file are deleted.
[0090] The voting module is used to respond to the cancellation command of the smart contract, send the cancellation event corresponding to the cancellation command to the endorsing nodes for voting, and obtain the number of votes.
[0091] In one embodiment, the triggering module 504 is further configured to trigger the management node to call the deployed deregistration chaincode from the third channel of the consortium blockchain when the number of votes is greater than or equal to the preset number of votes.
[0092] The permission verification module is also used to obtain the second calling permission of the management node; and to verify whether the second calling permission meets the permission required to call the deregistration chaincode.
[0093] In one embodiment, a smart contract is deployed on a first channel built on the consortium blockchain, and management chaincode is deployed on a second channel. When an anomaly is detected in the smart contract, the management node is triggered to call the management chaincode to freeze the smart contract, update its state value to the first state value (meaning nodes without the necessary permissions to call the smart contract cannot call it normally), and update the smart contract. Once the update is complete, the smart contract is unfrozen, allowing all nodes to call it. In other words, when an anomaly occurs in the smart contract, the management chaincode deployed on the consortium blockchain channel performs a freeze-upgrade-unfreeze operation on the smart contract, preventing errors in the on-chain data.
[0094] When a smart contract needs to be deregistered, in response to the smart contract's deregistration command, the management node is triggered to call the deployed deregistration chaincode from the third channel of the consortium blockchain. By executing the deregistration chaincode c, the smart contract's chaincode container and the corresponding chaincode source file are deleted. The deregistration of the smart contract is completed by calling the deregistration chaincode. Based on the lifecycle of smart contract installation, instantiation, and upgrade operations, the system realizes the freezing, unfreezing, and deregistration operations of smart contracts, completes the lifecycle management of smart contracts, and improves the utilization rate of blockchain storage resources.
[0095] Specific limitations regarding the smart contract lifecycle management device can be found in the limitations of the smart contract lifecycle management method described above, and will not be repeated here. Each module in the aforementioned smart contract lifecycle management device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0096] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a smart contract lifecycle management method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.
[0097] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0098] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0099] Deploy smart contracts on the first channel of the consortium blockchain and deploy management chaincode on the second channel.
[0100] When an abnormality is detected in the smart contract, the management node is triggered to call the management chaincode;
[0101] The smart contract is frozen based on the management chaincode, the smart contract's state value is updated to the first state value, and the smart contract is updated; the first state value is used to indicate that the smart contract can only be invoked by nodes with the permissions required to invoke the smart contract.
[0102] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0103] When the smart contract update is detected to be complete, the updated smart contract is unfrozen according to the management chaincode, and the state value of the smart contract is updated from the first state value to the second state value; the second state value is used to indicate that the smart contract can be called by all nodes on the consortium chain.
[0104] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0105] Obtain first access permission to the management node;
[0106] When the first call permission meets the permission required to call the management chaincode, the step of triggering the management node to call the management chaincode from the consortium blockchain channel is executed.
[0107] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0108] In response to the smart contract's cancellation command, the management node is triggered to call the deployed cancellation chaincode from the third channel of the consortium blockchain;
[0109] By executing the unregister chaincode, the chaincode container of the smart contract and the corresponding chaincode source file are deleted.
[0110] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0111] In response to the cancellation command of the smart contract, the cancellation event corresponding to the cancellation command is sent to the endorsing node for voting, and the number of votes is obtained;
[0112] When the number of votes is greater than or equal to the preset number of votes, the management node is triggered to call the deployed deregistration chaincode from the third channel of the consortium blockchain.
[0113] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0114] Obtain secondary access permissions for the management node;
[0115] When the second invocation permission meets the permission required to invoke the deregistration chaincode, the step of triggering the management node to invoke the deployed deregistration chaincode from the consortium blockchain channel is executed.
[0116] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0117] Deploy smart contracts on the first channel of the consortium blockchain and deploy management chaincode on the second channel.
[0118] When an abnormality is detected in the smart contract, the management node is triggered to call the management chaincode;
[0119] The smart contract is frozen based on the management chaincode, the smart contract's state value is updated to the first state value, and the smart contract is updated; the first state value is used to indicate that the smart contract can only be invoked by nodes with the permissions required to invoke the smart contract.
[0120] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0121] When the smart contract update is detected to be complete, the updated smart contract is unfrozen according to the management chaincode, and the state value of the smart contract is updated from the first state value to the second state value; the second state value is used to indicate that the smart contract can be called by all nodes on the consortium chain.
[0122] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0123] Obtain first access permission to the management node;
[0124] When the first call permission meets the permission required to call the management chaincode, the step of triggering the management node to call the management chaincode from the consortium blockchain channel is executed.
[0125] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0126] In response to the smart contract's cancellation command, the management node is triggered to call the deployed cancellation chaincode from the third channel of the consortium blockchain;
[0127] By executing the unregister chaincode, the chaincode container of the smart contract and the corresponding chaincode source file are deleted.
[0128] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0129] In response to the cancellation command of the smart contract, the cancellation event corresponding to the cancellation command is sent to the endorsing node for voting, and the number of votes is obtained;
[0130] When the number of votes is greater than or equal to the preset number of votes, the management node is triggered to call the deployed deregistration chaincode from the third channel of the consortium blockchain.
[0131] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0132] Obtain secondary access permissions for the management node;
[0133] When the second invocation permission meets the permission required to invoke the deregistration chaincode, the step of triggering the management node to invoke the deployed deregistration chaincode from the consortium blockchain channel is executed.
[0134] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0135] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0136] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for managing the lifecycle of smart contracts, characterized in that, The method includes: Deploy smart contracts on the first channel of the consortium blockchain and deploy management chaincode on the second channel. When an abnormality is detected in the smart contract, the management node is triggered to call the management chaincode; The initial state value of the management chaincode is detected. When the initial state value is detected to be a preset state value, the state value of the management chaincode is changed from the initial state value to a first state value, and the first state value is used as the state value of the smart contract. The first state value is used to indicate that the smart contract can only be called by nodes with the permissions required to call the smart contract.
2. The method according to claim 1, characterized in that, The method further includes: When the smart contract update is detected to be complete, the updated smart contract is unfrozen according to the management chaincode, and the state value of the smart contract is updated from the first state value to the second state value; the second state value is used to indicate that the smart contract can be called by all nodes on the consortium chain.
3. The method according to claim 1, characterized in that, Before the triggering management node invokes the management chaincode, the method further includes: Obtain first access permission from the management node; When the first calling permission meets the permission required to call the management chaincode, the step of triggering the management node to call the management chaincode is executed.
4. The method according to claim 1, characterized in that, The method further includes: In response to the cancellation command of the smart contract, the management node is triggered to call the deployed cancellation chaincode from the third channel of the consortium blockchain; By executing the deregistration chaincode, the chaincode container of the smart contract and the corresponding chaincode source file are deleted.
5. The method according to claim 4, characterized in that, The response to the smart contract's cancellation command, triggering the management node to call the deployed cancellation chaincode from the third channel of the consortium blockchain, includes: In response to the cancellation command of the smart contract, the cancellation event corresponding to the cancellation command is sent to the endorsing node for voting to obtain the number of votes; When the number of votes is greater than or equal to the preset number of votes, the management node is triggered to call the deployed deregistration chaincode from the third channel of the consortium blockchain.
6. The method according to claim 5, characterized in that, Before triggering the management node to invoke the deployed deregistration chaincode from the third channel of the consortium blockchain, the method further includes: Obtain the second access permission for the management node; When the second calling permission meets the permission required to call the deregistration chaincode, the step of triggering the management node to call the deployed deregistration chaincode from the third channel of the consortium blockchain is executed.
7. A smart contract lifecycle management device, characterized in that, The device includes: The deployment module is used to deploy smart contracts on the first channel of the consortium blockchain and to deploy management chaincode on the second channel. The triggering module is used to trigger the management node to call the management chaincode when an abnormality is detected in the smart contract. The freezing module is used to detect the initial state value of the management chaincode. When the initial state value is detected to be a preset state value, the state value of the management chaincode is changed from the initial state value to a first state value, and the first state value is used as the state value of the smart contract. The first state value is used to indicate that the smart contract can only be called by nodes with the permissions required to call the smart contract.
8. The apparatus according to claim 7, characterized in that, The device further includes: The unfreezing module is used to unfreeze the updated smart contract according to the management chaincode when the smart contract update is detected to be complete, and update the state value of the smart contract from the first state value to the second state value; the second state value is used to indicate that the smart contract can be called by all nodes on the consortium chain.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.