[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

WO2020206848A1 - Method and device for smart contract upgrade, blockchain node device, and medium - Google Patents

Method and device for smart contract upgrade, blockchain node device, and medium Download PDF

Info

Publication number
WO2020206848A1
WO2020206848A1 PCT/CN2019/093485 CN2019093485W WO2020206848A1 WO 2020206848 A1 WO2020206848 A1 WO 2020206848A1 CN 2019093485 W CN2019093485 W CN 2019093485W WO 2020206848 A1 WO2020206848 A1 WO 2020206848A1
Authority
WO
WIPO (PCT)
Prior art keywords
smart contract
contract
upgrade
old
new
Prior art date
Application number
PCT/CN2019/093485
Other languages
French (fr)
Chinese (zh)
Inventor
周茂青
Original Assignee
深圳市网心科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市网心科技有限公司 filed Critical 深圳市网心科技有限公司
Publication of WO2020206848A1 publication Critical patent/WO2020206848A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information

Definitions

  • This application relates to the field of smart contracts under blockchain technology, and in particular to a smart contract upgrade method, device, blockchain node equipment, and computer-readable storage medium.
  • Blockchain technology was originally used to record every Bitcoin transaction in the bitcoin network, which is a kind of accounting mechanism.
  • Ethereum has greatly expanded the blockchain by embedding smart contracts.
  • the scope of application of the technology and the functions that can be achieved, but one of the characteristics of the blockchain technology is that the stored data cannot be completely deleted (unless you have a node device that can tamper with more than 50% of the entire blockchain network in a short time The ability to store data), when the content of the smart contract needs to be upgraded or revised, it cannot be directly replaced under the traditional mechanism.
  • the existing solution provided by Ethereum separate the code logic and data of the smart contract to form two different contracts, namely the logic contract and the data contract, so as to realize the replacement of the implementation logic while keeping the data unchanged, thereby
  • the business logic is upgraded separately. But the resulting problem is that the upgrade operation of the logic contract actually first needs to redeploy a new logic contract on the blockchain network.
  • the new logic contract and the old logic contract each have their own contract address.
  • the purpose of this application is to provide a smart contract upgrade method, device, block chain node equipment, and computer readable storage medium, which aims to solve as much as possible the existing process of upgrading smart contracts due to the existence of two different contract addresses.
  • the user needs to complete various problems caused by the replacement of the old and new contract addresses.
  • this application first provides a smart contract upgrade method, including:
  • obtain the smart contract upgrade request including:
  • the method further includes:
  • the smart contract upgrade method further includes:
  • the initiation information of the smart contract upgrade request is sent to the user who deployed the old smart contract.
  • verifying whether the smart contract upgrade request is legal including:
  • verifying whether the smart contract upgrade request is legal including:
  • the smart contract upgrade method further includes:
  • this application also provides a smart contract upgrade device, which includes:
  • the smart contract upgrade request obtaining unit is used to obtain the smart contract upgrade request
  • the old contract address and the new contract code acquisition unit is used to determine the old contract address of the replaced old smart contract according to the smart contract upgrade request, and extract the new contract code of the new smart contract from the smart contract upgrade request;
  • the corresponding relationship establishment and deployment unit is used to establish the corresponding relationship between the old contract address and the new contract code, and deploy the corresponding relationship in the newly formed block of the blockchain.
  • the smart contract upgrade request obtaining unit includes:
  • the block chain data pool obtaining subunit is used to obtain the smart contract upgrade request from the block chain data pool.
  • the smart contract upgrade device further includes:
  • the legality verification unit is configured to verify whether the smart contract upgrade request is legal before establishing the correspondence between the old contract address and the new contract code;
  • the legality verification pass execution unit is configured to execute the step of establishing the correspondence between the old contract address and the new contract code only when the smart contract upgrade request is legal.
  • the smart contract upgrade device further includes:
  • the illegal processing unit is configured to send the initiation information of the smart contract upgrade request to the user who deployed the old smart contract when the smart contract upgrade request is verified to be not legal.
  • the legality verification unit includes:
  • the user ID consistency verification subunit is used to verify whether the user ID that initiated the smart contract upgrade request is consistent with the user ID that deployed the old smart contract;
  • the first legality determination subunit is configured to determine that the smart contract upgrade request is legal when the user ID that initiated the smart contract upgrade request is consistent with the user ID that deployed the old smart contract;
  • the first illegality determination subunit is used to determine that the smart contract upgrade request is not legal when the user ID that initiated the smart contract upgrade request is not consistent with the user ID that deployed the old smart contract.
  • the legality verification unit includes:
  • the upgrade verification address list extraction subunit is used to extract the upgrade verification address list from the old smart contract; wherein a preset number of addresses are recorded in the upgrade verification address list;
  • a signature information acquisition subunit configured to extract signature information corresponding to the new smart contract from the smart contract upgrade request
  • the signature requirement required for the upgrade satisfies the judging subunit, which is used to judge whether the signature information can meet the requirement of the upgrade verification address list for the signature corresponding to the recorded address;
  • the second legality determination subunit is used to determine that the smart contract upgrade request is legal when the requirements are met;
  • the second illegality determination subunit is used to determine that the smart contract upgrade request does not have legality when the requirement is not met.
  • the smart contract upgrade device further includes:
  • the smart contract call request receiving unit is used to receive the smart contract call request
  • the target smart contract address determining unit is configured to determine the target smart contract address according to the smart contract call request
  • the corresponding latest contract code determining and invoking unit is used to determine the corresponding new contract code in the latest block deployed and containing the target smart contract address, and execute the new contract code to complete the smart contract invocation request.
  • the present application further provides a blockchain node device, the blockchain node device includes a memory, a processor, and a bus, and the memory stores an intelligence that can run on the processor.
  • a contract upgrade program where the smart contract upgrade program is transmitted to the processor by the bus, and when executed by the processor, the smart contract upgrade method as described in the above content is implemented.
  • this application further provides a computer-readable storage medium on which a smart contract upgrade program is stored, and the smart contract upgrade program can be executed by one or more processors, In order to achieve the smart contract upgrade method described in the above content.
  • This application also provides a smart contract upgrade device, a blockchain node device and a computer-readable storage medium, which have the above-mentioned beneficial effects, and will not be repeated here.
  • Figure 1 is a flowchart of a smart contract upgrade method provided by an embodiment of the application
  • FIG. 2 is a flowchart of another smart contract upgrade method provided by an embodiment of the application.
  • FIG. 3 is a flowchart of a method for verifying the legitimacy of an upgrade request based on a user ID in the smart contract upgrade method provided by an embodiment of the application;
  • FIG. 4 is a flowchart of a method for verifying the legality of an upgrade request based on a signature in the smart contract upgrade method provided by the embodiment of the application;
  • FIG. 5 is a flowchart of a method for invoking a smart contract provided by an embodiment of the application
  • FIG. 6 is a structural block diagram of a smart contract upgrade device provided by an embodiment of the application.
  • FIG. 7 is a schematic structural diagram of a blockchain node device provided by an embodiment of the application.
  • FIG. 1 is a flowchart of a smart contract upgrade method provided by an embodiment of the application, which includes the following steps:
  • This step is to obtain the smart contract upgrade request for subsequent smart contract upgrades.
  • One way to obtain the smart contract upgrade request is to obtain the smart contract upgrade request from the blockchain data pool in the blockchain network.
  • the blockchain network is usually used to store transaction data
  • the blockchain data pool is also usually called a transaction data pool.
  • various requests initiated by users uploaded through each blockchain node device will be aggregated into the data pool.
  • the upgrade party will initiate a smart contract upgrade request to the blockchain network through the blockchain node device, so that the blockchain network can obtain the smart contract upgrade request from the blockchain data pool.
  • the smart contract upgrade is completed in response to the smart contract upgrade request.
  • the smart contract upgrade request in order to complete the upgrade of the smart contract, usually includes at least the content of the new smart contract (ie code or different forms of code, such as bytecode that is easy to be executed by the computer after compilation, etc.) and needs to be replaced ,
  • the relevant information of the upgraded old smart contract (such as the most important contract address).
  • relevant information such as legality verification, time stamps, and other information or data used to achieve special requirements can also be included in the smart contract upgrade request or with the The smart contract upgrade request is sent together and uploaded to the blockchain data pool.
  • S102 Determine the old contract address of the replaced old smart contract according to the smart contract upgrade request, and extract the new contract code of the new smart contract from the smart contract upgrade request;
  • this step aims to determine two parameters according to the smart contract upgrade request.
  • One is the contract code of the new smart contract.
  • This step and subsequent steps will use the "new contract code” to refer to; the second is the new contract code.
  • the smart contract corresponds to the contract address of the old smart contract that has been deployed in the blockchain network and needs to be upgraded and replaced. This step and subsequent steps will use the "old contract address" to refer to.
  • smart contract calls are implemented through smart contract call requests initiated by users. This is because the smart contract call request contains the address of the target smart contract that the user needs to call, that is, the target contract address, and each smart contract When the contract is deployed to the blockchain network, the corresponding relationship between the contract address and the contract code will be established, so that after the target contract address is extracted from the smart contract call request, the corresponding contract can be successfully called according to the corresponding relationship Code, and implement the smart contract function by executing the contract code.
  • Key-Value Key-value pair
  • the contract address is Key
  • the contract code is Value.
  • Key1 represents the contract address of the old smart contract
  • Value1 represents the contract code of the old smart contract
  • S103 Establish a corresponding relationship between the old contract address and the new contract code, and deploy the corresponding relationship in the newly formed block of the blockchain.
  • this step aims to establish the corresponding relationship between the old contract address and the new contract code, and deploy the corresponding relationship in the newly formed block of the blockchain.
  • the contract code of the new smart contract determined according to the smart contract upgrade request can be represented by Value2, so the operation performed in this step is to establish the correspondence between Key1 and Value2, and deploy the new correspondence in the latest In the formed block, users can successfully call the upgraded smart contract code without replacing Key1 with Key2 in their own applications.
  • the corresponding relationship between the old contract address and the new contract code established in this application is a new operation of the corresponding relationship, rather than a traditional replacement operation, only due to the non-deletable feature of the blockchain Yes, but there will not be call confusion because Key1 corresponds to the two contract addresses of Value1 and Value2 at the same time.
  • the chain relationship and atomicity between the blocks in the blockchain when a smart contract is called, there will always be The corresponding relationship is called in the nearest block, so based on the fact that the new smart contract must be deployed on the blockchain network later than the old smart contract, the new smart contract must be deployed after the block where the old smart contract is located. In the block, based on this situation, the corresponding relationship cannot be modified in time, there is a one-to-many situation, and there will be no problems in the execution and call process.
  • legality verification can eliminate the above hidden dangers through the legality verification steps.
  • legality verification can be achieved in a variety of specific ways. For example, it can be achieved by judging whether the initiating users of the new and old smart contracts are the same user, or by signing, public and private key mechanisms, etc. A similar mechanism can be implemented, and the most suitable method can be flexibly selected according to the specific situation, and there is no specific limitation here.
  • Figure 2 is a flowchart of another smart contract upgrade method provided in an embodiment of the application. It is different from Embodiment 1. This embodiment considers the security of smart contract upgrades. On the basis, the legality verification steps for the smart contract upgrade request are added, and a specific implementation method is given, including the following steps:
  • S202 Determine the old contract address of the replaced old smart contract according to the smart contract upgrade request, and obtain the new contract code of the new smart contract from the smart contract upgrade request;
  • the verification of the validity of the smart contract upgrade request is placed after S202, before S204 and S205, and after S202, because some parameters or data obtained in step S202 are needed to implement the legality verification step of S203. If it is not necessary to execute S202 to determine whether the smart contract upgrade request is legal, it can also be placed after S201 and before S202.
  • S204 Send the initiation information of the smart contract upgrade request to the user who deployed the old smart contract;
  • This step is based on the verification result of S203 that the smart contract upgrade request is not legal.
  • this embodiment provides a specific follow-up processing method, which is to send the initiation information of the smart contract upgrade request
  • the initiation information should include which user initiated the smart contract upgrade request, and by telling this part of the information to users who have the right to upgrade the old smart contract to inform them that there are users trying Modify the smart contract that you have deployed.
  • the blockchain network can also issue a warning to fake users after verifying this behavior, and the serious ones can be added to the blacklist.
  • S205 Establish a corresponding relationship between the old contract address and the new contract code, and deploy the corresponding relationship in the newly formed block of the blockchain.
  • This step is based on the verification result of S203 that the smart contract upgrade request is legal. Therefore, the corresponding relationship between the old contract address and the new contract code will be added on this basis, and subsequent deployment operations will be completed.
  • Figure 3 is a flowchart of a method for verifying the legitimacy of a user ID-based upgrade request in the smart contract upgrade method provided in an embodiment of the application.
  • this embodiment provides a A specific method for verifying the legality of a smart contract upgrade request includes the following steps:
  • this application here provides a method for judging whether the smart contract upgrade request is legal based on the user ID, that is, by judging the user who initiated the smart contract upgrade request and the user who deployed the old smart contract Whether it is the same user to determine whether the smart contract upgrade request is legal, because the upgrade operation is often limited to the original author's implementation, and upgraders who are not the original author are usually regarded as counterfeiters.
  • the user ID described here is a feature information that can be used to uniquely identify a blockchain user. It can be called differently in different application scenarios, such as user address, user identification code, user feature code, etc. , Within the scope of the idea of this step, all should belong to the protection scope of this application.
  • the legality verification method based on the user ID is more suitable for individual deployment users, that is, there are usually no other approved users to perform smart contract upgrade operations.
  • this application also provides the user ID-based legality verification method for upgrade requests as shown in Figure 4, which is suitable for team deployment users.
  • the address upgrade verification address list can flexibly set the number of address corresponding signatures required to pass legality verification, so that users who deploy non-old smart contracts can also complete smart contract upgrade operations through this mechanism, including the following steps:
  • the upgrade verification address list records a preset number of addresses. It should be noted that the multiple addresses recorded are suitable for the legality verification of the upgrade. Check whether the smart contract upgrade request carries the required number or The signature given by the address of the object completes the verification.
  • This step is based on the fact that the signature information is also included in the smart contract upgrade request.
  • S403 Determine whether the signature information meets the requirements of the upgrade verification address list for the signature corresponding to the recorded address, if it meets the requirements, execute S404, otherwise execute S405;
  • this requirement can be flexibly set according to the actual situation, such as setting the signature of more than the preset number of addresses, the signature of certain specific addresses, and even each item that needs to be recorded in the upgrade verification address list.
  • the signature corresponding to the address can be flexibly selected according to all the special requirements that may exist in the actual situation, and there is no specific limitation here.
  • S405 Determine that the smart contract upgrade request is not legal.
  • This embodiment provides two legality verification methods suitable for different scenarios through Figure 3 and Figure 4 respectively. Of course, it does not mean that there are no other implementation solutions besides these two methods. The above two solutions are only for common A feasible solution exists in the application scenario.
  • Figure 5 is a flow chart of a smart contract invocation method provided by an embodiment of this application. It shows how the user can invoke the smart contract through the same contract address after the smart contract upgrade method provided in any of the above embodiments corresponding to this application.
  • the process of completing the target operation to the new contract code includes the following steps
  • S502 Determine the target smart contract address according to the smart contract call request
  • S503 Determine the corresponding new contract code in the latest block deployed and containing the target smart contract address, and execute the new contract code to complete the smart contract call request.
  • FIG. 6 is a structural block diagram of a smart contract upgrade device provided by an embodiment of the application.
  • the device may include:
  • the smart contract upgrade request obtaining unit 100 is configured to obtain the smart contract upgrade request
  • the old contract address and new contract code acquisition unit 200 is used to determine the old contract address of the replaced old smart contract according to the smart contract upgrade request, and extract the new contract code of the new smart contract from the smart contract upgrade request;
  • the correspondence relationship establishment and deployment unit 300 is used to establish the correspondence relationship between the old contract address and the new contract code, and deploy the correspondence relationship in the newly formed block of the blockchain.
  • the smart contract upgrade acquiring unit 100 may include:
  • the block chain data pool obtaining subunit is used to obtain the smart contract upgrade request from the block chain data pool.
  • the smart contract upgrade device may also include:
  • the legality verification unit is used to verify whether the smart contract upgrade request is legal before establishing the correspondence between the old contract address and the new contract code;
  • the legality verification passes the execution unit and is used to execute the step of establishing the correspondence between the old contract address and the new contract code only when the smart contract upgrade request is legal.
  • the smart contract upgrade device may also include:
  • the illegal processing unit is used to send the initiation information of the smart contract upgrade request to the user who deployed the old smart contract when the smart contract upgrade request is verified to be not legal.
  • the legality verification unit may include:
  • the user ID consistency verification subunit is used to verify whether the user ID that initiated the smart contract upgrade request is consistent with the user ID that deployed the old smart contract;
  • the first legality determination subunit is used to determine that the smart contract upgrade request is legal when the user ID that initiated the smart contract upgrade request is consistent with the user ID that deployed the old smart contract;
  • the first illegality determination subunit is used to determine that the smart contract upgrade request is not legal when the user ID that initiated the smart contract upgrade request is inconsistent with the user ID that deployed the old smart contract.
  • the legality verification unit may include:
  • the upgrade verification address list extraction subunit is used to extract the upgrade verification address list from the old smart contract; among them, the upgrade verification address list records a preset number of addresses;
  • the signature information acquisition subunit is used to extract the signature information corresponding to the new smart contract from the smart contract upgrade request;
  • the signature requirements required for the upgrade meet the judging subunit, which is used to determine whether the signature information can meet the requirements for the signature corresponding to the recorded address in the upgrade verification address list;
  • the second legality determination subunit is used to determine the legality of the smart contract upgrade request when the requirements are met;
  • the second illegality determination sub-unit is used to determine that the smart contract upgrade request is not legal when the requirements are not met.
  • the smart contract upgrade device may also include:
  • the smart contract call request receiving unit is used to receive the smart contract call request
  • the target smart contract address determination unit is used to determine the target smart contract address according to the smart contract call request
  • the corresponding latest contract code determination and calling unit is used to determine the corresponding new contract code in the latest block deployed with the target smart contract address, and execute the new contract code to complete the smart contract call request.
  • This embodiment exists as a device embodiment corresponding to the above method embodiment.
  • the above functional units are also described and explained in the above method embodiment.
  • this embodiment also has a method embodiment. All the beneficial effects of, will not be repeated here.
  • the blockchain node device 400 includes a memory 410, a processor 420, and a bus 430.
  • the memory 410 stores a smart contract upgrade program that can run on the processor 420, and the smart contract upgrade program is transmitted to the processor 420 through the bus 430. , And when executed by the processor 420, each step in the smart contract upgrade method described in the above embodiment can be implemented.
  • the memory 410 includes at least one type of readable storage medium.
  • the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), magnetic memory, magnetic disk, and optical disk.
  • the memory 410 may be an internal storage unit of the blockchain node device 400 in some embodiments, such as a hard disk of the blockchain node device 400. In some other embodiments, the memory 410 may also be an external storage device of the blockchain node device 400, such as a plug-in hard disk or a smart media card (SMC) equipped on the blockchain node device 400, Secure Digital (SD) card, Flash Card, etc. Further, the memory 410 may also be composed of an internal storage unit and an external storage device at the same time. Further, the memory 410 can be used not only to store various application software and various data installed in the blockchain node device 400, but also to temporarily store data that has been output or will be output.
  • SMC smart media card
  • the processor 420 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips, and is used to run program codes or process data stored in the memory 410 , Such as smart contract upgrade procedures.
  • CPU central processing unit
  • controller a controller
  • microcontroller a microprocessor
  • microprocessor or other data processing chips
  • the bus 430 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the bus can be divided into address bus, data bus, control bus, etc.
  • bidirectional hollow indicator line is used in Fig. 7, but it does not mean that there is only one bus or one type of bus.
  • the disclosed system, device, and method may be implemented in other ways.
  • the device embodiments described above are merely illustrative, for example, the division of units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or integrated. To another system, or some features can be ignored, or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • each unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • the technical solution of this application essentially or the part that contributes to the existing technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , Including several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method given in each embodiment of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program code .

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

