WO2019233454A1 - Procédé et dispositif de mise à niveau de code de chaîne - Google Patents
Procédé et dispositif de mise à niveau de code de chaîne Download PDFInfo
- Publication number
- WO2019233454A1 WO2019233454A1 PCT/CN2019/090206 CN2019090206W WO2019233454A1 WO 2019233454 A1 WO2019233454 A1 WO 2019233454A1 CN 2019090206 W CN2019090206 W CN 2019090206W WO 2019233454 A1 WO2019233454 A1 WO 2019233454A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- version
- chain code
- version set
- world state
- node
- Prior art date
Links
Images
Classifications
-
- 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
- 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
- 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/389—Keeping log of transactions for guaranteeing non-repudiation of a transaction
Definitions
- the present application relates to the field of blockchain technology, and in particular, to a method and device for upgrading a chain code.
- the chain code is used to indicate the logic of the transaction and the rules of transaction processing.
- the node includes the relevant records of at least one transaction (including the payer and receiver of the transaction funds, the amount of the transaction funds, etc.) in the area by executing the chain code.
- the block acts as an account page.
- the transactions existing in the blockchain network can be recorded in multiple blocks. Each block is connected together in a certain order to form a blockchain.
- the formed blockchain is also the transaction recorded in the blockchain network. Ledger.
- chain codes that is, smart contracts
- the nodes can execute the new chain codes to process each transaction to meet user needs.
- users can also upgrade the version of the chain code, and the node processes each transaction by executing a higher version of the chain code.
- the client can initiate a chaincode upgrade process. Specifically, the client sends a chain code upgrade command to the preset node to indicate which version the chain code is upgraded to. The preset node verifies the client's certificate and signature. If the client's identity is confirmed to be valid, the corresponding version of the chain code is updated. Upgrade packages and related configurations are stored in the state database. Subsequently, when the client initiates a transaction, the node can call the upgraded chain code in the state database and execute the upgraded chain code to process the transaction, so that the client's transaction proceeds smoothly.
- the node because the node only confirms the identity of the client, it cannot avoid the logical defect chain code from the legitimate client. In this way, when the node processes the transaction according to the logical defect chain code, it is easy to generate errors and misplace the world of the transaction Status, reducing the accuracy of blockchain transactions.
- the embodiments of the present application provide a method and device for upgrading a chain code, which can improve the accuracy of blockchain transactions.
- an embodiment of the present application provides a method for upgrading a chain code.
- the method includes: an endorsement node (Endorse) obtains a first target version set corresponding to a chain code to be upgraded, and in an independent operating environment according to the first A target version set simulates the upgrade of the chain code to be upgraded. If the second world state world state of the first target version set is consistent with the first world state, the endorsing node upgrades the upgrade chain code outside of the independent operating environment.
- the first world state is the world state before the upgrade of the chain code to be upgraded, and the second world state is the world state after the upgrade of the chain code to be upgraded.
- the first target version set includes the upgrade package and upgrade of the first target version. Related configuration of the package, independent operating environment does not affect the operating environment outside itself.
- the method for upgrading the chain code provided in the embodiment of this application endorses the node.
- the simulation upgrade process in the memory of independent operation environment protection will not interfere with other applications outside the independent operation environment, that is, it will not cause damage to the actual transactions and blockchain data outside the independent operation environment.
- the second world state after the simulation upgrade is consistent with the first world state before the simulation upgrade, indicating that the first target version of the chain code has not tampered with the world state.
- the feasibility of the chain code upgrade has been verified in an independent operating environment.
- the probability that the first target version chain code tampered with the world state will be correspondingly reduced, so that the accuracy of transactions based on the untampered world state after the actual upgrade is improved, and blockchain transactions are improved. Security.
- the following steps may be performed: if the second world state of the first target version set is inconsistent with the first world state, the endorsing node Update the first target version set to the second target version set, the second target version set is the latest legal version set in the branch of the version tree to which the first target version set belongs, and the second world state and first world of the legal version set The status is consistent.
- the second world state of the version set of the first target version is inconsistent with the first world state
- the second world state of the first target version set is inconsistent with the first world state, wherein the first target version is a version corresponding to the first target version set.
- the endorsing node can learn the history of the illegal version set by querying the version tree, avoiding the client to call the chain code corresponding to the illegal version set for transactions, and improving transaction security.
- identity verification that is, from which client
- simulation upgrade which simplifies the chain code upgrade process.
- the version tree includes a root node and a child node, and the child node includes a first child node and a second child node.
- the first child node is a first-level child node of the root node
- the second child node is a division node.
- each first child node is a version root node of a domain chain code.
- the second root node of the domain chain code is connected to the version root node, and the first child node of the domain chain code and The second child node of the domain chain code forms a version tree branch of the domain chain code; each child node corresponds to a version set, and the version set includes the version upgrade package and the related configuration of the version upgrade package.
- Different domain chain codes have different chain codes.
- the first target version set is connected after the latest version version set in the version tree branch to which it belongs.
- the method of creating a version tree may be implemented as follows:
- the endorsement node determines the version tree branch to which the first target version set belongs according to the domain to which the chain code to be upgraded belongs, and connects the first target version set to the first After the latest version set in the branch of the version tree to which the target version set belongs.
- the version sets of different versions are connected in the order of the update time of the versions, and the new version set is based on the old version set at a higher level.
- the following steps may be performed: If the second world state of the first target version set is consistent with the first world state, Endorse The first target version set is stored in the state database, or if the second world state of the first target version set is inconsistent with the first world state, Endorse stores the second target version set in the state database.
- the legal latest version set is stored in the state database, which means that the legal version set can be called by the client, and the illegal version set is not stored in the state database, so the client will not call the illegal version.
- Set the corresponding chain code to reduce the risk of calling illegal version sets for transactions.
- an embodiment of the present application provides a device for upgrading a chain code.
- the device is provided with a processor and a memory.
- the memory is configured to store information including program instructions; the processor is configured to obtain a first target version set corresponding to the chain code to be upgraded, and the first target version set includes an upgrade package of the first target version and related configurations of the upgrade package. ; Simulate the upgrade of the chain code to be upgraded according to the first target version set in an independent operating environment, the independent operating environment does not affect the operating environment other than itself; if the second world state of the first target version set is the world state and the first If the world status is the same, the chain code to be upgraded is upgraded outside the independent operating environment.
- the first world state is to simulate the world state before the upgrade; the second world state is to simulate the world state after the upgrade. .
- the processor is further configured to update the first target version set to the second target version set if the second world state of the first target version set is inconsistent with the first world state, and the second target The version set is the latest legal version set in the branch of the version tree to which the first target version set belongs, and the second world state of the legal version set is consistent with the first world state.
- the second world state of the version set of the first target version is inconsistent with the first world state
- the second world state of the first target version set is inconsistent with the first world state, wherein the first target version is a version corresponding to the first target version set.
- the version tree includes a root node and a child node, and the child node includes a first child node and a second child node.
- the first child node is a first-level child node of the root node
- the second child node is a division node.
- each first child node is a version root node of a domain chain code.
- the second root node of the domain chain code is connected to the version root node, and the first child node of the domain chain code and The second child node of the domain chain code forms a version tree branch of the domain chain code; each child node corresponds to a version set, and the version set includes the version upgrade package and the related configuration of the version upgrade package.
- Different domain chain codes have different chain codes.
- the first target version set is connected after the latest version version set in the version tree branch to which it belongs.
- the processor is further configured to determine a version tree branch to which the first target version set belongs according to a domain to which the chain code to be upgraded belongs, and connect the first target version set to a version to which the first target version set belongs. After the latest version set in the tree branch.
- the version sets of different versions are connected in the order of the update time of the versions, and the new version set is based on the old version set at a higher level.
- the processor is further configured to: if the second world state of the first target version set is consistent with the first world state, Endorse stores the first target version set to a state database; or, if the first If the second world state of the target version set is inconsistent with the first world state, Endorse stores the second target version set to the state database.
- a chain code upgrading device has the function of implementing the method of any one of the first aspects.
- This function can be realized by hardware, and can also be implemented by hardware executing corresponding software.
- the hardware or software includes one or more modules corresponding to the above functions.
- a chain code upgrading device including: a processor and a memory; the memory is configured to store computer execution instructions; when the device is running, the processor executes the computer execution instructions stored in the memory, so that the The device executes the chain code upgrading method according to any one of the first aspects.
- an apparatus including: a processor; the processor is coupled to the memory and reads instructions in the memory, and then executes the method for upgrading a chain code according to any one of the first aspects according to the instructions.
- a computer-readable storage medium stores instructions that, when run on a computer, enable the computer to execute the method for upgrading a chain code according to any one of the first aspects.
- a computer program product containing instructions which, when run on a computer, enables the computer to execute the method for upgrading a chain code according to any one of the first aspects.
- a chip system includes a processor, and is configured to support the foregoing device to implement the functions involved in the foregoing first aspect.
- the chip system further includes a memory, which is used to store program instructions and data necessary for the device.
- the chip system can be composed of chips, and can also include chips and other discrete devices.
- a circuit system including a processing circuit configured to perform a function according to the first aspect described above.
- the technical effects brought by any one of the design methods in the second aspect to the ninth aspect can refer to the technical effects brought by the different design methods in the first aspect, and will not be repeated here.
- FIG. 1 is a schematic architecture diagram of a blockchain system according to an embodiment of the present application.
- FIG. 2 is a first schematic structural diagram of an endorsement node according to an embodiment of the present application.
- FIG. 3 is a schematic flowchart of a method for obtaining a target version set according to an embodiment of the present application
- FIG. 4 is a schematic diagram of a chain code upgrade process and a state of the world in the prior art
- FIG. 5 is a schematic flowchart of a chain code upgrade method according to an embodiment of the present application.
- FIG. 6 is a schematic diagram of a chain code upgrade process and a state of the world provided by an embodiment of the present application;
- FIG. 7 is a flowchart of a method for creating a version tree according to an embodiment of the present application.
- FIG. 8 is a schematic diagram of a version tree provided by an embodiment of the present application.
- FIG. 9 is a flowchart of a version tree management method according to an embodiment of the present application.
- FIG. 10 is a second structural diagram of an endorsement node provided by this embodiment.
- the network architecture and service scenarios described in the embodiments of the present application are used to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. With the evolution of the network architecture and the emergence of new service scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
- Ledger Used to record every transaction in the blockchain system, usually including the blockchain and the current state of the world. Among them, the blockchain consists of a set of blocks connected end to end.
- World State It is used to indicate the execution result and state of the transaction, and usually consists of a set of variables.
- FIG. 1 it is a schematic structural diagram of a blockchain system according to an embodiment of the present application.
- the blockchain system 100 includes a client 101, at least one endorsing node 102 (only one is exemplarily shown in FIG. 1), at least one submitting node 103, and at least one consensus node 104 (orderer) 104 ( Figure 1 shows only one by way of example).
- the client 101 and the endorsement node 102 may be connected through a wireless network (such as Wi-Fi, Bluetooth, a cellular mobile network, or the like) or a wired network (such as fiber optics), which is not limited in the embodiment of the present application.
- a wireless network such as Wi-Fi, Bluetooth, a cellular mobile network, or the like
- a wired network such as fiber optics
- the client 101 and the consensus node 104 may also be connected through a wireless network (such as Wi-Fi, Bluetooth, a cellular mobile network, or the like) or a wired network (such as fiber optics), which is not limited in the embodiment of the present application.
- a wireless network such as Wi-Fi, Bluetooth, a cellular mobile network, or the like
- a wired network such as fiber optics
- the consensus node 104 and the endorsement node 102 may also be connected through a wireless network (such as Wi-Fi, Bluetooth, cellular mobile network, etc.) or a wired network (such as optical fiber, etc.), which is not limited in this embodiment of the present application.
- a wireless network such as Wi-Fi, Bluetooth, cellular mobile network, etc.
- a wired network such as optical fiber, etc.
- the client 101 is configured to send a chain code deployment, a chain code upgrade request, and initiate a transaction request to the endorsement node 102 and the like. It is also used to send each transaction to the consensus node 104.
- a software development kit SDK is deployed in the client 101, and a user can use the SDK provided by the client 101 to create a chain code and submit a chain code upgrade request to trigger the chain code upgrade process.
- the client 101 stores a key, so that the key can be used for identity verification, so as to improve the security of the blockchain system 100.
- the clients mentioned above may include various computing devices with computing functions, personal digital assistant (PDA) computers, tablet computers, handheld devices, and laptop computers (laptops) computer), user equipment (UE), terminal equipment (terminal), and the like.
- PDA personal digital assistant
- UE user equipment
- terminal terminal
- the devices mentioned above are collectively referred to as terminals in this application.
- the endorsement node 102 is used to respond to the chaincode deployment request, chaincode upgrade request, transaction request, etc. initiated by the client 101 and verify the legitimacy of each request (including the legitimacy of the client's identity). If the request is a legitimate request, Then the endorsement node 102 performs an endorsement operation for the request, and feeds the endorsement result to the client 101, so that the client 101 sends the transaction to the consensus node 104 according to the endorsement result, so as to determine the order of the transaction in the blockchain.
- the endorsement node 102 in the embodiment of the present application may be implemented by a device or a function module in a device, which is not specifically limited in the embodiment of the present application.
- the foregoing function module may be a network element in a hardware device, a software function running on a hardware device, or a virtualized function instantiated on a platform (for example, a cloud platform).
- the submitting node 103 is used to obtain an ordered block chain sorted by the consensus node 104.
- the submitting node 103 may be implemented by a device, may also be a functional module in a device, or have other implementation manners, which are not specifically limited in this embodiment of the present application.
- the endorsement node 102 and the submission node 103 may be co-located in one device, and the device has the function of the endorsement node 102 and the function of the submission node 103.
- the endorsement node 102 and the submission node 103 may be implemented as different components in a device, or may be implemented as different functional modules in a device, which is not limited in the embodiment of the present application.
- the consensus node 104 is used to sort each transaction sent by the client 101 to ensure that each transaction is written into the blockchain in the correct order. It is also used to notify the submitting node 103 of the sorted transactions.
- the consensus node 104 may be implemented by a device, may also be a functional module within a device, or have other implementation manners, which are not specifically limited in this embodiment of the present application.
- the chain code upgrade method provided in the embodiment of the present application is mainly applied to the above endorsement node.
- the endorsement node in the embodiment of the present application may have the functions of the endorsement node 101 and the submission node 102 shown in FIG. 1, and when implemented by a hardware device FIG. 2 shows a schematic diagram of the hardware structure of an exemplary endorsement node.
- the endorsement node 200 includes at least one processor 201, a communication line 202, a memory 203, and at least one transceiver 204.
- the processor 201 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more processors for controlling the execution of the program of the solution of the present application. integrated circuit.
- CPU central processing unit
- ASIC application-specific integrated circuit
- the communication line 202 may include a path for transmitting information between the aforementioned components.
- the transceiver 204 is configured to communicate with other devices or communication networks, such as Ethernet, wireless access network (RAN), wireless local area networks (WLAN), and the like.
- Ethernet wireless access network
- WLAN wireless local area networks
- the memory 203 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), or other types that can store information and instructions Dynamic storage device, can also be electrically erasable programmable read-only memory (electrically erasable programmable read-only memory (EEPROM)), read-only compact disc (compact disc-read-only memory (CD-ROM) or other optical disc storage, optical disc storage (Including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), disk storage media or other magnetic storage devices, or can be used to carry or store desired program code in the form of instructions or data structures and can be used by a computer Any other media accessed, but not limited to this.
- the memory may exist independently, and is connected to the processor through the communication line 202. The memory can also be integrated with the processor.
- the memory 203 is configured to store a computer execution instruction for executing the solution of the present application, and the processor 201 controls execution.
- the processor 201 is configured to execute computer execution instructions stored in the memory 203, so as to implement the method for upgrading a chain code provided in the following embodiments of the present application.
- the memory 203 stores the simulation upgrade application code, version tree management application code, endorsement application code, transaction storage application code, submission application code, block assembly application code, Chain code life cycle management (Life Code of Chain Code, LSCC) application code, etc.
- the simulation upgrade application code is used to provide a chain code simulation upgrade function.
- the version tree management application code is used to provide the corresponding management functions of the version tree.
- the endorsement application code is used to provide endorsement functionality.
- the transaction storage application code is used to provide the function of accounting for each transaction.
- the submission application code is used to provide the ability to submit content to other types of nodes.
- the block assembly application code is used to provide the function of assembling blocks into a blockchain.
- LSCC is used to provide the function of chain code life cycle management.
- the computer-executable instructions in the embodiments of the present application may also be referred to as application program codes, which are not specifically limited in the embodiments of the present application.
- the processor 201 may include one or more CPUs, such as CPU0 and CPU1 in FIG. 2.
- the endorsement node 200 may include multiple processors, such as the processor 201 and the processor 207 in FIG. 2. Each of these processors can be a single-CPU processor or a multi-CPU processor.
- a processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).
- the endorsement node 200 may further include an output device 205 and an input device 206.
- the output device 205 is in communication with the processor 201 and can display information in a variety of ways.
- the output device 205 may be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. Wait.
- the input device 206 is in communication with the processor 201 and can receive user input in a variety of ways.
- the input device 206 may be a mouse, a keyboard, a touch screen device, or a sensing device.
- the above-mentioned endorsement node 200 may be a general-purpose device or a special-purpose device.
- the endorsement node 200 may be a desktop computer, a portable computer, a personal digital assistant (PDA), a mobile phone, a tablet computer, a wireless terminal device, or a device with a similar structure in FIG. 2.
- PDA personal digital assistant
- the embodiment of the present application does not limit the type of the endorsement node 200.
- the endorsement node obtains the target version set flow.
- the process of obtaining the target version set is the basis of the chain code upgrade method provided by the following embodiments of this application, and includes the following steps:
- the client receives an installation package upload instruction input by a user.
- the upgrade package is an installation package of the first target version of the chain code to be upgraded.
- the installation package is a version 2.0 installation package. Since the embodiments of the present application are mainly applied to the chain code upgrade process, the installation package herein may also be referred to as an upgrade package.
- the user enters the installation package upload instruction through a subcommand, or the user enters the installation package upload instruction through a User Interface (UI) method.
- UI User Interface
- the user can also enter the installation package upload instruction through other methods. This application The embodiment does not limit this.
- the client reports the installation package of the first target version of the chain code to be upgraded to the endorsing node.
- the endorsement node stores the installation package of the first target version.
- the endorsement node stores the installation package of the first target version, and then the corresponding installation package can be used to upgrade the chain code to be upgraded to the first target version according to user needs, which meets more Demand for new business.
- Fig. 4 Taking the precious metal transaction as an example, as shown in Fig. 4, suppose that at the beginning, enterprise A and enterprise B signed a contract for precious metal transactions, and used the blockchain technology to conduct precious metal transactions. The two parties agreed that their initial account quotas were 20 Million. The blockchain system performs the initialization process of this contract (that is, the chain code). The initial world state (such as the initial account status and initial account quota) in the contract is recorded on the ledger of each endorsed node. Among them, the account limit of both parties in the initial contract is: A's account limit is 200,000, and B's account limit is 200,000.
- Enterprise A paid RMB 20,000 to Enterprise B for the purchase of a certain precious metal.
- the account balance of enterprise A was 180,000, and the account balance of enterprise B was 220,000.
- Company B believes that the unit price of precious metals should be increased. Therefore, Company B and Company A re-sign a contract with a new unit price of precious metals recorded in the agreement.
- the blockchain system verifies whether the new chain code (contract) was submitted by enterprise A or enterprise B. If the new chain code is submitted by enterprise A or enterprise B, the blockchain system confirms that the new chain code is legal, and executes the new The chain code initialization process, the initial value of the account in the new chain code (contract) is recorded in the ledger.
- the new chain code has logical defects, it is likely to misplace the world state of the transaction (such as account status, account initial value, account balance, etc.). Still referring to Figure 4, the account balance of enterprise A should be 220,000, but due to a logical defect in the new chain code, the account balance of enterprise A was misplaced to 200,000. Similarly, the account balance of enterprise B was misplaced to 20 Million.
- an embodiment of the present application provides a method for upgrading a chain code. As shown in FIG. 5, the method includes the following steps:
- the client sends a chain code upgrade request to the endorsing node.
- the chain code upgrade request carries an upgrade proposal, which is used to request the endorsing node to upgrade the chain code to be upgraded to the first target version.
- the upgrade proposal includes the first target version installation package in Endorses the path in the node and the related configuration of the installation package.
- the related configuration of the installation package includes, but is not limited to, the name of the chain code corresponding to the installation package and the corresponding version of the chain code.
- users can upgrade the chaincode through the command line or UI.
- users can also upgrade the chaincode in other ways.
- the command line method is used, in one example, the user enters a chain code upgrade instruction through the client to trigger the client to execute S501.
- the client After the user enters the chain code upgrade instruction on the client, the client generates a code structure (Spec) according to the chain code upgrade instruction, generates a deployment spec according to the Spec, and generates an upgrade proposal according to the deployment Spec.
- the client can digitally sign the upgrade proposal.
- the client uses the private key to encrypt the upgrade proposal to implement signature of the upgrade proposal.
- the client sends a chain code upgrade request carrying an upgrade proposal to the endorsing node through a protocol such as Remote Procedure Call (Protocol, Protocol, RPC) to notify the endorsing node to upgrade the chain code to be upgraded to the first target version.
- a protocol such as Remote Procedure Call (Protocol, Protocol, RPC) to notify the endorsing node to upgrade the chain code to be upgraded to the first target version.
- the endorsement node obtains a first target version set corresponding to the chain code to be upgraded.
- the first target version set includes an upgrade package of the first target version and related configurations of the upgrade package.
- an upgrade package of a version is an installation package of the version.
- the endorsing node After receiving the chaincode upgrade request, the endorsing node calls the ProcessProposal interface to process the carried upgrade proposal and verifies the signature of the upgrade proposal. Specifically, the endorsement node uses the client's public key to verify whether the upgrade proposal comes from the client. The endorsement node can also verify the client's certificate and authority, thereby further strengthening the security of the blockchain system. If the verification is passed, the endorsement node obtains the installation package of the first target version and the related configuration of the installation package of the first target version according to the path of the installation package of the first target version in the upgrade proposal. For the convenience of description, the path of a version installation package and the related configuration of the version installation package are referred to as a version set in this article, which are described here collectively, and will not be described in detail below. In this way, the path of the first target version installation package and the related configuration of the first target version installation package are collectively referred to as the target version set.
- the endorsement node creates an independent operating environment.
- the independent running environment is a container, and the container is at least one application running independently and the running environment of at least one application.
- the independent running environment may also have other implementation forms, for example, being implemented as a running environment such as a virtual machine, which is not limited in the embodiment of the present application.
- the independent operating environment does not affect the operating environment outside of itself. For example, the data of the Host file system outside the independent operating environment will not be changed, and the data in the actual state database outside the independent operating environment will not be altered.
- the endorsement node calls an application programming interface (Application Programming Interface, API) to create an independent running environment, for example, the endorsement node calls an API interface to create a container.
- API Application Programming Interface
- the endorsement node can create an independent operating environment in advance before S501, and in the future, it can directly use the independent operating environment created in advance. Alternatively, the endorsement node is created after the first target version set is obtained. Of course, the independent running environment may also be created at another time. That is, the timing of creating an independent operating environment is not limited in the embodiment of the present application.
- the endorsement node obtains the first world state.
- the first world state is the state of the chain code to be upgraded before the upgrade.
- the embodiment of the present application does not limit the timing of obtaining the first world state.
- the endorsing node may execute S504 after S503, and may also execute S504 before or after S502.
- the endorsement node performs a simulated upgrade on the chain code to be upgraded according to the first target version set in an independent operating environment.
- the endorsement node compiles the chaincode indicated by the first target version set (that is, the installation package of the first target version and the related configuration of the first target version installation package), and generates an image according to the binary file of the compiled chaincode .
- the endorsement node starts the above-mentioned generated image, and executes the simulation upgrade process of the chaincode in the independent operating environment according to the information of the first target version set contained in the image. Specifically, the endorsement node performs a simulated upgrade of the chain code to be upgraded in the independent operating environment according to the first target version installation package and related configuration of the installation package, and initializes the first target version chain code after the simulated upgrade.
- the process of simulating the upgrade of the chain code is similar to the process of actually upgrading the chain code. The difference is that the simulation upgrade process is performed in an independent operating environment and does not affect other applications outside the independent operating environment in the endorsement node.
- the running of the program code that is, the simulation upgrade process will not interfere with other operations outside the independent running environment, and applications outside the independent running environment cannot perceive the above simulation upgrade process.
- the endorsement node obtains a second world state, and the second world state is a simulated world state of the chain code to be upgraded.
- the second world state corresponding to the initial target version of the chain code after initialization is: the account balance of enterprise A is 180,000, and the account balance of enterprise B is 220,000.
- the upgrade here in S507 is the actual chaincode upgrade process, including the initialization process of the first target version of the chaincode.
- the actions of the endorsement node in the above steps S501 to S507 can be executed by the processor 201 shown in FIG. 2 calling the application program code stored in the memory 203.
- the processor 201 calls the simulation upgrade application program code stored in the memory 203 to perform the simulation upgrade action of S505.
- the above actions can also be performed in other manners, which are not limited in the embodiment of the present application.
- the method for upgrading the chain code provided in the embodiment of this application endorses the node.
- the simulation upgrade process in the memory of independent operation environment protection will not interfere with other applications outside the independent operation environment, that is, it will not cause damage to the actual transactions and blockchain data outside the independent operation environment.
- the second world state after the simulation upgrade is consistent with the first world state before the simulation upgrade, indicating that the first target version of the chain code has not tampered with the world state.
- the feasibility of the chain code upgrade has been verified in an independent operating environment.
- the probability that the first target version chain code tampered with the world state will be correspondingly reduced, so that the accuracy of transactions based on the untampered world state after the actual upgrade is improved, and blockchain transactions are improved. Security.
- a method for managing a version tree of a chain code is also provided. As shown in FIG. 7, a process for creating a version tree is provided.
- the basis of the version tree management method includes the following steps:
- the endorsement node obtains a new version set corresponding to the chain code.
- the processor 201 of the endorsement node calls the LSCC in the memory 203, and the LSCC obtains a new version set corresponding to the chain code.
- the endorsement node determines the version tree branch to which the new version set belongs according to the domain to which the chain code corresponding to the new version set belongs.
- the processor 201 calls the version tree management application code in the memory 203, and the version tree management application code determines the version tree branch to which the new version set belongs according to the domain to which the chain code belongs.
- the version tree includes a root node and a child node.
- the root node is a virtual node and does not correspond to a version set with practical significance.
- the child node includes a first child node and a second child node.
- the first child node is a first-level child node of the root node.
- the second child node is a child node other than the first-level child node.
- Each first child node is a version root node of the domain chain code.
- the version root node directly or indirectly connects the second child node of the domain chain code, the first child node of the domain chain code and the second child of the domain chain code. Nodes constitute the version tree branch of the domain chain code.
- each child node corresponds to a version set
- a version set includes the installation package of the version and the related configuration of the installation package of the version.
- the version sets of different versions are linked according to the update time of the version, and the new version set is based on the old version set at a higher level.
- the domain can be used to describe the function of the chain code, and can also be used to distinguish different user services.
- the domain 1 corresponds to the chain code of the precious metal transaction
- the domain 2 corresponds to the charity chain code of the charity
- the domain 3 corresponds to the chain code of the stock transaction.
- the version tree in FIG. 8 includes a root node and a plurality of child nodes.
- the precious metal field branch includes a version root node (first-level child node) and other level child nodes of the field, where the version root node corresponds to a version set of version 1.0 (that is, 1.0 version of the chaincode installation package and 1.0 version of the chaincode installation package), the second-level child node connected to the root node of this version corresponds to the version set of version 2.0, and the third-level child node corresponds to the version set of version 3.0 .
- each node in the charity funds branch and the stock domain branch corresponds to a version set.
- the chain code to be upgraded is a chain code in the field of precious metal transactions between enterprise A and enterprise B, and enterprise A and enterprise B must upgrade the chain code to be upgraded to version 4.0 ,
- the new version is version 4.0, and the branch of the version tree to which the new version set belongs is the precious metal field branch shown in FIG. 8.
- the endorsement node connects the acquired new version set to the latest version version set in the branch of the version tree to which the new version set belongs.
- the processor 201 of the endorsement node calls the version tree management application code in the memory 203 to connect the new version set to the branch of the version tree to which it belongs.
- the latest version set is the 3.0 version set
- the newly obtained 4.0 version set is connected after the 3.0 version set.
- each version set is legal. Specifically, if the endorsing node determines that the second world state after the simulated upgrade of a certain version of the chaincode is consistent with the first world state before the simulated upgrade, indicating that the version of the chaincode has not tampered with the world state, the version set is determined to be a legal version Set, that is, in the embodiment of the present application, the legal version set refers to a version set that is consistent with the state of the world before and after the simulation upgrade, and a unified description is made here.
- the endorsing node determines that the second world state after the simulated upgrade of a certain version of the chaincode is inconsistent with the first world state before the simulated upgrade, it determines that the version set is an illegal version set, that is, in the embodiment of the present application, it is illegal
- the version set refers to a version set that is inconsistent with the state of the world before and after the simulation upgrade, and is described here uniformly.
- the processor 201 of the endorsement node initially determines that a certain version set is a legal version set, the simulation upgrade application code shown in FIG. 2 is called in an independent operating environment, and the use of the simulation upgrade application code is simulated. Private key 1 signs the version set.
- the processor 201 of the endorsing node calls the LSCC shown in Figure 2.
- the LSCC uses the public key 1 (the public key 1 and the private key 1 are used in pairs) to verify whether the version set has been simulated and upgraded.
- the application code processes, and if so, finally determines that the version set is a legal version set.
- each version set of the precious metal field chain code, the 1.0 version set, 2.0, 3.0 version set is a legal version set, the 4.0 version is an illegal version set; each version set of the charity field chain code, the 1.0 version set And 2.0 version sets are legal version sets; for each version set of the chain code in the stock field, the 1.0 version set and the 2.0 version set are legal version sets.
- the legal version set can be stored in the state database, which means that the legal version set in the state database can be called by the client, and the illegal version set is not stored in the state database, so the client does not call To the chain code corresponding to the illegal version set, reducing the risk of calling the illegal version set for transactions.
- the action of the endorsement node to connect the new version set to its own version tree branch can be used as a trigger condition to trigger the endorsement node to create the independent operating environment mentioned above.
- a trigger condition to trigger the endorsement node to create the independent operating environment mentioned above.
- the triggering condition of the event of creating an independent container is not limited to this, and this embodiment of the present application does not limit this.
- the endorsement node stores the version set of each version of the chaincode, that is, the endorsement node has a history of chaincode installation and each upgrade.
- the old version set is sequentially connected to the new version set, and the chain code version can be traced according to subsequent business requirements, and the appropriate version of the chain code can be selected as the chain code to provide transaction services to improve the user experience.
- the method includes the following steps:
- the endorsement node obtains a first target version set corresponding to the chain code to be upgraded.
- the endorsement node queries the version tree according to the first target version set.
- the first target version set further includes the domain to which the chain code belongs or the version tree branch to which the chain code belongs, and is used to instruct the endorsing node to query the corresponding version tree branch.
- the version tree of the endorsement node query is shown in FIG. 8, and the branch of the version tree to which the first target version chain code belongs is a branch in the precious metal field.
- the endorsement node determines whether the version set of the first target version exists in the version tree. If the version set of the first target version exists in the version tree and the version set of the first target version is an illegal version set, S904, S905, S906: If the version set of the first target version exists in the version tree and the version set of the first target version is a legal version set, execute S906; if the version set of the first target version does not exist in the version tree, perform S907.
- the first target version is a version of the first target version set.
- the endorsement node determines that the first target version set is an illegal version set.
- the first target version set is the 4.0 version set.
- the endorsement node can determine that the first target version set is also an illegal version set.
- the endorsement node updates the first target version set to the second target version set.
- the second target version set is the latest legal version set in the branch of the version tree to which the first target version set belongs.
- the endorsement node may use the latest legal version 3.0 in the precious metal field as the second target version, and accordingly, the 3.0 version set is used as the second target version set.
- the endorsement node uses the updated target version set as a valid version set.
- the endorsement node uses the 3.0 version set (that is, the second target version set) of the precious metal field in the state database as the valid version set, and the valid version set is used by the client to complete subsequent client-to-client interactions. Transaction.
- the endorsement node sets the 3.0 version set of the precious metal field in the state database to be valid, and when subsequent clients call the chain code in the precious metal field, the 3.0 version version set is directly called.
- the endorsement node directly sets the version 3.0 set in the state database to be valid. To be called by the client.
- the endorsement node simulates the upgrade of the chain code to be upgraded according to the first target version set in an independent operating environment.
- the user specifies that the precious metal domain chain code is upgraded to version 5.0. Since the precious metal domain branch of version 5.0 does not exist in the version tree, the endorsement node can perform the simulated upgrade process shown in FIG. 5.
- the endorsing node will use this version 5.0 chaincode as the chaincode for providing services to clients.
- the endorsing node executes the above S905 and S906 to update the first target version set to the second target version set, so as to re-determine the available valid version set, where the second target
- the version set is the latest legal version set in the branch of the version tree to which the first target version set belongs. For example, as shown in Figure 8, if the second world state of the first target version set (such as the 5.0 version set) is inconsistent with the first world state, it means that the version 5.0 chain code is likely to tamper with the world state of the blockchain system.
- the endorsement node executes S905 and S906 to re-determine the 3.0 version set in the precious metal field shown in FIG. 8 as a valid version set, and uses the 3.0 version set to provide services to the client.
- the version tree management method provided by the embodiment of the present application, when it is necessary to roll back to a certain chain code version, it can quickly roll back to the latest valid version set according to the version tree, and the valid version set will not tamper with the state of the world. So as to ensure the success of transactions between clients. For example, when a user repeatedly uploads an illegal version set, the endorsing node can learn the history of the illegal version set by querying the version tree, preventing the client from calling the chain code corresponding to the illegal version set for transactions, and improving transaction security. In addition, since it is known whether the version set is an illegal version set by querying the version tree, there is no need to perform operations such as identity verification (that is, from which client) and simulation upgrade, which simplifies the chain code upgrade process.
- the business scenario related to the version tree management of this application is not limited to the embodiment shown in FIG. 9.
- the blockchain system may fail and users cannot upgrade the chain code in time.
- the endorsement node can roll back to the latest version of the valid version set according to the version tree, thereby ensuring that the client calls the latest version of the valid version set for transactions.
- each functional module or functional unit may be divided corresponding to each function, or two or more functions may be integrated into one.
- Processing module The above integrated modules may be implemented in the form of hardware, or in the form of software functional modules or functional units.
- the division of modules or units in the embodiments of the present application is schematic, and is only a logical function division. In actual implementation, there may be another division manner.
- FIG. 10 shows a possible structure diagram of an endorsement node involved in the above embodiment.
- the endorsement node 1000 includes a storage unit 1001, a processing unit 1002, and a communication unit 1003.
- the storage unit 1001 may store, for example, a version tree corresponding to a chain code.
- the processing unit 1002 is configured to control and manage the actions of the endorsement node 1000 to execute the technical solution steps in the embodiment of the present application.
- the communication unit 1003 is configured to support the endorsement node 1000 to communicate with other devices in the communication system shown in FIG. 1. For example, the endorsement node 1000 is supported to execute S501 in FIG. 5.
- the storage unit 1001 may be implemented as the memory 203 of the endorsement node in FIG. 2.
- the processing unit 1002 may be implemented as the processor 201 or 207 of the endorsement node in FIG. 2, and the communication unit 1003 may be implemented as the transceiver 204 of the endorsement node in FIG. 2.
- An embodiment of the present application further provides a computer-readable storage medium.
- the computer-readable storage medium has instructions stored therein.
- the endorsement node executes the instruction, the endorsement node executes the execution by the endorsement node in the method flow shown in the foregoing method embodiment. Each step.
- the computer-readable storage medium may be, for example, but is not limited to, an electric, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (non-exhaustive list) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (Read-Only Memory (ROM)), Erasable Programmable Read Only Memory (EPROM), registers, hard disk, optical fiber, portable compact disk read-only memory (Compact Disc Read-Only Memory, CD-ROM ), An optical storage device, a magnetic storage device, or any suitable combination of the foregoing, or any other form of computer-readable storage medium known in the art.
- An exemplary storage medium is coupled to the processor such that the processor can read information from, and write information to, the storage medium.
- the storage medium may also be an integral part of the processor.
- the processor and the storage medium may be located in an Application Specific Integrated Circuit (ASIC).
- ASIC Application Specific Integrated Circuit
- the computer-readable storage medium may be any tangible medium containing or storing a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
- the embodiment of the present application further provides a chip system, which is applied to an endorsement node.
- the chip system includes a processor for supporting the endorsement node to implement the methods in the foregoing embodiments, for example, a chain code to be upgraded in a container. Perform a simulated upgrade.
- the chip system further includes a memory. This memory is used to store the necessary program instructions and data of the endorsement node. Of course, the memory may not be in the chip system.
- the chip system may be composed of a chip, and may also include a chip and other discrete devices, which are not specifically limited in the embodiments of the present application.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Business, Economics & Management (AREA)
- Accounting & Taxation (AREA)
- General Business, Economics & Management (AREA)
- Strategic Management (AREA)
- Finance (AREA)
- Stored Programmes (AREA)
Abstract
L'invention a trait au domaine technique des chaînes de blocs et concerne un procédé et un dispositif de de mise à niveau de code de chaîne. Le procédé comprend les étapes suivantes : un nœud d'approbation (102) obtient un premier ensemble de versions cibles correspondant à un code de chaîne devant être mis à niveau (S502), puis effectue une mise à niveau de simulation sur le code de chaîne devant être mis à niveau en fonction de la première version cible définie dans un environnement d'exploitation indépendant (S505) ; si un second état du premier ensemble de versions cibles est cohérent avec un premier état, le nœud d'approbation (102) met à niveau le code de chaîne devant être mis à niveau à l'extérieur de l'environnement d'exploitation indépendant (S502). Le premier ensemble de versions cibles comprend un progiciel de mise à niveau d'une première version cible ainsi qu'une configuration associée du progiciel de mise à niveau ; l'environnement d'exploitation indépendant n'affecte pas l'environnement d'exploitation à l'extérieur de l'environnement d'exploitation indépendant ; le premier état est l'état du code de chaîne devant être mis à niveau avant la mise à niveau de simulation, et le second état est l'état du code de chaîne devant être mis à niveau après la mise à niveau de simulation.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810591924.1 | 2018-06-07 | ||
CN201810591924.1A CN110580624B (zh) | 2018-06-07 | 2018-06-07 | 链码升级方法及装置 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2019233454A1 true WO2019233454A1 (fr) | 2019-12-12 |
Family
ID=68770083
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2019/090206 WO2019233454A1 (fr) | 2018-06-07 | 2019-06-05 | Procédé et dispositif de mise à niveau de code de chaîne |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN110580624B (fr) |
WO (1) | WO2019233454A1 (fr) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2024002468A1 (fr) * | 2022-06-28 | 2024-01-04 | Huawei Cloud Computing Technologies Co., Ltd. | Mises à jour automatisées à chaud de contrat intelligent |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111221568B (zh) * | 2020-01-10 | 2023-05-26 | 杭州趣链科技有限公司 | 一种基于物理机部署的Fabric链码生命周期管理系统 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106709704A (zh) * | 2016-11-23 | 2017-05-24 | 杭州秘猿科技有限公司 | 一种基于许可链的智能合约升级方法 |
CN106919419A (zh) * | 2017-02-03 | 2017-07-04 | 中钞信用卡产业发展有限公司北京智能卡技术研究院 | 区块链上的智能合约程序的更新方法及装置 |
WO2018018992A1 (fr) * | 2016-07-25 | 2018-02-01 | 中兴通讯股份有限公司 | Système, appareil et procédé de chaîne de blocs d'application |
CN107832139A (zh) * | 2017-09-26 | 2018-03-23 | 上海点融信息科技有限责任公司 | 用于管理区块链节点的计算资源的方法、设备和系统 |
CN107943580A (zh) * | 2017-11-13 | 2018-04-20 | 上海点融信息科技有限责任公司 | 用于管理区块链节点处的用户智能合约的方法以及设备 |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180123779A1 (en) * | 2016-11-01 | 2018-05-03 | Jiangang Zhang | Flexible Blockchain Smart-Contract Deployment |
US11176519B2 (en) * | 2016-11-11 | 2021-11-16 | International Business Machines Corporation | Smart contract admission check and fault tolerance in a blockchain |
CN106775619B (zh) * | 2016-11-12 | 2020-05-12 | 杭州复杂美科技有限公司 | 灵活区块链架构系统 |
CN106778329B (zh) * | 2016-11-28 | 2020-12-04 | 中国银行股份有限公司 | 一种区块链智能合约模板动态更新方法、装置及系统 |
TWI614713B (zh) * | 2017-01-23 | 2018-02-11 | 現代財富控股有限公司 | 基於區塊鏈的智能合約版本控管系統及其方法 |
CN107562513B (zh) * | 2017-07-18 | 2020-08-07 | 杭州趣链科技有限公司 | 一种基于java的智能合约生命周期的管理方法 |
CN107464148A (zh) * | 2017-08-23 | 2017-12-12 | 众安信息技术服务有限公司 | 一种基于联盟链的智能合约升级方法和系统 |
-
2018
- 2018-06-07 CN CN201810591924.1A patent/CN110580624B/zh active Active
-
2019
- 2019-06-05 WO PCT/CN2019/090206 patent/WO2019233454A1/fr active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2018018992A1 (fr) * | 2016-07-25 | 2018-02-01 | 中兴通讯股份有限公司 | Système, appareil et procédé de chaîne de blocs d'application |
CN106709704A (zh) * | 2016-11-23 | 2017-05-24 | 杭州秘猿科技有限公司 | 一种基于许可链的智能合约升级方法 |
CN106919419A (zh) * | 2017-02-03 | 2017-07-04 | 中钞信用卡产业发展有限公司北京智能卡技术研究院 | 区块链上的智能合约程序的更新方法及装置 |
CN107832139A (zh) * | 2017-09-26 | 2018-03-23 | 上海点融信息科技有限责任公司 | 用于管理区块链节点的计算资源的方法、设备和系统 |
CN107943580A (zh) * | 2017-11-13 | 2018-04-20 | 上海点融信息科技有限责任公司 | 用于管理区块链节点处的用户智能合约的方法以及设备 |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2024002468A1 (fr) * | 2022-06-28 | 2024-01-04 | Huawei Cloud Computing Technologies Co., Ltd. | Mises à jour automatisées à chaud de contrat intelligent |
Also Published As
Publication number | Publication date |
---|---|
CN110580624A (zh) | 2019-12-17 |
CN110580624B (zh) | 2022-02-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109981679B (zh) | 在区块链网络中执行事务的方法和装置 | |
TWI737944B (zh) | 基於區塊鏈的交易執行方法及裝置、電子設備 | |
TWI722256B (zh) | 業務處理方法及裝置 | |
WO2020233048A1 (fr) | Procédé et système de génération de logiciel personnalisé, dispositif électronique et support d'informations | |
CN110874739B (zh) | 实现高完整性、高带宽、低延迟、安全处理的分布式计算和存储网络 | |
EP3605946B1 (fr) | Système de planification de ressources d'entreprise distribué à base de registre | |
JP7228322B2 (ja) | ブロックチェーン・ネットワークにおける自動コミット・トランザクション管理 | |
WO2019125576A1 (fr) | Suivi de transfert | |
CN113056760A (zh) | 多租户环境中具有去中心化分类账的高级智能合约 | |
US20240289774A1 (en) | Method for processing cargo allocation information, electronic device, and non-transitory computer-readable storage medium | |
US11194911B2 (en) | Blockchain technique for agile software development framework | |
US9912759B2 (en) | Dynamically generating solution stacks | |
WO2021031472A1 (fr) | Procédé et dispositif de traitement de contrat intelligent, dispositif informatique et support de stockage | |
US11070563B2 (en) | Trace-based transaction validation and commitment | |
US20160260157A1 (en) | Rapid service orchestration and management | |
US20180191865A1 (en) | Global cloud applications management | |
US10656939B2 (en) | Modeling lifetime of hybrid software application using application manifest | |
CN110959165A (zh) | 用于自动验证云服务代理系统中的要约的功能的技术 | |
CN113505520A (zh) | 用于支持异构联邦学习的方法、装置和系统 | |
CN111311407A (zh) | 基于区块链系统的数据处理方法、装置及电子设备 | |
WO2019233454A1 (fr) | Procédé et dispositif de mise à niveau de code de chaîne | |
US11716380B2 (en) | Secure self-contained mechanism for managing interactions between distributed computing components | |
CN117874064A (zh) | 多协议云环境中的请求处理 | |
WO2021114075A1 (fr) | Procédé, système et appareil de traitement de cote de crédit basés sur une chaîne de blocs, et support | |
US10924491B2 (en) | Process manager for digital communication |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19815615 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 19815615 Country of ref document: EP Kind code of ref document: A1 |