Intelligent contract processing method and device based on block chain, equipment and medium
By updating and checking the initial bytecode of the smart contract, the problems of high threshold, ecological isolation and insufficient tool chain in the development of existing smart contracts are solved, and the security, documentation, efficient deployment and operation of smart contracts are achieved.
Patent Information
- Application Number
- CN202510085518.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-20
- Publication Date
- 2025-05-16
AI Technical Summary
The development of existing smart contracts has problems such as high development threshold, ecological isolation and imperfect tool chain, resulting in low development efficiency and difficulty in debugging.
By obtaining the initial contract bytecode of the smart contract sent by the blockchain, determining the processing fee for the code block and updating the bytecode, performing floating-point number checks and non-whitelist library checks, obtaining the target contract bytecode, and deploying according to the processing fee and target contract bytecode.
It realizes the security, documentation, efficient deployment and operation of smart contracts, lowers the development threshold, and improves development efficiency and system security.
Smart Images

Figure CN120010960A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a blockchain-based smart contract processing method, device, equipment and medium. Background Art
[0002] With the rapid development of blockchain technology, smart contracts, as a tool for automated contract execution, have been widely used in finance, supply chain, evidence storage and anti-counterfeiting and other fields. However, existing smart contracts usually rely on dedicated virtual machines (such as EVM), which have the following main problems: 1. High development threshold: Existing smart contract languages (such as Solidity) require developers to master new syntax and tool chains, and the learning cost is high. 2. Ecological isolation: Lack of rich class library support, developers often need to build complex functions from scratch. 3. Imperfect tool chain: The existing smart contract development environment lacks a complete debugger, performance analysis tools and testing framework, making it difficult to efficiently debug and optimize complex contracts. Summary of the invention
[0003] The present invention provides a blockchain-based smart contract processing method, device, equipment and medium, which solves the problems of high development threshold, ecological isolation and insufficient tool chain in existing smart contract development.
[0004] According to one aspect of the present invention, a blockchain-based smart contract processing method is provided, which is applied to a contract virtual machine. The method includes:
[0005] Obtaining the initial contract bytecode of the smart contract sent by the blockchain; the initial contract bytecode includes contract bytecode and tool bytecode;
[0006] Determine the required handling fee of the code block of the initial contract bytecode, and update the initial contract bytecode according to the required handling fee to obtain a new contract bytecode;
[0007] Perform floating point check and non-whitelist library check on the new contract bytecode respectively to obtain the target contract bytecode;
[0008] The smart contract is deployed according to the required handling fee and the target contract bytecode.
[0009] According to another aspect of the present invention, a blockchain-based smart contract processing method is provided, which is applied to a blockchain and includes:
[0010] Obtain a contract deployment request initiated by a blockchain client, and decode the contract deployment request to obtain an initial contract bytecode of the smart contract; the initial contract bytecode includes a contract class bytecode and a tool class bytecode;
[0011] The initial contract bytecode is sent to the contract virtual machine, so that the contract virtual machine deploys the smart contract according to the initial contract bytecode.
[0012] According to another aspect of the present invention, there is provided a blockchain-based smart contract processing device, which is configured in a contract virtual machine and includes:
[0013] The first contract bytecode acquisition module is used to acquire the initial contract bytecode of the smart contract sent by the blockchain; the initial contract bytecode includes contract bytecode and tool bytecode;
[0014] A contract bytecode update module, used to determine the required handling fee of the code block of the initial contract bytecode, and update the initial contract bytecode according to the required handling fee to obtain a new contract bytecode;
[0015] A contract bytecode checking module, used to perform floating point check and non-whitelist library check on the new contract bytecode to obtain the target contract bytecode;
[0016] A contract deployment module is used to deploy the smart contract according to the required handling fee and the target contract bytecode.
[0017] According to another aspect of the present invention, there is provided a blockchain-based smart contract processing device, which is configured on a blockchain and includes:
[0018] The second contract bytecode acquisition module is used to obtain the contract deployment request initiated by the blockchain client, and decode the contract deployment request to obtain the initial contract bytecode of the smart contract; the initial contract bytecode includes contract class bytecode and tool class bytecode;
[0019] A contract deployment module is used to send the initial contract bytecode to the contract virtual machine so that the contract virtual machine deploys the smart contract according to the initial contract bytecode.
[0020] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0021] at least one processor; and
[0022] a memory communicatively connected to the at least one processor; wherein,
[0023] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the blockchain-based smart contract processing method described in any embodiment of the present invention.
[0024] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the blockchain-based smart contract processing method described in any embodiment of the present invention when executed.
[0025] The technical solution of the embodiment of the present invention is to obtain the initial contract bytecode of the smart contract sent by the blockchain; the initial contract bytecode includes the contract class bytecode and the tool class bytecode; determine the required handling fee of the code block of the initial contract bytecode, and update the initial contract bytecode according to the required handling fee to obtain the new contract bytecode; perform floating point check and non-whitelist library check on the new contract bytecode respectively to obtain the target contract bytecode; deploy the smart contract according to the required handling fee and the target contract bytecode. The above technical solution can safely deploy the smart contract to the blockchain, so that the smart contract can run safely, documented and efficiently in the blockchain environment.
[0026] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0028] Figure 1 is a flowchart of a blockchain-based smart contract processing method provided according to an embodiment of the present invention;
[0029] Figure 2 is a flowchart of a blockchain-based smart contract processing method provided according to an embodiment of the present invention;
[0030] Figure 3 It is an interactive diagram of a blockchain-based smart contract processing process provided according to an embodiment of the present invention;
[0031] Figure 4 It is a structural diagram of a smart contract processing device based on blockchain provided according to an embodiment of the present invention;
[0032] Figure 5 It is a structural diagram of a smart contract processing device based on blockchain provided according to an embodiment of the present invention;
[0033] Figure 6It is a structural schematic diagram of an electronic device for implementing the blockchain-based smart contract processing method of an embodiment of the present invention. DETAILED DESCRIPTION
[0034] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0035] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof 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 those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0036] In addition, it should be noted that the collection, storage, use, processing, transmission, provision and disclosure of relevant data such as smart contracts involved in the technical solution of the present invention are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0037] Figure 1 This is a flowchart of a blockchain-based smart contract processing method provided by an embodiment of the present invention. This embodiment can be applied to how to deploy and call smart contracts in a blockchain, etc. The method can be executed by a smart contract processing device of a blockchain, which can be implemented in the form of hardware and / or software. The device can be configured in an electronic device that carries the smart contract processing function of the blockchain, such as a contract virtual machine, where the contract virtual machine is a Java contract virtual machine. Figure 1 As shown, the method includes:
[0038] S110. Obtain the initial contract bytecode of the smart contract sent by the blockchain.
[0039] Among them, smart contracts are written in Java language. Developers write smart contracts in Java language, and the code can directly call some standard libraries and third-party libraries (except random number, file system and network related libraries); after the writing is completed, the contract code of the written smart contract is packaged through the compilation and packaging tool to obtain a Jar package; the Jar package is deployed to the blockchain through blockchain tools such as blockchain clients such as software development kit sdk.
[0040] The so-called initial contract bytecode refers to the contract code of the smart contract obtained by the blockchain; optionally, the initial contract bytecode includes contract class bytecode and tool class bytecode; among which, the contract class bytecode refers to the bytecode contained in the contract code of the smart contract; the tool class bytecode refers to the tool class bytecode involved in the contract code of the smart contract.
[0041] Specifically, after the blockchain receives the smart contract deployment request initiated by the blockchain client, it decodes the contract deployment request to obtain the initial contract bytecode of the smart contract, and sends the initial contract bytecode to the Java contract virtual machine; accordingly, the Java contract virtual machine obtains the initial contract bytecode of the smart contract.
[0042] S120. Determine the required handling fee of the code block of the initial contract bytecode, and update the initial contract bytecode according to the required handling fee to obtain a new contract bytecode.
[0043] The code blocks are separated by curly braces, that is, one curly brace in the bytecode is one code block. The so-called required handling fee refers to the handling fee such as Gas that needs to be consumed during the execution of the code block of the smart contract's contract bytecode in the blockchain. The so-called new contract bytecode refers to the new contract bytecode obtained after adding the code block to the initial contract bytecode.
[0044] Specifically, the Java ASM library can be used to access the initial contract bytecode. For each initial contract bytecode, the handling fee required for the code block of the bytecode during execution is calculated, and then the code requiring the handling fee is inserted at the front of the code block in the initial contract bytecode to obtain a new contract bytecode.
[0045] S130. Perform floating point check and non-whitelist library check on the new contract bytecode respectively to obtain the target contract bytecode.
[0046] Among them, floating point check refers to checking whether there are instruction codes for floating point related operations in the new contract bytecode. The so-called non-whitelist library check refers to checking whether there are uncertain data such as random numbers, system files and network-related libraries in the new contract bytecode or loaded; among them, non-whitelist libraries include at least one of random numbers, file systems and network-related libraries. The so-called target contract bytecode refers to the secure contract bytecode that meets the requirements of blockchain deployment.
[0047] An optional method is to perform floating point check and non-whitelist library check on the new contract bytecode respectively to obtain the target contract bytecode, including: finding whether there are floating point operation instructions in the new contract bytecode, and finding whether there are non-whitelist libraries in the new contract bytecode; if there are no floating point operation instructions and non-whitelist libraries, the new contract bytecode is used as the target contract bytecode.
[0048] Specifically, use the ASM library to access the new contract bytecode. If instructions related to floating-point operations appear in the bytecode, a deployment failure status code is returned immediately. If no instructions related to floating-point operations appear in the bytecode, continue to use the custom class loader to load the contract class in the new contract bytecode. If a non-whitelist class library is loaded, a deployment failure status code is returned immediately. If the non-whitelist class library is not loaded, the new contract bytecode is used as the target contract bytecode.
[0049] It is understandable that since different machines have different decimal point precision for floating-point numbers, if there are floating-point numbers in the contract bytecode, the results of floating-point operations on different machines will be different, causing consensus problems in the blockchain. Therefore, there must be no floating-point operation-related instructions in smart contracts, which can ensure the safe deployment of contracts. At the same time, non-whitelist libraries will also cause security issues in smart contract processing in the blockchain. Therefore, a non-whitelist library check is performed in the contract bytecode of the smart contract before deployment, which can ensure the safe deployment and call of smart contracts in the blockchain and ensure the security of the blockchain.
[0050] S140. Deploy the smart contract according to the required handling fee and the target contract bytecode.
[0051] An optional method is to initialize the smart contract according to the target contract bytecode; during the contract initialization process, determine whether the remaining handling fee on the chain meets the required handling fee; if so, continue to initialize the smart contract to achieve smart contract deployment. Specifically, run the target contract bytecode of the smart contract to initialize the smart contract. During the initialization process, determine whether the remaining handling fee on the chain meets the required handling fee of the code block in the target contract bytecode of the smart contract. If so, continue to initialize the smart contract, that is, continue to run the target contract bytecode. After the initialization is successful, the smart contract deployment is completed; if not, the execution of the smart contract is terminated immediately, and a deployment failure status code is returned indicating that the contract deployment failed due to insufficient handling fees on the chain. After the initialization is successful, that is, after the deployment is successful, the contract deployment result and the target contract bytecode are returned to the blockchain.
[0052] It is understandable that by judging whether the on-chain transaction fee meets the transaction fee required by the contract code of the smart contract during operation, it is possible to avoid infinite loop execution of the contract and prevent the contract from consuming memory infinitely.
[0053] The technical solution of the embodiment of the present invention is to obtain the initial contract bytecode of the smart contract sent by the blockchain; the initial contract bytecode includes the contract class bytecode and the tool class bytecode; determine the required handling fee of the code block of the initial contract bytecode, and update the initial contract bytecode according to the required handling fee to obtain the new contract bytecode; perform floating point check and non-whitelist library check on the new contract bytecode respectively to obtain the target contract bytecode; deploy the smart contract according to the required handling fee and the target contract bytecode. The above technical solution can safely deploy the smart contract to the blockchain, so that the smart contract can run safely, documented and efficiently in the blockchain environment.
[0054] On the basis of the above embodiment, as an optional method of the present invention, after the smart contract is deployed according to the required handling fee and the target contract bytecode, it also includes: obtaining the contract call request sent by the blockchain; decoding the transaction data to obtain the contract method and parameters of the smart contract; and calling the smart contract using a custom class loader according to the contract method and parameters.
[0055] Among them, the contract call request refers to a request to call a smart contract, including transaction data and the target contract bytecode of the smart contract; among them, transaction data refers to the data involved in a specific business transaction.
[0056] Specifically, when a transaction is triggered, the contract call request sent by the blockchain is obtained, the transaction data in the contract call request is decoded to obtain the contract method and parameters of the smart contract, and the custom class loader is used to call the smart contract according to the contract method and parameters, that is, the smart contract is executed according to the contract method and parameters. After the smart contract is executed, the contract call result of the smart contract is returned to the blockchain.
[0057] It should be noted that after the smart contract is deployed, the smart contract is cached and recorded as a contract object in the cache. After obtaining a contract call request, the contract object corresponding to the smart contract is obtained from the cache, and the smart contract is executed according to the contract method and parameters. In this way, when the Java contract virtual machine deploys a smart contract, a contract object is created, which can improve system performance and avoid repeated object calls, that is, it can be called multiple times after being deployed once.
[0058] Figure 2 This is a flowchart of a blockchain-based smart contract processing method provided according to an embodiment of the present invention. This embodiment can be applied to how to deploy and call smart contracts in a blockchain, etc. The method can be executed by a blockchain smart contract processing device, which can be implemented in the form of hardware and / or software. The device can be configured in an electronic device that carries the blockchain smart contract processing function, such as a blockchain. Figure 2 As shown, the method includes:
[0059] S210. Obtain a contract deployment request initiated by a blockchain client, and decode the contract deployment request to obtain an initial contract bytecode of the smart contract.
[0060] The blockchain client may be a software development kit (sdk). The contract deployment request refers to a request for deploying a smart contract, and the contract deployment request includes the initial contract bytecode of the smart contract, etc.
[0061] The so-called initial contract bytecode refers to the contract code of the smart contract obtained by the blockchain; optionally, the initial contract bytecode includes contract class bytecode and tool class bytecode; among which, the contract class bytecode refers to the bytecode contained in the contract code of the smart contract; the tool class bytecode refers to the tool class bytecode involved in the contract code of the smart contract.
[0062] Specifically, a user can initiate a contract deployment request to the blockchain through a blockchain client; accordingly, the blockchain obtains the contract deployment request initiated by the blockchain client, decodes the contract deployment request, and obtains the initial contract bytecode of the smart contract.
[0063] S220. Send the initial contract bytecode to the contract virtual machine so that the contract virtual machine deploys the smart contract according to the initial contract bytecode.
[0064] Specifically, the blockchain sends the initial contract bytecode to the contract virtual machine. Correspondingly, the contract virtual machine deploys the smart contract according to the initial contract bytecode, that is, determines the required handling fee of the code block of the initial contract bytecode, and updates the initial contract bytecode according to the required handling fee to obtain the new contract bytecode, performs floating point check and non-whitelist library check on the new contract bytecode, obtains the target contract bytecode, and deploys the smart contract according to the required handling fee and the target contract bytecode. After the deployment is completed, the contract deployment result returned by the contract virtual machine is obtained, and the deployment receipt of the contract deployment request is returned to the blockchain client.
[0065] The technical solution provided by the embodiment of the present invention obtains the contract deployment request initiated by the blockchain client and decodes the contract deployment request to obtain the initial contract bytecode of the smart contract; the initial contract bytecode includes the contract class bytecode and the tool class bytecode; the initial contract bytecode is sent to the contract virtual machine so that the contract virtual machine deploys the smart contract according to the initial contract bytecode. The above technical solution can safely deploy the smart contract to the blockchain, so that the smart contract can run safely, documented and efficiently in the blockchain environment.
[0066] On the basis of the above embodiment, as an optional implementation mode of the present invention, after the initial contract bytecode is sent to the contract virtual machine so that the contract virtual machine deploys the smart contract according to the initial contract bytecode, it also includes: obtaining a contract call request initiated by the blockchain client, and decoding the contract call request to obtain transaction data; the transaction data includes the contract method and parameters of the smart contract; obtaining the target contract bytecode of the smart contract; sending the transaction data and the target contract bytecode to the contract virtual machine to call the smart contract.
[0067] Among them, the contract call request refers to a request for calling a smart contract; it includes transaction data and the target contract bytecode of the smart contract; among them, transaction data refers to the data involved in a specific business transaction.
[0068] Specifically, the user initiates a contract call request to the blockchain through the blockchain client; accordingly, the blockchain decodes the contract call request to obtain transaction data and obtains the target contract bytecode of the smart contract; the transaction data and the target contract bytecode are sent to the contract virtual machine to call the smart contract.
[0069] Furthermore, the contract execution results of the smart contract can be broadcast to message subscribers through the event mechanism.
[0070] Figure 3It is an interactive diagram of a blockchain-based smart contract processing process provided according to an embodiment of the present invention. In this embodiment, the blockchain-based smart contract processing method is implemented by the blockchain client SDK, blockchain chain and Java contract virtual machine. The specific interaction process is as follows Figure 3 shown.
[0071] Figure 4 This is a schematic diagram of the structure of a blockchain-based smart contract processing device provided according to an embodiment of the present invention. This embodiment can be applied to how to deploy and call smart contracts in a blockchain, etc. The method can be executed by a blockchain smart contract processing device, which can be implemented in the form of hardware and / or software. The device can be configured in an electronic device that carries the blockchain's smart contract processing function, such as a contract virtual machine, where the contract virtual machine is a Java contract virtual machine. Figure 4 As shown, the device comprises:
[0072] The first contract bytecode acquisition module 310 is used to acquire the initial contract bytecode of the smart contract sent by the blockchain; the initial contract bytecode includes contract bytecode and tool bytecode;
[0073] The contract bytecode update module 320 is used to determine the required handling fee of the code block of the initial contract bytecode, and update the initial contract bytecode according to the required handling fee to obtain a new contract bytecode;
[0074] The contract bytecode checking module 330 is used to perform floating point check and non-whitelist library check on the new contract bytecode to obtain the target contract bytecode;
[0075] The contract deployment module 340 is used to deploy the smart contract according to the required handling fee and the target contract bytecode.
[0076] The technical solution of the embodiment of the present invention is to obtain the initial contract bytecode of the smart contract sent by the blockchain; the initial contract bytecode includes the contract class bytecode and the tool class bytecode; determine the required handling fee of the code block of the initial contract bytecode, and update the initial contract bytecode according to the required handling fee to obtain the new contract bytecode; perform floating point check and non-whitelist library check on the new contract bytecode respectively to obtain the target contract bytecode; deploy the smart contract according to the required handling fee and the target contract bytecode. The above technical solution can safely deploy the smart contract to the blockchain, so that the smart contract can run safely, documented and efficiently in the blockchain environment.
[0077] Optionally, the contract bytecode checking module 330 is specifically used for:
[0078] Check whether there are floating point operation instructions in the new contract bytecode, and check whether there are non-whitelist libraries in the new contract bytecode; where non-whitelist libraries include at least one of random number, file system, and network-related libraries;
[0079] If there are no floating-point operation instructions and non-whitelist libraries, the new contract bytecode will be used as the target contract bytecode.
[0080] Optionally, the contract deployment module 340 is specifically used for:
[0081] Initialize the smart contract according to the target contract bytecode;
[0082] During the contract initialization process, determine whether the remaining transaction fees on the chain meet the required transaction fees; if so, continue to initialize the smart contract to implement smart contract deployment.
[0083] The blockchain-based smart contract processing device provided in the embodiment of the present invention can execute the blockchain-based smart contract processing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0084] Figure 5 This is a schematic diagram of the structure of a blockchain-based smart contract processing device according to an embodiment of the present invention. This embodiment can be applied to how to deploy and call smart contracts in a blockchain, etc. The method can be executed by a blockchain smart contract processing device, which can be implemented in the form of hardware and / or software. The device can be configured in an electronic device that carries the blockchain smart contract processing function, such as a blockchain. Figure 5 As shown, the device comprises:
[0085] The second contract bytecode acquisition module 410 is used to obtain the contract deployment request initiated by the blockchain client, and decode the contract deployment request to obtain the initial contract bytecode of the smart contract; the initial contract bytecode includes the contract class bytecode and the tool class bytecode;
[0086] The contract deployment module 420 is used to send the initial contract bytecode to the contract virtual machine so that the contract virtual machine deploys the smart contract according to the initial contract bytecode.
[0087] The technical solution provided by the embodiment of the present invention obtains the contract deployment request initiated by the blockchain client and decodes the contract deployment request to obtain the initial contract bytecode of the smart contract; the initial contract bytecode includes the contract class bytecode and the tool class bytecode; the initial contract bytecode is sent to the contract virtual machine so that the contract virtual machine deploys the smart contract according to the initial contract bytecode. The above technical solution can safely deploy the smart contract to the blockchain, so that the smart contract can run safely, documented and efficiently in the blockchain environment.
[0088] Optionally, the device further includes a contract calling module, which is used to:
[0089] Send the initial contract bytecode to the contract virtual machine so that after the initial contract bytecode of the contract virtual machine deploys the smart contract, obtain the contract call request initiated by the blockchain client, and decode the contract call request to obtain transaction data; the transaction data includes the contract method and parameters of the smart contract;
[0090] Get the target contract bytecode of the smart contract;
[0091] Send the transaction data and target contract bytecode to the contract virtual machine to call the smart contract.
[0092] The blockchain-based smart contract processing device provided in the embodiment of the present invention can execute the blockchain-based smart contract processing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0093] According to an embodiment of the present invention, the present invention also provides an electronic device, a readable storage medium and a computer program product.
[0094] Figure 6 It is a structural schematic diagram of an electronic device that implements the blockchain-based smart contract processing method of an embodiment of the present invention. Figure 6 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0095] like Figure 6As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0096] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0097] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a blockchain-based smart contract processing method.
[0098] In some embodiments, the blockchain-based smart contract processing method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the blockchain-based smart contract processing method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the blockchain-based smart contract processing method in any other appropriate manner (e.g., by means of firmware).
[0099] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0100] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0101] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0102] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0103] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0104] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0105] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0106] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A smart contract processing method based on blockchain, characterized in that: Applied to a contract virtual machine, the method includes: Obtaining the initial contract bytecode of the smart contract sent by the blockchain; the initial contract bytecode includes contract bytecode and tool bytecode; Determine the required handling fee of the code block of the initial contract bytecode, and update the initial contract bytecode according to the required handling fee to obtain a new contract bytecode; Perform floating point check and non-whitelist library check on the new contract bytecode respectively to obtain the target contract bytecode; The smart contract is deployed according to the required handling fee and the target contract bytecode.
2. The method according to claim 1, characterized in that Perform floating point check and non-whitelist library check on the new contract bytecode respectively to obtain the target contract bytecode, including: Check whether there are floating point operation instructions in the new contract bytecode, and check whether there are non-whitelist libraries in the new contract bytecode; wherein the non-whitelist libraries include at least one of random number, file system and network related libraries; If there are no floating point operation instructions and non-whitelist libraries, the new contract bytecode is used as the target contract bytecode.
3. The method according to claim 1, characterized in that Deploying the smart contract according to the required handling fee and the target contract bytecode includes: Initialize the smart contract according to the target contract bytecode; During the contract initialization process, it is determined whether the remaining handling fee on the chain meets the required handling fee; if so, the smart contract is initialized to implement the smart contract deployment.
4. The method according to claim 1, characterized in that: After the smart contract is deployed according to the required handling fee and the target contract bytecode, the method further includes: Obtaining a contract call request sent by the blockchain; the contract call request includes transaction data and a target contract bytecode of the smart contract; Decoding the transaction data to obtain the contract method and parameters of the smart contract; According to the contract method and parameters, a custom class loader is used to call the smart contract.
5. A blockchain-based smart contract processing method, characterized in that: Applied to blockchain, the method includes: Obtain a contract deployment request initiated by a blockchain client, and decode the contract deployment request to obtain an initial contract bytecode of the smart contract; the initial contract bytecode includes a contract class bytecode and a tool class bytecode; The initial contract bytecode is sent to the contract virtual machine, so that the contract virtual machine deploys the smart contract according to the initial contract bytecode.
6. The method according to claim 5, characterized in that After sending the initial contract bytecode to the contract virtual machine so that the contract virtual machine deploys the smart contract according to the initial contract bytecode, the method further includes: Obtaining a contract call request initiated by the blockchain client, and decoding the contract call request to obtain transaction data; the transaction data includes the contract method and parameters of the smart contract; Obtain the target contract bytecode of the smart contract; The transaction data and the target contract bytecode are sent to the contract virtual machine to call the smart contract.
7. A smart contract processing device based on blockchain, characterized in that: Configured in the contract virtual machine, the device includes: The first contract bytecode acquisition module is used to acquire the initial contract bytecode of the smart contract sent by the blockchain; the initial contract bytecode includes contract bytecode and tool bytecode; A contract bytecode update module, used to determine the required handling fee of the code block of the initial contract bytecode, and update the initial contract bytecode according to the required handling fee to obtain a new contract bytecode; A contract bytecode checking module, used to perform floating point check and non-whitelist library check on the new contract bytecode to obtain the target contract bytecode; A contract deployment module is used to deploy the smart contract according to the required handling fee and the target contract bytecode.
8. A smart contract processing device based on blockchain, characterized in that: Configured in a blockchain, the device includes: The second contract bytecode acquisition module is used to obtain the contract deployment request initiated by the blockchain client, and decode the contract deployment request to obtain the initial contract bytecode of the smart contract; the initial contract bytecode includes contract class bytecode and tool class bytecode; A contract deployment module is used to send the initial contract bytecode to the contract virtual machine so that the contract virtual machine deploys the smart contract according to the initial contract bytecode.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the blockchain-based smart contract processing method described in any one of claims 1-4 or claims 5-6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the processor to implement the blockchain-based smart contract processing method described in any one of claims 1-4 or claims 5-6 when executed.