A method and device for a smart contract upgrade, a blockchain node device, and a computer-readable storage medium, for solving the problem of replacement brought forth by the presence of two, a new and an old, contract addresses in the prior art. The present application does not deploy anew a new smart contract under a new contract address, but rather adds a correlation between an old contract address of the old contract and a new contract code of the new contract; because of the chain characteristic between blocks in a blockchain, when calling a smart contract, the correlation is always found in the nearest block, and the smart contract corresponding to the latest contract code is always called, and because only the correlation is modified, the contract address does not undergo any change, obviated is the need for a user to perform a replacement operation, and eliminated from the source is the uncontrollable factor of an address replacement being performed by the user, thus enhancing user experience for the user.

Description

一种智能合约升级方法、装置、区块链节点设备及介质Smart contract upgrade method, device, blockchain node equipment and medium
本申请要求于2019年04月11日提交至中国专利局、申请号为201910290052.X、发明名称为“一种智能合约升级方法、装置、区块链节点设备及介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application requires the priority of the Chinese patent application submitted to the Chinese Patent Office on April 11, 2019, with the application number 201910290052.X and the invention title "A smart contract upgrade method, device, blockchain node equipment and medium" Right, the entire contents of which are incorporated in this application by reference.
技术领域Technical field
本申请涉及区块链技术下的智能合约领域,特别涉及一种智能合约升级方法、装置、区块链节点设备及计算机可读存储介质。This application relates to the field of smart contracts under blockchain technology, and in particular to a smart contract upgrade method, device, blockchain node equipment, and computer-readable storage medium.
背景技术Background technique
随着数据量的增加,传统中心化的数据管理模式暴露出越来越多的问题,单节点故障问题、可拓展性问题、维护问题等等都是制约传统中心化进一步发展的重要问题。因此,为解决中心化带来的这些问题,基于去中心化理念的区块链技术开始逐步进入广大用户的视野。As the amount of data increases, the traditional centralized data management model exposes more and more problems. Single-node failure, scalability, maintenance, etc. are all important issues that restrict the further development of traditional centralized. Therefore, in order to solve these problems caused by centralization, blockchain technology based on the concept of decentralization has gradually entered the field of vision of the majority of users.
区块链技术最初用于记录比特币网络中每一笔比特币的交易,即一种记账机制,而随着技术的发展,以太坊通过嵌入智能合约的方式极大的拓展了区块链技术的应用范围和可以实现的功能,但由于区块链技术的一大特性就是已存储的数据无法完全删除(除非拥有能够在短时间内篡改构成整个区块链网络50%以上的节点设备中已存储数据的能力),导致在智能合约的内容需要升级或修正时,是无法向传统机制下直接替换的。Blockchain technology was originally used to record every bitcoin transaction in the bitcoin network, which is a kind of accounting mechanism. With the development of technology, Ethereum has greatly expanded the blockchain by embedding smart contracts. The scope of application of the technology and the functions that can be achieved, but one of the characteristics of the blockchain technology is that the stored data cannot be completely deleted (unless you have a node device that can tamper with more than 50% of the entire blockchain network in a short time The ability to store data), when the content of the smart contract needs to be upgraded or revised, it cannot be directly replaced under the traditional mechanism.
现有以太坊提供的解决方案:将智能合约的代码逻辑和数据分离的方式来形成两个不同的合约,即逻辑合约和数据合约,以此实现在保持数据不变的同时更换实现逻辑,从而单独实现业务逻辑的升级。但由此产生的问题是:逻辑合约的升级操作实际上首先需要重新部署一个新的逻辑合约在区块链网络上,新逻辑合约和旧逻辑合约各自拥有自己的合约地址,由于合约地址的改变,还需要引导所有可能调用该智能合约的用户修正原先内嵌于应用程序中的合约地址,否则依然会使用旧的合约地址对应的旧智能合约带来,由于对使用者完成合约地址更新的需求非常高,而对使用者 是否完成更新操作的可控程度又不高,因此会对使用者带来较差的使用体验。The existing solution provided by Ethereum: separate the code logic and data of the smart contract to form two different contracts, namely the logic contract and the data contract, so as to realize the replacement of the implementation logic while keeping the data unchanged, thereby The business logic is upgraded separately. But the resulting problem is that the upgrade operation of the logic contract actually first needs to redeploy a new logic contract on the blockchain network. The new logic contract and the old logic contract each have their own contract address. Due to the change of the contract address , It is also necessary to guide all users who may call the smart contract to modify the contract address originally embedded in the application, otherwise the old smart contract corresponding to the old contract address will still be used, due to the need for users to complete the contract address update It is very high, and the degree of control over whether the user completes the update operation is not high, so it will bring a poor user experience to the user.
因此,如何尽可能的解决现有智能合约升级需求中存在的技术缺陷,提供一种更便捷、更可控、在不更新合约地址的基础上完成智能合约升级的方法,是本领域技术人员亟待解决的问题。Therefore, how to solve the technical defects existing in the existing smart contract upgrade requirements as much as possible, and provide a more convenient, more controllable, and complete smart contract upgrade method without updating the contract address is an urgent need for those skilled in the art solved problem.
发明内容Summary of the invention
本申请的目的是提供一种智能合约升级方法、装置、区块链节点设备及计算机可读存储介质,旨在尽可能的解决现有升级智能合约过程中因存在新旧两个不同的合约地址导致使用者需要自行完成新旧合约地址的替换所带来的各种问题。The purpose of this application is to provide a smart contract upgrade method, device, block chain node equipment, and computer readable storage medium, which aims to solve as much as possible the existing process of upgrading smart contracts due to the existence of two different contract addresses. The user needs to complete various problems caused by the replacement of the old and new contract addresses.
为实现上述目的,本申请首先提供了一种智能合约升级方法,包括:In order to achieve the above objectives, this application first provides a smart contract upgrade method, including:
获取智能合约升级请求;Get smart contract upgrade request;
根据所述智能合约升级请求确定被替换的旧智能合约的旧合约地址,并从所述智能合约升级请求中提取得到新智能合约的新合约代码;Determine the old contract address of the replaced old smart contract according to the smart contract upgrade request, and extract the new contract code of the new smart contract from the smart contract upgrade request;
建立所述旧合约地址与所述新合约代码间的对应关系,并将所述对应关系部署在区块链新形成的区块中。Establish a corresponding relationship between the old contract address and the new contract code, and deploy the corresponding relationship in a newly formed block of the blockchain.
可选的,获取智能合约升级请求,包括:Optionally, obtain the smart contract upgrade request, including:
从区块链数据池中获取所述智能合约升级请求。Obtain the smart contract upgrade request from the blockchain data pool.
可选的,在建立所述旧合约地址与所述新合约代码间的对应关系之前,还包括:Optionally, before establishing the correspondence between the old contract address and the new contract code, the method further includes:
验证所述智能合约升级请求是否具有合法性;Verify whether the smart contract upgrade request is legal;
仅当所述智能合约升级请求具有合法性时,执行所述建立所述旧合约地址与所述新合约代码间的对应关系的步骤。Only when the smart contract upgrade request is legal, the step of establishing the correspondence between the old contract address and the new contract code is executed.
可选的,该智能合约升级方法还包括:Optionally, the smart contract upgrade method further includes:
当所述智能合约升级请求经验证不具有合法性时,将所述智能合约升级请求的发起信息发送给部署所述旧智能合约的用户。When the smart contract upgrade request is verified as not having legitimacy, the initiation information of the smart contract upgrade request is sent to the user who deployed the old smart contract.
可选的,验证所述智能合约升级请求是否具有合法性,包括:Optionally, verifying whether the smart contract upgrade request is legal, including:
验证发起所述智能合约升级请求的用户ID与部署所述旧智能合约的用户ID是否一致;Verifying whether the user ID that initiated the smart contract upgrade request is consistent with the user ID that deployed the old smart contract;
若发起所述智能合约升级请求的用户ID与部署所述旧智能合约的用 户ID一致,则判定所述智能合约升级请求具有合法性;If the user ID that initiated the smart contract upgrade request is consistent with the user ID that deployed the old smart contract, it is determined that the smart contract upgrade request is legal;
若发起所述智能合约升级请求的用户ID与部署所述旧智能合约的用户ID不一致,则判定所述智能合约升级请求不具有合法性。If the user ID that initiated the smart contract upgrade request is inconsistent with the user ID that deployed the old smart contract, it is determined that the smart contract upgrade request is not legal.
可选的,验证所述智能合约升级请求是否具有合法性,包括:Optionally, verifying whether the smart contract upgrade request is legal, including:
从所述旧智能合约中提取到升级验证地址列表;其中,所述升级验证地址列表中记录有预设数量的地址;Extract the upgrade verification address list from the old smart contract; wherein a preset number of addresses are recorded in the upgrade verification address list;
从所述智能合约升级请求中提取到与所述新智能合约对应的签名信息;Extracting signature information corresponding to the new smart contract from the smart contract upgrade request;
判断所述签名信息是否能够满足所述升级验证地址列表对记录的地址对应的签名的要求;Judging whether the signature information can meet the requirement of the upgrade verification address list for the signature corresponding to the recorded address;
若满足了所述要求,则判定所述智能合约升级请求具有合法性;If the requirements are met, it is determined that the smart contract upgrade request is legal;
若不满足所述要求,则判定所述智能合约升级请求不具有合法性。If the requirements are not met, it is determined that the smart contract upgrade request does not have legitimacy.
可选的,该智能合约升级方法还包括:Optionally, the smart contract upgrade method further includes:
接收智能合约调用请求;Receive smart contract call request;
根据所述智能合约调用请求确定目标智能合约地址;Determine the target smart contract address according to the smart contract call request;
在部署有包含所述目标智能合约地址的最新区块中确定对应的新合约代码,并执行所述新合约代码来完成所述智能合约调用请求。Determine the corresponding new contract code in the latest block deployed with the target smart contract address, and execute the new contract code to complete the smart contract call request.
为实现上述目的,本申请还提供了一种智能合约升级装置,该装置包括:In order to achieve the above objective, this application also provides a smart contract upgrade device, which includes:
智能合约升级请求获取单元,用于获取智能合约升级请求;The smart contract upgrade request obtaining unit is used to obtain the smart contract upgrade request;
旧合约地址和新合约代码获取单元,用于根据所述智能合约升级请求确定被替换的旧智能合约的旧合约地址,并从所述智能合约升级请求中提取得到新智能合约的新合约代码;The old contract address and the new contract code acquisition unit is used to determine the old contract address of the replaced old smart contract according to the smart contract upgrade request, and extract the new contract code of the new smart contract from the smart contract upgrade request;
对应关系建立及部署单元,用于建立所述旧合约地址与所述新合约代码间的对应关系,并将所述对应关系部署在区块链新形成的区块中。The corresponding relationship establishment and deployment unit is used to establish the corresponding relationship between the old contract address and the new contract code, and deploy the corresponding relationship in the newly formed block of the blockchain.
可选的,所述智能合约升级请求获取单元包括:Optionally, the smart contract upgrade request obtaining unit includes:
区块链数据池获取子单元,用于从所述区块链数据池中获取所述智能合约升级请求。The block chain data pool obtaining subunit is used to obtain the smart contract upgrade request from the block chain data pool.
可选的,该智能合约升级装置还包括:Optionally, the smart contract upgrade device further includes:
合法性验证单元,用于在建立所述旧合约地址与所述新合约代码间的 对应关系之前,验证所述智能合约升级请求是否具有合法性;The legality verification unit is configured to verify whether the smart contract upgrade request is legal before establishing the correspondence between the old contract address and the new contract code;
合法性验证通过执行单元,用于仅当所述智能合约升级请求具有合法性时,执行所述建立所述旧合约地址与所述新合约代码间的对应关系的步骤。The legality verification pass execution unit is configured to execute the step of establishing the correspondence between the old contract address and the new contract code only when the smart contract upgrade request is legal.
可选的,该智能合约升级装置还包括:Optionally, the smart contract upgrade device further includes:
不合法处理单元,用于当所述智能合约升级请求经验证不具有合法性时,将所述智能合约升级请求的发起信息发送给部署所述旧智能合约的用户。The illegal processing unit is configured to send the initiation information of the smart contract upgrade request to the user who deployed the old smart contract when the smart contract upgrade request is verified to be not legal.
可选的,所述合法性验证单元包括:Optionally, the legality verification unit includes:
用户ID一致性验证子单元,用于验证发起所述智能合约升级请求的用户ID与部署所述旧智能合约的用户ID是否一致;The user ID consistency verification subunit is used to verify whether the user ID that initiated the smart contract upgrade request is consistent with the user ID that deployed the old smart contract;
第一合法判定子单元,用于当发起所述智能合约升级请求的用户ID与部署所述旧智能合约的用户ID一致时,判定所述智能合约升级请求具有合法性;The first legality determination subunit is configured to determine that the smart contract upgrade request is legal when the user ID that initiated the smart contract upgrade request is consistent with the user ID that deployed the old smart contract;
第一不合法判定子单元,用于当发起所述智能合约升级请求的用户ID与部署所述旧智能合约的用户ID不一致时,判定所述智能合约升级请求不具有合法性。The first illegality determination subunit is used to determine that the smart contract upgrade request is not legal when the user ID that initiated the smart contract upgrade request is not consistent with the user ID that deployed the old smart contract.
可选的,所述合法性验证单元包括:Optionally, the legality verification unit includes:
升级验证地址列表提取子单元,用于从所述旧智能合约中提取到升级验证地址列表;其中,所述升级验证地址列表中记录有预设数量的地址;The upgrade verification address list extraction subunit is used to extract the upgrade verification address list from the old smart contract; wherein a preset number of addresses are recorded in the upgrade verification address list;
签名信息获取子单元,用于从所述智能合约升级请求中提取到与所述新智能合约对应的签名信息;A signature information acquisition subunit, configured to extract signature information corresponding to the new smart contract from the smart contract upgrade request;
升级所需签名要求满足判断子单元,用于判断所述签名信息是否能够满足所述升级验证地址列表对记录的地址对应的签名的要求;The signature requirement required for the upgrade satisfies the judging subunit, which is used to judge whether the signature information can meet the requirement of the upgrade verification address list for the signature corresponding to the recorded address;
第二合法判定子单元,用于当满足了所述要求时,判定所述智能合约升级请求具有合法性;The second legality determination subunit is used to determine that the smart contract upgrade request is legal when the requirements are met;
第二不合法判定子单元,用于当不满足所述要求时,判定所述智能合约升级请求不具有合法性。The second illegality determination subunit is used to determine that the smart contract upgrade request does not have legality when the requirement is not met.
可选的,该智能合约升级装置还包括:Optionally, the smart contract upgrade device further includes:
智能合约调用请求接收单元,用于接收智能合约调用请求;The smart contract call request receiving unit is used to receive the smart contract call request;
目标智能合约地址确定单元,用于根据所述智能合约调用请求确定目标智能合约地址;The target smart contract address determining unit is configured to determine the target smart contract address according to the smart contract call request;
对应最新合约代码确定及调用单元,用于在部署有包含所述目标智能合约地址的最新区块中确定对应的新合约代码,并执行所述新合约代码来完成所述智能合约调用请求。The corresponding latest contract code determining and invoking unit is used to determine the corresponding new contract code in the latest block deployed and containing the target smart contract address, and execute the new contract code to complete the smart contract invocation request.
为实现上述目的,本申请还进一步提供了一种区块链节点设备,所述区块链节点设备包括存储器、处理器以及总线,所述存储器上存储有可在所述处理器上运行的智能合约升级程序,所述智能合约升级程序被所述总线传输至所述处理器,并在被所述处理器执行时实现如上述内容所描述的智能合约升级方法。In order to achieve the above objective, the present application further provides a blockchain node device, the blockchain node device includes a memory, a processor, and a bus, and the memory stores an intelligence that can run on the processor. A contract upgrade program, where the smart contract upgrade program is transmitted to the processor by the bus, and when executed by the processor, the smart contract upgrade method as described in the above content is implemented.
为实现上述目的,本申请还进一步提供了一种计算机可读存储介质,所述计算机可读存储介质上存储有智能合约升级程序,所述智能合约升级程序可被一个或多个处理器执行,以实现如上述内容所描述的智能合约升级方法。In order to achieve the above objective, this application further provides a computer-readable storage medium on which a smart contract upgrade program is stored, and the smart contract upgrade program can be executed by one or more processors, In order to achieve the smart contract upgrade method described in the above content.
通过本申请提供的智能合约升级方法可以明显看出,为解决现有技术中存在新旧两个合约地址所带来的替换问题,本申请并不会重新为新智能合约部署在一个新合约地址下,而是新增旧智能合约的旧合约地址与新智能合约的新合约代码间的对应关系,由于区块链中各区块间的链式特性,使得在调用智能合约时,总是会在最近的区块中找到该对应关系,因此总是会调用对应于最新合约代码的智能合约,且由于只改变了对应关系,合约地址并未发生改变,因此使用者也无需进行替换操作,从源头上消除了由使用者进行地址替换这一不可控因素,进而提升了使用者的使用体验。From the smart contract upgrade method provided in this application, it is obvious that in order to solve the replacement problem caused by the new and old contract addresses in the prior art, this application will not re-deploy the new smart contract under a new contract address , But to add the correspondence between the old contract address of the old smart contract and the new contract code of the new smart contract. Due to the chain characteristics of each block in the blockchain, the smart contract will always be called in the latest The corresponding relationship is found in the block of, so the smart contract corresponding to the latest contract code is always called, and because only the corresponding relationship is changed, the contract address has not changed, so the user does not need to perform replacement operations, from the source The uncontrollable factor of address replacement by the user is eliminated, thereby improving the user experience.
本申请同时还提供了一种智能合约升级装置、区块链节点设备及计算机可读存储介质,具有上述有益效果,在此不再赘述。This application also provides a smart contract upgrade device, a blockchain node device and a computer-readable storage medium, which have the above-mentioned beneficial effects, and will not be repeated here.
附图说明Description of the drawings
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。In order to more clearly describe the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only It is an embodiment of the present application. For those of ordinary skill in the art, other drawings can be obtained according to the provided drawings without creative work.
图1为本申请实施例提供的一种智能合约升级方法的流程图;Figure 1 is a flowchart of a smart contract upgrade method provided by an embodiment of the application;
图2为本申请实施例提供的另一种智能合约升级方法的流程图;Figure 2 is a flowchart of another smart contract upgrade method provided by an embodiment of the application;
图3为本申请实施例提供的智能合约升级方法中一种基于用户ID的升级请求合法性验证方法的流程图;FIG. 3 is a flowchart of a method for verifying the legitimacy of an upgrade request based on a user ID in the smart contract upgrade method provided by an embodiment of the application;
图4为本申请实施例提供的智能合约升级方法中一种基于签名的升级请求合法性验证方法的流程图;4 is a flowchart of a method for verifying the legality of an upgrade request based on a signature in the smart contract upgrade method provided by the embodiment of the application;
图5为本申请实施例提供的一种智能合约调用方法的流程图;FIG. 5 is a flowchart of a method for invoking a smart contract provided by an embodiment of the application;
图6为本申请实施例提供的一种智能合约升级装置的结构框图;FIG. 6 is a structural block diagram of a smart contract upgrade device provided by an embodiment of the application;
图7为本申请实施例提供的一种区块链节点设备的结构示意图。FIG. 7 is a schematic structural diagram of a blockchain node device provided by an embodiment of the application.
具体实施方式detailed description
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the objectives, technical solutions, and advantages of the present invention clearer, the following further describes the present invention in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present invention, but not to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention.
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, without having to use To describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments described herein can be implemented in an order other than the content illustrated or described herein. In addition, the terms "including" and "having" and any variations of them are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to the clearly listed Those steps or units may include other steps or units that are not clearly listed or are inherent to these processes, methods, products, or equipment.
需要说明的是,在本发明中涉及“第一”、“第二”等的描述仅用于描述目的,而不能理解为指示或暗示其相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。另外,各个实施例之间的技术方案可以相互结合,但是必须是以本领域普通技术人员能够实现为基础,当技术方案的结合出现相互矛盾或无法实现时应当认为这种技术方案的结合不存在,也不在本 发明要求的保护范围之内。It should be noted that the descriptions related to "first", "second", etc. in the present invention are only for descriptive purposes, and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. . Therefore, the features defined with "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but it must be based on what can be achieved by a person of ordinary skill in the art. When the combination of technical solutions is contradictory or cannot be achieved, it should be considered that such a combination of technical solutions does not exist. , Is not within the protection scope of the present invention.
实施例一Example one
请参见图1,图1为本申请实施例提供的一种智能合约升级方法的流程图,其包括以下步骤:Please refer to FIG. 1. FIG. 1 is a flowchart of a smart contract upgrade method provided by an embodiment of the application, which includes the following steps:
S101:获取智能合约升级请求;S101: Obtain a smart contract upgrade request;
本步骤旨在获取到后续用于进行智能合约升级的智能合约升级请求。This step is to obtain the smart contract upgrade request for subsequent smart contract upgrades.
一种包括但不限于的智能合约升级请求获取方式为:从区块链网络中的区块链数据池中获取该智能合约升级请求。由于通常区块链网络被用于存储交易数据,因此该区块链数据池也通常被称为交易数据池。其中,经过每个区块链节点设备上传来的由使用者发起的各种请求都会被汇总至该数据池中,当需要将某个之前已部署在区块链网络上的旧智能合约升级为一个新的智能合约时,升级方就会经由区块链节点设备向区块链网络发起智能合约升级请求,以使得区块链网络能够从区块链数据池中获取到该智能合约升级请求,以响应该智能合约升级请求完成智能合约的升级。One way to obtain the smart contract upgrade request, including but not limited to, is to obtain the smart contract upgrade request from the blockchain data pool in the blockchain network. Since the blockchain network is usually used to store transaction data, the blockchain data pool is also usually called a transaction data pool. Among them, various requests initiated by users uploaded through each blockchain node device will be aggregated into the data pool. When it is necessary to upgrade an old smart contract that has been deployed on the blockchain network to For a new smart contract, the upgrade party will initiate a smart contract upgrade request to the blockchain network through the blockchain node device, so that the blockchain network can obtain the smart contract upgrade request from the blockchain data pool. The smart contract upgrade is completed in response to the smart contract upgrade request.
其中,为了完成智能合约的升级,该智能合约升级请求中通常至少会包括新智能合约的内容(即代码或代码的不同存在形式,例如编译后便于计算机执行的字节码等)和需要被替换、升级的旧智能合约的相关信息(例如最重要的合约地址)。当然,根据实际应用场景下所有可能存在的特殊要求,也可以将诸如进行合法性验证的相关信息、时间戳以及其它用于实现特殊要求的信息或数据以包含于该智能合约升级请求或随该智能合约升级请求一并发送的形式上传至区块链数据池。Among them, in order to complete the upgrade of the smart contract, the smart contract upgrade request usually includes at least the content of the new smart contract (ie code or different forms of code, such as bytecode that is easy to be executed by the computer after compilation, etc.) and needs to be replaced , The relevant information of the upgraded old smart contract (such as the most important contract address). Of course, according to all possible special requirements in actual application scenarios, relevant information such as legality verification, time stamps, and other information or data used to achieve special requirements can also be included in the smart contract upgrade request or with the The smart contract upgrade request is sent together and uploaded to the blockchain data pool.
S102:根据智能合约升级请求确定被替换的旧智能合约的旧合约地址,并从智能合约升级请求中提取得到新智能合约的新合约代码;S102: Determine the old contract address of the replaced old smart contract according to the smart contract upgrade request, and extract the new contract code of the new smart contract from the smart contract upgrade request;
在S101的基础上,本步骤旨在根据智能合约升级请求确定两个参数,其一是新智能合约的合约代码,本步骤及后续将使用“新合约代码”进行指代;其二是与新智能合约对应的已经部署在区块链网络中的需要被升级、被替换的旧智能合约的合约地址,本步骤及后续将使用“旧合约地址”进行指代。On the basis of S101, this step aims to determine two parameters according to the smart contract upgrade request. One is the contract code of the new smart contract. This step and subsequent steps will use the "new contract code" to refer to; the second is the new contract code. The smart contract corresponds to the contract address of the old smart contract that has been deployed in the blockchain network and needs to be upgraded and replaced. This step and subsequent steps will use the "old contract address" to refer to.
为加深理解,将通过举例说明:To deepen understanding, examples will be used to illustrate:
在实际情况下,智能合约的调用是通过用户发起的智能合约调用请求 实现的,这是因为智能合约调用请求中包含有用户需要调用的目标智能合约的地址,即目标合约地址,而每个智能合约在部署至区块链网络中时,会建立合约地址与合约代码间的对应关系,以使得在从智能合约调用请求中提取到目标合约地址后,能够根据该对应关系成功调用到相应的合约代码,并通过执行该合约代码的方式完成该智能合约功能的实现。In actual situations, smart contract calls are implemented through smart contract call requests initiated by users. This is because the smart contract call request contains the address of the target smart contract that the user needs to call, that is, the target contract address, and each smart contract When the contract is deployed to the blockchain network, the corresponding relationship between the contract address and the contract code will be established, so that after the target contract address is extracted from the smart contract call request, the corresponding contract can be successfully called according to the corresponding relationship Code, and implement the smart contract function by executing the contract code.
以Key-Value(键值对)形式来表示就是,合约地址为Key,合约代码为Value,在每个智能合约部署在区块链网络上时,Key和Value间的对应关系就已经得到了建立,本步骤根据智能合约升级请求确定出的一个为新智能合约的Value,一个是旧智能合约的Key,假定Key1表示旧智能合约的合约地址,Value1表示旧智能合约的合约代码,则在未升级之前,合约地址与合约代码间的对应关系为:Key1—Value1。Expressed in the form of Key-Value (key-value pair) that is, the contract address is Key, and the contract code is Value. When each smart contract is deployed on the blockchain network, the correspondence between Key and Value has been established. In this step, one is the value of the new smart contract and the other is the key of the old smart contract. Assuming that Key1 represents the contract address of the old smart contract, and Value1 represents the contract code of the old smart contract, it is not upgraded Before, the corresponding relationship between contract address and contract code was: Key1—Value1.
S103:建立旧合约地址与新合约代码间的对应关系,并将对应关系部署在区块链新形成的区块中。S103: Establish a corresponding relationship between the old contract address and the new contract code, and deploy the corresponding relationship in the newly formed block of the blockchain.
在S102的基础上,本步骤旨在建立旧合约地址与新合约代码间的对应关系,并将该对应关系部署在该区块链最新形成的区块中。沿用上个例子,根据智能合约升级请求确定出的新智能合约的合约代码可以使用Value2表示,因此本步骤所执行的操作为建立Key1与Value2间的对应关系,并将该新对应关系部署在最新形成的区块中,使得用户可以在不需要将自身应用中的Key1替换为Key2的情况下,也可以成功调用到升级后的智能合约代码。On the basis of S102, this step aims to establish the corresponding relationship between the old contract address and the new contract code, and deploy the corresponding relationship in the newly formed block of the blockchain. Following the previous example, the contract code of the new smart contract determined according to the smart contract upgrade request can be represented by Value2, so the operation performed in this step is to establish the correspondence between Key1 and Value2, and deploy the new correspondence in the latest In the formed block, users can successfully call the upgraded smart contract code without replacing Key1 with Key2 in their own applications.
需要说明的是,本申请建立的旧合约地址与新合约代码间的对应关系,是一条对应关系的新增操作,而非像传统的替换操作,只是由于区块链所具有的不可删除特性导致的,但并不会因为Key1同时对应Value1和Value2两个合约地址而出现调用混乱,因为区块链中各区块间的链式关系和原子性,导致在调用一个智能合约时,总是会在存在该对应关系的最近的区块中调用,因此基于新智能合约一定晚于旧智能合约部署在区块链网络上的实际情况,导致新智能合约一定会部署在旧智能合约所在区块之后的区块中,基于此种情况,及时无法修改对应关系、存在一对多的情况,在执行和调用过程中也不会出现问题。It should be noted that the corresponding relationship between the old contract address and the new contract code established in this application is a new operation of the corresponding relationship, rather than a traditional replacement operation, only due to the non-deletable feature of the blockchain Yes, but there will not be call confusion because Key1 corresponds to the two contract addresses of Value1 and Value2 at the same time. Because of the chain relationship and atomicity between the blocks in the blockchain, when a smart contract is called, there will always be The corresponding relationship is called in the nearest block, so based on the fact that the new smart contract must be deployed on the blockchain network later than the old smart contract, the new smart contract must be deployed after the block where the old smart contract is located. In the block, based on this situation, the corresponding relationship cannot be modified in time, there is a one-to-many situation, and there will be no problems in the execution and call process.
进一步的,由于区块链网络中的任何使用者都可以发起智能合约升级 请求,为防止恶意攻击者借助此机制扰乱智能合约发挥正常功能,还可以在新对应关系生效之前加入对智能合约升级请求的合法性验证机制,以通过合法性验证步骤消除上述隐患。根据实际情况的不同,合法性验证可以通过多种具体的方式来实现,例如可以通过判断新旧两个智能合约的发起用户是否为相同的用户来实现,也可以通过签名、公私钥机制等相同或类似的机制来实现,可根据具体情况灵活选择最合适的方式,此处并不做具体限定。Further, since any user in the blockchain network can initiate a smart contract upgrade request, in order to prevent malicious attackers from using this mechanism to disrupt the normal function of the smart contract, it is also possible to add a smart contract upgrade request before the new correspondence takes effect. The legality verification mechanism to eliminate the above hidden dangers through the legality verification steps. Depending on the actual situation, legality verification can be achieved in a variety of specific ways. For example, it can be achieved by judging whether the initiating users of the new and old smart contracts are the same user, or by signing, public and private key mechanisms, etc. A similar mechanism can be implemented, and the most suitable method can be flexibly selected according to the specific situation, and there is no specific limitation here.
通过本申请提供的智能合约升级方法可以明显看出,为解决现有技术中存在新旧两个合约地址所带来的替换问题,本申请并不会重新为新智能合约部署在一个新合约地址下,而是新增旧智能合约的旧合约地址与新智能合约的新合约代码间的对应关系,由于区块链中各区块间的链式特性,使得在调用智能合约时,总是会在最近的区块中找到该对应关系,因此总是会调用对应于最新合约代码的智能合约,且由于只改变了对应关系,合约地址并未发生改变,因此使用者也无需进行替换操作,从源头上消除了由使用者进行地址替换这一不可控因素,进而提升了使用者的使用体验。From the smart contract upgrade method provided in this application, it is obvious that in order to solve the replacement problem caused by the new and old contract addresses in the prior art, this application will not re-deploy the new smart contract under a new contract address , But to add the correspondence between the old contract address of the old smart contract and the new contract code of the new smart contract. Due to the chain characteristics of each block in the blockchain, the smart contract will always be called in the latest The corresponding relationship is found in the block of, so the smart contract corresponding to the latest contract code is always called, and because only the corresponding relationship is changed, the contract address has not changed, so the user does not need to perform replacement operations, from the source The uncontrollable factor of address replacement by the user is eliminated, thereby improving the user experience.
实施例二Example two
请参见图2,图2为本申请实施例提供的另一种智能合约升级方法的流程图,区别于实施例一,本实施例从考虑智能合约升级安全性的角度出发,在实施例一的基础上加入了对智能合约升级请求的合法性验证步骤,并给出了一种具体的实现方法,包括以下步骤:Please refer to Figure 2. Figure 2 is a flowchart of another smart contract upgrade method provided in an embodiment of the application. It is different from Embodiment 1. This embodiment considers the security of smart contract upgrades. On the basis, the legality verification steps for the smart contract upgrade request are added, and a specific implementation method is given, including the following steps:
S201:获取智能合约升级请求;S201: Obtain a smart contract upgrade request;
S202:根据智能合约升级请求确定被替换的旧智能合约的旧合约地址,并从智能合约升级请求中获取新智能合约的新合约代码;S202: Determine the old contract address of the replaced old smart contract according to the smart contract upgrade request, and obtain the new contract code of the new smart contract from the smart contract upgrade request;
S203:验证智能合约升级请求是否具有合法性,如果是则执行S205,否则执行S204;S203: Verify whether the smart contract upgrade request is legal, if yes, execute S205, otherwise execute S204;
本实施例将验证智能合约升级请求是否具有合法性放在了S202之后、S204和S205之前,放在S202之后是因为还需要根据S202步骤获取到的一些参数或数据来实现S203的合法性验证步骤,若不需要执行S202也能够判别该智能合约升级请求是否具有合法性,也可以放在S201之后、S202 之前。In this embodiment, the verification of the validity of the smart contract upgrade request is placed after S202, before S204 and S205, and after S202, because some parameters or data obtained in step S202 are needed to implement the legality verification step of S203. If it is not necessary to execute S202 to determine whether the smart contract upgrade request is legal, it can also be placed after S201 and before S202.
S204:将智能合约升级请求的发起信息发送给部署旧智能合约的用户;S204: Send the initiation information of the smart contract upgrade request to the user who deployed the old smart contract;
本步骤建立在S203的验证结果为该智能合约升级请求不具有合法性的基础上,在此情况下,本实施例提供了一种具体的后续处理方法,即将该智能合约升级请求的发起信息发送给部署旧智能合约的用户,其中,该发起信息中应包含是由哪个用户发起的该智能合约升级请求,通过将这部分信息告知真正拥有旧智能合约升级权限的用户,来告知其有用户试图修改自己已部署的智能合约。进一步的,区块链网络还可以在核实这一行为后,对假冒用户发起警告,严重者可加入黑名单。This step is based on the verification result of S203 that the smart contract upgrade request is not legal. In this case, this embodiment provides a specific follow-up processing method, which is to send the initiation information of the smart contract upgrade request For users deploying old smart contracts, the initiation information should include which user initiated the smart contract upgrade request, and by telling this part of the information to users who have the right to upgrade the old smart contract to inform them that there are users trying Modify the smart contract that you have deployed. Furthermore, the blockchain network can also issue a warning to fake users after verifying this behavior, and the serious ones can be added to the blacklist.
S205:建立旧合约地址与新合约代码间的对应关系,并将对应关系部署在区块链新形成的区块中。S205: Establish a corresponding relationship between the old contract address and the new contract code, and deploy the corresponding relationship in the newly formed block of the blockchain.
本步骤建立在S203的验证结果为该智能合约升级请求具有合法性的基础上,因此将在此基础上开始新增旧合约地址与新合约代码间的对应关系,并完成后续的部署操作。This step is based on the verification result of S203 that the smart contract upgrade request is legal. Therefore, the corresponding relationship between the old contract address and the new contract code will be added on this basis, and subsequent deployment operations will be completed.
实施例三Example three
请参见图3,图3为本申请实施例提供的智能合约升级方法中一种基于用户ID的升级请求合法性验证方法的流程图,在实施例二的基础上,本实施例给出了一种具体如何对智能合约升级请求进行合法性验证的方法,包括如下步骤:Please refer to Figure 3. Figure 3 is a flowchart of a method for verifying the legitimacy of a user ID-based upgrade request in the smart contract upgrade method provided in an embodiment of the application. On the basis of the second embodiment, this embodiment provides a A specific method for verifying the legality of a smart contract upgrade request includes the following steps:
S301:验证发起智能合约升级请求的用户ID与部署旧智能合约的用户ID是否一致,若是则执行S302,否则执行S303;S301: Verify whether the user ID that initiated the smart contract upgrade request is consistent with the user ID that deployed the old smart contract, if yes, execute S302, otherwise execute S303;
S302:判定智能合约升级请求具有合法性;S302: Determine that the smart contract upgrade request is legal;
S303:判定智能合约升级请求不具有合法性。S303: Determine that the smart contract upgrade request is not legal.
通过上述内容可以看出,本申请在此处提供了一种基于用户ID来判别该智能合约升级请求是否具有合法性的方法,即通过判断发起智能合约升级请求的用户与部署旧智能合约的用户是否为同一用户的方式来判断该智能合约升级请求是否具有合法性,因为升级操作往往被限定为还需要原作者来实现,非原作者的升级者通常会被视为仿冒者。需要说明的是,此处所描述的用户ID是一个可用于唯一确定一个区块链用户的特征信息,在不 同的应用场景可以有不同的称呼,例如用户地址、用户识别码、用户特征码等等,在不超出本步骤思想的范围内,应均属于本申请的保护范围。It can be seen from the above content that this application here provides a method for judging whether the smart contract upgrade request is legal based on the user ID, that is, by judging the user who initiated the smart contract upgrade request and the user who deployed the old smart contract Whether it is the same user to determine whether the smart contract upgrade request is legal, because the upgrade operation is often limited to the original author's implementation, and upgraders who are not the original author are usually regarded as counterfeiters. It should be noted that the user ID described here is a feature information that can be used to uniquely identify a blockchain user. It can be called differently in different application scenarios, such as user address, user identification code, user feature code, etc. , Within the scope of the idea of this step, all should belong to the protection scope of this application.
还需要说明的是,基于用户ID的合法性验证方法更适合个人部署用户,即通常不会有其它被认可的用户来进行智能合约升级操作。It should also be noted that the legality verification method based on the user ID is more suitable for individual deployment users, that is, there are usually no other approved users to perform smart contract upgrade operations.
区别于图3所示的适用于个人部署用户的合法性判别方法,本申请还提供了如图4所示的基于用户ID的升级请求合法性验证方法,适合团队部署用户,通过记录有多个地址的升级验证地址列表,可以灵活设定通过合法性验证所需的地址对应签名的数量,使得非旧智能合约的部署用户也可以通过此机制完成智能合约的升级操作,包括如下步骤:Different from the legality judgment method suitable for individual deployment users shown in Figure 3, this application also provides the user ID-based legality verification method for upgrade requests as shown in Figure 4, which is suitable for team deployment users. The address upgrade verification address list can flexibly set the number of address corresponding signatures required to pass legality verification, so that users who deploy non-old smart contracts can also complete smart contract upgrade operations through this mechanism, including the following steps:
S401:从旧智能合约中提取到升级验证地址列表;S401: Extract the upgrade verification address list from the old smart contract;
其中,该升级验证地址列表记录有预设数量的地址,需要说明的是,记录的多个地址适用于在进行升级进行的合法性验证时,查看该智能合约升级请求中是否携带有要求数量或对象的地址给出的签名来完成验证。Among them, the upgrade verification address list records a preset number of addresses. It should be noted that the multiple addresses recorded are suitable for the legality verification of the upgrade. Check whether the smart contract upgrade request carries the required number or The signature given by the address of the object completes the verification.
S402:从智能合约升级请求中提取到与新智能合约对应的签名信息;S402: Extract the signature information corresponding to the new smart contract from the smart contract upgrade request;
本步骤建立在签名信息也包含在智能合约升级请求的基础上。This step is based on the fact that the signature information is also included in the smart contract upgrade request.
S403:判断签名信息是否满足升级验证地址列表对记录的地址对应的签名的要求,若满足则执行S404,否则执行S405;S403: Determine whether the signature information meets the requirements of the upgrade verification address list for the signature corresponding to the recorded address, if it meets the requirements, execute S404, otherwise execute S405;
具体的,该要求可以根据实际情况灵活设定,例如设定需要超过预设数量的地址的签名、需要某些特定地址的签名,更甚可以设定需要记录在升级验证地址列表中的每个地址对应的签名,根据实际情况下所有可能存在的特殊要求,可灵活选择要求的具体表现形式,此处不做具体限定。Specifically, this requirement can be flexibly set according to the actual situation, such as setting the signature of more than the preset number of addresses, the signature of certain specific addresses, and even each item that needs to be recorded in the upgrade verification address list. The signature corresponding to the address can be flexibly selected according to all the special requirements that may exist in the actual situation, and there is no specific limitation here.
S404:判定智能合约升级请求具有合法性;S404: Determine that the smart contract upgrade request is legal;
S405:判定智能合约升级请求不具有合法性。S405: Determine that the smart contract upgrade request is not legal.
本实施例分别通过图3和图4提供了两种适用于不同场景的合法性验证方法,当然,并不是说除这两种方法外就没有其它的实现方案,上述两种方案仅作为针对常见应用场景下的一种可行解决方案存在。This embodiment provides two legality verification methods suitable for different scenarios through Figure 3 and Figure 4 respectively. Of course, it does not mean that there are no other implementation solutions besides these two methods. The above two solutions are only for common A feasible solution exists in the application scenario.
实施例四Example four
请参见图5,图5为本申请实施例提供的一种智能合约调用方法的流程 图,为对应本申请通过上述任意实施例给出的智能合约升级方法后,用户如何通过相同的合约地址调用到新合约代码来完成目标操作的过程,包括如下步骤Please refer to Figure 5. Figure 5 is a flow chart of a smart contract invocation method provided by an embodiment of this application. It shows how the user can invoke the smart contract through the same contract address after the smart contract upgrade method provided in any of the above embodiments corresponding to this application. The process of completing the target operation to the new contract code includes the following steps
S501:接收智能合约调用请求;S501: Receive a smart contract call request;
S502:根据智能合约调用请求确定目标智能合约地址;S502: Determine the target smart contract address according to the smart contract call request;
S503:在部署有包含目标智能合约地址的最新区块中确定对应的新合约代码,并执行新合约代码来完成智能合约调用请求。S503: Determine the corresponding new contract code in the latest block deployed and containing the target smart contract address, and execute the new contract code to complete the smart contract call request.
还需要说明的是,本申请仅针对智能合约运行在区块链服务进程内容的虚拟机中的场景,不针对其它场景。It should also be noted that this application only addresses the scenario where the smart contract runs in the virtual machine of the blockchain service process content, and does not address other scenarios.
因为情况复杂,无法一一列举进行阐述,本领域技术人员应能意识到根据本申请提供的基本方法原理结合实际情况可以存在很多的例子,在不付出足够的创造性劳动下,应均在本申请的保护范围内。Because the situation is complicated, it is impossible to enumerate one by one. Those skilled in the art should be aware that there can be many examples based on the basic method and principle provided in this application combined with the actual situation. Without paying enough creative work, they should all be included in this application. Within the scope of protection.
实施例五Example five
请参见图6,图6为本申请实施例提供的一种智能合约升级装置的结构框图,该装置可以包括:Please refer to FIG. 6. FIG. 6 is a structural block diagram of a smart contract upgrade device provided by an embodiment of the application. The device may include:
智能合约升级请求获取单元100,用于获取智能合约升级请求;The smart contract upgrade request obtaining unit 100 is configured to obtain the smart contract upgrade request;
旧合约地址和新合约代码获取单元200,用于根据智能合约升级请求确定被替换的旧智能合约的旧合约地址,并从智能合约升级请求中提取得到新智能合约的新合约代码;The old contract address and new contract code acquisition unit 200 is used to determine the old contract address of the replaced old smart contract according to the smart contract upgrade request, and extract the new contract code of the new smart contract from the smart contract upgrade request;
对应关系建立及部署单元300,用于建立旧合约地址与新合约代码间的对应关系,并将对应关系部署在区块链新形成的区块中。The correspondence relationship establishment and deployment unit 300 is used to establish the correspondence relationship between the old contract address and the new contract code, and deploy the correspondence relationship in the newly formed block of the blockchain.
其中,该智能合约升级获取单元100可以包括:Wherein, the smart contract upgrade acquiring unit 100 may include:
区块链数据池获取子单元,用于从区块链数据池中获取所述智能合约升级请求。The block chain data pool obtaining subunit is used to obtain the smart contract upgrade request from the block chain data pool.
进一步的,该智能合约升级装置还可以包括:Further, the smart contract upgrade device may also include:
合法性验证单元,用于在建立旧合约地址与新合约代码间的对应关系之前,验证智能合约升级请求是否具有合法性;The legality verification unit is used to verify whether the smart contract upgrade request is legal before establishing the correspondence between the old contract address and the new contract code;
合法性验证通过执行单元,用于仅当智能合约升级请求具有合法性时, 执行建立旧合约地址与新合约代码间的对应关系的步骤。The legality verification passes the execution unit and is used to execute the step of establishing the correspondence between the old contract address and the new contract code only when the smart contract upgrade request is legal.
更进一步的,该智能合约升级装置还可以包括:Furthermore, the smart contract upgrade device may also include:
不合法处理单元,用于当智能合约升级请求经验证不具有合法性时,将智能合约升级请求的发起信息发送给部署旧智能合约的用户。The illegal processing unit is used to send the initiation information of the smart contract upgrade request to the user who deployed the old smart contract when the smart contract upgrade request is verified to be not legal.
其中,该合法性验证单元可以包括:Wherein, the legality verification unit may include:
用户ID一致性验证子单元,用于验证发起智能合约升级请求的用户ID与部署旧智能合约的用户ID是否一致;The user ID consistency verification subunit is used to verify whether the user ID that initiated the smart contract upgrade request is consistent with the user ID that deployed the old smart contract;
第一合法判定子单元,用于当发起智能合约升级请求的用户ID与部署旧智能合约的用户ID一致时,判定智能合约升级请求具有合法性;The first legality determination subunit is used to determine that the smart contract upgrade request is legal when the user ID that initiated the smart contract upgrade request is consistent with the user ID that deployed the old smart contract;
第一不合法判定子单元,用于当发起智能合约升级请求的用户ID与部署旧智能合约的用户ID不一致时,判定智能合约升级请求不具有合法性。The first illegality determination subunit is used to determine that the smart contract upgrade request is not legal when the user ID that initiated the smart contract upgrade request is inconsistent with the user ID that deployed the old smart contract.
其中,该合法性验证单元可以包括:Wherein, the legality verification unit may include:
升级验证地址列表提取子单元,用于从旧智能合约中提取到升级验证地址列表;其中,升级验证地址列表中记录有预设数量的地址;The upgrade verification address list extraction subunit is used to extract the upgrade verification address list from the old smart contract; among them, the upgrade verification address list records a preset number of addresses;
签名信息获取子单元,用于从智能合约升级请求中提取到与新智能合约对应的签名信息;The signature information acquisition subunit is used to extract the signature information corresponding to the new smart contract from the smart contract upgrade request;
升级所需签名要求满足判断子单元,用于判断签名信息是否能够满足升级验证地址列表对记录的地址对应的签名的要求;The signature requirements required for the upgrade meet the judging subunit, which is used to determine whether the signature information can meet the requirements for the signature corresponding to the recorded address in the upgrade verification address list;
第二合法判定子单元,用于当满足了要求时,判定智能合约升级请求具有合法性;The second legality determination subunit is used to determine the legality of the smart contract upgrade request when the requirements are met;
第二不合法判定子单元,用于当不满足要求时,判定智能合约升级请求不具有合法性。The second illegality determination sub-unit is used to determine that the smart contract upgrade request is not legal when the requirements are not met.
进一步的,该智能合约升级装置还可以包括:Further, the smart contract upgrade device may also include:
智能合约调用请求接收单元,用于接收智能合约调用请求;The smart contract call request receiving unit is used to receive the smart contract call request;
目标智能合约地址确定单元,用于根据智能合约调用请求确定目标智能合约地址;The target smart contract address determination unit is used to determine the target smart contract address according to the smart contract call request;
对应最新合约代码确定及调用单元,用于在部署有包含目标智能合约地址的最新区块中确定对应的新合约代码,并执行新合约代码来完成智能合约调用请求。The corresponding latest contract code determination and calling unit is used to determine the corresponding new contract code in the latest block deployed with the target smart contract address, and execute the new contract code to complete the smart contract call request.
本实施例作为与上述方法实施例对应的装置实施例存在,上述各功能 单元也以在上述方法实施例中进行过说明和解释,由于对应于方法实施例,本实施例也相应具有方法实施例的全部有益效果,此处不再一一赘述。This embodiment exists as a device embodiment corresponding to the above method embodiment. The above functional units are also described and explained in the above method embodiment. As it corresponds to the method embodiment, this embodiment also has a method embodiment. All the beneficial effects of, will not be repeated here.
在上文中已经通过一些实施例对如何不需要用户自行替换升级后的新之智能合约的地址也能够通过原合约地址调用新合约代码进行了详细的描述,本申请还提供一种与该方法对应的实体硬件装置,此部分内容原理与方案部分相对应,实现原理的部分此处不再赘述,以下将对该实体硬件装置的硬件组成进行描述,请参见图7,图7为本申请实施例提供的一种区块链节点设备的结构示意图:In the above, some embodiments have been used to describe in detail how to call the new contract code through the original contract address without the need for the user to replace the address of the upgraded new smart contract. This application also provides a method corresponding to this method. The physical hardware device of this part corresponds to the solution part. The implementation principle is not repeated here. The hardware composition of the physical hardware device will be described below. Please refer to Figure 7, which is an embodiment of the application. A schematic diagram of the structure of a blockchain node device provided:
该区块链节点设备400包括存储器410、处理器420以及总线430,存储器410上存储有可在处理器420上运行的智能合约升级程序,该智能合约升级程序通过总线430被传输至处理器420,并在被处理器420执行时可实现如上述实施例所描述的智能合约升级方法中的各步骤。The blockchain node device 400 includes a memory 410, a processor 420, and a bus 430. The memory 410 stores a smart contract upgrade program that can run on the processor 420, and the smart contract upgrade program is transmitted to the processor 420 through the bus 430. , And when executed by the processor 420, each step in the smart contract upgrade method described in the above embodiment can be implemented.
其中,存储器410至少包括一种类型的可读存储介质,可读存储介质包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、磁性存储器、磁盘、光盘等。存储器410在一些实施例中可以是区块链节点设备400的内部存储单元,例如该区块链节点设备400的硬盘。存储器410在另一些实施例中也可以是该区块链节点设备400的外部存储设备,例如该区块链节点设备400上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,存储器410还可以同时由内部存储单元和外部存储设备同时组成。进一步的,存储器410不仅可以用于存储安装于该区块链节点设备400中的各种应用软件和各类数据,还可以用于暂时地存储已经输出或者将要输出的数据。The memory 410 includes at least one type of readable storage medium. The readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), magnetic memory, magnetic disk, and optical disk. The memory 410 may be an internal storage unit of the blockchain node device 400 in some embodiments, such as a hard disk of the blockchain node device 400. In some other embodiments, the memory 410 may also be an external storage device of the blockchain node device 400, such as a plug-in hard disk or a smart media card (SMC) equipped on the blockchain node device 400, Secure Digital (SD) card, Flash Card, etc. Further, the memory 410 may also be composed of an internal storage unit and an external storage device at the same time. Further, the memory 410 can be used not only to store various application software and various data installed in the blockchain node device 400, but also to temporarily store data that has been output or will be output.
处理器420在一些实施例中可以是中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器或其他数据处理芯片,用于运行存储器410中存储的程序代码或处理数据,例如智能合约升级程序等。In some embodiments, the processor 420 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips, and is used to run program codes or process data stored in the memory 410 , Such as smart contract upgrade procedures.
总线430可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。该总线可以分为地址总线、数据总线、控制总线等。为便于表示,图7中仅用一条双向中空指示线表示,但并不表示仅有一根总线 或一种类型的总线。The bus 430 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of presentation, only one bidirectional hollow indicator line is used in Fig. 7, but it does not mean that there is only one bus or one type of bus.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware or any combination thereof. In the several embodiments provided in this application, it should be understood that the disclosed system, device, and method may be implemented in other ways. For example, the device embodiments described above are merely illustrative, for example, the division of units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or integrated. To another system, or some features can be ignored, or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, the functional units in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例中所给出的方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the technical solution of this application essentially or the part that contributes to the existing technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , Including several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method given in each embodiment of the present application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program code .
需要说明的是,上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。并且本文中的术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置、物品或者方 法不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、装置、物品或者方法所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、装置、物品或者方法中还存在另外的相同要素。It should be noted that the sequence numbers of the above-mentioned embodiments of the present invention are only for description, and do not represent the advantages and disadvantages of the embodiments. And the terms "include", "include" or any other variants thereof in this article are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements not only includes those elements, but also includes The other elements listed may also include elements inherent to the process, device, article, or method. If there are no more restrictions, the element defined by the sentence "including a..." does not exclude the existence of other identical elements in the process, device, article or method that includes the element.
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above are only the preferred embodiments of the present invention, and do not limit the scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the description and drawings of the present invention, or directly or indirectly applied to other related technical fields , The same reason is included in the scope of patent protection of the present invention.

Claims (10)

  1. 一种智能合约升级方法,其特征在于,包括:A smart contract upgrade method, characterized in that it includes:
    获取智能合约升级请求;Get smart contract upgrade request;
    根据所述智能合约升级请求确定被替换的旧智能合约的旧合约地址,并从所述智能合约升级请求中提取得到新智能合约的新合约代码;Determine the old contract address of the replaced old smart contract according to the smart contract upgrade request, and extract the new contract code of the new smart contract from the smart contract upgrade request;
    建立所述旧合约地址与所述新合约代码间的对应关系,并将所述对应关系部署在区块链新形成的区块中。Establish a corresponding relationship between the old contract address and the new contract code, and deploy the corresponding relationship in a newly formed block of the blockchain.
  2. 根据权利要求1所述的智能合约升级方法,其特征在于,获取智能合约升级请求,包括:The smart contract upgrade method according to claim 1, wherein obtaining a smart contract upgrade request includes:
    从区块链数据池中提取得到所述智能合约升级请求。The smart contract upgrade request is extracted from the blockchain data pool.
  3. 根据权利要求1所述的智能合约升级方法,其特征在于,在建立所述旧合约地址与所述新合约代码间的对应关系之前,还包括:The smart contract upgrade method according to claim 1, wherein before establishing the correspondence between the old contract address and the new contract code, it further comprises:
    验证所述智能合约升级请求是否具有合法性;Verify whether the smart contract upgrade request is legal;
    仅当所述智能合约升级请求具有合法性时,执行所述建立所述旧合约地址与所述新合约代码间的对应关系的步骤。Only when the smart contract upgrade request is legal, the step of establishing the correspondence between the old contract address and the new contract code is executed.
  4. 根据权利要求3所述的智能合约升级方法,其特征在于,还包括:The smart contract upgrade method according to claim 3, further comprising:
    当所述智能合约升级请求经验证不具有合法性时,将所述智能合约升级请求的发起信息发送给部署所述旧智能合约的用户。When the smart contract upgrade request is verified as not having legitimacy, the initiation information of the smart contract upgrade request is sent to the user who deployed the old smart contract.
  5. 根据权利要求3所述的智能合约升级方法,其特征在于,验证所述智能合约升级请求是否具有合法性,包括:The smart contract upgrade method according to claim 3, characterized in that verifying whether the smart contract upgrade request is legal, comprises:
    验证发起所述智能合约升级请求的用户ID与部署所述旧智能合约的用户ID是否一致;Verifying whether the user ID that initiated the smart contract upgrade request is consistent with the user ID that deployed the old smart contract;
    若发起所述智能合约升级请求的用户ID与部署所述旧智能合约的用户ID一致,则判定所述智能合约升级请求具有合法性;If the user ID that initiated the smart contract upgrade request is consistent with the user ID that deployed the old smart contract, it is determined that the smart contract upgrade request is legal;
    若发起所述智能合约升级请求的用户ID与部署所述旧智能合约的用户ID不一致,则判定所述智能合约升级请求不具有合法性。If the user ID that initiated the smart contract upgrade request is inconsistent with the user ID that deployed the old smart contract, it is determined that the smart contract upgrade request is not legal.
  6. 根据权利要求3所述的智能合约升级方法,其特征在于,验证所述智能合约升级请求是否具有合法性,包括:The smart contract upgrade method according to claim 3, characterized in that verifying whether the smart contract upgrade request is legal, comprises:
    从所述旧智能合约中提取到升级验证地址列表;其中,所述升级验证地址列表中记录有预设数量的地址;Extract the upgrade verification address list from the old smart contract; wherein a preset number of addresses are recorded in the upgrade verification address list;
    从所述智能合约升级请求中提取到与所述新智能合约对应的签名信息;Extracting signature information corresponding to the new smart contract from the smart contract upgrade request;
    判断所述签名信息是否能够满足所述升级验证地址列表对记录的地址对应的签名的要求;Judging whether the signature information can meet the requirement of the upgrade verification address list for the signature corresponding to the recorded address;
    若满足了所述要求,则判定所述智能合约升级请求具有合法性;If the requirements are met, it is determined that the smart contract upgrade request is legal;
    若不满足所述要求,则判定所述智能合约升级请求不具有合法性。If the requirements are not met, it is determined that the smart contract upgrade request does not have legitimacy.
  7. 根据权利要求1至6任一项所述的智能合约升级方法,其特征在于,还包括:The smart contract upgrade method according to any one of claims 1 to 6, characterized in that it further comprises:
    接收智能合约调用请求;Receive smart contract call request;
    根据所述智能合约调用请求确定目标智能合约地址;Determine the target smart contract address according to the smart contract call request;
    在部署有包含所述目标智能合约地址的最新区块中确定对应的新合约代码,并执行所述新合约代码来完成所述智能合约调用请求。Determine the corresponding new contract code in the latest block deployed with the target smart contract address, and execute the new contract code to complete the smart contract call request.
  8. 一种智能合约升级装置,其特征在于,包括:A smart contract upgrade device, characterized in that it includes:
    智能合约升级请求获取单元,用于获取智能合约升级请求;The smart contract upgrade request obtaining unit is used to obtain the smart contract upgrade request;
    旧合约地址和新合约代码获取单元,用于根据所述智能合约升级请求确定被替换的旧智能合约的旧合约地址,并从所述智能合约升级请求中提取得到新智能合约的新合约代码;The old contract address and the new contract code acquisition unit is used to determine the old contract address of the replaced old smart contract according to the smart contract upgrade request, and extract the new contract code of the new smart contract from the smart contract upgrade request;
    对应关系建立及部署单元,用于建立所述旧合约地址与所述新合约代码间的对应关系,并将所述对应关系部署在区块链新形成的区块中。The corresponding relationship establishment and deployment unit is used to establish the corresponding relationship between the old contract address and the new contract code, and deploy the corresponding relationship in the newly formed block of the blockchain.
  9. 一种区块链节点设备,其特征在于,包括:A block chain node device is characterized in that it comprises:
    存储器,用于存储计算机程序;Memory, used to store computer programs;
    处理器,用于执行所述计算机程序时实现如权利要求1至7任一项所述的智能合约升级方法。The processor is configured to implement the smart contract upgrade method according to any one of claims 1 to 7 when executing the computer program.
  10. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至7任一项所述的智能合约升级方法。A computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the smart contract upgrade according to any one of claims 1 to 7 is realized method.
PCT/CN2019/093485 2019-04-11 2019-06-28 Method and device for smart contract upgrade, blockchain node device, and medium WO2020206848A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910290052.XA CN110018840B (en) 2019-04-11 2019-04-11 Intelligent contract upgrading method and device, block chain link point equipment and medium
CN201910290052.X 2019-04-11

Publications (1)

Publication Number Publication Date
WO2020206848A1 true WO2020206848A1 (en) 2020-10-15

Family

ID=67191027

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/093485 WO2020206848A1 (en) 2019-04-11 2019-06-28 Method and device for smart contract upgrade, blockchain node device, and medium

Country Status (2)

Country Link
CN (1) CN110018840B (en)
WO (1) WO2020206848A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113721947A (en) * 2021-07-21 2021-11-30 杭州溪塔科技有限公司 Method and device for upgrading block chain contract original address
CN114168652A (en) * 2021-12-07 2022-03-11 浙商银行股份有限公司 Intelligent contract interaction method, device, equipment and storage medium

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112541756B (en) * 2019-09-20 2023-07-04 上海哔哩哔哩科技有限公司 Block chain contract upgrading method and device, computer equipment and readable storage medium
CN111182527B (en) * 2019-12-27 2022-07-26 深圳市云伽智能技术有限公司 OTA (over the air) firmware upgrading method and device, terminal equipment and storage medium thereof
CN111475777B (en) * 2020-03-09 2023-04-25 上海零数众合信息科技有限公司 Upgrading method of intelligent block chain contracts
CN112162770B (en) * 2020-10-20 2023-11-10 深圳技术大学 Firmware version upgrading method and device for realizing integrity verification based on block chain
CN112527781B (en) * 2020-12-23 2022-07-15 上海万向区块链股份公司 Intelligent contract data migration method and system
CN112631642B (en) * 2020-12-29 2024-06-21 杭州趣链科技有限公司 Intelligent contract upgrading method and device, blockchain node and storage medium
CN112749152A (en) * 2021-01-19 2021-05-04 矩阵元技术(深圳)有限公司 Data migration method and device of intelligent contract and storage medium
CN114880010A (en) * 2022-05-13 2022-08-09 北京微芯感知科技有限公司 Method and device for dynamically updating intelligent contract

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107464148A (en) * 2017-08-23 2017-12-12 众安信息技术服务有限公司 A kind of intelligent contract upgrade method and system based on alliance's chain
CN108170740A (en) * 2017-12-18 2018-06-15 深圳前海微众银行股份有限公司 Data migration method, system and computer readable storage medium
US20180365686A1 (en) * 2017-06-19 2018-12-20 Hitachi, Ltd. Smart contract lifecycle management
CN109272335A (en) * 2018-09-17 2019-01-25 深圳市元征科技股份有限公司 A kind of intelligence contract administration method, system, equipment and computer storage medium
CN109445820A (en) * 2018-10-29 2019-03-08 深圳市元征科技股份有限公司 A kind of intelligence contract upgrade method, system, equipment and computer storage medium
CN109559229A (en) * 2018-11-30 2019-04-02 众安信息技术服务有限公司 The method of the intelligent contract group of update based on block chain

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106709704B (en) * 2016-11-23 2020-04-24 杭州溪塔科技有限公司 Intelligent contract upgrading method based on license chain
US10102265B1 (en) * 2017-04-12 2018-10-16 Vijay K. Madisetti Method and system for tuning blockchain scalability for fast and low-cost payment and transaction processing
CN108881312A (en) * 2018-08-24 2018-11-23 北京京东尚科信息技术有限公司 Intelligent contract upgrade method, system and relevant device and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180365686A1 (en) * 2017-06-19 2018-12-20 Hitachi, Ltd. Smart contract lifecycle management
CN107464148A (en) * 2017-08-23 2017-12-12 众安信息技术服务有限公司 A kind of intelligent contract upgrade method and system based on alliance's chain
CN108170740A (en) * 2017-12-18 2018-06-15 深圳前海微众银行股份有限公司 Data migration method, system and computer readable storage medium
CN109272335A (en) * 2018-09-17 2019-01-25 深圳市元征科技股份有限公司 A kind of intelligence contract administration method, system, equipment and computer storage medium
CN109445820A (en) * 2018-10-29 2019-03-08 深圳市元征科技股份有限公司 A kind of intelligence contract upgrade method, system, equipment and computer storage medium
CN109559229A (en) * 2018-11-30 2019-04-02 众安信息技术服务有限公司 The method of the intelligent contract group of update based on block chain

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113721947A (en) * 2021-07-21 2021-11-30 杭州溪塔科技有限公司 Method and device for upgrading block chain contract original address
CN114168652A (en) * 2021-12-07 2022-03-11 浙商银行股份有限公司 Intelligent contract interaction method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN110018840B (en) 2021-12-03
CN110018840A (en) 2019-07-16

Similar Documents

Publication Publication Date Title
WO2020206848A1 (en) Method and device for smart contract upgrade, blockchain node device, and medium
CN110636492B (en) Handover of mobile service providers using blockchains
CN109561085B (en) Identity verification method based on equipment identification code, server and medium
CN109492378A (en) A kind of auth method based on EIC equipment identification code, server and medium
JP5802848B2 (en) Computer-implemented method, non-temporary computer-readable medium and computer system for identifying Trojanized applications (apps) for mobile environments
US20100229242A1 (en) Program execution control system, program execution control method and computer program for program execution control
WO2017088135A1 (en) Method and device for configuring security indication information
US9208313B2 (en) Protecting anti-malware processes
CN102883324A (en) Security verification method, security verification device and mobile terminal for plugin call in mobile terminal
CN103077345B (en) Based on software authorization method and the system of virtual machine
WO2022073340A1 (en) Mobile terminal application security detection method and system, terminal, and storage medium
CN107679370B (en) Equipment identifier generation method and device
US9465924B2 (en) Apparatus for preventing replay attack and method for preventing replay attack
EP4081917B1 (en) System and method for protecting software licensing information via a trusted platform module
CN109145590A (en) A kind of function hook detection method, detection device and computer-readable medium
CN114398686A (en) Block chain-based file storage method, device, equipment and storage medium
CN109634641B (en) Application program updating method and device, electronic equipment and medium
CN114707147A (en) Service request processing method and electronic equipment
CN113946854A (en) File access control method and device and computer readable storage medium
US20230359741A1 (en) Trusted boot method and apparatus, electronic device, and readable storage medium
US8667604B2 (en) Protection of software on portable medium
WO2019233454A1 (en) Chain code upgrading method and device
US20220405413A1 (en) Information management system, method of controlling the information management system, and storage medium storing program
US20190251532A1 (en) Systems and methods for providing distributed licensing and subscription management
JP2009238155A (en) Data storage system and data storage method

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: 19924245

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: 19924245

Country of ref document: EP

Kind code of ref document: A1